VirtualBox

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

Last change on this file since 85817 was 84658, checked in by vboxsync, 5 years ago

WDDM: allow to change the refresh rate for debug purposes.

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