VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.c@ 58130

Last change on this file since 58130 was 58130, checked in by vboxsync, 9 years ago

x11/vboxvideo: More file header fixes. (Doxygen expected a file name (optional) after @file, not $Id:$. No blank lines after @file line.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 54.6 KB
Line 
1/* $Id: vboxvideo.c 58130 2015-10-08 22:31:55Z vboxsync $ */
2/** @file
3 * Linux Additions X11 graphics driver
4 */
5
6/*
7 * Copyright (C) 2006-2013 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 * --------------------------------------------------------------------
17 *
18 * This code is based on the X.Org VESA driver with the following copyrights:
19 *
20 * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
21 * Copyright 2008 Red Hat, Inc.
22 * Copyright 2012 Red Hat, Inc.
23 *
24 * and the following permission notice (not all original sourse files include
25 * the last paragraph):
26 *
27 * Permission is hereby granted, free of charge, to any person obtaining a
28 * copy of this software and associated documentation files (the "Software"),
29 * to deal in the Software without restriction, including without limitation
30 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
31 * and/or sell copies of the Software, and to permit persons to whom the
32 * Software is furnished to do so, subject to the following conditions:
33 *
34 * The above copyright notice and this permission notice shall be included in
35 * all copies or substantial portions of the Software.
36 *
37 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
40 * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
41 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
42 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
43 * SOFTWARE.
44 *
45 * Except as contained in this notice, the name of Conectiva Linux shall
46 * not be used in advertising or otherwise to promote the sale, use or other
47 * dealings in this Software without prior written authorization from
48 * Conectiva Linux.
49 *
50 * Authors: Paulo César Pereira de Andrade <[email protected]>
51 * David Dawes <[email protected]>
52 * Adam Jackson <[email protected]>
53 * Dave Airlie <[email protected]>
54 */
55
56#include "vboxvideo.h"
57#include <VBox/VBoxGuest.h>
58#include <VBox/VBoxGuestLib.h>
59#include <VBox/Hardware/VBoxVideoVBE.h>
60#include "version-generated.h"
61#include "product-generated.h"
62#include "revision-generated.h"
63
64/* Basic definitions and functions needed by all drivers. */
65#include "xf86.h"
66/* For video memory mapping. */
67#include "xf86_OSproc.h"
68#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6
69/* PCI resources. */
70# include "xf86Resources.h"
71#endif
72/* Generic server linear frame-buffer APIs. */
73#include "fb.h"
74/* Colormap and visual handling. */
75#include "micmap.h"
76#include "xf86cmap.h"
77/* ShadowFB support */
78#include "shadowfb.h"
79/* VGA hardware functions for setting and restoring text mode */
80#include "vgaHW.h"
81#ifdef VBOX_DRI
82# include "xf86drm.h"
83# include "xf86drmMode.h"
84#endif
85#ifdef VBOXVIDEO_13
86/* X.org 1.3+ mode setting */
87# define _HAVE_STRING_ARCH_strsep /* bits/string2.h, __strsep_1c. */
88# include "xf86Crtc.h"
89# include "xf86Modes.h"
90/* For xf86RandR12GetOriginalVirtualSize(). */
91# include "xf86RandR12.h"
92#endif
93/* For setting the root window property. */
94#include "property.h"
95#include "X11/Xatom.h"
96
97#ifdef XORG_7X
98# include <stdlib.h>
99# include <string.h>
100#endif
101
102/* Mandatory functions */
103
104static const OptionInfoRec * VBOXAvailableOptions(int chipid, int busid);
105static void VBOXIdentify(int flags);
106#ifndef PCIACCESS
107static Bool VBOXProbe(DriverPtr drv, int flags);
108#else
109static Bool VBOXPciProbe(DriverPtr drv, int entity_num,
110 struct pci_device *dev, intptr_t match_data);
111#endif
112static Bool VBOXPreInit(ScrnInfoPtr pScrn, int flags);
113static Bool VBOXScreenInit(ScreenPtr pScreen, int argc, char **argv);
114static Bool VBOXEnterVT(ScrnInfoPtr pScrn);
115static void VBOXLeaveVT(ScrnInfoPtr pScrn);
116static Bool VBOXCloseScreen(ScreenPtr pScreen);
117static Bool VBOXSaveScreen(ScreenPtr pScreen, int mode);
118static Bool VBOXSwitchMode(ScrnInfoPtr pScrn, DisplayModePtr pMode);
119static void VBOXAdjustFrame(ScrnInfoPtr pScrn, int x, int y);
120static void VBOXFreeScreen(ScrnInfoPtr pScrn);
121static void VBOXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int mode,
122 int flags);
123
124/* locally used functions */
125static Bool VBOXMapVidMem(ScrnInfoPtr pScrn);
126static void VBOXUnmapVidMem(ScrnInfoPtr pScrn);
127static void VBOXSaveMode(ScrnInfoPtr pScrn);
128static void VBOXRestoreMode(ScrnInfoPtr pScrn);
129static void setSizesAndCursorIntegration(ScrnInfoPtr pScrn, bool fScreenInitTime);
130
131#ifndef XF86_SCRN_INTERFACE
132# define xf86ScreenToScrn(pScreen) xf86Screens[(pScreen)->myNum]
133# define xf86ScrnToScreen(pScrn) screenInfo.screens[(pScrn)->scrnIndex]
134#endif
135
136static inline void VBOXSetRec(ScrnInfoPtr pScrn)
137{
138 if (!pScrn->driverPrivate)
139 {
140 VBOXPtr pVBox = (VBOXPtr)xnfcalloc(sizeof(VBOXRec), 1);
141 pScrn->driverPrivate = pVBox;
142#if defined(VBOXVIDEO_13) && defined(RT_OS_LINUX)
143 pVBox->fdACPIDevices = -1;
144#endif
145 }
146}
147
148enum GenericTypes
149{
150 CHIP_VBOX_GENERIC
151};
152
153#ifdef PCIACCESS
154static const struct pci_id_match vbox_device_match[] = {
155 {
156 VBOX_VENDORID, VBOX_DEVICEID, PCI_MATCH_ANY, PCI_MATCH_ANY,
157 0, 0, 0
158 },
159
160 { 0, 0, 0 },
161};
162#endif
163
164/* Supported chipsets */
165static SymTabRec VBOXChipsets[] =
166{
167 {VBOX_DEVICEID, "vbox"},
168 {-1, NULL}
169};
170
171static PciChipsets VBOXPCIchipsets[] = {
172 { VBOX_DEVICEID, VBOX_DEVICEID, RES_SHARED_VGA },
173 { -1, -1, RES_UNDEFINED },
174};
175
176/*
177 * This contains the functions needed by the server after loading the
178 * driver module. It must be supplied, and gets added the driver list by
179 * the Module Setup function in the dynamic case. In the static case a
180 * reference to this is compiled in, and this requires that the name of
181 * this DriverRec be an upper-case version of the driver name.
182 */
183
184#ifdef XORG_7X
185_X_EXPORT
186#endif
187DriverRec VBOXVIDEO = {
188 VBOX_VERSION,
189 VBOX_DRIVER_NAME,
190 VBOXIdentify,
191#ifdef PCIACCESS
192 NULL,
193#else
194 VBOXProbe,
195#endif
196 VBOXAvailableOptions,
197 NULL,
198 0,
199#ifdef XORG_7X
200 NULL,
201#endif
202#ifdef PCIACCESS
203 vbox_device_match,
204 VBOXPciProbe
205#endif
206};
207
208/* No options for now */
209static const OptionInfoRec VBOXOptions[] = {
210 { -1, NULL, OPTV_NONE, {0}, FALSE }
211};
212
213#ifndef XORG_7X
214/*
215 * List of symbols from other modules that this module references. This
216 * list is used to tell the loader that it is OK for symbols here to be
217 * unresolved providing that it hasn't been told that they haven't been
218 * told that they are essential via a call to xf86LoaderReqSymbols() or
219 * xf86LoaderReqSymLists(). The purpose is this is to avoid warnings about
220 * unresolved symbols that are not required.
221 */
222static const char *fbSymbols[] = {
223 "fbPictureInit",
224 "fbScreenInit",
225 NULL
226};
227
228static const char *shadowfbSymbols[] = {
229 "ShadowFBInit2",
230 NULL
231};
232
233static const char *ramdacSymbols[] = {
234 "xf86DestroyCursorInfoRec",
235 "xf86InitCursor",
236 "xf86CreateCursorInfoRec",
237 NULL
238};
239
240static const char *vgahwSymbols[] = {
241 "vgaHWFreeHWRec",
242 "vgaHWGetHWRec",
243 "vgaHWGetIOBase",
244 "vgaHWGetIndex",
245 "vgaHWRestore",
246 "vgaHWSave",
247 "vgaHWSetStdFuncs",
248 NULL
249};
250#endif /* !XORG_7X */
251
252/** Resize the virtual framebuffer. */
253static Bool adjustScreenPixmap(ScrnInfoPtr pScrn, int width, int height)
254{
255 ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
256 VBOXPtr pVBox = VBOXGetRec(pScrn);
257 int adjustedWidth = pScrn->bitsPerPixel == 16 ? (width + 1) & ~1 : width;
258 int cbLine = adjustedWidth * pScrn->bitsPerPixel / 8;
259 PixmapPtr pPixmap;
260
261 TRACE_LOG("width=%d, height=%d\n", width, height);
262 VBVXASSERT(width >= 0 && height >= 0, ("Invalid negative width (%d) or height (%d)\n", width, height));
263 if (pScreen == NULL) /* Not yet initialised. */
264 return TRUE;
265 pPixmap = pScreen->GetScreenPixmap(pScreen);
266 VBVXASSERT(pPixmap != NULL, ("Failed to get the screen pixmap.\n"));
267 TRACE_LOG("pPixmap=%p adjustedWidth=%d height=%d pScrn->depth=%d pScrn->bitsPerPixel=%d cbLine=%d pVBox->base=%p pPixmap->drawable.width=%d pPixmap->drawable.height=%d\n",
268 pPixmap, adjustedWidth, height, pScrn->depth, pScrn->bitsPerPixel, cbLine, pVBox->base, pPixmap->drawable.width,
269 pPixmap->drawable.height);
270 if ( adjustedWidth != pPixmap->drawable.width
271 || height != pPixmap->drawable.height)
272 {
273 if ( adjustedWidth > VBOX_VIDEO_MAX_VIRTUAL || height > VBOX_VIDEO_MAX_VIRTUAL
274 || (unsigned)cbLine * (unsigned)height >= pVBox->cbFBMax)
275 {
276 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
277 "Virtual framebuffer %dx%d too large. For information, video memory: %u Kb.\n",
278 adjustedWidth, height, (unsigned) pVBox->cbFBMax / 1024);
279 return FALSE;
280 }
281 if (pScrn->vtSema)
282 vbvxClearVRAM(pScrn, ((size_t)pScrn->virtualX) * pScrn->virtualY * (pScrn->bitsPerPixel / 8),
283 ((size_t)adjustedWidth) * height * (pScrn->bitsPerPixel / 8));
284 pScreen->ModifyPixmapHeader(pPixmap, adjustedWidth, height, pScrn->depth, pScrn->bitsPerPixel, cbLine, pVBox->base);
285 }
286 pScrn->displayWidth = pScrn->virtualX = adjustedWidth;
287 pScrn->virtualY = height;
288#ifdef VBOX_DRI_OLD
289 if (pVBox->useDRI)
290 VBOXDRIUpdateStride(pScrn, pVBox);
291#endif
292 return TRUE;
293}
294
295/** Set a video mode to the hardware, RandR 1.1 version. Since we no longer do
296 * virtual frame buffers, adjust the screen pixmap dimensions to match. The
297 * "override" parameters are for when we received a mode hint while switched to
298 * a virtual terminal. In this case VBoxClient will have told us about the
299 * mode, but not yet been able to do a mode switch using RandR. We solve this
300 * by setting the requested mode to the host but keeping the virtual frame-
301 * buffer matching what the X server expects. */
302static void setModeRandR11(ScrnInfoPtr pScrn, DisplayModePtr pMode, bool fScreenInitTime, bool fEnterVTTime,
303 int cXOverRide, int cYOverRide)
304{
305 VBOXPtr pVBox = VBOXGetRec(pScrn);
306 struct vbvxFrameBuffer frameBuffer = { 0, 0, pMode->HDisplay, pMode->VDisplay, pScrn->bitsPerPixel};
307 int cXPhysical = cXOverRide > 0 ? min(cXOverRide, pMode->HDisplay) : pMode->HDisplay;
308 int cYPhysical = cYOverRide > 0 ? min(cYOverRide, pMode->VDisplay) : pMode->VDisplay;
309
310 pVBox->pScreens[0].aScreenLocation.cx = pMode->HDisplay;
311 pVBox->pScreens[0].aScreenLocation.cy = pMode->VDisplay;
312 if (fScreenInitTime)
313 {
314 /* The screen structure is not fully set up yet, so do not touch it. */
315 pScrn->displayWidth = pScrn->virtualX = pMode->HDisplay;
316 pScrn->virtualY = pMode->VDisplay;
317 }
318 else
319 {
320 xf86ScrnToScreen(pScrn)->width = pMode->HDisplay;
321 xf86ScrnToScreen(pScrn)->height = pMode->VDisplay;
322 /* This prevents a crash in CentOS 3. I was unable to debug it to
323 * satisfaction, partly due to the lack of symbols. My guess is that
324 * pScrn->ModifyPixmapHeader() expects certain things to be set up when
325 * it sees pScrn->vtSema set to true which are not quite done at this
326 * point of the VT switch. */
327 if (fEnterVTTime)
328 pScrn->vtSema = FALSE;
329 adjustScreenPixmap(pScrn, pMode->HDisplay, pMode->VDisplay);
330 if (fEnterVTTime)
331 pScrn->vtSema = TRUE;
332 }
333 if (pMode->HDisplay != 0 && pMode->VDisplay != 0 && pScrn->vtSema)
334 vbvxSetMode(pScrn, 0, cXPhysical, cYPhysical, 0, 0, true, true, &frameBuffer);
335 pScrn->currentMode = pMode;
336}
337
338#ifdef VBOXVIDEO_13
339/* X.org 1.3+ mode-setting support ******************************************/
340
341/** Set a video mode to the hardware, RandR 1.2 version. If this is the first
342 * screen, re-set the current mode for all others (the offset for the first
343 * screen is always treated as zero by the hardware, so all other screens need
344 * to be changed to compensate for any changes!). The mode to set is taken
345 * from the X.Org Crtc structure. */
346static void setModeRandR12(ScrnInfoPtr pScrn, unsigned cScreen)
347{
348 VBOXPtr pVBox = VBOXGetRec(pScrn);
349 unsigned i;
350 struct vbvxFrameBuffer frameBuffer = { pVBox->pScreens[0].paCrtcs->x, pVBox->pScreens[0].paCrtcs->y, pScrn->virtualX,
351 pScrn->virtualY, pScrn->bitsPerPixel };
352 unsigned cFirst = cScreen;
353 unsigned cLast = cScreen != 0 ? cScreen + 1 : pVBox->cScreens;
354 int originalX, originalY;
355
356 /* Check that this code cannot trigger the resizing bug in X.Org Server 1.3.
357 * See the work-around in ScreenInit. */
358 xf86RandR12GetOriginalVirtualSize(pScrn, &originalX, &originalY);
359 VBVXASSERT(originalX == VBOX_VIDEO_MAX_VIRTUAL && originalY == VBOX_VIDEO_MAX_VIRTUAL, ("OriginalSize=%dx%d",
360 originalX, originalY));
361 for (i = cFirst; i < cLast; ++i)
362 if (pVBox->pScreens[i].paCrtcs->mode.HDisplay != 0 && pVBox->pScreens[i].paCrtcs->mode.VDisplay != 0 && pScrn->vtSema)
363 vbvxSetMode(pScrn, i, pVBox->pScreens[i].paCrtcs->mode.HDisplay, pVBox->pScreens[i].paCrtcs->mode.VDisplay,
364 pVBox->pScreens[i].paCrtcs->x, pVBox->pScreens[i].paCrtcs->y, pVBox->pScreens[i].fPowerOn,
365 pVBox->pScreens[i].paOutputs->status == XF86OutputStatusConnected, &frameBuffer);
366}
367
368/** Wrapper around setModeRandR12() to avoid exposing non-obvious semantics.
369 */
370static void setAllModesRandR12(ScrnInfoPtr pScrn)
371{
372 setModeRandR12(pScrn, 0);
373}
374
375/* For descriptions of these functions and structures, see
376 hw/xfree86/modes/xf86Crtc.h and hw/xfree86/modes/xf86Modes.h in the
377 X.Org source tree. */
378
379static Bool vbox_config_resize(ScrnInfoPtr pScrn, int cw, int ch)
380{
381 VBOXPtr pVBox = VBOXGetRec(pScrn);
382 Bool rc;
383 unsigned i;
384
385 TRACE_LOG("width=%d, height=%d\n", cw, ch);
386 rc = adjustScreenPixmap(pScrn, cw, ch);
387 /* Power-on all screens (the server expects this) and set the new pitch to them. */
388 for (i = 0; i < pVBox->cScreens; ++i)
389 pVBox->pScreens[i].fPowerOn = true;
390 setAllModesRandR12(pScrn);
391 vbvxSetSolarisMouseRange(cw, ch);
392 return rc;
393}
394
395static const xf86CrtcConfigFuncsRec VBOXCrtcConfigFuncs = {
396 vbox_config_resize
397};
398
399static void
400vbox_crtc_dpms(xf86CrtcPtr crtc, int mode)
401{
402 ScrnInfoPtr pScrn = crtc->scrn;
403 VBOXPtr pVBox = VBOXGetRec(pScrn);
404 unsigned cDisplay = (uintptr_t)crtc->driver_private;
405
406 TRACE_LOG("mode=%d\n", mode);
407 pVBox->pScreens[cDisplay].fPowerOn = (mode != DPMSModeOff);
408 setModeRandR12(pScrn, cDisplay);
409}
410
411static Bool
412vbox_crtc_lock (xf86CrtcPtr crtc)
413{ (void) crtc; return FALSE; }
414
415
416/* We use this function to check whether the X server owns the active virtual
417 * terminal before attempting a mode switch, since the RandR extension isn't
418 * very dilligent here, which can mean crashes if we are unlucky. This is
419 * not the way it the function is intended - it is meant for reporting modes
420 * which the hardware can't handle. I hope that this won't confuse any clients
421 * connecting to us. */
422static Bool
423vbox_crtc_mode_fixup (xf86CrtcPtr crtc, DisplayModePtr mode,
424 DisplayModePtr adjusted_mode)
425{ (void) crtc; (void) mode; (void) adjusted_mode; return TRUE; }
426
427static void
428vbox_crtc_stub (xf86CrtcPtr crtc)
429{ (void) crtc; }
430
431static void
432vbox_crtc_mode_set (xf86CrtcPtr crtc, DisplayModePtr mode,
433 DisplayModePtr adjusted_mode, int x, int y)
434{
435 (void) mode;
436 VBOXPtr pVBox = VBOXGetRec(crtc->scrn);
437 unsigned cDisplay = (uintptr_t)crtc->driver_private;
438
439 TRACE_LOG("name=%s, HDisplay=%d, VDisplay=%d, x=%d, y=%d\n", adjusted_mode->name,
440 adjusted_mode->HDisplay, adjusted_mode->VDisplay, x, y);
441 pVBox->pScreens[cDisplay].fPowerOn = true;
442 pVBox->pScreens[cDisplay].aScreenLocation.cx = adjusted_mode->HDisplay;
443 pVBox->pScreens[cDisplay].aScreenLocation.cy = adjusted_mode->VDisplay;
444 pVBox->pScreens[cDisplay].aScreenLocation.x = x;
445 pVBox->pScreens[cDisplay].aScreenLocation.y = y;
446 setModeRandR12(crtc->scrn, cDisplay);
447}
448
449static void
450vbox_crtc_gamma_set (xf86CrtcPtr crtc, CARD16 *red,
451 CARD16 *green, CARD16 *blue, int size)
452{ (void) crtc; (void) red; (void) green; (void) blue; (void) size; }
453
454static void *
455vbox_crtc_shadow_allocate (xf86CrtcPtr crtc, int width, int height)
456{ (void) crtc; (void) width; (void) height; return NULL; }
457
458static const xf86CrtcFuncsRec VBOXCrtcFuncs = {
459 .dpms = vbox_crtc_dpms,
460 .save = NULL, /* These two are never called by the server. */
461 .restore = NULL,
462 .lock = vbox_crtc_lock,
463 .unlock = NULL, /* This will not be invoked if lock returns FALSE. */
464 .mode_fixup = vbox_crtc_mode_fixup,
465 .prepare = vbox_crtc_stub,
466 .mode_set = vbox_crtc_mode_set,
467 .commit = vbox_crtc_stub,
468 .gamma_set = vbox_crtc_gamma_set,
469 .shadow_allocate = vbox_crtc_shadow_allocate,
470 .shadow_create = NULL, /* These two should not be invoked if allocate
471 returns NULL. */
472 .shadow_destroy = NULL,
473 .set_cursor_colors = NULL, /* We are still using the old cursor API. */
474 .set_cursor_position = NULL,
475 .show_cursor = NULL,
476 .hide_cursor = NULL,
477 .load_cursor_argb = NULL,
478 .destroy = vbox_crtc_stub
479};
480
481static void
482vbox_output_stub (xf86OutputPtr output)
483{ (void) output; }
484
485static void
486vbox_output_dpms (xf86OutputPtr output, int mode)
487{
488 (void)output; (void)mode;
489}
490
491static int
492vbox_output_mode_valid (xf86OutputPtr output, DisplayModePtr mode)
493{
494 return MODE_OK;
495}
496
497static Bool
498vbox_output_mode_fixup (xf86OutputPtr output, DisplayModePtr mode,
499 DisplayModePtr adjusted_mode)
500{ (void) output; (void) mode; (void) adjusted_mode; return TRUE; }
501
502static void
503vbox_output_mode_set (xf86OutputPtr output, DisplayModePtr mode,
504 DisplayModePtr adjusted_mode)
505{ (void) output; (void) mode; (void) adjusted_mode; }
506
507/* A virtual monitor is always connected. */
508static xf86OutputStatus
509vbox_output_detect (xf86OutputPtr output)
510{
511 ScrnInfoPtr pScrn = output->scrn;
512 VBOXPtr pVBox = VBOXGetRec(pScrn);
513 uint32_t iScreen = (uintptr_t)output->driver_private;
514 return pVBox->pScreens[iScreen].afConnected
515 ? XF86OutputStatusConnected : XF86OutputStatusDisconnected;
516}
517
518static DisplayModePtr vbox_output_add_mode(VBOXPtr pVBox, DisplayModePtr *pModes, const char *pszName, int x, int y,
519 Bool isPreferred, Bool isUserDef)
520{
521 TRACE_LOG("pszName=%s, x=%d, y=%d\n", pszName ? pszName : "(null)", x, y);
522 DisplayModePtr pMode = xnfcalloc(1, sizeof(DisplayModeRec));
523 int cRefresh = 60;
524
525 pMode->status = MODE_OK;
526 /* We don't ask the host whether it likes user defined modes,
527 * as we assume that the user really wanted that mode. */
528 pMode->type = isUserDef ? M_T_USERDEF : M_T_BUILTIN;
529 if (isPreferred)
530 pMode->type |= M_T_PREFERRED;
531 /* Older versions of VBox only support screen widths which are a multiple
532 * of 8 */
533 if (pVBox->fAnyX)
534 pMode->HDisplay = x;
535 else
536 pMode->HDisplay = x & ~7;
537 pMode->HSyncStart = pMode->HDisplay + 2;
538 pMode->HSyncEnd = pMode->HDisplay + 4;
539 pMode->HTotal = pMode->HDisplay + 6;
540 pMode->VDisplay = y;
541 pMode->VSyncStart = pMode->VDisplay + 2;
542 pMode->VSyncEnd = pMode->VDisplay + 4;
543 pMode->VTotal = pMode->VDisplay + 6;
544 pMode->Clock = pMode->HTotal * pMode->VTotal * cRefresh / 1000; /* kHz */
545 if (NULL == pszName) {
546 xf86SetModeDefaultName(pMode);
547 } else {
548 pMode->name = xnfstrdup(pszName);
549 }
550 *pModes = xf86ModesAdd(*pModes, pMode);
551 return pMode;
552}
553
554static DisplayModePtr
555vbox_output_get_modes (xf86OutputPtr output)
556{
557 unsigned cIndex = 0;
558 DisplayModePtr pModes = NULL;
559 ScrnInfoPtr pScrn = output->scrn;
560 VBOXPtr pVBox = VBOXGetRec(pScrn);
561
562 TRACE_ENTRY();
563 uint32_t iScreen = (uintptr_t)output->driver_private;
564 vbox_output_add_mode(pVBox, &pModes, NULL,
565 RT_CLAMP(pVBox->pScreens[iScreen].aPreferredSize.cx, VBOX_VIDEO_MIN_SIZE, VBOX_VIDEO_MAX_VIRTUAL),
566 RT_CLAMP(pVBox->pScreens[iScreen].aPreferredSize.cy, VBOX_VIDEO_MIN_SIZE, VBOX_VIDEO_MAX_VIRTUAL),
567 TRUE, FALSE);
568 vbox_output_add_mode(pVBox, &pModes, NULL, 2560, 1600, FALSE, FALSE);
569 vbox_output_add_mode(pVBox, &pModes, NULL, 2560, 1440, FALSE, FALSE);
570 vbox_output_add_mode(pVBox, &pModes, NULL, 2048, 1536, FALSE, FALSE);
571 vbox_output_add_mode(pVBox, &pModes, NULL, 1920, 1600, FALSE, FALSE);
572 vbox_output_add_mode(pVBox, &pModes, NULL, 1920, 1080, FALSE, FALSE);
573 vbox_output_add_mode(pVBox, &pModes, NULL, 1680, 1050, FALSE, FALSE);
574 vbox_output_add_mode(pVBox, &pModes, NULL, 1600, 1200, FALSE, FALSE);
575 vbox_output_add_mode(pVBox, &pModes, NULL, 1400, 1050, FALSE, FALSE);
576 vbox_output_add_mode(pVBox, &pModes, NULL, 1280, 1024, FALSE, FALSE);
577 vbox_output_add_mode(pVBox, &pModes, NULL, 1024, 768, FALSE, FALSE);
578 vbox_output_add_mode(pVBox, &pModes, NULL, 800, 600, FALSE, FALSE);
579 vbox_output_add_mode(pVBox, &pModes, NULL, 640, 480, FALSE, FALSE);
580 TRACE_EXIT();
581 return pModes;
582}
583
584static const xf86OutputFuncsRec VBOXOutputFuncs = {
585 .create_resources = vbox_output_stub,
586 .dpms = vbox_output_dpms,
587 .save = NULL, /* These two are never called by the server. */
588 .restore = NULL,
589 .mode_valid = vbox_output_mode_valid,
590 .mode_fixup = vbox_output_mode_fixup,
591 .prepare = vbox_output_stub,
592 .commit = vbox_output_stub,
593 .mode_set = vbox_output_mode_set,
594 .detect = vbox_output_detect,
595 .get_modes = vbox_output_get_modes,
596#ifdef RANDR_12_INTERFACE
597 .set_property = NULL,
598#endif
599 .destroy = vbox_output_stub
600};
601#endif /* VBOXVIDEO_13 */
602
603/* Module loader interface */
604static MODULESETUPPROTO(vboxSetup);
605
606static XF86ModuleVersionInfo vboxVersionRec =
607{
608 VBOX_DRIVER_NAME,
609 VBOX_VENDOR,
610 MODINFOSTRING1,
611 MODINFOSTRING2,
612#ifdef XORG_7X
613 XORG_VERSION_CURRENT,
614#else
615 XF86_VERSION_CURRENT,
616#endif
617 1, /* Module major version. Xorg-specific */
618 0, /* Module minor version. Xorg-specific */
619 1, /* Module patchlevel. Xorg-specific */
620 ABI_CLASS_VIDEODRV, /* This is a video driver */
621 ABI_VIDEODRV_VERSION,
622 MOD_CLASS_VIDEODRV,
623 {0, 0, 0, 0}
624};
625
626/*
627 * This data is accessed by the loader. The name must be the module name
628 * followed by "ModuleData".
629 */
630#ifdef XORG_7X
631_X_EXPORT
632#endif
633XF86ModuleData vboxvideoModuleData = { &vboxVersionRec, vboxSetup, NULL };
634
635static pointer
636vboxSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor)
637{
638 static Bool Initialised = FALSE;
639
640 if (!Initialised)
641 {
642 Initialised = TRUE;
643#ifdef PCIACCESS
644 xf86AddDriver(&VBOXVIDEO, Module, HaveDriverFuncs);
645#else
646 xf86AddDriver(&VBOXVIDEO, Module, 0);
647#endif
648#ifndef XORG_7X
649 LoaderRefSymLists(fbSymbols,
650 shadowfbSymbols,
651 ramdacSymbols,
652 vgahwSymbols,
653 NULL);
654#endif
655 xf86Msg(X_CONFIG, "Load address of symbol \"VBOXVIDEO\" is %p\n",
656 (void *)&VBOXVIDEO);
657 return (pointer)TRUE;
658 }
659
660 if (ErrorMajor)
661 *ErrorMajor = LDR_ONCEONLY;
662 return (NULL);
663}
664
665
666static const OptionInfoRec *
667VBOXAvailableOptions(int chipid, int busid)
668{
669 return (VBOXOptions);
670}
671
672static void
673VBOXIdentify(int flags)
674{
675 xf86PrintChipsets(VBOX_NAME, "guest driver for VirtualBox", VBOXChipsets);
676}
677
678#ifndef XF86_SCRN_INTERFACE
679# define SCRNINDEXAPI(pfn) pfn ## Index
680static Bool VBOXScreenInitIndex(int scrnIndex, ScreenPtr pScreen, int argc,
681 char **argv)
682{ return VBOXScreenInit(pScreen, argc, argv); }
683
684static Bool VBOXEnterVTIndex(int scrnIndex, int flags)
685{ (void) flags; return VBOXEnterVT(xf86Screens[scrnIndex]); }
686
687static void VBOXLeaveVTIndex(int scrnIndex, int flags)
688{ (void) flags; VBOXLeaveVT(xf86Screens[scrnIndex]); }
689
690static Bool VBOXCloseScreenIndex(int scrnIndex, ScreenPtr pScreen)
691{ (void) scrnIndex; return VBOXCloseScreen(pScreen); }
692
693static Bool VBOXSwitchModeIndex(int scrnIndex, DisplayModePtr pMode, int flags)
694{ (void) flags; return VBOXSwitchMode(xf86Screens[scrnIndex], pMode); }
695
696static void VBOXAdjustFrameIndex(int scrnIndex, int x, int y, int flags)
697{ (void) flags; VBOXAdjustFrame(xf86Screens[scrnIndex], x, y); }
698
699static void VBOXFreeScreenIndex(int scrnIndex, int flags)
700{ (void) flags; VBOXFreeScreen(xf86Screens[scrnIndex]); }
701# else
702# define SCRNINDEXAPI(pfn) pfn
703#endif /* XF86_SCRN_INTERFACE */
704
705static void setScreenFunctions(ScrnInfoPtr pScrn, xf86ProbeProc pfnProbe)
706{
707 pScrn->driverVersion = VBOX_VERSION;
708 pScrn->driverName = VBOX_DRIVER_NAME;
709 pScrn->name = VBOX_NAME;
710 pScrn->Probe = pfnProbe;
711 pScrn->PreInit = VBOXPreInit;
712 pScrn->ScreenInit = SCRNINDEXAPI(VBOXScreenInit);
713 pScrn->SwitchMode = SCRNINDEXAPI(VBOXSwitchMode);
714 pScrn->AdjustFrame = SCRNINDEXAPI(VBOXAdjustFrame);
715 pScrn->EnterVT = SCRNINDEXAPI(VBOXEnterVT);
716 pScrn->LeaveVT = SCRNINDEXAPI(VBOXLeaveVT);
717 pScrn->FreeScreen = SCRNINDEXAPI(VBOXFreeScreen);
718}
719
720/*
721 * One of these functions is called once, at the start of the first server
722 * generation to do a minimal probe for supported hardware.
723 */
724
725#ifdef PCIACCESS
726static Bool
727VBOXPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
728 intptr_t match_data)
729{
730 ScrnInfoPtr pScrn;
731
732 TRACE_ENTRY();
733 pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, VBOXPCIchipsets,
734 NULL, NULL, NULL, NULL, NULL);
735 if (pScrn != NULL) {
736 VBOXPtr pVBox;
737
738 VBOXSetRec(pScrn);
739 pVBox = VBOXGetRec(pScrn);
740 if (!pVBox)
741 return FALSE;
742 setScreenFunctions(pScrn, NULL);
743 pVBox->pciInfo = dev;
744 }
745
746 TRACE_LOG("returning %s\n", BOOL_STR(pScrn != NULL));
747 return (pScrn != NULL);
748}
749#endif
750
751#ifndef PCIACCESS
752static Bool
753VBOXProbe(DriverPtr drv, int flags)
754{
755 Bool foundScreen = FALSE;
756 int numDevSections;
757 GDevPtr *devSections;
758
759 /*
760 * Find the config file Device sections that match this
761 * driver, and return if there are none.
762 */
763 if ((numDevSections = xf86MatchDevice(VBOX_NAME,
764 &devSections)) <= 0)
765 return (FALSE);
766
767 /* PCI BUS */
768 if (xf86GetPciVideoInfo())
769 {
770 int numUsed;
771 int *usedChips;
772 int i;
773 numUsed = xf86MatchPciInstances(VBOX_NAME, VBOX_VENDORID,
774 VBOXChipsets, VBOXPCIchipsets,
775 devSections, numDevSections,
776 drv, &usedChips);
777 if (numUsed > 0)
778 {
779 if (flags & PROBE_DETECT)
780 foundScreen = TRUE;
781 else
782 for (i = 0; i < numUsed; i++)
783 {
784 ScrnInfoPtr pScrn = NULL;
785 /* Allocate a ScrnInfoRec */
786 if ((pScrn = xf86ConfigPciEntity(pScrn,0,usedChips[i],
787 VBOXPCIchipsets,NULL,
788 NULL,NULL,NULL,NULL)))
789 {
790 setScreenFunctions(pScrn, VBOXProbe);
791 foundScreen = TRUE;
792 }
793 }
794 free(usedChips);
795 }
796 }
797 free(devSections);
798 return (foundScreen);
799}
800#endif
801
802
803/*
804 * QUOTE from the XFree86 DESIGN document:
805 *
806 * The purpose of this function is to find out all the information
807 * required to determine if the configuration is usable, and to initialise
808 * those parts of the ScrnInfoRec that can be set once at the beginning of
809 * the first server generation.
810 *
811 * (...)
812 *
813 * This includes probing for video memory, clocks, ramdac, and all other
814 * HW info that is needed. It includes determining the depth/bpp/visual
815 * and related info. It includes validating and determining the set of
816 * video modes that will be used (and anything that is required to
817 * determine that).
818 *
819 * This information should be determined in the least intrusive way
820 * possible. The state of the HW must remain unchanged by this function.
821 * Although video memory (including MMIO) may be mapped within this
822 * function, it must be unmapped before returning.
823 *
824 * END QUOTE
825 */
826
827static Bool
828VBOXPreInit(ScrnInfoPtr pScrn, int flags)
829{
830 VBOXPtr pVBox;
831 Gamma gzeros = {0.0, 0.0, 0.0};
832 rgb rzeros = {0, 0, 0};
833
834 TRACE_ENTRY();
835 /* Are we really starting the server, or is this just a dummy run? */
836 if (flags & PROBE_DETECT)
837 return (FALSE);
838
839 xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VirtualBox guest additions video driver version " VBOX_VERSION_STRING "r%d\n",
840 VBOX_SVN_REV);
841
842 /* Get our private data from the ScrnInfoRec structure. */
843 VBOXSetRec(pScrn);
844 pVBox = VBOXGetRec(pScrn);
845 if (!pVBox)
846 return FALSE;
847
848 /* Entity information seems to mean bus information. */
849 pVBox->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
850
851 /* The ramdac module is needed for the hardware cursor. */
852 if (!xf86LoadSubModule(pScrn, "ramdac"))
853 return FALSE;
854
855 /* The framebuffer module. */
856 if (!xf86LoadSubModule(pScrn, "fb"))
857 return (FALSE);
858
859 if (!xf86LoadSubModule(pScrn, "shadowfb"))
860 return FALSE;
861
862 if (!xf86LoadSubModule(pScrn, "vgahw"))
863 return FALSE;
864
865#ifdef VBOX_DRI_OLD
866 /* Load the dri module. */
867 if (!xf86LoadSubModule(pScrn, "dri"))
868 return FALSE;
869#else
870# ifdef VBOX_DRI
871 /* Load the dri module. */
872 if (!xf86LoadSubModule(pScrn, "dri2"))
873 return FALSE;
874# endif
875#endif
876
877#ifndef PCIACCESS
878 if (pVBox->pEnt->location.type != BUS_PCI)
879 return FALSE;
880
881 pVBox->pciInfo = xf86GetPciInfoForEntity(pVBox->pEnt->index);
882 pVBox->pciTag = pciTag(pVBox->pciInfo->bus,
883 pVBox->pciInfo->device,
884 pVBox->pciInfo->func);
885#endif
886
887 /* Set up our ScrnInfoRec structure to describe our virtual
888 capabilities to X. */
889
890 pScrn->chipset = "vbox";
891 /** @note needed during colourmap initialisation */
892 pScrn->rgbBits = 8;
893
894 /* Let's create a nice, capable virtual monitor. */
895 pScrn->monitor = pScrn->confScreen->monitor;
896 pScrn->monitor->DDC = NULL;
897 pScrn->monitor->nHsync = 1;
898 pScrn->monitor->hsync[0].lo = 1;
899 pScrn->monitor->hsync[0].hi = 10000;
900 pScrn->monitor->nVrefresh = 1;
901 pScrn->monitor->vrefresh[0].lo = 1;
902 pScrn->monitor->vrefresh[0].hi = 100;
903
904 pScrn->progClock = TRUE;
905
906 /* Using the PCI information caused problems with non-powers-of-two
907 sized video RAM configurations */
908 pVBox->cbFBMax = VBoxVideoGetVRAMSize();
909 pScrn->videoRam = pVBox->cbFBMax / 1024;
910
911 /* Check if the chip restricts horizontal resolution or not. */
912 pVBox->fAnyX = VBoxVideoAnyWidthAllowed();
913
914 /* Set up clock information that will support all modes we need. */
915 pScrn->clockRanges = xnfcalloc(sizeof(ClockRange), 1);
916 pScrn->clockRanges->minClock = 1000;
917 pScrn->clockRanges->maxClock = 1000000000;
918 pScrn->clockRanges->clockIndex = -1;
919 pScrn->clockRanges->ClockMulFactor = 1;
920 pScrn->clockRanges->ClockDivFactor = 1;
921
922 if (!xf86SetDepthBpp(pScrn, 24, 0, 0, Support32bppFb))
923 return FALSE;
924 /* We only support 16 and 24 bits depth (i.e. 16 and 32bpp) */
925 if (pScrn->bitsPerPixel != 32 && pScrn->bitsPerPixel != 16)
926 {
927 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
928 "The VBox additions only support 16 and 32bpp graphics modes\n");
929 return FALSE;
930 }
931 xf86PrintDepthBpp(pScrn);
932 vboxAddModes(pScrn);
933
934#ifdef VBOXVIDEO_13
935 pScrn->virtualX = VBOX_VIDEO_MAX_VIRTUAL;
936 pScrn->virtualY = VBOX_VIDEO_MAX_VIRTUAL;
937#else
938 /* We don't validate with xf86ValidateModes and xf86PruneModes as we
939 * already know what we like and what we don't. */
940
941 pScrn->currentMode = pScrn->modes;
942
943 /* Set the right virtual resolution. */
944 pScrn->virtualX = pScrn->bitsPerPixel == 16 ? (pScrn->currentMode->HDisplay + 1) & ~1 : pScrn->currentMode->HDisplay;
945 pScrn->virtualY = pScrn->currentMode->VDisplay;
946
947#endif /* !VBOXVIDEO_13 */
948
949 /* Needed before we initialise DRI. */
950 pScrn->displayWidth = pScrn->virtualX;
951
952 xf86PrintModes(pScrn);
953
954 /* VGA hardware initialisation */
955 if (!vgaHWGetHWRec(pScrn))
956 return FALSE;
957 /* Must be called before any VGA registers are saved or restored */
958 vgaHWSetStdFuncs(VGAHWPTR(pScrn));
959 vgaHWGetIOBase(VGAHWPTR(pScrn));
960
961 /* Colour weight - we always call this, since we are always in
962 truecolour. */
963 if (!xf86SetWeight(pScrn, rzeros, rzeros))
964 return (FALSE);
965
966 /* visual init */
967 if (!xf86SetDefaultVisual(pScrn, -1))
968 return (FALSE);
969
970 xf86SetGamma(pScrn, gzeros);
971
972 /* Set the DPI. Perhaps we should read this from the host? */
973 xf86SetDpi(pScrn, 96, 96);
974
975 if (pScrn->memPhysBase == 0) {
976#ifdef PCIACCESS
977 pScrn->memPhysBase = pVBox->pciInfo->regions[0].base_addr;
978#else
979 pScrn->memPhysBase = pVBox->pciInfo->memBase[0];
980#endif
981 pScrn->fbOffset = 0;
982 }
983
984 TRACE_EXIT();
985 return (TRUE);
986}
987
988/**
989 * Dummy function for setting the colour palette, which we actually never
990 * touch. However, the server still requires us to provide this.
991 */
992static void
993vboxLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
994 LOCO *colors, VisualPtr pVisual)
995{
996 (void)pScrn; (void) numColors; (void) indices; (void) colors;
997 (void)pVisual;
998}
999
1000/** Set the graphics and guest cursor support capabilities to the host if
1001 * the user-space helper is running. */
1002static void updateGraphicsCapability(ScrnInfoPtr pScrn, Bool hasVT)
1003{
1004 VBOXPtr pVBox = VBOXGetRec(pScrn);
1005 size_t cData;
1006 int32_t *paData;
1007 int rc;
1008
1009 if (pVBox->fHaveHGSMIModeHints)
1010 return;
1011 rc = vbvxGetIntegerPropery(pScrn, "VBOX_HAS_GRAPHICS", &cData, &paData);
1012 if (rc != VINF_SUCCESS || cData != 1)
1013 return;
1014 if (RT_BOOL(*paData) != hasVT)
1015 {
1016 uint32_t fFeatures;
1017 VbglR3SetGuestCaps(hasVT ? VMMDEV_GUEST_SUPPORTS_GRAPHICS : 0, hasVT ? 0 : VMMDEV_GUEST_SUPPORTS_GRAPHICS);
1018 rc = VbglR3GetMouseStatus(&fFeatures, NULL, NULL);
1019 fFeatures &= VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE | VMMDEV_MOUSE_NEW_PROTOCOL;
1020 if (RT_SUCCESS(rc))
1021 VbglR3SetMouseStatus(hasVT ? fFeatures : fFeatures | VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR);
1022 }
1023 *paData = hasVT;
1024}
1025
1026#ifdef VBOXVIDEO_13
1027
1028static void setVirtualSizeRandR12(ScrnInfoPtr pScrn, bool fScreenInitTime)
1029{
1030 VBOXPtr pVBox = VBOXGetRec(pScrn);
1031 unsigned i;
1032 unsigned cx = 0;
1033 unsigned cy = 0;
1034
1035 for (i = 0; i < pVBox->cScreens; ++i)
1036 {
1037 if ( pVBox->fHaveHGSMIModeHints && pVBox->pScreens[i].afHaveLocation)
1038 {
1039 pVBox->pScreens[i].paCrtcs->x = pVBox->pScreens[i].aPreferredLocation.x;
1040 pVBox->pScreens[i].paCrtcs->y = pVBox->pScreens[i].aPreferredLocation.y;
1041 }
1042 if ( pVBox->pScreens[i].paOutputs->status == XF86OutputStatusConnected
1043 && pVBox->pScreens[i].paCrtcs->x + pVBox->pScreens[i].aPreferredSize.cx < VBOX_VIDEO_MAX_VIRTUAL
1044 && pVBox->pScreens[i].paCrtcs->y + pVBox->pScreens[i].aPreferredSize.cy < VBOX_VIDEO_MAX_VIRTUAL)
1045 {
1046 cx = max(cx, pVBox->pScreens[i].paCrtcs->x + pVBox->pScreens[i].aPreferredSize.cx);
1047 cy = max(cy, pVBox->pScreens[i].paCrtcs->y + pVBox->pScreens[i].aPreferredSize.cy);
1048 }
1049 }
1050 if (cx != 0 && cy != 0)
1051 {
1052 /* Do not set the virtual resolution in limited context as that can
1053 * cause problems setting up RandR 1.2 which needs it set to the
1054 * maximum size at this point. */
1055 if (!fScreenInitTime)
1056 {
1057 TRACE_LOG("cx=%u, cy=%u\n", cx, cy);
1058 xf86ScrnToScreen(pScrn)->width = cx;
1059 xf86ScrnToScreen(pScrn)->height = cy;
1060 xf86ScrnToScreen(pScrn)->mmWidth = cx * 254 / 960;
1061 xf86ScrnToScreen(pScrn)->mmHeight = cy * 254 / 960;
1062 adjustScreenPixmap(pScrn, cx, cy);
1063 vbvxSetSolarisMouseRange(cx, cy);
1064 }
1065 }
1066}
1067
1068static void setScreenSizesRandR12(ScrnInfoPtr pScrn, bool fScreenInitTime)
1069{
1070 VBOXPtr pVBox = VBOXGetRec(pScrn);
1071 unsigned i;
1072
1073 for (i = 0; i < pVBox->cScreens; ++i)
1074 {
1075 if (!pVBox->pScreens[i].afConnected)
1076 continue;
1077 /* The Crtc can get "unset" if the screen was disconnected previously.
1078 * I couldn't find an API to re-set it which did not have side-effects.
1079 */
1080 pVBox->pScreens[i].paOutputs->crtc = pVBox->pScreens[i].paCrtcs;
1081 xf86CrtcSetMode(pVBox->pScreens[i].paCrtcs, pVBox->pScreens[i].paOutputs->probed_modes, RR_Rotate_0,
1082 pVBox->pScreens[i].paCrtcs->x, pVBox->pScreens[i].paCrtcs->y);
1083 if (!fScreenInitTime)
1084 RRCrtcNotify(pVBox->pScreens[i].paCrtcs->randr_crtc, pVBox->pScreens[i].paOutputs->randr_output->modes[0],
1085 pVBox->pScreens[i].paCrtcs->x, pVBox->pScreens[i].paCrtcs->y, RR_Rotate_0,
1086#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 5
1087 NULL,
1088#endif
1089 1, &pVBox->pScreens[i].paOutputs->randr_output);
1090 }
1091}
1092
1093static void setSizesRandR12(ScrnInfoPtr pScrn, bool fScreenInitTime)
1094{
1095 VBOXPtr pVBox = VBOXGetRec(pScrn);
1096
1097 if (!fScreenInitTime)
1098 {
1099# if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 5
1100 RRGetInfo(xf86ScrnToScreen(pScrn), TRUE);
1101# else
1102 RRGetInfo(xf86ScrnToScreen(pScrn));
1103# endif
1104 }
1105 setVirtualSizeRandR12(pScrn, fScreenInitTime);
1106 setScreenSizesRandR12(pScrn, fScreenInitTime);
1107 if (!fScreenInitTime)
1108 {
1109 /* We use RRScreenSizeSet() here and not RRScreenSizeNotify() because
1110 * the first also pushes the virtual screen size to the input driver.
1111 * We were doing this manually by setting screenInfo.width and height
1112 * and calling xf86UpdateDesktopDimensions() where appropriate, but this
1113 * failed on Ubuntu 12.04.0 due to a problematic X server back-port. */
1114 RRScreenSizeSet(xf86ScrnToScreen(pScrn), xf86ScrnToScreen(pScrn)->width, xf86ScrnToScreen(pScrn)->height,
1115 xf86ScrnToScreen(pScrn)->mmWidth, xf86ScrnToScreen(pScrn)->mmHeight);
1116 RRTellChanged(xf86ScrnToScreen(pScrn));
1117 }
1118}
1119
1120#else
1121
1122static void setSizesRandR11(ScrnInfoPtr pScrn)
1123{
1124 VBOXPtr pVBox = VBOXGetRec(pScrn);
1125 DisplayModePtr pNewMode;
1126
1127 pNewMode = pScrn->modes != pScrn->currentMode ? pScrn->modes : pScrn->modes->next;
1128 pNewMode->HDisplay = RT_CLAMP(pVBox->pScreens[0].aPreferredSize.cx, VBOX_VIDEO_MIN_SIZE, VBOX_VIDEO_MAX_VIRTUAL);
1129 pNewMode->VDisplay = RT_CLAMP(pVBox->pScreens[0].aPreferredSize.cy, VBOX_VIDEO_MIN_SIZE, VBOX_VIDEO_MAX_VIRTUAL);
1130}
1131
1132#endif
1133
1134static void setSizesAndCursorIntegration(ScrnInfoPtr pScrn, bool fScreenInitTime)
1135{
1136 VBOXPtr pVBox = VBOXGetRec(pScrn);
1137
1138 TRACE_LOG("fScreenInitTime=%d\n", (int)fScreenInitTime);
1139#ifdef VBOXVIDEO_13
1140 setSizesRandR12(pScrn, fScreenInitTime);
1141#else
1142 setSizesRandR11(pScrn);
1143#endif
1144 /* This calls EnableDisableFBAccess(), so only use when switched in. */
1145 if (pScrn->vtSema)
1146 vbvxReprobeCursor(pScrn);
1147}
1148
1149/* We update the size hints from the X11 property set by VBoxClient every time
1150 * that the X server goes to sleep (to catch the property change request).
1151 * Although this is far more often than necessary it should not have real-life
1152 * performance consequences and allows us to simplify the code quite a bit. */
1153static void vboxBlockHandler(pointer pData, OSTimePtr pTimeout, pointer pReadmask)
1154{
1155 ScrnInfoPtr pScrn = (ScrnInfoPtr)pData;
1156 VBOXPtr pVBox = VBOXGetRec(pScrn);
1157 bool fNeedUpdate = false;
1158
1159 (void)pTimeout;
1160 (void)pReadmask;
1161 updateGraphicsCapability(pScrn, pScrn->vtSema);
1162 if (pScrn->vtSema)
1163 vbvxReadSizesAndCursorIntegrationFromHGSMI(pScrn, &fNeedUpdate);
1164 /* This has to be done even when we are switched out so that VBoxClient can
1165 * set a mode using RandR without having to know the virtual terminal state.
1166 */
1167 if (ROOT_WINDOW(pScrn) != NULL)
1168 vbvxReadSizesAndCursorIntegrationFromProperties(pScrn, &fNeedUpdate);
1169 if (fNeedUpdate)
1170 setSizesAndCursorIntegration(pScrn, false);
1171}
1172
1173/*
1174 * QUOTE from the XFree86 DESIGN document:
1175 *
1176 * This is called at the start of each server generation.
1177 *
1178 * (...)
1179 *
1180 * Decide which operations need to be placed under resource access
1181 * control. (...) Map any video memory or other memory regions. (...)
1182 * Save the video card state. (...) Initialise the initial video
1183 * mode.
1184 *
1185 * End QUOTE.
1186 */
1187static Bool VBOXScreenInit(ScreenPtr pScreen, int argc, char **argv)
1188{
1189 ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
1190 VBOXPtr pVBox = VBOXGetRec(pScrn);
1191 VisualPtr visual;
1192
1193 TRACE_ENTRY();
1194
1195 /* Initialise our guest library if possible: ignore failure. */
1196 VbglR3Init();
1197 if (!VBOXMapVidMem(pScrn))
1198 return (FALSE);
1199
1200 /* save current video state */
1201 VBOXSaveMode(pScrn);
1202
1203 /* mi layer - reset the visual list (?)*/
1204 miClearVisualTypes();
1205 if (!miSetVisualTypes(pScrn->depth, TrueColorMask,
1206 pScrn->rgbBits, TrueColor))
1207 return (FALSE);
1208 if (!miSetPixmapDepths())
1209 return (FALSE);
1210
1211#ifdef VBOX_DRI
1212 pVBox->useDRI = VBOXDRIScreenInit(pScrn, pScreen, pVBox);
1213# ifndef VBOX_DRI_OLD /* DRI2 */
1214 if (pVBox->drmFD >= 0)
1215 /* Tell the kernel driver, if present, that we are taking over. */
1216 drmIoctl(pVBox->drmFD, VBOXVIDEO_IOCTL_DISABLE_HGSMI, NULL);
1217# endif
1218#endif
1219
1220 if (!fbScreenInit(pScreen, pVBox->base,
1221 pScrn->virtualX, pScrn->virtualY,
1222 pScrn->xDpi, pScrn->yDpi,
1223 pScrn->displayWidth, pScrn->bitsPerPixel))
1224 return (FALSE);
1225
1226 /* Fixup RGB ordering */
1227 /** @note the X server uses this even in true colour. */
1228 visual = pScreen->visuals + pScreen->numVisuals;
1229 while (--visual >= pScreen->visuals) {
1230 if ((visual->class | DynamicClass) == DirectColor) {
1231 visual->offsetRed = pScrn->offset.red;
1232 visual->offsetGreen = pScrn->offset.green;
1233 visual->offsetBlue = pScrn->offset.blue;
1234 visual->redMask = pScrn->mask.red;
1235 visual->greenMask = pScrn->mask.green;
1236 visual->blueMask = pScrn->mask.blue;
1237 }
1238 }
1239
1240 /* must be after RGB ordering fixed */
1241 fbPictureInit(pScreen, 0, 0);
1242
1243 xf86SetBlackWhitePixels(pScreen);
1244 pScrn->vtSema = TRUE;
1245
1246#if defined(VBOXVIDEO_13) && defined(RT_OS_LINUX)
1247 vbvxSetUpLinuxACPI(pScreen);
1248#endif
1249
1250 if (!VBoxHGSMIIsSupported())
1251 {
1252 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Graphics device too old to support.\n");
1253 return FALSE;
1254 }
1255 vbvxSetUpHGSMIHeapInGuest(pVBox, pScrn->videoRam * 1024);
1256 pVBox->cScreens = VBoxHGSMIGetMonitorCount(&pVBox->guestCtx);
1257 pVBox->pScreens = xnfcalloc(pVBox->cScreens, sizeof(*pVBox->pScreens));
1258 pVBox->paVBVAModeHints = xnfcalloc(pVBox->cScreens, sizeof(*pVBox->paVBVAModeHints));
1259 xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Requested monitor count: %u\n", pVBox->cScreens);
1260 vboxEnableVbva(pScrn);
1261 /* Set up the dirty rectangle handler. It will be added into a function
1262 * chain and gets removed when the screen is cleaned up. */
1263 if (ShadowFBInit2(pScreen, NULL, vbvxHandleDirtyRect) != TRUE)
1264 return FALSE;
1265 VBoxInitialiseSizeHints(pScrn);
1266 /* Get any screen size hints from HGSMI. Do not yet try to access X11
1267 * properties, as they are not yet set up, and nor are the clients that
1268 * might have set them. */
1269 vbvxReadSizesAndCursorIntegrationFromHGSMI(pScrn, NULL);
1270
1271#ifdef VBOXVIDEO_13
1272 /* Initialise CRTC and output configuration for use with randr1.2. */
1273 xf86CrtcConfigInit(pScrn, &VBOXCrtcConfigFuncs);
1274
1275 {
1276 uint32_t i;
1277
1278 for (i = 0; i < pVBox->cScreens; ++i)
1279 {
1280 char szOutput[256];
1281
1282 /* Setup our virtual CRTCs. */
1283 pVBox->pScreens[i].paCrtcs = xf86CrtcCreate(pScrn, &VBOXCrtcFuncs);
1284 pVBox->pScreens[i].paCrtcs->driver_private = (void *)(uintptr_t)i;
1285
1286 /* Set up our virtual outputs. */
1287 snprintf(szOutput, sizeof(szOutput), "VGA-%u", i);
1288 pVBox->pScreens[i].paOutputs
1289 = xf86OutputCreate(pScrn, &VBOXOutputFuncs, szOutput);
1290
1291 /* We are not interested in the monitor section in the
1292 * configuration file. */
1293 xf86OutputUseScreenMonitor(pVBox->pScreens[i].paOutputs, FALSE);
1294 pVBox->pScreens[i].paOutputs->possible_crtcs = 1 << i;
1295 pVBox->pScreens[i].paOutputs->possible_clones = 0;
1296 pVBox->pScreens[i].paOutputs->driver_private = (void *)(uintptr_t)i;
1297 TRACE_LOG("Created crtc (%p) and output %s (%p)\n",
1298 (void *)pVBox->pScreens[i].paCrtcs, szOutput,
1299 (void *)pVBox->pScreens[i].paOutputs);
1300 }
1301 }
1302
1303 /* Set a sane minimum and maximum mode size to match what the hardware
1304 * supports. */
1305 xf86CrtcSetSizeRange(pScrn, VBOX_VIDEO_MIN_SIZE, VBOX_VIDEO_MIN_SIZE, VBOX_VIDEO_MAX_VIRTUAL, VBOX_VIDEO_MAX_VIRTUAL);
1306
1307 /* Now create our initial CRTC/output configuration. */
1308 if (!xf86InitialConfiguration(pScrn, TRUE)) {
1309 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Initial CRTC configuration failed!\n");
1310 return (FALSE);
1311 }
1312
1313 /* Work around a bug in the original X server modesetting code, which took
1314 * the first valid values set to these two as maxima over the server
1315 * lifetime. This bug was introduced on Feb 15 2007 and was fixed in commit
1316 * fa877d7f three months later, so it was present in X.Org Server 1.3. */
1317 pScrn->virtualX = VBOX_VIDEO_MAX_VIRTUAL;
1318 pScrn->virtualY = VBOX_VIDEO_MAX_VIRTUAL;
1319
1320 /* Initialise randr 1.2 mode-setting functions. */
1321 if (!xf86CrtcScreenInit(pScreen)) {
1322 return FALSE;
1323 }
1324
1325 /* set first video mode */
1326 setSizesAndCursorIntegration(pScrn, true);
1327#else
1328 /* set first video mode */
1329 setModeRandR11(pScrn, pScrn->currentMode, true, false, 0, 0);
1330#endif
1331
1332 /* Register block and wake-up handlers for getting new screen size hints. */
1333 RegisterBlockAndWakeupHandlers(vboxBlockHandler, (WakeupHandlerProcPtr)NoopDDA, (pointer)pScrn);
1334
1335 /* software cursor */
1336 miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
1337
1338 /* colourmap code */
1339 if (!miCreateDefColormap(pScreen))
1340 return (FALSE);
1341
1342 if(!xf86HandleColormaps(pScreen, 256, 8, vboxLoadPalette, NULL, 0))
1343 return (FALSE);
1344
1345 pVBox->CloseScreen = pScreen->CloseScreen;
1346 pScreen->CloseScreen = SCRNINDEXAPI(VBOXCloseScreen);
1347#ifdef VBOXVIDEO_13
1348 pScreen->SaveScreen = xf86SaveScreen;
1349#else
1350 pScreen->SaveScreen = VBOXSaveScreen;
1351#endif
1352
1353#ifdef VBOXVIDEO_13
1354 xf86DPMSInit(pScreen, xf86DPMSSet, 0);
1355#else
1356 /* We probably do want to support power management - even if we just use
1357 a dummy function. */
1358 xf86DPMSInit(pScreen, VBOXDisplayPowerManagementSet, 0);
1359#endif
1360
1361 /* Report any unused options (only for the first generation) */
1362 if (serverGeneration == 1)
1363 xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
1364
1365 if (vbvxCursorInit(pScreen) != TRUE)
1366 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
1367 "Unable to start the VirtualBox mouse pointer integration with the host system.\n");
1368
1369#ifdef VBOX_DRI_OLD
1370 if (pVBox->useDRI)
1371 pVBox->useDRI = VBOXDRIFinishScreenInit(pScreen);
1372#endif
1373
1374 return (TRUE);
1375}
1376
1377#define NO_VT_ATOM_NAME "VBOXVIDEO_NO_VT"
1378
1379static Bool VBOXEnterVT(ScrnInfoPtr pScrn)
1380{
1381 VBOXPtr pVBox = VBOXGetRec(pScrn);
1382#ifndef VBOXVIDEO_13
1383 /* If we got a mode request while we were switched out, temporarily override
1384 * the physical mode set to the device while keeping things consistent from
1385 * the server's point of view. */
1386 int cXOverRide = RT_CLAMP(pVBox->pScreens[0].aPreferredSize.cx, VBOX_VIDEO_MIN_SIZE, VBOX_VIDEO_MAX_VIRTUAL);
1387 int cYOverRide = RT_CLAMP(pVBox->pScreens[0].aPreferredSize.cy, VBOX_VIDEO_MIN_SIZE, VBOX_VIDEO_MAX_VIRTUAL);
1388#endif
1389
1390 TRACE_ENTRY();
1391 updateGraphicsCapability(pScrn, TRUE);
1392#ifdef VBOX_DRI_OLD
1393 if (pVBox->useDRI)
1394 DRIUnlock(xf86ScrnToScreen(pScrn));
1395#elif defined(VBOX_DRI) /* DRI2 */
1396 if (pVBox->drmFD >= 0)
1397 {
1398 /* Tell the kernel driver, if present, that we are taking over. */
1399 drmSetMaster(pVBox->drmFD);
1400 }
1401#endif
1402 vbvxSetUpHGSMIHeapInGuest(pVBox, pScrn->videoRam * 1024);
1403 vboxEnableVbva(pScrn);
1404 /* Re-set video mode */
1405#ifdef VBOXVIDEO_13
1406 vbvxReadSizesAndCursorIntegrationFromHGSMI(pScrn, NULL);
1407 setSizesAndCursorIntegration(pScrn, false);
1408#else
1409 setModeRandR11(pScrn, pScrn->currentMode, false, true, cXOverRide, cYOverRide);
1410 DeleteProperty(ROOT_WINDOW(pScrn), MakeAtom(NO_VT_ATOM_NAME, sizeof(NO_VT_ATOM_NAME) - 1, TRUE));
1411#endif
1412 return TRUE;
1413}
1414
1415static void VBOXLeaveVT(ScrnInfoPtr pScrn)
1416{
1417 VBOXPtr pVBox = VBOXGetRec(pScrn);
1418#ifdef VBOXVIDEO_13
1419 unsigned i;
1420#else
1421 int32_t propertyValue = 0;
1422#endif
1423
1424 TRACE_ENTRY();
1425 updateGraphicsCapability(pScrn, FALSE);
1426#ifdef VBOXVIDEO_13
1427 for (i = 0; i < pVBox->cScreens; ++i)
1428 vbox_crtc_dpms(pVBox->pScreens[i].paCrtcs, DPMSModeOff);
1429#else
1430 ChangeWindowProperty(ROOT_WINDOW(pScrn), MakeAtom(NO_VT_ATOM_NAME, sizeof(NO_VT_ATOM_NAME) - 1, FALSE), XA_INTEGER, 32,
1431 PropModeReplace, 1, &propertyValue, TRUE);
1432#endif
1433 vboxDisableVbva(pScrn);
1434 vbvxClearVRAM(pScrn, ((size_t)pScrn->virtualX) * pScrn->virtualY * (pScrn->bitsPerPixel / 8), 0);
1435#ifdef VBOX_DRI_OLD
1436 if (pVBox->useDRI)
1437 DRILock(xf86ScrnToScreen(pScrn), 0);
1438#elif defined(VBOX_DRI) /* DRI2 */
1439 if (pVBox->drmFD >= 0)
1440 drmDropMaster(pVBox->drmFD);
1441#endif
1442 VBOXRestoreMode(pScrn);
1443 TRACE_EXIT();
1444}
1445
1446static Bool VBOXCloseScreen(ScreenPtr pScreen)
1447{
1448 ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
1449 VBOXPtr pVBox = VBOXGetRec(pScrn);
1450#if defined(VBOX_DRI) && !defined(VBOX_DRI_OLD) /* DRI2 */
1451 BOOL fRestore = TRUE;
1452#endif
1453 BOOL ret;
1454
1455 if (pScrn->vtSema)
1456 {
1457#ifdef VBOXVIDEO_13
1458 unsigned i;
1459
1460 for (i = 0; i < pVBox->cScreens; ++i)
1461 vbox_crtc_dpms(pVBox->pScreens[i].paCrtcs, DPMSModeOff);
1462#endif
1463 vboxDisableVbva(pScrn);
1464 vbvxClearVRAM(pScrn, ((size_t)pScrn->virtualX) * pScrn->virtualY * (pScrn->bitsPerPixel / 8), 0);
1465 }
1466#ifdef VBOX_DRI
1467# ifndef VBOX_DRI_OLD /* DRI2 */
1468 if ( pVBox->drmFD >= 0
1469 /* Tell the kernel driver, if present, that we are going away. */
1470 && drmIoctl(pVBox->drmFD, VBOXVIDEO_IOCTL_ENABLE_HGSMI, NULL) >= 0)
1471 fRestore = false;
1472# endif
1473 if (pVBox->useDRI)
1474 VBOXDRICloseScreen(pScreen, pVBox);
1475 pVBox->useDRI = false;
1476#endif
1477#if defined(VBOX_DRI) && !defined(VBOX_DRI_OLD) /* DRI2 */
1478 if (fRestore)
1479#endif
1480 if (pScrn->vtSema)
1481 VBOXRestoreMode(pScrn);
1482 if (pScrn->vtSema)
1483 VBOXUnmapVidMem(pScrn);
1484 pScrn->vtSema = FALSE;
1485
1486 vbvxCursorTerm(pVBox);
1487
1488 pScreen->CloseScreen = pVBox->CloseScreen;
1489#if defined(VBOXVIDEO_13) && defined(RT_OS_LINUX)
1490 vbvxCleanUpLinuxACPI(pScreen);
1491#endif
1492#ifndef XF86_SCRN_INTERFACE
1493 ret = pScreen->CloseScreen(pScreen->myNum, pScreen);
1494#else
1495 ret = pScreen->CloseScreen(pScreen);
1496#endif
1497 VbglR3Term();
1498 return ret;
1499}
1500
1501static Bool VBOXSwitchMode(ScrnInfoPtr pScrn, DisplayModePtr pMode)
1502{
1503 Bool rc = TRUE;
1504
1505 TRACE_LOG("HDisplay=%d, VDisplay=%d\n", pMode->HDisplay, pMode->VDisplay);
1506#ifdef VBOXVIDEO_13
1507 rc = xf86SetSingleMode(pScrn, pMode, RR_Rotate_0);
1508#else
1509 setModeRandR11(pScrn, pMode, false, false, 0, 0);
1510#endif
1511 TRACE_LOG("returning %s\n", rc ? "TRUE" : "FALSE");
1512 return rc;
1513}
1514
1515static void VBOXAdjustFrame(ScrnInfoPtr pScrn, int x, int y)
1516{ (void)pScrn; (void)x; (void)y; }
1517
1518static void VBOXFreeScreen(ScrnInfoPtr pScrn)
1519{
1520 /* Destroy the VGA hardware record */
1521 vgaHWFreeHWRec(pScrn);
1522 /* And our private record */
1523 free(pScrn->driverPrivate);
1524 pScrn->driverPrivate = NULL;
1525}
1526
1527static Bool
1528VBOXMapVidMem(ScrnInfoPtr pScrn)
1529{
1530 VBOXPtr pVBox = VBOXGetRec(pScrn);
1531 Bool rc = TRUE;
1532
1533 TRACE_ENTRY();
1534 if (!pVBox->base)
1535 {
1536#ifdef PCIACCESS
1537 (void) pci_device_map_range(pVBox->pciInfo,
1538 pScrn->memPhysBase,
1539 pScrn->videoRam * 1024,
1540 PCI_DEV_MAP_FLAG_WRITABLE,
1541 & pVBox->base);
1542#else
1543 pVBox->base = xf86MapPciMem(pScrn->scrnIndex,
1544 VIDMEM_FRAMEBUFFER,
1545 pVBox->pciTag, pScrn->memPhysBase,
1546 (unsigned) pScrn->videoRam * 1024);
1547#endif
1548 if (!pVBox->base)
1549 rc = FALSE;
1550 }
1551 TRACE_LOG("returning %s\n", rc ? "TRUE" : "FALSE");
1552 return rc;
1553}
1554
1555static void
1556VBOXUnmapVidMem(ScrnInfoPtr pScrn)
1557{
1558 VBOXPtr pVBox = VBOXGetRec(pScrn);
1559
1560 TRACE_ENTRY();
1561 if (pVBox->base == NULL)
1562 return;
1563
1564#ifdef PCIACCESS
1565 (void) pci_device_unmap_range(pVBox->pciInfo,
1566 pVBox->base,
1567 pScrn->videoRam * 1024);
1568#else
1569 xf86UnMapVidMem(pScrn->scrnIndex, pVBox->base,
1570 (unsigned) pScrn->videoRam * 1024);
1571#endif
1572 pVBox->base = NULL;
1573 TRACE_EXIT();
1574}
1575
1576static Bool
1577VBOXSaveScreen(ScreenPtr pScreen, int mode)
1578{
1579 (void)pScreen; (void)mode;
1580 return TRUE;
1581}
1582
1583void
1584VBOXSaveMode(ScrnInfoPtr pScrn)
1585{
1586 VBOXPtr pVBox = VBOXGetRec(pScrn);
1587 vgaRegPtr vgaReg;
1588
1589 TRACE_ENTRY();
1590 vgaReg = &VGAHWPTR(pScrn)->SavedReg;
1591 vgaHWSave(pScrn, vgaReg, VGA_SR_ALL);
1592 pVBox->fSavedVBEMode = VBoxVideoGetModeRegisters(&pVBox->cSavedWidth,
1593 &pVBox->cSavedHeight,
1594 &pVBox->cSavedPitch,
1595 &pVBox->cSavedBPP,
1596 &pVBox->fSavedFlags);
1597}
1598
1599void
1600VBOXRestoreMode(ScrnInfoPtr pScrn)
1601{
1602 VBOXPtr pVBox = VBOXGetRec(pScrn);
1603 vgaRegPtr vgaReg;
1604#ifdef VBOX_DRI
1605 drmModeResPtr pRes;
1606#endif
1607
1608 TRACE_ENTRY();
1609#ifdef VBOX_DRI
1610 /* Do not try to re-set the VGA state if a mode-setting driver is loaded. */
1611 if ( pVBox->drmFD >= 0
1612 && LoaderSymbol("drmModeGetResources") != NULL
1613 && (pRes = drmModeGetResources(pVBox->drmFD)) != NULL)
1614 {
1615 drmModeFreeResources(pRes);
1616 return;
1617 }
1618#endif
1619 vgaReg = &VGAHWPTR(pScrn)->SavedReg;
1620 vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL);
1621 if (pVBox->fSavedVBEMode)
1622 VBoxVideoSetModeRegisters(pVBox->cSavedWidth, pVBox->cSavedHeight,
1623 pVBox->cSavedPitch, pVBox->cSavedBPP,
1624 pVBox->fSavedFlags, 0, 0);
1625 else
1626 VBoxVideoDisableVBE();
1627}
1628
1629static void
1630VBOXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int mode,
1631 int flags)
1632{
1633 (void)pScrn; (void)mode; (void) flags;
1634}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette