Changeset 9811 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jun 19, 2008 9:29:12 AM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 32186
- Location:
- trunk/src/VBox/Additions
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk
r9632 r9811 88 88 VBoxGuestR3LibDaemonize.cpp \ 89 89 VBoxGuestR3LibGR.cpp \ 90 VBoxGuestR3LibInfoSvc.cpp \ 90 91 VBoxGuestR3LibMouse.cpp \ 91 92 VBoxGuestR3LibMisc.cpp \ … … 117 118 VBoxGuestR3Lib.cpp \ 118 119 VBoxGuestR3LibGR.cpp \ 120 VBoxGuestR3LibInfoSvc.cpp \ 119 121 VBoxGuestR3LibMouse.cpp \ 120 122 VBoxGuestR3LibMisc.cpp \ -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibVideo.cpp
r8425 r9811 28 28 #include <iprt/assert.h> 29 29 #include <VBox/log.h> 30 #include <VBox/HostServices/VBoxInfoSvc.h> /* For Save and RetrieveVideoMode */ 30 31 31 32 #include "VBGLR3Internal.h" … … 232 233 return fRc; 233 234 } 235 236 /** 237 * Save video mode parameters to the registry. 238 * 239 * @returns iprt status value 240 * @param pszName the name to save the mode parameters under 241 * @param cx mode width 242 * @param cy mode height 243 * @param cBits bits per pixel for the mode 244 */ 245 VBGLR3DECL(int) VbglR3SaveVideoMode(char *pszName, uint32_t cx, uint32_t cy, uint32_t cBits) 246 { 247 using namespace svcInfo; 248 249 char pcModeName[KEY_MAX_LEN]; 250 char pcModeParms[KEY_MAX_VALUE_LEN]; 251 uint32_t u32ClientId = 0; 252 RTStrPrintf(pcModeName, sizeof(pcModeName), "VideoMode/%s", pszName); 253 RTStrPrintf(pcModeParms, sizeof(pcModeParms), "%dx%dx%d", cx, cy, cBits); 254 int rc = VbglR3InfoSvcConnect(&u32ClientId); 255 if (RT_SUCCESS(rc)) 256 rc = VbglR3InfoSvcWriteKey(u32ClientId, pcModeName, pcModeParms); 257 if (u32ClientId != 0) 258 VbglR3InfoSvcDisconnect(u32ClientId); /* Return value ignored, because what can we do anyway? */ 259 return rc; 260 } 261 262 263 /** 264 * Retrieve video mode parameters from the registry. 265 * 266 * @returns iprt status value 267 * @param pszName the name under which the mode parameters are saved 268 * @param pcx where to store the mode width 269 * @param pcy where to store the mode height 270 * @param pcBits where to store the bits per pixel for the mode 271 */ 272 VBGLR3DECL(int) VbglR3RetrieveVideoMode(char *pszName, uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits) 273 { 274 using namespace svcInfo; 275 276 char pcModeName[KEY_MAX_LEN]; 277 char pcModeParms[KEY_MAX_VALUE_LEN]; 278 char *pszNext; 279 uint32_t u32ClientId; 280 uint32_t cx, cy, cBits; 281 282 RTStrPrintf(pcModeName, sizeof(pcModeName), "VideoMode/%s", pszName); 283 int rc = VbglR3InfoSvcConnect(&u32ClientId); 284 if (RT_SUCCESS(rc)) 285 rc = VbglR3InfoSvcReadKey(u32ClientId, pcModeName, pcModeParms, 286 sizeof(pcModeParms), NULL); 287 if (RT_SUCCESS(rc)) 288 /* Extract the width from the string */ 289 rc = RTStrToUInt32Ex(pcModeParms, &pszNext, 10, &cx); 290 if ( (VWRN_NUMBER_TOO_BIG == rc) 291 || (VWRN_NEGATIVE_UNSIGNED == rc) 292 || (RT_SUCCESS(rc) && (*pszNext != ',') && (*pszNext != 'x'))) 293 rc = VERR_INVALID_PARAMETER; 294 if (RT_SUCCESS(rc)) 295 { 296 if ((*pszNext != ',') || (*pszNext != 'x')) 297 ++pszNext; 298 for (;' ' == *pszNext; ++pszNext); 299 rc = RTStrToUInt32Ex(pszNext, &pszNext, 10, &cy); 300 } 301 if ( (VWRN_NUMBER_TOO_BIG == rc) 302 || (VWRN_NEGATIVE_UNSIGNED == rc) 303 || (RT_SUCCESS(rc) && (*pszNext != ',') && (*pszNext != 'x'))) 304 rc = VERR_INVALID_PARAMETER; 305 if (RT_SUCCESS(rc)) 306 { 307 if ((*pszNext != ',') || (*pszNext != 'x')) 308 ++pszNext; 309 for (;' ' == *pszNext; ++pszNext); 310 rc = RTStrToUInt32Ex(pszNext, &pszNext, 10, &cBits); 311 } 312 if ( (VWRN_NUMBER_TOO_BIG == rc) 313 || (VWRN_NEGATIVE_UNSIGNED == rc) 314 || (VWRN_TRAILING_CHARS == rc)) 315 rc = VERR_INVALID_PARAMETER; 316 if (u32ClientId != 0) 317 VbglR3InfoSvcDisconnect(u32ClientId); /* Return value ignored, because what can we do anyway? */ 318 if (RT_SUCCESS(rc)) 319 { 320 *pcx = cx; 321 *pcy = cy; 322 *pcBits = cBits; 323 } 324 return rc; 325 } -
trunk/src/VBox/Additions/x11/xgraphics/vboxutils.c
r9252 r9811 1002 1002 Bool 1003 1003 vboxGetDisplayChangeRequest(ScrnInfoPtr pScrn, uint32_t *pcx, uint32_t *pcy, 1004 uint32_t *pcBits, uint32_t *piDisplay ,1005 VBOXPtr pVBox) 1006 { 1004 uint32_t *pcBits, uint32_t *piDisplay) 1005 { 1006 VBOXPtr pVBox = pScrn->driverPrivate; 1007 1007 TRACE_ENTRY(); 1008 1008 if (!pVBox->useDevice) … … 1025 1025 */ 1026 1026 Bool 1027 vboxHostLikesVideoMode(uint32_t cx, uint32_t cy, uint32_t cBits) 1028 { 1029 TRACE_ENTRY(); 1027 vboxHostLikesVideoMode(ScrnInfoPtr pScrn, uint32_t cx, uint32_t cy, uint32_t cBits) 1028 { 1029 VBOXPtr pVBox = pScrn->driverPrivate; 1030 TRACE_ENTRY(); 1031 if (!pVBox->useDevice) 1032 return TRUE; /* If we can't ask the host then we like everything. */ 1030 1033 return VbglR3HostLikesVideoMode(cx, cy, cBits); 1031 1034 } 1035 1036 /** 1037 * Save video mode parameters to the registry. 1038 * 1039 * @returns iprt status value 1040 * @param pszName the name to save the mode parameters under 1041 * @param cx mode width 1042 * @param cy mode height 1043 * @param cBits bits per pixel for the mode 1044 */ 1045 Bool 1046 vboxSaveVideoMode(ScrnInfoPtr pScrn, uint32_t cx, uint32_t cy, uint32_t cBits) 1047 { 1048 VBOXPtr pVBox = pScrn->driverPrivate; 1049 TRACE_ENTRY(); 1050 if (!pVBox->useDevice) 1051 return FALSE; 1052 return RT_SUCCESS(VbglR3SaveVideoMode("SavedMode", cx, cy, cBits)); 1053 } 1054 1055 /** 1056 * Retrieve video mode parameters from the registry. 1057 * 1058 * @returns iprt status value 1059 * @param pszName the name under which the mode parameters are saved 1060 * @param pcx where to store the mode width 1061 * @param pcy where to store the mode height 1062 * @param pcBits where to store the bits per pixel for the mode 1063 */ 1064 Bool 1065 vboxRetrieveVideoMode(ScrnInfoPtr pScrn, uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits) 1066 { 1067 VBOXPtr pVBox = pScrn->driverPrivate; 1068 TRACE_ENTRY(); 1069 if (!pVBox->useDevice) 1070 return FALSE; 1071 int rc = VbglR3RetrieveVideoMode("SavedMode", pcx, pcy, pcBits); 1072 if (RT_SUCCESS(rc)) 1073 TRACE_LOG("Retrieved a video mode of %dx%dx%d\n", *pcx, *pcy, *pcBits); 1074 else 1075 TRACE_LOG("Failed to retrieve video mode, error %d\n", rc); 1076 return (RT_SUCCESS(rc)); 1077 } -
trunk/src/VBox/Additions/x11/xgraphics/vboxvideo.h
r9252 r9811 189 189 extern Bool vboxGetDisplayChangeRequest(ScrnInfoPtr pScrn, uint32_t *pcx, 190 190 uint32_t *pcy, uint32_t *pcBits, 191 uint32_t *piDisplay , VBOXPtr pVBox);191 uint32_t *piDisplay); 192 192 193 extern Bool vboxHostLikesVideoMode(uint32_t cx, uint32_t cy, uint32_t cBits); 193 extern Bool vboxHostLikesVideoMode(ScrnInfoPtr pScrn, uint32_t cx, uint32_t cy, uint32_t cBits); 194 extern Bool vboxSaveVideoMode(ScrnInfoPtr pScrn, uint32_t cx, uint32_t cy, uint32_t cBits); 195 extern Bool vboxRetrieveVideoMode(ScrnInfoPtr pScrn, uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits); 194 196 195 197 #endif /* _VBOXVIDEO_H_ */ -
trunk/src/VBox/Additions/x11/xgraphics/vboxvideo_13.c
r9018 r9811 52 52 */ 53 53 54 /* #define DEBUG_VIDEO 1 */ 54 #ifdef DEBUG_michael 55 # define DEBUG_VIDEO 1 56 #endif 55 57 #ifdef DEBUG_VIDEO 56 58 … … 300 302 VBOXSetMode(crtc->scrn, adjusted_mode); 301 303 VBOXAdjustFrame(crtc->scrn->scrnIndex, x, y, 0); 304 vboxSaveVideoMode(crtc->scrn, adjusted_mode->HDisplay, 305 adjusted_mode->VDisplay, crtc->scrn->bitsPerPixel); 302 306 } 303 307 … … 345 349 vbox_output_mode_valid (xf86OutputPtr output, DisplayModePtr mode) 346 350 { 351 ScrnInfoPtr pScrn = output->scrn; 347 352 int rc = MODE_OK; 348 353 TRACE3("HDisplay=%d, VDisplay=%d\n", mode->HDisplay, mode->VDisplay); 349 if ( vbox_device_available(VBOXGetRec( output->scrn))350 && !vboxHostLikesVideoMode( mode->HDisplay, mode->VDisplay,351 output->scrn->bitsPerPixel)354 if ( vbox_device_available(VBOXGetRec(pScrn)) 355 && !vboxHostLikesVideoMode(pScrn, mode->HDisplay, 356 mode->VDisplay, pScrn->bitsPerPixel) 352 357 ) 353 358 rc = MODE_BAD; … … 413 418 if (vbox_device_available(pVBox)) 414 419 { 415 rc = vboxGetDisplayChangeRequest(pScrn, &x, &y, &bpp, &display, pVBox); 416 /* @todo - check the display number once we support multiple displays. */ 420 rc = vboxGetDisplayChangeRequest(pScrn, &x, &y, &bpp, &display); 421 /** @todo - check the display number once we support multiple displays. */ 422 /* If we don't find a display request, see if we have a saved hint 423 * from a previous session. */ 424 if (rc) 425 TRACE3("Got a display change request for %dx%d\n", x, y); 426 if (!rc || (0 == x) || (0 == y)) 427 { 428 rc = vboxRetrieveVideoMode(pScrn, &x, &y, &bpp); 429 if (rc) 430 TRACE3("Retrieved a video mode of %dx%d\n", x, y); 431 } 417 432 if (rc && (0 != x) && (0 != y)) { 418 433 /* We prefer a slightly smaller size to a slightly larger one */ … … 720 735 /* We only support 16 and 24 bits depth (i.e. 16 and 32bpp) */ 721 736 if ( vboxGetDisplayChangeRequest(pScrn, &cx, &cy, &cBits, 722 &iDisplay , pVBox)737 &iDisplay) 723 738 && (cBits != 16) 724 739 ) -
trunk/src/VBox/Additions/x11/xgraphics/vboxvideo_15.c
r9252 r9811 117 117 static const OptionInfoRec * VBOXAvailableOptions(int chipid, int busid); 118 118 static void VBOXIdentify(int flags); 119 #ifndef PCIACCESS 119 120 static Bool VBOXProbe(DriverPtr drv, int flags); 120 # ifdef PCIACCESS121 #else 121 122 static Bool VBOXPciProbe(DriverPtr drv, int entity_num, 122 123 struct pci_device *dev, intptr_t match_data); … … 334 335 VBOXSetMode(crtc->scrn, adjusted_mode); 335 336 VBOXAdjustFrame(crtc->scrn->scrnIndex, x, y, 0); 337 vboxSaveVideoMode(crtc->scrn, adjusted_mode->HDisplay, 338 adjusted_mode->VDisplay, crtc->scrn->bitsPerPixel); 336 339 } 337 340 … … 379 382 vbox_output_mode_valid (xf86OutputPtr output, DisplayModePtr mode) 380 383 { 384 ScrnInfoPtr pScrn = output->scrn; 381 385 int rc = MODE_OK; 382 386 TRACE3("HDisplay=%d, VDisplay=%d\n", mode->HDisplay, mode->VDisplay); 383 if ( vbox_device_available(VBOXGetRec( output->scrn))384 && !vboxHostLikesVideoMode( mode->HDisplay, mode->VDisplay,385 output->scrn->bitsPerPixel)387 if ( vbox_device_available(VBOXGetRec(pScrn)) 388 && !vboxHostLikesVideoMode(pScrn, mode->HDisplay, mode->VDisplay, 389 pScrn->bitsPerPixel) 386 390 ) 387 391 rc = MODE_BAD; … … 447 451 if (vbox_device_available(pVBox)) 448 452 { 449 rc = vboxGetDisplayChangeRequest(pScrn, &x, &y, &bpp, &display , pVBox);453 rc = vboxGetDisplayChangeRequest(pScrn, &x, &y, &bpp, &display); 450 454 /* @todo - check the display number once we support multiple displays. */ 455 /* If we don't find a display request, see if we have a saved hint 456 * from a previous session. */ 457 if (!rc || (0 == x) || (0 == y)) 458 rc = vboxRetrieveVideoMode(pScrn, &x, &y, &bpp); 451 459 if (rc && (0 != x) && (0 != y)) { 452 460 /* We prefer a slightly smaller size to a slightly larger one */ … … 636 644 #endif 637 645 646 #ifndef PCIACCESS 638 647 static Bool 639 648 VBOXProbe(DriverPtr drv, int flags) … … 651 660 return (FALSE); 652 661 653 #ifndef PCIACCESS654 662 /* PCI BUS */ 655 663 if (xf86GetPciVideoInfo()) { … … 690 698 } 691 699 } 700 701 xfree(devSections); 702 703 return (foundScreen); 704 } 692 705 #endif 693 694 xfree(devSections);695 696 return (foundScreen);697 }698 706 699 707 /* … … 804 812 /* We only support 16 and 24 bits depth (i.e. 16 and 32bpp) */ 805 813 if ( vboxGetDisplayChangeRequest(pScrn, &cx, &cy, &cBits, 806 &iDisplay , pVBox)814 &iDisplay) 807 815 && (cBits != 16) 808 816 ) -
trunk/src/VBox/Additions/x11/xgraphics/vboxvideo_70.c
r8472 r9811 470 470 uint32_t cx = 0, cy = 0, iDisplay = 0, cBits = 24; 471 471 472 if (vboxGetDisplayChangeRequest(pScrn, &cx, &cy, &cBits, &iDisplay, 473 pVBox)) 472 if (vboxGetDisplayChangeRequest(pScrn, &cx, &cy, &cBits, &iDisplay)) 474 473 { 475 474 /* We only support 16 and 24 bits depth (i.e. 16 and 32bpp) */ … … 515 514 ++i; 516 515 } 517 if (vboxHostLikesVideoMode( 1024, 768, pScrn->bitsPerPixel))516 if (vboxHostLikesVideoMode(pScrn, 1024, 768, pScrn->bitsPerPixel)) 518 517 { 519 518 pScrn->display->modes[i] = "1024x768"; 520 519 ++i; 521 520 } 522 if (vboxHostLikesVideoMode( 800, 600, pScrn->bitsPerPixel))521 if (vboxHostLikesVideoMode(pScrn, 800, 600, pScrn->bitsPerPixel)) 523 522 { 524 523 pScrn->display->modes[i] = "800x600";
Note:
See TracChangeset
for help on using the changeset viewer.