VirtualBox

Ignore:
Timestamp:
Apr 2, 2010 9:12:26 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
59659
Message:

wddm: vboxtray: abstraction display driver API for passing escape codes (using ExtEscape for XPDM & PFND3DKMT stugg for WDDM); WDDM miniport driver: basics for handling autoresize & seamles

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp

    r27912 r27955  
    3939    /* EnumDisplayDevices does not exist in NT. isVBoxDisplayDriverActive et al. are using these functions. */
    4040    BOOL (WINAPI * pfnEnumDisplayDevices)(IN LPCSTR lpDevice, IN DWORD iDevNum, OUT PDISPLAY_DEVICEA lpDisplayDevice, IN DWORD dwFlags);
    41 
    4241} VBOXDISPLAYCONTEXT;
    4342
    4443static VBOXDISPLAYCONTEXT gCtx = {0};
     44
     45#ifdef VBOXWDDM
     46static bool vboxWddmReinitVideoModes(VBOXDISPLAYCONTEXT *pCtx)
     47{
     48    VBOXDISPIFESCAPE escape = {0};
     49    escape.escapeCode = VBOXESC_REINITVIDEOMODES;
     50    DWORD err = VBoxDispIfEscape(&pCtx->pEnv->dispIf, &escape, 0);
     51    if (err != NO_ERROR)
     52    {
     53        Log((__FUNCTION__": VBoxDispIfEscape failed with err (%d)\n", err));
     54        return false;
     55    }
     56    return true;
     57}
     58
     59typedef enum
     60{
     61    VBOXDISPLAY_DRIVER_TYPE_UNKNOWN = 0,
     62    VBOXDISPLAY_DRIVER_TYPE_XPDM    = 1,
     63    VBOXDISPLAY_DRIVER_TYPE_WDDM    = 2
     64} VBOXDISPLAY_DRIVER_TYPE;
     65
     66static VBOXDISPLAY_DRIVER_TYPE getVBoxDisplayDriverType (VBOXDISPLAYCONTEXT *pCtx);
     67#endif
    4568
    4669int VBoxDisplayInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread)
     
    6689        *(uintptr_t *)&gCtx.pfnEnumDisplayDevices = (uintptr_t)GetProcAddress(hUser, "EnumDisplayDevicesA");
    6790        Log(("VBoxTray: pfnEnumDisplayDevices = %p\n", gCtx.pfnEnumDisplayDevices));
     91
     92#ifdef VBOXWDDM
     93        if (OSinfo.dwMajorVersion >= 6)
     94        {
     95            /* this is vista and up, check if we need to switch the display driver if to WDDM mode */
     96            Log(("VBoxTray: this is vista and up\n"));
     97            VBOXDISPLAY_DRIVER_TYPE enmType = getVBoxDisplayDriverType (&gCtx);
     98            if (enmType == VBOXDISPLAY_DRIVER_TYPE_WDDM)
     99            {
     100                Log(("VBoxTray: WDDM driver is installed, switching display driver if to WDDM mode\n"));
     101                /* this is hacky, but the most easiest way */
     102                DWORD err = VBoxDispIfSwitchMode(const_cast<PVBOXDISPIF>(&pEnv->dispIf), VBOXDISPIF_MODE_WDDM, NULL /* old mode, we don't care about it */);
     103                if (err == NO_ERROR)
     104                    Log(("VBoxTray: DispIf switched to WDDM mode successfully\n"));
     105                else
     106                    Log(("VBoxTray: failed to switch DispIf to WDDM mode, err (%d)\n", err));
     107            }
     108        }
     109#endif
    68110    }
    69111    else if (OSinfo.dwMajorVersion <= 4)            /* Windows NT 4.0 */
     
    89131}
    90132
     133#ifdef VBOXWDDM
     134static VBOXDISPLAY_DRIVER_TYPE getVBoxDisplayDriverType (VBOXDISPLAYCONTEXT *pCtx)
     135#else
    91136static bool isVBoxDisplayDriverActive (VBOXDISPLAYCONTEXT *pCtx)
     137#endif
    92138{
     139#ifdef VBOXWDDM
     140    VBOXDISPLAY_DRIVER_TYPE enmType = VBOXDISPLAY_DRIVER_TYPE_UNKNOWN;
     141#else
    93142    bool result = false;
     143#endif
    94144
    95145    if( pCtx->pfnEnumDisplayDevices )
     
    120170
    121171                if (strcmp(&dispDevice.DeviceString[0], "VirtualBox Graphics Adapter") == 0)
     172#ifndef VBOXWDDM
    122173                    result = true;
    123 #ifdef VBOXWDDM
    124                 if (strcmp(&dispDevice.DeviceString[0], "VirtualBox Graphics Adapter (Microsoft Corporation - WDDM)") == 0)
    125                     result = true;
     174#else
     175                    enmType = VBOXDISPLAY_DRIVER_TYPE_XPDM;
     176                else if (strcmp(&dispDevice.DeviceString[0], "VirtualBox Graphics Adapter (Microsoft Corporation - WDDM)") == 0)
     177                    enmType = VBOXDISPLAY_DRIVER_TYPE_WDDM;
    126178#endif
    127179                break;
     
    146198        /* Check for the short name, because all long stuff would be truncated */
    147199        if (strcmp((char*)&tempDevMode.dmDeviceName[0], "VBoxDisp") == 0)
     200#ifndef VBOXWDDM
    148201            result = true;
    149     }
    150 
     202#else
     203            enmType = VBOXDISPLAY_DRIVER_TYPE_XPDM;
     204#endif
     205    }
     206
     207#ifndef VBOXWDDM
    151208    return result;
     209#else
     210    return enmType;
     211#endif
    152212}
    153213
    154214/* Returns TRUE to try again. */
    155 static BOOL ResizeDisplayDevice(ULONG Id, DWORD Width, DWORD Height, DWORD BitsPerPixel)
     215static BOOL ResizeDisplayDevice(
     216#ifdef VBOXWDDM
     217        VBOXDISPLAYCONTEXT *pCtx, VBOXDISPLAY_DRIVER_TYPE enmType,
     218#endif
     219        ULONG Id, DWORD Width, DWORD Height, DWORD BitsPerPixel
     220        )
    156221{
    157222    BOOL fModeReset = (Width == 0 && Height == 0 && BitsPerPixel == 0);
     
    334399        Log(("ResizeDisplayDevice: EnumDisplaySettings last error %d\n", GetLastError ()));
    335400    }
     401
     402#ifdef VBOXWDDM
     403    if (enmType == VBOXDISPLAY_DRIVER_TYPE_WDDM)
     404        vboxWddmReinitVideoModes(pCtx);
     405#endif
    336406
    337407    /* Assign the new rectangles to displays. */
     
    472542                         * Only try to change video mode if the active display driver is VBox additions.
    473543                         */
     544#ifdef VBOXWDDM
     545                        VBOXDISPLAY_DRIVER_TYPE enmDriverType = getVBoxDisplayDriverType (pCtx);
     546
     547                        if (enmDriverType == VBOXDISPLAY_DRIVER_TYPE_WDDM)
     548                            Log(("VBoxDisplayThread : Detected WDDM Driver\n"));
     549
     550                        if (enmDriverType != VBOXDISPLAY_DRIVER_TYPE_UNKNOWN)
     551#else
    474552                        if (isVBoxDisplayDriverActive (pCtx))
     553#endif
    475554                        {
    476555                            Log(("VBoxDisplayThread : Display driver is active!\n"));
     
    481560
    482561                                /* W2K or later. */
    483                                 if (!ResizeDisplayDevice(displayChangeRequest.display,
     562                                if (!ResizeDisplayDevice(
     563#ifdef VBOXWDDM
     564                                                         pCtx, enmDriverType ,
     565#endif
     566                                                         displayChangeRequest.display,
    484567                                                         displayChangeRequest.xres,
    485568                                                         displayChangeRequest.yres,
    486                                                          displayChangeRequest.bpp))
     569                                                         displayChangeRequest.bpp
     570                                                         ))
    487571                                {
    488572                                    break;
Note: See TracChangeset for help on using the changeset viewer.

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