VirtualBox

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

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

wddm: more secondary monitor autoresize fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.0 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#ifdef VBOX_WITH_WDDM
111#define VBOX_WITH_GENERIC_MULTIMONITOR
112typedef struct _DEVICE_EXTENSION *PDEVICE_EXTENSION;
113#include <VBox/VBoxVideo.h>
114#include "wddm/VBoxVideoIf.h"
115#include "wddm/VBoxVideoMisc.h"
116#include "wddm/VBoxVideoShgsmi.h"
117#include "wddm/VBoxVideoCm.h"
118#include "wddm/VBoxVideoVdma.h"
119#include "wddm/VBoxVideoWddm.h"
120#include "wddm/VBoxVideoVidPn.h"
121#ifdef VBOXWDDM_WITH_VBVA
122# include "wddm/VBoxVideoVbva.h"
123#endif
124#ifdef VBOX_WITH_VIDEOHWACCEL
125# include "wddm/VBoxVideoVhwa.h"
126#endif
127
128#define VBOXWDDM_POINTER_ATTRIBUTES_SIZE VBOXWDDM_ROUNDBOUND( \
129 VBOXWDDM_ROUNDBOUND( sizeof (VIDEO_POINTER_ATTRIBUTES), 4 ) + \
130 VBOXWDDM_ROUNDBOUND(VBOXWDDM_C_POINTER_MAX_WIDTH * VBOXWDDM_C_POINTER_MAX_HEIGHT * 4, 4) + \
131 VBOXWDDM_ROUNDBOUND((VBOXWDDM_C_POINTER_MAX_WIDTH * VBOXWDDM_C_POINTER_MAX_HEIGHT + 7) >> 3, 4) \
132 , 8)
133
134typedef struct VBOXWDDM_POINTER_INFO
135{
136 uint32_t xPos;
137 uint32_t yPos;
138 union
139 {
140 VIDEO_POINTER_ATTRIBUTES data;
141 char buffer[VBOXWDDM_POINTER_ATTRIBUTES_SIZE];
142 } Attributes;
143} VBOXWDDM_POINTER_INFO, *PVBOXWDDM_POINTER_INFO;
144
145typedef struct VBOXWDDM_GLOBAL_POINTER_INFO
146{
147 uint32_t cVisible;
148} VBOXWDDM_GLOBAL_POINTER_INFO, *PVBOXWDDM_GLOBAL_POINTER_INFO;
149
150#ifdef VBOX_WITH_VIDEOHWACCEL
151typedef struct VBOXWDDM_VHWA
152{
153 VBOXVHWA_INFO Settings;
154 volatile uint32_t cOverlaysCreated;
155} VBOXWDDM_VHWA;
156#endif
157
158typedef struct VBOXWDDM_SOURCE
159{
160 struct VBOXWDDM_ALLOCATION * pPrimaryAllocation;
161#ifdef VBOXWDDM_RENDER_FROM_SHADOW
162 struct VBOXWDDM_ALLOCATION * pShadowAllocation;
163 VBOXVIDEOOFFSET offVram;
164 VBOXWDDM_SURFACE_DESC SurfDesc;
165 VBOXVBVAINFO Vbva;
166#endif
167#ifdef VBOX_WITH_VIDEOHWACCEL
168 /* @todo: in our case this seems more like a target property,
169 * but keep it here for now */
170 VBOXWDDM_VHWA Vhwa;
171 volatile uint32_t cOverlays;
172 LIST_ENTRY OverlayList;
173 KSPIN_LOCK OverlayListLock;
174#endif
175 POINT VScreenPos;
176 VBOXWDDM_POINTER_INFO PointerInfo;
177} VBOXWDDM_SOURCE, *PVBOXWDDM_SOURCE;
178
179typedef struct VBOXWDDM_TARGET
180{
181 uint32_t ScanLineState;
182 uint32_t HeightVisible;
183 uint32_t HeightTotal;
184} VBOXWDDM_TARGET, *PVBOXWDDM_TARGET;
185
186#endif
187
188typedef struct VBOXVIDEO_COMMON
189{
190 int cDisplays; /* Number of displays. */
191
192 ULONG cbVRAM; /* The VRAM size. */
193
194 ULONG cbMiniportHeap; /* The size of reserved VRAM for miniport driver heap.
195 * It is at offset:
196 * cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap
197 */
198 PVOID pvMiniportHeap; /* The pointer to the miniport heap VRAM.
199 * This is mapped by miniport separately.
200 */
201 volatile HGSMIHOSTFLAGS * pHostFlags; /* HGSMI host flags */
202 volatile bool bHostCmdProcessing;
203
204 PVOID pvAdapterInformation; /* The pointer to the last 4K of VRAM.
205 * This is mapped by miniport separately.
206 */
207
208 /** Host HGSMI capabilities the guest can handle */
209 uint32_t fCaps;
210
211 BOOLEAN bHGSMI; /* Whether HGSMI is enabled. */
212
213 HGSMIAREA areaHostHeap; /* Host heap VRAM area. */
214
215 HGSMICHANNELINFO channels;
216
217 HGSMIHEAP hgsmiAdapterHeap;
218
219 /* The IO Port Number for host commands. */
220 RTIOPORT IOPortHost;
221
222 /* The IO Port Number for guest commands. */
223 RTIOPORT IOPortGuest;
224} VBOXVIDEO_COMMON, *PVBOXVIDEO_COMMON;
225
226typedef struct _DEVICE_EXTENSION
227{
228 struct _DEVICE_EXTENSION *pNext; /* Next extension in the DualView extension list.
229 * The primary extension is the first one.
230 */
231#ifndef VBOX_WITH_WDDM
232 struct _DEVICE_EXTENSION *pPrimary; /* Pointer to the primary device extension. */
233
234 ULONG iDevice; /* Device index: 0 for primary, otherwise a secondary device. */
235
236 ULONG CurrentMode; /* Saved information about video modes */
237 ULONG CurrentModeWidth;
238 ULONG CurrentModeHeight;
239 ULONG CurrentModeBPP;
240
241 ULONG ulFrameBufferOffset; /* The framebuffer position in the VRAM. */
242 ULONG ulFrameBufferSize; /* The size of the current framebuffer. */
243#endif
244 union {
245 /* Information that is only relevant to the primary device or is the same for all devices. */
246 struct {
247
248 void *pvReqFlush; /* Pointer to preallocated generic request structure for
249 * VMMDevReq_VideoAccelFlush. Allocated when VBVA status
250 * is changed. Deallocated on HwReset.
251 */
252
253
254 ULONG ulVbvaEnabled; /* Indicates that VBVA mode is enabled. */
255
256#ifdef VBOX_WITH_WDDM
257 VBOXVDMAINFO Vdma;
258# ifdef VBOXVDMA_WITH_VBVA
259 VBOXVBVAINFO Vbva;
260# endif
261#endif
262 ULONG ulMaxFrameBufferSize; /* The size of the VRAM allocated for the a single framebuffer. */
263
264 BOOLEAN fMouseHidden; /* Has the mouse cursor been hidden by the guest? */
265
266
267 VBOXVIDEO_COMMON commonInfo;
268#ifndef VBOX_WITH_WDDM
269 /* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */
270 VBOXVIDEOPORTPROCS VideoPortProcs;
271#else
272 /* committed VidPn handle */
273 D3DKMDT_HVIDPN hCommittedVidPn;
274 /* Display Port handle and callbacks */
275 DXGKRNL_INTERFACE DxgkInterface;
276#endif
277 } primary;
278
279 /* Secondary device information. */
280 struct {
281 BOOLEAN bEnabled; /* Device enabled flag */
282 } secondary;
283 } u;
284
285 HGSMIAREA areaDisplay; /* Entire VRAM chunk for this display device. */
286
287#ifdef VBOX_WITH_WDDM
288 PDEVICE_OBJECT pPDO;
289 UNICODE_STRING RegKeyName;
290 UNICODE_STRING VideoGuid;
291
292 uint8_t * pvVisibleVram;
293
294 VBOXVIDEOCM_MGR CmMgr;
295 /* hgsmi allocation manager */
296 VBOXVIDEOCM_ALLOC_MGR AllocMgr;
297 VBOXVDMADDI_CMD_QUEUE DdiCmdQueue;
298 LIST_ENTRY SwapchainList3D;
299 /* mutex for context list operations */
300 FAST_MUTEX ContextMutex;
301 KSPIN_LOCK SynchLock;
302 volatile uint32_t cContexts3D;
303 volatile uint32_t cUnlockedVBVADisabled;
304
305 VBOXWDDM_GLOBAL_POINTER_INFO PointerInfo;
306
307 VBOXSHGSMILIST CtlList;
308 VBOXSHGSMILIST DmaCmdList;
309#ifdef VBOX_WITH_VIDEOHWACCEL
310 VBOXSHGSMILIST VhwaCmdList;
311#endif
312// BOOL bSetNotifyDxDpc;
313 BOOL bNotifyDxDpc;
314
315 VBOXWDDM_SOURCE aSources[VBOX_VIDEO_MAX_SCREENS];
316 VBOXWDDM_TARGET aTargets[VBOX_VIDEO_MAX_SCREENS];
317#endif
318 BOOLEAN fAnyX; /* Unrestricted horizontal resolution flag. */
319} DEVICE_EXTENSION, *PDEVICE_EXTENSION;
320
321static inline PVBOXVIDEO_COMMON commonFromDeviceExt(PDEVICE_EXTENSION pExt)
322{
323#ifndef VBOX_WITH_WDDM
324 return &pExt->pPrimary->u.primary.commonInfo;
325#else
326 return &pExt->u.primary.commonInfo;
327#endif
328}
329
330static inline PDEVICE_EXTENSION commonToPrimaryExt(PVBOXVIDEO_COMMON pCommon)
331{
332 return RT_FROM_MEMBER(pCommon, DEVICE_EXTENSION, u.primary.commonInfo);
333}
334
335#ifndef VBOX_WITH_WDDM
336#define DEV_MOUSE_HIDDEN(dev) ((dev)->pPrimary->u.primary.fMouseHidden)
337#define DEV_SET_MOUSE_HIDDEN(dev) \
338do { \
339 (dev)->pPrimary->u.primary.fMouseHidden = TRUE; \
340} while (0)
341#define DEV_SET_MOUSE_SHOWN(dev) \
342do { \
343 (dev)->pPrimary->u.primary.fMouseHidden = FALSE; \
344} while (0)
345#else
346#define DEV_MOUSE_HIDDEN(dev) ((dev)->u.primary.fMouseHidden)
347#define DEV_SET_MOUSE_HIDDEN(dev) \
348do { \
349 (dev)->u.primary.fMouseHidden = TRUE; \
350} while (0)
351#define DEV_SET_MOUSE_SHOWN(dev) \
352do { \
353 (dev)->u.primary.fMouseHidden = FALSE; \
354} while (0)
355#endif
356extern "C"
357{
358/** Signal an event in a guest-OS-specific way. pvEvent will be re-cast to
359 * something OS-specific. */
360void VBoxVideoCmnSignalEvent(PVBOXVIDEO_COMMON pCommon, uint64_t pvEvent);
361
362/** Allocate memory to be used in normal driver operation (dispatch level in
363 * Windows) but not necessarily in IRQ context. */
364void *VBoxVideoCmnMemAllocDriver(PVBOXVIDEO_COMMON pCommon, size_t cb);
365
366/** Free memory allocated by @a VBoxVideoCmnMemAllocDriver */
367void VBoxVideoCmnMemFreeDriver(PVBOXVIDEO_COMMON pCommon, void *pv);
368
369/** Write an 8-bit value to an I/O port. */
370void VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value);
371
372/** Write a 16-bit value to an I/O port. */
373void VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value);
374
375/** Write a 32-bit value to an I/O port. */
376void VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value);
377
378/** Read an 8-bit value from an I/O port. */
379uint8_t VBoxVideoCmnPortReadUchar(RTIOPORT Port);
380
381/** Read a 16-bit value from an I/O port. */
382uint16_t VBoxVideoCmnPortReadUshort(RTIOPORT Port);
383
384/** Read a 32-bit value from an I/O port. */
385uint32_t VBoxVideoCmnPortReadUlong(RTIOPORT Port);
386
387#ifndef VBOX_WITH_WDDM
388
389RT_C_DECLS_BEGIN
390ULONG DriverEntry(IN PVOID Context1, IN PVOID Context2);
391RT_C_DECLS_END
392
393#else
394
395RT_C_DECLS_BEGIN
396NTSTATUS
397DriverEntry(
398 IN PDRIVER_OBJECT DriverObject,
399 IN PUNICODE_STRING RegistryPath
400 );
401RT_C_DECLS_END
402
403PVBOXWDDM_VIDEOMODES_INFO vboxWddmGetVideoModesInfo(PDEVICE_EXTENSION DeviceExtension, D3DDDI_VIDEO_PRESENT_TARGET_ID VidPnTargetId);
404PVBOXWDDM_VIDEOMODES_INFO vboxWddmGetAllVideoModesInfos(PDEVICE_EXTENSION DeviceExtension);
405
406void vboxVideoInitCustomVideoModes(PDEVICE_EXTENSION pDevExt);
407
408VOID vboxWddmInvalidateVideoModesInfo(PDEVICE_EXTENSION DeviceExtension);
409
410/* @return STATUS_BUFFER_TOO_SMALL - if buffer is too small, STATUS_SUCCESS - on success */
411NTSTATUS vboxWddmGetModesForResolution(VIDEO_MODE_INFORMATION *pAllModes, uint32_t cAllModes, int iSearchPreferredMode,
412 const D3DKMDT_2DREGION *pResolution, VIDEO_MODE_INFORMATION * pModes, uint32_t cModes, uint32_t *pcModes, int32_t *piPreferrableMode);
413
414int vboxWddmVideoModeFind(const VIDEO_MODE_INFORMATION *pModes, int cModes, const VIDEO_MODE_INFORMATION *pM);
415int vboxWddmVideoResolutionFind(const D3DKMDT_2DREGION *pResolutions, int cResolutions, const D3DKMDT_2DREGION *pRes);
416bool vboxWddmVideoResolutionsMatch(const D3DKMDT_2DREGION *pResolutions1, const D3DKMDT_2DREGION *pResolutions2, int cResolutions);
417bool vboxWddmVideoModesMatch(const VIDEO_MODE_INFORMATION *pModes1, const VIDEO_MODE_INFORMATION *pModes2, int cModes);
418
419D3DDDIFORMAT vboxWddmCalcPixelFormat(const VIDEO_MODE_INFORMATION *pInfo);
420bool vboxWddmFillMode(VIDEO_MODE_INFORMATION *pInfo, D3DDDIFORMAT enmFormat, ULONG w, ULONG h);
421
422DECLINLINE(ULONG) vboxWddmVramCpuVisibleSize(PDEVICE_EXTENSION pDevExt)
423{
424#ifdef VBOXWDDM_RENDER_FROM_SHADOW
425 /* all memory layout info should be initialized */
426 Assert(pDevExt->aSources[0].Vbva.offVBVA);
427 /* page aligned */
428 Assert(!(pDevExt->aSources[0].Vbva.offVBVA & 0xfff));
429
430 return (ULONG)(pDevExt->aSources[0].Vbva.offVBVA & ~0xfffULL);
431#else
432 /* all memory layout info should be initialized */
433 Assert(pDevExt->u.primary.Vdma.CmdHeap.area.offBase);
434 /* page aligned */
435 Assert(!(pDevExt->u.primary.Vdma.CmdHeap.area.offBase & 0xfff));
436
437 return pDevExt->u.primary.Vdma.CmdHeap.area.offBase & ~0xfffUL;
438#endif
439}
440
441DECLINLINE(ULONG) vboxWddmVramCpuVisibleSegmentSize(PDEVICE_EXTENSION pDevExt)
442{
443 return vboxWddmVramCpuVisibleSize(pDevExt);
444}
445
446#ifdef VBOXWDDM_RENDER_FROM_SHADOW
447DECLINLINE(ULONG) vboxWddmVramCpuInvisibleSegmentSize(PDEVICE_EXTENSION pDevExt)
448{
449 return vboxWddmVramCpuVisibleSegmentSize(pDevExt);
450}
451
452DECLINLINE(bool) vboxWddmCmpSurfDescsBase(VBOXWDDM_SURFACE_DESC *pDesc1, VBOXWDDM_SURFACE_DESC *pDesc2)
453{
454 if (pDesc1->width != pDesc2->width)
455 return false;
456 if (pDesc1->height != pDesc2->height)
457 return false;
458 if (pDesc1->format != pDesc2->format)
459 return false;
460 if (pDesc1->bpp != pDesc2->bpp)
461 return false;
462 if (pDesc1->pitch != pDesc2->pitch)
463 return false;
464 return true;
465}
466
467DECLINLINE(void) vboxWddmAssignShadow(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
468{
469 if (pSource->pShadowAllocation == pAllocation)
470 {
471 Assert(pAllocation->bAssigned);
472 return;
473 }
474
475 if (pSource->pShadowAllocation)
476 {
477 PVBOXWDDM_ALLOCATION pOldAlloc = pSource->pShadowAllocation;
478 /* clear the visibility info fo the current primary */
479 pOldAlloc->bVisible = FALSE;
480 pOldAlloc->bAssigned = FALSE;
481 Assert(pOldAlloc->SurfDesc.VidPnSourceId == srcId);
482 /* release the shadow surface */
483 pOldAlloc->SurfDesc.VidPnSourceId = D3DDDI_ID_UNINITIALIZED;
484 }
485
486 if (pAllocation)
487 {
488 Assert(!pAllocation->bAssigned);
489 Assert(!pAllocation->bVisible);
490 pAllocation->bVisible = FALSE;
491 /* this check ensures the shadow is not used for other source simultaneously */
492 Assert(pAllocation->SurfDesc.VidPnSourceId == D3DDDI_ID_UNINITIALIZED);
493 pAllocation->SurfDesc.VidPnSourceId = srcId;
494 pAllocation->bAssigned = TRUE;
495 if (!vboxWddmCmpSurfDescsBase(&pSource->SurfDesc, &pAllocation->SurfDesc))
496 pSource->offVram = VBOXVIDEOOFFSET_VOID; /* force guest->host notification */
497 pSource->SurfDesc = pAllocation->SurfDesc;
498 }
499
500 pSource->pShadowAllocation = pAllocation;
501}
502#endif
503
504DECLINLINE(VOID) vboxWddmAssignPrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
505{
506 if (pSource->pPrimaryAllocation == pAllocation)
507 return;
508
509 if (pSource->pPrimaryAllocation)
510 {
511 PVBOXWDDM_ALLOCATION pOldAlloc = pSource->pPrimaryAllocation;
512 /* clear the visibility info fo the current primary */
513 pOldAlloc->bVisible = FALSE;
514 pOldAlloc->bAssigned = FALSE;
515 Assert(pOldAlloc->SurfDesc.VidPnSourceId == srcId);
516 }
517
518 if (pAllocation)
519 {
520 pAllocation->bVisible = FALSE;
521 Assert(pAllocation->SurfDesc.VidPnSourceId == srcId);
522 pAllocation->SurfDesc.VidPnSourceId = srcId;
523 pAllocation->bAssigned = TRUE;
524 }
525
526 pSource->pPrimaryAllocation = pAllocation;
527}
528
529
530#endif
531
532void* vboxHGSMIBufferAlloc(PVBOXVIDEO_COMMON pCommon,
533 HGSMISIZE cbData,
534 uint8_t u8Ch,
535 uint16_t u16Op);
536void vboxHGSMIBufferFree (PVBOXVIDEO_COMMON pCommon, void *pvBuffer);
537int vboxHGSMIBufferSubmit (PVBOXVIDEO_COMMON pCommon, void *pvBuffer);
538
539BOOLEAN FASTCALL VBoxVideoSetCurrentModePerform(PDEVICE_EXTENSION DeviceExtension,
540 USHORT width, USHORT height, USHORT bpp
541#ifdef VBOX_WITH_WDDM
542 , ULONG offDisplay
543#endif
544 );
545
546BOOLEAN FASTCALL VBoxVideoSetCurrentMode(
547 PDEVICE_EXTENSION DeviceExtension,
548 PVIDEO_MODE RequestedMode,
549 PSTATUS_BLOCK StatusBlock);
550
551BOOLEAN FASTCALL VBoxVideoResetDevice(
552 PDEVICE_EXTENSION DeviceExtension,
553 PSTATUS_BLOCK StatusBlock);
554
555BOOLEAN FASTCALL VBoxVideoMapVideoMemory(
556 PDEVICE_EXTENSION DeviceExtension,
557 PVIDEO_MEMORY RequestedAddress,
558 PVIDEO_MEMORY_INFORMATION MapInformation,
559 PSTATUS_BLOCK StatusBlock);
560
561BOOLEAN FASTCALL VBoxVideoUnmapVideoMemory(
562 PDEVICE_EXTENSION DeviceExtension,
563 PVIDEO_MEMORY VideoMemory,
564 PSTATUS_BLOCK StatusBlock);
565
566BOOLEAN FASTCALL VBoxVideoQueryNumAvailModes(
567 PDEVICE_EXTENSION DeviceExtension,
568 PVIDEO_NUM_MODES Modes,
569 PSTATUS_BLOCK StatusBlock);
570
571BOOLEAN FASTCALL VBoxVideoQueryAvailModes(
572 PDEVICE_EXTENSION DeviceExtension,
573 PVIDEO_MODE_INFORMATION ReturnedModes,
574 PSTATUS_BLOCK StatusBlock);
575
576BOOLEAN FASTCALL VBoxVideoQueryCurrentMode(
577 PDEVICE_EXTENSION DeviceExtension,
578 PVIDEO_MODE_INFORMATION VideoModeInfo,
579 PSTATUS_BLOCK StatusBlock);
580
581BOOLEAN FASTCALL VBoxVideoSetColorRegisters(
582 PDEVICE_EXTENSION DeviceExtension,
583 PVIDEO_CLUT ColorLookUpTable,
584 PSTATUS_BLOCK StatusBlock);
585
586int VBoxMapAdapterMemory (PVBOXVIDEO_COMMON pCommon,
587 void **ppv,
588 ULONG ulOffset,
589 ULONG ulSize);
590
591void VBoxUnmapAdapterMemory (PVBOXVIDEO_COMMON pCommon, void **ppv);
592
593typedef bool(*PFNVIDEOIRQSYNC)(void *);
594bool VBoxSyncToVideoIRQ(PVBOXVIDEO_COMMON pCommon, PFNVIDEOIRQSYNC pfnSync,
595 void *pvUser);
596
597void VBoxComputeFrameBufferSizes (PDEVICE_EXTENSION PrimaryExtension);
598
599
600/*
601 * Host and Guest port IO helpers.
602 */
603DECLINLINE(void) VBoxHGSMIHostWrite(PVBOXVIDEO_COMMON pCommon, ULONG data)
604{
605 VBoxVideoCmnPortWriteUlong(pCommon->IOPortHost, data);
606}
607
608DECLINLINE(ULONG) VBoxHGSMIHostRead(PVBOXVIDEO_COMMON pCommon)
609{
610 return VBoxVideoCmnPortReadUlong(pCommon->IOPortHost);
611}
612
613DECLINLINE(void) VBoxHGSMIGuestWrite(PVBOXVIDEO_COMMON pCommon, ULONG data)
614{
615 VBoxVideoCmnPortWriteUlong(pCommon->IOPortGuest, data);
616}
617
618DECLINLINE(ULONG) VBoxHGSMIGuestRead(PVBOXVIDEO_COMMON pCommon)
619{
620 return VBoxVideoCmnPortReadUlong(pCommon->IOPortGuest);
621}
622
623
624BOOLEAN VBoxHGSMIIsSupported (void);
625
626typedef int FNHGSMIFILLVIEWINFO (void *pvData, VBVAINFOVIEW *pInfo);
627typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO;
628
629int VBoxHGSMISendViewInfo(PVBOXVIDEO_COMMON pCommon, uint32_t u32Count, PFNHGSMIFILLVIEWINFO pfnFill, void *pvData);
630
631VOID VBoxSetupDisplaysHGSMI (PVBOXVIDEO_COMMON pCommon,
632 ULONG AdapterMemorySize, uint32_t fCaps);
633BOOLEAN vboxUpdatePointerShape (PVBOXVIDEO_COMMON pCommon,
634 PVIDEO_POINTER_ATTRIBUTES pointerAttr,
635 uint32_t cbLength);
636
637void VBoxFreeDisplaysHGSMI(PVBOXVIDEO_COMMON pCommon);
638#ifndef VBOX_WITH_WDDM
639DECLCALLBACK(void) hgsmiHostCmdComplete (HVBOXVIDEOHGSMI hHGSMI, struct _VBVAHOSTCMD * pCmd);
640DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, uint32_t iDisplay, struct _VBVAHOSTCMD ** ppCmd);
641#endif
642
643
644int vboxVBVAChannelDisplayEnable(PVBOXVIDEO_COMMON pCommon,
645 int iDisplay, /* negative would mean this is a miniport handler */
646 uint8_t u8Channel);
647
648void hgsmiProcessHostCommandQueue(PVBOXVIDEO_COMMON pCommon);
649
650void HGSMIClearIrq (PVBOXVIDEO_COMMON pCommon);
651
652} /* extern "C" */
653
654#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