VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h@ 26179

Last change on this file since 26179 was 26179, checked in by vboxsync, 15 years ago

wddm: more impl

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 29.8 KB
Line 
1/** @file
2 * VirtualBox Video miniport driver
3 *
4 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
5 *
6 * This file is part of VirtualBox Open Source Edition (OSE), as
7 * available from http://www.virtualbox.org. This file is free software;
8 * you can redistribute it and/or modify it under the terms of the GNU
9 * General Public License (GPL) as published by the Free Software
10 * Foundation, in version 2 as it comes in the "COPYING" file of the
11 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
12 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
13 *
14 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
15 * Clara, CA 95054 USA or visit http://www.sun.com if you need
16 * additional information or have any questions.
17 */
18
19#ifndef VBOXVIDEO_H
20#define VBOXVIDEO_H
21
22#include <VBox/cdefs.h>
23#include <VBox/types.h>
24#include <iprt/assert.h>
25
26#ifdef VBOX_WITH_HGSMI
27//#include <iprt/thread.h>
28
29#include <VBox/HGSMI/HGSMI.h>
30#include <VBox/HGSMI/HGSMIChSetup.h>
31#include "VBoxHGSMI.h"
32#endif /* VBOX_WITH_HGSMI */
33
34RT_C_DECLS_BEGIN
35#ifndef VBOXWDDM
36#include "dderror.h"
37#include "devioctl.h"
38#include "miniport.h"
39#include "ntddvdeo.h"
40#include "video.h"
41#else
42# define VBOX_WITH_WORKAROUND_MISSING_PACK
43# if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
44# define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
45# define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
46# define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
47# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
48# define _interlockedbittestandset _interlockedbittestandset_StupidDDKVsCompilerCrap
49# define _interlockedbittestandreset _interlockedbittestandreset_StupidDDKVsCompilerCrap
50# define _interlockedbittestandset64 _interlockedbittestandset64_StupidDDKVsCompilerCrap
51# define _interlockedbittestandreset64 _interlockedbittestandreset64_StupidDDKVsCompilerCrap
52# pragma warning(disable : 4163)
53# ifdef VBOX_WITH_WORKAROUND_MISSING_PACK
54# pragma warning(disable : 4103)
55# endif
56# include <ntddk.h>
57# pragma warning(default : 4163)
58# ifdef VBOX_WITH_WORKAROUND_MISSING_PACK
59# pragma pack()
60# pragma warning(default : 4103)
61# endif
62# undef _InterlockedExchange
63# undef _InterlockedExchangeAdd
64# undef _InterlockedCompareExchange
65# undef _InterlockedAddLargeStatistic
66# undef _interlockedbittestandset
67# undef _interlockedbittestandreset
68# undef _interlockedbittestandset64
69# undef _interlockedbittestandreset64
70# else
71# include <ntddk.h>
72# endif
73#include "dispmprt.h"
74#include "ntddvdeo.h"
75#include "dderror.h"
76#endif
77RT_C_DECLS_END
78
79#define VBE_DISPI_IOPORT_INDEX 0x01CE
80#define VBE_DISPI_IOPORT_DATA 0x01CF
81#define VBE_DISPI_INDEX_ID 0x0
82#define VBE_DISPI_INDEX_XRES 0x1
83#define VBE_DISPI_INDEX_YRES 0x2
84#define VBE_DISPI_INDEX_BPP 0x3
85#define VBE_DISPI_INDEX_ENABLE 0x4
86#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
87#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
88#define VBE_DISPI_INDEX_VBOX_VIDEO 0xa
89
90#define VBE_DISPI_ID2 0xB0C2
91/* The VBOX interface id. Indicates support for VBE_DISPI_INDEX_VBOX_VIDEO. */
92#define VBE_DISPI_ID_VBOX_VIDEO 0xBE00
93#ifdef VBOX_WITH_HGSMI
94#define VBE_DISPI_ID_HGSMI 0xBE01
95#endif /* VBOX_WITH_HGSMI */
96#define VBE_DISPI_DISABLED 0x00
97#define VBE_DISPI_ENABLED 0x01
98#define VBE_DISPI_LFB_ENABLED 0x40
99#define VBE_DISPI_LFB_PHYSICAL_ADDRESS 0xE0000000
100#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 4
101#define VBE_DISPI_TOTAL_VIDEO_MEMORY_KB (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB * 1024)
102#define VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES (VBE_DISPI_TOTAL_VIDEO_MEMORY_KB * 1024)
103
104#ifdef VBOX_WITH_HGSMI
105#define VGA_PORT_HGSMI_HOST 0x3b0
106#define VGA_PORT_HGSMI_GUEST 0x3d0
107#endif /* VBOX_WITH_HGSMI */
108
109/* common API types */
110#ifndef VBOXWDDM
111typedef PSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK;
112typedef UCHAR VBOXVCMNIRQL, *PVBOXVCMNIRQL;
113
114typedef PEVENT VBOXVCMNEVENT, *PVBOXVCMNEVENT;
115
116typedef struct _DEVICE_EXTENSION * VBOXCMNREG;
117#else
118#include <VBox/VBoxVideo.h>
119
120typedef KSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK;
121typedef KIRQL VBOXVCMNIRQL, *PVBOXVCMNIRQL;
122
123typedef KEVENT VBOXVCMNEVENT, *PVBOXVCMNEVENT;
124
125typedef HANDLE VBOXCMNREG;
126
127typedef enum
128{
129 VBOXWDDM_CMD_UNEFINED = 0,
130 VBOXWDDM_CMD_DMA_TRANSFER
131} VBOXWDDM_CMD_TYPE;
132
133typedef struct VBOXWDDM_SOURCE
134{
135 HGSMIHEAP hgsmiDisplayHeap;
136// VBVABUFFER *pVBVA; /* Pointer to the pjScreen + layout->offVBVABuffer. NULL if VBVA is not enabled. */
137} VBOXWDDM_SOURCE, *PVBOXWDDM_SOURCE;
138
139typedef enum
140{
141 VBOXWDDM_ALLOC_UNEFINED = 0,
142 VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE,
143 VBOXWDDM_ALLOC_STD_SHADOWSURFACE,
144 VBOXWDDM_ALLOC_STD_STAGINGSURFACE,
145 /* this one is win 7-specific and hence unused for now */
146 VBOXWDDM_ALLOC_STD_GDISURFACE
147 /* custom allocation types requested from user-mode d3d module will go here */
148} VBOXWDDM_ALLOC_TYPE;
149
150typedef struct VBOXWDDM_ALLOCINFO
151{
152 VBOXWDDM_ALLOC_TYPE enmType;
153 char Body[1];
154} VBOXWDDM_ALLOCINFO, *PVBOXWDDM_ALLOCINFO;
155
156#define VBOXWDDM_ALLOCINFO_HEADSIZE() (RT_OFFSETOF(VBOXWDDM_ALLOCINFO, Body))
157#define VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(_s) (VBOXWDDM_ALLOCINFO_HEADSIZE() + (_s))
158#define VBOXWDDM_ALLOCINFO_SIZE(_tCmd) (VBOXWDDM_ALLOCINFO_SIZE_FROMBODYSIZE(sizeof(_tCmd)))
159#define VBOXWDDM_ALLOCINFO_BODY(_p, _t) ((_t*)(_p)->Body)
160#define VBOXWDDM_ALLOCINFO_HEAD(_pb) ((VBOXWDDM_ALLOCINFO*)((uint8_t *)(_pb) - RT_OFFSETOF(VBOXWDDM_ALLOCINFO, Body)))
161
162typedef struct VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE
163{
164 D3DKMDT_SHAREDPRIMARYSURFACEDATA SurfData;
165} VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE, *PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE;
166
167typedef struct VBOXWDDM_ALLOCINFO_SHADOWSURFACE
168{
169 D3DKMDT_SHADOWSURFACEDATA SurfData;
170} VBOXWDDM_ALLOCINFO_SHADOWSURFACE, *PVBOXWDDM_ALLOCINFO_SHADOWSURFACE;
171
172typedef struct VBOXWDDM_ALLOCINFO_STAGINGSURFACE
173{
174 D3DKMDT_STAGINGSURFACEDATA SurfData;
175} VBOXWDDM_ALLOCINFO_STAGINGSURFACE, *PVBOXWDDM_ALLOCINFO_STAGINGSURFACE;
176
177/* allocation */
178typedef struct VBOXWDDM_ALLOCATION
179{
180 VBOXWDDM_ALLOC_TYPE enmType;
181 char Body[1];
182} VBOXWDDM_ALLOCATION, *PVBOXWDDM_ALLOCATION;
183
184#define VBOXWDDM_ALLOCATION_HEADSIZE() (RT_OFFSETOF(VBOXWDDM_ALLOCATION, Body))
185#define VBOXWDDM_ALLOCATION_SIZE_FROMBODYSIZE(_s) (VBOXWDDM_ALLOCATION_HEADSIZE() + (_s))
186#define VBOXWDDM_ALLOCATION_SIZE(_tCmd) (VBOXWDDM_ALLOCATION_SIZE_FROMBODYSIZE(sizeof(_tCmd)))
187#define VBOXWDDM_ALLOCATION_BODY(_p, _t) ((_t*)(_p)->Body)
188#define VBOXWDDM_ALLOCATION_HEAD(_pb) ((VBOXWDDM_ALLOCATION*)((uint8_t *)(_pb) - RT_OFFSETOF(VBOXWDDM_ALLOCATION, Body)))
189
190typedef struct VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE
191{
192 VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE AllocInfo;
193} VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE, *PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE;
194
195typedef struct VBOXWDDM_ALLOCATION_SHADOWSURFACE
196{
197 VBOXWDDM_ALLOCINFO_SHADOWSURFACE AllocInfo;
198} VBOXWDDM_ALLOCATION_SHADOWSURFACE, *PVBOXWDDM_ALLOCATION_SHADOWSURFACE;
199
200typedef struct VBOXWDDM_ALLOCATION_STAGINGSURFACE
201{
202 VBOXWDDM_ALLOCINFO_STAGINGSURFACE AllocInfo;
203} VBOXWDDM_ALLOCATION_STAGINGSURFACE, *PVBOXWDDM_ALLOCATION_STAGINGSURFACE;
204
205
206typedef struct VBOXWDDM_DEVICE
207{
208 HANDLE hDevice; /* the handle that the driver should use when it calls back into the Microsoft DirectX graphics kernel subsystem */
209 struct _DEVICE_EXTENSION * pAdapter; /* Adapder info */
210 DXGK_CREATEDEVICEFLAGS fCreationFlags; /* device creation flags passed to DxgkDdiCreateDevice, not sure we need it */
211 DXGK_DEVICEINFO DeviceInfo;
212} VBOXWDDM_DEVICE, *PVBOXWDDM_DEVICE;
213
214#endif
215
216typedef struct _DEVICE_EXTENSION
217{
218 struct _DEVICE_EXTENSION *pNext; /* Next extension in the DualView extension list.
219 * The primary extension is the first one.
220 */
221
222 struct _DEVICE_EXTENSION *pPrimary; /* Pointer to the primary device extension. */
223
224 ULONG iDevice; /* Device index: 0 for primary, otherwise a secondary device. */
225
226
227 ULONG CurrentMode; /* Saved information about video modes */
228 ULONG CurrentModeWidth;
229 ULONG CurrentModeHeight;
230 ULONG CurrentModeBPP;
231
232 ULONG ulFrameBufferOffset; /* The framebuffer position in the VRAM. */
233 ULONG ulFrameBufferSize; /* The size of the current framebuffer. */
234
235 union {
236 /* Information that is only relevant to the primary device or is the same for all devices. */
237 struct {
238
239 void *pvReqFlush; /* Pointer to preallocated generic request structure for
240 * VMMDevReq_VideoAccelFlush. Allocated when VBVA status
241 * is changed. Deallocated on HwReset.
242 */
243
244
245 ULONG ulVbvaEnabled; /* Indicates that VBVA mode is enabled. */
246
247 BOOLEAN bVBoxVideoSupported; /* TRUE if VBoxVideo extensions, including DualView, are supported by the host. */
248
249 int cDisplays; /* Number of displays. */
250
251 ULONG cbVRAM; /* The VRAM size. */
252
253 ULONG cbMiniportHeap; /* The size of reserved VRAM for miniport driver heap.
254 * It is at offset:
255 * cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap
256 */
257 PVOID pvMiniportHeap; /* The pointer to the miniport heap VRAM.
258 * This is mapped by miniport separately.
259 */
260#ifdef VBOX_WITH_HGSMI
261 volatile HGSMIHOSTFLAGS * pHostFlags; /* HGSMI host flags */
262 volatile bool bHostCmdProcessing;
263 VBOXVCMNSPIN_LOCK pSynchLock;
264#endif
265
266 PVOID pvAdapterInformation; /* The pointer to the last 4K of VRAM.
267 * This is mapped by miniport separately.
268 */
269
270 ULONG ulMaxFrameBufferSize; /* The size of the VRAM allocated for the a single framebuffer. */
271
272 BOOLEAN fMouseHidden; /* Has the mouse cursor been hidden by the guest? */
273
274#ifndef VBOX_WITH_HGSMI
275 ULONG ulDisplayInformationSize; /* The size of the Display information, which is at offset:
276 * ulFrameBufferOffset + ulMaxFrameBufferSize.
277 */
278#endif /* !VBOX_WITH_HGSMI */
279
280#ifdef VBOX_WITH_HGSMI
281 BOOLEAN bHGSMI; /* Whether HGSMI is enabled. */
282
283 HGSMIAREA areaHostHeap; /* Host heap VRAM area. */
284
285 HGSMICHANNELINFO channels;
286
287 HGSMIHEAP hgsmiAdapterHeap;
288
289 /* The IO Port Number for host commands. */
290 RTIOPORT IOPortHost;
291
292 /* The IO Port Number for guest commands. */
293 RTIOPORT IOPortGuest;
294# ifndef VBOXWDDM
295 /* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */
296 VBOXVIDEOPORTPROCS VideoPortProcs;
297# else
298 /* Display Port handle and callbacks */
299 DXGKRNL_INTERFACE DxgkInterface;
300# endif
301#endif /* VBOX_WITH_HGSMI */
302 } primary;
303
304 /* Secondary device information. */
305 struct {
306 BOOLEAN bEnabled; /* Device enabled flag */
307 } secondary;
308 } u;
309
310#ifdef VBOX_WITH_HGSMI
311 HGSMIAREA areaDisplay; /* Entire VRAM chunk for this display device. */
312#endif /* VBOX_WITH_HGSMI */
313
314#ifdef VBOXWDDM
315 PDEVICE_OBJECT pPDO;
316
317 ULONG cSources;
318 /* currently we define the array for the max possible size since we do not know
319 * the monitor count at the DxgkDdiAddDevice,
320 * i.e. we obtain the monitor count in DxgkDdiStartDevice due to implementation of the currently re-used XPDM functionality
321 *
322 * @todo: use the dynamic array size calculated at DxgkDdiAddDevice
323 * */
324 VBOXWDDM_SOURCE aSources[VBOX_VIDEO_MAX_SCREENS];
325#endif
326} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
327
328#define DEV_MOUSE_HIDDEN(dev) ((dev)->pPrimary->u.primary.fMouseHidden)
329#define DEV_SET_MOUSE_HIDDEN(dev) \
330do { \
331 (dev)->pPrimary->u.primary.fMouseHidden = TRUE; \
332} while (0)
333#define DEV_SET_MOUSE_SHOWN(dev) \
334do { \
335 (dev)->pPrimary->u.primary.fMouseHidden = FALSE; \
336} while (0)
337
338extern "C"
339{
340#ifndef VBOXWDDM
341/* XPDM-WDDM common API */
342
343typedef PEVENT VBOXVCMNEVENT, *PVBOXVCMNEVENT;
344
345DECLINLINE(VOID) VBoxVideoCmnPortWriteUchar(IN PUCHAR Port, IN UCHAR Value)
346{
347 VideoPortWritePortUchar(Port,Value);
348}
349
350DECLINLINE(VOID) VBoxVideoCmnPortWriteUshort(IN PUSHORT Port, IN USHORT Value)
351{
352 VideoPortWritePortUshort(Port,Value);
353}
354
355DECLINLINE(VOID) VBoxVideoCmnPortWriteUlong(IN PULONG Port, IN ULONG Value)
356{
357 VideoPortWritePortUlong(Port,Value);
358}
359
360DECLINLINE(UCHAR) VBoxVideoCmnPortReadUchar(IN PUCHAR Port)
361{
362 return VideoPortReadPortUchar(Port);
363}
364
365DECLINLINE(USHORT) VBoxVideoCmnPortReadUshort(IN PUSHORT Port)
366{
367 return VideoPortReadPortUshort(Port);
368}
369
370DECLINLINE(ULONG) VBoxVideoCmnPortReadUlong(IN PULONG Port)
371{
372 return VideoPortReadPortUlong(Port);
373}
374
375DECLINLINE(VOID) VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem)
376{
377 VideoPortZeroMemory(pvMem, cbMem);
378}
379
380DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
381{
382 pDeviceExtension->u.primary.VideoPortProcs.pfnAcquireSpinLock(pDeviceExtension, *SpinLock, OldIrql);
383}
384
385DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
386{
387 pDeviceExtension->u.primary.VideoPortProcs.pfnAcquireSpinLockAtDpcLevel(pDeviceExtension, *SpinLock);
388}
389
390DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
391{
392 pDeviceExtension->u.primary.VideoPortProcs.pfnReleaseSpinLock(pDeviceExtension, *SpinLock, NewIrql);
393}
394
395DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
396{
397 pDeviceExtension->u.primary.VideoPortProcs.pfnReleaseSpinLockFromDpcLevel(pDeviceExtension, *SpinLock);
398}
399
400DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
401{
402 return pDeviceExtension->u.primary.VideoPortProcs.pfnCreateSpinLock(pDeviceExtension, SpinLock);
403}
404
405DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
406{
407 return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteSpinLock(pDeviceExtension, *SpinLock);
408}
409
410DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
411{
412 return pDeviceExtension->u.primary.VideoPortProcs.pfnSetEvent(pDeviceExtension, *pEvent);
413}
414
415DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)
416{
417 ULONG fFlags = NOTIFICATION_EVENT;
418 if(bSignaled)
419 fFlags |= INITIAL_EVENT_SIGNALED;
420
421 return pDeviceExtension->u.primary.VideoPortProcs.pfnCreateEvent(pDeviceExtension, fFlags, NULL, pEvent);
422}
423
424DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
425{
426 return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteEvent(pDeviceExtension, *pEvent);
427}
428
429DECLINLINE(PVOID) VBoxVideoCmnMemAllocNonPaged(IN PDEVICE_EXTENSION pDeviceExtension, IN SIZE_T NumberOfBytes, IN ULONG Tag)
430{
431 return pDeviceExtension->u.primary.VideoPortProcs.pfnAllocatePool(pDeviceExtension, (VBOXVP_POOL_TYPE)VpNonPagedPool, NumberOfBytes, Tag);
432}
433
434DECLINLINE(VOID) VBoxVideoCmnMemFree(IN PDEVICE_EXTENSION pDeviceExtension, IN PVOID Ptr)
435{
436 pDeviceExtension->u.primary.VideoPortProcs.pfnFreePool(pDeviceExtension, Ptr);
437}
438
439DECLINLINE(VP_STATUS) VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg)
440{
441 *pReg = pDeviceExtension->pPrimary;
442 return NO_ERROR;
443}
444
445DECLINLINE(VP_STATUS) VBoxVideoCmnRegFini(IN VBOXCMNREG Reg)
446{
447 return NO_ERROR;
448}
449
450VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal);
451
452VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val);
453
454/* */
455
456RT_C_DECLS_BEGIN
457ULONG DriverEntry(IN PVOID Context1, IN PVOID Context2);
458RT_C_DECLS_END
459
460VP_STATUS VBoxVideoFindAdapter(
461 IN PVOID HwDeviceExtension,
462 IN PVOID HwContext,
463 IN PWSTR ArgumentString,
464 IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo,
465 OUT PUCHAR Again);
466
467BOOLEAN VBoxVideoInitialize(PVOID HwDeviceExtension);
468
469BOOLEAN VBoxVideoStartIO(
470 PVOID HwDeviceExtension,
471 PVIDEO_REQUEST_PACKET RequestPacket);
472
473#if defined(VBOX_WITH_HGSMI) && defined(VBOX_WITH_VIDEOHWACCEL)
474BOOLEAN VBoxVideoInterrupt(PVOID HwDeviceExtension);
475#endif
476
477
478BOOLEAN VBoxVideoResetHW(
479 PVOID HwDeviceExtension,
480 ULONG Columns,
481 ULONG Rows);
482
483VP_STATUS VBoxVideoGetPowerState(
484 PVOID HwDeviceExtension,
485 ULONG HwId,
486 PVIDEO_POWER_MANAGEMENT VideoPowerControl);
487
488VP_STATUS VBoxVideoSetPowerState(
489 PVOID HwDeviceExtension,
490 ULONG HwId,
491 PVIDEO_POWER_MANAGEMENT VideoPowerControl);
492
493VP_STATUS VBoxVideoGetChildDescriptor(
494 PVOID HwDeviceExtension,
495 PVIDEO_CHILD_ENUM_INFO ChildEnumInfo,
496 PVIDEO_CHILD_TYPE VideoChildType,
497 PUCHAR pChildDescriptor,
498 PULONG pUId,
499 PULONG pUnused);
500
501
502void VBoxSetupVideoPortFunctions(PDEVICE_EXTENSION PrimaryExtension,
503 VBOXVIDEOPORTPROCS *pCallbacks,
504 PVIDEO_PORT_CONFIG_INFO pConfigInfo);
505
506#else
507
508/* XPDM-WDDM common API */
509DECLINLINE(VOID) VBoxVideoCmnPortWriteUchar(IN PUCHAR Port, IN UCHAR Value)
510{
511 WRITE_PORT_UCHAR(Port,Value);
512}
513
514DECLINLINE(VOID) VBoxVideoCmnPortWriteUshort(IN PUSHORT Port, IN USHORT Value)
515{
516 WRITE_PORT_USHORT(Port,Value);
517}
518
519DECLINLINE(VOID) VBoxVideoCmnPortWriteUlong(IN PULONG Port, IN ULONG Value)
520{
521 WRITE_PORT_ULONG(Port,Value);
522}
523
524DECLINLINE(UCHAR) VBoxVideoCmnPortReadUchar(IN PUCHAR Port)
525{
526 return READ_PORT_UCHAR(Port);
527}
528
529DECLINLINE(USHORT) VBoxVideoCmnPortReadUshort(IN PUSHORT Port)
530{
531 return READ_PORT_USHORT(Port);
532}
533
534DECLINLINE(ULONG) VBoxVideoCmnPortReadUlong(IN PULONG Port)
535{
536 return READ_PORT_ULONG(Port);
537}
538
539DECLINLINE(VOID) VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem)
540{
541 memset(pvMem, 0, cbMem);
542}
543
544DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
545{
546 KeAcquireSpinLock(SpinLock, OldIrql);
547}
548
549DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
550{
551 KeAcquireSpinLockAtDpcLevel(SpinLock);
552}
553
554DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
555{
556 KeReleaseSpinLock(SpinLock, NewIrql);
557}
558
559DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
560{
561 KeReleaseSpinLockFromDpcLevel(SpinLock);
562}
563
564DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
565{
566 KeInitializeSpinLock(SpinLock);
567 return NO_ERROR;
568}
569
570DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
571{
572 return NO_ERROR;
573}
574
575DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
576{
577 return KeSetEvent(pEvent, 0, FALSE);
578}
579
580DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)
581{
582 KeInitializeEvent(pEvent, NotificationEvent, bSignaled);
583 return NO_ERROR;
584}
585
586DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
587{
588 return NO_ERROR;
589}
590
591DECLINLINE(PVOID) VBoxVideoCmnMemAllocNonPaged(IN PDEVICE_EXTENSION pDeviceExtension, IN SIZE_T NumberOfBytes, IN ULONG Tag)
592{
593 return ExAllocatePoolWithTag(NonPagedPool, NumberOfBytes, Tag);
594}
595
596DECLINLINE(VOID) VBoxVideoCmnMemFree(IN PDEVICE_EXTENSION pDeviceExtension, IN PVOID Ptr)
597{
598 ExFreePool(Ptr);
599}
600
601VP_STATUS VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg);
602
603DECLINLINE(VP_STATUS) VBoxVideoCmnRegFini(IN VBOXCMNREG Reg)
604{
605 if(!Reg)
606 return ERROR_INVALID_PARAMETER;
607
608 NTSTATUS Status = ZwClose(Reg);
609 return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
610}
611
612VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal);
613
614VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val);
615
616/* */
617
618RT_C_DECLS_BEGIN
619NTSTATUS
620DriverEntry(
621 IN PDRIVER_OBJECT DriverObject,
622 IN PUNICODE_STRING RegistryPath
623 );
624RT_C_DECLS_END
625
626NTSTATUS vboxVidPnCheckTopology(const D3DKMDT_HVIDPN hDesiredVidPn,
627 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
628 BOOLEAN *pbSupported);
629
630NTSTATUS vboxVidPnCheckSourceModeInfo(const D3DKMDT_HVIDPN hDesiredVidPn,
631 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo,
632 BOOLEAN *pbSupported);
633
634NTSTATUS vboxVidPnCheckSourceModeSet(const D3DKMDT_HVIDPN hDesiredVidPn,
635 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
636 BOOLEAN *pbSupported);
637
638NTSTATUS vboxVidPnCheckTargetModeInfo(const D3DKMDT_HVIDPN hDesiredVidPn,
639 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo,
640 BOOLEAN *pbSupported);
641
642NTSTATUS vboxVidPnCheckTargetModeSet(const D3DKMDT_HVIDPN hDesiredVidPn,
643 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
644 BOOLEAN *pbSupported);
645
646typedef struct VBOXVIDPNCMCONTEXT
647{
648 NTSTATUS Status;
649 CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* pEnumCofuncModalityArg;
650}VBOXVIDPNCMCONTEXT, *PVBOXVIDPNCMCONTEXT;
651
652typedef struct VBOXVIDPN_NEW_SRCMODESET_CHECK
653{
654 VBOXVIDPNCMCONTEXT CommonInfo;
655 CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
656 BOOLEAN bNeedAdjustment;
657}VBOXVIDPN_NEW_SRCMODESET_CHECK, *PVBOXVIDPN_NEW_SRCMODESET_CHECK;
658
659typedef struct VBOXVIDPN_NEW_SRCMODESET_POPULATION
660{
661 VBOXVIDPNCMCONTEXT CommonInfo;
662 CONST D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
663 /* new source mode (the one being populated) */
664 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet;
665 CONST DXGK_VIDPNSOURCEMODESET_INTERFACE* pNewVidPnSourceModeSetInterface;
666}VBOXVIDPN_NEW_SRCMODESET_POPULATION, *PVBOXVIDPN_NEW_SRCMODESET_POPULATION;
667
668/* !!!NOTE: The callback is responsible for releasing the path */
669typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMPATHS(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
670 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
671 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext);
672typedef FNVBOXVIDPNENUMPATHS *PFNVBOXVIDPNENUMPATHS;
673
674/* !!!NOTE: The callback is responsible for releasing the source mode info */
675typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMSOURCEMODES(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
676 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
677 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext);
678typedef FNVBOXVIDPNENUMSOURCEMODES *PFNVBOXVIDPNENUMSOURCEMODES;
679
680/* !!!NOTE: The callback is responsible for releasing the target mode info */
681typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMTARGETMODES(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
682 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
683 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext);
684typedef FNVBOXVIDPNENUMTARGETMODES *PFNVBOXVIDPNENUMTARGETMODES;
685
686
687DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
688 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
689 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext);
690
691DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalitySourceModeEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
692 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
693 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext);
694
695DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityTargetModeEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
696 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
697 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext);
698
699NTSTATUS vboxVidPnEnumPaths(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
700 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
701 PFNVBOXVIDPNENUMPATHS pfnCallback, PVOID pContext);
702
703NTSTATUS vboxVidPnEnumSourceModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
704 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
705 PFNVBOXVIDPNENUMSOURCEMODES pfnCallback, PVOID pContext);
706
707NTSTATUS vboxVidPnEnumTargetModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
708 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
709 PFNVBOXVIDPNENUMTARGETMODES pfnCallback, PVOID pContext);
710#endif
711
712BOOLEAN FASTCALL VBoxVideoSetCurrentMode(
713 PDEVICE_EXTENSION DeviceExtension,
714 PVIDEO_MODE RequestedMode,
715 PSTATUS_BLOCK StatusBlock);
716
717BOOLEAN FASTCALL VBoxVideoResetDevice(
718 PDEVICE_EXTENSION DeviceExtension,
719 PSTATUS_BLOCK StatusBlock);
720
721BOOLEAN FASTCALL VBoxVideoMapVideoMemory(
722 PDEVICE_EXTENSION DeviceExtension,
723 PVIDEO_MEMORY RequestedAddress,
724 PVIDEO_MEMORY_INFORMATION MapInformation,
725 PSTATUS_BLOCK StatusBlock);
726
727BOOLEAN FASTCALL VBoxVideoUnmapVideoMemory(
728 PDEVICE_EXTENSION DeviceExtension,
729 PVIDEO_MEMORY VideoMemory,
730 PSTATUS_BLOCK StatusBlock);
731
732BOOLEAN FASTCALL VBoxVideoQueryNumAvailModes(
733 PDEVICE_EXTENSION DeviceExtension,
734 PVIDEO_NUM_MODES Modes,
735 PSTATUS_BLOCK StatusBlock);
736
737BOOLEAN FASTCALL VBoxVideoQueryAvailModes(
738 PDEVICE_EXTENSION DeviceExtension,
739 PVIDEO_MODE_INFORMATION ReturnedModes,
740 PSTATUS_BLOCK StatusBlock);
741
742BOOLEAN FASTCALL VBoxVideoQueryCurrentMode(
743 PDEVICE_EXTENSION DeviceExtension,
744 PVIDEO_MODE_INFORMATION VideoModeInfo,
745 PSTATUS_BLOCK StatusBlock);
746
747BOOLEAN FASTCALL VBoxVideoSetColorRegisters(
748 PDEVICE_EXTENSION DeviceExtension,
749 PVIDEO_CLUT ColorLookUpTable,
750 PSTATUS_BLOCK StatusBlock);
751
752int VBoxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
753 void **ppv,
754 ULONG ulOffset,
755 ULONG ulSize);
756
757void VBoxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
758 void **ppv, ULONG ulSize);
759
760void VBoxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension);
761
762#ifdef VBOX_WITH_HGSMI
763
764/*
765 * Host and Guest port IO helpers.
766 */
767DECLINLINE(void) VBoxHGSMIHostWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
768{
769 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost, data);
770}
771
772DECLINLINE(ULONG) VBoxHGSMIHostRead(PDEVICE_EXTENSION PrimaryExtension)
773{
774 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost);
775}
776
777DECLINLINE(void) VBoxHGSMIGuestWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
778{
779 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest, data);
780}
781
782DECLINLINE(ULONG) VBoxHGSMIGuestRead(PDEVICE_EXTENSION PrimaryExtension)
783{
784 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest);
785}
786
787BOOLEAN VBoxHGSMIIsSupported (PDEVICE_EXTENSION PrimaryExtension);
788
789VOID VBoxSetupDisplaysHGSMI (PDEVICE_EXTENSION PrimaryExtension,
790#ifndef VBOXWDDM
791 PVIDEO_PORT_CONFIG_INFO pConfigInfo,
792#endif
793 ULONG AdapterMemorySize);
794BOOLEAN vboxUpdatePointerShape (PDEVICE_EXTENSION DeviceExtension,
795 PVIDEO_POINTER_ATTRIBUTES pointerAttr,
796 uint32_t cbLength);
797DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
798DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd);
799
800
801int vboxVBVAChannelDisplayEnable(PDEVICE_EXTENSION PrimaryExtension,
802 int iDisplay, /* negative would mean this is a miniport handler */
803 uint8_t u8Channel);
804
805VOID VBoxVideoHGSMIDpc(
806 IN PVOID HwDeviceExtension,
807 IN PVOID Context
808 );
809
810void HGSMIClearIrq (PDEVICE_EXTENSION PrimaryExtension);
811
812#endif /* VBOX_WITH_HGSMI */
813} /* extern "C" */
814
815#endif /* VBOXVIDEO_H */
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