VirtualBox

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

Last change on this file since 52350 was 52350, checked in by vboxsync, 10 years ago

more resize fixes, dumper fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.8 KB
Line 
1/* $Id: VBoxMPWddm.h 52350 2014-08-11 18:30:55Z vboxsync $ */
2/** @file
3 * VBox WDDM Miniport driver
4 */
5
6/*
7 * Copyright (C) 2011-2013 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#ifdef VBOX_WDDM_WIN8
22# define VBOX_WDDM_DRIVERNAME L"VBoxVideoW8"
23#else
24# define VBOX_WDDM_DRIVERNAME L"VBoxVideoWddm"
25#endif
26
27#ifndef DEBUG_misha
28# ifdef Assert
29# error "VBoxMPWddm.h must be included first."
30# endif
31# define RT_NO_STRICT
32#endif
33#include "common/VBoxMPUtils.h"
34#include "common/VBoxMPDevExt.h"
35#include "../../common/VBoxVideoTools.h"
36
37//#define VBOXWDDM_DEBUG_VIDPN
38
39#define VBOXWDDM_CFG_DRV_DEFAULT 0
40#define VBOXWDDM_CFG_DRV_SECONDARY_TARGETS_CONNECTED 1
41
42#define VBOXWDDM_CFG_DRVTARGET_CONNECTED 1
43
44#define VBOXWDDM_CFG_LOG_UM_BACKDOOR 0x00000001
45#define VBOXWDDM_CFG_LOG_UM_DBGPRINT 0x00000002
46#define VBOXWDDM_CFG_STR_LOG_UM L"VBoxLogUm"
47
48#define VBOXWDDM_REG_DRV_FLAGS_NAME L"VBoxFlags"
49#define VBOXWDDM_REG_DRV_DISPFLAGS_PREFIX L"VBoxDispFlags"
50
51#define VBOXWDDM_REG_DRVKEY_PREFIX L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Class\\"
52
53#define VBOXWDDM_REG_DISPLAYSETTINGSVIDEOKEY L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video\\"
54#define VBOXWDDM_REG_DISPLAYSETTINGSVIDEOKEY_SUBKEY L"\\Video"
55
56
57#define VBOXWDDM_REG_DISPLAYSETTINGSKEY_PREFIX_VISTA L"\\Registry\\Machine\\System\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Control\\VIDEO\\"
58#define VBOXWDDM_REG_DISPLAYSETTINGSKEY_PREFIX_WIN7 L"\\Registry\\Machine\\System\\CurrentControlSet\\Hardware Profiles\\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, D3DDDI_VIDEO_PRESENT_SOURCE_ID 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 *pScreen, 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))
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#ifdef VBOX_WITH_CROGL
192#define VBOXWDDMENTRY_2_SWAPCHAIN(_pE) ((PVBOXWDDM_SWAPCHAIN)((uint8_t*)(_pE) - RT_OFFSETOF(VBOXWDDM_SWAPCHAIN, DevExtListEntry)))
193
194BOOLEAN DxgkDdiInterruptRoutineNew(
195 IN CONST PVOID MiniportDeviceContext,
196 IN ULONG MessageNumber
197 );
198#endif
199
200#ifdef VBOX_WDDM_WIN8
201# define VBOXWDDM_IS_DISPLAYONLY() (g_VBoxDisplayOnly)
202#else
203# define VBOXWDDM_IS_DISPLAYONLY() (FALSE)
204#endif
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