VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.h@ 76553

Last change on this file since 76553 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
1/* $Id: VBoxMPWddm.h 76553 2019-01-01 01:45:53Z vboxsync $ */
2/** @file
3 * VBox WDDM Miniport driver
4 */
5
6/*
7 * Copyright (C) 2011-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___VBoxMPWddm_h___
19#define ___VBoxMPWddm_h___
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#define VBOX_WDDM_DRIVERNAME L"VBoxWddm"
25
26#ifndef DEBUG_misha
27# ifdef Assert
28# error "VBoxMPWddm.h must be included first."
29# endif
30# define RT_NO_STRICT
31#endif
32#include "common/VBoxMPUtils.h"
33#include "common/VBoxMPDevExt.h"
34#include "../../common/VBoxVideoTools.h"
35
36//#define VBOXWDDM_DEBUG_VIDPN
37
38#define VBOXWDDM_CFG_DRV_DEFAULT 0
39#define VBOXWDDM_CFG_DRV_SECONDARY_TARGETS_CONNECTED 1
40
41#define VBOXWDDM_CFG_DRVTARGET_CONNECTED 1
42
43#define VBOXWDDM_CFG_LOG_UM_BACKDOOR 0x00000001
44#define VBOXWDDM_CFG_LOG_UM_DBGPRINT 0x00000002
45#define VBOXWDDM_CFG_STR_LOG_UM L"VBoxLogUm"
46
47#define VBOXWDDM_REG_DRV_FLAGS_NAME L"VBoxFlags"
48#define VBOXWDDM_REG_DRV_DISPFLAGS_PREFIX L"VBoxDispFlags"
49
50#define VBOXWDDM_REG_DRVKEY_PREFIX L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Class\\"
51
52#define VBOXWDDM_REG_DISPLAYSETTINGSVIDEOKEY L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video\\"
53#define VBOXWDDM_REG_DISPLAYSETTINGSVIDEOKEY_SUBKEY L"\\Video"
54
55
56#define VBOXWDDM_REG_DISPLAYSETTINGSKEY_PREFIX_VISTA L"\\Registry\\Machine\\System\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Control\\VIDEO\\"
57#define VBOXWDDM_REG_DISPLAYSETTINGSKEY_PREFIX_WIN7 L"\\Registry\\Machine\\System\\CurrentControlSet\\Hardware Profiles\\UnitedVideo\\CONTROL\\VIDEO\\"
58#define VBOXWDDM_REG_DISPLAYSETTINGSKEY_PREFIX_WIN10_17763 L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\UnitedVideo\\CONTROL\\VIDEO\\"
59
60#define VBOXWDDM_REG_DISPLAYSETTINGS_ATTACH_RELX L"Attach.RelativeX"
61#define VBOXWDDM_REG_DISPLAYSETTINGS_ATTACH_RELY L"Attach.RelativeY"
62#define VBOXWDDM_REG_DISPLAYSETTINGS_ATTACH_DESKTOP L"Attach.ToDesktop"
63
64extern DWORD g_VBoxLogUm;
65
66RT_C_DECLS_BEGIN
67NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath);
68RT_C_DECLS_END
69
70PVOID vboxWddmMemAlloc(IN SIZE_T cbSize);
71PVOID vboxWddmMemAllocZero(IN SIZE_T cbSize);
72VOID vboxWddmMemFree(PVOID pvMem);
73
74NTSTATUS vboxWddmCallIsr(PVBOXMP_DEVEXT pDevExt);
75
76DECLINLINE(PVBOXWDDM_RESOURCE) vboxWddmResourceForAlloc(PVBOXWDDM_ALLOCATION pAlloc)
77{
78#if 0
79 if(pAlloc->iIndex == VBOXWDDM_ALLOCATIONINDEX_VOID)
80 return NULL;
81 PVBOXWDDM_RESOURCE pRc = (PVBOXWDDM_RESOURCE)(((uint8_t*)pAlloc) - RT_OFFSETOF(VBOXWDDM_RESOURCE, aAllocations[pAlloc->iIndex]));
82 return pRc;
83#else
84 return pAlloc->pResource;
85#endif
86}
87
88VOID vboxWddmAllocationDestroy(PVBOXWDDM_ALLOCATION pAllocation);
89
90DECLINLINE(BOOLEAN) vboxWddmAddrSetVram(PVBOXWDDM_ADDR pAddr, UINT SegmentId, VBOXVIDEOOFFSET offVram)
91{
92 if (pAddr->SegmentId == SegmentId && pAddr->offVram == offVram)
93 return FALSE;
94
95 pAddr->SegmentId = SegmentId;
96 pAddr->offVram = offVram;
97 return TRUE;
98}
99
100DECLINLINE(bool) vboxWddmAddrVramEqual(const VBOXWDDM_ADDR *pAddr1, const VBOXWDDM_ADDR *pAddr2)
101{
102 return pAddr1->SegmentId == pAddr2->SegmentId && pAddr1->offVram == pAddr2->offVram;
103}
104
105DECLINLINE(VBOXVIDEOOFFSET) vboxWddmVramAddrToOffset(PVBOXMP_DEVEXT pDevExt, PHYSICAL_ADDRESS Addr)
106{
107 PVBOXMP_COMMON pCommon = VBoxCommonFromDeviceExt(pDevExt);
108 AssertRelease(pCommon->phVRAM.QuadPart <= Addr.QuadPart);
109 return (VBOXVIDEOOFFSET)Addr.QuadPart - pCommon->phVRAM.QuadPart;
110}
111
112DECLINLINE(VOID) vboxWddmAssignPrimary(PVBOXWDDM_SOURCE pSource, PVBOXWDDM_ALLOCATION pAllocation,
113 D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
114{
115 RT_NOREF(srcId);
116
117 /* vboxWddmAssignPrimary can not be run in reentrant order, so safely do a direct unlocked check here */
118 if (pSource->pPrimaryAllocation == pAllocation)
119 return;
120
121 if (pSource->pPrimaryAllocation)
122 {
123 PVBOXWDDM_ALLOCATION pOldAlloc = pSource->pPrimaryAllocation;
124 /* clear the visibility info fo the current primary */
125 pOldAlloc->bVisible = FALSE;
126 pOldAlloc->bAssigned = FALSE;
127 Assert(pOldAlloc->AllocData.SurfDesc.VidPnSourceId == srcId);
128 }
129
130 if (pAllocation)
131 {
132 Assert(pAllocation->AllocData.SurfDesc.VidPnSourceId == srcId);
133 pAllocation->bAssigned = TRUE;
134 pAllocation->bVisible = pSource->bVisible;
135
136 if (pSource->AllocData.hostID != pAllocation->AllocData.hostID)
137 {
138 pSource->u8SyncState &= ~VBOXWDDM_HGSYNC_F_SYNCED_LOCATION; /* force guest->host notification */
139 pSource->AllocData.hostID = pAllocation->AllocData.hostID;
140 }
141
142 if (!vboxWddmAddrVramEqual(&pSource->AllocData.Addr, &pAllocation->AllocData.Addr))
143 {
144 if (!pAllocation->AllocData.hostID)
145 pSource->u8SyncState &= ~VBOXWDDM_HGSYNC_F_SYNCED_LOCATION; /* force guest->host notification */
146
147 pSource->AllocData.Addr = pAllocation->AllocData.Addr;
148 }
149 }
150 else
151 {
152 pSource->u8SyncState &= ~VBOXWDDM_HGSYNC_F_SYNCED_LOCATION; /* force guest->host notification */
153 /*ensure we do not refer to the deleted host id */
154 pSource->AllocData.hostID = 0;
155 }
156
157 KIRQL OldIrql;
158 KeAcquireSpinLock(&pSource->AllocationLock, &OldIrql);
159 pSource->pPrimaryAllocation = pAllocation;
160 KeReleaseSpinLock(&pSource->AllocationLock, OldIrql);
161}
162
163DECLINLINE(VBOXVIDEOOFFSET) vboxWddmAddrFramOffset(const VBOXWDDM_ADDR *pAddr)
164{
165 return (pAddr->offVram != VBOXVIDEOOFFSET_VOID && pAddr->SegmentId) ?
166 (pAddr->SegmentId == 1 ? pAddr->offVram : 0)
167 : VBOXVIDEOOFFSET_VOID;
168}
169
170DECLINLINE(int) vboxWddmScreenInfoInit(VBVAINFOSCREEN RT_UNTRUSTED_VOLATILE_HOST *pScreen,
171 const VBOXWDDM_ALLOC_DATA *pAllocData, const POINT * pVScreenPos, uint16_t fFlags)
172{
173 VBOXVIDEOOFFSET offVram = vboxWddmAddrFramOffset(&pAllocData->Addr);
174 if (offVram == VBOXVIDEOOFFSET_VOID && !(fFlags & (VBVA_SCREEN_F_DISABLED | VBVA_SCREEN_F_BLANK2)))
175 {
176 WARN(("offVram == VBOXVIDEOOFFSET_VOID"));
177 return VERR_INVALID_PARAMETER;
178 }
179
180 pScreen->u32ViewIndex = pAllocData->SurfDesc.VidPnSourceId;
181 pScreen->i32OriginX = pVScreenPos->x;
182 pScreen->i32OriginY = pVScreenPos->y;
183 pScreen->u32StartOffset = (uint32_t)offVram;
184 pScreen->u32LineSize = pAllocData->SurfDesc.pitch;
185 pScreen->u32Width = pAllocData->SurfDesc.width;
186 pScreen->u32Height = pAllocData->SurfDesc.height;
187 pScreen->u16BitsPerPixel = (uint16_t)pAllocData->SurfDesc.bpp;
188 pScreen->u16Flags = fFlags;
189
190 return VINF_SUCCESS;
191}
192
193bool vboxWddmGhDisplayCheckSetInfoFromSource(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SOURCE pSource);
194
195#ifdef VBOX_WITH_CROGL
196#define VBOXWDDMENTRY_2_SWAPCHAIN(_pE) ((PVBOXWDDM_SWAPCHAIN)((uint8_t*)(_pE) - RT_UOFFSETOF(VBOXWDDM_SWAPCHAIN, DevExtListEntry)))
197
198BOOLEAN DxgkDdiInterruptRoutineNew(
199 IN CONST PVOID MiniportDeviceContext,
200 IN ULONG MessageNumber
201 );
202#endif
203
204#define VBOXWDDM_IS_DISPLAYONLY() (g_VBoxDisplayOnly)
205
206# define VBOXWDDM_IS_FB_ALLOCATION(_pDevExt, _pAlloc) ((_pAlloc)->bAssigned)
207
208# define VBOXWDDM_FB_ALLOCATION(_pDevExt, _pSrc) ((_pSrc)->pPrimaryAllocation)
209
210#define VBOXWDDM_CTXLOCK_INIT(_p) do { \
211 KeInitializeSpinLock(&(_p)->ContextLock); \
212 } while (0)
213#define VBOXWDDM_CTXLOCK_DATA KIRQL _ctxLockOldIrql;
214#define VBOXWDDM_CTXLOCK_LOCK(_p) do { \
215 KeAcquireSpinLock(&(_p)->ContextLock, &_ctxLockOldIrql); \
216 } while (0)
217#define VBOXWDDM_CTXLOCK_UNLOCK(_p) do { \
218 KeReleaseSpinLock(&(_p)->ContextLock, _ctxLockOldIrql); \
219 } while (0)
220
221#endif /* #ifndef ___VBoxMPWddm_h___ */
222
Note: See TracBrowser for help on using the repository browser.

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