1 | /*
|
---|
2 | * Copyright (C) 2010 Oracle Corporation
|
---|
3 | *
|
---|
4 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
5 | * available from http://www.virtualbox.org. This file is free software;
|
---|
6 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
7 | * General Public License (GPL) as published by the Free Software
|
---|
8 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
9 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
10 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
11 | */
|
---|
12 |
|
---|
13 | #ifndef ___VBoxVideoMisc_h__
|
---|
14 | #define ___VBoxVideoMisc_h__
|
---|
15 |
|
---|
16 | DECLINLINE(void) vboxVideoLeDetach(LIST_ENTRY *pList, LIST_ENTRY *pDstList)
|
---|
17 | {
|
---|
18 | if (IsListEmpty(pList))
|
---|
19 | {
|
---|
20 | InitializeListHead(pDstList);
|
---|
21 | }
|
---|
22 | else
|
---|
23 | {
|
---|
24 | *pDstList = *pList;
|
---|
25 | Assert(pDstList->Flink->Blink == pList);
|
---|
26 | Assert(pDstList->Blink->Flink == pList);
|
---|
27 | /* pDstList->Flink & pDstList->Blink point to the "real| entries, never to pList
|
---|
28 | * since we've checked IsListEmpty(pList) above */
|
---|
29 | pDstList->Flink->Blink = pDstList;
|
---|
30 | pDstList->Blink->Flink = pDstList;
|
---|
31 | InitializeListHead(pList);
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
35 | typedef struct _DEVICE_EXTENSION *PDEVICE_EXTENSION;
|
---|
36 | typedef struct VBOXWDDM_SWAPCHAIN *PVBOXWDDM_SWAPCHAIN;
|
---|
37 | typedef struct VBOXWDDM_CONTEXT *PVBOXWDDM_CONTEXT;
|
---|
38 | typedef struct VBOXWDDM_ALLOCATION *PVBOXWDDM_ALLOCATION;
|
---|
39 |
|
---|
40 | typedef uint32_t VBOXWDDM_HANDLE;
|
---|
41 | #define VBOXWDDM_HANDLE_INVALID 0UL
|
---|
42 |
|
---|
43 | typedef struct VBOXWDDM_HTABLE
|
---|
44 | {
|
---|
45 | uint32_t cData;
|
---|
46 | uint32_t iNext2Search;
|
---|
47 | uint32_t cSize;
|
---|
48 | PVOID *paData;
|
---|
49 | } VBOXWDDM_HTABLE, *PVBOXWDDM_HTABLE;
|
---|
50 |
|
---|
51 | typedef struct VBOXWDDM_HTABLE_ITERATOR
|
---|
52 | {
|
---|
53 | PVBOXWDDM_HTABLE pTbl;
|
---|
54 | uint32_t iCur;
|
---|
55 | uint32_t cLeft;
|
---|
56 | } VBOXWDDM_HTABLE_ITERATOR, *PVBOXWDDM_HTABLE_ITERATOR;
|
---|
57 |
|
---|
58 | VOID vboxWddmHTableIterInit(PVBOXWDDM_HTABLE pTbl, PVBOXWDDM_HTABLE_ITERATOR pIter);
|
---|
59 | PVOID vboxWddmHTableIterNext(PVBOXWDDM_HTABLE_ITERATOR pIter, VBOXWDDM_HANDLE *phHandle);
|
---|
60 | BOOL vboxWddmHTableIterHasNext(PVBOXWDDM_HTABLE_ITERATOR pIter);
|
---|
61 | PVOID vboxWddmHTableIterRemoveCur(PVBOXWDDM_HTABLE_ITERATOR pIter);
|
---|
62 | NTSTATUS vboxWddmHTableCreate(PVBOXWDDM_HTABLE pTbl, uint32_t cSize);
|
---|
63 | VOID vboxWddmHTableDestroy(PVBOXWDDM_HTABLE pTbl);
|
---|
64 | NTSTATUS vboxWddmHTableRealloc(PVBOXWDDM_HTABLE pTbl, uint32_t cNewSize);
|
---|
65 | VBOXWDDM_HANDLE vboxWddmHTablePut(PVBOXWDDM_HTABLE pTbl, PVOID pvData);
|
---|
66 | PVOID vboxWddmHTableRemove(PVBOXWDDM_HTABLE pTbl, VBOXWDDM_HANDLE hHandle);
|
---|
67 | PVOID vboxWddmHTableGet(PVBOXWDDM_HTABLE pTbl, VBOXWDDM_HANDLE hHandle);
|
---|
68 |
|
---|
69 |
|
---|
70 | PVBOXWDDM_SWAPCHAIN vboxWddmSwapchainCreate();
|
---|
71 | DECLINLINE(BOOLEAN) vboxWddmSwapchainRetain(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain);
|
---|
72 | DECLINLINE(VOID) vboxWddmSwapchainRelease(PVBOXWDDM_SWAPCHAIN pSwapchain);
|
---|
73 | PVBOXWDDM_SWAPCHAIN vboxWddmSwapchainRetainByAlloc(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAlloc);
|
---|
74 | VOID vboxWddmSwapchainAllocRemove(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain, PVBOXWDDM_ALLOCATION pAlloc);
|
---|
75 | BOOLEAN vboxWddmSwapchainAllocAdd(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain, PVBOXWDDM_ALLOCATION pAlloc);
|
---|
76 | VOID vboxWddmSwapchainAllocRemoveAll(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain);
|
---|
77 | VOID vboxWddmSwapchainDestroy(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SWAPCHAIN pSwapchain);
|
---|
78 | VOID vboxWddmSwapchainCtxDestroyAll(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_CONTEXT pContext);
|
---|
79 | NTSTATUS vboxWddmSwapchainCtxEscape(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_CONTEXT pContext, PVBOXDISPIFESCAPE_SWAPCHAININFO pSwapchainInfo, UINT cbSize);
|
---|
80 |
|
---|
81 |
|
---|
82 | NTSTATUS vboxWddmRegQueryDisplaySettingsKeyName(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId,
|
---|
83 | ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
|
---|
84 | NTSTATUS vboxWddmRegOpenDisplaySettingsKey(IN PDEVICE_EXTENSION pDeviceExtension, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, OUT PHANDLE phKey);
|
---|
85 | NTSTATUS vboxWddmRegDisplaySettingsQueryRelX(HANDLE hKey, int * pResult);
|
---|
86 | NTSTATUS vboxWddmRegDisplaySettingsQueryRelY(HANDLE hKey, int * pResult);
|
---|
87 | NTSTATUS vboxWddmDisplaySettingsQueryPos(IN PDEVICE_EXTENSION pDeviceExtension, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, POINT * pPos);
|
---|
88 | NTSTATUS vboxWddmRegQueryVideoGuidString(ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
|
---|
89 |
|
---|
90 | NTSTATUS vboxWddmRegQueryDrvKeyName(PDEVICE_EXTENSION pDevExt, ULONG cbBuf, PWCHAR pBuf, PULONG pcbResult);
|
---|
91 |
|
---|
92 | NTSTATUS vboxWddmRegOpenKey(OUT PHANDLE phKey, IN PWCHAR pName, IN ACCESS_MASK fAccess);
|
---|
93 | NTSTATUS vboxWddmRegQueryValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT PDWORD pDword);
|
---|
94 | NTSTATUS vboxWddmRegSetValueDword(IN HANDLE hKey, IN PWCHAR pName, OUT DWORD val);
|
---|
95 |
|
---|
96 | UNICODE_STRING* vboxWddmVGuidGet(PDEVICE_EXTENSION pDevExt);
|
---|
97 | VOID vboxWddmVGuidFree(PDEVICE_EXTENSION pDevExt);
|
---|
98 |
|
---|
99 | #define VBOXWDDM_MM_VOID 0xffffffffUL
|
---|
100 |
|
---|
101 | typedef struct VBOXWDDM_MM
|
---|
102 | {
|
---|
103 | RTL_BITMAP BitMap;
|
---|
104 | UINT cPages;
|
---|
105 | UINT cAllocs;
|
---|
106 | PULONG pBuffer;
|
---|
107 | } VBOXWDDM_MM, *PVBOXWDDM_MM;
|
---|
108 |
|
---|
109 | NTSTATUS vboxMmInit(PVBOXWDDM_MM pMm, UINT cPages);
|
---|
110 | ULONG vboxMmAlloc(PVBOXWDDM_MM pMm, UINT cPages);
|
---|
111 | VOID vboxMmFree(PVBOXWDDM_MM pMm, UINT iPage, UINT cPages);
|
---|
112 | NTSTATUS vboxMmTerm(PVBOXWDDM_MM pMm);
|
---|
113 |
|
---|
114 | typedef struct VBOXVIDEOCM_ALLOC_MGR
|
---|
115 | {
|
---|
116 | /* synch lock */
|
---|
117 | FAST_MUTEX Mutex;
|
---|
118 | VBOXWDDM_HTABLE AllocTable;
|
---|
119 | VBOXWDDM_MM Mm;
|
---|
120 | // PHYSICAL_ADDRESS PhData;
|
---|
121 | uint8_t *pvData;
|
---|
122 | uint32_t offData;
|
---|
123 | uint32_t cbData;
|
---|
124 | } VBOXVIDEOCM_ALLOC_MGR, *PVBOXVIDEOCM_ALLOC_MGR;
|
---|
125 |
|
---|
126 | typedef struct VBOXVIDEOCM_ALLOC_CONTEXT
|
---|
127 | {
|
---|
128 | PVBOXVIDEOCM_ALLOC_MGR pMgr;
|
---|
129 | /* synch lock */
|
---|
130 | FAST_MUTEX Mutex;
|
---|
131 | VBOXWDDM_HTABLE AllocTable;
|
---|
132 | } VBOXVIDEOCM_ALLOC_CONTEXT, *PVBOXVIDEOCM_ALLOC_CONTEXT;
|
---|
133 |
|
---|
134 | NTSTATUS vboxVideoAMgrCreate(PDEVICE_EXTENSION pDevExt, PVBOXVIDEOCM_ALLOC_MGR pMgr, uint32_t offData, uint32_t cbData);
|
---|
135 | NTSTATUS vboxVideoAMgrDestroy(PDEVICE_EXTENSION pDevExt, PVBOXVIDEOCM_ALLOC_MGR pMgr);
|
---|
136 |
|
---|
137 | NTSTATUS vboxVideoAMgrCtxCreate(PVBOXVIDEOCM_ALLOC_MGR pMgr, PVBOXVIDEOCM_ALLOC_CONTEXT pCtx);
|
---|
138 | NTSTATUS vboxVideoAMgrCtxDestroy(PVBOXVIDEOCM_ALLOC_CONTEXT pCtx);
|
---|
139 |
|
---|
140 | NTSTATUS vboxVideoAMgrCtxAllocCreate(PVBOXVIDEOCM_ALLOC_CONTEXT pContext, PVBOXVIDEOCM_UM_ALLOC pUmAlloc);
|
---|
141 | NTSTATUS vboxVideoAMgrCtxAllocDestroy(PVBOXVIDEOCM_ALLOC_CONTEXT pContext, VBOXDISP_KMHANDLE hSesionHandle);
|
---|
142 |
|
---|
143 | #ifdef VBOX_WITH_CRHGSMI
|
---|
144 | NTSTATUS vboxVideoAMgrCtxAllocSubmit(PDEVICE_EXTENSION pDevExt, PVBOXVIDEOCM_ALLOC_CONTEXT pContext, UINT cBuffers, VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE *paBuffers);
|
---|
145 | #endif
|
---|
146 |
|
---|
147 | #endif /* #ifndef ___VBoxVideoMisc_h__ */
|
---|