VirtualBox

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

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

Additions/win: Win10 build 17763 uses different registry key to store desktop layout, fixed path to that key, bugref:9266

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