Changeset 7168 in vbox for trunk/src/VBox/Additions/x11
- Timestamp:
- Feb 27, 2008 12:47:42 PM (17 years ago)
- Location:
- trunk/src/VBox/Additions/x11/xgraphics
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/xgraphics/vboxutils.c
r7087 r7168 119 119 xfree (pVBox->reqp); 120 120 pVBox->reqp = NULL; 121 122 VbglR3Term();123 121 } 124 122 … … 308 306 309 307 Bool 308 vbox_init(int scrnIndex) 309 { 310 Bool rc = TRUE; 311 int vrc = VbglR3Init(); 312 if (RT_FAILURE(vrc)) 313 { 314 xf86DrvMsg(scrnIndex, X_ERROR, "VbglR3Init failed rc=%d.\n", rc); 315 rc = FALSE; 316 } 317 return rc; 318 } 319 320 Bool 310 321 vbox_open(ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBox) 311 322 { … … 324 335 pVBox->useVbva = vboxInitVbva(scrnIndex, pScreen, pVBox); 325 336 return TRUE; 326 }327 328 rc = VbglR3Init();329 if (RT_FAILURE(rc))330 {331 xf86DrvMsg(scrnIndex, X_ERROR, "VbglR3Init failed rc=%d.\n", rc);332 return FALSE;333 337 } 334 338 … … 352 356 } 353 357 xf86DrvMsg(scrnIndex, X_ERROR, "Could not allocate %lu bytes for VMM request\n", (unsigned long)size); 354 VbglR3Term();355 358 return FALSE; 356 359 } -
trunk/src/VBox/Additions/x11/xgraphics/vboxvideo.h
r6849 r7168 183 183 #endif 184 184 185 Bool vbox_cursor_init (ScreenPtr pScreen); 186 Bool vbox_open (ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBOX); 187 void vbox_close (ScrnInfoPtr pScrn, VBOXPtr pVBOX); 185 extern Bool vbox_init(int scrnIndex); 186 extern Bool vbox_cursor_init (ScreenPtr pScreen); 187 extern Bool vbox_open (ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBOX); 188 extern void vbox_close (ScrnInfoPtr pScrn, VBOXPtr pVBOX); 188 189 189 190 extern Bool vboxEnableVbva(ScrnInfoPtr pScrn); -
trunk/src/VBox/Additions/x11/xgraphics/vboxvideo_13.c
r6849 r7168 409 409 vbox_output_add_mode(&pModes, NULL, x, y, TRUE); 410 410 } 411 vbox_output_add_mode(&pModes, "1024x768", 1024, 768, FALSE);412 vbox_output_add_mode(&pModes, "800x600", 800, 600, FALSE);413 vbox_output_add_mode(&pModes, "640x480", 640, 480, FALSE);411 vbox_output_add_mode(&pModes, NULL, 1024, 768, FALSE); 412 vbox_output_add_mode(&pModes, NULL, 800, 600, FALSE); 413 vbox_output_add_mode(&pModes, NULL, 640, 480, FALSE); 414 414 TRACE2; 415 415 return pModes; … … 648 648 return (FALSE); 649 649 650 xf86Msg(X_INFO, 651 "VirtualBox guest additions video driver version " 652 VBOX_VERSION_STRING "\n"); 650 xf86DrvMsg(pScrn->scrnIndex, X_INFO, 651 "VirtualBox guest additions video driver version " 652 VBOX_VERSION_STRING "\n"); 653 654 /* Initialise the guest library */ 655 if (!vbox_init(pScrn->scrnIndex)) 656 return FALSE; 653 657 654 658 /* Get our private data from the ScrnInfoRec structure. */ … … 700 704 pScrn->videoRam = inl(VBE_DISPI_IOPORT_DATA) / 1024; 701 705 702 /* This function asks X to choose a depth and bpp based on the 703 config file and the command line, and gives a default in 704 case none is specified. Note that we only support 32bpp, not 705 24bpp. After spending ages looking through the XFree86 4.2 706 source code however, I realised that it automatically uses 707 32bpp for depth 24 unless you explicitly add a "24 24" 708 format to its internal list. */ 709 if (!xf86SetDepthBpp(pScrn, pScrn->videoRam >= 2048 ? 24 : 16, 0, 0, 710 Support32bppFb)) 711 return FALSE; 712 if (pScrn->depth != 24 && pScrn->depth != 16) 706 /* Query the host for the preferred colour depth */ 707 { 708 uint32_t cx, cy, iDisplay, cBits = 24; 709 710 /* We only support 16 and 24 bits depth (i.e. 16 and 32bpp) */ 711 if ( vboxGetDisplayChangeRequest(pScrn, &cx, &cy, &cBits, &iDisplay) 712 && (cBits != 16)) 713 cBits = 24; 714 if (!xf86SetDepthBpp(pScrn, cBits, 0, 0, Support32bppFb)) 715 return FALSE; 716 } 717 if (pScrn->bitsPerPixel != 32 && pScrn->bitsPerPixel != 16) 713 718 { 714 719 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, … … 734 739 output = xf86OutputCreate(pScrn, &VBOXOutputFuncs, "Virtual Output"); 735 740 736 /* Set a sane minimum and maximum mode size */ 737 xf86CrtcSetSizeRange(pScrn, 64, 64, 64000, 64000); 738 739 /* I don't know exactly what these are for (and they are only used in a couple 740 of places in the X server code), but due to a bug in RandR 1.2 they place 741 an upper limit on possible resolutions. To add to the fun, they get set 742 automatically if we don't do it ourselves. */ 743 pScrn->display->virtualX = 64000; 744 pScrn->display->virtualY = 64000; 741 /* Set a sane minimum mode size and the maximum allowed by the available VRAM */ 742 /** @todo Make sure that the host resolution is supported if it fits into VRAM. */ 743 { 744 unsigned maxSize, trySize = 512; 745 746 do { 747 maxSize = trySize; 748 trySize += 128; 749 } while (trySize * trySize * pScrn->bitsPerPixel / 8 < pScrn->videoRam * 1024); 750 751 xf86CrtcSetSizeRange(pScrn, 64, 64, maxSize, maxSize); 752 753 /* I don't know exactly what these are for (and they are only used in a couple 754 of places in the X server code), but due to a bug in RandR 1.2 they place 755 an upper limit on possible resolutions. To add to the fun, they get set 756 automatically if we don't do it ourselves. */ 757 pScrn->display->virtualX = maxSize; 758 pScrn->display->virtualY = maxSize; 759 xf86DrvMsg(pScrn->scrnIndex, X_INFO, 760 "The maximum supported resolution is currently %dx%d\n", maxSize, maxSize); 761 } 745 762 746 763 /* We are not interested in the monitor section in the configuration file. */ … … 1047 1064 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES); 1048 1065 outw(VBE_DISPI_IOPORT_DATA, pMode->VDisplay); 1066 /* Set the virtual resolution. We are still using VESA to control 1067 the virtual offset. */ 1068 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VIRT_WIDTH); 1069 outw(VBE_DISPI_IOPORT_DATA, pScrn->displayWidth); 1049 1070 /* Enable linear framebuffer mode. */ 1050 1071 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ENABLE); 1051 1072 outw(VBE_DISPI_IOPORT_DATA, 1052 1073 VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED); 1053 /* Set the virtual resolution. We are still using VESA to control1054 the virtual offset. */1055 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VIRT_WIDTH);1056 outw(VBE_DISPI_IOPORT_DATA, pScrn->displayWidth);1057 1074 if (pVBox->useVbva == TRUE) 1058 1075 if (vboxEnableVbva(pScrn) != TRUE) /* Bad but not fatal */ -
trunk/src/VBox/Additions/x11/xgraphics/vboxvideo_68.c
r6643 r7168 371 371 return (FALSE); 372 372 373 xf86 Msg(X_INFO,374 "VirtualBox guest additions video driver version "375 VBOX_VERSION_STRING "\n");373 xf86DrvMsg(pScrn->scrnIndex, X_INFO, 374 "VirtualBox guest additions video driver version " 375 VBOX_VERSION_STRING "\n"); 376 376 377 377 /* Get our private data from the ScrnInfoRec structure. */ … … 453 453 Support32bppFb)) 454 454 return FALSE; 455 if (pScrn-> depth != 24 && pScrn->depth!= 16)455 if (pScrn->bitsPerPixel != 32 && pScrn->bitsPerPixel != 16) 456 456 { 457 457 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, … … 497 497 } 498 498 499 /* Determine the virtual screen resolution from the first mode (which will be selected) */500 sscanf(pScrn->display->modes[0], "%dx%d",501 &pScrn->display->virtualX, &pScrn->display->virtualY);502 pScrn->display->virtualX = (pScrn->display->virtualX + 7) & ~7;503 504 499 /* Create a builtin mode for every specified mode. This allows to specify arbitrary 505 500 * screen resolutions */ … … 511 506 512 507 sscanf(pScrn->display->modes[i], "%dx%d", &x, &y); 513 /* sanity check, smaller resolutions does not make sense */514 if (x < 64 || y < 64)515 {516 xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Ignoring mode \"%s\"\n",517 pScrn->display->modes[i]);518 continue;519 }520 508 m = xnfcalloc(sizeof(DisplayModeRec), 1); 521 509 m->status = MODE_OK; … … 533 521 } 534 522 523 /* Set a sane minimum mode size and the maximum allowed by the available VRAM */ 524 { 525 unsigned maxSize, trySize = 512; 526 527 do { 528 maxSize = trySize; 529 trySize += 128; 530 } while (trySize * trySize * pScrn->bitsPerPixel / 8 < pScrn->videoRam * 1024); 531 532 /* I don't know exactly what these are for (and they are only used in a couple 533 of places in the X server code). */ 534 pScrn->display->virtualX = maxSize; 535 pScrn->display->virtualY = maxSize; 536 xf86DrvMsg(pScrn->scrnIndex, X_INFO, 537 "The maximum supported resolution is currently %dx%d\n", maxSize, maxSize); 538 } 539 535 540 /* Filter out video modes not supported by the virtual hardware 536 we described. All modes used by the Windows additions should 537 work fine. */ 541 we described. */ 538 542 i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, 539 543 pScrn->display->modes, 540 clockRanges, NULL, 0, 6400, 1, 0, 1440, 541 pScrn->display->virtualX, 542 pScrn->display->virtualY, 543 pScrn->videoRam, LOOKUP_BEST_REFRESH); 544 clockRanges, NULL, 64, pScrn->display->virtualX, 1, 545 64, pScrn->display->virtualY, 0, 0, 546 pScrn->videoRam * 1024, LOOKUP_BEST_REFRESH); 544 547 545 548 if (i <= 0) { … … 554 557 xf86PrintModes(pScrn); 555 558 556 /* Set display resolution. This was arbitrarily chosen to be about the same as my monitor. */557 xf86SetDpi(pScrn, 100, 100);559 /* Set display resolution. Perhaps we should read this from the host. */ 560 xf86SetDpi(pScrn, 96, 96); 558 561 559 562 if (pScrn->modes == NULL) { -
trunk/src/VBox/Additions/x11/xgraphics/vboxvideo_70.c
r6642 r7168 381 381 int i; 382 382 DisplayModePtr m_prev; 383 char *pcHostModeName = NULL; 383 384 384 385 /* Are we really starting the server, or is this just a dummy run? */ … … 386 387 return (FALSE); 387 388 388 xf86Msg(X_INFO, 389 "VirtualBox guest additions video driver version " 390 VBOX_VERSION_STRING "\n"); 391 392 /* Get our private data from the ScrnInfoRec structure. */ 389 xf86DrvMsg(pScrn->scrnIndex, X_INFO, 390 "VirtualBox guest additions video driver version " 391 VBOX_VERSION_STRING "\n"); 392 393 /* Initialise the guest library */ 394 if (!vbox_init(pScrn->scrnIndex)) 395 return FALSE; 396 397 /* Get our private data from the ScrnInfoRec structure. */ 393 398 pVBox = VBOXGetRec(pScrn); 394 399 … … 458 463 clockRanges->ClockDivFactor = 1; 459 464 460 /* This function asks X to choose a depth and bpp based on the 461 config file and the command line, and gives a default in 462 case none is specified. Note that we only support 32bpp, not 463 24bpp. After spending ages looking through the XFree86 4.2 464 source code however, I realised that it automatically uses 465 32bpp for depth 24 unless you explicitly add a "24 24" 466 format to its internal list. */ 467 if (!xf86SetDepthBpp(pScrn, pScrn->videoRam >= 2048 ? 24 : 16, 0, 0, 468 Support32bppFb)) 469 return FALSE; 470 if (pScrn->depth != 24 && pScrn->depth != 16) 465 /* Query the host for the preferred resolution and colour depth */ 466 { 467 uint32_t cx, cy, iDisplay, cBits = 24; 468 469 if (vboxGetDisplayChangeRequest(pScrn, &cx, &cy, &cBits, &iDisplay)) 470 { 471 /* We only support 16 and 24 bits depth (i.e. 16 and 32bpp) */ 472 if (cBits != 16) 473 cBits = 24; 474 pcHostModeName = XNFprintf("%dx%d", cx, cy); 475 } 476 if (!xf86SetDepthBpp(pScrn, cBits, 0, 0, Support32bppFb)) 477 return FALSE; 478 } 479 if (pScrn->bitsPerPixel != 32 && pScrn->bitsPerPixel != 16) 471 480 { 472 481 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, … … 476 485 xf86PrintDepthBpp(pScrn); 477 486 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 487 /* To get around the problem of SUSE specifying a single, invalid mode in their 490 * Xorg.conf by default, we add a n additional modeto the end of the user specified488 * Xorg.conf by default, we add additional modes to the end of the user specified 491 489 * list. This means that if all user modes are invalid, X will try our mode before 492 490 * falling back to its standard mode list. */ 493 491 if (pScrn->display->modes == NULL) 494 492 { 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; 493 i = 0; 494 /* The user specified no modes at all. */ 495 pScrn->display->modes = xnfalloc(5 * sizeof(char*)); 501 496 } 502 497 else 503 498 { 504 /* Add 1024x768 to the end of the mode list in case the others are all invalid. */505 499 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; 500 pScrn->display->modes = xnfrealloc(pScrn->display->modes, (i + 5) 501 * sizeof(char *)); 502 } 503 /* Add additional modes to the end of the mode list in case the others are 504 all invalid. */ 505 if (pcHostModeName != NULL) 506 pScrn->display->modes[i] = pcHostModeName; 507 else 508 --i; 509 pScrn->display->modes[i+1] = "1024x768"; 510 pScrn->display->modes[i+2] = "800x600"; 511 pScrn->display->modes[i+3] = "640x480"; 512 pScrn->display->modes[i+4] = NULL; 518 513 519 514 /* Create a builtin mode for every specified mode. This allows to specify arbitrary … … 526 521 527 522 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 523 m = xnfcalloc(sizeof(DisplayModeRec), 1); 536 524 m->status = MODE_OK; … … 555 543 } 556 544 545 /* Colour weight - we always call this, since we are always in 546 truecolour. */ 547 if (!xf86SetWeight(pScrn, rzeros, rzeros)) 548 return (FALSE); 549 550 /* visual init */ 551 if (!xf86SetDefaultVisual(pScrn, -1)) 552 return (FALSE); 553 554 xf86SetGamma(pScrn, gzeros); 555 556 /* Set a sane minimum mode size and the maximum allowed by the available VRAM */ 557 { 558 unsigned maxSize, trySize = 512; 559 560 do { 561 maxSize = trySize; 562 trySize += 128; 563 } while (trySize * trySize * pScrn->bitsPerPixel / 8 < pScrn->videoRam * 1024); 564 565 /* I don't know exactly what these are for (and they are only used in a couple 566 of places in the X server code). */ 567 pScrn->display->virtualX = maxSize; 568 pScrn->display->virtualY = maxSize; 569 xf86DrvMsg(pScrn->scrnIndex, X_INFO, 570 "The maximum supported resolution is currently %dx%d\n", maxSize, maxSize); 571 } 572 557 573 /* Filter out video modes not supported by the virtual hardware 558 we described. All modes used by the Windows additions should 559 work fine. */ 574 we described. */ 560 575 i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, 561 576 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); 577 clockRanges, NULL, 64, pScrn->display->virtualX, 1, 578 64, pScrn->display->virtualY, 0, 0, 579 pScrn->videoRam * 1024, LOOKUP_BEST_REFRESH); 566 580 567 581 if (i <= 0) { … … 576 590 xf86PrintModes(pScrn); 577 591 578 /* Set display resolution. This was arbitrarily chosen to be about the same as my monitor. */579 xf86SetDpi(pScrn, 100, 100);592 /* Set display resolution. Perhaps we should read this from the host. */ 593 xf86SetDpi(pScrn, 96, 96); 580 594 581 595 if (pScrn->modes == NULL) {
Note:
See TracChangeset
for help on using the changeset viewer.