VirtualBox

Changeset 37490 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Jun 16, 2011 10:58:27 AM (13 years ago)
Author:
vboxsync
Message:

wddm: autoresize fixes

Location:
trunk/src/VBox/Additions/WINNT
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/common/VBoxVideoLog.h

    r37207 r37490  
    4444#endif
    4545
     46#define _LOGMSG_EXACT(_logger, _a)                                          \
     47    do                                                                      \
     48    {                                                                       \
     49        _logger(_a);                                                        \
     50    } while (0)
     51
    4652#define _LOGMSG(_logger, _a)                                                \
    4753    do                                                                      \
     
    6672#define LOGF_ENTER() LOGF(("ENTER"))
    6773#define LOGF_LEAVE() LOGF(("LEAVE"))
     74#define LOGREL_EXACT(_a) _LOGMSG_EXACT(Log, _a)
    6875
    6976#endif /*VBOXVIDEOLOG_H*/
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPVidModes.cpp

    r37423 r37490  
    2525#include <wchar.h>
    2626
     27#ifdef VBOX_WITH_WDDM
     28# define VBOX_WITHOUT_24BPP_MODES
     29#endif
     30
    2731/* Custom video modes which are being read from registry at driver startup. */
    2832static VIDEO_MODE_INFORMATION g_CustomVideoModes[64] = { 0 };
     
    3640/* Number of available video modes, set by VBoxMPCmnBuildVideoModesTable. */
    3741static uint32_t g_NumVideoModes = 0;
     42
     43static BOOLEAN
     44VBoxMPValidateVideoModeParamsGuest(PVBOXMP_DEVEXT pExt, uint32_t iDisplay, uint32_t xres, uint32_t yres, uint32_t bpp)
     45{
     46    switch (bpp)
     47    {
     48        case 32:
     49            break;
     50        case 24:
     51#ifdef VBOX_WITHOUT_24BPP_MODES
     52            return FALSE;
     53#else
     54            break;
     55#endif
     56        case 16:
     57            break;
     58        case 8:
     59#ifndef VBOX_WITH_8BPP_MODES
     60            return FALSE;
     61#else
     62            break;
     63#endif
     64        default:
     65            WARN(("Unexpected bpp (%d)", bpp));
     66            return FALSE;
     67    }
     68    return TRUE;
     69}
    3870
    3971/* Fills given video mode BPP related fields */
     
    161193            }
    162194
    163             VBoxFillVidModeInfo(&g_CustomVideoModes[iMode], CustomXRes, CustomYRes, CustomBPP, 0, 0);
     195            if (VBoxMPValidateVideoModeParamsGuest(pExt, iMode, CustomXRes, CustomYRes, CustomBPP))
     196            {
     197                VBoxFillVidModeInfo(&g_CustomVideoModes[iMode], CustomXRes, CustomYRes, CustomBPP, 0, 0);
     198            }
    164199        }
    165200    }
     
    271306        }
    272307
     308        if (!VBoxMPValidateVideoModeParamsGuest(pExt, iMode, 800, 600, bitsPerPixel))
     309            continue;
     310
    273311        VBoxFillVidModeInfo(&pModesTable[iMode], 800, 600, bitsPerPixel, iMode+1, 0);
    274312
     
    311349            {
    312350                /* host doesn't like this mode */
     351                continue;
     352            }
     353
     354            if (!VBoxMPValidateVideoModeParamsGuest(pExt, iDisplay, resolutionMatrix[resIndex].xRes, resolutionMatrix[resIndex].yRes, bitsPerPixel))
     355            {
     356                /* guest does not like this mode */
    313357                continue;
    314358            }
     
    389433            /* host doesn't like this mode */
    390434            break;
     435        }
     436
     437        if (!VBoxMPValidateVideoModeParamsGuest(pExt, iDisplay, xres, yres, bpp))
     438        {
     439            /* guest does not like this mode */
     440            continue;
    391441        }
    392442
     
    479529        bpp=32;
    480530    }
     531
     532    if (!VBoxMPValidateVideoModeParamsGuest(pExt, iDisplay, xres, yres, bpp))
     533        return FALSE;
    481534
    482535    /* Check if host likes this mode */
     
    767820static VBOXWDDM_VIDEOMODES_INFO g_aVBoxVideoModeInfos[VBOX_VIDEO_MAX_SCREENS] = {0};
    768821
    769 bool VBoxWddmFillMode(VIDEO_MODE_INFORMATION *pInfo, D3DDDIFORMAT enmFormat, ULONG w, ULONG h)
     822bool VBoxWddmFillMode(PVBOXMP_DEVEXT pExt, uint32_t iDisplay, VIDEO_MODE_INFORMATION *pInfo, D3DDDIFORMAT enmFormat, ULONG w, ULONG h)
    770823{
    771824    switch (enmFormat)
    772825    {
    773826        case D3DDDIFMT_A8R8G8B8:
     827            if (!VBoxMPValidateVideoModeParamsGuest(pExt, iDisplay, w, h, 32))
     828            {
     829                WARN(("unsupported mode info for format(%d)", enmFormat));
     830                return false;
     831            }
    774832            VBoxFillVidModeInfo(pInfo, w, h, 32, 0, 0);
    775833            return true;
    776834        case D3DDDIFMT_R8G8B8:
     835            if (!VBoxMPValidateVideoModeParamsGuest(pExt, iDisplay, w, h, 24))
     836            {
     837                WARN(("unsupported mode info for format(%d)", enmFormat));
     838                return false;
     839            }
    777840            VBoxFillVidModeInfo(pInfo, w, h, 24, 0, 0);
    778841            return true;
    779842        case D3DDDIFMT_R5G6B5:
     843            if (!VBoxMPValidateVideoModeParamsGuest(pExt, iDisplay, w, h, 16))
     844            {
     845                WARN(("unsupported mode info for format(%d)", enmFormat));
     846                return false;
     847            }
    780848            VBoxFillVidModeInfo(pInfo, w, h, 16, 0, 0);
    781849            return true;
    782850        case D3DDDIFMT_P8:
     851            if (!VBoxMPValidateVideoModeParamsGuest(pExt, iDisplay, w, h, 8))
     852            {
     853                WARN(("unsupported mode info for format(%d)", enmFormat));
     854                return false;
     855            }
    783856            VBoxFillVidModeInfo(pInfo, w, h, 8, 0, 0);
    784857            return true;
     
    793866
    794867static void
    795 VBoxWddmBuildResolutionTable(PVIDEO_MODE_INFORMATION pModesTable, size_t tableSize,
    796                              SIZE *pResolutions, uint32_t * pcResolutions)
     868VBoxWddmBuildResolutionTable(PVIDEO_MODE_INFORMATION pModesTable, size_t tableSize, int iPreferredMode,
     869                             SIZE *pResolutions, uint32_t * pcResolutions, int *piPreferredResolution)
    797870{
    798871    uint32_t cResolutionsArray = *pcResolutions;
    799872    uint32_t cResolutions = 0;
    800873
     874    *piPreferredResolution = -1;
     875
    801876    for (uint32_t i=0; i<tableSize; ++i)
    802877    {
    803878        PVIDEO_MODE_INFORMATION pMode = &pModesTable[i];
    804         BOOLEAN bFound = FALSE;
     879        int iResolution = -1;
    805880
    806881        for (uint32_t j=0; j<cResolutions; ++j)
     
    809884                && pResolutions[j].cy == pMode->VisScreenHeight)
    810885            {
    811                 bFound = TRUE;
     886                iResolution = j;
    812887                break;
    813888            }
    814889        }
    815890
    816         if (!bFound)
     891        if (iResolution < 0)
    817892        {
    818893            if (cResolutions == cResolutionsArray)
     
    822897            }
    823898
     899            iResolution = cResolutions;
    824900            pResolutions[cResolutions].cx = pMode->VisScreenWidth;
    825901            pResolutions[cResolutions].cy = pMode->VisScreenHeight;
    826902            ++cResolutions;
    827903        }
     904
     905        Assert(iResolution >= 0);
     906        if (i == iPreferredMode)
     907        {
     908            Assert(*piPreferredResolution == -1);
     909            *piPreferredResolution = iResolution;
     910        }
    828911    }
    829912
    830913    *pcResolutions = cResolutions;
     914    Assert(*piPreferredResolution >= 0);
     915}
     916
     917static void VBoxWddmBuildResolutionTableForModes(PVBOXWDDM_VIDEOMODES_INFO pModes)
     918{
     919    pModes->cResolutions = RT_ELEMENTS(pModes->aResolutions);
     920    VBoxWddmBuildResolutionTable(pModes->aModes, pModes->cModes, pModes->iPreferredMode,
     921            (SIZE*)((void*)pModes->aResolutions), &pModes->cResolutions, &pModes->iPreferredResolution);
     922    Assert(pModes->aResolutions[pModes->iPreferredResolution].cx == pModes->aModes[pModes->iPreferredMode].VisScreenWidth
     923            && pModes->aResolutions[pModes->iPreferredResolution].cy == pModes->aModes[pModes->iPreferredMode].VisScreenHeight);
    831924}
    832925
     
    9131006                AssertRelease(RT_ELEMENTS(pModes->aModes) > pModes->cModes); /* if not - the driver state is screwed up, @todo: better do KeBugCheckEx here */
    9141007
    915                 if (pModes->aModes[pModes->iPreferredMode].BitsPerPlane != bpp)
    916                 {
    917                     VBoxFillVidModeInfo(&pModes->aModes[pModes->cModes],
     1008                if (pModes->aModes[pModes->iPreferredMode].BitsPerPlane == bpp)
     1009                    continue;
     1010
     1011                if (!VBoxMPValidateVideoModeParamsGuest(pExt, VidPnTargetId,
     1012                        pModes->aModes[pModes->iPreferredMode].VisScreenWidth,
     1013                        pModes->aModes[pModes->iPreferredMode].VisScreenHeight,
     1014                        bpp))
     1015                    continue;
     1016
     1017                VBoxFillVidModeInfo(&pModes->aModes[pModes->cModes],
    9181018                                        pModes->aModes[pModes->iPreferredMode].VisScreenWidth,
    9191019                                        pModes->aModes[pModes->iPreferredMode].VisScreenHeight,
    9201020                                        bpp, pModes->cModes, 0);
    921                     if (VBoxMPFindVideoMode(pModes->aModes, pModes->cModes, &pModes->aModes[pModes->cModes]) < 0)
    922                     {
    923                         ++pModes->cModes;
    924                     }
     1021                if (VBoxMPFindVideoMode(pModes->aModes, pModes->cModes, &pModes->aModes[pModes->cModes]) < 0)
     1022                {
     1023                    ++pModes->cModes;
    9251024                }
    9261025            }
     
    9731072    }
    9741073
    975     pModes->cPrevModes = pModes->cModes;
    976 
    9771074    /* Build resolution table */
    978     VBoxWddmBuildResolutionTable(pModes->aModes, pModes->cModes, (SIZE*)((void*)pModes->aResolutions), &pModes->cResolutions);
     1075    VBoxWddmBuildResolutionTableForModes(pModes);
    9791076}
    9801077
     
    10231120                if (enmFormat != D3DDDIFMT_UNKNOWN)
    10241121                {
    1025                     if (VBoxWddmFillMode(&ModeInfo, enmFormat, pScreenInfo->Width, pScreenInfo->Height))
     1122                    if (VBoxWddmFillMode(pExt, pScreenInfo->Id, &ModeInfo, enmFormat, pScreenInfo->Width, pScreenInfo->Height))
    10261123                    {
    10271124                        VBoxWddmBuildVideoModesInfo(pExt, pScreenInfo->Id, pInfo, &ModeInfo, 1);
     
    10741171}
    10751172
     1173static PVBOXWDDM_VIDEOMODES_INFO vboxWddmGetVideoModesInfoInternal(PVBOXMP_DEVEXT pExt, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId)
     1174{
     1175    Assert(VidPnTargetId < (D3DDDI_VIDEO_PRESENT_TARGET_ID)VBoxCommonFromDeviceExt(pExt)->cDisplays);
     1176    if (VidPnTargetId >= (D3DDDI_VIDEO_PRESENT_TARGET_ID)VBoxCommonFromDeviceExt(pExt)->cDisplays)
     1177    {
     1178        return NULL;
     1179    }
     1180
     1181    PVBOXWDDM_VIDEOMODES_INFO pInfo = &g_aVBoxVideoModeInfos[VidPnTargetId];
     1182
     1183    if (!pInfo->cModes)
     1184    {
     1185        VBoxWddmBuildVideoModesInfo(pExt, VidPnTargetId, pInfo, NULL, 0);
     1186        Assert(pInfo->cModes);
     1187    }
     1188
     1189    return pInfo;
     1190}
     1191
     1192static VOID vboxWddmAddVideoModes(PVBOXMP_DEVEXT pExt, PVBOXWDDM_VIDEOMODES_INFO pDstInfo, PVBOXWDDM_VIDEOMODES_INFO pSrcInfo)
     1193{
     1194    for (int i = 0; i < (int)pSrcInfo->cModes; ++i)
     1195    {
     1196        int foundIdx = VBoxMPFindVideoMode(pDstInfo->aModes, pDstInfo->cModes, &pSrcInfo->aModes[i]);
     1197        if (foundIdx >= 0)
     1198            continue;
     1199
     1200        Assert(0);
     1201        pDstInfo->aModes[pDstInfo->cModes] = pSrcInfo->aModes[i];
     1202        ++pDstInfo->cModes;
     1203    }
     1204
     1205    VBoxWddmBuildResolutionTableForModes(pDstInfo);
     1206}
     1207
    10761208PVBOXWDDM_VIDEOMODES_INFO VBoxWddmGetAllVideoModesInfos(PVBOXMP_DEVEXT pExt)
    10771209{
     
    10791211    for (int i = 0; i < VBoxCommonFromDeviceExt(pExt)->cDisplays; ++i)
    10801212    {
    1081         VBoxWddmGetVideoModesInfo(pExt, (D3DDDI_VIDEO_PRESENT_TARGET_ID)i);
     1213        vboxWddmGetVideoModesInfoInternal(pExt, (D3DDDI_VIDEO_PRESENT_TARGET_ID)i);
    10821214    }
    10831215
     
    10871219PVBOXWDDM_VIDEOMODES_INFO VBoxWddmGetVideoModesInfo(PVBOXMP_DEVEXT pExt, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId)
    10881220{
    1089     Assert(VidPnTargetId < (D3DDDI_VIDEO_PRESENT_TARGET_ID)VBoxCommonFromDeviceExt(pExt)->cDisplays);
    1090     if (VidPnTargetId >= (D3DDDI_VIDEO_PRESENT_TARGET_ID)VBoxCommonFromDeviceExt(pExt)->cDisplays)
    1091     {
    1092         return NULL;
    1093     }
    1094 
    1095     PVBOXWDDM_VIDEOMODES_INFO pInfo = &g_aVBoxVideoModeInfos[VidPnTargetId];
    1096 
    1097     if (!pInfo->cModes)
    1098     {
    1099         VBoxWddmBuildVideoModesInfo(pExt, VidPnTargetId, pInfo, NULL, 0);
    1100         Assert(pInfo->cModes);
    1101     }
    1102 
    1103     return pInfo;
     1221    return &VBoxWddmGetAllVideoModesInfos(pExt)[VidPnTargetId];
    11041222}
    11051223
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPCm.cpp

    r36867 r37490  
    225225static void vboxVideoCmSessionDestroy(PVBOXVIDEOCM_SESSION pSession)
    226226{
     227    /* signal event so that user-space client can figure out the context is destroyed
     228     * in case the context destroyal is caused by Graphics device reset or miniport driver update */
     229    KeSetEvent(pSession->pUmEvent, 0, FALSE);
    227230    ObDereferenceObject(pSession->pUmEvent);
    228231    Assert(IsListEmpty(&pSession->ContextList));
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPMisc.cpp

    r37300 r37490  
    11801180static DECLCALLBACK(VOID) vboxVideoAMgrAllocSubmitCompletion(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext)
    11811181{
     1182    /* we should be called from our DPC routine */
     1183    Assert(KeGetCurrentIrql() == DISPATCH_LEVEL);
     1184
    11821185    PVBOXVDMACBUF_DR pDr = (PVBOXVDMACBUF_DR)pvContext;
    11831186    PVBOXVDMACMD pHdr = VBOXVDMACBUF_DR_TAIL(pDr, VBOXVDMACMD);
     
    12151218}
    12161219
     1220/* submits a set of chromium uhgsmi buffers to host for processing */
    12171221NTSTATUS vboxVideoAMgrCtxAllocSubmit(PVBOXMP_DEVEXT pDevExt, PVBOXVIDEOCM_ALLOC_CONTEXT pContext, UINT cBuffers, VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE *paBuffers)
    12181222{
     
    12571261            PVBOXVDMADDI_CMD pDdiCmd = VBOXVDMADDI_CMD_FROM_BUF_DR(pDr);
    12581262            vboxVdmaDdiCmdInit(pDdiCmd, 0, NULL, vboxVideoAMgrAllocSubmitCompletion, pDr);
     1263            /* mark command as submitted & invisible for the dx runtime since dx did not originate it */
    12591264            vboxVdmaDdiCmdSubmittedNotDx(pDdiCmd);
    12601265            int rc = vboxVdmaCBufDrSubmit(pDevExt, &pDevExt->u.primary.Vdma, pDr);
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPTypes.h

    r37300 r37490  
    258258    int32_t iPreferredMode;
    259259    uint32_t cModes;
    260     uint32_t cPrevModes;
    261260    VIDEO_MODE_INFORMATION aModes[VBOXWDDM_MAX_VIDEOMODES];
     261    int32_t iPreferredResolution;
    262262    uint32_t cResolutions;
    263263    D3DKMDT_2DREGION aResolutions[VBOXWDDM_MAX_VIDEOMODES];
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.h

    r36867 r37490  
    7878}
    7979
     80/* marks the command a submitted in a way that it is invisible for dx runtime,
     81 * i.e. the dx runtime won't be notified about the command completion
     82 * this is used to submit commands initiated by the driver, but not by the dx runtime */
    8083DECLINLINE(VOID) vboxVdmaDdiCmdSubmittedNotDx(PVBOXVDMADDI_CMD pCmd)
    8184{
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVidPn.cpp

    r37207 r37490  
    395395        pMonitorSourceMode->ColorCoeffDynamicRanges.FourthChannel = 0;
    396396        pMonitorSourceMode->Origin = enmOrigin;
    397         Assert(!bPreferred);
    398 //        pMonitorSourceMode->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED;
    399         pMonitorSourceMode->Preference = D3DKMDT_MP_PREFERRED;
     397        pMonitorSourceMode->Preference = bPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED;
    400398    }
    401399
     
    451449}
    452450
    453 NTSTATUS vboxVidPnPopulateTargetModeInfoFromLegacy(D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, D3DKMDT_2DREGION *pResolution)
    454 {
    455     pNewVidPnTargetModeInfo->Preference = D3DKMDT_MP_NOTPREFERRED;
     451NTSTATUS vboxVidPnPopulateTargetModeInfoFromLegacy(D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, D3DKMDT_2DREGION *pResolution, BOOLEAN fPreferred)
     452{
     453    pNewVidPnTargetModeInfo->Preference = fPreferred ? D3DKMDT_MP_PREFERRED : D3DKMDT_MP_NOTPREFERRED;
    456454    return vboxVidPnPopulateVideoSignalInfo(&pNewVidPnTargetModeInfo->VideoSignalInfo, pResolution, 60 /* ULONG VSync */);
    457455}
     
    473471    {
    474472        D3DKMDT_VIDPN_TARGET_MODE dummyMode = {0};
    475         Status = vboxVidPnPopulateTargetModeInfoFromLegacy(&dummyMode, &pData->pResolutions[i]);
     473        Status = vboxVidPnPopulateTargetModeInfoFromLegacy(&dummyMode, &pData->pResolutions[i], FALSE /* preference does not matter for now */);
    476474        Assert(Status == STATUS_SUCCESS);
    477475        if (Status == STATUS_SUCCESS)
     
    525523}
    526524
     525typedef struct VBOXVIDPNMATCHMONMODESENUM
     526{
     527    D3DKMDT_2DREGION *paResolutions;
     528    uint32_t cResolutions;
     529    BOOLEAN fMatch;
     530} VBOXVIDPNMATCHMONMODESENUM, *PVBOXVIDPNMATCHMONMODESENUM;
     531
     532static DECLCALLBACK(BOOLEAN) vboxFidPnMatchMonitorModesEnum(D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS, CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf,
     533        CONST D3DKMDT_MONITOR_SOURCE_MODE *pMonitorSMI, PVOID pContext)
     534{
     535    PVBOXVIDPNMATCHMONMODESENUM pInfo = (PVBOXVIDPNMATCHMONMODESENUM)pContext;
     536
     537    Assert(pInfo->fMatch);
     538
     539    for (UINT i = 0; i < pInfo->cResolutions; ++i)
     540    {
     541        D3DKMDT_2DREGION *pResolution = &pInfo->paResolutions[i];
     542        if (pMonitorSMI->VideoSignalInfo.ActiveSize.cx != pResolution->cx
     543                || pMonitorSMI->VideoSignalInfo.ActiveSize.cy != pResolution->cy)
     544        {
     545            pInfo->fMatch = FALSE;
     546            break;
     547        }
     548    }
     549
     550    pMonitorSMSIf->pfnReleaseModeInfo(hMonitorSMS, pMonitorSMI);
     551
     552    return pInfo->fMatch;
     553}
     554
     555/* matches the monitor mode set for the given target id with the resolution set, and sets the pfMatch to true if they match, otherwise sets it to false */
     556NTSTATUS vboxVidPnMatchMonitorModes(PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_TARGET_ID targetId,
     557        D3DKMDT_2DREGION *pResolutions, uint32_t cResolutions, BOOLEAN *pfMatch)
     558{
     559    *pfMatch = FALSE;
     560    CONST DXGK_MONITOR_INTERFACE *pMonitorInterface;
     561    NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbQueryMonitorInterface(pDevExt->u.primary.DxgkInterface.DeviceHandle, DXGK_MONITOR_INTERFACE_VERSION_V1, &pMonitorInterface);
     562    if (!NT_SUCCESS(Status))
     563    {
     564        WARN(("DxgkCbQueryMonitorInterface failed, Status (0x%x)", Status));
     565        return Status;
     566    }
     567
     568    D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS;
     569    CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf;
     570    Status = pMonitorInterface->pfnAcquireMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle,
     571                                        targetId,
     572                                        &hMonitorSMS,
     573                                        &pMonitorSMSIf);
     574    if (!NT_SUCCESS(Status))
     575    {
     576        WARN(("pfnAcquireMonitorSourceModeSet failed, Status (0x%x)", Status));
     577        if (Status == STATUS_GRAPHICS_MONITOR_NOT_CONNECTED)
     578        {
     579            /* this is ok in case we replug the monitor to pick up the monitor modes properly,
     580             * so pretend success  */
     581            *pfMatch = TRUE;
     582            Status = STATUS_SUCCESS;
     583        }
     584        return Status;
     585    }
     586
     587    VBOXVIDPNMATCHMONMODESENUM Info;
     588    Info.paResolutions = pResolutions;
     589    Info.cResolutions = cResolutions;
     590    Info.fMatch = TRUE;
     591
     592    Status = vboxVidPnEnumMonitorSourceModes(hMonitorSMS, pMonitorSMSIf, vboxFidPnMatchMonitorModesEnum, &Info);
     593    if (NT_SUCCESS(Status))
     594    {
     595        *pfMatch = Info.fMatch;
     596    }
     597
     598    NTSTATUS tmpStatus = pMonitorInterface->pfnReleaseMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle, hMonitorSMS);
     599    if (!NT_SUCCESS(tmpStatus))
     600        WARN(("pfnReleaseMonitorSourceModeSet failed tmpStatus(0x%x)", tmpStatus));
     601
     602    return Status;
     603}
     604
    527605NTSTATUS vboxVidPnCheckAddMonitorModes(PVBOXMP_DEVEXT pDevExt,
    528606        D3DDDI_VIDEO_PRESENT_TARGET_ID targetId, D3DKMDT_MONITOR_CAPABILITIES_ORIGIN enmOrigin,
    529         D3DKMDT_2DREGION *pResolutions, uint32_t cResolutions)
     607        D3DKMDT_2DREGION *pResolutions, uint32_t cResolutions, int iPreferred)
    530608{
    531609    NTSTATUS Status;
    532610    CONST DXGK_MONITOR_INTERFACE *pMonitorInterface;
    533611    Status = pDevExt->u.primary.DxgkInterface.DxgkCbQueryMonitorInterface(pDevExt->u.primary.DxgkInterface.DeviceHandle, DXGK_MONITOR_INTERFACE_VERSION_V1, &pMonitorInterface);
    534     Assert(Status == STATUS_SUCCESS);
    535     if (Status == STATUS_SUCCESS)
    536     {
    537         D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS;
    538         CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf;
    539         Status = pMonitorInterface->pfnAcquireMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle,
     612    if (!NT_SUCCESS(Status))
     613    {
     614        WARN(("DxgkCbQueryMonitorInterface failed, Status()0x%x", Status));
     615        return Status;
     616    }
     617
     618    D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS;
     619    CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf;
     620
     621    Status = pMonitorInterface->pfnAcquireMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle,
    540622                                        targetId,
    541623                                        &hMonitorSMS,
    542624                                        &pMonitorSMSIf);
     625    if (!NT_SUCCESS(Status))
     626    {
     627        WARN(("DxgkCbQueryMonitorInterface failed, Status()0x%x", Status));
     628        if (Status == STATUS_GRAPHICS_MONITOR_NOT_CONNECTED)
     629        {
     630            /* this is ok in case we replug the monitor to pick up the monitor modes properly,
     631             * so pretend success  */
     632            Status = STATUS_SUCCESS;
     633        }
     634        return Status;
     635    }
     636
     637    for (uint32_t i = 0; i < cResolutions; ++i)
     638    {
     639        D3DKMDT_2DREGION *pRes = &pResolutions[i];
     640
     641        Status = vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy(pDevExt,
     642                hMonitorSMS,
     643                pMonitorSMSIf,
     644                pRes,
     645                enmOrigin,
     646                iPreferred == i
     647                );
    543648        Assert(Status == STATUS_SUCCESS);
    544         if (Status == STATUS_SUCCESS)
    545         {
    546             for (uint32_t i = 0; i < cResolutions; ++i)
    547             {
    548                 D3DKMDT_2DREGION *pRes = &pResolutions[i];
    549 //                VBOXVIDPNCHECKMONMODESENUM ChkInfo = {0};
    550 //                ChkInfo.Region = *pRes;
    551 //                Status = vboxVidPnEnumMonitorSourceModes(hMonitorSMS, pMonitorSMSIf,
    552 //                        vboxFidPnCheckMonitorModesEnum, &ChkInfo);
    553 //                Assert(Status == STATUS_SUCCESS);
    554 //                if (Status == STATUS_SUCCESS)
    555 //                {
    556 //                    if (!ChkInfo.pMonitorSMI)
    557 //                    {
    558                         Status = vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy(pDevExt,
    559                                 hMonitorSMS,
    560                                 pMonitorSMSIf,
    561                                 pRes,
    562                                 enmOrigin,
    563                                 FALSE
    564                                 );
    565                         Assert(Status == STATUS_SUCCESS);
    566                         if (Status != STATUS_SUCCESS)
    567                         {
    568                             LOGREL(("vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy failed Status(0x%x)", Status));
    569                             break;
    570                         }
    571 //                    }
    572 //                    else
    573 //                    {
    574 //                        pMonitorSMSIf->pfnReleaseModeInfo(hMonitorSMS, ChkInfo.pMonitorSMI);
    575 //                    }
    576 //                }
    577 //                else
    578 //                {
    579 //                    LOGREL(("vboxVidPnEnumMonitorSourceModes failed Status(0x%x)", Status));
    580 //                    break;
    581 //                }
    582             }
    583             NTSTATUS tmpStatus = pMonitorInterface->pfnReleaseMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle, hMonitorSMS);
    584             Assert(tmpStatus == STATUS_SUCCESS);
    585             if (tmpStatus != STATUS_SUCCESS)
    586                 LOGREL(("pfnReleaseMonitorSourceModeSet failed tmpStatus(0x%x)", tmpStatus));
    587         }
    588         else
    589             LOGREL(("pfnAcquireMonitorSourceModeSet failed Status(0x%x)", Status));
    590     }
    591     else
    592         LOGREL(("DxgkCbQueryMonitorInterface failed Status(0x%x)", Status));
     649        if (Status != STATUS_SUCCESS)
     650        {
     651            LOGREL(("vboxVidPnCreatePopulateMonitorSourceModeInfoFromLegacy failed Status(0x%x)", Status));
     652            break;
     653        }
     654    }
     655
     656    NTSTATUS tmpStatus = pMonitorInterface->pfnReleaseMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle, hMonitorSMS);
     657    if (!NT_SUCCESS(tmpStatus))
     658    {
     659        WARN(("pfnReleaseMonitorSourceModeSet failed tmpStatus(0x%x)", tmpStatus));
     660    }
    593661
    594662    return Status;
    595663}
    596664
    597 static NTSTATUS vboxVidPnPathAdd(D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
     665NTSTATUS vboxVidPnPathAdd(D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
    598666        const D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, const D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId)
    599667{
     
    704772            if (NT_SUCCESS(Status))
    705773            {
    706 
    707774                /* success */
    708775                continue;
     
    766833        VIDEO_MODE_INFORMATION *pModeToPin,
    767834        D3DKMDT_VIDEO_PRESENT_TARGET_MODE_ID *pModeIdToPin,
     835        BOOLEAN fSetPreferred,
    768836        BOOLEAN fDoPin
    769837        )
     
    798866        }
    799867
    800         Status = vboxVidPnPopulateTargetModeInfoFromLegacy(pNewVidPnTargetModeInfo, pResolution);
     868        BOOLEAN fIsPinMode = pModeToPin && pModeToPin->VisScreenWidth == pResolution->cx
     869                && pModeToPin->VisScreenHeight == pResolution->cy;
     870
     871        Status = vboxVidPnPopulateTargetModeInfoFromLegacy(pNewVidPnTargetModeInfo, pResolution, fIsPinMode && fSetPreferred);
    801872        if (NT_SUCCESS(Status))
    802873        {
    803             if (pModeToPin && pModeToPin->VisScreenWidth == pResolution->cx
    804                     && pModeToPin->VisScreenHeight == pResolution->cy)
     874            if (fIsPinMode)
    805875            {
    806876                targetModeId = pNewVidPnTargetModeInfo->Id;
     
    875945    NTSTATUS Status;
    876946
     947#if 0
    877948    Status = vboxVidPnPathAdd(hVidPn, pVidPnInterface, VidPnSourceId, VidPnTargetId);
    878949    if (!NT_SUCCESS(Status))
     
    881952        return Status;
    882953    }
     954#endif
    883955
    884956    VIDEO_MODE_INFORMATION *pModeToPin = iModeToPin >= 0 ? &pModes[iModeToPin] : NULL;
    885     Status = vboxVidPnCreatePopulateTargetModeInfoFromLegacy(hVidPn, pVidPnInterface, VidPnTargetId, pResolutions, cResolutions, pModeToPin, NULL, TRUE);
     957    Status = vboxVidPnCreatePopulateTargetModeInfoFromLegacy(hVidPn, pVidPnInterface, VidPnTargetId, pResolutions, cResolutions, pModeToPin, NULL, TRUE, TRUE);
    886958    if (!NT_SUCCESS(Status))
    887959    {
     
    11621234    const DXGK_VIDPNTARGETMODESET_INTERFACE *pNewVidPnTargetModeSetInterface;
    11631235
     1236    if (VidPnSourceId != VidPnTargetId || pCbContext->apPathInfos[VidPnTargetId].enmState != VBOXVIDPNPATHITEM_STATE_PRESENT)
     1237    {
     1238        return STATUS_SUCCESS;
     1239    }
     1240
    11641241    D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
    11651242    const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
     
    12001277        {
    12011278            Assert(hNewVidPnTargetModeSet);
    1202             if (pCbContext->apPathInfos[VidPnSourceId].enmState == VBOXVIDPNPATHITEM_STATE_PRESENT)
     1279            if (VidPnSourceId == VidPnTargetId && pCbContext->apPathInfos[VidPnTargetId].enmState == VBOXVIDPNPATHITEM_STATE_PRESENT)
    12031280            {
    12041281                Assert(VidPnSourceId == VidPnTargetId);
     
    12211298                    if (NT_SUCCESS(Status))
    12221299                    {
    1223                         Status = vboxVidPnPopulateTargetModeInfoFromLegacy(pNewVidPnTargetModeInfo, pResolution);
     1300                        Status = vboxVidPnPopulateTargetModeInfoFromLegacy(pNewVidPnTargetModeInfo, pResolution, i == pInfo->iPreferredResolution);
    12241301                        Assert(Status == STATUS_SUCCESS);
    12251302                        if (NT_SUCCESS(Status))
     
    12681345        if (!NT_SUCCESS(Status))
    12691346        {
    1270             AssertFailed();
     1347            WARN(("\n\n!!!!!!!\n\n pfnAssignTargetModeSet failed, Status(0x%x)", Status));
    12711348            tmpStatus = pVidPnInterface->pfnReleaseTargetModeSet(hVidPn, hNewVidPnTargetModeSet);
    12721349            Assert(tmpStatus == STATUS_SUCCESS);
     
    12861363    D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet = NULL;
    12871364    const DXGK_VIDPNSOURCEMODESET_INTERFACE *pNewVidPnSourceModeSetInterface;
     1365
     1366    if (VidPnSourceId != VidPnTargetId || pCbContext->apPathInfos[VidPnSourceId].enmState != VBOXVIDPNPATHITEM_STATE_PRESENT)
     1367    {
     1368        return STATUS_SUCCESS;
     1369    }
    12881370
    12891371    D3DKMDT_HVIDPNTARGETMODESET hCurVidPnTargetModeSet;
     
    13251407        {
    13261408            Assert(hNewVidPnSourceModeSet);
    1327             if (pCbContext->apPathInfos[VidPnSourceId].enmState == VBOXVIDPNPATHITEM_STATE_PRESENT)
     1409            if (VidPnSourceId == VidPnTargetId && pCbContext->apPathInfos[VidPnSourceId].enmState == VBOXVIDPNPATHITEM_STATE_PRESENT)
    13281410            {
    13291411                Assert(VidPnSourceId == VidPnTargetId);
     
    13921474        if (!NT_SUCCESS(Status))
    13931475        {
    1394             AssertFailed();
     1476            WARN(("\n\n!!!!!!!\n\n pfnAssignSourceModeSet failed, Status(0x%x)", Status));
    13951477            tmpStatus = pVidPnInterface->pfnReleaseSourceModeSet(hVidPn, hNewVidPnSourceModeSet);
    13961478            Assert(tmpStatus == STATUS_SUCCESS);
     
    24232505void vboxVidPnDumpCopyProtectoin(const char *pPrefix, const D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION *pCopyProtection, const char *pSuffix)
    24242506{
    2425     LOGREL(("%sType(%s), TODO%s", pPrefix,
     2507    LOGREL_EXACT(("%sType(%s), TODO%s", pPrefix,
    24262508            vboxVidPnDumpStrCopyProtectionType(pCopyProtection->CopyProtectionType), pSuffix));
    24272509}
     
    24302512void vboxVidPnDumpPathTransformation(const D3DKMDT_VIDPN_PRESENT_PATH_TRANSFORMATION *pContentTransformation)
    24312513{
    2432     LOGREL(("  --Transformation: Scaling(%s), ScalingSupport(%d), Rotation(%s), RotationSupport(%d)--",
     2514    LOGREL_EXACT(("  --Transformation: Scaling(%s), ScalingSupport(%d), Rotation(%s), RotationSupport(%d)--",
    24332515            vboxVidPnDumpStrScaling(pContentTransformation->Scaling), pContentTransformation->ScalingSupport,
    24342516            vboxVidPnDumpStrRotation(pContentTransformation->Rotation), pContentTransformation->RotationSupport));
     
    24372519void vboxVidPnDumpRegion(const char *pPrefix, const D3DKMDT_2DREGION *pRegion, const char *pSuffix)
    24382520{
    2439     LOGREL(("%s%dX%d%s", pPrefix, pRegion->cx, pRegion->cy, pSuffix));
     2521    LOGREL_EXACT(("%s%dX%d%s", pPrefix, pRegion->cx, pRegion->cy, pSuffix));
    24402522}
    24412523
    24422524void vboxVidPnDumpRational(const char *pPrefix, const D3DDDI_RATIONAL *pRational, const char *pSuffix)
    24432525{
    2444     LOGREL(("%s%d/%d=%d%s", pPrefix, pRational->Numerator, pRational->Denominator, pRational->Numerator/pRational->Denominator, pSuffix));
     2526    LOGREL_EXACT(("%s%d/%d=%d%s", pPrefix, pRational->Numerator, pRational->Denominator, pRational->Numerator/pRational->Denominator, pSuffix));
    24452527}
    24462528
    24472529void vboxVidPnDumpRanges(const char *pPrefix, const D3DKMDT_COLOR_COEFF_DYNAMIC_RANGES *pDynamicRanges, const char *pSuffix)
    24482530{
    2449     LOGREL(("%sFirstChannel(%d), SecondChannel(%d), ThirdChannel(%d), FourthChannel(%d)%s", pPrefix,
     2531    LOGREL_EXACT(("%sFirstChannel(%d), SecondChannel(%d), ThirdChannel(%d), FourthChannel(%d)%s", pPrefix,
    24502532            pDynamicRanges->FirstChannel,
    24512533            pDynamicRanges->SecondChannel,
     
    24572539void vboxVidPnDumpGammaRamp(const char *pPrefix, const D3DKMDT_GAMMA_RAMP *pGammaRamp, const char *pSuffix)
    24582540{
    2459     LOGREL(("%sType(%s), DataSize(%d), TODO: dump the rest%s", pPrefix,
     2541    LOGREL_EXACT(("%sType(%s), DataSize(%d), TODO: dump the rest%s", pPrefix,
    24602542            vboxVidPnDumpStrGammaRampType(pGammaRamp->Type), pGammaRamp->DataSize,
    24612543            pSuffix));
     
    24642546void vboxVidPnDumpSourceMode(const char *pPrefix, const D3DKMDT_VIDPN_SOURCE_MODE* pVidPnSourceModeInfo, const char *pSuffix)
    24652547{
    2466     LOGREL(("%sType(%s), ", pPrefix, vboxVidPnDumpStrSourceModeType(pVidPnSourceModeInfo->Type)));
     2548    LOGREL_EXACT(("%sType(%s), ", pPrefix, vboxVidPnDumpStrSourceModeType(pVidPnSourceModeInfo->Type)));
    24672549    vboxVidPnDumpRegion("surf(", &pVidPnSourceModeInfo->Format.Graphics.PrimSurfSize, "), ");
    24682550    vboxVidPnDumpRegion("vis(", &pVidPnSourceModeInfo->Format.Graphics.VisibleRegionSize, "), ");
    2469     LOGREL(("stride(%d), ", pVidPnSourceModeInfo->Format.Graphics.Stride));
    2470     LOGREL(("format(%s), ", vboxVidPnDumpStrPixFormat(pVidPnSourceModeInfo->Format.Graphics.PixelFormat)));
    2471     LOGREL(("clrBasis(%s), ", vboxVidPnDumpStrColorBasis(pVidPnSourceModeInfo->Format.Graphics.ColorBasis)));
    2472     LOGREL(("pvam(%s)%s", vboxVidPnDumpStrPvam(pVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode), pSuffix));
     2551    LOGREL_EXACT(("stride(%d), ", pVidPnSourceModeInfo->Format.Graphics.Stride));
     2552    LOGREL_EXACT(("format(%s), ", vboxVidPnDumpStrPixFormat(pVidPnSourceModeInfo->Format.Graphics.PixelFormat)));
     2553    LOGREL_EXACT(("clrBasis(%s), ", vboxVidPnDumpStrColorBasis(pVidPnSourceModeInfo->Format.Graphics.ColorBasis)));
     2554    LOGREL_EXACT(("pvam(%s)%s", vboxVidPnDumpStrPvam(pVidPnSourceModeInfo->Format.Graphics.PixelValueAccessMode), pSuffix));
    24732555}
    24742556
    24752557void vboxVidPnDumpSignalInfo(const char *pPrefix, const D3DKMDT_VIDEO_SIGNAL_INFO *pVideoSignalInfo, const char *pSuffix)
    24762558{
    2477     LOGREL(("%sVStd(%s), ", pPrefix, vboxVidPnDumpStrSignalStandard(pVideoSignalInfo->VideoStandard)));
     2559    LOGREL_EXACT(("%sVStd(%s), ", pPrefix, vboxVidPnDumpStrSignalStandard(pVideoSignalInfo->VideoStandard)));
    24782560    vboxVidPnDumpRegion("totSize(", &pVideoSignalInfo->TotalSize, "), ");
    24792561    vboxVidPnDumpRegion("activeSize(", &pVideoSignalInfo->ActiveSize, "), ");
    24802562    vboxVidPnDumpRational("VSynch(", &pVideoSignalInfo->VSyncFreq, "), ");
    2481     LOGREL(("PixelRate(%d), ScanLineOrdering(%s)%s", pVideoSignalInfo->PixelRate, vboxVidPnDumpStrScanLineOrdering(pVideoSignalInfo->ScanLineOrdering), pSuffix));
     2563    LOGREL_EXACT(("PixelRate(%d), ScanLineOrdering(%s)%s", pVideoSignalInfo->PixelRate, vboxVidPnDumpStrScanLineOrdering(pVideoSignalInfo->ScanLineOrdering), pSuffix));
    24822564}
    24832565
    24842566void vboxVidPnDumpTargetMode(const char *pPrefix, const D3DKMDT_VIDPN_TARGET_MODE* CONST  pVidPnTargetModeInfo, const char *pSuffix)
    24852567{
    2486     LOGREL(("%s", pPrefix));
     2568    LOGREL_EXACT(("%s", pPrefix));
    24872569    vboxVidPnDumpSignalInfo("VSI: ", &pVidPnTargetModeInfo->VideoSignalInfo, ", ");
    2488     LOGREL(("Preference(%s)%s", vboxVidPnDumpStrModePreference(pVidPnTargetModeInfo->Preference), pSuffix));
     2570    LOGREL_EXACT(("Preference(%s)%s", vboxVidPnDumpStrModePreference(pVidPnTargetModeInfo->Preference), pSuffix));
    24892571}
    24902572
     
    25122594        else if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
    25132595        {
    2514             LOGREL(("Source NOT Pinned"));
     2596            LOGREL_EXACT(("Source NOT Pinned\n"));
    25152597        }
    25162598        else
    25172599        {
    2518             LOGREL(("ERROR getting piined Source Mode(0x%x)", Status));
     2600            LOGREL_EXACT(("ERROR getting piined Source Mode(0x%x)\n", Status));
    25192601        }
    25202602        pVidPnInterface->pfnReleaseSourceModeSet(hVidPn, hCurVidPnSourceModeSet);
     
    25222604    else
    25232605    {
    2524         LOGREL(("ERROR getting SourceModeSet(0x%x)", Status));
    2525     }
    2526 }
    2527 
    2528 
    2529 static DECLCALLBACK(BOOLEAN) vboxVidPnDumpSourceModeSetEnum(D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
     2606        LOGREL_EXACT(("ERROR getting SourceModeSet(0x%x)\n", Status));
     2607    }
     2608}
     2609
     2610
     2611DECLCALLBACK(BOOLEAN) vboxVidPnDumpSourceModeSetEnum(D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
    25302612        const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext)
    25312613{
     
    25362618void vboxVidPnDumpSourceModeSet(PVBOXMP_DEVEXT pDevExt, const D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
    25372619{
    2538     LOGREL(("  >>>+++SourceMode Set for Source(%d)+++", VidPnSourceId));
     2620    LOGREL_EXACT(("  >>>+++SourceMode Set for Source(%d)+++\n", VidPnSourceId));
    25392621    D3DKMDT_HVIDPNSOURCEMODESET hCurVidPnSourceModeSet;
    25402622    const DXGK_VIDPNSOURCEMODESET_INTERFACE *pCurVidPnSourceModeSetInterface;
     
    25532635        if (Status != STATUS_SUCCESS)
    25542636        {
    2555             LOGREL(("ERROR enumerating Source Modes(0x%x)", Status));
     2637            LOGREL_EXACT(("ERROR enumerating Source Modes(0x%x)\n", Status));
    25562638        }
    25572639        pVidPnInterface->pfnReleaseSourceModeSet(hVidPn, hCurVidPnSourceModeSet);
     
    25592641    else
    25602642    {
    2561         LOGREL(("ERROR getting SourceModeSet for Source(%d), Status(0x%x)", VidPnSourceId, Status));
    2562     }
    2563 
    2564     LOGREL(("  <<<+++End Of SourceMode Set for Source(%d)+++", VidPnSourceId));
     2643        LOGREL_EXACT(("ERROR getting SourceModeSet for Source(%d), Status(0x%x)\n", VidPnSourceId, Status));
     2644    }
     2645
     2646    LOGREL_EXACT(("  <<<+++End Of SourceMode Set for Source(%d)+++", VidPnSourceId));
    25652647}
    25662648
     
    25742656void vboxVidPnDumpTargetModeSet(PVBOXMP_DEVEXT pDevExt, const D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId)
    25752657{
    2576     LOGREL(("  >>>---TargetMode Set for Target(%d)---", VidPnTargetId));
     2658    LOGREL_EXACT(("  >>>---TargetMode Set for Target(%d)---\n", VidPnTargetId));
    25772659    D3DKMDT_HVIDPNTARGETMODESET hCurVidPnTargetModeSet;
    25782660    const DXGK_VIDPNTARGETMODESET_INTERFACE *pCurVidPnTargetModeSetInterface;
     
    25912673        if (Status != STATUS_SUCCESS)
    25922674        {
    2593             LOGREL(("ERROR enumerating Target Modes(0x%x)", Status));
     2675            LOGREL_EXACT(("ERROR enumerating Target Modes(0x%x)\n", Status));
    25942676        }
    25952677        pVidPnInterface->pfnReleaseTargetModeSet(hVidPn, hCurVidPnTargetModeSet);
     
    25972679    else
    25982680    {
    2599         LOGREL(("ERROR getting TargetModeSet for Target(%d), Status(0x%x)", VidPnTargetId, Status));
    2600     }
    2601 
    2602     LOGREL(("  <<<---End Of TargetMode Set for Target(%d)---", VidPnTargetId));
     2681        LOGREL_EXACT(("ERROR getting TargetModeSet for Target(%d), Status(0x%x)\n", VidPnTargetId, Status));
     2682    }
     2683
     2684    LOGREL_EXACT(("  <<<---End Of TargetMode Set for Target(%d)---", VidPnTargetId));
    26032685}
    26042686
     
    26272709        else if (Status == STATUS_GRAPHICS_MODE_NOT_PINNED)
    26282710        {
    2629             LOGREL(("Target NOT Pinned"));
     2711            LOGREL_EXACT(("Target NOT Pinned\n"));
    26302712        }
    26312713        else
    26322714        {
    2633             LOGREL(("ERROR getting piined Target Mode(0x%x)", Status));
     2715            LOGREL_EXACT(("ERROR getting piined Target Mode(0x%x)\n", Status));
    26342716        }
    26352717        pVidPnInterface->pfnReleaseTargetModeSet(hVidPn, hCurVidPnTargetModeSet);
     
    26372719    else
    26382720    {
    2639         LOGREL(("ERROR getting TargetModeSet(0x%x)", Status));
     2721        LOGREL_EXACT(("ERROR getting TargetModeSet(0x%x)\n", Status));
    26402722    }
    26412723}
     
    26432725void vboxVidPnDumpCofuncModalityArg(const char *pPrefix, CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* CONST  pEnumCofuncModalityArg, const char *pSuffix)
    26442726{
    2645     LOGREL(("%sPivotType(%s), SourceId(0x%x), TargetId(0x%x),%s", pPrefix, vboxVidPnDumpStrCFMPivotType(pEnumCofuncModalityArg->EnumPivotType),
     2727    LOGREL_EXACT(("%sPivotType(%s), SourceId(0x%x), TargetId(0x%x),%s", pPrefix, vboxVidPnDumpStrCFMPivotType(pEnumCofuncModalityArg->EnumPivotType),
    26462728            pEnumCofuncModalityArg->EnumPivot.VidPnSourceId, pEnumCofuncModalityArg->EnumPivot.VidPnTargetId, pSuffix));
    26472729}
     
    26492731void vboxVidPnDumpPath(const D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, const D3DKMDT_VIDPN_PRESENT_PATH *pVidPnPresentPathInfo)
    26502732{
    2651     LOGREL((" >>**** Start Dump VidPn Path ****>>"));
    2652     LOGREL(("VidPnSourceId(%d),  VidPnTargetId(%d)",
     2733    LOGREL_EXACT((" >>**** Start Dump VidPn Path ****>>\n"));
     2734    LOGREL_EXACT(("VidPnSourceId(%d),  VidPnTargetId(%d)\n",
    26532735            pVidPnPresentPathInfo->VidPnSourceId, pVidPnPresentPathInfo->VidPnTargetId));
    26542736
     
    26582740    vboxVidPnDumpPathTransformation(&pVidPnPresentPathInfo->ContentTransformation);
    26592741
    2660     LOGREL(("Importance(%s), TargetColorBasis(%s), Content(%s), ",
     2742    LOGREL_EXACT(("Importance(%s), TargetColorBasis(%s), Content(%s), ",
    26612743            vboxVidPnDumpStrImportance(pVidPnPresentPathInfo->ImportanceOrdinal),
    26622744            vboxVidPnDumpStrColorBasis(pVidPnPresentPathInfo->VidPnTargetColorBasis),
     
    26682750    vboxVidPnDumpGammaRamp("GammaRamp: ", &pVidPnPresentPathInfo->GammaRamp, "\n");
    26692751
    2670     LOGREL((" <<**** Stop Dump VidPn Path ****<<"));
     2752    LOGREL_EXACT((" <<**** Stop Dump VidPn Path ****<<"));
    26712753}
    26722754
     
    26892771void vboxVidPnDumpVidPn(const char * pPrefix, PVBOXMP_DEVEXT pDevExt, D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, const char * pSuffix)
    26902772{
    2691     LOGREL(("%s", pPrefix));
     2773    LOGREL_EXACT(("%s", pPrefix));
    26922774
    26932775    VBOXVIDPNDUMPPATHENUM CbData;
     
    27112793    }
    27122794
    2713     LOGREL(("%s", pSuffix));
    2714 }
     2795    LOGREL_EXACT(("%s", pSuffix));
     2796}
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVidPn.h

    r37207 r37490  
    139139NTSTATUS vboxVidPnCheckAddMonitorModes(PVBOXMP_DEVEXT pDevExt,
    140140        D3DDDI_VIDEO_PRESENT_TARGET_ID targetId, D3DKMDT_MONITOR_CAPABILITIES_ORIGIN enmOrigin,
    141         D3DKMDT_2DREGION *pResolutions, uint32_t cResolutions);
     141        D3DKMDT_2DREGION *pResolutions, uint32_t cResolutions, int iPreferred);
     142
     143NTSTATUS vboxVidPnMatchMonitorModes(PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_TARGET_ID targetId,
     144        D3DKMDT_2DREGION *pResolutions, uint32_t cResolutions, BOOLEAN *pfMatch);
    142145
    143146NTSTATUS vboxVidPnCofuncModalityForPath(PVBOXVIDPNCOFUNCMODALITY pCbContext, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId);
     
    146149                                    BOOLEAN fBreakOnDisabled, UINT cItems, PVBOXVIDPNPATHITEM paItems, BOOLEAN *pfDisabledFound);
    147150
     151NTSTATUS vboxVidPnPathAdd(D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
     152        const D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, const D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId);
     153
    148154void vboxVidPnDumpVidPn(const char * pPrefix, PVBOXMP_DEVEXT pDevExt, D3DKMDT_HVIDPN hVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface, const char * pSuffix);
    149155void vboxVidPnDumpCofuncModalityArg(const char *pPrefix, CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* CONST  pEnumCofuncModalityArg, const char *pSuffix);
     156DECLCALLBACK(BOOLEAN) vboxVidPnDumpSourceModeSetEnum(D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
     157        const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext);
     158DECLCALLBACK(BOOLEAN) vboxVidPnDumpTargetModeSetEnum(D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
     159        const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext);
     160
    150161#endif /* #ifndef ___VBoxMPVidPn_h___ */
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp

    r37300 r37490  
    9191}
    9292
    93 //VBOXVIDEOOFFSET vboxWddmVRAMAddressToOffset(PVBOXMP_DEVEXT pDevExt, PHYSICAL_ADDRESS phAddress)
    94 //{
    95 //    Assert(phAddress.QuadPart >= VBE_DISPI_LFB_PHYSICAL_ADDRESS);
    96 //    if (phAddress.QuadPart < VBE_DISPI_LFB_PHYSICAL_ADDRESS)
    97 //        return VBOXVIDEOOFFSET_VOID;
    98 //
    99 //    VBOXVIDEOOFFSET off = phAddress.QuadPart - VBE_DISPI_LFB_PHYSICAL_ADDRESS;
    100 //    Assert(off < pDevExt->u.primary.cbVRAM);
    101 //    if (off >= pDevExt->u.primary.cbVRAM)
    102 //        return VBOXVIDEOOFFSET_VOID;
    103 //
    104 //    return off;
    105 //}
    106 
    10793VBOXVIDEOOFFSET vboxWddmValidatePrimary(PVBOXWDDM_ALLOCATION pAllocation)
    10894{
     
    330316        return VBOXWDDM_HGSMICMD_TYPE_CTL;
    331317    return VBOXWDDM_HGSMICMD_TYPE_UNDEFINED;
     318}
     319
     320static NTSTATUS vboxWddmChildStatusReportPerform(PVBOXMP_DEVEXT pDevExt, PVBOXVDMA_CHILD_STATUS pChildStatus, D3DDDI_VIDEO_PRESENT_TARGET_ID iChild)
     321{
     322    DXGK_CHILD_STATUS DdiChildStatus;
     323    if (pChildStatus->fFlags & VBOXVDMA_CHILD_STATUS_F_DISCONNECTED)
     324    {
     325        /* report disconnected */
     326        memset(&DdiChildStatus, 0, sizeof (DdiChildStatus));
     327        DdiChildStatus.Type = StatusConnection;
     328        if (iChild != D3DDDI_ID_UNINITIALIZED)
     329        {
     330            Assert(iChild < UINT32_MAX/2);
     331            Assert(iChild < (UINT)VBoxCommonFromDeviceExt(pDevExt)->cDisplays);
     332            DdiChildStatus.ChildUid = iChild;
     333        }
     334        else
     335        {
     336            Assert(pChildStatus->iChild < UINT32_MAX/2);
     337            Assert(pChildStatus->iChild < (UINT)VBoxCommonFromDeviceExt(pDevExt)->cDisplays);
     338            DdiChildStatus.ChildUid = pChildStatus->iChild;
     339        }
     340        DdiChildStatus.HotPlug.Connected = FALSE;
     341        NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbIndicateChildStatus(pDevExt->u.primary.DxgkInterface.DeviceHandle, &DdiChildStatus);
     342        if (!NT_SUCCESS(Status))
     343        {
     344            WARN(("DxgkCbIndicateChildStatus failed with Status (0x%x)", Status));
     345            return Status;
     346        }
     347    }
     348
     349    if (pChildStatus->fFlags & VBOXVDMA_CHILD_STATUS_F_CONNECTED)
     350    {
     351        /* report disconnected */
     352        memset(&DdiChildStatus, 0, sizeof (DdiChildStatus));
     353        DdiChildStatus.Type = StatusConnection;
     354        if (iChild != D3DDDI_ID_UNINITIALIZED)
     355        {
     356            Assert(iChild < UINT32_MAX/2);
     357            Assert(iChild < (UINT)VBoxCommonFromDeviceExt(pDevExt)->cDisplays);
     358            DdiChildStatus.ChildUid = iChild;
     359        }
     360        else
     361        {
     362            Assert(pChildStatus->iChild < UINT32_MAX/2);
     363            Assert(pChildStatus->iChild < (UINT)VBoxCommonFromDeviceExt(pDevExt)->cDisplays);
     364            DdiChildStatus.ChildUid = pChildStatus->iChild;
     365        }
     366        DdiChildStatus.HotPlug.Connected = TRUE;
     367        NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbIndicateChildStatus(pDevExt->u.primary.DxgkInterface.DeviceHandle, &DdiChildStatus);
     368        if (!NT_SUCCESS(Status))
     369        {
     370            WARN(("DxgkCbIndicateChildStatus failed with Status (0x%x)", Status));
     371            return Status;
     372        }
     373    }
     374
     375    if (pChildStatus->fFlags & VBOXVDMA_CHILD_STATUS_F_ROTATED)
     376    {
     377        /* report disconnected */
     378        memset(&DdiChildStatus, 0, sizeof (DdiChildStatus));
     379        DdiChildStatus.Type = StatusRotation;
     380        if (iChild != D3DDDI_ID_UNINITIALIZED)
     381        {
     382            Assert(iChild < UINT32_MAX/2);
     383            Assert(iChild < (UINT)VBoxCommonFromDeviceExt(pDevExt)->cDisplays);
     384            DdiChildStatus.ChildUid = iChild;
     385        }
     386        else
     387        {
     388            Assert(pChildStatus->iChild < UINT32_MAX/2);
     389            Assert(pChildStatus->iChild < (UINT)VBoxCommonFromDeviceExt(pDevExt)->cDisplays);
     390            DdiChildStatus.ChildUid = pChildStatus->iChild;
     391        }
     392        DdiChildStatus.Rotation.Angle = pChildStatus->u8RotationAngle;
     393        NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbIndicateChildStatus(pDevExt->u.primary.DxgkInterface.DeviceHandle, &DdiChildStatus);
     394        if (!NT_SUCCESS(Status))
     395        {
     396            WARN(("DxgkCbIndicateChildStatus failed with Status (0x%x)", Status));
     397            return Status;
     398        }
     399    }
     400
     401    return STATUS_SUCCESS;
     402}
     403
     404typedef struct VBOXWDDMCHILDSTATUSCB
     405{
     406    PVBOXVDMACBUF_DR pDr;
     407    PKEVENT pEvent;
     408} VBOXWDDMCHILDSTATUSCB, *PVBOXWDDMCHILDSTATUSCB;
     409
     410static DECLCALLBACK(VOID) vboxWddmChildStatusReportCompletion(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext)
     411{
     412    /* we should be called from our DPC routine */
     413    Assert(KeGetCurrentIrql() == DISPATCH_LEVEL);
     414
     415    PVBOXWDDMCHILDSTATUSCB pCtx = (PVBOXWDDMCHILDSTATUSCB)pvContext;
     416    PVBOXVDMACBUF_DR pDr = pCtx->pDr;
     417    PVBOXVDMACMD pHdr = VBOXVDMACBUF_DR_TAIL(pDr, VBOXVDMACMD);
     418    VBOXVDMACMD_CHILD_STATUS_IRQ *pBody = VBOXVDMACMD_BODY(pHdr, VBOXVDMACMD_CHILD_STATUS_IRQ);
     419
     420    for (UINT i = 0; i < pBody->cInfos; ++i)
     421    {
     422        PVBOXVDMA_CHILD_STATUS pInfo = &pBody->aInfos[i];
     423        if (pBody->fFlags & VBOXVDMACMD_CHILD_STATUS_IRQ_F_APPLY_TO_ALL)
     424        {
     425            for (D3DDDI_VIDEO_PRESENT_TARGET_ID iChild = 0; iChild < (UINT)VBoxCommonFromDeviceExt(pDevExt)->cDisplays; ++iChild)
     426            {
     427                NTSTATUS Status = vboxWddmChildStatusReportPerform(pDevExt, pInfo, iChild);
     428                if (!NT_SUCCESS(Status))
     429                {
     430                    WARN(("vboxWddmChildStatusReportPerform failed with Status (0x%x)", Status));
     431                    break;
     432                }
     433            }
     434        }
     435        else
     436        {
     437            NTSTATUS Status = vboxWddmChildStatusReportPerform(pDevExt, pInfo, D3DDDI_ID_UNINITIALIZED);
     438            if (!NT_SUCCESS(Status))
     439            {
     440                WARN(("vboxWddmChildStatusReportPerform failed with Status (0x%x)", Status));
     441                break;
     442            }
     443        }
     444    }
     445
     446    vboxVdmaCBufDrFree(&pDevExt->u.primary.Vdma, pDr);
     447
     448    if (pCtx->pEvent)
     449    {
     450        KeSetEvent(pCtx->pEvent, 0, FALSE);
     451    }
     452}
     453
     454static NTSTATUS vboxWddmChildStatusReportReconnected(PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_TARGET_ID idTarget)
     455{
     456    NTSTATUS Status = STATUS_UNSUCCESSFUL;
     457    UINT cbCmd = VBOXVDMACMD_SIZE_FROMBODYSIZE(sizeof (VBOXVDMACMD_CHILD_STATUS_IRQ));
     458
     459    PVBOXVDMACBUF_DR pDr = vboxVdmaCBufDrCreate(&pDevExt->u.primary.Vdma, cbCmd);
     460    if (pDr)
     461    {
     462        // vboxVdmaCBufDrCreate zero initializes the pDr
     463        /* the command data follows the descriptor */
     464        pDr->fFlags = VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR;
     465        pDr->cbBuf = cbCmd;
     466        pDr->rc = VERR_NOT_IMPLEMENTED;
     467
     468        PVBOXVDMACMD pHdr = VBOXVDMACBUF_DR_TAIL(pDr, VBOXVDMACMD);
     469        pHdr->enmType = VBOXVDMACMD_TYPE_CHILD_STATUS_IRQ;
     470        pHdr->u32CmdSpecific = 0;
     471        PVBOXVDMACMD_CHILD_STATUS_IRQ pBody = VBOXVDMACMD_BODY(pHdr, VBOXVDMACMD_CHILD_STATUS_IRQ);
     472        pBody->cInfos = 1;
     473        if (idTarget == D3DDDI_ID_ALL)
     474        {
     475            pBody->fFlags |= VBOXVDMACMD_CHILD_STATUS_IRQ_F_APPLY_TO_ALL;
     476        }
     477        pBody->aInfos[0].iChild = idTarget;
     478        pBody->aInfos[0].fFlags = VBOXVDMA_CHILD_STATUS_F_DISCONNECTED | VBOXVDMA_CHILD_STATUS_F_CONNECTED;
     479
     480        /* we're going to KeWaitForSingleObject */
     481        Assert(KeGetCurrentIrql() < DISPATCH_LEVEL);
     482
     483        PVBOXVDMADDI_CMD pDdiCmd = VBOXVDMADDI_CMD_FROM_BUF_DR(pDr);
     484        VBOXWDDMCHILDSTATUSCB Ctx;
     485        KEVENT Event;
     486        KeInitializeEvent(&Event, NotificationEvent, FALSE);
     487        Ctx.pDr = pDr;
     488        Ctx.pEvent = &Event;
     489        vboxVdmaDdiCmdInit(pDdiCmd, 0, NULL, vboxWddmChildStatusReportCompletion, &Ctx);
     490        /* mark command as submitted & invisible for the dx runtime since dx did not originate it */
     491        vboxVdmaDdiCmdSubmittedNotDx(pDdiCmd);
     492        int rc = vboxVdmaCBufDrSubmit(pDevExt, &pDevExt->u.primary.Vdma, pDr);
     493        Assert(rc == VINF_SUCCESS);
     494        if (RT_SUCCESS(rc))
     495        {
     496            Status = KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
     497            Assert(Status == STATUS_SUCCESS);
     498            return STATUS_SUCCESS;
     499        }
     500
     501        Status = STATUS_UNSUCCESSFUL;
     502
     503        vboxVdmaCBufDrFree(&pDevExt->u.primary.Vdma, pDr);
     504    }
     505    else
     506    {
     507        Assert(0);
     508        /* @todo: try flushing.. */
     509        LOGREL(("vboxVdmaCBufDrCreate returned NULL"));
     510        Status = STATUS_INSUFFICIENT_RESOURCES;
     511    }
     512
     513    return Status;
     514}
     515
     516static NTSTATUS vboxWddmChildStatusCheck(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_VIDEOMODES_INFO paInfos)
     517{
     518    NTSTATUS Status = STATUS_SUCCESS;
     519    bool bChanged[VBOX_VIDEO_MAX_SCREENS] = {};
     520    int i;
     521
     522    Assert(!bChanged[0]);
     523    for (i = 1; i < VBoxCommonFromDeviceExt(pDevExt)->cDisplays; ++i)
     524    {
     525        /* @todo: check that we actually need the current source->target */
     526        PVBOXWDDM_VIDEOMODES_INFO pInfo = &paInfos[i];
     527        VIDEO_MODE_INFORMATION *pModeInfo = &pInfo->aModes[pInfo->iPreferredMode];
     528        BOOLEAN fMatch = FALSE;
     529        Status = vboxVidPnMatchMonitorModes(pDevExt, i, pInfo->aResolutions, pInfo->cResolutions, &fMatch);
     530        if (!NT_SUCCESS(Status))
     531        {
     532            WARN(("vboxVidPnMatchMonitorModes failed Status(0x%x)", Status));
     533            /* ignore the failures here, although we probably should not?? */
     534            break;
     535        }
     536
     537        bChanged[i] = !fMatch;
     538
     539        if (!fMatch)
     540        {
     541            Status = vboxWddmChildStatusReportReconnected(pDevExt, i);
     542            if (!NT_SUCCESS(Status))
     543            {
     544                WARN(("vboxWddmChildStatusReportReconnected failed Status(0x%x)", Status));
     545                /* ignore the failures here, although we probably should not?? */
     546                break;
     547            }
     548        }
     549    }
     550
     551    if (!NT_SUCCESS(Status))
     552    {
     553        WARN(("updating monitor modes failed, Status(0x%x)", Status));
     554        return Status;
     555    }
     556
     557    /* wait for the reconnected monitor data to be picked up */
     558    CONST DXGK_MONITOR_INTERFACE *pMonitorInterface;
     559    Status = pDevExt->u.primary.DxgkInterface.DxgkCbQueryMonitorInterface(pDevExt->u.primary.DxgkInterface.DeviceHandle, DXGK_MONITOR_INTERFACE_VERSION_V1, &pMonitorInterface);
     560    if (!NT_SUCCESS(Status))
     561    {
     562        WARN(("DxgkCbQueryMonitorInterface failed, Status()0x%x", Status));
     563        return Status;
     564    }
     565
     566    for (i = 0; i < VBoxCommonFromDeviceExt(pDevExt)->cDisplays; ++i)
     567    {
     568        D3DKMDT_HMONITORSOURCEMODESET hMonitorSMS;
     569        CONST DXGK_MONITORSOURCEMODESET_INTERFACE *pMonitorSMSIf;
     570        if (!bChanged[i])
     571            continue;
     572
     573        while (1)
     574        {
     575            Status = pMonitorInterface->pfnAcquireMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle,
     576                                                i,
     577                                                &hMonitorSMS,
     578                                                &pMonitorSMSIf);
     579            if (NT_SUCCESS(Status))
     580            {
     581                NTSTATUS tmpStatus = pMonitorInterface->pfnReleaseMonitorSourceModeSet(pDevExt->u.primary.DxgkInterface.DeviceHandle, hMonitorSMS);
     582                if (!NT_SUCCESS(tmpStatus))
     583                {
     584                    WARN(("pfnReleaseMonitorSourceModeSet failed tmpStatus(0x%x)", tmpStatus));
     585                }
     586                break;
     587            }
     588
     589            if (Status != STATUS_GRAPHICS_MONITOR_NOT_CONNECTED)
     590            {
     591                WARN(("DxgkCbQueryMonitorInterface failed, Status()0x%x", Status));
     592                break;
     593            }
     594
     595            Assert(KeGetCurrentIrql() < DISPATCH_LEVEL);
     596
     597            LARGE_INTEGER Interval;
     598            Interval.QuadPart = -(int64_t) 2 /* ms */ * 10000;
     599            NTSTATUS tmpStatus = KeDelayExecutionThread(KernelMode, FALSE, &Interval);
     600            if (!NT_SUCCESS(tmpStatus))
     601            {
     602                WARN(("KeDelayExecutionThread failed tmpStatus(0x%x)", tmpStatus));
     603            }
     604        }
     605    }
     606
     607    return STATUS_SUCCESS;
    332608}
    333609
     
    11091385        ChildRelations[i].ChildCapabilities.Type.VideoOutput.MonitorOrientationAwareness = D3DKMDT_MOA_INTERRUPTIBLE; /* ?? D3DKMDT_MOA_NONE*/
    11101386        ChildRelations[i].ChildCapabilities.Type.VideoOutput.SupportsSdtvModes = FALSE;
    1111         ChildRelations[i].ChildCapabilities.HpdAwareness = HpdAwarenessAlwaysConnected; //HpdAwarenessInterruptible; /* ?? HpdAwarenessAlwaysConnected; */
     1387        ChildRelations[i].ChildCapabilities.HpdAwareness = HpdAwarenessInterruptible; /* ?? HpdAwarenessAlwaysConnected; */
    11121388        ChildRelations[i].AcpiUid =  0; /* */
    11131389        ChildRelations[i].ChildUid = i; /* should be == target id */
     
    27963072                    )
    27973073            {
    2798                 /* we do now care about the others for now */
     3074                /* we do not care about the others for now */
    27993075                Status = STATUS_SUCCESS;
    28003076                break;
     
    34143690                    /* ensure the last char is \0*/
    34153691                    *((uint8_t*)pDbgPrint + pEscape->PrivateDriverDataSize - 1) = '\0';
    3416                     DbgPrint(pDbgPrint->aStringBuf);
     3692                    LOGREL(("%s", pDbgPrint->aStringBuf));
    34173693                }
    34183694                Status = STATUS_SUCCESS;
     
    35843860            (PVBOXWDDM_RECOMMENDVIDPN)pRecommendFunctionalVidPnArg->pPrivateDriverData : NULL;
    35853861    PVBOXWDDM_VIDEOMODES_INFO pInfos = VBoxWddmUpdateVideoModesInfo(pDevExt, NULL /*pVidPnInfo*/);
     3862    int i;
     3863
     3864    for (i = 0; i < VBoxCommonFromDeviceExt(pDevExt)->cDisplays; ++i)
     3865    {
     3866        /* @todo: check that we actually need the current source->target */
     3867        PVBOXWDDM_VIDEOMODES_INFO pInfo = &pInfos[i];
     3868        VIDEO_MODE_INFORMATION *pModeInfo = &pInfo->aModes[pInfo->iPreferredMode];
     3869#if 0
     3870        D3DKMDT_2DREGION Resolution;
     3871        Resolution.cx = pModeInfo->VisScreenWidth;
     3872        Resolution.cy = pModeInfo->VisScreenHeight;
     3873        Status = vboxVidPnCheckAddMonitorModes(pDevExt, i, D3DKMDT_MCO_DRIVER, &Resolution, 1, 0);
     3874#else
     3875        Status = vboxVidPnCheckAddMonitorModes(pDevExt, i, D3DKMDT_MCO_DRIVER, pInfo->aResolutions, pInfo->cResolutions, pInfo->iPreferredResolution);
     3876#endif
     3877        Assert(Status == STATUS_SUCCESS);
     3878        if (Status != STATUS_SUCCESS)
     3879        {
     3880            LOGREL(("vboxVidPnCheckAddMonitorModes failed Status(0x%x)", Status));
     3881            break;
     3882        }
     3883    }
     3884
    35863885    const DXGK_VIDPN_INTERFACE* pVidPnInterface = NULL;
    35873886    Status = pDevExt->u.primary.DxgkInterface.DxgkCbQueryVidPnInterface(pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn, DXGK_VIDPN_INTERFACE_VERSION_V1, &pVidPnInterface);
    3588     Assert(Status == STATUS_SUCCESS);
    3589     if (Status == STATUS_SUCCESS)
    3590     {
    3591         VIDEO_MODE_INFORMATION *pResModes = NULL;
    3592         uint32_t cResModes = 0;
    3593         int i;
    3594         for (i = 0; i < VBoxCommonFromDeviceExt(pDevExt)->cDisplays; ++i)
    3595         {
    3596             /* @todo: check that we actually need the current source->target */
    3597             PVBOXWDDM_VIDEOMODES_INFO pInfo = &pInfos[i];
    3598             VIDEO_MODE_INFORMATION *pModeInfo = &pInfo->aModes[pInfo->iPreferredMode];
    3599 #if 1
    3600             D3DKMDT_2DREGION Resolution;
    3601             Resolution.cx = pModeInfo->VisScreenWidth;
    3602             Resolution.cy = pModeInfo->VisScreenHeight;
    3603             Status = vboxVidPnCheckAddMonitorModes(pDevExt, i, D3DKMDT_MCO_DRIVER, &Resolution, 1);
    3604 #else
    3605             Status = vboxVidPnCheckAddMonitorModes(pDevExt, i, D3DKMDT_MCO_DRIVER, pInfo->aResolutions, pInfo->cResolutions);
    3606 #endif
     3887    if (!NT_SUCCESS(Status))
     3888    {
     3889        WARN(("DxgkCbQueryVidPnInterface failed Status(0x%x)", Status));
     3890        return Status;
     3891    }
     3892
     3893    for (i = 0; i < VBoxCommonFromDeviceExt(pDevExt)->cDisplays; ++i)
     3894    {
     3895        Status = vboxVidPnPathAdd(pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn, pVidPnInterface, i, i);
     3896        if (!NT_SUCCESS(Status))
     3897        {
     3898            WARN(("vboxVidPnPathAdd failed Status(0x%x)", Status));
     3899            return Status;
     3900        }
     3901    }
     3902
     3903    VIDEO_MODE_INFORMATION *pResModes = NULL;
     3904    uint32_t cResModes = 0;
     3905
     3906    for (i = 0; i < VBoxCommonFromDeviceExt(pDevExt)->cDisplays; ++i)
     3907    {
     3908        D3DKMDT_2DREGION Resolution;
     3909        PVBOXWDDM_VIDEOMODES_INFO pInfo = &pInfos[i];
     3910        VIDEO_MODE_INFORMATION *pModeInfo = &pInfo->aModes[pInfo->iPreferredMode];
     3911        Resolution.cx = pModeInfo->VisScreenWidth;
     3912        Resolution.cy = pModeInfo->VisScreenHeight;
     3913        int32_t iPreferableResMode;
     3914        uint32_t cActualResModes;
     3915
     3916        Status = VBoxWddmGetModesForResolution(pInfo->aModes, pInfo->cModes, pInfo->iPreferredMode, &Resolution,
     3917                pResModes, cResModes, &cActualResModes, &iPreferableResMode);
     3918        Assert(Status == STATUS_SUCCESS || Status == STATUS_BUFFER_TOO_SMALL);
     3919        if (Status == STATUS_BUFFER_TOO_SMALL)
     3920        {
     3921            Assert(cResModes < cActualResModes);
     3922            if (pResModes)
     3923            {
     3924                vboxWddmMemFree(pResModes);
     3925            }
     3926            pResModes = (VIDEO_MODE_INFORMATION*)vboxWddmMemAllocZero(sizeof (*pResModes) * cActualResModes);
     3927            Assert(pResModes);
     3928            if (!pResModes)
     3929            {
     3930                Status = STATUS_NO_MEMORY;
     3931                break;
     3932            }
     3933            cResModes = cActualResModes;
     3934            Status = VBoxWddmGetModesForResolution(pInfo->aModes, pInfo->cModes, pInfo->iPreferredMode, &Resolution,
     3935                                pResModes, cResModes, &cActualResModes, &iPreferableResMode);
    36073936            Assert(Status == STATUS_SUCCESS);
    36083937            if (Status != STATUS_SUCCESS)
    3609             {
    3610                 LOGREL(("vboxVidPnCheckAddMonitorModes failed Status(0x%x)", Status));
    36113938                break;
    3612             }
    3613         }
    3614 
    3615         for (i = 0; i < VBoxCommonFromDeviceExt(pDevExt)->cDisplays; ++i)
    3616         {
    3617             D3DKMDT_2DREGION Resolution;
    3618             PVBOXWDDM_VIDEOMODES_INFO pInfo = &pInfos[i];
    3619             VIDEO_MODE_INFORMATION *pModeInfo = &pInfo->aModes[pInfo->iPreferredMode];
    3620             Resolution.cx = pModeInfo->VisScreenWidth;
    3621             Resolution.cy = pModeInfo->VisScreenHeight;
    3622             int32_t iPreferableResMode;
    3623             uint32_t cActualResModes;
    3624 
    3625             Status = VBoxWddmGetModesForResolution(pInfo->aModes, pInfo->cModes, pInfo->iPreferredMode, &Resolution,
    3626                     pResModes, cResModes, &cActualResModes, &iPreferableResMode);
    3627             Assert(Status == STATUS_SUCCESS || Status == STATUS_BUFFER_TOO_SMALL);
    3628             if (Status == STATUS_BUFFER_TOO_SMALL)
    3629             {
    3630                 Assert(cResModes < cActualResModes);
    3631                 if (pResModes)
    3632                 {
    3633                     vboxWddmMemFree(pResModes);
    3634                 }
    3635                 pResModes = (VIDEO_MODE_INFORMATION*)vboxWddmMemAllocZero(sizeof (*pResModes) * cActualResModes);
    3636                 Assert(pResModes);
    3637                 if (!pResModes)
    3638                 {
    3639                     Status = STATUS_NO_MEMORY;
    3640                     break;
    3641                 }
    3642                 cResModes = cActualResModes;
    3643                 Status = VBoxWddmGetModesForResolution(pInfo->aModes, pInfo->cModes, pInfo->iPreferredMode, &Resolution,
    3644                                     pResModes, cResModes, &cActualResModes, &iPreferableResMode);
    3645                 Assert(Status == STATUS_SUCCESS);
    3646                 if (Status != STATUS_SUCCESS)
    3647                     break;
    3648             }
    3649             else if (Status != STATUS_SUCCESS)
    3650                 break;
    3651 
    3652             Assert(iPreferableResMode >= 0);
    3653             Assert(cActualResModes);
    3654 
    3655             Status = vboxVidPnCreatePopulateVidPnPathFromLegacy(pDevExt, pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn, pVidPnInterface,
    3656                             pResModes, cActualResModes, iPreferableResMode,
    3657                             &Resolution, 1 /* cResolutions */,
    3658                             i, i); /* srcId, tgtId */
    3659             Assert(Status == STATUS_SUCCESS);
    3660             if (Status != STATUS_SUCCESS)
    3661             {
    3662                 LOGREL(("vboxVidPnCreatePopulateVidPnFromLegacy failed Status(0x%x)", Status));
    3663                 break;
    3664             }
    3665         }
    3666 
    3667         if(pResModes)
    3668             vboxWddmMemFree(pResModes);
     3939        }
     3940        else if (Status != STATUS_SUCCESS)
     3941            break;
     3942
     3943        Assert(iPreferableResMode >= 0);
     3944        Assert(cActualResModes);
     3945
     3946        Status = vboxVidPnCreatePopulateVidPnPathFromLegacy(pDevExt, pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn, pVidPnInterface,
     3947                        pResModes, cActualResModes, iPreferableResMode,
     3948                        &Resolution, 1 /* cResolutions */,
     3949                        i, i); /* srcId, tgtId */
     3950        Assert(Status == STATUS_SUCCESS);
     3951        if (Status != STATUS_SUCCESS)
     3952        {
     3953            LOGREL(("vboxVidPnCreatePopulateVidPnFromLegacy failed Status(0x%x)", Status));
     3954            break;
     3955        }
     3956    }
     3957
     3958    if(pResModes)
     3959        vboxWddmMemFree(pResModes);
    36693960
    36703961#ifdef VBOXWDDM_DEBUG_VIDPN
    36713962        vboxVidPnDumpVidPn("\n>>>>Recommended VidPN: >>>>", pDevExt, pRecommendFunctionalVidPnArg->hRecommendedFunctionalVidPn, pVidPnInterface, "<<<<<<<<<<<<<<<<<<<<\n");
    36723963#endif
    3673     }
    36743964
    36753965    LOGF(("LEAVE, status(0x%x), context(0x%x)", Status, hAdapter));
     
    40284318    NTSTATUS Status;
    40294319    PVBOXWDDM_VIDEOMODES_INFO pInfo = VBoxWddmGetVideoModesInfo(pDevExt, pRecommendMonitorModesArg->VideoPresentTargetId);
     4320    PVIDEO_MODE_INFORMATION pPreferredMode = &pInfo->aModes[pInfo->iPreferredMode];
     4321
    40304322
    40314323    for (uint32_t i = 0; i < pInfo->cResolutions; i++)
     
    40414333                    &pInfo->aResolutions[i],
    40424334                    D3DKMDT_MCO_DRIVER,
    4043                     FALSE);
     4335                    pPreferredMode->VisScreenWidth == pInfo->aResolutions[i].cx
     4336                    && pPreferredMode->VisScreenHeight == pInfo->aResolutions[i].cy);
    40444337            Assert(Status == STATUS_SUCCESS);
    40454338            if (Status == STATUS_SUCCESS)
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp

    r34780 r37490  
    265265{
    266266    PVBOXDISPIFWDDM_RESIZEOP_CONTEXT pCtx = (PVBOXDISPIFWDDM_RESIZEOP_CONTEXT)pContext;
    267 
    268267    D3DKMT_INVALIDATEACTIVEVIDPN IAVidPnData = {0};
    269268    uint32_t cbData = VBOXWDDM_RECOMMENDVIDPN_SIZE(1);
Note: See TracChangeset for help on using the changeset viewer.

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