VirtualBox

Ignore:
Timestamp:
Feb 24, 2010 7:48:02 PM (15 years ago)
Author:
vboxsync
Message:

wddm: more impl

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp

    r26667 r26767  
    4747}
    4848
     49//VBOXVIDEOOFFSET vboxWddmVRAMAddressToOffset(PDEVICE_EXTENSION pDevExt, PHYSICAL_ADDRESS phAddress)
     50//{
     51//    Assert(phAddress.QuadPart >= VBE_DISPI_LFB_PHYSICAL_ADDRESS);
     52//    if (phAddress.QuadPart < VBE_DISPI_LFB_PHYSICAL_ADDRESS)
     53//        return VBOXVIDEOOFFSET_VOID;
     54//
     55//    VBOXVIDEOOFFSET off = phAddress.QuadPart - VBE_DISPI_LFB_PHYSICAL_ADDRESS;
     56//    Assert(off < pDevExt->u.primary.cbVRAM);
     57//    if (off >= pDevExt->u.primary.cbVRAM)
     58//        return VBOXVIDEOOFFSET_VOID;
     59//
     60//    return off;
     61//}
     62
     63VBOXVIDEOOFFSET vboxWddmValidatePrimary(PVBOXWDDM_ALLOCATION pAllocation)
     64{
     65    Assert(pAllocation);
     66    if (!pAllocation)
     67    {
     68        drprintf((__FUNCTION__": no allocation specified for Source\n"));
     69        return VBOXVIDEOOFFSET_VOID;
     70    }
     71
     72    Assert(pAllocation->SegmentId);
     73    if (!pAllocation->SegmentId)
     74    {
     75        drprintf((__FUNCTION__": allocation is not paged in\n"));
     76        return VBOXVIDEOOFFSET_VOID;
     77    }
     78
     79    VBOXVIDEOOFFSET offVram = pAllocation->offVram;
     80    Assert(offVram != VBOXVIDEOOFFSET_VOID);
     81    if (offVram == VBOXVIDEOOFFSET_VOID)
     82        drprintf((__FUNCTION__": VRAM pffset is not defined\n"));
     83
     84    return offVram;
     85}
     86
     87NTSTATUS vboxWddmGhDisplayPostInfoScreen (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
     88{
     89    VBOXVIDEOOFFSET offVram = pAllocation->offVram;
     90    Assert(offVram != VBOXVIDEOOFFSET_VOID);
     91    if (offVram == VBOXVIDEOOFFSET_VOID)
     92        return STATUS_INVALID_PARAMETER;
     93
     94    PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
     95    /* Issue the screen info command. */
     96    void *p = vboxHGSMIBufferAlloc (pDevExt,
     97                                      sizeof (VBVAINFOSCREEN),
     98                                      HGSMI_CH_VBVA,
     99                                      VBVA_INFO_SCREEN);
     100    Assert(p);
     101    if (p)
     102    {
     103        VBVAINFOSCREEN *pScreen = (VBVAINFOSCREEN *)p;
     104
     105        pScreen->u32ViewIndex    = pPrimaryInfo->VidPnSourceId;
     106        pScreen->i32OriginX      = 0;
     107        pScreen->i32OriginY      = 0;
     108        pScreen->u32StartOffset  = offVram;
     109        pScreen->u32LineSize     = pAllocation->u.SurfInfo.pitch;
     110        pScreen->u32Width        = pAllocation->u.SurfInfo.width;
     111        pScreen->u32Height       = pAllocation->u.SurfInfo.height;
     112        pScreen->u16BitsPerPixel = (uint16_t)pAllocation->u.SurfInfo.bpp;
     113        pScreen->u16Flags        = VBVA_SCREEN_F_ACTIVE;
     114
     115        vboxHGSMIBufferSubmit (pDevExt, p);
     116
     117        vboxHGSMIBufferFree (pDevExt, p);
     118    }
     119
     120    return STATUS_SUCCESS;
     121}
     122
     123NTSTATUS vboxWddmGhDisplayPostInfoView (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
     124{
     125    VBOXVIDEOOFFSET offVram = pAllocation->offVram;
     126    Assert(offVram != VBOXVIDEOOFFSET_VOID);
     127    if (offVram == VBOXVIDEOOFFSET_VOID)
     128        return STATUS_INVALID_PARAMETER;
     129
     130    PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
     131    /* Issue the screen info command. */
     132    void *p = vboxHGSMIBufferAlloc (pDevExt,
     133                                      sizeof (VBVAINFOVIEW),
     134                                      HGSMI_CH_VBVA,
     135                                      VBVA_INFO_VIEW);
     136    Assert(p);
     137    if (p)
     138    {
     139        VBVAINFOVIEW *pView = (VBVAINFOVIEW *)p;
     140
     141        pView->u32ViewIndex     = pPrimaryInfo->VidPnSourceId;
     142        pView->u32ViewOffset    = offVram;
     143        pView->u32ViewSize      = vboxWddmVramReportedSize(pDevExt)/pDevExt->u.primary.cDisplays;
     144
     145        pView->u32MaxScreenSize = pView->u32ViewSize;
     146
     147        vboxHGSMIBufferSubmit (pDevExt, p);
     148
     149        vboxHGSMIBufferFree (pDevExt, p);
     150    }
     151
     152    return STATUS_SUCCESS;
     153}
     154
     155NTSTATUS vboxWddmGhDisplaySetMode (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
     156{
     157    PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
     158    if (pPrimaryInfo->VidPnSourceId)
     159        return STATUS_SUCCESS;
     160
     161    if (VBoxVideoSetCurrentModePerform(pDevExt, pAllocation->u.SurfInfo.width,
     162            pAllocation->u.SurfInfo.height, pAllocation->u.SurfInfo.bpp))
     163        return STATUS_SUCCESS;
     164
     165    AssertBreakpoint();
     166    drprintf((__FUNCTION__": VBoxVideoSetCurrentModePerform failed\n"));
     167    return STATUS_UNSUCCESSFUL;
     168}
     169
     170
     171NTSTATUS vboxWddmGhDisplaySetInfo(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource)
     172{
     173    PVBOXWDDM_ALLOCATION pAllocation = pSource->pAllocation;
     174    VBOXVIDEOOFFSET offVram = vboxWddmValidatePrimary(pAllocation);
     175    Assert(offVram != VBOXVIDEOOFFSET_VOID);
     176    if (offVram == VBOXVIDEOOFFSET_VOID)
     177        return STATUS_INVALID_PARAMETER;
     178
     179    /*
     180     * Set the current mode into the hardware.
     181     */
     182    NTSTATUS Status = vboxWddmGhDisplaySetMode (pDevExt, pAllocation);
     183    Assert(Status == STATUS_SUCCESS);
     184    if (Status == STATUS_SUCCESS)
     185    {
     186        Status = vboxWddmGhDisplayPostInfoView (pDevExt, pAllocation);
     187        Assert(Status == STATUS_SUCCESS);
     188        if (Status == STATUS_SUCCESS)
     189        {
     190            Status = vboxWddmGhDisplayPostInfoScreen (pDevExt, pAllocation);
     191            Assert(Status == STATUS_SUCCESS);
     192            if (Status != STATUS_SUCCESS)
     193                drprintf((__FUNCTION__": vboxWddmGhDisplayPostInfoScreen failed\n"));
     194        }
     195        else
     196            drprintf((__FUNCTION__": vboxWddmGhDisplayPostInfoView failed\n"));
     197    }
     198    else
     199        drprintf((__FUNCTION__": vboxWddmGhDisplaySetMode failed\n"));
     200
     201    return Status;
     202}
     203
    49204#if 0
    50 void 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 }
    85205
    86206NTSTATUS vboxWddmGhInitPrimary(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId, D3DKMDT_VIDPN_SOURCE_MODE *pVidPnSourceModeInfo)
     
    11071227                /* make sure the size is page aligned */
    11081228                /* @todo: need to setup VBVA buffers and adjust the mem size here */
    1109                 pQsOut->pSegmentDescriptor->Size = (pContext->u.primary.cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE - pContext->u.primary.cbMiniportHeap) & (~0xfffUL);
     1229                pQsOut->pSegmentDescriptor->Size = vboxWddmVramReportedSize(pContext);
    11101230                pQsOut->pSegmentDescriptor->NbOfBanks = 0;
    11111231                pQsOut->pSegmentDescriptor->pBankRangeTable = 0;
     
    15171637        Assert(pPatchList->AllocationIndex < pPatch->AllocationListSize);
    15181638        const DXGK_ALLOCATIONLIST *pAllocationList = &pPatch->pAllocationList[pPatchList->AllocationIndex];
    1519         if (pAllocationList->PhysicalAddress.QuadPart)
     1639        if (pAllocationList->SegmentId)
    15201640        {
    15211641            Assert(pPatchList->PatchOffset < (pPatch->DmaBufferPrivateDataSubmissionEndOffset - pPatch->DmaBufferPrivateDataSubmissionStartOffset));
    1522             *((PHYSICAL_ADDRESS*)(pBuf+pPatchList->PatchOffset)) = pAllocationList->PhysicalAddress;
     1642            *((VBOXVIDEOOFFSET*)(pBuf+pPatchList->PatchOffset)) = (VBOXVIDEOOFFSET)pAllocationList->PhysicalAddress.QuadPart;
    15231643        }
    15241644        else
     
    20792199            Assert(pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE);
    20802200            PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
    2081             pAllocation->phAddress = pSetVidPnSourceAddress->PrimaryAddress;
     2201            pAllocation->offVram = (VBOXVIDEOOFFSET)pSetVidPnSourceAddress->PrimaryAddress.QuadPart;
     2202            pAllocation->SegmentId = pSetVidPnSourceAddress->PrimarySegment;
     2203            Assert (pAllocation->SegmentId);
    20822204            Assert (!pPrimary->bVisible);
    20832205            if (pPrimary->bVisible)
    20842206            {
    2085                 /* @todo: should not generally happen, but still inform host*/
     2207                /* should not generally happen, but still inform host*/
     2208                Status = vboxWddmGhDisplaySetInfo(pDevExt, pSource);
     2209                Assert(Status == STATUS_SUCCESS);
     2210                if (Status != STATUS_SUCCESS)
     2211                    drprintf((__FUNCTION__": vboxWddmGhDisplaySetInfo failed, Status (0x%x)\n", Status));
    20862212            }
    20872213        }
     
    21102236    )
    21112237{
    2112     return STATUS_NOT_IMPLEMENTED;
     2238    /* DxgkDdiSetVidPnSourceVisibility should be made pageable. */
     2239    PAGED_CODE();
     2240
     2241    dfprintf(("==> "__FUNCTION__ ", context(0x%x)\n", hAdapter));
     2242
     2243    NTSTATUS Status = STATUS_SUCCESS;
     2244    PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
     2245    Assert(pDevExt->cSources > pSetVidPnSourceVisibility->VidPnSourceId);
     2246    if (pDevExt->cSources > pSetVidPnSourceVisibility->VidPnSourceId)
     2247    {
     2248        PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pSetVidPnSourceVisibility->VidPnSourceId];
     2249        PVBOXWDDM_ALLOCATION pAllocation = pSource->pAllocation;
     2250        PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
     2251
     2252        Assert(pPrimary->bVisible != pSetVidPnSourceVisibility->Visible);
     2253        if (pPrimary->bVisible != pSetVidPnSourceVisibility->Visible)
     2254        {
     2255            pPrimary->bVisible = pSetVidPnSourceVisibility->Visible;
     2256            if (pPrimary->bVisible)
     2257            {
     2258                Status = vboxWddmGhDisplaySetInfo(pDevExt, pSource);
     2259                Assert(Status == STATUS_SUCCESS);
     2260                if (Status != STATUS_SUCCESS)
     2261                    drprintf((__FUNCTION__": vboxWddmGhDisplaySetInfo failed, Status (0x%x)\n", Status));
     2262            }
     2263        }
     2264    }
     2265    else
     2266    {
     2267        drprintf((__FUNCTION__": invalid VidPnSourceId (%d), should be smaller than (%d)\n", pSetVidPnSourceVisibility->VidPnSourceId, pDevExt->cSources));
     2268        Status = STATUS_INVALID_PARAMETER;
     2269    }
     2270
     2271    dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
     2272
     2273    return Status;
    21132274}
    21142275
     
    21202281    )
    21212282{
     2283
    21222284    return STATUS_NOT_IMPLEMENTED;
    21232285}
     
    23682530                    if (vboxWddmPixFormatConversionSupported(pSrcAlloc->u.SurfInfo.format, pDstAlloc->u.SurfInfo.format))
    23692531                    {
    2370                         memset(pPresent->pPatchLocationListOut, 0, 3*sizeof (D3DDDI_PATCHLOCATIONLIST));
    2371                         pPresent->pPatchLocationListOut->PatchOffset = 0;
     2532                        memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST));
     2533//                        pPresent->pPatchLocationListOut->PatchOffset = 0;
     2534//                        ++pPresent->pPatchLocationListOut;
     2535                        pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, offSrc);
     2536                        pPresent->pPatchLocationListOut->AllocationIndex = 0;
    23722537                        ++pPresent->pPatchLocationListOut;
    2373                         pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, phSrc);
    2374                         pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_SOURCE_INDEX;
    2375                         ++pPresent->pPatchLocationListOut;
    2376                         pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, phDst);
    2377                         pPresent->pPatchLocationListOut->AllocationIndex = DXGK_PRESENT_DESTINATION_INDEX;
     2538                        pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, offDst);
     2539                        pPresent->pPatchLocationListOut->AllocationIndex = 1;
    23782540                        ++pPresent->pPatchLocationListOut;
    23792541
     
    23812543                        pCmd->u32CmdSpecific = 0;
    23822544                        PVBOXVDMACMD_DMA_PRESENT_BLT pTransfer = VBOXVDMACMD_BODY(pCmd, VBOXVDMACMD_DMA_PRESENT_BLT);
    2383                         pTransfer->phSrc = pSrc->PhysicalAddress.QuadPart;
    2384                         pTransfer->phDst = pDst->PhysicalAddress.QuadPart;
     2545                        pTransfer->offSrc = (VBOXVIDEOOFFSET)pSrc->PhysicalAddress.QuadPart;
     2546                        pTransfer->offDst = (VBOXVIDEOOFFSET)pDst->PhysicalAddress.QuadPart;
    23852547                        vboxWddmSurfDescFromAllocation(pSrcAlloc, &pTransfer->srcDesc);
    23862548                        vboxWddmSurfDescFromAllocation(pDstAlloc, &pTransfer->dstDesc);
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.h

    r26667 r26767  
    6767{
    6868    VBOXWDDM_ALLOC_TYPE enmType;
    69     PHYSICAL_ADDRESS phAddress;
    70     BOOLEAN bPagedIn;
     69    VBOXVIDEOOFFSET offVram;
     70    UINT SegmentId;
    7171    union
    7272    {
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