Changeset 6484 in vbox
- Timestamp:
- Jan 24, 2008 2:59:40 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27485
- Location:
- trunk/src/VBox/Additions/x11/xgraphics
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/xgraphics/Makefile.kmk
r6301 r6484 25 25 # for BUILD_TARGET=l4 26 26 SUFF_DLL = .so 27 28 # For now 29 VBOX_LIB_VBGL_R3 := $(PATH_LIB)/VBoxGuestR3LibLinux.a 30 VBOX_LIB_IPRT_GUEST_R3 := $(PATH_LIB)/RuntimeLnx32GuestR3.a 27 31 28 32 vboxvideo_drv_TEMPLATE = VBOXLNX32GUESTR3EXE … … 102 106 vboxvideo_68.c \ 103 107 vboxutils.c 104 108 vboxvideo_drv_LIBS = \ 109 $(VBOX_LIB_VBGL_R3) \ 110 $(VBOX_LIB_IPRT_GUEST_R3) 105 111 106 112 vboxvideo_drv_70_TEMPLATE = VBOXLNX32GUESTR3DLLNOCPP … … 119 125 vboxvideo_70.c \ 120 126 vboxutils.c 121 127 vboxvideo_drv_70_LIBS = \ 128 $(VBOX_LIB_VBGL_R3) \ 129 $(VBOX_LIB_IPRT_GUEST_R3) 122 130 123 131 vboxvideo_drv_71_TEMPLATE = VBOXLNX32GUESTR3DLLNOCPP … … 132 140 vboxvideo_70.c \ 133 141 vboxutils.c 142 vboxvideo_drv_71_LIBS = \ 143 $(VBOX_LIB_VBGL_R3) \ 144 $(VBOX_LIB_IPRT_GUEST_R3) 134 145 135 146 vboxvideo_drv_13_TEMPLATE = VBOXLNX32GUESTR3DLLNOCPP … … 144 155 vboxvideo_13.c \ 145 156 vboxutils.c 157 vboxvideo_drv_13_LIBS = \ 158 $(VBOX_LIB_VBGL_R3) \ 159 $(VBOX_LIB_IPRT_GUEST_R3) 146 160 147 161 vboxvideo_drv_14_TEMPLATE = VBOXLNX32GUESTR3DLLNOCPP … … 153 167 ../x11include/1.4/X11 \ 154 168 ../x11include/1.4/xorg 169 # The actual source has not changed from the 1.3 driver, but the headers 170 # have. To be safe, build the driver for 1.4 separately. 155 171 vboxvideo_drv_14_SOURCES = \ 156 vboxvideo_1 4.c \172 vboxvideo_13.c \ 157 173 vboxutils.c 174 vboxvideo_drv_14_LIBS = \ 175 $(VBOX_LIB_VBGL_R3) \ 176 $(VBOX_LIB_IPRT_GUEST_R3) 158 177 endif 159 178 -
trunk/src/VBox/Additions/x11/xgraphics/vboxutils.c
r6483 r6484 954 954 return TRUE; 955 955 } 956 957 958 /** 959 * Query the last display change request. 960 * 961 * @returns iprt status value 962 * @retval xres horizontal pixel resolution (0 = do not change) 963 * @retval yres vertical pixel resolution (0 = do not change) 964 * @retval bpp bits per pixel (0 = do not change) 965 * @param eventAck Flag that the request is an acknowlegement for the 966 * VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST. 967 * Values: 968 * 0 - just querying, 969 * VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged. 970 * @param display 0 for primary display, 1 for the first secondary, etc. 971 */ 972 Bool 973 vboxGetDisplayChangeRequest(ScrnInfoPtr pScrn, uint32_t *px, uint32_t *py, 974 uint32_t *pbpp, uint32_t eventAck, uint32_t display) 975 { 976 int rc, scrnIndex = pScrn->scrnIndex; 977 VBOXPtr pVBox = pScrn->driverPrivate; 978 979 VMMDevDisplayChangeRequest2 Req; 980 vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequest2); 981 Req.xres = 0; 982 Req.yres = 0; 983 Req.bpp = 0; 984 Req.eventAck = eventAck; 985 Req.display = display; 986 rc = vbox_vmmcall(pScrn, pVBox, &Req.header); 987 if (RT_SUCCESS(rc)) 988 { 989 *px = Req.xres; 990 *py = Req.yres; 991 *pbpp = Req.bpp; 992 return TRUE; 993 } 994 xf86DrvMsg(scrnIndex, X_ERROR, 995 "Failed to request the last resolution requested from the guest, rc=%d.\n", 996 rc); 997 return FALSE; 998 } -
trunk/src/VBox/Additions/x11/xgraphics/vboxvideo.h
r6301 r6484 205 205 vboxDisableVbva(ScrnInfoPtr pScrn); 206 206 207 /** 208 * Query the last display change request. 209 * 210 * @returns iprt status value 211 * @retval xres horizontal pixel resolution (0 = do not change) 212 * @retval yres vertical pixel resolution (0 = do not change) 213 * @retval bpp bits per pixel (0 = do not change) 214 * @param eventAck Flag that the request is an acknowlegement for the 215 * VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST. 216 * Values: 217 * 0 - just querying, 218 * VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST - event acknowledged. 219 * @param display 0 for primary display, 1 for the first secondary, etc. 220 */ 221 extern Bool 222 vboxGetDisplayChangeRequest(ScrnInfoPtr pScrn, uint32_t *px, uint32_t *py, 223 uint32_t *pbpp, uint32_t eventAck, uint32_t display); 224 207 225 #endif /* _VBOXVIDEO_H_ */ -
trunk/src/VBox/Additions/x11/xgraphics/vboxvideo_13.c
r6202 r6484 50 50 #define DEBUG_VERB 2 51 51 52 #define TRACE \ 53 do { \ 54 xf86Msg(X_INFO, __PRETTY_FUNCTION__); \ 55 xf86Msg(X_INFO, ": entering\n"); \ 56 } while(0) 57 #define TRACE2 \ 58 do { \ 59 xf86Msg(X_INFO, __PRETTY_FUNCTION__); \ 60 xf86Msg(X_INFO, ": leaving\n"); \ 61 } while(0) 62 #define TRACE3(...) \ 63 do { \ 64 xf86Msg(X_INFO, __PRETTY_FUNCTION__); \ 65 xf86Msg(X_INFO, __VA_ARGS__); \ 66 } while(0) 52 67 #ifdef XFree86LOADER 53 68 # include "xorg-server.h" … … 75 90 #include "extensions/dpms.h" */ 76 91 92 /* X.org 1.3+ mode setting */ 93 #include "xf86Crtc.h" 94 #include "xf86Modes.h" 95 77 96 /* Mandatory functions */ 78 97 … … 86 105 static void VBOXLeaveVT(int scrnIndex, int flags); 87 106 static Bool VBOXCloseScreen(int scrnIndex, ScreenPtr pScreen); 88 static Bool VBOXSaveScreen(ScreenPtr pScreen, int mode);89 107 static Bool VBOXSwitchMode(int scrnIndex, DisplayModePtr pMode, int flags); 90 108 static ModeStatus VBOXValidMode(int scrn, DisplayModePtr p, Bool flag, int pass); … … 93 111 static void VBOXFreeScreen(int scrnIndex, int flags); 94 112 static void VBOXFreeRec(ScrnInfoPtr pScrn); 95 static void VBOXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int mode,96 int flags);97 113 98 114 /* locally used functions */ … … 107 123 vbeSaveRestoreFunction function); 108 124 109 /* Initialise DGA */110 111 static Bool VBOXDGAInit(ScrnInfoPtr pScrn, ScreenPtr pScreen);112 113 125 /* 114 126 * This contains the functions needed by the server after loading the … … 142 154 }; 143 155 144 typedef enum {145 OPTION_SHADOW_FB,146 OPTION_DFLT_REFRESH,147 OPTION_MODESET_CLEAR_SCREEN148 } VBOXOpts;149 150 156 /* No options for now */ 151 157 static const OptionInfoRec VBOXOptions[] = { … … 153 159 }; 154 160 161 static VBOXPtr 162 VBOXGetRec(ScrnInfoPtr pScrn) 163 { 164 if (!pScrn->driverPrivate) { 165 pScrn->driverPrivate = xcalloc(sizeof(VBOXRec), 1); 166 ((VBOXPtr)pScrn->driverPrivate)->vbox_fd = -1; 167 } 168 169 return ((VBOXPtr)pScrn->driverPrivate); 170 } 171 172 static void 173 VBOXFreeRec(ScrnInfoPtr pScrn) 174 { 175 VBOXPtr pVBox = VBOXGetRec(pScrn); 176 #if 0 177 xfree(pVBox->vbeInfo); 178 #endif 179 xfree(pVBox->savedPal); 180 xfree(pVBox->fonts); 181 xfree(pScrn->driverPrivate); 182 pScrn->driverPrivate = NULL; 183 } 184 185 /* X.org 1.3+ mode-setting support ******************************************/ 186 187 /* For descriptions of these functions and structures, see 188 hw/xfree86/modes/xf86Crtc.h and hw/xfree86/modes/xf86Modes.h in the 189 X.Org source tree. */ 190 191 static Bool 192 VBOXCrtcResize(ScrnInfoPtr scrn, int width, int height) 193 { 194 int bpp = scrn->bitsPerPixel; 195 ScreenPtr pScreen = scrn->pScreen; 196 PixmapPtr pPixmap = NULL; 197 VBOXPtr pVBox = VBOXGetRec(scrn); 198 Bool rc = TRUE; 199 200 TRACE3("width=%d, height=%d\n", width, height); 201 /* We only support horizontal resolutions which are a multiple of 8. Round down if 202 necessary. */ 203 if (width % 8 != 0) 204 { 205 xf86DrvMsg(scrn->scrnIndex, X_WARNING, 206 "VirtualBox only supports virtual screen widths which are a multiple of 8. Rounding up from %d to %d\n", 207 width, width - (width % 8) + 8); 208 width = width - (width % 8) + 8; 209 } 210 if (width * height * bpp / 8 >= scrn->videoRam * 1024) 211 { 212 xf86DrvMsg(scrn->scrnIndex, X_ERROR, 213 "Unable to set up a virtual screen size of %dx%d with %d Kb of video memory. Please increase the video memory size.\n", 214 width, height, scrn->videoRam); 215 rc = FALSE; 216 } 217 if (rc) { 218 pPixmap = pScreen->GetScreenPixmap(pScreen); 219 if (NULL == pPixmap) { 220 xf86DrvMsg(scrn->scrnIndex, X_ERROR, 221 "Failed to get the screen pixmap.\n"); 222 rc = FALSE; 223 } 224 } 225 if (rc) { 226 TRACE3("Setting screen pixmap parameters: width=%d, height=%d, depth=%d, bpp=%d, stride=%d, VRAM=%p\n", width, height, scrn->depth, bpp, width * bpp / 8, pVBox->base); 227 if ( 228 !pScreen->ModifyPixmapHeader(pPixmap, width, height, 229 scrn->depth, bpp, width * bpp / 8, 230 pVBox->base) 231 ) { 232 xf86DrvMsg(scrn->scrnIndex, X_ERROR, 233 "Failed to set up the screen pixmap.\n"); 234 rc = FALSE; 235 } 236 } 237 if (rc) { 238 scrn->virtualX = width; 239 scrn->virtualY = height; 240 scrn->displayWidth = width; 241 } 242 TRACE3("returning %s\n", rc ? "TRUE" : "FALSE"); 243 return rc; 244 } 245 246 static const xf86CrtcConfigFuncsRec VBOXCrtcConfigFuncs = { 247 VBOXCrtcResize 248 }; 249 250 static void 251 vbox_crtc_dpms(xf86CrtcPtr crtc, int mode) 252 { TRACE; (void) crtc; (void) mode; } 253 254 static Bool 255 vbox_crtc_lock (xf86CrtcPtr crtc) 256 { TRACE; (void) crtc; return FALSE; } 257 258 static Bool 259 vbox_crtc_mode_fixup (xf86CrtcPtr crtc, DisplayModePtr mode, 260 DisplayModePtr adjusted_mode) 261 { 262 ScrnInfoPtr pScrn = crtc->scrn; 263 int xRes = adjusted_mode->HDisplay; 264 265 TRACE; 266 (void) mode; 267 /* We only support horizontal resolutions which are a multiple of 8. Round down if 268 necessary. */ 269 if (xRes % 8 != 0) 270 { 271 xf86DrvMsg(pScrn->scrnIndex, X_WARNING, 272 "VirtualBox only supports screen widths which are a multiple of 8. Rounding down from %d to %d\n", 273 xRes, xRes - (xRes % 8)); 274 adjusted_mode->HDisplay = xRes - (xRes % 8); 275 } 276 TRACE2; 277 return TRUE; 278 } 279 280 static void 281 vbox_crtc_stub (xf86CrtcPtr crtc) 282 { TRACE; (void) crtc; } 283 284 static void 285 vbox_crtc_mode_set (xf86CrtcPtr crtc, DisplayModePtr mode, 286 DisplayModePtr adjusted_mode, int x, int y) 287 { 288 (void) mode; 289 TRACE; 290 VBOXSetMode(crtc->scrn, adjusted_mode); 291 VBOXAdjustFrame(crtc->scrn->scrnIndex, x, y, 0); 292 TRACE2; 293 } 294 295 static void 296 vbox_crtc_gamma_set (xf86CrtcPtr crtc, CARD16 *red, 297 CARD16 *green, CARD16 *blue, int size) 298 { TRACE; (void) crtc; (void) red; (void) green; (void) blue; (void) size; } 299 300 static void * 301 vbox_crtc_shadow_allocate (xf86CrtcPtr crtc, int width, int height) 302 { TRACE; (void) crtc; (void) width; (void) height; return NULL; } 303 304 static const xf86CrtcFuncsRec VBOXCrtcFuncs = { 305 .dpms = vbox_crtc_dpms, 306 .save = NULL, /* These two are never called by the server. */ 307 .restore = NULL, 308 .lock = vbox_crtc_lock, 309 .unlock = NULL, /* This will not be invoked if lock returns FALSE. */ 310 .mode_fixup = vbox_crtc_mode_fixup, 311 .prepare = vbox_crtc_stub, 312 .mode_set = vbox_crtc_mode_set, 313 .commit = vbox_crtc_stub, 314 .gamma_set = vbox_crtc_gamma_set, 315 .shadow_allocate = vbox_crtc_shadow_allocate, 316 .shadow_create = NULL, /* These two should not be invoked if allocate 317 returns NULL. */ 318 .shadow_destroy = NULL, 319 .set_cursor_colors = NULL, /* We are still using the old cursor API. */ 320 .set_cursor_position = NULL, 321 .show_cursor = NULL, 322 .hide_cursor = NULL, 323 .load_cursor_argb = NULL, 324 .destroy = vbox_crtc_stub 325 }; 326 327 static void 328 vbox_output_stub (xf86OutputPtr output) 329 { TRACE; (void) output; } 330 331 static void 332 vbox_output_dpms (xf86OutputPtr output, int mode) 333 { TRACE; (void) output; (void) mode; } 334 335 static int 336 vbox_output_mode_valid (xf86OutputPtr output, DisplayModePtr mode) 337 { 338 TRACE3("Modeline %s %f %d %d %d %d %d %d %d %d\n", 339 mode->name, mode->Clock * 1.0 / 1000, mode->HDisplay, mode->HSyncStart, 340 mode->HSyncEnd, mode->HTotal, mode->VDisplay, mode->VSyncStart, 341 mode->VSyncEnd, mode->VTotal); 342 (void) output; (void) mode; 343 return MODE_OK; 344 } 345 346 static Bool 347 vbox_output_mode_fixup (xf86OutputPtr output, DisplayModePtr mode, 348 DisplayModePtr adjusted_mode) 349 { TRACE; (void) output; (void) mode; (void) adjusted_mode; return TRUE; } 350 351 static void 352 vbox_output_mode_set (xf86OutputPtr output, DisplayModePtr mode, 353 DisplayModePtr adjusted_mode) 354 { TRACE; (void) output; (void) mode; (void) adjusted_mode; } 355 356 /* A virtual monitor is always connected. */ 357 static xf86OutputStatus 358 vbox_output_detect (xf86OutputPtr output) 359 { 360 (void) output; 361 return XF86OutputStatusConnected; 362 } 363 364 static void 365 vbox_output_add_mode (DisplayModePtr *pModes, const char *pszName, int x, int y, 366 Bool isPreferred) 367 { 368 DisplayModePtr pMode = xnfcalloc(1, sizeof(DisplayModeRec)); 369 370 pMode->status = MODE_OK; 371 pMode->type = isPreferred ? M_T_PREFERRED : M_T_BUILTIN; 372 /* VBox only supports screen widths which are a multiple of 8 */ 373 pMode->HDisplay = (x + 7) & ~7; 374 pMode->HSyncStart = pMode->HDisplay + 2; 375 pMode->HSyncEnd = pMode->HDisplay + 4; 376 pMode->HTotal = pMode->HDisplay + 6; 377 pMode->VDisplay = y; 378 pMode->VSyncStart = pMode->VDisplay + 2; 379 pMode->VSyncEnd = pMode->VDisplay + 4; 380 pMode->VTotal = pMode->VDisplay + 6; 381 pMode->Clock = pMode->HTotal * pMode->VTotal * 60 / 1000; /* kHz */ 382 if (NULL == pszName) { 383 xf86SetModeDefaultName(pMode); 384 } else { 385 pMode->name = xnfstrdup(pszName); 386 } 387 *pModes = xf86ModesAdd(*pModes, pMode); 388 } 389 390 static DisplayModePtr 391 vbox_output_get_modes (xf86OutputPtr output) 392 { 393 uint32_t x, y, bpp; 394 int rc; 395 DisplayModePtr pModes = NULL; 396 ScrnInfoPtr pScrn = output->scrn; 397 398 TRACE; 399 rc = vboxGetDisplayChangeRequest(pScrn, &x, &y, &bpp, 0, 0); 400 if (RT_SUCCESS(rc) && (0 != x) && (0 != y)) { 401 TRACE3("Adding host mode %dx%d\n", x, y); 402 vbox_output_add_mode(&pModes, NULL, x, y, TRUE); 403 vbox_output_add_mode(&pModes, "1024x768", 1024, 768, FALSE); 404 vbox_output_add_mode(&pModes, "800x600", 800, 600, FALSE); 405 vbox_output_add_mode(&pModes, "640x480", 640, 480, FALSE); 406 } else { 407 vbox_output_add_mode(&pModes, "1024x768", 1024, 768, FALSE); 408 vbox_output_add_mode(&pModes, "800x600", 800, 600, FALSE); 409 vbox_output_add_mode(&pModes, "640x480", 640, 480, FALSE); 410 } 411 TRACE2; 412 return pModes; 413 } 414 415 #ifdef RANDR_12_INTERFACE 416 /* We don't yet have mutable properties, whatever they are. */ 417 static Bool 418 vbox_output_set_property(xf86OutputPtr output, Atom property, 419 RRPropertyValuePtr value) 420 { TRACE; (void) output, (void) property, (void) value; return FALSE; } 421 #endif 422 423 static const xf86OutputFuncsRec VBOXOutputFuncs = { 424 .create_resources = vbox_output_stub, 425 .dpms = vbox_output_dpms, 426 .save = NULL, /* These two are never called by the server. */ 427 .restore = NULL, 428 .mode_valid = vbox_output_mode_valid, 429 .mode_fixup = vbox_output_mode_fixup, 430 .prepare = vbox_output_stub, 431 .commit = vbox_output_stub, 432 .mode_set = vbox_output_mode_set, 433 .detect = vbox_output_detect, 434 .get_modes = vbox_output_get_modes, 435 #ifdef RANDR_12_INTERFACE 436 .set_property = vbox_output_set_property, 437 #endif 438 .destroy = vbox_output_stub 439 }; 440 155 441 /* 156 442 * List of symbols from other modules that this module references. This 157 443 * list is used to tell the loader that it is OK for symbols here to be 158 * unresolved providing that it hasn't been told that they haven't been159 * told that they are essential via a call to xf86LoaderReqSymbols() or160 * xf86LoaderReqSymLists(). The purpose is this is to avoid warnings about161 * unresolved symbols that arenot required.444 * unresolved providing that it hasn't been told that they are essential 445 * via a call to xf86LoaderReqSymbols() or xf86LoaderReqSymLists(). The 446 * purpose is this is to avoid warnings about unresolved symbols that are 447 * not required. 162 448 */ 163 449 static const char *fbSymbols[] = { … … 323 609 } 324 610 325 static VBOXPtr326 VBOXGetRec(ScrnInfoPtr pScrn)327 {328 if (!pScrn->driverPrivate)329 {330 pScrn->driverPrivate = xcalloc(sizeof(VBOXRec), 1);331 ((VBOXPtr)pScrn->driverPrivate)->vbox_fd = -1;332 }333 334 return ((VBOXPtr)pScrn->driverPrivate);335 }336 337 static void338 VBOXFreeRec(ScrnInfoPtr pScrn)339 {340 VBOXPtr pVBox = VBOXGetRec(pScrn);341 #if 0342 xfree(pVBox->vbeInfo);343 #endif344 xfree(pVBox->savedPal);345 xfree(pVBox->fonts);346 xfree(pScrn->driverPrivate);347 pScrn->driverPrivate = NULL;348 }349 350 611 /* 351 612 * QUOTE from the XFree86 DESIGN document: … … 378 639 Gamma gzeros = {0.0, 0.0, 0.0}; 379 640 rgb rzeros = {0, 0, 0}; 380 ClockRange *clockRanges; 381 int i; 382 DisplayModePtr m_prev; 641 xf86OutputPtr output; 383 642 384 643 /* Are we really starting the server, or is this just a dummy run? */ … … 428 687 pScrn->rgbBits = 8; 429 688 430 /* Let's create a nice, capable virtual monitor. */689 /* I assume that this is no longer a requirement in the config file. */ 431 690 pScrn->monitor = pScrn->confScreen->monitor; 432 pScrn->monitor->DDC = NULL;433 pScrn->monitor->nHsync = 1;434 pScrn->monitor->hsync[0].lo = 1;435 pScrn->monitor->hsync[0].hi = 10000;436 pScrn->monitor->nVrefresh = 1;437 pScrn->monitor->vrefresh[0].lo = 1;438 pScrn->monitor->vrefresh[0].hi = 100;439 691 440 692 pScrn->chipset = "vbox"; 441 693 pScrn->progClock = TRUE; 442 694 443 /* Determine the size of the VBox video RAM from PCI data*/444 #if 0445 pScrn->videoRam = 1 << pVBox->pciInfo->size[0];446 #endif447 695 /* Using the PCI information caused problems with non-powers-of-two 448 696 sized video RAM configurations */ 449 697 pScrn->videoRam = inl(VBE_DISPI_IOPORT_DATA) / 1024; 450 451 /* Set up clock information that will support all modes we need. */452 clockRanges = xnfcalloc(sizeof(ClockRange), 1);453 clockRanges->next = NULL;454 clockRanges->minClock = 1000;455 clockRanges->maxClock = 1000000000;456 clockRanges->clockIndex = -1;457 clockRanges->ClockMulFactor = 1;458 clockRanges->ClockDivFactor = 1;459 698 460 699 /* This function asks X to choose a depth and bpp based on the … … 476 715 xf86PrintDepthBpp(pScrn); 477 716 478 /* Colour weight - we always call this, since we are always in479 truecolour. */480 if (!xf86SetWeight(pScrn, rzeros, rzeros))481 return (FALSE);482 483 /* visual init */484 if (!xf86SetDefaultVisual(pScrn, -1))485 return (FALSE);486 487 xf86SetGamma(pScrn, gzeros);488 489 /* To get around the problem of SUSE specifying a single, invalid mode in their490 * Xorg.conf by default, we add an additional mode to the end of the user specified491 * list. This means that if all user modes are invalid, X will try our mode before492 * falling back to its standard mode list. */493 if (pScrn->display->modes == NULL)494 {495 /* The user specified no modes at all - specify 1024x768 as a default. */496 pScrn->display->modes = xnfalloc(4 * sizeof(char*));497 pScrn->display->modes[0] = "1024x768";498 pScrn->display->modes[1] = "800x600";499 pScrn->display->modes[2] = "640x480";500 pScrn->display->modes[3] = NULL;501 }502 else503 {504 /* Add 1024x768 to the end of the mode list in case the others are all invalid. */505 for (i = 0; pScrn->display->modes[i] != NULL; i++);506 pScrn->display->modes = xnfrealloc(pScrn->display->modes, (i + 4)507 * sizeof(char *));508 pScrn->display->modes[i ] = "1024x768";509 pScrn->display->modes[i+1] = "800x600";510 pScrn->display->modes[i+2] = "640x480";511 pScrn->display->modes[i+3] = NULL;512 }513 514 /* Determine the virtual screen resolution from the first mode (which will be selected) */515 sscanf(pScrn->display->modes[0], "%dx%d",516 &pScrn->display->virtualX, &pScrn->display->virtualY);517 pScrn->display->virtualX = (pScrn->display->virtualX + 7) & ~7;518 519 /* Create a builtin mode for every specified mode. This allows to specify arbitrary520 * screen resolutions */521 m_prev = NULL;522 for (i = 0; pScrn->display->modes[i] != NULL; i++)523 {524 DisplayModePtr m;525 int x = 0, y = 0;526 527 sscanf(pScrn->display->modes[i], "%dx%d", &x, &y);528 /* sanity check, smaller resolutions does not make sense */529 if (x < 64 || y < 64)530 {531 xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Ignoring mode \"%s\"\n",532 pScrn->display->modes[i]);533 continue;534 }535 m = xnfcalloc(sizeof(DisplayModeRec), 1);536 m->status = MODE_OK;537 m->type = M_T_BUILTIN;538 /* VBox does only support screen widths which are a multiple of 8 */539 m->HDisplay = (x + 7) & ~7;540 m->HSyncStart = m->HDisplay + 2;541 m->HSyncEnd = m->HDisplay + 4;542 m->HTotal = m->HDisplay + 6;543 m->VDisplay = y;544 m->VSyncStart = m->VDisplay + 2;545 m->VSyncEnd = m->VDisplay + 4;546 m->VTotal = m->VDisplay + 6;547 m->Clock = m->HTotal * m->VTotal * 60 / 1000; /* kHz */548 m->name = strdup(pScrn->display->modes[i]);549 if (!m_prev)550 pScrn->modePool = m;551 else552 m_prev->next = m;553 m->prev = m_prev;554 m_prev = m;555 }556 557 /* Filter out video modes not supported by the virtual hardware558 we described. All modes used by the Windows additions should559 work fine. */560 i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,561 pScrn->display->modes,562 clockRanges, NULL, 0, 6400, 1, 0, 1440,563 pScrn->display->virtualX,564 pScrn->display->virtualY,565 pScrn->videoRam, LOOKUP_BEST_REFRESH);566 567 if (i <= 0) {568 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No usable graphics modes found.\n");569 return (FALSE);570 }571 xf86PruneDriverModes(pScrn);572 573 pScrn->currentMode = pScrn->modes;574 pScrn->displayWidth = pScrn->virtualX;575 576 xf86PrintModes(pScrn);577 578 /* Set display resolution. This was arbitrarily chosen to be about the same as my monitor. */579 xf86SetDpi(pScrn, 100, 100);580 581 if (pScrn->modes == NULL) {582 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No graphics modes available\n");583 return (FALSE);584 }585 586 717 /* options */ 587 718 xf86CollectOptions(pScrn, NULL); … … 591 722 xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pVBox->Options); 592 723 724 /* Initialise CRTC and output configuration for use with randr1.2. */ 725 xf86CrtcConfigInit(pScrn, &VBOXCrtcConfigFuncs); 726 727 /* Setup our single virtual CRTC. */ 728 xf86CrtcCreate(pScrn, &VBOXCrtcFuncs); 729 730 /* Set up our single virtual output. */ 731 output = xf86OutputCreate(pScrn, &VBOXOutputFuncs, "Virtual Output"); 732 733 /* Set a sane minimum and maximum mode size */ 734 xf86CrtcSetSizeRange(pScrn, 64, 64, 102400, 76800); 735 736 /* I don't know exactly what these are for (and they are only used in a couple 737 of places in the X server code), but due to a bug in RandR 1.2 they place 738 an upper limit on possible resolutions. To add to the fun, they get set 739 automatically if we don't do it ourselves. */ 740 pScrn->display->virtualX = 102400; 741 pScrn->display->virtualY = 76800; 742 743 /* We are not interested in the monitor section in the configuration file. */ 744 xf86OutputUseScreenMonitor(output, FALSE); 745 output->possible_crtcs = 1; 746 output->possible_clones = 0; 747 748 /* Now create our initial CRTC/output configuration. */ 749 if (!xf86InitialConfiguration(pScrn, TRUE)) { 750 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Initial CRTC configuration failed!\n"); 751 return (FALSE); 752 } 753 754 /* Colour weight - we always call this, since we are always in 755 truecolour. */ 756 if (!xf86SetWeight(pScrn, rzeros, rzeros)) 757 return (FALSE); 758 759 /* visual init */ 760 if (!xf86SetDefaultVisual(pScrn, -1)) 761 return (FALSE); 762 763 xf86SetGamma(pScrn, gzeros); 764 765 /* Set a default display resolution. */ 766 xf86SetDpi(pScrn, 96, 96); 767 593 768 /* Framebuffer-related setup */ 594 769 pScrn->bitmapBitOrder = BITMAP_BIT_ORDER; 770 595 771 return (TRUE); 596 772 } … … 641 817 pVBox->savedPal = VBESetGetPaletteData(pVBox->pVbe, FALSE, 0, 256, 642 818 NULL, FALSE, FALSE); 643 644 /* set first video mode */645 if (!VBOXSetMode(pScrn, pScrn->currentMode))646 return FALSE;647 648 /* set the viewport */649 VBOXAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);650 651 /* Blank the screen for aesthetic reasons. */652 VBOXSaveScreen(pScreen, SCREEN_SAVER_ON);653 819 654 820 /* mi layer - reset the visual list (?)*/ … … 667 833 pScrn->virtualX, pScrn->virtualY, 668 834 pScrn->xDpi, pScrn->yDpi, 669 pScrn-> displayWidth, pScrn->bitsPerPixel))835 pScrn->virtualX, pScrn->bitsPerPixel)) 670 836 return (FALSE); 671 837 … … 686 852 fbPictureInit(pScreen, 0, 0); 687 853 688 VBOXDGAInit(pScrn, pScreen);689 690 854 xf86SetBlackWhitePixels(pScreen); 691 855 miInitializeBackingStore(pScreen); 692 856 xf86SetBackingStore(pScreen); 857 858 /* Initialise DGA. The cast is unfortunately correct - it gets cast back 859 to (unsigned char *) later. */ 860 xf86DiDGAInit(pScreen, (unsigned long) pVBox->base); 861 862 /* Initialise randr 1.2 mode-setting functions and set first mode. */ 863 if (!xf86CrtcScreenInit(pScreen)) { 864 return FALSE; 865 } 866 867 if (!xf86SetDesiredModes(pScrn)) { 868 return FALSE; 869 } 870 871 /* set the viewport */ 872 VBOXAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); 693 873 694 874 /* software cursor */ … … 708 888 pVBox->CloseScreen = pScreen->CloseScreen; 709 889 pScreen->CloseScreen = VBOXCloseScreen; 710 pScreen->SaveScreen = VBOXSaveScreen;711 712 /* However, we probably do want to support power management -713 even if we just usea dummy function. */714 xf86DPMSInit(pScreen, VBOXDisplayPowerManagementSet, 0);890 pScreen->SaveScreen = xf86SaveScreen; 891 892 /* We probably do want to support power management - even if we just use 893 a dummy function. */ 894 xf86DPMSInit(pScreen, xf86DPMSSet, 0); 715 895 716 896 /* Report any unused options (only for the first generation) */ … … 734 914 { 735 915 ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; 736 VBOXPtr pVBox = VBOXGetRec(pScrn); 737 738 if (!VBOXSetMode(pScrn, pScrn->currentMode)) 739 return FALSE; 740 VBOXAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); 741 if (pVBox->useVbva == TRUE) 742 vboxEnableVbva(pScrn); 743 return TRUE; 916 917 return xf86SetDesiredModes(pScrn); 744 918 } 745 919 … … 770 944 VBOXUnmapVidMem(pScrn); 771 945 } 772 if (pVBox->pDGAMode) {773 xfree(pVBox->pDGAMode);774 pVBox->pDGAMode = NULL;775 pVBox->nDGAMode = 0;776 }777 946 pScrn->vtSema = FALSE; 778 947 … … 811 980 } 812 981 } 982 #if 0 813 983 /* 814 984 * First off, if this isn't a mode we handed to the server (ie, … … 817 987 if (!(p->type & M_T_BUILTIN)) 818 988 return MODE_NOMODE; 989 #endif 819 990 /* 820 991 * Finally, walk through the vsync rates 1Hz at a time looking for a mode … … 842 1013 { 843 1014 ScrnInfoPtr pScrn; 1015 1016 pScrn = xf86Screens[scrnIndex]; /* Why does X have three ways of refering to the screen? */ 1017 return xf86SetSingleMode(pScrn, pMode, 0); 1018 } 1019 1020 /* Set a graphics mode */ 1021 static Bool 1022 VBOXSetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode) 1023 { 844 1024 VBOXPtr pVBox; 845 1025 846 pScrn = xf86Screens[scrnIndex]; /* Why does X have three ways of refering to the screen? */1026 int bpp = pScrn->depth == 24 ? 32 : 16; 847 1027 pVBox = VBOXGetRec(pScrn); 848 1028 if (pVBox->useVbva == TRUE) 849 1029 if (vboxDisableVbva(pScrn) != TRUE) /* This would be bad. */ 850 1030 return FALSE; 851 if (VBOXSetMode(pScrn, pMode) != TRUE)852 return FALSE;853 if (pVBox->useVbva == TRUE)854 if (vboxEnableVbva(pScrn) != TRUE) /* Bad but not fatal */855 pVBox->useVbva = FALSE;856 return TRUE;857 }858 859 /* Set a graphics mode */860 static Bool861 VBOXSetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode)862 {863 VBOXPtr pVBox;864 865 int bpp = pScrn->depth == 24 ? 32 : 16;866 int xRes = pMode->HDisplay;867 if (pScrn->virtualX * pScrn->virtualY * bpp / 8868 >= pScrn->videoRam * 1024)869 {870 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,871 "Unable to set up a virtual screen size of %dx%d with %d Kb of video memory. Please increase the video memory size.\n",872 pScrn->virtualX, pScrn->virtualY, pScrn->videoRam);873 return FALSE;874 }875 /* We only support horizontal resolutions which are a multiple of 8. Round down if876 necessary. */877 if (xRes % 8 != 0)878 {879 xf86DrvMsg(pScrn->scrnIndex, X_WARNING,880 "VirtualBox only supports screen widths which are a multiple of 8. Rounding down from %d to %d\n",881 xRes, xRes - (xRes % 8));882 xRes = xRes - (xRes % 8);883 }884 pVBox = VBOXGetRec(pScrn);885 1031 pScrn->vtSema = TRUE; 886 1032 /* Disable linear framebuffer mode before making changes to the resolution. */ … … 895 1041 the display part of the scanlines. */ 896 1042 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES); 897 outw(VBE_DISPI_IOPORT_DATA, xRes);1043 outw(VBE_DISPI_IOPORT_DATA, pMode->HDisplay); 898 1044 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES); 899 1045 outw(VBE_DISPI_IOPORT_DATA, pMode->VDisplay); … … 906 1052 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VIRT_WIDTH); 907 1053 outw(VBE_DISPI_IOPORT_DATA, pScrn->displayWidth); 1054 if (pVBox->useVbva == TRUE) 1055 if (vboxEnableVbva(pScrn) != TRUE) /* Bad but not fatal */ 1056 pVBox->useVbva = FALSE; 908 1057 return (TRUE); 909 1058 } … … 1188 1337 } 1189 1338 1190 static Bool1191 VBOXSaveScreen(ScreenPtr pScreen, int mode)1192 {1193 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];1194 VBOXPtr pVBox = VBOXGetRec(pScrn);1195 Bool on = xf86IsUnblank(mode);1196 1197 if (on)1198 SetTimeSinceLastInputEvent();1199 1200 if (pScrn->vtSema) {1201 unsigned char scrn = ReadSeq(pVBox, 0x01);1202 1203 if (on)1204 scrn &= ~0x20;1205 else1206 scrn |= 0x20;1207 SeqReset(pVBox, TRUE);1208 WriteSeq(0x01, scrn);1209 SeqReset(pVBox, FALSE);1210 }1211 1212 return (TRUE);1213 }1214 1215 1339 Bool 1216 1340 VBOXSaveRestore(ScrnInfoPtr pScrn, vbeSaveRestoreFunction function) … … 1271 1395 return (TRUE); 1272 1396 } 1273 1274 static void1275 VBOXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int mode,1276 int flags)1277 {1278 /* VBox is always power efficient... */1279 }1280 1281 1282 1283 1284 /***********************************************************************1285 * DGA stuff1286 ***********************************************************************/1287 static Bool VBOXDGAOpenFramebuffer(ScrnInfoPtr pScrn, char **DeviceName,1288 unsigned char **ApertureBase,1289 int *ApertureSize, int *ApertureOffset,1290 int *flags);1291 static Bool VBOXDGASetMode(ScrnInfoPtr pScrn, DGAModePtr pDGAMode);1292 static void VBOXDGASetViewport(ScrnInfoPtr pScrn, int x, int y, int flags);1293 1294 static Bool1295 VBOXDGAOpenFramebuffer(ScrnInfoPtr pScrn, char **DeviceName,1296 unsigned char **ApertureBase, int *ApertureSize,1297 int *ApertureOffset, int *flags)1298 {1299 VBOXPtr pVBox = VBOXGetRec(pScrn);1300 1301 *DeviceName = NULL; /* No special device */1302 *ApertureBase = (unsigned char *)(long)(pVBox->mapPhys);1303 *ApertureSize = pVBox->mapSize;1304 *ApertureOffset = pVBox->mapOff;1305 *flags = DGA_NEED_ROOT;1306 1307 return (TRUE);1308 }1309 1310 static Bool1311 VBOXDGASetMode(ScrnInfoPtr pScrn, DGAModePtr pDGAMode)1312 {1313 DisplayModePtr pMode;1314 int scrnIdx = pScrn->pScreen->myNum;1315 int frameX0, frameY0;1316 1317 if (pDGAMode) {1318 pMode = pDGAMode->mode;1319 frameX0 = frameY0 = 0;1320 }1321 else {1322 if (!(pMode = pScrn->currentMode))1323 return (TRUE);1324 1325 frameX0 = pScrn->frameX0;1326 frameY0 = pScrn->frameY0;1327 }1328 1329 if (!(*pScrn->SwitchMode)(scrnIdx, pMode, 0))1330 return (FALSE);1331 (*pScrn->AdjustFrame)(scrnIdx, frameX0, frameY0, 0);1332 1333 return (TRUE);1334 }1335 1336 static void1337 VBOXDGASetViewport(ScrnInfoPtr pScrn, int x, int y, int flags)1338 {1339 (*pScrn->AdjustFrame)(pScrn->pScreen->myNum, x, y, flags);1340 }1341 1342 static int1343 VBOXDGAGetViewport(ScrnInfoPtr pScrn)1344 {1345 return (0);1346 }1347 1348 static DGAFunctionRec VBOXDGAFunctions =1349 {1350 VBOXDGAOpenFramebuffer,1351 NULL, /* CloseFramebuffer */1352 VBOXDGASetMode,1353 VBOXDGASetViewport,1354 VBOXDGAGetViewport,1355 NULL, /* Sync */1356 NULL, /* FillRect */1357 NULL, /* BlitRect */1358 NULL, /* BlitTransRect */1359 };1360 1361 static void1362 VBOXDGAAddModes(ScrnInfoPtr pScrn)1363 {1364 VBOXPtr pVBox = VBOXGetRec(pScrn);1365 DisplayModePtr pMode = pScrn->modes;1366 DGAModePtr pDGAMode;1367 1368 do {1369 pDGAMode = xrealloc(pVBox->pDGAMode,1370 (pVBox->nDGAMode + 1) * sizeof(DGAModeRec));1371 if (!pDGAMode)1372 break;1373 1374 pVBox->pDGAMode = pDGAMode;1375 pDGAMode += pVBox->nDGAMode;1376 (void)memset(pDGAMode, 0, sizeof(DGAModeRec));1377 1378 ++pVBox->nDGAMode;1379 pDGAMode->mode = pMode;1380 pDGAMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE;1381 pDGAMode->byteOrder = pScrn->imageByteOrder;1382 pDGAMode->depth = pScrn->depth;1383 pDGAMode->bitsPerPixel = pScrn->bitsPerPixel;1384 pDGAMode->red_mask = pScrn->mask.red;1385 pDGAMode->green_mask = pScrn->mask.green;1386 pDGAMode->blue_mask = pScrn->mask.blue;1387 pDGAMode->visualClass = TrueColor;1388 pDGAMode->xViewportStep = 1;1389 pDGAMode->yViewportStep = 1;1390 pDGAMode->viewportWidth = pMode->HDisplay;1391 pDGAMode->viewportHeight = pMode->VDisplay;1392 1393 pDGAMode->bytesPerScanline = pVBox->maxBytesPerScanline;1394 pDGAMode->imageWidth = pMode->HDisplay;1395 pDGAMode->imageHeight = pMode->VDisplay;1396 pDGAMode->pixmapWidth = pDGAMode->imageWidth;1397 pDGAMode->pixmapHeight = pDGAMode->imageHeight;1398 pDGAMode->maxViewportX = pScrn->virtualX -1399 pDGAMode->viewportWidth;1400 pDGAMode->maxViewportY = pScrn->virtualY -1401 pDGAMode->viewportHeight;1402 1403 pDGAMode->address = pVBox->base;1404 1405 pMode = pMode->next;1406 } while (pMode != pScrn->modes);1407 }1408 1409 static Bool1410 VBOXDGAInit(ScrnInfoPtr pScrn, ScreenPtr pScreen)1411 {1412 VBOXPtr pVBox = VBOXGetRec(pScrn);1413 1414 if (!pVBox->nDGAMode)1415 VBOXDGAAddModes(pScrn);1416 1417 return (DGAInit(pScreen, &VBOXDGAFunctions,1418 pVBox->pDGAMode, pVBox->nDGAMode));1419 }
Note:
See TracChangeset
for help on using the changeset viewer.