Changeset 34130 in vbox
- Timestamp:
- Nov 16, 2010 10:42:54 PM (14 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo-win.h
r34079 r34130 313 313 PVBOXWDDM_VIDEOMODES_INFO vboxWddmGetVideoModesInfo(PDEVICE_EXTENSION DeviceExtension, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId); 314 314 PVBOXWDDM_VIDEOMODES_INFO vboxWddmGetAllVideoModesInfos(PDEVICE_EXTENSION DeviceExtension); 315 PVBOXWDDM_VIDEOMODES_INFO vboxWddmUpdateVideoModesInfo(PDEVICE_EXTENSION DeviceExtension, PVBOXWDDM_RECOMMENDVIDPN pVidPnInfo); 315 316 316 317 void vboxVideoInitCustomVideoModes(PDEVICE_EXTENSION pDevExt); … … 322 323 const D3DKMDT_2DREGION *pResolution, VIDEO_MODE_INFORMATION * pModes, uint32_t cModes, uint32_t *pcModes, int32_t *piPreferrableMode); 323 324 324 int vbox WddmVideoModeFind(const VIDEO_MODE_INFORMATION *pModes, int cModes, const VIDEO_MODE_INFORMATION *pM);325 int vboxVideoModeFind(const VIDEO_MODE_INFORMATION *pModes, int cModes, const VIDEO_MODE_INFORMATION *pM); 325 326 int vboxWddmVideoResolutionFind(const D3DKMDT_2DREGION *pResolutions, int cResolutions, const D3DKMDT_2DREGION *pRes); 326 327 bool vboxWddmVideoResolutionsMatch(const D3DKMDT_2DREGION *pResolutions1, const D3DKMDT_2DREGION *pResolutions2, int cResolutions); -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
r34079 r34130 601 601 #ifdef VBOX_WITH_WDDM 602 602 603 static bool vboxVideoModesMatch( VIDEO_MODE_INFORMATION *pMode1,VIDEO_MODE_INFORMATION *pMode2)603 static bool vboxVideoModesMatch(const VIDEO_MODE_INFORMATION *pMode1, const VIDEO_MODE_INFORMATION *pMode2) 604 604 { 605 605 return pMode1->VisScreenHeight == pMode2->VisScreenHeight … … 608 608 } 609 609 610 static DECLINLINE(void) vboxVideoCheckModeAdd(VIDEO_MODE_INFORMATION *pModes, int *pcNumModes) 610 int vboxVideoModeFind(const VIDEO_MODE_INFORMATION *pModes, int cModes, const VIDEO_MODE_INFORMATION *pM) 611 { 612 for (int i = 0; i < cModes; ++i) 613 { 614 const VIDEO_MODE_INFORMATION *pMode = &pModes[i]; 615 if (vboxVideoModesMatch(pMode, pM)) 616 return i; 617 } 618 return -1; 619 } 620 621 static DECLINLINE(int) vboxVideoCheckModeAdd(VIDEO_MODE_INFORMATION *pModes, int *pcNumModes, int *piPreferred) 611 622 { 612 623 const int cNumModes = *pcNumModes; … … 614 625 { 615 626 if (vboxVideoModesMatch(&pModes[i], &pModes[cNumModes])) 616 return; 617 } 618 (*pcNumModes)++; 619 } 620 621 # define VBOXVIDEOMODE_ADDED(_aModes, _pcModes) vboxVideoCheckModeAdd(_aModes, _pcModes) 627 { 628 if (piPreferred && *piPreferred == cNumModes) 629 { 630 *piPreferred = i; 631 } 632 return i; 633 } 634 } 635 ++(*pcNumModes); 636 return cNumModes; 637 } 638 639 static bool vboxVideoModeAdjustCheckSupported(PDEVICE_EXTENSION pDevExt, int iDisplay, VIDEO_MODE_INFORMATION *pMode) 640 { 641 /* round down to multiple of 8 if necessary */ 642 if (!pDevExt->fAnyX) { 643 if ((pMode->VisScreenWidth & 0xfff8) != pMode->VisScreenWidth) 644 dprintf(("VBoxVideo: rounding down xres from %d to %d\n", pMode->VisScreenWidth, pMode->VisScreenWidth & 0xfff8)); 645 pMode->VisScreenWidth &= 0xfff8; 646 } 647 648 if (vboxLikesVideoMode(iDisplay, pMode->VisScreenWidth, pMode->VisScreenHeight, pMode->BitsPerPlane)) 649 return true; 650 return false; 651 } 652 653 static int vboxVideoModeAdd(VIDEO_MODE_INFORMATION *pModes, uint32_t cModes, uint32_t *pcNumModes, const VIDEO_MODE_INFORMATION *pMode) 654 { 655 const uint32_t cNumModes = *pcNumModes; 656 for (uint32_t i = 0; i < cNumModes; ++i) 657 { 658 if (vboxVideoModesMatch(&pModes[i], pMode)) 659 { 660 return (int)i; 661 } 662 } 663 664 if (cNumModes < cModes) 665 { 666 pModes[cNumModes] = *pMode; 667 pModes[cNumModes].ModeIndex = cNumModes; 668 ++(*pcNumModes); 669 return (int)cNumModes; 670 } 671 672 return -1; 673 } 674 675 676 # define VBOXVIDEOMODE_ADDED(_aModes, _pcModes, _piPreferred) vboxVideoCheckModeAdd(_aModes, _pcModes, _piPreferred) 622 677 #else 623 # define VBOXVIDEOMODE_ADDED(_aModes, _pcModes) do { (*(_pcModes))++; } while (0) 624 #endif 678 # define VBOXVIDEOMODE_ADDED(_aModes, _pcModes, _piPreferred) ((*(_pcModes))++) 679 #endif 680 681 static void vboxVideoInitMode(VIDEO_MODE_INFORMATION *pVideoMode, ULONG xres, ULONG yres, ULONG bpp, ULONG index, ULONG yoffset) 682 { 683 /* 684 * Build mode entry. 685 */ 686 memset(pVideoMode, 0, sizeof(VIDEO_MODE_INFORMATION)); 687 688 pVideoMode->Length = sizeof(VIDEO_MODE_INFORMATION); 689 pVideoMode->ModeIndex = index; 690 pVideoMode->VisScreenWidth = xres; 691 pVideoMode->VisScreenHeight = yres - yoffset; 692 pVideoMode->ScreenStride = xres * ((bpp + 7) / 8); 693 pVideoMode->NumberOfPlanes = 1; 694 pVideoMode->BitsPerPlane = bpp; 695 pVideoMode->Frequency = 60; 696 pVideoMode->XMillimeter = 320; 697 pVideoMode->YMillimeter = 240; 698 switch (bpp) 699 { 700 #ifdef VBOX_WITH_8BPP_MODES 701 case 8: 702 pVideoMode->NumberRedBits = 6; 703 pVideoMode->NumberGreenBits = 6; 704 pVideoMode->NumberBlueBits = 6; 705 pVideoMode->RedMask = 0; 706 pVideoMode->GreenMask = 0; 707 pVideoMode->BlueMask = 0; 708 break; 709 #endif 710 case 16: 711 pVideoMode->NumberRedBits = 5; 712 pVideoMode->NumberGreenBits = 6; 713 pVideoMode->NumberBlueBits = 5; 714 pVideoMode->RedMask = 0xF800; 715 pVideoMode->GreenMask = 0x7E0; 716 pVideoMode->BlueMask = 0x1F; 717 break; 718 case 24: 719 pVideoMode->NumberRedBits = 8; 720 pVideoMode->NumberGreenBits = 8; 721 pVideoMode->NumberBlueBits = 8; 722 pVideoMode->RedMask = 0xFF0000; 723 pVideoMode->GreenMask = 0xFF00; 724 pVideoMode->BlueMask = 0xFF; 725 break; 726 case 32: 727 pVideoMode->NumberRedBits = 8; 728 pVideoMode->NumberGreenBits = 8; 729 pVideoMode->NumberBlueBits = 8; 730 pVideoMode->RedMask = 0xFF0000; 731 pVideoMode->GreenMask = 0xFF00; 732 pVideoMode->BlueMask = 0xFF; 733 break; 734 } 735 pVideoMode->AttributeFlags = VIDEO_MODE_GRAPHICS | VIDEO_MODE_COLOR | VIDEO_MODE_NO_OFF_SCREEN; 736 #ifdef VBOX_WITH_8BPP_MODES 737 if (bpp == 8) 738 pVideoMode->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN | VIDEO_MODE_MANAGED_PALETTE; 739 #endif 740 pVideoMode->VideoMemoryBitmapWidth = xres; 741 pVideoMode->VideoMemoryBitmapHeight = yres - yoffset; 742 pVideoMode->DriverSpecificAttributeFlags = 0; 743 } 625 744 626 745 static int vboxVideoBuildModesTable(PDEVICE_EXTENSION DeviceExtension, int iDisplay, … … 1178 1297 VideoModes[cNumVideoModes].DriverSpecificAttributeFlags = 0; 1179 1298 1180 VBOXVIDEOMODE_ADDED(VideoModes, &cNumVideoModes );1299 VBOXVIDEOMODE_ADDED(VideoModes, &cNumVideoModes, &iPreferredVideoMode); 1181 1300 1182 1301 /* next run */ … … 1231 1350 iPreferredVideoMode = cNumVideoModes; 1232 1351 1233 VBOXVIDEOMODE_ADDED(VideoModes, &cNumVideoModes); 1352 VBOXVIDEOMODE_ADDED(VideoModes, &cNumVideoModes, &iPreferredVideoMode); 1353 1354 for (UINT i = 32; i >= 8; i/=2 ) 1355 { 1356 if (cModesTable <= cNumVideoModes) 1357 { 1358 rc = VERR_BUFFER_OVERFLOW; 1359 break; 1360 } 1361 1362 if (VideoModes[iPreferredVideoMode].BitsPerPlane != i) 1363 { 1364 vboxVideoInitMode(&VideoModes[cNumVideoModes], 1365 VideoModes[iPreferredVideoMode].VisScreenWidth, 1366 VideoModes[iPreferredVideoMode].VisScreenHeight, 1367 i /* bpp*/ , 1368 cNumVideoModes /* index*/, 1369 0 /* yoffset*/); 1370 VBOXVIDEOMODE_ADDED(VideoModes, &cNumVideoModes, NULL); 1371 } 1372 } 1234 1373 } 1235 1374 … … 2311 2450 AssertCompile(RT_OFFSETOF(SIZE, cy) == RT_OFFSETOF(D3DKMDT_2DREGION, cy)); 2312 2451 static VOID vboxWddmBuildVideoModesInfo(PDEVICE_EXTENSION DeviceExtension, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId, 2313 PVBOXWDDM_VIDEOMODES_INFO pModes )2452 PVBOXWDDM_VIDEOMODES_INFO pModes, VIDEO_MODE_INFORMATION *paAddlModes, UINT cAddlModes) 2314 2453 { 2315 2454 pModes->cModes = RT_ELEMENTS(pModes->aModes); 2316 2455 pModes->cResolutions = RT_ELEMENTS(pModes->aResolutions); 2317 2456 vboxVideoBuildModesTable(DeviceExtension, VidPnTargetId, pModes->aModes, &pModes->cModes, &pModes->iPreferredMode); 2457 for (UINT i = 0; i < cAddlModes; ++i) 2458 { 2459 if (vboxVideoModeAdjustCheckSupported(DeviceExtension, VidPnTargetId, &paAddlModes[i])) 2460 { 2461 int iDx = vboxVideoModeAdd(pModes->aModes, RT_ELEMENTS(pModes->aModes), &pModes->cModes, &paAddlModes[i]); 2462 Assert(iDx >= 0); 2463 if (iDx >= 0) 2464 pModes->iPreferredMode = iDx; 2465 } 2466 } 2467 #if 0 2468 if (pModes->cPrevModes == pModes->cModes) 2469 { 2470 Assert(pModes->cModes < RT_ELEMENTS(pModes->aModes)); 2471 if (pModes->cModes < RT_ELEMENTS(pModes->aModes)) 2472 { 2473 ULONG w = pModes->aModes[0].VisScreenWidth; 2474 ULONG h = pModes->aModes[0].VisScreenHeight; 2475 w += 8; 2476 h += 8; 2477 2478 if (vboxWddmFillMode(&pModes->aModes[pModes->cModes], D3DDDIFMT_A8R8G8B8, w, h)) 2479 { 2480 pModes->aModes[pModes->cModes].ModeIndex = pModes->cModes; 2481 ++pModes->cModes; 2482 } 2483 else 2484 { 2485 Assert(0); 2486 } 2487 } 2488 VIDEO_MODE_INFORMATION TmpMode = pModes->aModes[1]; 2489 pModes->aModes[1] = pModes->aModes[2]; 2490 pModes->aModes[2] = TmpMode; 2491 } 2492 #endif 2493 pModes->cPrevModes = pModes->cModes; 2318 2494 vboxVideoBuildResolutionTable(pModes->aModes, pModes->cModes, (SIZE*)((void*)pModes->aResolutions), &pModes->cResolutions); 2319 2495 } … … 2352 2528 } 2353 2529 2354 int vboxWddmVideoModeFind(const VIDEO_MODE_INFORMATION *pModes, int cModes, const VIDEO_MODE_INFORMATION *pM)2355 {2356 for (int i = 0; i < cModes; ++i)2357 {2358 const VIDEO_MODE_INFORMATION *pMode = &pModes[i];2359 if (pMode->VisScreenHeight == pM->VisScreenHeight && pMode->VisScreenWidth == pM->VisScreenWidth && pMode->BitsPerPlane == pM->BitsPerPlane)2360 return i;2361 }2362 return -1;2363 }2364 2365 2530 int vboxWddmVideoResolutionFind(const D3DKMDT_2DREGION *pResolutions, int cResolutions, const D3DKMDT_2DREGION *pRes) 2366 2531 { … … 2491 2656 pInfo->VideoMemoryBitmapWidth = w; 2492 2657 pInfo->VideoMemoryBitmapHeight = h; 2658 pInfo->XMillimeter = 320; 2659 pInfo->YMillimeter = 240; 2493 2660 2494 2661 switch (enmFormat) … … 2500 2667 pInfo->GreenMask = 0xFF00; 2501 2668 pInfo->BlueMask = 0xFF; 2669 pInfo->ScreenStride = pInfo->VisScreenWidth * pInfo->BitsPerPlane / 8; 2502 2670 return true; 2503 2671 case D3DDDIFMT_R8G8B8: … … 2507 2675 pInfo->GreenMask = 0xFF00; 2508 2676 pInfo->BlueMask = 0xFF; 2677 pInfo->ScreenStride = pInfo->VisScreenWidth * pInfo->BitsPerPlane / 8; 2509 2678 return true; 2510 2679 case D3DDDIFMT_R5G6B5: … … 2514 2683 pInfo->GreenMask = 0x7E0; 2515 2684 pInfo->BlueMask = 0x1F; 2685 pInfo->ScreenStride = pInfo->VisScreenWidth * pInfo->BitsPerPlane / 8; 2516 2686 return true; 2517 2687 case D3DDDIFMT_P8: … … 2521 2691 pInfo->GreenMask = 0; 2522 2692 pInfo->BlueMask = 0; 2693 pInfo->ScreenStride = pInfo->VisScreenWidth * pInfo->BitsPerPlane / 8; 2523 2694 return true; 2524 2695 default: … … 2541 2712 } 2542 2713 2543 if (!g_aVBoxVideoModeInfos[VidPnTargetId].cModes) 2544 { 2545 vboxWddmBuildVideoModesInfo(DeviceExtension, VidPnTargetId, &g_aVBoxVideoModeInfos[VidPnTargetId]); 2546 } 2547 2548 return &g_aVBoxVideoModeInfos[VidPnTargetId]; 2714 PVBOXWDDM_VIDEOMODES_INFO pInfo = &g_aVBoxVideoModeInfos[VidPnTargetId]; 2715 2716 if (!pInfo->cModes) 2717 { 2718 vboxWddmBuildVideoModesInfo(DeviceExtension, VidPnTargetId, pInfo, NULL, 0); 2719 Assert(pInfo->cModes); 2720 } 2721 2722 return pInfo; 2549 2723 } 2550 2724 … … 2566 2740 g_aVBoxVideoModeInfos[i].cModes = 0; 2567 2741 } 2742 } 2743 2744 PVBOXWDDM_VIDEOMODES_INFO vboxWddmUpdateVideoModesInfo(PDEVICE_EXTENSION DeviceExtension, PVBOXWDDM_RECOMMENDVIDPN pVidPnInfo) 2745 { 2746 vboxWddmInvalidateVideoModesInfo(DeviceExtension); 2747 2748 if (pVidPnInfo) 2749 { 2750 for (UINT i = 0; i < pVidPnInfo->cScreenInfos; ++i) 2751 { 2752 PVBOXWDDM_RECOMMENDVIDPN_SCREEN_INFO pScreenInfo = &pVidPnInfo->aScreenInfos[i]; 2753 Assert(pScreenInfo->Id < (DWORD)commonFromDeviceExt(DeviceExtension)->cDisplays); 2754 if (pScreenInfo->Id < (DWORD)commonFromDeviceExt(DeviceExtension)->cDisplays) 2755 { 2756 PVBOXWDDM_VIDEOMODES_INFO pInfo = &g_aVBoxVideoModeInfos[pScreenInfo->Id]; 2757 VIDEO_MODE_INFORMATION ModeInfo = {0}; 2758 D3DDDIFORMAT enmFormat; 2759 switch (pScreenInfo->BitsPerPixel) 2760 { 2761 case 32: 2762 enmFormat = D3DDDIFMT_A8R8G8B8; 2763 break; 2764 case 24: 2765 enmFormat = D3DDDIFMT_R8G8B8; 2766 break; 2767 case 16: 2768 enmFormat = D3DDDIFMT_R5G6B5; 2769 break; 2770 case 8: 2771 enmFormat = D3DDDIFMT_P8; 2772 break; 2773 default: 2774 Assert(0); 2775 enmFormat = D3DDDIFMT_UNKNOWN; 2776 break; 2777 } 2778 if (enmFormat != D3DDDIFMT_UNKNOWN) 2779 { 2780 if (vboxWddmFillMode(&ModeInfo, enmFormat, pScreenInfo->Width, pScreenInfo->Height)) 2781 { 2782 vboxWddmBuildVideoModesInfo(DeviceExtension, pScreenInfo->Id, pInfo, &ModeInfo, 1); 2783 } 2784 else 2785 { 2786 Assert(0); 2787 } 2788 } 2789 } 2790 } 2791 } 2792 2793 /* ensure we have all the rest populated */ 2794 vboxWddmGetAllVideoModesInfos(DeviceExtension); 2795 return g_aVBoxVideoModeInfos; 2568 2796 } 2569 2797 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoMisc.cpp
r34079 r34130 644 644 645 645 RtlInitUnicodeString(&RtlStr, pName); 646 InitializeObjectAttributes(&ObjAttr, &RtlStr, OBJ_CASE_INSENSITIVE , NULL, NULL);646 InitializeObjectAttributes(&ObjAttr, &RtlStr, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); 647 647 648 648 return ZwOpenKey(phKey, fAccess, &ObjAttr); -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp
r34079 r34130 23 23 if (Status == STATUS_SUCCESS) 24 24 { 25 BOOLEAN bFoundPrimary = TRUE;25 BOOLEAN bFoundPrimary = FALSE; 26 26 27 27 while (1) … … 29 29 if (pNewVidPnPresentPathInfo->VidPnSourceId != pNewVidPnPresentPathInfo->VidPnTargetId) 30 30 { 31 dprintf(("unsupported source(%d)->target(%d) pare\n", pNewVidPnPresentPathInfo->VidPnSourceId, pNewVidPnPresentPathInfo->VidPnTargetId)); 32 // AssertBreakpoint(); 31 dprintf(("unsupported source(%d)->target(%d) pair\n", pNewVidPnPresentPathInfo->VidPnSourceId, pNewVidPnPresentPathInfo->VidPnTargetId)); 33 32 bSupported = FALSE; 34 33 break; … … 213 212 } 214 213 215 //bSupported &= bFoundPrimary;214 bSupported &= bFoundPrimary; 216 215 217 216 if (pNewVidPnPresentPathInfo) … … 616 615 pMonitorSourceMode->ColorCoeffDynamicRanges.FourthChannel = 0; 617 616 pMonitorSourceMode->Origin = enmOrigin; 618 pMonitorSourceMode->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED; 617 Assert(!bPreferred); 618 // pMonitorSourceMode->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED; 619 pMonitorSourceMode->Preference = D3DKMDT_MP_PREFERRED; 619 620 } 620 621 … … 645 646 { 646 647 Status = pMonitorSMSIf->pfnAddMode(hMonitorSMS, pMonitorSMI); 647 Assert(Status == STATUS_SUCCESS); 648 Assert(Status == STATUS_SUCCESS/* || Status == STATUS_GRAPHICS_MODE_ALREADY_IN_MODESET*/); 649 // if (Status == STATUS_GRAPHICS_MODE_ALREADY_IN_MODESET) 650 // Status = STATUS_SUCCESS; 648 651 if (Status == STATUS_SUCCESS) 649 652 break; … … 672 675 { 673 676 Assert(!bPreferred); 674 pNewVidPnTargetModeInfo->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED; 677 // pNewVidPnTargetModeInfo->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED; 678 pNewVidPnTargetModeInfo->Preference = D3DKMDT_MP_PREFERRED; 675 679 676 680 return vboxVidPnPopulateVideoSignalInfo(&pNewVidPnTargetModeInfo->VideoSignalInfo, pResolution, 60 /* ULONG VSync */); … … 869 873 } 870 874 875 typedef struct VBOXVIDPNCHECKMONMODESENUM 876 { 877 D3DKMDT_2DREGION Region; 878 const D3DKMDT_MONITOR_SOURCE_MODE * pMonitorSMI; 879 } VBOXVIDPNCHECKMONMODESENUM, *PVBOXVIDPNCHECKMONMODESENUM; 880 881 static DECLCALLBACK(BOOLEAN) vboxFidPnCheckMonitorModesEnum(D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf, 882 CONST D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSMI, PVOID pContext) 883 { 884 PVBOXVIDPNCHECKMONMODESENUM pInfo = (PVBOXVIDPNCHECKMONMODESENUM)pContext; 885 if (pMonitorSMI->VideoSignalInfo.ActiveSize.cx == pInfo->Region.cx 886 && pMonitorSMI->VideoSignalInfo.ActiveSize.cy == pInfo->Region.cy) 887 { 888 Assert(!pInfo->pMonitorSMI); 889 if (pInfo->pMonitorSMI) 890 { 891 pMonitorSMSIf->pfnReleaseModeInfo(hMonitorSMS, pInfo->pMonitorSMI); 892 } 893 pInfo->pMonitorSMI = pMonitorSMI; 894 } 895 else 896 { 897 pMonitorSMSIf->pfnReleaseModeInfo(hMonitorSMS, pMonitorSMI); 898 } 899 return TRUE; 900 } 901 871 902 NTSTATUS vboxVidPnCheckAddMonitorModes(PDEVICE_EXTENSION pDevExt, 872 903 D3DDDI_VIDEO_PRESENT_TARGET_ID targetId, D3DKMDT_MONITOR_CAPABILITIES_ORIGIN enmOrigin, … … 874 905 { 875 906 NTSTATUS Status; 876 #if 0 877 D3DKMDT_2DREGION *pResolutionsCopy = (D3DKMDT_2DREGION*)vboxWddmMemAlloc(cResolutions * sizeof (D3DKMDT_2DREGION)); 878 if (pResolutionsCopy) 879 { 880 memcpy(pResolutionsCopy, pResolutions, cResolutions * sizeof (D3DKMDT_2DREGION)); 881 #endif 882 CONST DXGK_MONITOR_INTERFACE *pMonitorInterface; 883 Status = pDevExt->u.primary.DxgkInterface.DxgkCbQueryMonitorInterface(pDevExt->u.primary.DxgkInterface.DeviceHandle, DXGK_MONITOR_INTERFACE_VERSION_V1, &pMonitorInterface); 907 CONST DXGK_MONITOR_INTERFACE *pMonitorInterface; 908 Status = pDevExt->u.primary.DxgkInterface.DxgkCbQueryMonitorInterface(pDevExt->u.primary.DxgkInterface.DeviceHandle, DXGK_MONITOR_INTERFACE_VERSION_V1, &pMonitorInterface); 909 Assert(Status == STATUS_SUCCESS); 910 if (Status == STATUS_SUCCESS) 911 { 912 D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS; 913 CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf; 914 Status = pMonitorInterface->pfnAcquireMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle, 915 targetId, 916 &hMonitorSMS, 917 &pMonitorSMSIf); 884 918 Assert(Status == STATUS_SUCCESS); 885 919 if (Status == STATUS_SUCCESS) 886 920 { 887 D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS; 888 CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf; 889 Status = pMonitorInterface->pfnAcquireMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle, 890 targetId, 891 &hMonitorSMS, 892 &pMonitorSMSIf); 893 Assert(Status == STATUS_SUCCESS); 894 if (Status == STATUS_SUCCESS) 895 { 896 #if 0 897 VBOXVIDPNCHECKADDMONITORMODES EnumData = {0}; 898 EnumData.cResolutions = cResolutions; 899 EnumData.pResolutions = pResolutionsCopy; 900 Status = vboxVidPnEnumMonitorSourceModes(pDevExt, hMonitorSMS, pMonitorSMSIf, 901 vboxVidPnCheckAddMonitorModesEnum, &EnumData); 921 for (uint32_t i = 0; i < cResolutions; ++i) 922 { 923 D3DKMDT_2DREGION *pRes = &pResolutions[i]; 924 VBOXVIDPNCHECKMONMODESENUM ChkInfo = {0}; 925 ChkInfo.Region = *pRes; 926 Status = vboxVidPnEnumMonitorSourceModes(hMonitorSMS, pMonitorSMSIf, 927 vboxFidPnCheckMonitorModesEnum, &ChkInfo); 902 928 Assert(Status == STATUS_SUCCESS); 903 929 if (Status == STATUS_SUCCESS) 904 930 { 905 Assert(EnumData.Status == STATUS_SUCCESS); 906 if (EnumData.Status == STATUS_SUCCESS) 931 if (!ChkInfo.pMonitorSMI) 907 932 { 908 #endif 909 for (uint32_t i = 0; i < cResolutions; ++i) 933 Status = vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy(pDevExt, 934 hMonitorSMS, 935 pMonitorSMSIf, 936 pRes, 937 enmOrigin, 938 FALSE//i == (uint32_t)iPreferred 939 ); 940 Assert(Status == STATUS_SUCCESS); 941 if (Status != STATUS_SUCCESS) 910 942 { 911 #if 0 912 D3DKMDT_2DREGION *pRes = &pResolutionsCopy[i]; 913 #else 914 D3DKMDT_2DREGION *pRes = &pResolutions[i]; 915 #endif 916 if (pRes->cx) 917 { 918 Status = vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy(pDevExt, 919 hMonitorSMS, 920 pMonitorSMSIf, 921 pRes, 922 enmOrigin, 923 i == (uint32_t)iPreferred); 924 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_MODE_ALREADY_IN_MODESET); 925 if (Status == STATUS_GRAPHICS_MODE_ALREADY_IN_MODESET) 926 { 927 Status = STATUS_SUCCESS; 928 } 929 else if (Status != STATUS_SUCCESS) 930 { 931 drprintf((__FUNCTION__": vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy failed Status(0x%x)\n", Status)); 932 break; 933 } 934 } 943 drprintf((__FUNCTION__": vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy failed Status(0x%x)\n", Status)); 944 break; 935 945 } 936 #if 0 946 } 947 else 948 { 949 pMonitorSMSIf->pfnReleaseModeInfo(hMonitorSMS, ChkInfo.pMonitorSMI); 937 950 } 938 951 } 939 #endif 940 NTSTATUS tmpStatus = pMonitorInterface->pfnReleaseMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle, hMonitorSMS); 941 Assert(tmpStatus == STATUS_SUCCESS); 942 if (tmpStatus != STATUS_SUCCESS) 943 drprintf((__FUNCTION__": pfnReleaseMonitorSourceModeSet failed tmpStatus(0x%x)\n", tmpStatus)); 944 } 945 else 946 drprintf((__FUNCTION__": pfnAcquireMonitorSourceModeSet failed Status(0x%x)\n", Status)); 952 else 953 { 954 drprintf((__FUNCTION__": vboxVidPnEnumMonitorSourceModes failed Status(0x%x)\n", Status)); 955 break; 956 } 957 } 958 NTSTATUS tmpStatus = pMonitorInterface->pfnReleaseMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle, hMonitorSMS); 959 Assert(tmpStatus == STATUS_SUCCESS); 960 if (tmpStatus != STATUS_SUCCESS) 961 drprintf((__FUNCTION__": pfnReleaseMonitorSourceModeSet failed tmpStatus(0x%x)\n", tmpStatus)); 947 962 } 948 963 else 949 drprintf((__FUNCTION__": DxgkCbQueryMonitorInterface failed Status(0x%x)\n", Status)); 950 #if 0 951 vboxWddmMemFree(pResolutionsCopy); 964 drprintf((__FUNCTION__": pfnAcquireMonitorSourceModeSet failed Status(0x%x)\n", Status)); 952 965 } 953 966 else 954 { 955 drprintf((__FUNCTION__": failed to allocate resolution copy of size (%d)\n", cResolutions)); 956 Status = STATUS_NO_MEMORY; 957 } 958 #endif 967 drprintf((__FUNCTION__": DxgkCbQueryMonitorInterface failed Status(0x%x)\n", Status)); 959 968 960 969 return Status; … … 1005 1014 Status = vboxVidPnPopulateTargetModeSetFromLegacy(pDevExt, 1006 1015 hNewVidPnTargetModeSet, pNewVidPnTargetModeSetInterface, 1007 pResolutions, cResolutions, pPreferredMode, 0 , &PreferredTrgModeId);1016 pResolutions, cResolutions, pPreferredMode, 0 /* flags */, &PreferredTrgModeId); 1008 1017 Assert(Status == STATUS_SUCCESS); 1009 1018 if (Status == STATUS_SUCCESS) … … 1199 1208 pNewVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize.cy)) 1200 1209 { 1201 if (vbox WddmVideoModeFind(pInfo->pModes, pInfo->cModes, &Mode) < 0)1210 if (vboxVideoModeFind(pInfo->pModes, pInfo->cModes, &Mode) < 0) 1202 1211 { 1203 1212 if (pInfo->cResultModes < pInfo->cModes) … … 1251 1260 } 1252 1261 1253 DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,1254 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext)1255 { 1256 PVBOXVIDPNCOFUNCMODALITY pCbContext = (PVBOXVIDPNCOFUNCMODALITY)pContext; 1262 NTSTATUS vboxVidPnCofuncModalityForPath(PVBOXVIDPNCOFUNCMODALITY pCbContext, 1263 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId, 1264 BOOLEAN bModesAllowed) 1265 { 1257 1266 PDEVICE_EXTENSION pDevExt = pCbContext->pDevExt; 1258 1267 D3DKMDT_HVIDPN hDesiredVidPn = pCbContext->pEnumCofuncModalityArg->hConstrainingVidPn; … … 1260 1269 NTSTATUS Status = STATUS_SUCCESS; 1261 1270 pCbContext->Status = STATUS_SUCCESS; 1262 PVBOXWDDM_VIDEOMODES_INFO pInfo = &pCbContext->pInfos[pNewVidPnPresentPathInfo->VidPnTargetId]; 1263 bool bConversionSupported = 1264 ( 1265 pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_UNINITIALIZED 1266 || pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_IDENTITY 1267 || pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_UNPINNED 1268 || pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_NOTSPECIFIED 1269 ) 1270 && ( 1271 pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_UNINITIALIZED 1272 || pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_IDENTITY 1273 || pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_UNPINNED 1274 || pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_NOTSPECIFIED 1275 ); 1276 1271 PVBOXWDDM_VIDEOMODES_INFO pInfo = &pCbContext->pInfos[VidPnTargetId]; 1272 BOOLEAN bConversionSupported = bModesAllowed; 1277 1273 1278 1274 D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet; … … 1280 1276 1281 1277 Status = pVidPnInterface->pfnAcquireSourceModeSet(hDesiredVidPn, 1282 pNewVidPnPresentPathInfo->VidPnSourceId,1278 VidPnSourceId, 1283 1279 &hCurVidPnSourceModeSet, 1284 1280 &pCurVidPnSourceModeSetInterface); … … 1300 1296 const DXGK_VIDPNTARGETMODESET_INTERFACE *pCurVidPnTargetModeSetInterface; 1301 1297 Status = pVidPnInterface->pfnAcquireTargetModeSet(hDesiredVidPn, 1302 pNewVidPnPresentPathInfo->VidPnTargetId,1298 VidPnTargetId, 1303 1299 &hCurVidPnTargetModeSet, 1304 1300 &pCurVidPnTargetModeSetInterface); … … 1319 1315 bool bSrcPinned = pPinnedVidPnSourceModeInfo 1320 1316 || (pCbContext->pEnumCofuncModalityArg->EnumPivotType == D3DKMDT_EPT_VIDPNSOURCE 1321 && (pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnSourceId == pNewVidPnPresentPathInfo->VidPnSourceId1317 && (pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnSourceId == VidPnSourceId 1322 1318 || pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnSourceId == D3DDDI_ID_ALL)); 1323 1319 bool bTgtPinned = pPinnedVidPnTargetModeInfo 1324 1320 || (pCbContext->pEnumCofuncModalityArg->EnumPivotType == D3DKMDT_EPT_VIDPNTARGET 1325 && (pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnTargetId == pNewVidPnPresentPathInfo->VidPnTargetId1321 && (pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnTargetId == VidPnTargetId 1326 1322 || pCbContext->pEnumCofuncModalityArg->EnumPivot.VidPnTargetId == D3DDDI_ID_ALL)); 1327 1323 if (bSrcPinned) … … 1329 1325 if (!bTgtPinned) 1330 1326 { 1327 #if 1 1328 uint32_t cResolutions = bConversionSupported ? pInfo->cResolutions : 0; 1329 Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface, 1330 VidPnTargetId, 1331 pInfo->aResolutions, 1332 cResolutions, 1333 NULL, 1334 0, /* flags */ 1335 NULL); 1336 Assert(Status == STATUS_SUCCESS); 1337 #else 1331 1338 /* adjust target mode set relative to source mode set */ 1332 1339 /* 1. get list of resolutions for source and for target … … 1394 1401 { 1395 1402 Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface, 1396 pNewVidPnPresentPathInfo->VidPnTargetId,1403 VidPnTargetId, 1397 1404 pSrcResolutions, 1398 1405 cSrcResolutions, 1399 1406 NULL, 1400 0, 1407 0, /* flags */ 1401 1408 NULL); 1402 1409 Assert(Status == STATUS_SUCCESS); … … 1431 1438 } 1432 1439 } 1440 #endif 1433 1441 } 1434 1442 } 1435 1443 else if (bTgtPinned) 1436 1444 { 1445 #if 1 1446 uint32_t cModes = bConversionSupported ? pInfo->cModes : 0; 1447 Status = Status = vboxVidPnCreatePopulateSourceModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface, 1448 VidPnSourceId, 1449 pInfo->aModes, cModes, -1, NULL); 1450 Assert(Status == STATUS_SUCCESS); 1451 #else 1437 1452 /* adjust source mode set relative to target mode set */ 1438 1453 /* 1. get list of modes for target resolutions … … 1504 1519 { 1505 1520 Status = Status = vboxVidPnCreatePopulateSourceModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface, 1506 pNewVidPnPresentPathInfo->VidPnSourceId,1521 VidPnSourceId, 1507 1522 pTgtModes, Info.Base.cResultModes, -1, NULL); 1508 1523 Assert(Status == STATUS_SUCCESS); … … 1537 1552 } 1538 1553 } 1554 #endif 1539 1555 } 1540 1556 else 1541 1557 { 1558 #if 1 1559 uint32_t cModes = bConversionSupported ? pInfo->cModes : 0; 1560 Status = Status = vboxVidPnCreatePopulateSourceModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface, 1561 VidPnSourceId, 1562 pInfo->aModes, cModes, -1, NULL); 1563 Assert(Status == STATUS_SUCCESS); 1564 1565 uint32_t cResolutions = bConversionSupported ? pInfo->cResolutions : 0; 1566 Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface, 1567 VidPnTargetId, 1568 pInfo->aResolutions, 1569 cResolutions, 1570 NULL, 1571 0, 1572 NULL); 1573 Assert(Status == STATUS_SUCCESS); 1574 #else 1542 1575 /* neither Source nor Target are pinned */ 1543 1576 /* 1. get list of target resolutions … … 1601 1634 { 1602 1635 Status = Status = vboxVidPnCreatePopulateSourceModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface, 1603 pNewVidPnPresentPathInfo->VidPnSourceId,1636 VidPnSourceId, 1604 1637 pInfo->aModes, cModes, -1, NULL); 1605 1638 Assert(Status == STATUS_SUCCESS); … … 1667 1700 { 1668 1701 Status = vboxVidPnCreatePopulateTargetModeSetFromLegacy(pDevExt, hDesiredVidPn, pVidPnInterface, 1669 pNewVidPnPresentPathInfo->VidPnTargetId,1702 VidPnTargetId, 1670 1703 pInfo->aResolutions, 1671 1704 cResolutions, 1672 1705 NULL, 1673 0, 1706 0, /* flags */ 1674 1707 NULL); 1675 1708 Assert(Status == STATUS_SUCCESS); … … 1678 1711 } 1679 1712 } 1713 #endif 1680 1714 } 1681 1715 1682 1716 if (pPinnedVidPnTargetModeInfo) 1717 { 1683 1718 pCurVidPnTargetModeSetInterface->pfnReleaseModeInfo(hCurVidPnTargetModeSet, pPinnedVidPnTargetModeInfo); 1719 } 1684 1720 pVidPnInterface->pfnReleaseTargetModeSet(hDesiredVidPn, hCurVidPnTargetModeSet); 1685 1721 } … … 1688 1724 1689 1725 if (pPinnedVidPnSourceModeInfo) 1726 { 1727 if (Status == STATUS_SUCCESS) 1728 { 1729 D3DDDI_MULTISAMPLINGMETHOD Msm; 1730 Msm.NumSamples = 1; 1731 Msm.NumQualityLevels = 0; 1732 1733 Status = pVidPnInterface->pfnAssignMultisamplingMethodSet(hDesiredVidPn, VidPnSourceId, 1, &Msm); 1734 Assert(Status == STATUS_SUCCESS); 1735 } 1736 1690 1737 pCurVidPnSourceModeSetInterface->pfnReleaseModeInfo(hCurVidPnSourceModeSet, pPinnedVidPnSourceModeInfo); 1738 } 1691 1739 pVidPnInterface->pfnReleaseSourceModeSet(hDesiredVidPn, hCurVidPnSourceModeSet); 1692 1740 } 1693 1741 else 1694 1742 drprintf((__FUNCTION__": pfnAcquireSourceModeSet failed Status(0x%x)\n", Status)); 1743 1744 Assert(Status == STATUS_SUCCESS); 1745 return Status; 1746 1747 } 1748 1749 DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface, 1750 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext) 1751 { 1752 PVBOXVIDPNCOFUNCMODALITY pCbContext = (PVBOXVIDPNCOFUNCMODALITY)pContext; 1753 bool bConversionSupported = 1754 ( 1755 pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_UNINITIALIZED 1756 || pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_IDENTITY 1757 || pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_UNPINNED 1758 || pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_NOTSPECIFIED 1759 ) 1760 && ( 1761 pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_UNINITIALIZED 1762 || pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_IDENTITY 1763 || pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_UNPINNED 1764 || pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_NOTSPECIFIED 1765 ) 1766 && (pNewVidPnPresentPathInfo->VidPnSourceId == pNewVidPnPresentPathInfo->VidPnTargetId); 1767 1768 NTSTATUS Status = vboxVidPnCofuncModalityForPath(pCbContext, 1769 pNewVidPnPresentPathInfo->VidPnSourceId, pNewVidPnPresentPathInfo->VidPnTargetId, bConversionSupported); 1695 1770 1696 1771 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo); … … 1701 1776 } 1702 1777 1703 NTSTATUS vboxVidPnEnumMonitorSourceModes(PDEVICE_EXTENSION pDevExt, D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf, 1778 DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityCheckPathsSupportedEnum(D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface, 1779 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext) 1780 { 1781 PVBOXVIDPNCOFUNCMODALITY pCbContext = (PVBOXVIDPNCOFUNCMODALITY)pContext; 1782 bool bConversionSupported = 1783 ( 1784 pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_UNINITIALIZED 1785 || pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_IDENTITY 1786 || pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_UNPINNED 1787 || pNewVidPnPresentPathInfo->ContentTransformation.Scaling == D3DKMDT_VPPS_NOTSPECIFIED 1788 ) 1789 && ( 1790 pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_UNINITIALIZED 1791 || pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_IDENTITY 1792 || pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_UNPINNED 1793 || pNewVidPnPresentPathInfo->ContentTransformation.Rotation == D3DKMDT_VPPR_NOTSPECIFIED 1794 ) 1795 && (pNewVidPnPresentPathInfo->VidPnSourceId == pNewVidPnPresentPathInfo->VidPnTargetId); 1796 1797 NTSTATUS Status = vboxVidPnCofuncModalityForPath(pCbContext, 1798 pNewVidPnPresentPathInfo->VidPnSourceId, pNewVidPnPresentPathInfo->VidPnTargetId, bConversionSupported); 1799 1800 pVidPnTopologyInterface->pfnReleasePathInfo(hVidPnTopology, pNewVidPnPresentPathInfo); 1801 1802 pCbContext->Status = Status; 1803 Assert(Status == STATUS_SUCCESS); 1804 return Status == STATUS_SUCCESS; 1805 } 1806 1807 NTSTATUS vboxVidPnEnumMonitorSourceModes(D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf, 1704 1808 PFNVBOXVIDPNENUMMONITORSOURCEMODES pfnCallback, PVOID pContext) 1705 1809 { … … 1714 1818 CONST D3DKMDT_MONITOR_SOURCE_MODE *pNextMonitorSMI; 1715 1819 Status = pMonitorSMSIf->pfnAcquireNextModeInfo(hMonitorSMS, pMonitorSMI, &pNextMonitorSMI); 1716 if (!pfnCallback( pDevExt,hMonitorSMS, pMonitorSMSIf, pMonitorSMI, pContext))1820 if (!pfnCallback(hMonitorSMS, pMonitorSMSIf, pMonitorSMI, pContext)) 1717 1821 { 1718 1822 Assert(Status == STATUS_SUCCESS || Status == STATUS_GRAPHICS_NO_MORE_ELEMENTS_IN_DATASET); … … 2394 2498 } 2395 2499 2396 void vboxVidPnDumpCopyProtectoin(const D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION *pCopyProtection)2397 { 2398 drprintf((" CopyProtection: CopyProtectionType(%s), TODO: Dump All the rest\n",2399 vboxVidPnDumpStrCopyProtectionType(pCopyProtection->CopyProtectionType) ));2500 void vboxVidPnDumpCopyProtectoin(const char *pPrefix, const D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION *pCopyProtection, const char *pSuffix) 2501 { 2502 drprintf(("%sType(%s), TODO%s", pPrefix, 2503 vboxVidPnDumpStrCopyProtectionType(pCopyProtection->CopyProtectionType), pSuffix)); 2400 2504 } 2401 2505 … … 2403 2507 void vboxVidPnDumpPathTransformation(const D3DKMDT_VIDPN_PRESENT_PATH_TRANSFORMATION *pContentTransformation) 2404 2508 { 2405 drprintf((" Transformation: Scaling(%s), ScalingSupport(%d), Rotation(%s), RotationSupport(%d)\n",2509 drprintf((" --Transformation: Scaling(%s), ScalingSupport(%d), Rotation(%s), RotationSupport(%d)--\n", 2406 2510 vboxVidPnDumpStrScaling(pContentTransformation->Scaling), pContentTransformation->ScalingSupport, 2407 2511 vboxVidPnDumpStrRotation(pContentTransformation->Rotation), pContentTransformation->RotationSupport)); … … 2452 2556 vboxVidPnDumpRegion("activeSize(", &pVideoSignalInfo->ActiveSize, "), "); 2453 2557 vboxVidPnDumpRational("VSynch(", &pVideoSignalInfo->VSyncFreq, "), "); 2454 drprintf(("PixelRate(%d), ScanLineOrdering(%s)%s \n", pVideoSignalInfo->PixelRate, vboxVidPnDumpStrScanLineOrdering(pVideoSignalInfo->ScanLineOrdering), pSuffix));2558 drprintf(("PixelRate(%d), ScanLineOrdering(%s)%s", pVideoSignalInfo->PixelRate, vboxVidPnDumpStrScanLineOrdering(pVideoSignalInfo->ScanLineOrdering), pSuffix)); 2455 2559 } 2456 2560 … … 2459 2563 drprintf(("%s", pPrefix)); 2460 2564 vboxVidPnDumpSignalInfo("VSI: ", &pVidPnTargetModeInfo->VideoSignalInfo, ", "); 2461 drprintf(("Preference(%s)%s", vboxVidPnDumpStrModePreference(pVidPnTargetModeInfo->Preference), p Prefix));2565 drprintf(("Preference(%s)%s", vboxVidPnDumpStrModePreference(pVidPnTargetModeInfo->Preference), pSuffix)); 2462 2566 } 2463 2567 … … 2629 2733 vboxVidPnDumpPinnedTargetMode(hVidPn, pVidPnInterface, pVidPnPresentPathInfo->VidPnTargetId); 2630 2734 2631 drprintf(("ImportanceOrdinal(%s), VidPnTargetColorBasis(%s), Content(%s)\n", 2735 vboxVidPnDumpPathTransformation(&pVidPnPresentPathInfo->ContentTransformation); 2736 2737 drprintf(("Importance(%s), TargetColorBasis(%s), Content(%s), ", 2632 2738 vboxVidPnDumpStrImportance(pVidPnPresentPathInfo->ImportanceOrdinal), 2633 2739 vboxVidPnDumpStrColorBasis(pVidPnPresentPathInfo->VidPnTargetColorBasis), 2634 2740 vboxVidPnDumpStrContent(pVidPnPresentPathInfo->Content))); 2635 vboxVidPnDumpPathTransformation(&pVidPnPresentPathInfo->ContentTransformation); 2636 vboxVidPnDumpRegion("VisibleFromActiveTLOffset(", &pVidPnPresentPathInfo->VisibleFromActiveTLOffset, ")\n"); 2637 vboxVidPnDumpRegion("VisibleFromActiveBROffset(", &pVidPnPresentPathInfo->VisibleFromActiveBROffset, ")\n"); 2638 vboxVidPnDumpRanges("VidPnTargetColorCoeffDynamicRanges: ", &pVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges, "\n"); 2639 vboxVidPnDumpCopyProtectoin(&pVidPnPresentPathInfo->CopyProtection); 2741 vboxVidPnDumpRegion("VFA_TL_O(", &pVidPnPresentPathInfo->VisibleFromActiveTLOffset, "), "); 2742 vboxVidPnDumpRegion("VFA_BR_O(", &pVidPnPresentPathInfo->VisibleFromActiveBROffset, "), "); 2743 vboxVidPnDumpRanges("CCDynamicRanges: ", &pVidPnPresentPathInfo->VidPnTargetColorCoeffDynamicRanges, "| "); 2744 vboxVidPnDumpCopyProtectoin("CProtection: ", &pVidPnPresentPathInfo->CopyProtection, "| "); 2640 2745 vboxVidPnDumpGammaRamp("GammaRamp: ", &pVidPnPresentPathInfo->GammaRamp, "\n"); 2641 2746 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.h
r34018 r34130 71 71 72 72 /* !!!NOTE: The callback is responsible for releasing the source mode info */ 73 typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMMONITORSOURCEMODES( struct _DEVICE_EXTENSION* pDevExt,D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf,73 typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMMONITORSOURCEMODES(D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf, 74 74 CONST D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSMI, PVOID pContext); 75 75 typedef FNVBOXVIDPNENUMMONITORSOURCEMODES *PFNVBOXVIDPNENUMMONITORSOURCEMODES; … … 104 104 PFNVBOXVIDPNENUMTARGETMODES pfnCallback, PVOID pContext); 105 105 106 NTSTATUS vboxVidPnEnumMonitorSourceModes( struct _DEVICE_EXTENSION* pDevExt,D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf,106 NTSTATUS vboxVidPnEnumMonitorSourceModes(D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf, 107 107 PFNVBOXVIDPNENUMMONITORSOURCEMODES pfnCallback, PVOID pContext); 108 108 … … 126 126 D3DKMDT_2DREGION *pResolutions, uint32_t cResolutions, int32_t iPreferred); 127 127 128 NTSTATUS vboxVidPnCofuncModalityForPath(PVBOXVIDPNCOFUNCMODALITY pCbContext, 129 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId, 130 BOOLEAN bModesAllowed); 131 128 132 void vboxVidPnDumpVidPn(const char * pPrefix, PDEVICE_EXTENSION pDevExt, D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, const char * pSuffix); 129 133 void vboxVidPnDumpCofuncModalityArg(const char *pPrefix, CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* CONST pEnumCofuncModalityArg, const char *pSuffix); -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r34079 r34130 1084 1084 ChildRelations[i].ChildCapabilities.Type.VideoOutput.MonitorOrientationAwareness = D3DKMDT_MOA_INTERRUPTIBLE; /* ?? D3DKMDT_MOA_NONE*/ 1085 1085 ChildRelations[i].ChildCapabilities.Type.VideoOutput.SupportsSdtvModes = FALSE; 1086 ChildRelations[i].ChildCapabilities.HpdAwareness = HpdAwareness Interruptible; /* ?? HpdAwarenessAlwaysConnected; */1086 ChildRelations[i].ChildCapabilities.HpdAwareness = HpdAwarenessAlwaysConnected; //HpdAwarenessInterruptible; /* ?? HpdAwarenessAlwaysConnected; */ 1087 1087 ChildRelations[i].AcpiUid = i; /* */ 1088 1088 ChildRelations[i].ChildUid = i; /* should be == target id */ … … 3555 3555 { 3556 3556 #ifdef VBOXWDDM_DEBUG_VIDPN 3557 vboxVidPnDumpVidPn("\n>>>>IS SUPPORTED VidPN : >>>>\n", pContext, pIsSupportedVidPnArg->hDesiredVidPn, pVidPnInterface, "<<<<<<<<<<<<<<<<<<<<\n \n");3557 vboxVidPnDumpVidPn("\n>>>>IS SUPPORTED VidPN : >>>>\n", pContext, pIsSupportedVidPnArg->hDesiredVidPn, pVidPnInterface, "<<<<<<<<<<<<<<<<<<<<\n"); 3558 3558 #endif 3559 3559 … … 3566 3566 if (Status == STATUS_SUCCESS && bSupported) 3567 3567 { 3568 #if 0 3568 3569 for (int id = 0; id < commonFromDeviceExt(pContext)->cDisplays; ++id) 3569 3570 { … … 3577 3578 { 3578 3579 Status = vboxVidPnCheckSourceModeSet(pIsSupportedVidPnArg->hDesiredVidPn, hNewVidPnSourceModeSet, pVidPnSourceModeSetInterface, &bSupported); 3580 3581 Assert(bSupported); 3579 3582 3580 3583 pVidPnInterface->pfnReleaseSourceModeSet(pIsSupportedVidPnArg->hDesiredVidPn, hNewVidPnSourceModeSet); … … 3608 3611 { 3609 3612 Status = vboxVidPnCheckTargetModeSet(pIsSupportedVidPnArg->hDesiredVidPn, hNewVidPnTargetModeSet, pVidPnTargetModeSetInterface, &bSupported); 3613 3614 Assert(bSupported); 3610 3615 3611 3616 pVidPnInterface->pfnReleaseTargetModeSet(pIsSupportedVidPnArg->hDesiredVidPn, hNewVidPnTargetModeSet); … … 3626 3631 } 3627 3632 } 3633 #endif 3628 3634 } 3629 3635 } … … 3640 3646 3641 3647 #ifdef VBOXWDDM_DEBUG_VIDPN 3642 drprintf(("The Given VidPn is %ssupported ", pIsSupportedVidPnArg->IsVidPnSupported ? "" : "!!NOT!! "));3648 drprintf(("The Given VidPn is %ssupported\n\n", pIsSupportedVidPnArg->IsVidPnSupported ? "" : "!!NOT!! ")); 3643 3649 #endif 3644 3650 … … 3664 3670 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter; 3665 3671 NTSTATUS Status; 3666 vboxWddmInvalidateVideoModesInfo(pDevExt); 3667 PVBOXWDDM_VIDEOMODES_INFO pInfos = vboxWddmGetAllVideoModesInfos(pDevExt); 3672 PVBOXWDDM_RECOMMENDVIDPN pVidPnInfo = pRecommendFunctionalVidPnArg->PrivateDriverDataSize >= sizeof (VBOXWDDM_RECOMMENDVIDPN) ? 3673 (PVBOXWDDM_RECOMMENDVIDPN)pRecommendFunctionalVidPnArg->pPrivateDriverData : NULL; 3674 PVBOXWDDM_VIDEOMODES_INFO pInfos = vboxWddmUpdateVideoModesInfo(pDevExt, pVidPnInfo); 3668 3675 const DXGK_VIDPN_INTERFACE* pVidPnInterface = NULL; 3669 3676 Status = pDevExt->u.primary.DxgkInterface.DxgkCbQueryVidPnInterface(pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn, DXGK_VIDPN_INTERFACE_VERSION_V1, &pVidPnInterface); … … 3720 3727 3721 3728 Assert(iPreferableResMode >= 0); 3729 Assert(cActualResModes); 3722 3730 3723 3731 Status = vboxVidPnCreatePopulateVidPnFromLegacy(pDevExt, pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn, pVidPnInterface, 3724 pResModes, c ResModes, iPreferableResMode,3732 pResModes, cActualResModes, iPreferableResMode, 3725 3733 &Resolution, 1 /* cResolutions */, 3726 3734 i, i); /* srcId, tgtId */ … … 3776 3784 if (Status == STATUS_SUCCESS) 3777 3785 { 3786 BOOLEAN bSupported = FALSE; 3787 Status = vboxVidPnCheckTopology(pDevExt, pEnumCofuncModalityArg->hConstrainingVidPn, hVidPnTopology, pVidPnTopologyInterface, &bSupported); 3788 Assert(Status == STATUS_SUCCESS); 3789 Assert(bSupported); 3790 3778 3791 VBOXVIDPNCOFUNCMODALITY CbContext = {0}; 3779 3792 CbContext.pDevExt = pDevExt; … … 3781 3794 CbContext.pEnumCofuncModalityArg = pEnumCofuncModalityArg; 3782 3795 CbContext.pInfos = vboxWddmGetAllVideoModesInfos(pDevExt); 3796 3797 #if 1 3798 for (int i = 0; i < commonFromDeviceExt(pDevExt)->cDisplays; ++i) 3799 { 3800 vboxVidPnCofuncModalityForPath(&CbContext, i, i, TRUE); 3801 } 3802 #else 3783 3803 Status = vboxVidPnEnumPaths(hVidPnTopology, pVidPnTopologyInterface, 3784 3804 vboxVidPnCofuncModalityPathEnum, &CbContext); … … 3793 3813 else 3794 3814 drprintf((__FUNCTION__ ": vboxVidPnEnumPaths failed Status(0x%x)\n", Status)); 3815 #endif 3795 3816 } 3796 3817 else -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.h
r34018 r34130 228 228 int32_t iPreferredMode; 229 229 uint32_t cModes; 230 uint32_t cPrevModes; 230 231 VIDEO_MODE_INFORMATION aModes[VBOXWDDM_MAX_VIDEOMODES]; 231 232 uint32_t cResolutions; -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp
r33980 r34130 21 21 #include <iprt/assert.h> 22 22 23 #include <malloc.h> 24 23 25 /* display driver interface abstraction for XPDM & WDDM 24 26 * with WDDM we can not use ExtEscape to communicate with our driver … … 58 60 OSinfo.dwOSVersionInfoSize = sizeof (OSinfo); 59 61 GetVersionEx (&OSinfo); 62 bool bSupported = true; 63 60 64 if (OSinfo.dwMajorVersion >= 6) 61 65 { 62 /* this is vista and up */63 66 Log((__FUNCTION__": this is vista and up\n")); 64 HMODULE hGdi32 = GetModuleHandle("gdi32"); 65 if (hGdi32 != NULL) 66 { 67 bool bSupported = true; 68 pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromHdc = (PFND3DKMT_OPENADAPTERFROMHDC)GetProcAddress(hGdi32, "D3DKMTOpenAdapterFromHdc"); 69 Log((__FUNCTION__"pfnD3DKMTOpenAdapterFromHdc = %p\n", pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromHdc)); 70 bSupported &= !!(pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromHdc); 71 72 pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromGdiDisplayName = (PFND3DKMT_OPENADAPTERFROMGDIDISPLAYNAME)GetProcAddress(hGdi32, "D3DKMTOpenAdapterFromGdiDisplayName"); 73 Log((__FUNCTION__": pfnD3DKMTOpenAdapterFromGdiDisplayName = %p\n", pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromGdiDisplayName)); 74 bSupported &= !!(pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromGdiDisplayName); 75 76 pIf->modeData.wddm.pfnD3DKMTCloseAdapter = (PFND3DKMT_CLOSEADAPTER)GetProcAddress(hGdi32, "D3DKMTCloseAdapter"); 77 Log((__FUNCTION__": pfnD3DKMTCloseAdapter = %p\n", pIf->modeData.wddm.pfnD3DKMTCloseAdapter)); 78 bSupported &= !!(pIf->modeData.wddm.pfnD3DKMTCloseAdapter); 79 80 pIf->modeData.wddm.pfnD3DKMTEscape = (PFND3DKMT_ESCAPE)GetProcAddress(hGdi32, "D3DKMTEscape"); 81 Log((__FUNCTION__": pfnD3DKMTEscape = %p\n", pIf->modeData.wddm.pfnD3DKMTEscape)); 82 bSupported &= !!(pIf->modeData.wddm.pfnD3DKMTCloseAdapter); 83 84 pIf->modeData.wddm.pfnD3DKMTInvalidateActiveVidPn = (PFND3DKMT_INVALIDATEACTIVEVIDPN)GetProcAddress(hGdi32, "D3DKMTInvalidateActiveVidPn"); 85 Log((__FUNCTION__": pfnD3DKMTInvalidateActiveVidPn = %p\n", pIf->modeData.wddm.pfnD3DKMTInvalidateActiveVidPn)); 86 bSupported &= !!(pIf->modeData.wddm.pfnD3DKMTInvalidateActiveVidPn); 87 88 if (!bSupported) 89 { 90 Log((__FUNCTION__": one of pfnD3DKMT function pointers failed to initialize\n")); 67 HMODULE hUser = GetModuleHandle("USER32"); 68 if (hUser) 69 { 70 *(uintptr_t *)&pIf->modeData.wddm.pfnChangeDisplaySettingsEx = (uintptr_t)GetProcAddress(hUser, "ChangeDisplaySettingsExA"); 71 Log((__FUNCTION__": VBoxDisplayInit: pfnChangeDisplaySettingsEx = %p\n", pIf->modeData.wddm.pfnChangeDisplaySettingsEx)); 72 bSupported &= !!(pIf->modeData.wddm.pfnChangeDisplaySettingsEx); 73 74 *(uintptr_t *)&pIf->modeData.wddm.pfnEnumDisplayDevices = (uintptr_t)GetProcAddress(hUser, "EnumDisplayDevicesA"); 75 Log((__FUNCTION__": VBoxDisplayInit: pfnEnumDisplayDevices = %p\n", pIf->modeData.wddm.pfnEnumDisplayDevices)); 76 bSupported &= !!(pIf->modeData.wddm.pfnEnumDisplayDevices); 77 78 /* this is vista and up */ 79 HMODULE hGdi32 = GetModuleHandle("gdi32"); 80 if (hGdi32 != NULL) 81 { 82 pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromHdc = (PFND3DKMT_OPENADAPTERFROMHDC)GetProcAddress(hGdi32, "D3DKMTOpenAdapterFromHdc"); 83 Log((__FUNCTION__"pfnD3DKMTOpenAdapterFromHdc = %p\n", pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromHdc)); 84 bSupported &= !!(pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromHdc); 85 86 pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromGdiDisplayName = (PFND3DKMT_OPENADAPTERFROMGDIDISPLAYNAME)GetProcAddress(hGdi32, "D3DKMTOpenAdapterFromGdiDisplayName"); 87 Log((__FUNCTION__": pfnD3DKMTOpenAdapterFromGdiDisplayName = %p\n", pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromGdiDisplayName)); 88 bSupported &= !!(pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromGdiDisplayName); 89 90 pIf->modeData.wddm.pfnD3DKMTCloseAdapter = (PFND3DKMT_CLOSEADAPTER)GetProcAddress(hGdi32, "D3DKMTCloseAdapter"); 91 Log((__FUNCTION__": pfnD3DKMTCloseAdapter = %p\n", pIf->modeData.wddm.pfnD3DKMTCloseAdapter)); 92 bSupported &= !!(pIf->modeData.wddm.pfnD3DKMTCloseAdapter); 93 94 pIf->modeData.wddm.pfnD3DKMTEscape = (PFND3DKMT_ESCAPE)GetProcAddress(hGdi32, "D3DKMTEscape"); 95 Log((__FUNCTION__": pfnD3DKMTEscape = %p\n", pIf->modeData.wddm.pfnD3DKMTEscape)); 96 bSupported &= !!(pIf->modeData.wddm.pfnD3DKMTCloseAdapter); 97 98 pIf->modeData.wddm.pfnD3DKMTInvalidateActiveVidPn = (PFND3DKMT_INVALIDATEACTIVEVIDPN)GetProcAddress(hGdi32, "D3DKMTInvalidateActiveVidPn"); 99 Log((__FUNCTION__": pfnD3DKMTInvalidateActiveVidPn = %p\n", pIf->modeData.wddm.pfnD3DKMTInvalidateActiveVidPn)); 100 bSupported &= !!(pIf->modeData.wddm.pfnD3DKMTInvalidateActiveVidPn); 101 102 if (!bSupported) 103 { 104 Log((__FUNCTION__": one of pfnD3DKMT function pointers failed to initialize\n")); 105 err = ERROR_NOT_SUPPORTED; 106 } 107 } 108 else 109 { 110 Log((__FUNCTION__": GetModuleHandle(gdi32) failed, err(%d)\n", GetLastError())); 91 111 err = ERROR_NOT_SUPPORTED; 92 112 } 113 93 114 } 94 115 else 95 116 { 96 Log((__FUNCTION__": GetModuleHandle( gdi32) failed, err(%d)\n", GetLastError()));117 Log((__FUNCTION__": GetModuleHandle(USER32) failed, err(%d)\n", GetLastError())); 97 118 err = ERROR_NOT_SUPPORTED; 98 119 } … … 259 280 260 281 pCtx->Status = pIf->modeData.wddm.pfnD3DKMTInvalidateActiveVidPn(&IAVidPnData); 282 Assert(!pCtx->Status); 261 283 if (pCtx->Status) 262 284 Log((__FUNCTION__": pfnD3DKMTInvalidateActiveVidPn failed, Status (0x%x)\n", pCtx->Status)); … … 342 364 } 343 365 366 static BOOL vboxDispIfValidateResize(DISPLAY_DEVICE *paDisplayDevices, DEVMODE *paDeviceModes, UINT cDevModes) 367 { 368 DISPLAY_DEVICE DisplayDevice; 369 int i = 0; 370 UINT cMatched = 0; 371 DEVMODE DeviceMode; 372 for (int i = 0; ; ++i) 373 { 374 ZeroMemory(&DisplayDevice, sizeof(DISPLAY_DEVICE)); 375 DisplayDevice.cb = sizeof(DISPLAY_DEVICE); 376 377 if (!EnumDisplayDevices (NULL, i, &DisplayDevice, 0)) 378 break; 379 380 Log(("VBoxTray: vboxDispIfValidateResize: [%d(%d)] %s\n", i, cMatched, DisplayDevice.DeviceName)); 381 382 BOOL bFetchDevice = FALSE; 383 384 if (DisplayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) 385 { 386 Log(("VBoxTray: vboxDispIfValidateResize: Found primary device. err %d\n", GetLastError ())); 387 bFetchDevice = TRUE; 388 } 389 else if (!(DisplayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)) 390 { 391 392 Log(("VBoxTray: vboxDispIfValidateResize: Found secondary device. err %d\n", GetLastError ())); 393 bFetchDevice = TRUE; 394 } 395 396 if (bFetchDevice) 397 { 398 if (cMatched >= cDevModes) 399 { 400 Log(("VBoxTray: vboxDispIfValidateResize: %d >= %d\n", cDevModes, cMatched)); 401 return FALSE; 402 } 403 404 /* First try to get the video mode stored in registry (ENUM_REGISTRY_SETTINGS). 405 * A secondary display could be not active at the moment and would not have 406 * a current video mode (ENUM_CURRENT_SETTINGS). 407 */ 408 ZeroMemory(&DeviceMode, sizeof(DeviceMode)); 409 DeviceMode.dmSize = sizeof(DEVMODE); 410 if (!EnumDisplaySettings((LPSTR)DisplayDevice.DeviceName, 411 ENUM_REGISTRY_SETTINGS, &DeviceMode)) 412 { 413 Log(("VBoxTray: vboxDispIfValidateResize: EnumDisplaySettings error %d\n", GetLastError ())); 414 return FALSE; 415 } 416 417 if ( DeviceMode.dmPelsWidth == 0 418 || DeviceMode.dmPelsHeight == 0) 419 { 420 /* No ENUM_REGISTRY_SETTINGS yet. Seen on Vista after installation. 421 * Get the current video mode then. 422 */ 423 ZeroMemory(&DeviceMode, sizeof(DeviceMode)); 424 DeviceMode.dmSize = sizeof(DeviceMode); 425 if (!EnumDisplaySettings((LPSTR)DisplayDevice.DeviceName, 426 ENUM_CURRENT_SETTINGS, &DeviceMode)) 427 { 428 /* ENUM_CURRENT_SETTINGS returns FALSE when the display is not active: 429 * for example a disabled secondary display */ 430 Log(("VBoxTray: vboxDispIfValidateResize: EnumDisplaySettings(ENUM_CURRENT_SETTINGS) error %d\n", GetLastError ())); 431 return FALSE; 432 } 433 } 434 435 UINT j = 0; 436 for (; j < cDevModes; ++j) 437 { 438 if (!strncmp(DisplayDevice.DeviceName, paDisplayDevices[j].DeviceName, RT_ELEMENTS(DeviceMode.dmDeviceName))) 439 { 440 if (paDeviceModes[j].dmBitsPerPel != DeviceMode.dmBitsPerPel 441 || (paDeviceModes[j].dmPelsWidth & 0xfff8) != (DeviceMode.dmPelsWidth & 0xfff8) 442 || (paDeviceModes[j].dmPelsHeight & 0xfff8) != (DeviceMode.dmPelsHeight & 0xfff8) 443 || (paDeviceModes[j].dmPosition.x & 0xfff8) != (DeviceMode.dmPosition.x & 0xfff8) 444 || (paDeviceModes[j].dmPosition.y & 0xfff8) != (DeviceMode.dmPosition.y & 0xfff8) 445 || (paDisplayDevices[j].StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) == (DisplayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) 446 { 447 return FALSE; 448 } 449 break; 450 } 451 } 452 453 if (j == cDevModes) 454 return FALSE; 455 456 ++cMatched; 457 } 458 } 459 460 return cMatched == cDevModes; 461 } 462 463 DWORD vboxDispIfResizeModesWDDM(PCVBOXDISPIF const pIf, DISPLAY_DEVICE *paDisplayDevices, DEVMODE *paDeviceModes, UINT cDevModes) 464 { 465 UINT cbVidPnInfo = VBOXWDDM_RECOMMENDVIDPN_SIZE(cDevModes); 466 PVBOXWDDM_RECOMMENDVIDPN pVidPnInfo = (PVBOXWDDM_RECOMMENDVIDPN)alloca(cbVidPnInfo); 467 pVidPnInfo->cScreenInfos = cDevModes; 468 D3DKMT_HANDLE hAdapter = NULL; 469 NTSTATUS Status; 470 DWORD winEr = NO_ERROR; 471 UINT i = 0; 472 473 for (; i < cDevModes; i++) 474 { 475 PVBOXWDDM_RECOMMENDVIDPN_SCREEN_INFO pInfo = &pVidPnInfo->aScreenInfos[i]; 476 D3DKMT_OPENADAPTERFROMHDC OpenAdapterData = {0}; 477 OpenAdapterData.hDc = CreateDC(NULL, paDisplayDevices[i].DeviceName, NULL, NULL); 478 if (!OpenAdapterData.hDc) 479 { 480 winEr = GetLastError(); 481 Assert(0); 482 break; 483 } 484 485 Status = pIf->modeData.wddm.pfnD3DKMTOpenAdapterFromHdc(&OpenAdapterData); 486 Assert(!Status); 487 if (Status) 488 { 489 winEr = ERROR_GEN_FAILURE; 490 Assert(0); 491 break; 492 } 493 494 pInfo->Id = OpenAdapterData.VidPnSourceId; 495 pInfo->Width = paDeviceModes[i].dmPelsWidth; 496 pInfo->Height = paDeviceModes[i].dmPelsHeight; 497 pInfo->BitsPerPixel = paDeviceModes[i].dmBitsPerPel; 498 499 if (!hAdapter) 500 { 501 hAdapter = OpenAdapterData.hAdapter; 502 } 503 else 504 { 505 D3DKMT_CLOSEADAPTER ClosaAdapterData = {0}; 506 ClosaAdapterData.hAdapter = OpenAdapterData.hAdapter; 507 Status = pIf->modeData.wddm.pfnD3DKMTCloseAdapter(&ClosaAdapterData); 508 Assert(!Status); 509 } 510 } 511 512 if (winEr == NO_ERROR) 513 { 514 Assert(hAdapter); 515 516 D3DKMT_INVALIDATEACTIVEVIDPN IAVidPnData = {0}; 517 IAVidPnData.hAdapter = hAdapter; 518 IAVidPnData.pPrivateDriverData = pVidPnInfo; 519 IAVidPnData.PrivateDriverDataSize = cbVidPnInfo; 520 521 DWORD winEr = NO_ERROR; 522 Status = pIf->modeData.wddm.pfnD3DKMTInvalidateActiveVidPn(&IAVidPnData); 523 Assert(!Status); 524 if (Status) 525 { 526 Log((__FUNCTION__": pfnD3DKMTInvalidateActiveVidPn failed, Status (0x%x)\n", Status)); 527 winEr = ERROR_GEN_FAILURE; 528 } 529 } 530 531 if (hAdapter) 532 { 533 D3DKMT_CLOSEADAPTER ClosaAdapterData = {0}; 534 ClosaAdapterData.hAdapter = hAdapter; 535 Status = pIf->modeData.wddm.pfnD3DKMTCloseAdapter(&ClosaAdapterData); 536 Assert(!Status); 537 } 538 539 /* ignore any prev errors and just check if resize is OK */ 540 if (!vboxDispIfValidateResize(paDisplayDevices, paDeviceModes, cDevModes)) 541 { 542 /* now try to resize in a "regular" way */ 543 /* Assign the new rectangles to displays. */ 544 for (i = 0; i < cDevModes; i++) 545 { 546 /* On Vista one must specify DM_BITSPERPEL. 547 * Note that the current mode dmBitsPerPel is already in the DEVMODE structure. 548 */ 549 paDeviceModes[i].dmFields = DM_POSITION | DM_PELSHEIGHT | DM_PELSWIDTH | DM_BITSPERPEL; 550 551 Log(("VBoxTray: ResizeDisplayDevice: pfnChangeDisplaySettingsEx %x: %dx%dx%d at %d,%d\n", 552 pIf->modeData.wddm.pfnChangeDisplaySettingsEx, 553 paDeviceModes[i].dmPelsWidth, 554 paDeviceModes[i].dmPelsHeight, 555 paDeviceModes[i].dmBitsPerPel, 556 paDeviceModes[i].dmPosition.x, 557 paDeviceModes[i].dmPosition.y)); 558 559 LONG status = pIf->modeData.wddm.pfnChangeDisplaySettingsEx((LPSTR)paDisplayDevices[i].DeviceName, 560 &paDeviceModes[i], NULL, CDS_NORESET | CDS_UPDATEREGISTRY, NULL); 561 Log(("VBoxTray: ResizeDisplayDevice: ChangeDisplaySettingsEx position status %d, err %d\n", status, GetLastError ())); 562 } 563 564 /* A second call to ChangeDisplaySettings updates the monitor. */ 565 LONG status = pIf->modeData.wddm.pfnChangeDisplaySettingsEx(NULL, NULL, NULL, 0, NULL); 566 Log(("VBoxTray: ResizeDisplayDevice: ChangeDisplaySettings update status %d\n", status)); 567 if (status == DISP_CHANGE_SUCCESSFUL) 568 { 569 winEr = NO_ERROR; 570 } 571 else if (status == DISP_CHANGE_BADMODE) 572 { 573 /* Successfully set new video mode or our driver can not set the requested mode. Stop trying. */ 574 winEr = ERROR_RETRY; 575 } 576 else 577 { 578 winEr = ERROR_GEN_FAILURE; 579 } 580 } 581 else 582 { 583 winEr = NO_ERROR; 584 } 585 586 return winEr; 587 } 588 589 DWORD VBoxDispIfResizeModes(PCVBOXDISPIF const pIf, DISPLAY_DEVICE *paDisplayDevices, DEVMODE *paDeviceModes, UINT cDevModes) 590 { 591 switch (pIf->enmMode) 592 { 593 case VBOXDISPIF_MODE_XPDM_NT4: 594 return ERROR_NOT_SUPPORTED; 595 case VBOXDISPIF_MODE_XPDM: 596 return ERROR_NOT_SUPPORTED; 597 #ifdef VBOX_WITH_WDDM 598 case VBOXDISPIF_MODE_WDDM: 599 return vboxDispIfResizeModesWDDM(pIf, paDisplayDevices, paDeviceModes, cDevModes); 600 #endif 601 default: 602 Log((__FUNCTION__": unknown mode (%d)\n", pIf->enmMode)); 603 return ERROR_INVALID_PARAMETER; 604 } 605 } 606 344 607 static DWORD vboxDispIfSwitchToXPDM_NT4(PVBOXDISPIF pIf) 345 608 { -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.h
r32622 r34130 53 53 struct 54 54 { 55 /* ChangeDisplaySettingsEx does not exist in NT. ResizeDisplayDevice uses the function. */ 56 LONG (WINAPI * pfnChangeDisplaySettingsEx)(LPCTSTR lpszDeviceName, LPDEVMODE lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam); 57 58 /* EnumDisplayDevices does not exist in NT. isVBoxDisplayDriverActive et al. are using these functions. */ 59 BOOL (WINAPI * pfnEnumDisplayDevices)(IN LPCSTR lpDevice, IN DWORD iDevNum, OUT PDISPLAY_DEVICEA lpDisplayDevice, IN DWORD dwFlags); 60 55 61 /* open adapter */ 56 62 PFND3DKMT_OPENADAPTERFROMHDC pfnD3DKMTOpenAdapterFromHdc; … … 77 83 DWORD VBoxDispIfEscape(PCVBOXDISPIF const pIf, PVBOXDISPIFESCAPE pEscape, int cbData); 78 84 DWORD VBoxDispIfResize(PCVBOXDISPIF const pIf, ULONG Id, DWORD Width, DWORD Height, DWORD BitsPerPixel); 85 DWORD VBoxDispIfResizeModes(PCVBOXDISPIF const pIf, DISPLAY_DEVICE *paDisplayDevices, DEVMODE *paDeviceModes, UINT cDevModes); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp
r34025 r34130 212 212 213 213 /* Returns TRUE to try again. */ 214 static BOOL ResizeDisplayDevice(ULONG Id, DWORD Width, DWORD Height, DWORD BitsPerPixel) 214 static BOOL ResizeDisplayDevice(ULONG Id, DWORD Width, DWORD Height, DWORD BitsPerPixel, 215 VBOXDISPLAYCONTEXT *pCtx) 215 216 { 216 217 BOOL fModeReset = (Width == 0 && Height == 0 && BitsPerPixel == 0); … … 382 383 #endif /* Log */ 383 384 385 #ifdef VBOX_WITH_WDDM 386 VBOXDISPLAY_DRIVER_TYPE enmDriverType = getVBoxDisplayDriverType (pCtx); 387 if (enmDriverType == VBOXDISPLAY_DRIVER_TYPE_WDDM) 388 { 389 /* Assign the new rectangles to displays. */ 390 for (i = 0; i < NumDevices; i++) 391 { 392 paDeviceModes[i].dmPosition.x = paRects[i].left; 393 paDeviceModes[i].dmPosition.y = paRects[i].top; 394 paDeviceModes[i].dmPelsWidth = paRects[i].right - paRects[i].left; 395 paDeviceModes[i].dmPelsHeight = paRects[i].bottom - paRects[i].top; 396 397 /* On Vista one must specify DM_BITSPERPEL. 398 * Note that the current mode dmBitsPerPel is already in the DEVMODE structure. 399 */ 400 paDeviceModes[i].dmFields = DM_POSITION | DM_PELSHEIGHT | DM_PELSWIDTH | DM_BITSPERPEL; 401 402 if ( i == Id 403 && BitsPerPixel != 0) 404 { 405 /* Change dmBitsPerPel if requested. */ 406 paDeviceModes[i].dmBitsPerPel = BitsPerPixel; 407 } 408 409 Log(("VBoxTray: ResizeDisplayDevice: pfnChangeDisplaySettingsEx %x: %dx%dx%d at %d,%d\n", 410 gCtx.pfnChangeDisplaySettingsEx, 411 paDeviceModes[i].dmPelsWidth, 412 paDeviceModes[i].dmPelsHeight, 413 paDeviceModes[i].dmBitsPerPel, 414 paDeviceModes[i].dmPosition.x, 415 paDeviceModes[i].dmPosition.y)); 416 417 } 418 419 DWORD err = VBoxDispIfResizeModes(&pCtx->pEnv->dispIf, paDisplayDevices, paDeviceModes, NumDevices); 420 if (err == NO_ERROR || err != ERROR_RETRY) 421 { 422 if (err == NO_ERROR) 423 Log(("VBoxTray: VBoxDisplayThread: (WDDM) VBoxDispIfResizeModes succeeded\n")); 424 else 425 Log(("VBoxTray: VBoxDisplayThread: (WDDM) Failure VBoxDispIfResizeModes (%d)\n", err)); 426 return FALSE; 427 } 428 429 Log(("VBoxTray: ResizeDisplayDevice: (WDDM) RETRY requested\n")); 430 return TRUE; 431 } 432 #endif 384 433 /* Without this, Windows will not ask the miniport for its 385 434 * mode table but uses an internal cache instead. … … 550 599 Log(("VBoxTray: VBoxDisplayThread: Detected W2K or later\n")); 551 600 552 #ifdef VBOX_WITH_WDDM553 if (enmDriverType == VBOXDISPLAY_DRIVER_TYPE_WDDM)554 {555 DWORD err = VBoxDispIfResize(&pCtx->pEnv->dispIf,556 displayChangeRequest.display,557 displayChangeRequest.xres,558 displayChangeRequest.yres,559 displayChangeRequest.bpp);560 if (err == NO_ERROR)561 {562 Log(("VBoxTray: VBoxDisplayThread: VBoxDispIfResize succeeded\n"));563 break;564 }565 Log(("VBoxTray: VBoxDisplayThread: VBoxDispIfResize failed err(%d)\n", err));566 }567 #endif568 601 /* W2K or later. */ 569 602 if (!ResizeDisplayDevice(displayChangeRequest.display, 570 603 displayChangeRequest.xres, 571 604 displayChangeRequest.yres, 572 displayChangeRequest.bpp 605 displayChangeRequest.bpp, 606 pCtx 573 607 )) 574 608 { -
trunk/src/VBox/Additions/WINNT/include/VBoxDisplay.h
r33530 r34130 33 33 typedef struct 34 34 { 35 ULONGId;35 DWORD Id; 36 36 DWORD Width; 37 37 DWORD Height;
Note:
See TracChangeset
for help on using the changeset viewer.