VirtualBox

Ignore:
Timestamp:
Feb 15, 2010 10:10:11 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57735
Message:

wddm: more impl

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Miniport
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/Makefile.kmk

    r26493 r26556  
    8282  VBoxVideoWddm_NOINST     = true
    8383 endif
     84 
    8485 VBoxVideoWddm_SDKS=WINDDKWLH
    8586 VBoxVideoWddm_DEFS       += LOG_TO_BACKDOOR VBOX_WITH_8BPP_MODES
    86  VBoxVideoWddm_DEFS       += VBOX_WITH_HGSMI VBOXWDDM
     87 VBoxVideoWddm_DEFS       += VBOX_WITH_HGSMI VBOXWDDM VBOXVDMA
    8788 ifdef VBOX_WITH_VIDEOHWACCEL
    8889  VBoxVideoWddm_DEFS      += VBOX_WITH_VIDEOHWACCEL
     
    9899        wddm/VBoxVideoWddm.cpp \
    99100        wddm/VBoxVideoVidPn.cpp \
     101        wddm/VBoxVideoVdma.cpp \
     102        wddm/VBoxVideoShgsmi.cpp \
    100103        wddm/VBoxVideoWddm.def \
    101104        wddm/VBoxVideoWddm.rc
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp

    r26493 r26556  
    263263
    264264    /* size of the VRAM in bytes */
     265
     266#ifndef VBOXWDDM
    265267    ULONG vramSize = DeviceExtension->pPrimary->u.primary.ulMaxFrameBufferSize;
    266 
    267     gNumVideoModes = 0;
    268 #ifdef VBOXWDDM
     268#else
     269    ULONG vramSize = vboxWddmVramReportedSize(DeviceExtension);
     270
    269271    gPreferredVideoMode = 0;
    270272#endif
     273
     274    gNumVideoModes = 0;
    271275
    272276    size_t numModesCurrentColorDepth;
     
    751755        || (gCustomXRes || gCustomYRes || gCustomBPP))
    752756    {
     757#ifndef VBOXWDDM
    753758        dprintf(("VBoxVideo: adding custom video mode as #%d, current mode: %d \n", gNumVideoModes + 1, DeviceExtension->CurrentMode));
    754759        /* handle the startup case */
    755760        if (DeviceExtension->CurrentMode == 0)
     761#else
     762        if (!DeviceExtension->cSources || !DeviceExtension->aSources[0].ulFrameBufferSize)
     763#endif
    756764        {
    757765            /* Use the stored custom resolution values only if nothing was read from host.
     
    771779        xres &= 0xfff8;
    772780        /* take the current values for the fields that are not set */
     781#ifndef VBOXWDDM
    773782        if (DeviceExtension->CurrentMode != 0)
    774783        {
     
    780789                bpp  = DeviceExtension->CurrentModeBPP;
    781790        }
     791#else
     792        if (DeviceExtension->cSources && DeviceExtension->aSources[0].ulFrameBufferSize)
     793        {
     794            if (!xres)
     795                xres = DeviceExtension->aSources[0].VisScreenWidth;
     796            if (!yres)
     797                yres = DeviceExtension->aSources[0].VisScreenHeight;
     798            if (!bpp)
     799                bpp  = DeviceExtension->aSources[0].BitsPerPlane;
     800        }
     801#endif
    782802
    783803        /* Use a default value. */
     
    801821            {
    802822                /* we need an alternating index */
     823#ifndef VBOXWDDM
    803824                if (DeviceExtension->CurrentMode != 0)
     825#else
     826                if (DeviceExtension->cSources && DeviceExtension->aSources[0].ulFrameBufferSize)
     827#endif
    804828                {
    805829                    if (gInvocationCounter % 2)
     
    877901
    878902                /* for the startup case, we need this mode twice due to the alternating mode number */
     903#ifndef VBOXWDDM
    879904                if (DeviceExtension->CurrentMode == 0)
     905#else
     906                if (!DeviceExtension->cSources || !DeviceExtension->aSources[0].ulFrameBufferSize)
     907#endif
    880908                {
    881909                    dprintf(("VBoxVideo: making a copy of the custom mode as #%d\n", gNumVideoModes + 1));
     
    918946    {
    919947        int i;
     948#ifndef VBOXWDDM
    920949        dprintf(("VBoxVideo: VideoModes (CurrentMode = %d)\n", DeviceExtension->CurrentMode));
     950#endif
    921951        for (i=0; i<MAX_VIDEO_MODES + 2; i++)
    922952        {
     
    965995}
    966996
    967 #endif
     997#else
    968998
    969999/* Computes the size of a framebuffer. DualView has a few framebuffers of the computed size. */
     
    10331063    }
    10341064}
     1065
     1066#endif
    10351067
    10361068int VBoxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension, void **ppv, ULONG ulOffset, ULONG ulSize)
     
    10871119        VideoPortUnmapMemory(PrimaryExtension, *ppv, NULL);
    10881120#else
    1089         MmUnmapIoSpace(*ppv, ulSize);
     1121        NTSTATUS ntStatus = PrimaryExtension->u.primary.DxgkInterface.DxgkCbUnmapMemory(PrimaryExtension->u.primary.DxgkInterface.DeviceHandle,
     1122                *ppv);
     1123        Assert(ntStatus == STATUS_SUCCESS);
    10901124#endif
    10911125    }
     
    24302464}
    24312465
    2432 #ifndef VBOXWDDM
    2433 
    24342466/**
    24352467 * VBoxVideoSetCurrentMode
     
    24382470 */
    24392471BOOLEAN FASTCALL VBoxVideoSetCurrentMode(PDEVICE_EXTENSION DeviceExtension,
    2440                                          PVIDEO_MODE RequestedMode, PSTATUS_BLOCK StatusBlock)
    2441 {
     2472#ifndef VBOXWDDM
     2473                                         PVIDEO_MODE RequestedMode, PSTATUS_BLOCK StatusBlock
     2474#else
     2475                                         D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId,
     2476                                         PVBOXWDDM_SOURCE ModeInfo
     2477#endif
     2478                                         )
     2479{
     2480#ifndef VBOXWDDM
    24422481    PVIDEO_MODE_INFORMATION ModeInfo;
    24432482
     
    24592498        return TRUE;
    24602499    }
     2500#else
     2501    Assert(!srcId);
     2502
     2503    if (srcId)
     2504    {
     2505        dprintf(("VBoxVideo::VBoxVideoSetCurrentMode: Skipping for ? non-primary ? source ? %d\n",
     2506                srcId));
     2507        return TRUE;
     2508    }
     2509#endif
    24612510
    24622511    /* set the mode characteristics */
     
    24812530}
    24822531
     2532#ifndef VBOXWDDM
     2533
    24832534/*
    24842535 * VBoxVideoResetDevice
     
    26772728   return TRUE;
    26782729}
     2730
     2731#ifndef VBOXWDDM
    26792732
    26802733VP_STATUS VBoxVideoGetChildDescriptor(
     
    28702923    return rc;
    28712924}
     2925#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h

    r26505 r26556  
    117117#else
    118118#include <VBox/VBoxVideo.h>
     119#include "wddm/VBoxVideoShgsmi.h"
     120#include "wddm/VBoxVideoVdma.h"
    119121
    120122typedef KSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK;
     
    125127typedef HANDLE VBOXCMNREG;
    126128
    127 typedef enum
    128 {
    129     VBOXWDDM_CMD_UNEFINED = 0,
    130     VBOXWDDM_CMD_DMA_TRANSFER
    131 } VBOXWDDM_CMD_TYPE;
    132 
    133129typedef struct VBOXWDDM_SOURCE
    134130{
    135     HGSMIHEAP hgsmiDisplayHeap;
    136 //    VBVABUFFER *pVBVA; /* Pointer to the pjScreen + layout->offVBVABuffer. NULL if VBVA is not enabled. */
     131    ULONG VisScreenWidth;
     132    ULONG VisScreenHeight;
     133    ULONG BitsPerPlane;
     134
     135    ULONG ulFrameBufferOffset;                  /* The framebuffer position in the VRAM. */
     136    ULONG ulFrameBufferSize;                    /* The size of the current framebuffer. */
    137137} VBOXWDDM_SOURCE, *PVBOXWDDM_SOURCE;
    138138
     
    211211    DXGK_DEVICEINFO DeviceInfo;
    212212} VBOXWDDM_DEVICE, *PVBOXWDDM_DEVICE;
    213 
    214213#endif
    215214
     
    219218                                                * The primary extension is the first one.
    220219                                                */
    221 
     220#ifndef VBOXWDDM
    222221   struct _DEVICE_EXTENSION *pPrimary;         /* Pointer to the primary device extension. */
    223222
    224223   ULONG iDevice;                              /* Device index: 0 for primary, otherwise a secondary device. */
    225 
    226224
    227225   ULONG CurrentMode;                          /* Saved information about video modes */
     
    232230   ULONG ulFrameBufferOffset;                  /* The framebuffer position in the VRAM. */
    233231   ULONG ulFrameBufferSize;                    /* The size of the current framebuffer. */
    234 
     232#endif
    235233   union {
    236234       /* Information that is only relevant to the primary device or is the same for all devices. */
     
    258256                                                * This is mapped by miniport separately.
    259257                                                */
     258#ifdef VBOXWDDM
     259           VBOXVDMAINFO Vdma;
     260#endif
     261
    260262#ifdef VBOX_WITH_HGSMI
    261263           volatile HGSMIHOSTFLAGS * pHostFlags; /* HGSMI host flags */
     
    315317   PDEVICE_OBJECT pPDO;
    316318
     319   VBOXSHGSMILIST CtlList;
     320   VBOXSHGSMILIST DmaCmdList;
     321   BOOL bSetNotifyDxDpc;
     322   BOOL bNotifyDxDpc;
     323
    317324   ULONG cSources;
    318325   /* currently we define the array for the max possible size since we do not know
     
    326333} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
    327334
     335#ifndef VBOXWDDM
    328336#define DEV_MOUSE_HIDDEN(dev) ((dev)->pPrimary->u.primary.fMouseHidden)
    329337#define DEV_SET_MOUSE_HIDDEN(dev)   \
     
    335343    (dev)->pPrimary->u.primary.fMouseHidden = FALSE; \
    336344} while (0)
    337 
     345#else
     346#define DEV_MOUSE_HIDDEN(dev) ((dev)->u.primary.fMouseHidden)
     347#define DEV_SET_MOUSE_HIDDEN(dev)   \
     348do { \
     349    (dev)->u.primary.fMouseHidden = TRUE; \
     350} while (0)
     351#define DEV_SET_MOUSE_SHOWN(dev)   \
     352do { \
     353    (dev)->u.primary.fMouseHidden = FALSE; \
     354} while (0)
     355#endif
    338356extern "C"
    339357{
     
    626644VOID VBoxWddmGetModesTable(PDEVICE_EXTENSION DeviceExtension, bool bRebuildTable,
    627645        VIDEO_MODE_INFORMATION ** ppModes, uint32_t * pcModes, uint32_t * pPreferrableMode,
    628         D3DKMDT_2DREGION **pResolutions, uint32_t * pcResolutions);
     646        D3DKMDT_2DREGION **ppResolutions, uint32_t * pcResolutions);
    629647
    630648D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo);
    631649UINT vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format);
     650
     651DECLINLINE(ULONG) vboxWddmVramReportedSize(PDEVICE_EXTENSION pDevExt)
     652{
     653    return pDevExt->u.primary.Vdma.CmdHeap.area.offBase;
     654}
    632655
    633656NTSTATUS vboxVidPnCheckTopology(const D3DKMDT_HVIDPN hDesiredVidPn,
     
    764787DECLINLINE(void) VBoxHGSMIHostWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
    765788{
     789#ifndef VBOXWDDM
    766790    VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost, data);
     791#else
     792    VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->u.primary.IOPortHost, data);
     793#endif
    767794}
    768795
    769796DECLINLINE(ULONG) VBoxHGSMIHostRead(PDEVICE_EXTENSION PrimaryExtension)
    770797{
     798#ifndef VBOXWDDM
    771799    return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost);
     800#else
     801    return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->u.primary.IOPortHost);
     802#endif
    772803}
    773804
    774805DECLINLINE(void) VBoxHGSMIGuestWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
    775806{
     807#ifndef VBOXWDDM
    776808    VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest, data);
     809#else
     810    VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->u.primary.IOPortGuest, data);
     811#endif
    777812}
    778813
    779814DECLINLINE(ULONG) VBoxHGSMIGuestRead(PDEVICE_EXTENSION PrimaryExtension)
    780815{
     816#ifndef VBOXWDDM
    781817    return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest);
     818#else
     819    return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->u.primary.IOPortGuest);
     820#endif
    782821}
    783822
     
    792831                                PVIDEO_POINTER_ATTRIBUTES pointerAttr,
    793832                                uint32_t cbLength);
     833#ifndef VBOXWDDM
    794834DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
    795835DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd);
     836#endif
    796837
    797838
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp

    r26505 r26556  
    186186typedef FNHGSMICALLFINALIZE *PFNHGSMICALLFINALIZE;
    187187
     188void* VBoxHGSMIBufferAlloc (PDEVICE_EXTENSION PrimaryExtension,
     189                         HGSMISIZE cbData,
     190                         uint8_t u8Ch,
     191                         uint16_t u16Op)
     192{
     193#ifdef VBOXWDDM
     194    /* @todo: add synchronization */
     195#endif
     196    return HGSMIHeapAlloc (&PrimaryExtension->u.primary.hgsmiAdapterHeap, cbData, u8Ch, u16Op);
     197}
     198
     199void* VBoxHGSMIBufferAlloc (PDEVICE_EXTENSION PrimaryExtension,
     200                         uint8_t u8Ch,
     201                         uint16_t u16Op,
     202                         HGSMISIZE cbData)
     203{
     204#ifdef VBOXWDDM
     205    /* @todo: add synchronization */
     206#endif
     207    return HGSMIHeapAlloc (&PrimaryExtension->u.primary.hgsmiAdapterHeap, cbData, u8Ch, u16Op);
     208}
     209
     210void VBoxHGSMIBufferFree (PDEVICE_EXTENSION PrimaryExtension, void *pvBuffer)
     211{
     212#ifdef VBOXWDDM
     213    /* @todo: add synchronization */
     214#endif
     215    HGSMIHeapFree (&PrimaryExtension->u.primary.hgsmiAdapterHeap, pvBuffer);
     216}
     217
     218int VBoxHGSMIBufferSubmit (PDEVICE_EXTENSION PrimaryExtension, void *pvBuffer)
     219{
     220    /* Initialize the buffer and get the offset for port IO. */
     221    HGSMIOFFSET offBuffer = HGSMIHeapBufferOffset (&PrimaryExtension->u.primary.hgsmiAdapterHeap, pvBuffer);
     222
     223    Assert(offBuffer != HGSMIOFFSET_VOID);
     224    if (offBuffer != HGSMIOFFSET_VOID)
     225    {
     226        /* Submit the buffer to the host. */
     227        VBoxHGSMIGuestWrite(PrimaryExtension, offBuffer);
     228        return VINF_SUCCESS;
     229    }
     230
     231    return VERR_INVALID_PARAMETER;
     232}
     233
    188234static int vboxCallChannel (PDEVICE_EXTENSION PrimaryExtension,
    189235                         uint8_t u8Ch,
     
    197243
    198244    /* Allocate the IO buffer. */
     245#ifndef VBOXWDDM
    199246    if (PrimaryExtension->pPrimary != PrimaryExtension)
    200247    {
     
    202249        return VERR_INVALID_PARAMETER;
    203250    }
     251#endif
    204252
    205253    void *p = HGSMIHeapAlloc (&PrimaryExtension->u.primary.hgsmiAdapterHeap, cbData, u8Ch, u16Op);
     
    315363    return rc;
    316364}
    317 
     365#ifndef VBOXWDDM
    318366static int vbvaInitInfoDisplay (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData)
    319367{
     
    348396    return VERR_INTERNAL_ERROR;
    349397}
     398#endif
    350399
    351400static int vbvaInitInfoHeap (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData)
     
    389438    if(RT_SUCCESS (rc))
    390439    {
     440#ifndef VBOXWDDM
    391441        rc = vboxCallVBVA (PrimaryExtension,
    392442                               VBVA_INFO_VIEW,
     
    397447        AssertRC(rc);
    398448        if (RT_SUCCESS (rc))
     449#else
     450        /* in case of WDDM we do not control the framebuffer location,
     451         * i.e. it is assigned by Video Memory Manager,
     452         * The FB information should be passed to guest from our DxgkDdiSetVidPnSourceAddress callback */
     453#endif
    399454        {
    400455            /* Report the host heap location. */
     
    660715     */
    661716    PrimaryExtension->pNext                              = NULL;
     717#ifndef VBOXWDDM
    662718    PrimaryExtension->pPrimary                           = PrimaryExtension;
    663719    PrimaryExtension->iDevice                            = 0;
    664720    PrimaryExtension->ulFrameBufferOffset                = 0;
    665721    PrimaryExtension->ulFrameBufferSize                  = 0;
     722#endif
    666723    PrimaryExtension->u.primary.ulVbvaEnabled            = 0;
    667724    PrimaryExtension->u.primary.bVBoxVideoSupported      = FALSE;
     
    861918    }
    862919
     920#ifndef VBOXWDDM
    863921    /* Now when the number of monitors is known and extensions are created,
    864922     * calculate the layout of framebuffers.
    865923     */
    866924    VBoxComputeFrameBufferSizes (PrimaryExtension);
     925#endif
    867926
    868927    if (PrimaryExtension->u.primary.bHGSMI)
     
    876935        }
    877936    }
     937
     938#ifdef VBOXWDDM
     939    if (PrimaryExtension->u.primary.bHGSMI)
     940    {
     941        ULONG ulAvailable = PrimaryExtension->u.primary.cbVRAM
     942                            - PrimaryExtension->u.primary.cbMiniportHeap
     943                            - VBVA_ADAPTER_INFORMATION_SIZE;
     944
     945        /* use 25% od VRAM for DMA command buffer
     946         * @todo: ^^^? */
     947        ULONG ulSize = ulAvailable / 4;
     948
     949        /* Align down to 4096 bytes. */
     950        ulSize &= ~0xFFF;
     951        ULONG offset = ulAvailable - ulSize;
     952
     953        Assert(!(offset & 0xFFF));
     954
     955        rc = vboxVdmaCreate (PrimaryExtension, &PrimaryExtension->u.primary.Vdma, offset, ulSize);
     956        AssertRC(rc);
     957        if (RT_SUCCESS(rc))
     958        {
     959            /* can enable it right away since the host does not need any screen/FB info
     960             * for basic DMA functionality */
     961            rc = vboxVdmaEnable(PrimaryExtension, &PrimaryExtension->u.primary.Vdma);
     962            AssertRC(rc);
     963            if (RT_FAILURE(rc))
     964                vboxVdmaDestroy(PrimaryExtension, &PrimaryExtension->u.primary.Vdma);
     965        }
     966
     967        if (RT_FAILURE(rc))
     968            PrimaryExtension->u.primary.bHGSMI = FALSE;
     969    }
     970#endif
    878971
    879972    if (!PrimaryExtension->u.primary.bHGSMI)
     
    9531046                                uint32_t cbLength)
    9541047{
     1048#ifndef VBOXWDDM
    9551049    PDEVICE_EXTENSION PrimaryExtension = DeviceExtension->pPrimary;
    9561050
     
    9771071        return TRUE;
    9781072    }
     1073#else
     1074    PDEVICE_EXTENSION PrimaryExtension = DeviceExtension;
     1075#endif
    9791076
    9801077    uint32_t cbData = 0;
     
    11161213}
    11171214
     1215#ifndef VBOXWDDM
    11181216DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd)
    11191217{
     
    11641262    return VERR_INVALID_PARAMETER;
    11651263}
     1264#endif
    11661265
    11671266static DECLCALLBACK(int) vboxVBVAChannelGenericHandler(void *pvHandler, uint16_t u16ChannelInfo, void *pvBuffer, HGSMISIZE cbBuffer)
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp

    r26324 r26556  
    508508    pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Numerator = 60000;
    509509    pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Denominator = 1000;
    510     pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Numerator = pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy * 60 * 1.05;
     510    pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Numerator = pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy * 63; /* 63 is (60 * 1.05)*/
    511511    pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Denominator = 1;
    512512    pNewVidPnTargetModeInfo->VideoSignalInfo.PixelRate = 165000; /* @todo: ? */
     
    543543                if (Status == STATUS_SUCCESS)
    544544                {
    545                     if (iPreferredMomde == i)
     545                    if (bPreferred)
    546546                    {
    547547                        Status = pNewVidPnTargetModeSetInterface->pfnPinMode(hNewVidPnTargetModeSet, modeId);
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp

    r26324 r26556  
    3939    ExFreePool(pvMem);
    4040}
     41
     42void vboxSHGSMICbCommandWrite(struct _HGSMIHEAP * pHeap, HGSMIOFFSET data)
     43{
     44    /* @todo: this should be taken from PDEVICE_EXTENSION */
     45    //VBoxHGSMIGuestWrite(pDevExt, data);
     46    VBoxVideoCmnPortWriteUlong((PULONG)VGA_PORT_HGSMI_GUEST, data);
     47}
     48
     49#if 0
     50void vboxWddmProcessDisplayInfo (PPDEV ppdev)
     51{
     52    if (ppdev->bHGSMISupported)
     53    {
     54        /* Issue the screen info command. */
     55        void *p = HGSMIHeapAlloc (&ppdev->hgsmiDisplayHeap,
     56                                  sizeof (VBVAINFOSCREEN),
     57                                  HGSMI_CH_VBVA,
     58                                  VBVA_INFO_SCREEN);
     59        if (!p)
     60        {
     61            DISPDBG((0, "VBoxDISP::VBoxProcessDisplayInfo: HGSMIHeapAlloc failed\n"));
     62        }
     63        else
     64        {
     65            VBVAINFOSCREEN *pScreen = (VBVAINFOSCREEN *)p;
     66
     67            pScreen->u32ViewIndex    = ppdev->iDevice;
     68            pScreen->i32OriginX      = ppdev->ptlDevOrg.x;
     69            pScreen->i32OriginY      = ppdev->ptlDevOrg.y;
     70            pScreen->u32StartOffset  = 0;
     71            pScreen->u32LineSize     = ppdev->lDeltaScreen > 0?ppdev->lDeltaScreen: -ppdev->lDeltaScreen;
     72            pScreen->u32Width        = ppdev->cxScreen;
     73            pScreen->u32Height       = ppdev->cyScreen;
     74            pScreen->u16BitsPerPixel = (uint16_t)ppdev->ulBitCount;
     75            pScreen->u16Flags        = VBVA_SCREEN_F_ACTIVE;
     76
     77            vboxHGSMIBufferSubmit (ppdev, p);
     78
     79            HGSMIHeapFree (&ppdev->hgsmiDisplayHeap, p);
     80        }
     81    }
     82
     83    return;
     84}
     85
     86NTSTATUS vboxWddmGhInitPrimary(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, D3DKMDT_VIDPN_SOURCE_MODE *pVidPnSourceModeInfo)
     87{
     88    NTSTATUS Status;
     89    PVBOXWDDM_SOURCE pSourceInfo = &pDevExt->aSources[srcId];
     90    memset(pSourceInfo, 0, sizeof (VBOXWDDM_SOURCE));
     91    pSourceInfo->VisScreenWidth = pVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cx;
     92    pSourceInfo->VisScreenHeight = pVidPnSourceModeInfo->Format.Graphics.PrimSurfSize.cy;
     93    pSourceInfo->BitsPerPlane = vboxWddmCalcBitsPerPixel(pVidPnSourceModeInfo->Format.Graphics.PixelFormat);
     94    Assert(pSourceInfo->BitsPerPlane);
     95    if (pSourceInfo->BitsPerPlane)
     96    {
     97        /*
     98         * Set the current mode into the hardware.
     99         */
     100        if (VBoxVideoSetCurrentMode(pDevExt, srcId, pSourceInfo))
     101        {
     102
     103
     104        }
     105        else
     106        {
     107            AssertBreakpoint();
     108
     109        }
     110    }
     111    else
     112    {
     113        drprintf((__FUNCTION__":ERROR: failed to caltulate bpp from pixel format (%d)\n",
     114                pVidPnSourceModeInfo->Format.Graphics.PixelFormat));
     115        return STATUS_INVALID_PARAMETER;
     116    }
     117
     118    return Status;
     119
     120
     121
     122//    DWORD returnedDataLength;
     123//    DWORD MaxWidth, MaxHeight;
     124//    VIDEO_MEMORY videoMemory;
     125//    VIDEO_MEMORY_INFORMATION videoMemoryInformation;
     126//    ULONG RemappingNeeded = 0;
     127
     128
     129    /*
     130     * don't need to map anything here, we use one common HGSMI heap for all sources
     131     */
     132
     133    // If this is the first time we enable the surface we need to map in the
     134    // memory also.
     135    //
     136
     137    if (bFirst || RemappingNeeded)
     138    {
     139//        videoMemory.RequestedVirtualAddress = NULL;
     140//
     141//        if (EngDeviceIoControl(ppdev->hDriver,
     142//                               IOCTL_VIDEO_MAP_VIDEO_MEMORY,
     143//                               &videoMemory,
     144//                               sizeof(VIDEO_MEMORY),
     145//                               &videoMemoryInformation,
     146//                               sizeof(VIDEO_MEMORY_INFORMATION),
     147//                               &returnedDataLength))
     148//        {
     149//            DISPDBG((1, "DISP bInitSURF failed IOCTL_VIDEO_MAP\n"));
     150//            return(FALSE);
     151//        }
     152//
     153//        ppdev->pjScreen = (PBYTE)(videoMemoryInformation.FrameBufferBase);
     154//
     155//        if (videoMemoryInformation.FrameBufferBase !=
     156//            videoMemoryInformation.VideoRamBase)
     157//        {
     158//            DISPDBG((0, "VideoRamBase does not correspond to FrameBufferBase\n"));
     159//        }
     160//
     161//        //
     162//        // Make sure we can access this video memory
     163//        //
     164//
     165//        *(PULONG)(ppdev->pjScreen) = 0xaa55aa55;
     166//
     167//        if (*(PULONG)(ppdev->pjScreen) != 0xaa55aa55) {
     168//
     169//            DISPDBG((1, "Frame buffer memory is not accessible.\n"));
     170//            return(FALSE);
     171//        }
     172//
     173//        /* Clear VRAM to avoid distortions during the video mode change. */
     174//        RtlZeroMemory(ppdev->pjScreen,
     175//                      ppdev->cyScreen * (ppdev->lDeltaScreen > 0? ppdev->lDeltaScreen: -ppdev->lDeltaScreen));
     176//
     177//        //
     178//        // Initialize the head of the offscreen list to NULL.
     179//        //
     180//
     181//        ppdev->pOffscreenList = NULL;
     182//
     183//        // It's a hardware pointer; set up pointer attributes.
     184//
     185//        MaxHeight = ppdev->PointerCapabilities.MaxHeight;
     186//
     187//        // Allocate space for two DIBs (data/mask) for the pointer. If this
     188//        // device supports a color Pointer, we will allocate a larger bitmap.
     189//        // If this is a color bitmap we allocate for the largest possible
     190//        // bitmap because we have no idea of what the pixel depth might be.
     191//
     192//        // Width rounded up to nearest byte multiple
     193//
     194//        if (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER))
     195//        {
     196//            MaxWidth = (ppdev->PointerCapabilities.MaxWidth + 7) / 8;
     197//        }
     198//        else
     199//        {
     200//            MaxWidth = ppdev->PointerCapabilities.MaxWidth * sizeof(DWORD);
     201//        }
     202//
     203//        ppdev->cjPointerAttributes =
     204//                sizeof(VIDEO_POINTER_ATTRIBUTES) +
     205//                ((sizeof(UCHAR) * MaxWidth * MaxHeight) * 2);
     206//
     207//        ppdev->pPointerAttributes = (PVIDEO_POINTER_ATTRIBUTES)
     208//                EngAllocMem(0, ppdev->cjPointerAttributes, ALLOC_TAG);
     209//
     210//        if (ppdev->pPointerAttributes == NULL) {
     211//
     212//            DISPDBG((0, "bInitPointer EngAllocMem failed\n"));
     213//            return(FALSE);
     214//        }
     215//
     216//        ppdev->pPointerAttributes->Flags = ppdev->PointerCapabilities.Flags;
     217//        ppdev->pPointerAttributes->WidthInBytes = MaxWidth;
     218//        ppdev->pPointerAttributes->Width = ppdev->PointerCapabilities.MaxWidth;
     219//        ppdev->pPointerAttributes->Height = MaxHeight;
     220//        ppdev->pPointerAttributes->Column = 0;
     221//        ppdev->pPointerAttributes->Row = 0;
     222//        ppdev->pPointerAttributes->Enable = 0;
     223
     224        vboxInitVBoxVideo (ppdev, &videoMemoryInformation);
     225
     226#ifndef VBOX_WITH_HGSMI
     227        if (ppdev->bVBoxVideoSupported)
     228        {
     229            /* Setup the display information. */
     230            vboxSetupDisplayInfo (ppdev, &videoMemoryInformation);
     231        }
     232#endif /* !VBOX_WITH_HGSMI */
     233    }
     234
     235
     236    DISPDBG((1, "DISP bInitSURF: ppdev->ulBitCount %d\n", ppdev->ulBitCount));
     237
     238    if (   ppdev->ulBitCount == 16
     239        || ppdev->ulBitCount == 24
     240        || ppdev->ulBitCount == 32)
     241    {
     242#ifndef VBOX_WITH_HGSMI
     243        if (ppdev->pInfo) /* Do not use VBVA on old hosts. */
     244        {
     245            /* Enable VBVA for this video mode. */
     246            vboxVbvaEnable (ppdev);
     247        }
     248#else
     249        if (ppdev->bHGSMISupported)
     250        {
     251            /* Enable VBVA for this video mode. */
     252            ppdev->bHGSMISupported = vboxVbvaEnable (ppdev);
     253            LogRel(("VBoxDisp[%d]: VBVA %senabled\n", ppdev->iDevice, ppdev->bHGSMISupported? "": "not "));
     254        }
     255#endif /* VBOX_WITH_HGSMI */
     256    }
     257
     258    DISPDBG((1, "DISP bInitSURF success\n"));
     259
     260#ifndef VBOX_WITH_HGSMI
     261    /* Update the display information. */
     262    vboxUpdateDisplayInfo (ppdev);
     263#else
     264    /* Inform the host about this screen layout. */
     265    DISPDBG((1, "bInitSURF: %d,%d\n", ppdev->ptlDevOrg.x, ppdev->ptlDevOrg.y));
     266    VBoxProcessDisplayInfo (ppdev);
     267#endif /* VBOX_WITH_HGSMI */
     268
     269#ifdef VBOX_WITH_VIDEOHWACCEL
     270    /* tells we can process host commands */
     271    vboxVHWAEnable(ppdev);
     272#endif
     273
     274    return(TRUE);
     275}
     276#endif
     277
     278HGSMIHEAP* vboxWddmHgsmiGetHeapFromCmdOffset(PDEVICE_EXTENSION pDevExt, HGSMIOFFSET offCmd)
     279{
     280    if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.area, offCmd))
     281        return &pDevExt->u.primary.Vdma.CmdHeap;
     282    if (HGSMIAreaContainsOffset(&pDevExt->u.primary.hgsmiAdapterHeap.area, offCmd))
     283        return &pDevExt->u.primary.hgsmiAdapterHeap;
     284    return NULL;
     285}
     286
     287typedef enum
     288{
     289    VBOXWDDM_HGSMICMD_TYPE_UNDEFINED = 0,
     290    VBOXWDDM_HGSMICMD_TYPE_CTL       = 1,
     291    VBOXWDDM_HGSMICMD_TYPE_DMACMD    = 2
     292} VBOXWDDM_HGSMICMD_TYPE;
     293
     294VBOXWDDM_HGSMICMD_TYPE vboxWddmHgsmiGetCmdTypeFromOffset(PDEVICE_EXTENSION pDevExt, HGSMIOFFSET offCmd)
     295{
     296    if(HGSMIAreaContainsOffset(&pDevExt->u.primary.Vdma.CmdHeap.area, offCmd))
     297        return VBOXWDDM_HGSMICMD_TYPE_DMACMD;
     298    if (HGSMIAreaContainsOffset(&pDevExt->u.primary.hgsmiAdapterHeap.area, offCmd))
     299        return VBOXWDDM_HGSMICMD_TYPE_CTL;
     300    return VBOXWDDM_HGSMICMD_TYPE_UNDEFINED;
     301}
     302
    41303
    42304#define VBOXWDDM_REG_DRVKEY_PREFIX L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Class\\"
     
    491753    )
    492754{
    493     return false;
     755    PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)MiniportDeviceContext;
     756    BOOLEAN bOur = FALSE;
     757    if (pDevExt->u.primary.pHostFlags) /* If HGSMI is enabled at all. */
     758    {
     759        VBOXSHGSMILIST CtlList;
     760        VBOXSHGSMILIST DmaCmdList;
     761        vboxSHGSMIListInit(&CtlList);
     762        vboxSHGSMIListInit(&DmaCmdList);
     763        do
     764        {
     765            uint32_t flags = pDevExt->u.primary.pHostFlags->u32HostFlags;
     766            if (flags & HGSMIHOSTFLAGS_GCOMMAND_COMPLETED)
     767            {
     768                bOur = TRUE;
     769                /* read the command offset */
     770                HGSMIOFFSET offCmd = VBoxHGSMIGuestRead(pDevExt);
     771                Assert(offCmd != HGSMIOFFSET_VOID);
     772                if (offCmd != HGSMIOFFSET_VOID)
     773                {
     774                    VBOXWDDM_HGSMICMD_TYPE enmType = vboxWddmHgsmiGetCmdTypeFromOffset(pDevExt, offCmd);
     775                    PVBOXSHGSMILIST pList;
     776                    HGSMIHEAP * pHeap = NULL;
     777                    switch (enmType)
     778                    {
     779                        case VBOXWDDM_HGSMICMD_TYPE_DMACMD:
     780                            pList = &DmaCmdList;
     781                            pHeap = &pDevExt->u.primary.Vdma.CmdHeap;
     782                            break;
     783                        case VBOXWDDM_HGSMICMD_TYPE_CTL:
     784                            pList = &CtlList;
     785                            pHeap = &pDevExt->u.primary.hgsmiAdapterHeap;
     786                            break;
     787                        default:
     788                            AssertBreakpoint();
     789                    }
     790
     791                    if (pHeap)
     792                    {
     793                        int rc = VBoxSHGSMICommandProcessCompletion (pHeap, offCmd, TRUE /*bool bIrq*/ , pList);
     794                        AssertRC(rc);
     795                    }
     796                }
     797            }
     798            else if (flags & HGSMIHOSTFLAGS_COMMANDS_PENDING)
     799            {
     800                bOur = TRUE;
     801                AssertBreakpoint();
     802                /* @todo: FIXME: implement !!! */
     803            }
     804            else if (flags & HGSMIHOSTFLAGS_IRQ)
     805            {
     806                bOur = TRUE;
     807                AssertBreakpoint();
     808                /* unknown command */
     809            }
     810            else
     811                break;
     812        } while (1);
     813
     814        if (!vboxSHGSMIListIsEmpty(&CtlList))
     815            vboxSHGSMIListCat(&pDevExt->CtlList, &CtlList);
     816
     817        if (!vboxSHGSMIListIsEmpty(&DmaCmdList))
     818            vboxSHGSMIListCat(&pDevExt->DmaCmdList, &DmaCmdList);
     819
     820        if (pDevExt->bSetNotifyDxDpc)
     821        {
     822            pDevExt->bNotifyDxDpc = TRUE;
     823            pDevExt->bSetNotifyDxDpc = FALSE;
     824        }
     825
     826        if (bOur)
     827            HGSMIClearIrq (pDevExt);
     828    }
     829
     830    return bOur;
     831}
     832
     833
     834typedef struct VBOXWDDM_DPCDATA
     835{
     836    VBOXSHGSMILIST CtlList;
     837    VBOXSHGSMILIST DmaCmdList;
     838    BOOL bNotifyDpc;
     839} VBOXWDDM_DPCDATA, *PVBOXWDDM_DPCDATA;
     840
     841typedef struct VBOXWDDM_GETDPCDATA_CONTEXT
     842{
     843    PDEVICE_EXTENSION pDevExt;
     844    VBOXWDDM_DPCDATA data;
     845} VBOXWDDM_GETDPCDATA_CONTEXT, *PVBOXWDDM_GETDPCDATA_CONTEXT;
     846
     847BOOLEAN vboxWddmGetDPCDataCallback(PVOID Context)
     848{
     849    PVBOXWDDM_GETDPCDATA_CONTEXT pdc = (PVBOXWDDM_GETDPCDATA_CONTEXT)Context;
     850
     851    vboxSHGSMICmdListDetach2List(&pdc->pDevExt->CtlList, &pdc->data.CtlList);
     852    vboxSHGSMICmdListDetach2List(&pdc->pDevExt->DmaCmdList, &pdc->data.DmaCmdList);
     853    pdc->data.bNotifyDpc = pdc->pDevExt->bNotifyDxDpc;
     854    pdc->pDevExt->bNotifyDxDpc = FALSE;
     855    return TRUE;
    494856}
    495857
     
    498860    )
    499861{
    500 
     862    PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)MiniportDeviceContext;
     863
     864    VBOXWDDM_DPCDATA dpcData = {0};
     865    BOOLEAN bRet;
     866
     867    /* get DPC data at IRQL */
     868    NTSTATUS Status = pDevExt->u.primary.DxgkInterface.DxgkCbSynchronizeExecution(
     869            pDevExt->u.primary.DxgkInterface.DeviceHandle,
     870            vboxWddmGetDPCDataCallback,
     871            &dpcData,
     872            0,
     873            &bRet);
     874    Assert(Status == STATUS_SUCCESS);
     875
     876    if (!vboxSHGSMIListIsEmpty(&dpcData.CtlList))
     877    {
     878        int rc = VBoxSHGSMICommandPostprocessCompletion (&pDevExt->u.primary.hgsmiAdapterHeap, &dpcData.CtlList);
     879        AssertRC(rc);
     880    }
     881
     882    if (!vboxSHGSMIListIsEmpty(&dpcData.DmaCmdList))
     883    {
     884        int rc = VBoxSHGSMICommandPostprocessCompletion (&pDevExt->u.primary.Vdma.CmdHeap, &dpcData.DmaCmdList);
     885        AssertRC(rc);
     886    }
     887
     888    if (dpcData.bNotifyDpc)
     889        pDevExt->u.primary.DxgkInterface.DxgkCbNotifyDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);
    501890}
    502891
     
    9761365}
    9771366
     1367/**
     1368 *
     1369 */
    9781370NTSTATUS
    9791371APIENTRY
     
    15071899            VBOXVIDPNCOFUNCMODALITY CbContext = {0};
    15081900            CbContext.pEnumCofuncModalityArg = pEnumCofuncModalityArg;
    1509             VBoxWddmGetModesTable(pContext, true, &CbContext.pModes, &CbContext.cModes, &CbContext.iPreferredMode, &CbContext.cResolutions, &CbContext.pResolutions);
     1901            VBoxWddmGetModesTable(pContext, /* PDEVICE_EXTENSION DeviceExtension */
     1902                    true, /* bool bRebuildTable*/
     1903                    &CbContext.pModes, /* VIDEO_MODE_INFORMATION ** ppModes*/
     1904                    &CbContext.cModes, /* uint32_t * pcModes */
     1905                    &CbContext.iPreferredMode, /* uint32_t * pPreferrableMode*/
     1906                    &CbContext.pResolutions, /* D3DKMDT_2DREGION **ppResolutions */
     1907                    &CbContext.cResolutions /* uint32_t * pcResolutions */);
    15101908            Assert(CbContext.cModes);
    15111909            Assert(CbContext.cModes > CbContext.iPreferredMode);
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