VirtualBox

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

Last change on this file since 33980 was 33890, checked in by vboxsync, 14 years ago

Additions/WINNT/Graphics: more refactoring

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.4 KB
Line 
1/** @file
2 * VirtualBox Video miniport driver
3 *
4 * Copyright (C) 2006-2007 Oracle Corporation
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
15#ifndef VBOXVIDEO_H
16#define VBOXVIDEO_H
17
18#include <VBox/cdefs.h>
19#include <VBox/types.h>
20#include <iprt/assert.h>
21
22//#include <iprt/thread.h>
23
24#include <VBox/HGSMI/HGSMI.h>
25#include <VBox/HGSMI/HGSMIChSetup.h>
26#include <VBox/VBoxVideo.h>
27#include "VBoxHGSMI.h"
28
29RT_C_DECLS_BEGIN
30#ifndef VBOX_WITH_WDDM
31#include "dderror.h"
32#include "devioctl.h"
33#include "miniport.h"
34#include "ntddvdeo.h"
35#include "video.h"
36#else
37# ifdef PAGE_SIZE
38# undef PAGE_SIZE
39# endif
40# ifdef PAGE_SHIFT
41# undef PAGE_SHIFT
42# endif
43# define VBOX_WITH_WORKAROUND_MISSING_PACK
44# if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
45# define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
46# define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
47# define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
48# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
49# define _interlockedbittestandset _interlockedbittestandset_StupidDDKVsCompilerCrap
50# define _interlockedbittestandreset _interlockedbittestandreset_StupidDDKVsCompilerCrap
51# define _interlockedbittestandset64 _interlockedbittestandset64_StupidDDKVsCompilerCrap
52# define _interlockedbittestandreset64 _interlockedbittestandreset64_StupidDDKVsCompilerCrap
53# pragma warning(disable : 4163)
54# ifdef VBOX_WITH_WORKAROUND_MISSING_PACK
55# pragma warning(disable : 4103)
56# endif
57# include <ntddk.h>
58# pragma warning(default : 4163)
59# ifdef VBOX_WITH_WORKAROUND_MISSING_PACK
60# pragma pack()
61# pragma warning(default : 4103)
62# endif
63# undef _InterlockedExchange
64# undef _InterlockedExchangeAdd
65# undef _InterlockedCompareExchange
66# undef _InterlockedAddLargeStatistic
67# undef _interlockedbittestandset
68# undef _interlockedbittestandreset
69# undef _interlockedbittestandset64
70# undef _interlockedbittestandreset64
71# else
72# include <ntddk.h>
73# endif
74#include "dispmprt.h"
75#include "ntddvdeo.h"
76#include "dderror.h"
77#endif
78RT_C_DECLS_END
79
80#define VBE_DISPI_IOPORT_INDEX 0x01CE
81#define VBE_DISPI_IOPORT_DATA 0x01CF
82#define VBE_DISPI_INDEX_ID 0x0
83#define VBE_DISPI_INDEX_XRES 0x1
84#define VBE_DISPI_INDEX_YRES 0x2
85#define VBE_DISPI_INDEX_BPP 0x3
86#define VBE_DISPI_INDEX_ENABLE 0x4
87#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
88#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
89#define VBE_DISPI_INDEX_X_OFFSET 0x8
90#define VBE_DISPI_INDEX_Y_OFFSET 0x9
91#define VBE_DISPI_INDEX_VBOX_VIDEO 0xa
92
93#define VBE_DISPI_ID2 0xB0C2
94/* The VBOX interface id. Indicates support for VBE_DISPI_INDEX_VBOX_VIDEO. */
95#define VBE_DISPI_ID_VBOX_VIDEO 0xBE00
96#define VBE_DISPI_ID_HGSMI 0xBE01
97#define VBE_DISPI_ID_ANYX 0xBE02
98#define VBE_DISPI_DISABLED 0x00
99#define VBE_DISPI_ENABLED 0x01
100#define VBE_DISPI_LFB_ENABLED 0x40
101#define VBE_DISPI_LFB_PHYSICAL_ADDRESS 0xE0000000
102#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 4
103#define VBE_DISPI_TOTAL_VIDEO_MEMORY_KB (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB * 1024)
104#define VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES (VBE_DISPI_TOTAL_VIDEO_MEMORY_KB * 1024)
105
106#define VGA_PORT_HGSMI_HOST 0x3b0
107#define VGA_PORT_HGSMI_GUEST 0x3d0
108
109/* common API types */
110#ifndef VBOX_WITH_WDDM
111typedef PSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK;
112typedef UCHAR VBOXVCMNIRQL, *PVBOXVCMNIRQL;
113
114typedef struct _DEVICE_EXTENSION * VBOXCMNREG;
115#else
116#define VBOX_WITH_GENERIC_MULTIMONITOR
117typedef struct _DEVICE_EXTENSION *PDEVICE_EXTENSION;
118#include <VBox/VBoxVideo.h>
119#include "wddm/VBoxVideoIf.h"
120#include "wddm/VBoxVideoMisc.h"
121#include "wddm/VBoxVideoShgsmi.h"
122#include "wddm/VBoxVideoCm.h"
123#include "wddm/VBoxVideoVdma.h"
124#include "wddm/VBoxVideoWddm.h"
125#include "wddm/VBoxVideoVidPn.h"
126#ifdef VBOXWDDM_WITH_VBVA
127# include "wddm/VBoxVideoVbva.h"
128#endif
129#ifdef VBOX_WITH_VIDEOHWACCEL
130# include "wddm/VBoxVideoVhwa.h"
131#endif
132
133
134typedef KSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK;
135typedef KIRQL VBOXVCMNIRQL, *PVBOXVCMNIRQL;
136
137typedef HANDLE VBOXCMNREG;
138
139#define VBOXWDDM_POINTER_ATTRIBUTES_SIZE VBOXWDDM_ROUNDBOUND( \
140 VBOXWDDM_ROUNDBOUND( sizeof (VIDEO_POINTER_ATTRIBUTES), 4 ) + \
141 VBOXWDDM_ROUNDBOUND(VBOXWDDM_C_POINTER_MAX_WIDTH * VBOXWDDM_C_POINTER_MAX_HEIGHT * 4, 4) + \
142 VBOXWDDM_ROUNDBOUND((VBOXWDDM_C_POINTER_MAX_WIDTH * VBOXWDDM_C_POINTER_MAX_HEIGHT + 7) >> 3, 4) \
143 , 8)
144
145typedef struct VBOXWDDM_POINTER_INFO
146{
147 uint32_t xPos;
148 uint32_t yPos;
149 union
150 {
151 VIDEO_POINTER_ATTRIBUTES data;
152 char buffer[VBOXWDDM_POINTER_ATTRIBUTES_SIZE];
153 } Attributes;
154} VBOXWDDM_POINTER_INFO, *PVBOXWDDM_POINTER_INFO;
155
156typedef struct VBOXWDDM_GLOBAL_POINTER_INFO
157{
158 uint32_t cVisible;
159} VBOXWDDM_GLOBAL_POINTER_INFO, *PVBOXWDDM_GLOBAL_POINTER_INFO;
160
161#ifdef VBOX_WITH_VIDEOHWACCEL
162typedef struct VBOXWDDM_VHWA
163{
164 VBOXVHWA_INFO Settings;
165 volatile uint32_t cOverlaysCreated;
166} VBOXWDDM_VHWA;
167#endif
168
169typedef struct VBOXWDDM_SOURCE
170{
171 struct VBOXWDDM_ALLOCATION * pPrimaryAllocation;
172#ifdef VBOXWDDM_RENDER_FROM_SHADOW
173 struct VBOXWDDM_ALLOCATION * pShadowAllocation;
174 VBOXVIDEOOFFSET offVram;
175 VBOXWDDM_SURFACE_DESC SurfDesc;
176 VBOXVBVAINFO Vbva;
177#endif
178#ifdef VBOX_WITH_VIDEOHWACCEL
179 /* @todo: in our case this seems more like a target property,
180 * but keep it here for now */
181 VBOXWDDM_VHWA Vhwa;
182 volatile uint32_t cOverlays;
183 LIST_ENTRY OverlayList;
184 KSPIN_LOCK OverlayListLock;
185#endif
186 POINT VScreenPos;
187 VBOXWDDM_POINTER_INFO PointerInfo;
188} VBOXWDDM_SOURCE, *PVBOXWDDM_SOURCE;
189
190typedef struct VBOXWDDM_TARGET
191{
192 uint32_t ScanLineState;
193 uint32_t HeightVisible;
194 uint32_t HeightTotal;
195} VBOXWDDM_TARGET, *PVBOXWDDM_TARGET;
196
197#endif
198
199typedef struct VBOXVIDEO_COMMON
200{
201 int cDisplays; /* Number of displays. */
202
203 ULONG cbVRAM; /* The VRAM size. */
204
205 ULONG cbMiniportHeap; /* The size of reserved VRAM for miniport driver heap.
206 * It is at offset:
207 * cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap
208 */
209 PVOID pvMiniportHeap; /* The pointer to the miniport heap VRAM.
210 * This is mapped by miniport separately.
211 */
212 volatile HGSMIHOSTFLAGS * pHostFlags; /* HGSMI host flags */
213 volatile bool bHostCmdProcessing;
214
215 PVOID pvAdapterInformation; /* The pointer to the last 4K of VRAM.
216 * This is mapped by miniport separately.
217 */
218
219 /** Host HGSMI capabilities the guest can handle */
220 uint32_t fCaps;
221
222 BOOLEAN bHGSMI; /* Whether HGSMI is enabled. */
223
224 HGSMIAREA areaHostHeap; /* Host heap VRAM area. */
225
226 HGSMICHANNELINFO channels;
227
228 HGSMIHEAP hgsmiAdapterHeap;
229
230 /* The IO Port Number for host commands. */
231 RTIOPORT IOPortHost;
232
233 /* The IO Port Number for guest commands. */
234 RTIOPORT IOPortGuest;
235} VBOXVIDEO_COMMON, *PVBOXVIDEO_COMMON;
236
237typedef struct _DEVICE_EXTENSION
238{
239 struct _DEVICE_EXTENSION *pNext; /* Next extension in the DualView extension list.
240 * The primary extension is the first one.
241 */
242#ifndef VBOX_WITH_WDDM
243 struct _DEVICE_EXTENSION *pPrimary; /* Pointer to the primary device extension. */
244
245 ULONG iDevice; /* Device index: 0 for primary, otherwise a secondary device. */
246
247 ULONG CurrentMode; /* Saved information about video modes */
248 ULONG CurrentModeWidth;
249 ULONG CurrentModeHeight;
250 ULONG CurrentModeBPP;
251
252 ULONG ulFrameBufferOffset; /* The framebuffer position in the VRAM. */
253 ULONG ulFrameBufferSize; /* The size of the current framebuffer. */
254#endif
255 union {
256 /* Information that is only relevant to the primary device or is the same for all devices. */
257 struct {
258
259 void *pvReqFlush; /* Pointer to preallocated generic request structure for
260 * VMMDevReq_VideoAccelFlush. Allocated when VBVA status
261 * is changed. Deallocated on HwReset.
262 */
263
264
265 ULONG ulVbvaEnabled; /* Indicates that VBVA mode is enabled. */
266
267#ifdef VBOX_WITH_WDDM
268 VBOXVDMAINFO Vdma;
269# ifdef VBOXVDMA_WITH_VBVA
270 VBOXVBVAINFO Vbva;
271# endif
272#endif
273 ULONG ulMaxFrameBufferSize; /* The size of the VRAM allocated for the a single framebuffer. */
274
275 BOOLEAN fMouseHidden; /* Has the mouse cursor been hidden by the guest? */
276
277
278 VBOXVIDEO_COMMON commonInfo;
279#ifndef VBOX_WITH_WDDM
280 /* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */
281 VBOXVIDEOPORTPROCS VideoPortProcs;
282#else
283 /* committed VidPn handle */
284 D3DKMDT_HVIDPN hCommittedVidPn;
285 /* Display Port handle and callbacks */
286 DXGKRNL_INTERFACE DxgkInterface;
287#endif
288 } primary;
289
290 /* Secondary device information. */
291 struct {
292 BOOLEAN bEnabled; /* Device enabled flag */
293 } secondary;
294 } u;
295
296 HGSMIAREA areaDisplay; /* Entire VRAM chunk for this display device. */
297
298#ifdef VBOX_WITH_WDDM
299 PDEVICE_OBJECT pPDO;
300 UNICODE_STRING RegKeyName;
301 UNICODE_STRING VideoGuid;
302
303 uint8_t * pvVisibleVram;
304
305 VBOXVIDEOCM_MGR CmMgr;
306 /* hgsmi allocation manager */
307 VBOXVIDEOCM_ALLOC_MGR AllocMgr;
308 VBOXVDMADDI_CMD_QUEUE DdiCmdQueue;
309 LIST_ENTRY SwapchainList3D;
310 /* mutex for context list operations */
311 FAST_MUTEX ContextMutex;
312 KSPIN_LOCK SynchLock;
313 volatile uint32_t cContexts3D;
314 volatile uint32_t cUnlockedVBVADisabled;
315
316 VBOXWDDM_GLOBAL_POINTER_INFO PointerInfo;
317
318 VBOXSHGSMILIST CtlList;
319 VBOXSHGSMILIST DmaCmdList;
320#ifdef VBOX_WITH_VIDEOHWACCEL
321 VBOXSHGSMILIST VhwaCmdList;
322#endif
323// BOOL bSetNotifyDxDpc;
324 BOOL bNotifyDxDpc;
325
326 VBOXWDDM_SOURCE aSources[VBOX_VIDEO_MAX_SCREENS];
327 VBOXWDDM_TARGET aTargets[VBOX_VIDEO_MAX_SCREENS];
328#endif
329 BOOLEAN fAnyX; /* Unrestricted horizontal resolution flag. */
330} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
331
332static inline PVBOXVIDEO_COMMON commonFromDeviceExt(PDEVICE_EXTENSION pExt)
333{
334#ifndef VBOX_WITH_WDDM
335 return &pExt->pPrimary->u.primary.commonInfo;
336#else
337 return &pExt->u.primary.commonInfo;
338#endif
339}
340
341static inline PDEVICE_EXTENSION commonToPrimaryExt(PVBOXVIDEO_COMMON pCommon)
342{
343 return RT_FROM_MEMBER(pCommon, DEVICE_EXTENSION, u.primary.commonInfo);
344}
345
346#ifndef VBOX_WITH_WDDM
347#define DEV_MOUSE_HIDDEN(dev) ((dev)->pPrimary->u.primary.fMouseHidden)
348#define DEV_SET_MOUSE_HIDDEN(dev) \
349do { \
350 (dev)->pPrimary->u.primary.fMouseHidden = TRUE; \
351} while (0)
352#define DEV_SET_MOUSE_SHOWN(dev) \
353do { \
354 (dev)->pPrimary->u.primary.fMouseHidden = FALSE; \
355} while (0)
356#else
357#define DEV_MOUSE_HIDDEN(dev) ((dev)->u.primary.fMouseHidden)
358#define DEV_SET_MOUSE_HIDDEN(dev) \
359do { \
360 (dev)->u.primary.fMouseHidden = TRUE; \
361} while (0)
362#define DEV_SET_MOUSE_SHOWN(dev) \
363do { \
364 (dev)->u.primary.fMouseHidden = FALSE; \
365} while (0)
366#endif
367extern "C"
368{
369/** Signal an event in a guest-OS-specific way. pvEvent will be re-cast to
370 * something OS-specific. */
371void VBoxVideoCmnSignalEvent(PVBOXVIDEO_COMMON pCommon, uint64_t pvEvent);
372
373/** Allocate memory to be used in normal driver operation (dispatch level in
374 * Windows) but not necessarily in IRQ context. */
375void *VBoxVideoCmnMemAllocDriver(PVBOXVIDEO_COMMON pCommon, size_t cb);
376
377/** Free memory allocated by @a VBoxVideoCmnMemAllocDriver */
378void VBoxVideoCmnMemFreeDriver(PVBOXVIDEO_COMMON pCommon, void *pv);
379
380/** Write an 8-bit value to an I/O port. */
381void VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value);
382
383/** Write a 16-bit value to an I/O port. */
384void VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value);
385
386/** Write a 32-bit value to an I/O port. */
387void VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value);
388
389/** Read an 8-bit value from an I/O port. */
390uint8_t VBoxVideoCmnPortReadUchar(RTIOPORT Port);
391
392/** Read a 16-bit value from an I/O port. */
393uint16_t VBoxVideoCmnPortReadUshort(RTIOPORT Port);
394
395/** Read a 32-bit value from an I/O port. */
396uint32_t VBoxVideoCmnPortReadUlong(RTIOPORT Port);
397
398#ifndef VBOX_WITH_WDDM
399/* XPDM-WDDM common API */
400
401DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
402{
403 pDeviceExtension->u.primary.VideoPortProcs.pfnAcquireSpinLock(pDeviceExtension, *SpinLock, OldIrql);
404}
405
406DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
407{
408 pDeviceExtension->u.primary.VideoPortProcs.pfnReleaseSpinLock(pDeviceExtension, *SpinLock, NewIrql);
409}
410
411DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
412{
413 return pDeviceExtension->u.primary.VideoPortProcs.pfnCreateSpinLock(pDeviceExtension, SpinLock);
414}
415
416DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
417{
418 return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteSpinLock(pDeviceExtension, *SpinLock);
419}
420
421/* */
422
423RT_C_DECLS_BEGIN
424ULONG DriverEntry(IN PVOID Context1, IN PVOID Context2);
425RT_C_DECLS_END
426
427#else
428
429/* XPDM-WDDM common API */
430
431DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
432{
433 KeAcquireSpinLock(SpinLock, OldIrql);
434}
435
436DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
437{
438 KeReleaseSpinLock(SpinLock, NewIrql);
439}
440
441DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
442{
443 KeInitializeSpinLock(SpinLock);
444 return NO_ERROR;
445}
446
447DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
448{
449 return NO_ERROR;
450}
451
452/* */
453
454RT_C_DECLS_BEGIN
455NTSTATUS
456DriverEntry(
457 IN PDRIVER_OBJECT DriverObject,
458 IN PUNICODE_STRING RegistryPath
459 );
460RT_C_DECLS_END
461
462PVBOXWDDM_VIDEOMODES_INFO vboxWddmGetVideoModesInfo(PDEVICE_EXTENSION DeviceExtension, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId);
463PVBOXWDDM_VIDEOMODES_INFO vboxWddmGetAllVideoModesInfos(PDEVICE_EXTENSION DeviceExtension);
464
465void vboxVideoInitCustomVideoModes(PDEVICE_EXTENSION pDevExt);
466
467VOID vboxWddmInvalidateVideoModesInfo(PDEVICE_EXTENSION DeviceExtension);
468
469/* @return STATUS_BUFFER_TOO_SMALL - if buffer is too small, STATUS_SUCCESS - on success */
470NTSTATUS vboxWddmGetModesForResolution(PDEVICE_EXTENSION DeviceExtension, PVBOXWDDM_VIDEOMODES_INFO pModeInfos,
471 D3DKMDT_2DREGION *pResolution, VIDEO_MODE_INFORMATION * pModes, uint32_t cModes, uint32_t *pcModes, int32_t *piPreferrableMode);
472
473D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo);
474
475DECLINLINE(ULONG) vboxWddmVramCpuVisibleSize(PDEVICE_EXTENSION pDevExt)
476{
477#ifdef VBOXWDDM_RENDER_FROM_SHADOW
478 /* all memory layout info should be initialized */
479 Assert(pDevExt->aSources[0].Vbva.offVBVA);
480 /* page aligned */
481 Assert(!(pDevExt->aSources[0].Vbva.offVBVA & 0xfff));
482
483 return (ULONG)(pDevExt->aSources[0].Vbva.offVBVA & ~0xfffULL);
484#else
485 /* all memory layout info should be initialized */
486 Assert(pDevExt->u.primary.Vdma.CmdHeap.area.offBase);
487 /* page aligned */
488 Assert(!(pDevExt->u.primary.Vdma.CmdHeap.area.offBase & 0xfff));
489
490 return pDevExt->u.primary.Vdma.CmdHeap.area.offBase & ~0xfffUL;
491#endif
492}
493
494DECLINLINE(ULONG) vboxWddmVramCpuVisibleSegmentSize(PDEVICE_EXTENSION pDevExt)
495{
496 return vboxWddmVramCpuVisibleSize(pDevExt);
497}
498
499#ifdef VBOXWDDM_RENDER_FROM_SHADOW
500DECLINLINE(ULONG) vboxWddmVramCpuInvisibleSegmentSize(PDEVICE_EXTENSION pDevExt)
501{
502 return vboxWddmVramCpuVisibleSegmentSize(pDevExt);
503}
504
505DECLINLINE(bool) vboxWddmCmpSurfDescsBase(VBOXWDDM_SURFACE_DESC *pDesc1, VBOXWDDM_SURFACE_DESC *pDesc2)
506{
507 if (pDesc1->width != pDesc2->width)
508 return false;
509 if (pDesc1->height != pDesc2->height)
510 return false;
511 if (pDesc1->format != pDesc2->format)
512 return false;
513 if (pDesc1->bpp != pDesc2->bpp)
514 return false;
515 if (pDesc1->pitch != pDesc2->pitch)
516 return false;
517 return true;
518}
519
520DECLINLINE(void) vboxWddmAssignShadow(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
521{
522 if (pSource->pShadowAllocation == pAllocation)
523 {
524 Assert(pAllocation->bAssigned);
525 return;
526 }
527
528 if (pSource->pShadowAllocation)
529 {
530 PVBOXWDDM_ALLOCATION pOldAlloc = pSource->pShadowAllocation;
531 /* clear the visibility info fo the current primary */
532 pOldAlloc->bVisible = FALSE;
533 pOldAlloc->bAssigned = FALSE;
534 Assert(pOldAlloc->SurfDesc.VidPnSourceId == srcId);
535 /* release the shadow surface */
536 pOldAlloc->SurfDesc.VidPnSourceId = D3DDDI_ID_UNINITIALIZED;
537 }
538
539 if (pAllocation)
540 {
541 Assert(!pAllocation->bAssigned);
542 Assert(!pAllocation->bVisible);
543 pAllocation->bVisible = FALSE;
544 /* this check ensures the shadow is not used for other source simultaneously */
545 Assert(pAllocation->SurfDesc.VidPnSourceId == D3DDDI_ID_UNINITIALIZED);
546 pAllocation->SurfDesc.VidPnSourceId = srcId;
547 pAllocation->bAssigned = TRUE;
548 if (!vboxWddmCmpSurfDescsBase(&pSource->SurfDesc, &pAllocation->SurfDesc))
549 pSource->offVram = VBOXVIDEOOFFSET_VOID; /* force guest->host notification */
550 pSource->SurfDesc = pAllocation->SurfDesc;
551 }
552
553 pSource->pShadowAllocation = pAllocation;
554}
555#endif
556
557DECLINLINE(VOID) vboxWddmAssignPrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
558{
559 if (pSource->pPrimaryAllocation == pAllocation)
560 return;
561
562 if (pSource->pPrimaryAllocation)
563 {
564 PVBOXWDDM_ALLOCATION pOldAlloc = pSource->pPrimaryAllocation;
565 /* clear the visibility info fo the current primary */
566 pOldAlloc->bVisible = FALSE;
567 pOldAlloc->bAssigned = FALSE;
568 Assert(pOldAlloc->SurfDesc.VidPnSourceId == srcId);
569 }
570
571 if (pAllocation)
572 {
573 pAllocation->bVisible = FALSE;
574 Assert(pAllocation->SurfDesc.VidPnSourceId == srcId);
575 pAllocation->SurfDesc.VidPnSourceId = srcId;
576 pAllocation->bAssigned = TRUE;
577 }
578
579 pSource->pPrimaryAllocation = pAllocation;
580}
581
582
583#endif
584
585void* vboxHGSMIBufferAlloc(PVBOXVIDEO_COMMON pCommon,
586 HGSMISIZE cbData,
587 uint8_t u8Ch,
588 uint16_t u16Op);
589void vboxHGSMIBufferFree (PVBOXVIDEO_COMMON pCommon, void *pvBuffer);
590int vboxHGSMIBufferSubmit (PVBOXVIDEO_COMMON pCommon, void *pvBuffer);
591
592BOOLEAN FASTCALL VBoxVideoSetCurrentModePerform(PDEVICE_EXTENSION DeviceExtension,
593 USHORT width, USHORT height, USHORT bpp
594#ifdef VBOX_WITH_WDDM
595 , ULONG offDisplay
596#endif
597 );
598
599BOOLEAN FASTCALL VBoxVideoSetCurrentMode(
600 PDEVICE_EXTENSION DeviceExtension,
601 PVIDEO_MODE RequestedMode,
602 PSTATUS_BLOCK StatusBlock);
603
604BOOLEAN FASTCALL VBoxVideoResetDevice(
605 PDEVICE_EXTENSION DeviceExtension,
606 PSTATUS_BLOCK StatusBlock);
607
608BOOLEAN FASTCALL VBoxVideoMapVideoMemory(
609 PDEVICE_EXTENSION DeviceExtension,
610 PVIDEO_MEMORY RequestedAddress,
611 PVIDEO_MEMORY_INFORMATION MapInformation,
612 PSTATUS_BLOCK StatusBlock);
613
614BOOLEAN FASTCALL VBoxVideoUnmapVideoMemory(
615 PDEVICE_EXTENSION DeviceExtension,
616 PVIDEO_MEMORY VideoMemory,
617 PSTATUS_BLOCK StatusBlock);
618
619BOOLEAN FASTCALL VBoxVideoQueryNumAvailModes(
620 PDEVICE_EXTENSION DeviceExtension,
621 PVIDEO_NUM_MODES Modes,
622 PSTATUS_BLOCK StatusBlock);
623
624BOOLEAN FASTCALL VBoxVideoQueryAvailModes(
625 PDEVICE_EXTENSION DeviceExtension,
626 PVIDEO_MODE_INFORMATION ReturnedModes,
627 PSTATUS_BLOCK StatusBlock);
628
629BOOLEAN FASTCALL VBoxVideoQueryCurrentMode(
630 PDEVICE_EXTENSION DeviceExtension,
631 PVIDEO_MODE_INFORMATION VideoModeInfo,
632 PSTATUS_BLOCK StatusBlock);
633
634BOOLEAN FASTCALL VBoxVideoSetColorRegisters(
635 PDEVICE_EXTENSION DeviceExtension,
636 PVIDEO_CLUT ColorLookUpTable,
637 PSTATUS_BLOCK StatusBlock);
638
639int VBoxMapAdapterMemory (PVBOXVIDEO_COMMON pCommon,
640 void **ppv,
641 ULONG ulOffset,
642 ULONG ulSize);
643
644void VBoxUnmapAdapterMemory (PVBOXVIDEO_COMMON pCommon, void **ppv);
645
646typedef bool(*PFNVIDEOIRQSYNC)(void *);
647bool VBoxSyncToVideoIRQ(PVBOXVIDEO_COMMON pCommon, PFNVIDEOIRQSYNC pfnSync,
648 void *pvUser);
649
650void VBoxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension);
651
652
653/*
654 * Host and Guest port IO helpers.
655 */
656DECLINLINE(void) VBoxHGSMIHostWrite(PVBOXVIDEO_COMMON pCommon, ULONG data)
657{
658 VBoxVideoCmnPortWriteUlong(pCommon->IOPortHost, data);
659}
660
661DECLINLINE(ULONG) VBoxHGSMIHostRead(PVBOXVIDEO_COMMON pCommon)
662{
663 return VBoxVideoCmnPortReadUlong(pCommon->IOPortHost);
664}
665
666DECLINLINE(void) VBoxHGSMIGuestWrite(PVBOXVIDEO_COMMON pCommon, ULONG data)
667{
668 VBoxVideoCmnPortWriteUlong(pCommon->IOPortGuest, data);
669}
670
671DECLINLINE(ULONG) VBoxHGSMIGuestRead(PVBOXVIDEO_COMMON pCommon)
672{
673 return VBoxVideoCmnPortReadUlong(pCommon->IOPortGuest);
674}
675
676
677BOOLEAN VBoxHGSMIIsSupported (void);
678
679typedef int FNHGSMIFILLVIEWINFO (void *pvData, VBVAINFOVIEW *pInfo);
680typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO;
681
682int VBoxHGSMISendViewInfo(PVBOXVIDEO_COMMON pCommon, uint32_t u32Count, PFNHGSMIFILLVIEWINFO pfnFill, void *pvData);
683
684VOID VBoxSetupDisplaysHGSMI (PVBOXVIDEO_COMMON pCommon,
685 ULONG AdapterMemorySize, uint32_t fCaps);
686BOOLEAN vboxUpdatePointerShape (PVBOXVIDEO_COMMON pCommon,
687 PVIDEO_POINTER_ATTRIBUTES pointerAttr,
688 uint32_t cbLength);
689
690void VBoxFreeDisplaysHGSMI(PVBOXVIDEO_COMMON pCommon);
691#ifndef VBOX_WITH_WDDM
692DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
693DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, uint32_t iDisplay, struct _VBVAHOSTCMD ** ppCmd);
694#endif
695
696
697int vboxVBVAChannelDisplayEnable(PVBOXVIDEO_COMMON pCommon,
698 int iDisplay, /* negative would mean this is a miniport handler */
699 uint8_t u8Channel);
700
701void hgsmiProcessHostCommandQueue(PVBOXVIDEO_COMMON pCommon);
702
703void HGSMIClearIrq (PVBOXVIDEO_COMMON pCommon);
704
705} /* extern "C" */
706
707#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