VirtualBox

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

Last change on this file since 26630 was 26630, 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: 27.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#include "wddm/VBoxVideoShgsmi.h"
120#include "wddm/VBoxVideoVdma.h"
121#include "wddm/VBoxVideoWddm.h"
122
123typedef KSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK;
124typedef KIRQL VBOXVCMNIRQL, *PVBOXVCMNIRQL;
125
126typedef KEVENT VBOXVCMNEVENT, *PVBOXVCMNEVENT;
127
128typedef HANDLE VBOXCMNREG;
129
130typedef struct VBOXWDDM_SOURCE
131{
132 struct VBOXWDDM_ALLOCATION * pAllocation;
133} VBOXWDDM_SOURCE, *PVBOXWDDM_SOURCE;
134
135#endif
136
137typedef struct _DEVICE_EXTENSION
138{
139 struct _DEVICE_EXTENSION *pNext; /* Next extension in the DualView extension list.
140 * The primary extension is the first one.
141 */
142#ifndef VBOXWDDM
143 struct _DEVICE_EXTENSION *pPrimary; /* Pointer to the primary device extension. */
144
145 ULONG iDevice; /* Device index: 0 for primary, otherwise a secondary device. */
146
147 ULONG CurrentMode; /* Saved information about video modes */
148 ULONG CurrentModeWidth;
149 ULONG CurrentModeHeight;
150 ULONG CurrentModeBPP;
151
152 ULONG ulFrameBufferOffset; /* The framebuffer position in the VRAM. */
153 ULONG ulFrameBufferSize; /* The size of the current framebuffer. */
154#endif
155 union {
156 /* Information that is only relevant to the primary device or is the same for all devices. */
157 struct {
158
159 void *pvReqFlush; /* Pointer to preallocated generic request structure for
160 * VMMDevReq_VideoAccelFlush. Allocated when VBVA status
161 * is changed. Deallocated on HwReset.
162 */
163
164
165 ULONG ulVbvaEnabled; /* Indicates that VBVA mode is enabled. */
166
167 BOOLEAN bVBoxVideoSupported; /* TRUE if VBoxVideo extensions, including DualView, are supported by the host. */
168
169 int cDisplays; /* Number of displays. */
170
171 ULONG cbVRAM; /* The VRAM size. */
172
173 ULONG cbMiniportHeap; /* The size of reserved VRAM for miniport driver heap.
174 * It is at offset:
175 * cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap
176 */
177 PVOID pvMiniportHeap; /* The pointer to the miniport heap VRAM.
178 * This is mapped by miniport separately.
179 */
180#ifdef VBOXWDDM
181 VBOXVDMAINFO Vdma;
182#endif
183
184#ifdef VBOX_WITH_HGSMI
185 volatile HGSMIHOSTFLAGS * pHostFlags; /* HGSMI host flags */
186 volatile bool bHostCmdProcessing;
187 VBOXVCMNSPIN_LOCK pSynchLock;
188#endif
189
190 PVOID pvAdapterInformation; /* The pointer to the last 4K of VRAM.
191 * This is mapped by miniport separately.
192 */
193
194 ULONG ulMaxFrameBufferSize; /* The size of the VRAM allocated for the a single framebuffer. */
195
196 BOOLEAN fMouseHidden; /* Has the mouse cursor been hidden by the guest? */
197
198#ifndef VBOX_WITH_HGSMI
199 ULONG ulDisplayInformationSize; /* The size of the Display information, which is at offset:
200 * ulFrameBufferOffset + ulMaxFrameBufferSize.
201 */
202#endif /* !VBOX_WITH_HGSMI */
203
204#ifdef VBOX_WITH_HGSMI
205 BOOLEAN bHGSMI; /* Whether HGSMI is enabled. */
206
207 HGSMIAREA areaHostHeap; /* Host heap VRAM area. */
208
209 HGSMICHANNELINFO channels;
210
211 HGSMIHEAP hgsmiAdapterHeap;
212
213 /* The IO Port Number for host commands. */
214 RTIOPORT IOPortHost;
215
216 /* The IO Port Number for guest commands. */
217 RTIOPORT IOPortGuest;
218# ifndef VBOXWDDM
219 /* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */
220 VBOXVIDEOPORTPROCS VideoPortProcs;
221# else
222 /* Display Port handle and callbacks */
223 DXGKRNL_INTERFACE DxgkInterface;
224# endif
225#endif /* VBOX_WITH_HGSMI */
226 } primary;
227
228 /* Secondary device information. */
229 struct {
230 BOOLEAN bEnabled; /* Device enabled flag */
231 } secondary;
232 } u;
233
234#ifdef VBOX_WITH_HGSMI
235 HGSMIAREA areaDisplay; /* Entire VRAM chunk for this display device. */
236#endif /* VBOX_WITH_HGSMI */
237
238#ifdef VBOXWDDM
239 PDEVICE_OBJECT pPDO;
240
241 VBOXSHGSMILIST CtlList;
242 VBOXSHGSMILIST DmaCmdList;
243 BOOL bSetNotifyDxDpc;
244 BOOL bNotifyDxDpc;
245
246 ULONG cSources;
247 /* currently we define the array for the max possible size since we do not know
248 * the monitor count at the DxgkDdiAddDevice,
249 * i.e. we obtain the monitor count in DxgkDdiStartDevice due to implementation of the currently re-used XPDM functionality
250 *
251 * @todo: use the dynamic array size calculated at DxgkDdiAddDevice
252 * */
253 VBOXWDDM_SOURCE aSources[VBOX_VIDEO_MAX_SCREENS];
254#endif
255} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
256
257#ifndef VBOXWDDM
258#define DEV_MOUSE_HIDDEN(dev) ((dev)->pPrimary->u.primary.fMouseHidden)
259#define DEV_SET_MOUSE_HIDDEN(dev) \
260do { \
261 (dev)->pPrimary->u.primary.fMouseHidden = TRUE; \
262} while (0)
263#define DEV_SET_MOUSE_SHOWN(dev) \
264do { \
265 (dev)->pPrimary->u.primary.fMouseHidden = FALSE; \
266} while (0)
267#else
268#define DEV_MOUSE_HIDDEN(dev) ((dev)->u.primary.fMouseHidden)
269#define DEV_SET_MOUSE_HIDDEN(dev) \
270do { \
271 (dev)->u.primary.fMouseHidden = TRUE; \
272} while (0)
273#define DEV_SET_MOUSE_SHOWN(dev) \
274do { \
275 (dev)->u.primary.fMouseHidden = FALSE; \
276} while (0)
277#endif
278extern "C"
279{
280#ifndef VBOXWDDM
281/* XPDM-WDDM common API */
282
283typedef PEVENT VBOXVCMNEVENT, *PVBOXVCMNEVENT;
284
285DECLINLINE(VOID) VBoxVideoCmnPortWriteUchar(IN PUCHAR Port, IN UCHAR Value)
286{
287 VideoPortWritePortUchar(Port,Value);
288}
289
290DECLINLINE(VOID) VBoxVideoCmnPortWriteUshort(IN PUSHORT Port, IN USHORT Value)
291{
292 VideoPortWritePortUshort(Port,Value);
293}
294
295DECLINLINE(VOID) VBoxVideoCmnPortWriteUlong(IN PULONG Port, IN ULONG Value)
296{
297 VideoPortWritePortUlong(Port,Value);
298}
299
300DECLINLINE(UCHAR) VBoxVideoCmnPortReadUchar(IN PUCHAR Port)
301{
302 return VideoPortReadPortUchar(Port);
303}
304
305DECLINLINE(USHORT) VBoxVideoCmnPortReadUshort(IN PUSHORT Port)
306{
307 return VideoPortReadPortUshort(Port);
308}
309
310DECLINLINE(ULONG) VBoxVideoCmnPortReadUlong(IN PULONG Port)
311{
312 return VideoPortReadPortUlong(Port);
313}
314
315DECLINLINE(VOID) VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem)
316{
317 VideoPortZeroMemory(pvMem, cbMem);
318}
319
320DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
321{
322 pDeviceExtension->u.primary.VideoPortProcs.pfnAcquireSpinLock(pDeviceExtension, *SpinLock, OldIrql);
323}
324
325DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
326{
327 pDeviceExtension->u.primary.VideoPortProcs.pfnAcquireSpinLockAtDpcLevel(pDeviceExtension, *SpinLock);
328}
329
330DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
331{
332 pDeviceExtension->u.primary.VideoPortProcs.pfnReleaseSpinLock(pDeviceExtension, *SpinLock, NewIrql);
333}
334
335DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
336{
337 pDeviceExtension->u.primary.VideoPortProcs.pfnReleaseSpinLockFromDpcLevel(pDeviceExtension, *SpinLock);
338}
339
340DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
341{
342 return pDeviceExtension->u.primary.VideoPortProcs.pfnCreateSpinLock(pDeviceExtension, SpinLock);
343}
344
345DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
346{
347 return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteSpinLock(pDeviceExtension, *SpinLock);
348}
349
350DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
351{
352 return pDeviceExtension->u.primary.VideoPortProcs.pfnSetEvent(pDeviceExtension, *pEvent);
353}
354
355DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)
356{
357 ULONG fFlags = NOTIFICATION_EVENT;
358 if(bSignaled)
359 fFlags |= INITIAL_EVENT_SIGNALED;
360
361 return pDeviceExtension->u.primary.VideoPortProcs.pfnCreateEvent(pDeviceExtension, fFlags, NULL, pEvent);
362}
363
364DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
365{
366 return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteEvent(pDeviceExtension, *pEvent);
367}
368
369DECLINLINE(PVOID) VBoxVideoCmnMemAllocNonPaged(IN PDEVICE_EXTENSION pDeviceExtension, IN SIZE_T NumberOfBytes, IN ULONG Tag)
370{
371 return pDeviceExtension->u.primary.VideoPortProcs.pfnAllocatePool(pDeviceExtension, (VBOXVP_POOL_TYPE)VpNonPagedPool, NumberOfBytes, Tag);
372}
373
374DECLINLINE(VOID) VBoxVideoCmnMemFree(IN PDEVICE_EXTENSION pDeviceExtension, IN PVOID Ptr)
375{
376 pDeviceExtension->u.primary.VideoPortProcs.pfnFreePool(pDeviceExtension, Ptr);
377}
378
379DECLINLINE(VP_STATUS) VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg)
380{
381 *pReg = pDeviceExtension->pPrimary;
382 return NO_ERROR;
383}
384
385DECLINLINE(VP_STATUS) VBoxVideoCmnRegFini(IN VBOXCMNREG Reg)
386{
387 return NO_ERROR;
388}
389
390VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal);
391
392VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val);
393
394/* */
395
396RT_C_DECLS_BEGIN
397ULONG DriverEntry(IN PVOID Context1, IN PVOID Context2);
398RT_C_DECLS_END
399
400VP_STATUS VBoxVideoFindAdapter(
401 IN PVOID HwDeviceExtension,
402 IN PVOID HwContext,
403 IN PWSTR ArgumentString,
404 IN OUT PVIDEO_PORT_CONFIG_INFO ConfigInfo,
405 OUT PUCHAR Again);
406
407BOOLEAN VBoxVideoInitialize(PVOID HwDeviceExtension);
408
409BOOLEAN VBoxVideoStartIO(
410 PVOID HwDeviceExtension,
411 PVIDEO_REQUEST_PACKET RequestPacket);
412
413#if defined(VBOX_WITH_HGSMI) && defined(VBOX_WITH_VIDEOHWACCEL)
414BOOLEAN VBoxVideoInterrupt(PVOID HwDeviceExtension);
415#endif
416
417
418BOOLEAN VBoxVideoResetHW(
419 PVOID HwDeviceExtension,
420 ULONG Columns,
421 ULONG Rows);
422
423VP_STATUS VBoxVideoGetPowerState(
424 PVOID HwDeviceExtension,
425 ULONG HwId,
426 PVIDEO_POWER_MANAGEMENT VideoPowerControl);
427
428VP_STATUS VBoxVideoSetPowerState(
429 PVOID HwDeviceExtension,
430 ULONG HwId,
431 PVIDEO_POWER_MANAGEMENT VideoPowerControl);
432
433VP_STATUS VBoxVideoGetChildDescriptor(
434 PVOID HwDeviceExtension,
435 PVIDEO_CHILD_ENUM_INFO ChildEnumInfo,
436 PVIDEO_CHILD_TYPE VideoChildType,
437 PUCHAR pChildDescriptor,
438 PULONG pUId,
439 PULONG pUnused);
440
441
442void VBoxSetupVideoPortFunctions(PDEVICE_EXTENSION PrimaryExtension,
443 VBOXVIDEOPORTPROCS *pCallbacks,
444 PVIDEO_PORT_CONFIG_INFO pConfigInfo);
445
446#else
447
448/* XPDM-WDDM common API */
449DECLINLINE(VOID) VBoxVideoCmnPortWriteUchar(IN PUCHAR Port, IN UCHAR Value)
450{
451 WRITE_PORT_UCHAR(Port,Value);
452}
453
454DECLINLINE(VOID) VBoxVideoCmnPortWriteUshort(IN PUSHORT Port, IN USHORT Value)
455{
456 WRITE_PORT_USHORT(Port,Value);
457}
458
459DECLINLINE(VOID) VBoxVideoCmnPortWriteUlong(IN PULONG Port, IN ULONG Value)
460{
461 WRITE_PORT_ULONG(Port,Value);
462}
463
464DECLINLINE(UCHAR) VBoxVideoCmnPortReadUchar(IN PUCHAR Port)
465{
466 return READ_PORT_UCHAR(Port);
467}
468
469DECLINLINE(USHORT) VBoxVideoCmnPortReadUshort(IN PUSHORT Port)
470{
471 return READ_PORT_USHORT(Port);
472}
473
474DECLINLINE(ULONG) VBoxVideoCmnPortReadUlong(IN PULONG Port)
475{
476 return READ_PORT_ULONG(Port);
477}
478
479DECLINLINE(VOID) VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem)
480{
481 memset(pvMem, 0, cbMem);
482}
483
484DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
485{
486 KeAcquireSpinLock(SpinLock, OldIrql);
487}
488
489DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
490{
491 KeAcquireSpinLockAtDpcLevel(SpinLock);
492}
493
494DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
495{
496 KeReleaseSpinLock(SpinLock, NewIrql);
497}
498
499DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
500{
501 KeReleaseSpinLockFromDpcLevel(SpinLock);
502}
503
504DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
505{
506 KeInitializeSpinLock(SpinLock);
507 return NO_ERROR;
508}
509
510DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
511{
512 return NO_ERROR;
513}
514
515DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
516{
517 return KeSetEvent(pEvent, 0, FALSE);
518}
519
520DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)
521{
522 KeInitializeEvent(pEvent, NotificationEvent, bSignaled);
523 return NO_ERROR;
524}
525
526DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
527{
528 return NO_ERROR;
529}
530
531DECLINLINE(PVOID) VBoxVideoCmnMemAllocNonPaged(IN PDEVICE_EXTENSION pDeviceExtension, IN SIZE_T NumberOfBytes, IN ULONG Tag)
532{
533 return ExAllocatePoolWithTag(NonPagedPool, NumberOfBytes, Tag);
534}
535
536DECLINLINE(VOID) VBoxVideoCmnMemFree(IN PDEVICE_EXTENSION pDeviceExtension, IN PVOID Ptr)
537{
538 ExFreePool(Ptr);
539}
540
541VP_STATUS VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg);
542
543DECLINLINE(VP_STATUS) VBoxVideoCmnRegFini(IN VBOXCMNREG Reg)
544{
545 if(!Reg)
546 return ERROR_INVALID_PARAMETER;
547
548 NTSTATUS Status = ZwClose(Reg);
549 return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
550}
551
552VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal);
553
554VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val);
555
556/* */
557
558RT_C_DECLS_BEGIN
559NTSTATUS
560DriverEntry(
561 IN PDRIVER_OBJECT DriverObject,
562 IN PUNICODE_STRING RegistryPath
563 );
564RT_C_DECLS_END
565
566VOID VBoxWddmGetModesTable(PDEVICE_EXTENSION DeviceExtension, bool bRebuildTable,
567 VIDEO_MODE_INFORMATION ** ppModes, uint32_t * pcModes, uint32_t * pPreferrableMode,
568 D3DKMDT_2DREGION **ppResolutions, uint32_t * pcResolutions);
569
570D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo);
571UINT vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format);
572
573DECLINLINE(ULONG) vboxWddmVramReportedSize(PDEVICE_EXTENSION pDevExt)
574{
575 return pDevExt->u.primary.Vdma.CmdHeap.area.offBase;
576}
577
578NTSTATUS vboxVidPnCheckTopology(const D3DKMDT_HVIDPN hDesiredVidPn,
579 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
580 BOOLEAN *pbSupported);
581
582NTSTATUS vboxVidPnCheckSourceModeInfo(const D3DKMDT_HVIDPN hDesiredVidPn,
583 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo,
584 BOOLEAN *pbSupported);
585
586NTSTATUS vboxVidPnCheckSourceModeSet(const D3DKMDT_HVIDPN hDesiredVidPn,
587 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
588 BOOLEAN *pbSupported);
589
590NTSTATUS vboxVidPnCheckTargetModeInfo(const D3DKMDT_HVIDPN hDesiredVidPn,
591 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo,
592 BOOLEAN *pbSupported);
593
594NTSTATUS vboxVidPnCheckTargetModeSet(const D3DKMDT_HVIDPN hDesiredVidPn,
595 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
596 BOOLEAN *pbSupported);
597
598typedef struct VBOXVIDPNCOFUNCMODALITY
599{
600 NTSTATUS Status;
601 CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* pEnumCofuncModalityArg;
602 /* legacy mode information populated by the common XPDM-WDDM layer */
603 uint32_t cModes;
604 uint32_t iPreferredMode;
605 VIDEO_MODE_INFORMATION *pModes;
606 uint32_t cResolutions;
607 D3DKMDT_2DREGION *pResolutions;
608}VBOXVIDPNCOFUNCMODALITY, *PVBOXVIDPNCOFUNCMODALITY;
609
610/* !!!NOTE: The callback is responsible for releasing the path */
611typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMPATHS(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
612 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
613 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext);
614typedef FNVBOXVIDPNENUMPATHS *PFNVBOXVIDPNENUMPATHS;
615
616/* !!!NOTE: The callback is responsible for releasing the source mode info */
617typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMSOURCEMODES(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
618 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
619 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext);
620typedef FNVBOXVIDPNENUMSOURCEMODES *PFNVBOXVIDPNENUMSOURCEMODES;
621
622/* !!!NOTE: The callback is responsible for releasing the target mode info */
623typedef DECLCALLBACK(BOOLEAN) FNVBOXVIDPNENUMTARGETMODES(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
624 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
625 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext);
626typedef FNVBOXVIDPNENUMTARGETMODES *PFNVBOXVIDPNENUMTARGETMODES;
627
628
629DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityPathEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
630 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
631 const D3DKMDT_VIDPN_PRESENT_PATH *pNewVidPnPresentPathInfo, PVOID pContext);
632
633DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalitySourceModeEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
634 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
635 const D3DKMDT_VIDPN_SOURCE_MODE *pNewVidPnSourceModeInfo, PVOID pContext);
636
637DECLCALLBACK(BOOLEAN) vboxVidPnCofuncModalityTargetModeEnum(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
638 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
639 const D3DKMDT_VIDPN_TARGET_MODE *pNewVidPnTargetModeInfo, PVOID pContext);
640
641NTSTATUS vboxVidPnEnumPaths(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
642 D3DKMDT_HVIDPNTOPOLOGY hVidPnTopology, const DXGK_VIDPNTOPOLOGY_INTERFACE* pVidPnTopologyInterface,
643 PFNVBOXVIDPNENUMPATHS pfnCallback, PVOID pContext);
644
645NTSTATUS vboxVidPnEnumSourceModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
646 D3DKMDT_HVIDPNSOURCEMODESET hNewVidPnSourceModeSet, const DXGK_VIDPNSOURCEMODESET_INTERFACE *pVidPnSourceModeSetInterface,
647 PFNVBOXVIDPNENUMSOURCEMODES pfnCallback, PVOID pContext);
648
649NTSTATUS vboxVidPnEnumTargetModes(PDEVICE_EXTENSION pDevExt, const D3DKMDT_HVIDPN hDesiredVidPn, const DXGK_VIDPN_INTERFACE* pVidPnInterface,
650 D3DKMDT_HVIDPNTARGETMODESET hNewVidPnTargetModeSet, const DXGK_VIDPNTARGETMODESET_INTERFACE *pVidPnTargetModeSetInterface,
651 PFNVBOXVIDPNENUMTARGETMODES pfnCallback, PVOID pContext);
652#endif
653
654BOOLEAN FASTCALL VBoxVideoSetCurrentMode(
655 PDEVICE_EXTENSION DeviceExtension,
656 PVIDEO_MODE RequestedMode,
657 PSTATUS_BLOCK StatusBlock);
658
659BOOLEAN FASTCALL VBoxVideoResetDevice(
660 PDEVICE_EXTENSION DeviceExtension,
661 PSTATUS_BLOCK StatusBlock);
662
663BOOLEAN FASTCALL VBoxVideoMapVideoMemory(
664 PDEVICE_EXTENSION DeviceExtension,
665 PVIDEO_MEMORY RequestedAddress,
666 PVIDEO_MEMORY_INFORMATION MapInformation,
667 PSTATUS_BLOCK StatusBlock);
668
669BOOLEAN FASTCALL VBoxVideoUnmapVideoMemory(
670 PDEVICE_EXTENSION DeviceExtension,
671 PVIDEO_MEMORY VideoMemory,
672 PSTATUS_BLOCK StatusBlock);
673
674BOOLEAN FASTCALL VBoxVideoQueryNumAvailModes(
675 PDEVICE_EXTENSION DeviceExtension,
676 PVIDEO_NUM_MODES Modes,
677 PSTATUS_BLOCK StatusBlock);
678
679BOOLEAN FASTCALL VBoxVideoQueryAvailModes(
680 PDEVICE_EXTENSION DeviceExtension,
681 PVIDEO_MODE_INFORMATION ReturnedModes,
682 PSTATUS_BLOCK StatusBlock);
683
684BOOLEAN FASTCALL VBoxVideoQueryCurrentMode(
685 PDEVICE_EXTENSION DeviceExtension,
686 PVIDEO_MODE_INFORMATION VideoModeInfo,
687 PSTATUS_BLOCK StatusBlock);
688
689BOOLEAN FASTCALL VBoxVideoSetColorRegisters(
690 PDEVICE_EXTENSION DeviceExtension,
691 PVIDEO_CLUT ColorLookUpTable,
692 PSTATUS_BLOCK StatusBlock);
693
694int VBoxMapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
695 void **ppv,
696 ULONG ulOffset,
697 ULONG ulSize);
698
699void VBoxUnmapAdapterMemory (PDEVICE_EXTENSION PrimaryExtension,
700 void **ppv, ULONG ulSize);
701
702void VBoxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension);
703
704#ifdef VBOX_WITH_HGSMI
705
706/*
707 * Host and Guest port IO helpers.
708 */
709DECLINLINE(void) VBoxHGSMIHostWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
710{
711#ifndef VBOXWDDM
712 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost, data);
713#else
714 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->u.primary.IOPortHost, data);
715#endif
716}
717
718DECLINLINE(ULONG) VBoxHGSMIHostRead(PDEVICE_EXTENSION PrimaryExtension)
719{
720#ifndef VBOXWDDM
721 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortHost);
722#else
723 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->u.primary.IOPortHost);
724#endif
725}
726
727DECLINLINE(void) VBoxHGSMIGuestWrite(PDEVICE_EXTENSION PrimaryExtension, ULONG data)
728{
729#ifndef VBOXWDDM
730 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest, data);
731#else
732 VBoxVideoCmnPortWriteUlong((PULONG)PrimaryExtension->u.primary.IOPortGuest, data);
733#endif
734}
735
736DECLINLINE(ULONG) VBoxHGSMIGuestRead(PDEVICE_EXTENSION PrimaryExtension)
737{
738#ifndef VBOXWDDM
739 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->pPrimary->u.primary.IOPortGuest);
740#else
741 return VBoxVideoCmnPortReadUlong((PULONG)PrimaryExtension->u.primary.IOPortGuest);
742#endif
743}
744
745BOOLEAN VBoxHGSMIIsSupported (PDEVICE_EXTENSION PrimaryExtension);
746
747VOID VBoxSetupDisplaysHGSMI (PDEVICE_EXTENSION PrimaryExtension,
748#ifndef VBOXWDDM
749 PVIDEO_PORT_CONFIG_INFO pConfigInfo,
750#endif
751 ULONG AdapterMemorySize);
752BOOLEAN vboxUpdatePointerShape (PDEVICE_EXTENSION DeviceExtension,
753 PVIDEO_POINTER_ATTRIBUTES pointerAttr,
754 uint32_t cbLength);
755#ifndef VBOXWDDM
756DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
757DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd);
758#endif
759
760
761int vboxVBVAChannelDisplayEnable(PDEVICE_EXTENSION PrimaryExtension,
762 int iDisplay, /* negative would mean this is a miniport handler */
763 uint8_t u8Channel);
764
765VOID VBoxVideoHGSMIDpc(
766 IN PVOID HwDeviceExtension,
767 IN PVOID Context
768 );
769
770void HGSMIClearIrq (PDEVICE_EXTENSION PrimaryExtension);
771
772#endif /* VBOX_WITH_HGSMI */
773} /* extern "C" */
774
775#endif /* VBOXVIDEO_H */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette