Changeset 26556 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Miniport
- Timestamp:
- Feb 15, 2010 10:10:11 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57735
- 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 82 82 VBoxVideoWddm_NOINST = true 83 83 endif 84 84 85 VBoxVideoWddm_SDKS=WINDDKWLH 85 86 VBoxVideoWddm_DEFS += LOG_TO_BACKDOOR VBOX_WITH_8BPP_MODES 86 VBoxVideoWddm_DEFS += VBOX_WITH_HGSMI VBOXWDDM 87 VBoxVideoWddm_DEFS += VBOX_WITH_HGSMI VBOXWDDM VBOXVDMA 87 88 ifdef VBOX_WITH_VIDEOHWACCEL 88 89 VBoxVideoWddm_DEFS += VBOX_WITH_VIDEOHWACCEL … … 98 99 wddm/VBoxVideoWddm.cpp \ 99 100 wddm/VBoxVideoVidPn.cpp \ 101 wddm/VBoxVideoVdma.cpp \ 102 wddm/VBoxVideoShgsmi.cpp \ 100 103 wddm/VBoxVideoWddm.def \ 101 104 wddm/VBoxVideoWddm.rc -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
r26493 r26556 263 263 264 264 /* size of the VRAM in bytes */ 265 266 #ifndef VBOXWDDM 265 267 ULONG vramSize = DeviceExtension->pPrimary->u.primary.ulMaxFrameBufferSize; 266 267 gNumVideoModes = 0;268 #ifdef VBOXWDDM 268 #else 269 ULONG vramSize = vboxWddmVramReportedSize(DeviceExtension); 270 269 271 gPreferredVideoMode = 0; 270 272 #endif 273 274 gNumVideoModes = 0; 271 275 272 276 size_t numModesCurrentColorDepth; … … 751 755 || (gCustomXRes || gCustomYRes || gCustomBPP)) 752 756 { 757 #ifndef VBOXWDDM 753 758 dprintf(("VBoxVideo: adding custom video mode as #%d, current mode: %d \n", gNumVideoModes + 1, DeviceExtension->CurrentMode)); 754 759 /* handle the startup case */ 755 760 if (DeviceExtension->CurrentMode == 0) 761 #else 762 if (!DeviceExtension->cSources || !DeviceExtension->aSources[0].ulFrameBufferSize) 763 #endif 756 764 { 757 765 /* Use the stored custom resolution values only if nothing was read from host. … … 771 779 xres &= 0xfff8; 772 780 /* take the current values for the fields that are not set */ 781 #ifndef VBOXWDDM 773 782 if (DeviceExtension->CurrentMode != 0) 774 783 { … … 780 789 bpp = DeviceExtension->CurrentModeBPP; 781 790 } 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 782 802 783 803 /* Use a default value. */ … … 801 821 { 802 822 /* we need an alternating index */ 823 #ifndef VBOXWDDM 803 824 if (DeviceExtension->CurrentMode != 0) 825 #else 826 if (DeviceExtension->cSources && DeviceExtension->aSources[0].ulFrameBufferSize) 827 #endif 804 828 { 805 829 if (gInvocationCounter % 2) … … 877 901 878 902 /* for the startup case, we need this mode twice due to the alternating mode number */ 903 #ifndef VBOXWDDM 879 904 if (DeviceExtension->CurrentMode == 0) 905 #else 906 if (!DeviceExtension->cSources || !DeviceExtension->aSources[0].ulFrameBufferSize) 907 #endif 880 908 { 881 909 dprintf(("VBoxVideo: making a copy of the custom mode as #%d\n", gNumVideoModes + 1)); … … 918 946 { 919 947 int i; 948 #ifndef VBOXWDDM 920 949 dprintf(("VBoxVideo: VideoModes (CurrentMode = %d)\n", DeviceExtension->CurrentMode)); 950 #endif 921 951 for (i=0; i<MAX_VIDEO_MODES + 2; i++) 922 952 { … … 965 995 } 966 996 967 #e ndif997 #else 968 998 969 999 /* Computes the size of a framebuffer. DualView has a few framebuffers of the computed size. */ … … 1033 1063 } 1034 1064 } 1065 1066 #endif 1035 1067 1036 1068 int VBoxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension, void **ppv, ULONG ulOffset, ULONG ulSize) … … 1087 1119 VideoPortUnmapMemory(PrimaryExtension, *ppv, NULL); 1088 1120 #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); 1090 1124 #endif 1091 1125 } … … 2430 2464 } 2431 2465 2432 #ifndef VBOXWDDM2433 2434 2466 /** 2435 2467 * VBoxVideoSetCurrentMode … … 2438 2470 */ 2439 2471 BOOLEAN 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 2442 2481 PVIDEO_MODE_INFORMATION ModeInfo; 2443 2482 … … 2459 2498 return TRUE; 2460 2499 } 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 2461 2510 2462 2511 /* set the mode characteristics */ … … 2481 2530 } 2482 2531 2532 #ifndef VBOXWDDM 2533 2483 2534 /* 2484 2535 * VBoxVideoResetDevice … … 2677 2728 return TRUE; 2678 2729 } 2730 2731 #ifndef VBOXWDDM 2679 2732 2680 2733 VP_STATUS VBoxVideoGetChildDescriptor( … … 2870 2923 return rc; 2871 2924 } 2925 #endif -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
r26505 r26556 117 117 #else 118 118 #include <VBox/VBoxVideo.h> 119 #include "wddm/VBoxVideoShgsmi.h" 120 #include "wddm/VBoxVideoVdma.h" 119 121 120 122 typedef KSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK; … … 125 127 typedef HANDLE VBOXCMNREG; 126 128 127 typedef enum128 {129 VBOXWDDM_CMD_UNEFINED = 0,130 VBOXWDDM_CMD_DMA_TRANSFER131 } VBOXWDDM_CMD_TYPE;132 133 129 typedef struct VBOXWDDM_SOURCE 134 130 { 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. */ 137 137 } VBOXWDDM_SOURCE, *PVBOXWDDM_SOURCE; 138 138 … … 211 211 DXGK_DEVICEINFO DeviceInfo; 212 212 } VBOXWDDM_DEVICE, *PVBOXWDDM_DEVICE; 213 214 213 #endif 215 214 … … 219 218 * The primary extension is the first one. 220 219 */ 221 220 #ifndef VBOXWDDM 222 221 struct _DEVICE_EXTENSION *pPrimary; /* Pointer to the primary device extension. */ 223 222 224 223 ULONG iDevice; /* Device index: 0 for primary, otherwise a secondary device. */ 225 226 224 227 225 ULONG CurrentMode; /* Saved information about video modes */ … … 232 230 ULONG ulFrameBufferOffset; /* The framebuffer position in the VRAM. */ 233 231 ULONG ulFrameBufferSize; /* The size of the current framebuffer. */ 234 232 #endif 235 233 union { 236 234 /* Information that is only relevant to the primary device or is the same for all devices. */ … … 258 256 * This is mapped by miniport separately. 259 257 */ 258 #ifdef VBOXWDDM 259 VBOXVDMAINFO Vdma; 260 #endif 261 260 262 #ifdef VBOX_WITH_HGSMI 261 263 volatile HGSMIHOSTFLAGS * pHostFlags; /* HGSMI host flags */ … … 315 317 PDEVICE_OBJECT pPDO; 316 318 319 VBOXSHGSMILIST CtlList; 320 VBOXSHGSMILIST DmaCmdList; 321 BOOL bSetNotifyDxDpc; 322 BOOL bNotifyDxDpc; 323 317 324 ULONG cSources; 318 325 /* currently we define the array for the max possible size since we do not know … … 326 333 } DEVICE_EXTENSION, *PDEVICE_EXTENSION; 327 334 335 #ifndef VBOXWDDM 328 336 #define DEV_MOUSE_HIDDEN(dev) ((dev)->pPrimary->u.primary.fMouseHidden) 329 337 #define DEV_SET_MOUSE_HIDDEN(dev) \ … … 335 343 (dev)->pPrimary->u.primary.fMouseHidden = FALSE; \ 336 344 } while (0) 337 345 #else 346 #define DEV_MOUSE_HIDDEN(dev) ((dev)->u.primary.fMouseHidden) 347 #define DEV_SET_MOUSE_HIDDEN(dev) \ 348 do { \ 349 (dev)->u.primary.fMouseHidden = TRUE; \ 350 } while (0) 351 #define DEV_SET_MOUSE_SHOWN(dev) \ 352 do { \ 353 (dev)->u.primary.fMouseHidden = FALSE; \ 354 } while (0) 355 #endif 338 356 extern "C" 339 357 { … … 626 644 VOID VBoxWddmGetModesTable(PDEVICE_EXTENSION DeviceExtension, bool bRebuildTable, 627 645 VIDEO_MODE_INFORMATION ** ppModes, uint32_t * pcModes, uint32_t * pPreferrableMode, 628 D3DKMDT_2DREGION **p Resolutions, uint32_t * pcResolutions);646 D3DKMDT_2DREGION **ppResolutions, uint32_t * pcResolutions); 629 647 630 648 D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo); 631 649 UINT vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format); 650 651 DECLINLINE(ULONG) vboxWddmVramReportedSize(PDEVICE_EXTENSION pDevExt) 652 { 653 return pDevExt->u.primary.Vdma.CmdHeap.area.offBase; 654 } 632 655 633 656 NTSTATUS vboxVidPnCheckTopology(const D3DKMDT_HVIDPN hDesiredVidPn, … … 764 787 DECLINLINE(void) VBoxHGSMIHostWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data) 765 788 { 789 #ifndef VBOXWDDM 766 790 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost, data); 791 #else 792 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->u.primary.IOPortHost, data); 793 #endif 767 794 } 768 795 769 796 DECLINLINE(ULONG) VBoxHGSMIHostRead(PDEVICE_EXTENSION PrimaryExtension) 770 797 { 798 #ifndef VBOXWDDM 771 799 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost); 800 #else 801 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->u.primary.IOPortHost); 802 #endif 772 803 } 773 804 774 805 DECLINLINE(void) VBoxHGSMIGuestWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data) 775 806 { 807 #ifndef VBOXWDDM 776 808 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest, data); 809 #else 810 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->u.primary.IOPortGuest, data); 811 #endif 777 812 } 778 813 779 814 DECLINLINE(ULONG) VBoxHGSMIGuestRead(PDEVICE_EXTENSION PrimaryExtension) 780 815 { 816 #ifndef VBOXWDDM 781 817 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest); 818 #else 819 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->u.primary.IOPortGuest); 820 #endif 782 821 } 783 822 … … 792 831 PVIDEO_POINTER_ATTRIBUTES pointerAttr, 793 832 uint32_t cbLength); 833 #ifndef VBOXWDDM 794 834 DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd); 795 835 DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd); 836 #endif 796 837 797 838 -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp
r26505 r26556 186 186 typedef FNHGSMICALLFINALIZE *PFNHGSMICALLFINALIZE; 187 187 188 void* 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 199 void* 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 210 void 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 218 int 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 188 234 static int vboxCallChannel (PDEVICE_EXTENSION PrimaryExtension, 189 235 uint8_t u8Ch, … … 197 243 198 244 /* Allocate the IO buffer. */ 245 #ifndef VBOXWDDM 199 246 if (PrimaryExtension->pPrimary != PrimaryExtension) 200 247 { … … 202 249 return VERR_INVALID_PARAMETER; 203 250 } 251 #endif 204 252 205 253 void *p = HGSMIHeapAlloc (&PrimaryExtension->u.primary.hgsmiAdapterHeap, cbData, u8Ch, u16Op); … … 315 363 return rc; 316 364 } 317 365 #ifndef VBOXWDDM 318 366 static int vbvaInitInfoDisplay (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData) 319 367 { … … 348 396 return VERR_INTERNAL_ERROR; 349 397 } 398 #endif 350 399 351 400 static int vbvaInitInfoHeap (PDEVICE_EXTENSION PrimaryExtension, void *pvContext, void *pvData) … … 389 438 if(RT_SUCCESS (rc)) 390 439 { 440 #ifndef VBOXWDDM 391 441 rc = vboxCallVBVA (PrimaryExtension, 392 442 VBVA_INFO_VIEW, … … 397 447 AssertRC(rc); 398 448 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 399 454 { 400 455 /* Report the host heap location. */ … … 660 715 */ 661 716 PrimaryExtension->pNext = NULL; 717 #ifndef VBOXWDDM 662 718 PrimaryExtension->pPrimary = PrimaryExtension; 663 719 PrimaryExtension->iDevice = 0; 664 720 PrimaryExtension->ulFrameBufferOffset = 0; 665 721 PrimaryExtension->ulFrameBufferSize = 0; 722 #endif 666 723 PrimaryExtension->u.primary.ulVbvaEnabled = 0; 667 724 PrimaryExtension->u.primary.bVBoxVideoSupported = FALSE; … … 861 918 } 862 919 920 #ifndef VBOXWDDM 863 921 /* Now when the number of monitors is known and extensions are created, 864 922 * calculate the layout of framebuffers. 865 923 */ 866 924 VBoxComputeFrameBufferSizes (PrimaryExtension); 925 #endif 867 926 868 927 if (PrimaryExtension->u.primary.bHGSMI) … … 876 935 } 877 936 } 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 878 971 879 972 if (!PrimaryExtension->u.primary.bHGSMI) … … 953 1046 uint32_t cbLength) 954 1047 { 1048 #ifndef VBOXWDDM 955 1049 PDEVICE_EXTENSION PrimaryExtension = DeviceExtension->pPrimary; 956 1050 … … 977 1071 return TRUE; 978 1072 } 1073 #else 1074 PDEVICE_EXTENSION PrimaryExtension = DeviceExtension; 1075 #endif 979 1076 980 1077 uint32_t cbData = 0; … … 1116 1213 } 1117 1214 1215 #ifndef VBOXWDDM 1118 1216 DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd) 1119 1217 { … … 1164 1262 return VERR_INVALID_PARAMETER; 1165 1263 } 1264 #endif 1166 1265 1167 1266 static DECLCALLBACK(int) vboxVBVAChannelGenericHandler(void *pvHandler, uint16_t u16ChannelInfo, void *pvBuffer, HGSMISIZE cbBuffer) -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVidPn.cpp
r26324 r26556 508 508 pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Numerator = 60000; 509 509 pNewVidPnTargetModeInfo->VideoSignalInfo.VSyncFreq.Denominator = 1000; 510 pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Numerator = pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy * 6 0 * 1.05;510 pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Numerator = pNewVidPnTargetModeInfo->VideoSignalInfo.ActiveSize.cy * 63; /* 63 is (60 * 1.05)*/ 511 511 pNewVidPnTargetModeInfo->VideoSignalInfo.HSyncFreq.Denominator = 1; 512 512 pNewVidPnTargetModeInfo->VideoSignalInfo.PixelRate = 165000; /* @todo: ? */ … … 543 543 if (Status == STATUS_SUCCESS) 544 544 { 545 if ( iPreferredMomde == i)545 if (bPreferred) 546 546 { 547 547 Status = pNewVidPnTargetModeSetInterface->pfnPinMode(hNewVidPnTargetModeSet, modeId); -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r26324 r26556 39 39 ExFreePool(pvMem); 40 40 } 41 42 void 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 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 } 85 86 NTSTATUS 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 278 HGSMIHEAP* 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 287 typedef 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 294 VBOXWDDM_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 41 303 42 304 #define VBOXWDDM_REG_DRVKEY_PREFIX L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Class\\" … … 491 753 ) 492 754 { 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 834 typedef struct VBOXWDDM_DPCDATA 835 { 836 VBOXSHGSMILIST CtlList; 837 VBOXSHGSMILIST DmaCmdList; 838 BOOL bNotifyDpc; 839 } VBOXWDDM_DPCDATA, *PVBOXWDDM_DPCDATA; 840 841 typedef struct VBOXWDDM_GETDPCDATA_CONTEXT 842 { 843 PDEVICE_EXTENSION pDevExt; 844 VBOXWDDM_DPCDATA data; 845 } VBOXWDDM_GETDPCDATA_CONTEXT, *PVBOXWDDM_GETDPCDATA_CONTEXT; 846 847 BOOLEAN 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; 494 856 } 495 857 … … 498 860 ) 499 861 { 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); 501 890 } 502 891 … … 976 1365 } 977 1366 1367 /** 1368 * 1369 */ 978 1370 NTSTATUS 979 1371 APIENTRY … … 1507 1899 VBOXVIDPNCOFUNCMODALITY CbContext = {0}; 1508 1900 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 */); 1510 1908 Assert(CbContext.cModes); 1511 1909 Assert(CbContext.cModes > CbContext.iPreferredMode);
Note:
See TracChangeset
for help on using the changeset viewer.