VirtualBox

source: vbox/trunk/include/VBox/VBoxVideo.h@ 38643

Last change on this file since 38643 was 37490, checked in by vboxsync, 13 years ago

wddm: autoresize fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 42.5 KB
Line 
1/** @file
2 * VirtualBox Video interface.
3 */
4
5/*
6 * Copyright (C) 2006 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_VBoxVideo_h
27#define ___VBox_VBoxVideo_h
28
29#include <iprt/cdefs.h>
30#include <iprt/types.h>
31
32#include <VBox/VMMDev.h>
33
34/*
35 * The last 4096 bytes of the guest VRAM contains the generic info for all
36 * DualView chunks: sizes and offsets of chunks. This is filled by miniport.
37 *
38 * Last 4096 bytes of each chunk contain chunk specific data: framebuffer info,
39 * etc. This is used exclusively by the corresponding instance of a display driver.
40 *
41 * The VRAM layout:
42 * Last 4096 bytes - Adapter information area.
43 * 4096 bytes aligned miniport heap (value specified in the config rouded up).
44 * Slack - what left after dividing the VRAM.
45 * 4096 bytes aligned framebuffers:
46 * last 4096 bytes of each framebuffer is the display information area.
47 *
48 * The Virtual Graphics Adapter information in the guest VRAM is stored by the
49 * guest video driver using structures prepended by VBOXVIDEOINFOHDR.
50 *
51 * When the guest driver writes dword 0 to the VBE_DISPI_INDEX_VBOX_VIDEO
52 * the host starts to process the info. The first element at the start of
53 * the 4096 bytes region should be normally be a LINK that points to
54 * actual information chain. That way the guest driver can have some
55 * fixed layout of the information memory block and just rewrite
56 * the link to point to relevant memory chain.
57 *
58 * The processing stops at the END element.
59 *
60 * The host can access the memory only when the port IO is processed.
61 * All data that will be needed later must be copied from these 4096 bytes.
62 * But other VRAM can be used by host until the mode is disabled.
63 *
64 * The guest driver writes dword 0xffffffff to the VBE_DISPI_INDEX_VBOX_VIDEO
65 * to disable the mode.
66 *
67 * VBE_DISPI_INDEX_VBOX_VIDEO is used to read the configuration information
68 * from the host and issue commands to the host.
69 *
70 * The guest writes the VBE_DISPI_INDEX_VBOX_VIDEO index register, the the
71 * following operations with the VBE data register can be performed:
72 *
73 * Operation Result
74 * write 16 bit value NOP
75 * read 16 bit value count of monitors
76 * write 32 bit value sets the vbox command value and the command processed by the host
77 * read 32 bit value result of the last vbox command is returned
78 */
79
80#define VBOX_VIDEO_PRIMARY_SCREEN 0
81#define VBOX_VIDEO_NO_SCREEN ~0
82
83#define VBOX_VIDEO_MAX_SCREENS 64
84
85/* The size of the information. */
86/*
87 * The minimum HGSMI heap size is PAGE_SIZE (4096 bytes) and is a restriction of the
88 * runtime heapsimple API. Use minimum 2 pages here, because the info area also may
89 * contain other data (for example HGSMIHOSTFLAGS structure).
90 */
91#ifndef VBOX_XPDM_MINIPORT
92# define VBVA_ADAPTER_INFORMATION_SIZE (64*_1K)
93#else
94#define VBVA_ADAPTER_INFORMATION_SIZE (16*_1K)
95#define VBVA_DISPLAY_INFORMATION_SIZE (64*_1K)
96#endif
97#define VBVA_MIN_BUFFER_SIZE (64*_1K)
98
99
100/* The value for port IO to let the adapter to interpret the adapter memory. */
101#define VBOX_VIDEO_DISABLE_ADAPTER_MEMORY 0xFFFFFFFF
102
103/* The value for port IO to let the adapter to interpret the adapter memory. */
104#define VBOX_VIDEO_INTERPRET_ADAPTER_MEMORY 0x00000000
105
106/* The value for port IO to let the adapter to interpret the display memory.
107 * The display number is encoded in low 16 bits.
108 */
109#define VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE 0x00010000
110
111
112/* The end of the information. */
113#define VBOX_VIDEO_INFO_TYPE_END 0
114/* Instructs the host to fetch the next VBOXVIDEOINFOHDR at the given offset of VRAM. */
115#define VBOX_VIDEO_INFO_TYPE_LINK 1
116/* Information about a display memory position. */
117#define VBOX_VIDEO_INFO_TYPE_DISPLAY 2
118/* Information about a screen. */
119#define VBOX_VIDEO_INFO_TYPE_SCREEN 3
120/* Information about host notifications for the driver. */
121#define VBOX_VIDEO_INFO_TYPE_HOST_EVENTS 4
122/* Information about non-volatile guest VRAM heap. */
123#define VBOX_VIDEO_INFO_TYPE_NV_HEAP 5
124/* VBVA enable/disable. */
125#define VBOX_VIDEO_INFO_TYPE_VBVA_STATUS 6
126/* VBVA flush. */
127#define VBOX_VIDEO_INFO_TYPE_VBVA_FLUSH 7
128/* Query configuration value. */
129#define VBOX_VIDEO_INFO_TYPE_QUERY_CONF32 8
130
131
132#pragma pack(1)
133typedef struct VBOXVIDEOINFOHDR
134{
135 uint8_t u8Type;
136 uint8_t u8Reserved;
137 uint16_t u16Length;
138} VBOXVIDEOINFOHDR;
139
140
141typedef struct VBOXVIDEOINFOLINK
142{
143 /* Relative offset in VRAM */
144 int32_t i32Offset;
145} VBOXVIDEOINFOLINK;
146
147
148/* Resides in adapter info memory. Describes a display VRAM chunk. */
149typedef struct VBOXVIDEOINFODISPLAY
150{
151 /* Index of the framebuffer assigned by guest. */
152 uint32_t u32Index;
153
154 /* Absolute offset in VRAM of the framebuffer to be displayed on the monitor. */
155 uint32_t u32Offset;
156
157 /* The size of the memory that can be used for the screen. */
158 uint32_t u32FramebufferSize;
159
160 /* The size of the memory that is used for the Display information.
161 * The information is at u32Offset + u32FramebufferSize
162 */
163 uint32_t u32InformationSize;
164
165} VBOXVIDEOINFODISPLAY;
166
167
168/* Resides in display info area, describes the current video mode. */
169#define VBOX_VIDEO_INFO_SCREEN_F_NONE 0x00
170#define VBOX_VIDEO_INFO_SCREEN_F_ACTIVE 0x01
171
172typedef struct VBOXVIDEOINFOSCREEN
173{
174 /* Physical X origin relative to the primary screen. */
175 int32_t xOrigin;
176
177 /* Physical Y origin relative to the primary screen. */
178 int32_t yOrigin;
179
180 /* The scan line size in bytes. */
181 uint32_t u32LineSize;
182
183 /* Width of the screen. */
184 uint16_t u16Width;
185
186 /* Height of the screen. */
187 uint16_t u16Height;
188
189 /* Color depth. */
190 uint8_t bitsPerPixel;
191
192 /* VBOX_VIDEO_INFO_SCREEN_F_* */
193 uint8_t u8Flags;
194} VBOXVIDEOINFOSCREEN;
195
196/* The guest initializes the structure to 0. The positions of the structure in the
197 * display info area must not be changed, host will update the structure. Guest checks
198 * the events and modifies the structure as a response to host.
199 */
200#define VBOX_VIDEO_INFO_HOST_EVENTS_F_NONE 0x00000000
201#define VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET 0x00000080
202
203typedef struct VBOXVIDEOINFOHOSTEVENTS
204{
205 /* Host events. */
206 uint32_t fu32Events;
207} VBOXVIDEOINFOHOSTEVENTS;
208
209/* Resides in adapter info memory. Describes the non-volatile VRAM heap. */
210typedef struct VBOXVIDEOINFONVHEAP
211{
212 /* Absolute offset in VRAM of the start of the heap. */
213 uint32_t u32HeapOffset;
214
215 /* The size of the heap. */
216 uint32_t u32HeapSize;
217
218} VBOXVIDEOINFONVHEAP;
219
220/* Display information area. */
221typedef struct VBOXVIDEOINFOVBVASTATUS
222{
223 /* Absolute offset in VRAM of the start of the VBVA QUEUE. 0 to disable VBVA. */
224 uint32_t u32QueueOffset;
225
226 /* The size of the VBVA QUEUE. 0 to disable VBVA. */
227 uint32_t u32QueueSize;
228
229} VBOXVIDEOINFOVBVASTATUS;
230
231typedef struct VBOXVIDEOINFOVBVAFLUSH
232{
233 uint32_t u32DataStart;
234
235 uint32_t u32DataEnd;
236
237} VBOXVIDEOINFOVBVAFLUSH;
238
239#define VBOX_VIDEO_QCI32_MONITOR_COUNT 0
240#define VBOX_VIDEO_QCI32_OFFSCREEN_HEAP_SIZE 1
241
242typedef struct VBOXVIDEOINFOQUERYCONF32
243{
244 uint32_t u32Index;
245
246 uint32_t u32Value;
247
248} VBOXVIDEOINFOQUERYCONF32;
249#pragma pack()
250
251#ifdef VBOX_WITH_VIDEOHWACCEL
252#pragma pack(1)
253
254#define VBOXVHWA_VERSION_MAJ 0
255#define VBOXVHWA_VERSION_MIN 0
256#define VBOXVHWA_VERSION_BLD 6
257#define VBOXVHWA_VERSION_RSV 0
258
259typedef enum
260{
261 VBOXVHWACMD_TYPE_SURF_CANCREATE = 1,
262 VBOXVHWACMD_TYPE_SURF_CREATE,
263 VBOXVHWACMD_TYPE_SURF_DESTROY,
264 VBOXVHWACMD_TYPE_SURF_LOCK,
265 VBOXVHWACMD_TYPE_SURF_UNLOCK,
266 VBOXVHWACMD_TYPE_SURF_BLT,
267 VBOXVHWACMD_TYPE_SURF_FLIP,
268 VBOXVHWACMD_TYPE_SURF_OVERLAY_UPDATE,
269 VBOXVHWACMD_TYPE_SURF_OVERLAY_SETPOSITION,
270 VBOXVHWACMD_TYPE_SURF_COLORKEY_SET,
271 VBOXVHWACMD_TYPE_QUERY_INFO1,
272 VBOXVHWACMD_TYPE_QUERY_INFO2,
273 VBOXVHWACMD_TYPE_ENABLE,
274 VBOXVHWACMD_TYPE_DISABLE,
275 VBOXVHWACMD_TYPE_HH_CONSTRUCT,
276 VBOXVHWACMD_TYPE_HH_RESET
277#ifdef VBOX_WITH_WDDM
278 , VBOXVHWACMD_TYPE_SURF_GETINFO
279 , VBOXVHWACMD_TYPE_SURF_COLORFILL
280#endif
281 , VBOXVHWACMD_TYPE_HH_DISABLE
282 , VBOXVHWACMD_TYPE_HH_ENABLE
283 , VBOXVHWACMD_TYPE_HH_SAVESTATE_SAVEBEGIN
284 , VBOXVHWACMD_TYPE_HH_SAVESTATE_SAVEEND
285 , VBOXVHWACMD_TYPE_HH_SAVESTATE_SAVEPERFORM
286 , VBOXVHWACMD_TYPE_HH_SAVESTATE_LOADPERFORM
287} VBOXVHWACMD_TYPE;
288
289/* the command processing was asynch, set by the host to indicate asynch command completion
290 * must not be cleared once set, the command completion is performed by issuing a host->guest completion command
291 * while keeping this flag unchanged */
292#define VBOXVHWACMD_FLAG_HG_ASYNCH 0x00010000
293/* asynch completion is performed by issuing the event */
294#define VBOXVHWACMD_FLAG_GH_ASYNCH_EVENT 0x00000001
295/* issue interrupt on asynch completion */
296#define VBOXVHWACMD_FLAG_GH_ASYNCH_IRQ 0x00000002
297/* guest does not do any op on completion of this command, the host may copy the command and indicate that it does not need the command anymore
298 * by setting the VBOXVHWACMD_FLAG_HG_ASYNCH_RETURNED flag */
299#define VBOXVHWACMD_FLAG_GH_ASYNCH_NOCOMPLETION 0x00000004
300/* the host has copied the VBOXVHWACMD_FLAG_GH_ASYNCH_NOCOMPLETION command and returned it to the guest */
301#define VBOXVHWACMD_FLAG_HG_ASYNCH_RETURNED 0x00020000
302/* this is the host->host cmd, i.e. a configuration command posted by the host to the framebuffer */
303#define VBOXVHWACMD_FLAG_HH_CMD 0x10000000
304
305typedef struct VBOXVHWACMD
306{
307 VBOXVHWACMD_TYPE enmCmd; /* command type */
308 volatile int32_t rc; /* command result */
309 int32_t iDisplay; /* display index */
310 volatile int32_t Flags; /* ored VBOXVHWACMD_FLAG_xxx values */
311 uint64_t GuestVBVAReserved1; /* field internally used by the guest VBVA cmd handling, must NOT be modified by clients */
312 uint64_t GuestVBVAReserved2; /* field internally used by the guest VBVA cmd handling, must NOT be modified by clients */
313 volatile uint32_t cRefs;
314 int32_t Reserved;
315 union
316 {
317 struct VBOXVHWACMD *pNext;
318 uint32_t offNext;
319 uint64_t Data; /* the body is 64-bit aligned */
320 } u;
321 char body[1];
322} VBOXVHWACMD;
323
324#define VBOXVHWACMD_HEADSIZE() (RT_OFFSETOF(VBOXVHWACMD, body))
325#define VBOXVHWACMD_SIZE_FROMBODYSIZE(_s) (VBOXVHWACMD_HEADSIZE() + (_s))
326#define VBOXVHWACMD_SIZE(_tCmd) (VBOXVHWACMD_SIZE_FROMBODYSIZE(sizeof(_tCmd)))
327typedef unsigned int VBOXVHWACMD_LENGTH;
328typedef uint64_t VBOXVHWA_SURFHANDLE;
329#define VBOXVHWA_SURFHANDLE_INVALID 0ULL
330#define VBOXVHWACMD_BODY(_p, _t) ((_t*)(_p)->body)
331#define VBOXVHWACMD_HEAD(_pb) ((VBOXVHWACMD*)((uint8_t *)(_pb) - RT_OFFSETOF(VBOXVHWACMD, body)))
332
333typedef struct VBOXVHWA_RECTL
334{
335 int32_t left;
336 int32_t top;
337 int32_t right;
338 int32_t bottom;
339} VBOXVHWA_RECTL;
340
341typedef struct VBOXVHWA_COLORKEY
342{
343 uint32_t low;
344 uint32_t high;
345} VBOXVHWA_COLORKEY;
346
347typedef struct VBOXVHWA_PIXELFORMAT
348{
349 uint32_t flags;
350 uint32_t fourCC;
351 union
352 {
353 uint32_t rgbBitCount;
354 uint32_t yuvBitCount;
355 } c;
356
357 union
358 {
359 uint32_t rgbRBitMask;
360 uint32_t yuvYBitMask;
361 } m1;
362
363 union
364 {
365 uint32_t rgbGBitMask;
366 uint32_t yuvUBitMask;
367 } m2;
368
369 union
370 {
371 uint32_t rgbBBitMask;
372 uint32_t yuvVBitMask;
373 } m3;
374
375 union
376 {
377 uint32_t rgbABitMask;
378 } m4;
379
380 uint32_t Reserved;
381} VBOXVHWA_PIXELFORMAT;
382
383typedef struct VBOXVHWA_SURFACEDESC
384{
385 uint32_t flags;
386 uint32_t height;
387 uint32_t width;
388 uint32_t pitch;
389 uint32_t sizeX;
390 uint32_t sizeY;
391 uint32_t cBackBuffers;
392 uint32_t Reserved;
393 VBOXVHWA_COLORKEY DstOverlayCK;
394 VBOXVHWA_COLORKEY DstBltCK;
395 VBOXVHWA_COLORKEY SrcOverlayCK;
396 VBOXVHWA_COLORKEY SrcBltCK;
397 VBOXVHWA_PIXELFORMAT PixelFormat;
398 uint32_t surfCaps;
399 uint32_t Reserved2;
400 VBOXVHWA_SURFHANDLE hSurf;
401 uint64_t offSurface;
402} VBOXVHWA_SURFACEDESC;
403
404typedef struct VBOXVHWA_BLTFX
405{
406 uint32_t flags;
407 uint32_t rop;
408 uint32_t rotationOp;
409 uint32_t rotation;
410 uint32_t fillColor;
411 uint32_t Reserved;
412 VBOXVHWA_COLORKEY DstCK;
413 VBOXVHWA_COLORKEY SrcCK;
414} VBOXVHWA_BLTFX;
415
416typedef struct VBOXVHWA_OVERLAYFX
417{
418 uint32_t flags;
419 uint32_t Reserved1;
420 uint32_t fxFlags;
421 uint32_t Reserved2;
422 VBOXVHWA_COLORKEY DstCK;
423 VBOXVHWA_COLORKEY SrcCK;
424} VBOXVHWA_OVERLAYFX;
425
426#define VBOXVHWA_CAPS_BLT 0x00000040
427#define VBOXVHWA_CAPS_BLTCOLORFILL 0x04000000
428#define VBOXVHWA_CAPS_BLTFOURCC 0x00000100
429#define VBOXVHWA_CAPS_BLTSTRETCH 0x00000200
430#define VBOXVHWA_CAPS_BLTQUEUE 0x00000080
431
432#define VBOXVHWA_CAPS_OVERLAY 0x00000800
433#define VBOXVHWA_CAPS_OVERLAYFOURCC 0x00002000
434#define VBOXVHWA_CAPS_OVERLAYSTRETCH 0x00004000
435#define VBOXVHWA_CAPS_OVERLAYCANTCLIP 0x00001000
436
437#define VBOXVHWA_CAPS_COLORKEY 0x00400000
438#define VBOXVHWA_CAPS_COLORKEYHWASSIST 0x01000000
439
440#define VBOXVHWA_SCAPS_BACKBUFFER 0x00000004
441#define VBOXVHWA_SCAPS_COMPLEX 0x00000008
442#define VBOXVHWA_SCAPS_FLIP 0x00000010
443#define VBOXVHWA_SCAPS_FRONTBUFFER 0x00000020
444#define VBOXVHWA_SCAPS_OFFSCREENPLAIN 0x00000040
445#define VBOXVHWA_SCAPS_OVERLAY 0x00000080
446#define VBOXVHWA_SCAPS_PRIMARYSURFACE 0x00000200
447#define VBOXVHWA_SCAPS_SYSTEMMEMORY 0x00000800
448#define VBOXVHWA_SCAPS_VIDEOMEMORY 0x00004000
449#define VBOXVHWA_SCAPS_VISIBLE 0x00008000
450#define VBOXVHWA_SCAPS_LOCALVIDMEM 0x10000000
451
452#define VBOXVHWA_PF_PALETTEINDEXED8 0x00000020
453#define VBOXVHWA_PF_RGB 0x00000040
454#define VBOXVHWA_PF_RGBTOYUV 0x00000100
455#define VBOXVHWA_PF_YUV 0x00000200
456#define VBOXVHWA_PF_FOURCC 0x00000004
457
458#define VBOXVHWA_LOCK_DISCARDCONTENTS 0x00002000
459
460#define VBOXVHWA_CFG_ENABLED 0x00000001
461
462#define VBOXVHWA_SD_BACKBUFFERCOUNT 0x00000020
463#define VBOXVHWA_SD_CAPS 0x00000001
464#define VBOXVHWA_SD_CKDESTBLT 0x00004000
465#define VBOXVHWA_SD_CKDESTOVERLAY 0x00002000
466#define VBOXVHWA_SD_CKSRCBLT 0x00010000
467#define VBOXVHWA_SD_CKSRCOVERLAY 0x00008000
468#define VBOXVHWA_SD_HEIGHT 0x00000002
469#define VBOXVHWA_SD_PITCH 0x00000008
470#define VBOXVHWA_SD_PIXELFORMAT 0x00001000
471/*#define VBOXVHWA_SD_REFRESHRATE 0x00040000*/
472#define VBOXVHWA_SD_WIDTH 0x00000004
473
474#define VBOXVHWA_CKEYCAPS_DESTBLT 0x00000001
475#define VBOXVHWA_CKEYCAPS_DESTBLTCLRSPACE 0x00000002
476#define VBOXVHWA_CKEYCAPS_DESTBLTCLRSPACEYUV 0x00000004
477#define VBOXVHWA_CKEYCAPS_DESTBLTYUV 0x00000008
478#define VBOXVHWA_CKEYCAPS_DESTOVERLAY 0x00000010
479#define VBOXVHWA_CKEYCAPS_DESTOVERLAYCLRSPACE 0x00000020
480#define VBOXVHWA_CKEYCAPS_DESTOVERLAYCLRSPACEYUV 0x00000040
481#define VBOXVHWA_CKEYCAPS_DESTOVERLAYONEACTIVE 0x00000080
482#define VBOXVHWA_CKEYCAPS_DESTOVERLAYYUV 0x00000100
483#define VBOXVHWA_CKEYCAPS_SRCBLT 0x00000200
484#define VBOXVHWA_CKEYCAPS_SRCBLTCLRSPACE 0x00000400
485#define VBOXVHWA_CKEYCAPS_SRCBLTCLRSPACEYUV 0x00000800
486#define VBOXVHWA_CKEYCAPS_SRCBLTYUV 0x00001000
487#define VBOXVHWA_CKEYCAPS_SRCOVERLAY 0x00002000
488#define VBOXVHWA_CKEYCAPS_SRCOVERLAYCLRSPACE 0x00004000
489#define VBOXVHWA_CKEYCAPS_SRCOVERLAYCLRSPACEYUV 0x00008000
490#define VBOXVHWA_CKEYCAPS_SRCOVERLAYONEACTIVE 0x00010000
491#define VBOXVHWA_CKEYCAPS_SRCOVERLAYYUV 0x00020000
492#define VBOXVHWA_CKEYCAPS_NOCOSTOVERLAY 0x00040000
493
494#define VBOXVHWA_BLT_COLORFILL 0x00000400
495#define VBOXVHWA_BLT_DDFX 0x00000800
496#define VBOXVHWA_BLT_EXTENDED_FLAGS 0x40000000
497#define VBOXVHWA_BLT_EXTENDED_LINEAR_CONTENT 0x00000004
498#define VBOXVHWA_BLT_EXTENDED_PRESENTATION_STRETCHFACTOR 0x00000010
499#define VBOXVHWA_BLT_KEYDESTOVERRIDE 0x00004000
500#define VBOXVHWA_BLT_KEYSRCOVERRIDE 0x00010000
501#define VBOXVHWA_BLT_LAST_PRESENTATION 0x20000000
502#define VBOXVHWA_BLT_PRESENTATION 0x10000000
503#define VBOXVHWA_BLT_ROP 0x00020000
504
505
506#define VBOXVHWA_OVER_DDFX 0x00080000
507#define VBOXVHWA_OVER_HIDE 0x00000200
508#define VBOXVHWA_OVER_KEYDEST 0x00000400
509#define VBOXVHWA_OVER_KEYDESTOVERRIDE 0x00000800
510#define VBOXVHWA_OVER_KEYSRC 0x00001000
511#define VBOXVHWA_OVER_KEYSRCOVERRIDE 0x00002000
512#define VBOXVHWA_OVER_SHOW 0x00004000
513
514#define VBOXVHWA_CKEY_COLORSPACE 0x00000001
515#define VBOXVHWA_CKEY_DESTBLT 0x00000002
516#define VBOXVHWA_CKEY_DESTOVERLAY 0x00000004
517#define VBOXVHWA_CKEY_SRCBLT 0x00000008
518#define VBOXVHWA_CKEY_SRCOVERLAY 0x00000010
519
520#define VBOXVHWA_BLT_ARITHSTRETCHY 0x00000001
521#define VBOXVHWA_BLT_MIRRORLEFTRIGHT 0x00000002
522#define VBOXVHWA_BLT_MIRRORUPDOWN 0x00000004
523
524#define VBOXVHWA_OVERFX_ARITHSTRETCHY 0x00000001
525#define VBOXVHWA_OVERFX_MIRRORLEFTRIGHT 0x00000002
526#define VBOXVHWA_OVERFX_MIRRORUPDOWN 0x00000004
527
528#define VBOXVHWA_CAPS2_CANRENDERWINDOWED 0x00080000
529#define VBOXVHWA_CAPS2_WIDESURFACES 0x00001000
530#define VBOXVHWA_CAPS2_COPYFOURCC 0x00008000
531/*#define VBOXVHWA_CAPS2_FLIPINTERVAL 0x00200000*/
532/*#define VBOXVHWA_CAPS2_FLIPNOVSYNC 0x00400000*/
533
534
535#define VBOXVHWA_OFFSET64_VOID (UINT64_MAX)
536
537typedef struct VBOXVHWA_VERSION
538{
539 uint32_t maj;
540 uint32_t min;
541 uint32_t bld;
542 uint32_t reserved;
543} VBOXVHWA_VERSION;
544
545#define VBOXVHWA_VERSION_INIT(_pv) do { \
546 (_pv)->maj = VBOXVHWA_VERSION_MAJ; \
547 (_pv)->min = VBOXVHWA_VERSION_MIN; \
548 (_pv)->bld = VBOXVHWA_VERSION_BLD; \
549 (_pv)->reserved = VBOXVHWA_VERSION_RSV; \
550 } while(0)
551
552typedef struct VBOXVHWACMD_QUERYINFO1
553{
554 union
555 {
556 struct
557 {
558 VBOXVHWA_VERSION guestVersion;
559 } in;
560
561 struct
562 {
563 uint32_t cfgFlags;
564 uint32_t caps;
565
566 uint32_t caps2;
567 uint32_t colorKeyCaps;
568
569 uint32_t stretchCaps;
570 uint32_t surfaceCaps;
571
572 uint32_t numOverlays;
573 uint32_t curOverlays;
574
575 uint32_t numFourCC;
576 uint32_t reserved;
577 } out;
578 } u;
579} VBOXVHWACMD_QUERYINFO1;
580
581typedef struct VBOXVHWACMD_QUERYINFO2
582{
583 uint32_t numFourCC;
584 uint32_t FourCC[1];
585} VBOXVHWACMD_QUERYINFO2;
586
587#define VBOXVHWAINFO2_SIZE(_cFourCC) RT_OFFSETOF(VBOXVHWACMD_QUERYINFO2, FourCC[_cFourCC])
588
589typedef struct VBOXVHWACMD_SURF_CANCREATE
590{
591 VBOXVHWA_SURFACEDESC SurfInfo;
592 union
593 {
594 struct
595 {
596 uint32_t bIsDifferentPixelFormat;
597 uint32_t Reserved;
598 } in;
599
600 struct
601 {
602 int32_t ErrInfo;
603 } out;
604 } u;
605} VBOXVHWACMD_SURF_CANCREATE;
606
607typedef struct VBOXVHWACMD_SURF_CREATE
608{
609 VBOXVHWA_SURFACEDESC SurfInfo;
610} VBOXVHWACMD_SURF_CREATE;
611
612#ifdef VBOX_WITH_WDDM
613typedef struct VBOXVHWACMD_SURF_GETINFO
614{
615 VBOXVHWA_SURFACEDESC SurfInfo;
616} VBOXVHWACMD_SURF_GETINFO;
617#endif
618
619typedef struct VBOXVHWACMD_SURF_DESTROY
620{
621 union
622 {
623 struct
624 {
625 VBOXVHWA_SURFHANDLE hSurf;
626 } in;
627 } u;
628} VBOXVHWACMD_SURF_DESTROY;
629
630typedef struct VBOXVHWACMD_SURF_LOCK
631{
632 union
633 {
634 struct
635 {
636 VBOXVHWA_SURFHANDLE hSurf;
637 uint64_t offSurface;
638 uint32_t flags;
639 uint32_t rectValid;
640 VBOXVHWA_RECTL rect;
641 } in;
642 } u;
643} VBOXVHWACMD_SURF_LOCK;
644
645typedef struct VBOXVHWACMD_SURF_UNLOCK
646{
647 union
648 {
649 struct
650 {
651 VBOXVHWA_SURFHANDLE hSurf;
652 uint32_t xUpdatedMemValid;
653 uint32_t reserved;
654 VBOXVHWA_RECTL xUpdatedMemRect;
655 } in;
656 } u;
657} VBOXVHWACMD_SURF_UNLOCK;
658
659typedef struct VBOXVHWACMD_SURF_BLT
660{
661 uint64_t DstGuestSurfInfo;
662 uint64_t SrcGuestSurfInfo;
663 union
664 {
665 struct
666 {
667 VBOXVHWA_SURFHANDLE hDstSurf;
668 uint64_t offDstSurface;
669 VBOXVHWA_RECTL dstRect;
670 VBOXVHWA_SURFHANDLE hSrcSurf;
671 uint64_t offSrcSurface;
672 VBOXVHWA_RECTL srcRect;
673 uint32_t flags;
674 uint32_t xUpdatedSrcMemValid;
675 VBOXVHWA_BLTFX desc;
676 VBOXVHWA_RECTL xUpdatedSrcMemRect;
677 } in;
678 } u;
679} VBOXVHWACMD_SURF_BLT;
680
681#ifdef VBOX_WITH_WDDM
682typedef struct VBOXVHWACMD_SURF_COLORFILL
683{
684 union
685 {
686 struct
687 {
688 VBOXVHWA_SURFHANDLE hSurf;
689 uint64_t offSurface;
690 uint32_t u32Reserved;
691 uint32_t cRects;
692 VBOXVHWA_RECTL aRects[1];
693 } in;
694 } u;
695} VBOXVHWACMD_SURF_COLORFILL;
696#endif
697
698typedef struct VBOXVHWACMD_SURF_FLIP
699{
700 uint64_t TargGuestSurfInfo;
701 uint64_t CurrGuestSurfInfo;
702 union
703 {
704 struct
705 {
706 VBOXVHWA_SURFHANDLE hTargSurf;
707 uint64_t offTargSurface;
708 VBOXVHWA_SURFHANDLE hCurrSurf;
709 uint64_t offCurrSurface;
710 uint32_t flags;
711 uint32_t xUpdatedTargMemValid;
712 VBOXVHWA_RECTL xUpdatedTargMemRect;
713 } in;
714 } u;
715} VBOXVHWACMD_SURF_FLIP;
716
717typedef struct VBOXVHWACMD_SURF_COLORKEY_SET
718{
719 union
720 {
721 struct
722 {
723 VBOXVHWA_SURFHANDLE hSurf;
724 uint64_t offSurface;
725 VBOXVHWA_COLORKEY CKey;
726 uint32_t flags;
727 uint32_t reserved;
728 } in;
729 } u;
730} VBOXVHWACMD_SURF_COLORKEY_SET;
731
732#define VBOXVHWACMD_SURF_OVERLAY_UPDATE_F_SRCMEMRECT 0x00000001
733#define VBOXVHWACMD_SURF_OVERLAY_UPDATE_F_DSTMEMRECT 0x00000002
734
735typedef struct VBOXVHWACMD_SURF_OVERLAY_UPDATE
736{
737 union
738 {
739 struct
740 {
741 VBOXVHWA_SURFHANDLE hDstSurf;
742 uint64_t offDstSurface;
743 VBOXVHWA_RECTL dstRect;
744 VBOXVHWA_SURFHANDLE hSrcSurf;
745 uint64_t offSrcSurface;
746 VBOXVHWA_RECTL srcRect;
747 uint32_t flags;
748 uint32_t xFlags;
749 VBOXVHWA_OVERLAYFX desc;
750 VBOXVHWA_RECTL xUpdatedSrcMemRect;
751 VBOXVHWA_RECTL xUpdatedDstMemRect;
752 } in;
753 } u;
754}VBOXVHWACMD_SURF_OVERLAY_UPDATE;
755
756typedef struct VBOXVHWACMD_SURF_OVERLAY_SETPOSITION
757{
758 union
759 {
760 struct
761 {
762 VBOXVHWA_SURFHANDLE hDstSurf;
763 uint64_t offDstSurface;
764 VBOXVHWA_SURFHANDLE hSrcSurf;
765 uint64_t offSrcSurface;
766 uint32_t xPos;
767 uint32_t yPos;
768 uint32_t flags;
769 uint32_t reserved;
770 } in;
771 } u;
772} VBOXVHWACMD_SURF_OVERLAY_SETPOSITION;
773
774typedef struct VBOXVHWACMD_HH_CONSTRUCT
775{
776 void *pVM;
777 /* VRAM info for the backend to be able to properly translate VRAM offsets */
778 void *pvVRAM;
779 uint32_t cbVRAM;
780} VBOXVHWACMD_HH_CONSTRUCT;
781
782typedef struct VBOXVHWACMD_HH_SAVESTATE_SAVEPERFORM
783{
784 struct SSMHANDLE * pSSM;
785} VBOXVHWACMD_HH_SAVESTATE_SAVEPERFORM;
786
787typedef struct VBOXVHWACMD_HH_SAVESTATE_LOADPERFORM
788{
789 struct SSMHANDLE * pSSM;
790} VBOXVHWACMD_HH_SAVESTATE_LOADPERFORM;
791
792typedef DECLCALLBACK(void) FNVBOXVHWA_HH_CALLBACK(void*);
793typedef FNVBOXVHWA_HH_CALLBACK *PFNVBOXVHWA_HH_CALLBACK;
794
795#define VBOXVHWA_HH_CALLBACK_SET(_pCmd, _pfn, _parg) \
796 do { \
797 (_pCmd)->GuestVBVAReserved1 = (uint64_t)(uintptr_t)(_pfn); \
798 (_pCmd)->GuestVBVAReserved2 = (uint64_t)(uintptr_t)(_parg); \
799 }while(0)
800
801#define VBOXVHWA_HH_CALLBACK_GET(_pCmd) ((PFNVBOXVHWA_HH_CALLBACK)(_pCmd)->GuestVBVAReserved1)
802#define VBOXVHWA_HH_CALLBACK_GET_ARG(_pCmd) ((void*)(_pCmd)->GuestVBVAReserved2)
803
804#pragma pack()
805#endif /* #ifdef VBOX_WITH_VIDEOHWACCEL */
806
807/* All structures are without alignment. */
808#pragma pack(1)
809
810typedef struct VBVAHOSTFLAGS
811{
812 uint32_t u32HostEvents;
813 uint32_t u32SupportedOrders;
814} VBVAHOSTFLAGS;
815
816typedef struct VBVABUFFER
817{
818 VBVAHOSTFLAGS hostFlags;
819
820 /* The offset where the data start in the buffer. */
821 uint32_t off32Data;
822 /* The offset where next data must be placed in the buffer. */
823 uint32_t off32Free;
824
825 /* The queue of record descriptions. */
826 VBVARECORD aRecords[VBVA_MAX_RECORDS];
827 uint32_t indexRecordFirst;
828 uint32_t indexRecordFree;
829
830 /* Space to leave free in the buffer when large partial records are transferred. */
831 uint32_t cbPartialWriteThreshold;
832
833 uint32_t cbData;
834 uint8_t au8Data[1]; /* variable size for the rest of the VBVABUFFER area in VRAM. */
835} VBVABUFFER;
836
837/* guest->host commands */
838#define VBVA_QUERY_CONF32 1
839#define VBVA_SET_CONF32 2
840#define VBVA_INFO_VIEW 3
841#define VBVA_INFO_HEAP 4
842#define VBVA_FLUSH 5
843#define VBVA_INFO_SCREEN 6
844#define VBVA_ENABLE 7
845#define VBVA_MOUSE_POINTER_SHAPE 8
846#ifdef VBOX_WITH_VIDEOHWACCEL
847# define VBVA_VHWA_CMD 9
848#endif /* # ifdef VBOX_WITH_VIDEOHWACCEL */
849#ifdef VBOX_WITH_VDMA
850# define VBVA_VDMA_CTL 10 /* setup G<->H DMA channel info */
851# define VBVA_VDMA_CMD 11 /* G->H DMA command */
852#endif
853#define VBVA_INFO_CAPS 12 /* informs host about HGSMI caps. see _VBVACAPS below */
854
855/* host->guest commands */
856#define VBVAHG_EVENT 1
857#define VBVAHG_DISPLAY_CUSTOM 2
858#ifdef VBOX_WITH_VDMA
859#define VBVAHG_SHGSMI_COMPLETION 3
860#endif
861
862#ifdef VBOX_WITH_VIDEOHWACCEL
863#define VBVAHG_DCUSTOM_VHWA_CMDCOMPLETE 1
864#pragma pack(1)
865typedef struct VBVAHOSTCMDVHWACMDCOMPLETE
866{
867 uint32_t offCmd;
868}VBVAHOSTCMDVHWACMDCOMPLETE;
869#pragma pack()
870#endif /* # ifdef VBOX_WITH_VIDEOHWACCEL */
871
872#pragma pack(1)
873typedef enum
874{
875 VBVAHOSTCMD_OP_EVENT = 1,
876 VBVAHOSTCMD_OP_CUSTOM
877}VBVAHOSTCMD_OP_TYPE;
878
879typedef struct VBVAHOSTCMDEVENT
880{
881 uint64_t pEvent;
882}VBVAHOSTCMDEVENT;
883
884
885typedef struct VBVAHOSTCMD
886{
887 /* destination ID if >=0 specifies display index, otherwize the command is directed to the miniport */
888 int32_t iDstID;
889 int32_t customOpCode;
890 union
891 {
892 struct VBVAHOSTCMD *pNext;
893 uint32_t offNext;
894 uint64_t Data; /* the body is 64-bit aligned */
895 } u;
896 char body[1];
897}VBVAHOSTCMD;
898
899#define VBVAHOSTCMD_SIZE(_size) (sizeof(VBVAHOSTCMD) + (_size))
900#define VBVAHOSTCMD_BODY(_pCmd, _tBody) ((_tBody*)(_pCmd)->body)
901#define VBVAHOSTCMD_HDR(_pBody) ((VBVAHOSTCMD*)(((uint8_t*)_pBody) - RT_OFFSETOF(VBVAHOSTCMD, body)))
902#define VBVAHOSTCMD_HDRSIZE (RT_OFFSETOF(VBVAHOSTCMD, body))
903
904#pragma pack()
905
906/* VBVACONF32::u32Index */
907#define VBOX_VBVA_CONF32_MONITOR_COUNT 0
908#define VBOX_VBVA_CONF32_HOST_HEAP_SIZE 1
909
910typedef struct VBVACONF32
911{
912 uint32_t u32Index;
913 uint32_t u32Value;
914} VBVACONF32;
915
916typedef struct VBVAINFOVIEW
917{
918 /* Index of the screen, assigned by the guest. */
919 uint32_t u32ViewIndex;
920
921 /* The screen offset in VRAM, the framebuffer starts here. */
922 uint32_t u32ViewOffset;
923
924 /* The size of the VRAM memory that can be used for the view. */
925 uint32_t u32ViewSize;
926
927 /* The recommended maximum size of the VRAM memory for the screen. */
928 uint32_t u32MaxScreenSize;
929} VBVAINFOVIEW;
930
931typedef struct VBVAINFOHEAP
932{
933 /* Absolute offset in VRAM of the start of the heap. */
934 uint32_t u32HeapOffset;
935
936 /* The size of the heap. */
937 uint32_t u32HeapSize;
938
939} VBVAINFOHEAP;
940
941typedef struct VBVAFLUSH
942{
943 uint32_t u32Reserved;
944
945} VBVAFLUSH;
946
947/* VBVAINFOSCREEN::u8Flags */
948#define VBVA_SCREEN_F_NONE 0x0000
949#define VBVA_SCREEN_F_ACTIVE 0x0001
950/** The virtual monitor has been disabled by the guest and should be blacked
951 * out by the host and ignored for purposes of pointer position calculation. */
952#define VBVA_SCREEN_F_DISABLED 0x0002
953
954typedef struct VBVAINFOSCREEN
955{
956 /* Which view contains the screen. */
957 uint32_t u32ViewIndex;
958
959 /* Physical X origin relative to the primary screen. */
960 int32_t i32OriginX;
961
962 /* Physical Y origin relative to the primary screen. */
963 int32_t i32OriginY;
964
965 /* Offset of visible framebuffer relative to the framebuffer start. */
966 uint32_t u32StartOffset;
967
968 /* The scan line size in bytes. */
969 uint32_t u32LineSize;
970
971 /* Width of the screen. */
972 uint32_t u32Width;
973
974 /* Height of the screen. */
975 uint32_t u32Height;
976
977 /* Color depth. */
978 uint16_t u16BitsPerPixel;
979
980 /* VBVA_SCREEN_F_* */
981 uint16_t u16Flags;
982} VBVAINFOSCREEN;
983
984
985/* VBVAENABLE::u32Flags */
986#define VBVA_F_NONE 0x00000000
987#define VBVA_F_ENABLE 0x00000001
988#define VBVA_F_DISABLE 0x00000002
989/* extended VBVA to be used with WDDM */
990#define VBVA_F_EXTENDED 0x00000004
991/* vbva offset is absolute VRAM offset */
992#define VBVA_F_ABSOFFSET 0x00000008
993
994typedef struct VBVAENABLE
995{
996 uint32_t u32Flags;
997 uint32_t u32Offset;
998 int32_t i32Result;
999} VBVAENABLE;
1000
1001typedef struct VBVAENABLE_EX
1002{
1003 VBVAENABLE Base;
1004 uint32_t u32ScreenId;
1005} VBVAENABLE_EX;
1006
1007
1008typedef struct VBVAMOUSEPOINTERSHAPE
1009{
1010 /* The host result. */
1011 int32_t i32Result;
1012
1013 /* VBOX_MOUSE_POINTER_* bit flags. */
1014 uint32_t fu32Flags;
1015
1016 /* X coordinate of the hot spot. */
1017 uint32_t u32HotX;
1018
1019 /* Y coordinate of the hot spot. */
1020 uint32_t u32HotY;
1021
1022 /* Width of the pointer in pixels. */
1023 uint32_t u32Width;
1024
1025 /* Height of the pointer in scanlines. */
1026 uint32_t u32Height;
1027
1028 /* Pointer data.
1029 *
1030 ****
1031 * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color) mask.
1032 *
1033 * For pointers without alpha channel the XOR mask pixels are 32 bit values: (lsb)BGR0(msb).
1034 * For pointers with alpha channel the XOR mask consists of (lsb)BGRA(msb) 32 bit values.
1035 *
1036 * Guest driver must create the AND mask for pointers with alpha channel, so if host does not
1037 * support alpha, the pointer could be displayed as a normal color pointer. The AND mask can
1038 * be constructed from alpha values. For example alpha value >= 0xf0 means bit 0 in the AND mask.
1039 *
1040 * The AND mask is 1 bpp bitmap with byte aligned scanlines. Size of AND mask,
1041 * therefore, is cbAnd = (width + 7) / 8 * height. The padding bits at the
1042 * end of any scanline are undefined.
1043 *
1044 * The XOR mask follows the AND mask on the next 4 bytes aligned offset:
1045 * uint8_t *pXor = pAnd + (cbAnd + 3) & ~3
1046 * Bytes in the gap between the AND and the XOR mask are undefined.
1047 * XOR mask scanlines have no gap between them and size of XOR mask is:
1048 * cXor = width * 4 * height.
1049 ****
1050 *
1051 * Preallocate 4 bytes for accessing actual data as p->au8Data.
1052 */
1053 uint8_t au8Data[4];
1054
1055} VBVAMOUSEPOINTERSHAPE;
1056
1057/* the guest driver can handle asynch guest cmd completion by reading the command offset from io port */
1058#define VBVACAPS_COMPLETEGCMD_BY_IOREAD 0x00000001
1059/* the guest driver can handle video adapter IRQs */
1060#define VBVACAPS_IRQ 0x00000002
1061typedef struct VBVACAPS
1062{
1063 int32_t rc;
1064 uint32_t fCaps;
1065} VBVACAPS;
1066
1067#pragma pack()
1068
1069typedef uint64_t VBOXVIDEOOFFSET;
1070
1071#define VBOXVIDEOOFFSET_VOID ((VBOXVIDEOOFFSET)~0)
1072
1073#pragma pack(1)
1074
1075/*
1076 * VBOXSHGSMI made on top HGSMI and allows receiving notifications
1077 * about G->H command completion
1078 */
1079/* SHGSMI command header */
1080typedef struct VBOXSHGSMIHEADER
1081{
1082 uint64_t pvNext; /*<- completion processing queue */
1083 uint32_t fFlags; /*<- see VBOXSHGSMI_FLAG_XXX Flags */
1084 uint32_t cRefs; /*<- command referece count */
1085 uint64_t u64Info1; /*<- contents depends on the fFlags value */
1086 uint64_t u64Info2; /*<- contents depends on the fFlags value */
1087} VBOXSHGSMIHEADER, *PVBOXSHGSMIHEADER;
1088
1089typedef enum
1090{
1091 VBOXVDMACMD_TYPE_UNDEFINED = 0,
1092 VBOXVDMACMD_TYPE_DMA_PRESENT_BLT = 1,
1093 VBOXVDMACMD_TYPE_DMA_BPB_TRANSFER,
1094 VBOXVDMACMD_TYPE_DMA_BPB_FILL,
1095 VBOXVDMACMD_TYPE_DMA_PRESENT_SHADOW2PRIMARY,
1096 VBOXVDMACMD_TYPE_DMA_PRESENT_CLRFILL,
1097 VBOXVDMACMD_TYPE_DMA_PRESENT_FLIP,
1098 VBOXVDMACMD_TYPE_DMA_NOP,
1099 VBOXVDMACMD_TYPE_CHROMIUM_CMD, /* chromium cmd */
1100 VBOXVDMACMD_TYPE_DMA_BPB_TRANSFER_VRAMSYS,
1101 VBOXVDMACMD_TYPE_CHILD_STATUS_IRQ /* make the device notify child (monitor) state change IRQ */
1102} VBOXVDMACMD_TYPE;
1103
1104#pragma pack()
1105
1106/* the command processing was asynch, set by the host to indicate asynch command completion
1107 * must not be cleared once set, the command completion is performed by issuing a host->guest completion command
1108 * while keeping this flag unchanged */
1109#define VBOXSHGSMI_FLAG_HG_ASYNCH 0x00010000
1110#if 0
1111/* if set - asynch completion is performed by issuing the event,
1112 * if cleared - asynch completion is performed by calling a callback */
1113#define VBOXSHGSMI_FLAG_GH_ASYNCH_EVENT 0x00000001
1114#endif
1115/* issue interrupt on asynch completion, used for critical G->H commands,
1116 * i.e. for completion of which guest is waiting. */
1117#define VBOXSHGSMI_FLAG_GH_ASYNCH_IRQ 0x00000002
1118/* guest does not do any op on completion of this command,
1119 * the host may copy the command and indicate that it does not need the command anymore
1120 * by not setting VBOXSHGSMI_FLAG_HG_ASYNCH */
1121#define VBOXSHGSMI_FLAG_GH_ASYNCH_NOCOMPLETION 0x00000004
1122/* guest requires the command to be processed asynchronously,
1123 * not setting VBOXSHGSMI_FLAG_HG_ASYNCH by the host in this case is treated as command failure */
1124#define VBOXSHGSMI_FLAG_GH_ASYNCH_FORCE 0x00000008
1125/* force IRQ on cmd completion */
1126#define VBOXSHGSMI_FLAG_GH_ASYNCH_IRQ_FORCE 0x00000010
1127/* an IRQ-level callback is associated with the command */
1128#define VBOXSHGSMI_FLAG_GH_ASYNCH_CALLBACK_IRQ 0x00000020
1129/* guest expects this command to be completed synchronously */
1130#define VBOXSHGSMI_FLAG_GH_SYNCH 0x00000040
1131
1132
1133DECLINLINE(uint8_t *) VBoxSHGSMIBufferData (const VBOXSHGSMIHEADER* pHeader)
1134{
1135 return (uint8_t *)pHeader + sizeof (VBOXSHGSMIHEADER);
1136}
1137
1138DECLINLINE(PVBOXSHGSMIHEADER) VBoxSHGSMIBufferHeader (const void *pvData)
1139{
1140 return (PVBOXSHGSMIHEADER)((uint8_t *)pvData - sizeof (VBOXSHGSMIHEADER));
1141}
1142
1143#ifdef VBOX_WITH_VDMA
1144# pragma pack(1)
1145
1146/* VDMA - Video DMA */
1147
1148/* VDMA Control API */
1149/* VBOXVDMA_CTL::u32Flags */
1150typedef enum
1151{
1152 VBOXVDMA_CTL_TYPE_NONE = 0,
1153 VBOXVDMA_CTL_TYPE_ENABLE,
1154 VBOXVDMA_CTL_TYPE_DISABLE,
1155 VBOXVDMA_CTL_TYPE_FLUSH
1156} VBOXVDMA_CTL_TYPE;
1157
1158typedef struct VBOXVDMA_CTL
1159{
1160 VBOXVDMA_CTL_TYPE enmCtl;
1161 uint32_t u32Offset;
1162 int32_t i32Result;
1163} VBOXVDMA_CTL, *PVBOXVDMA_CTL;
1164
1165typedef struct VBOXVDMA_RECTL
1166{
1167 int16_t left;
1168 int16_t top;
1169 uint16_t width;
1170 uint16_t height;
1171} VBOXVDMA_RECTL, *PVBOXVDMA_RECTL;
1172
1173typedef enum
1174{
1175 VBOXVDMA_PIXEL_FORMAT_UNKNOWN = 0,
1176 VBOXVDMA_PIXEL_FORMAT_R8G8B8 = 20,
1177 VBOXVDMA_PIXEL_FORMAT_A8R8G8B8 = 21,
1178 VBOXVDMA_PIXEL_FORMAT_X8R8G8B8 = 22,
1179 VBOXVDMA_PIXEL_FORMAT_R5G6B5 = 23,
1180 VBOXVDMA_PIXEL_FORMAT_X1R5G5B5 = 24,
1181 VBOXVDMA_PIXEL_FORMAT_A1R5G5B5 = 25,
1182 VBOXVDMA_PIXEL_FORMAT_A4R4G4B4 = 26,
1183 VBOXVDMA_PIXEL_FORMAT_R3G3B2 = 27,
1184 VBOXVDMA_PIXEL_FORMAT_A8 = 28,
1185 VBOXVDMA_PIXEL_FORMAT_A8R3G3B2 = 29,
1186 VBOXVDMA_PIXEL_FORMAT_X4R4G4B4 = 30,
1187 VBOXVDMA_PIXEL_FORMAT_A2B10G10R10 = 31,
1188 VBOXVDMA_PIXEL_FORMAT_A8B8G8R8 = 32,
1189 VBOXVDMA_PIXEL_FORMAT_X8B8G8R8 = 33,
1190 VBOXVDMA_PIXEL_FORMAT_G16R16 = 34,
1191 VBOXVDMA_PIXEL_FORMAT_A2R10G10B10 = 35,
1192 VBOXVDMA_PIXEL_FORMAT_A16B16G16R16 = 36,
1193 VBOXVDMA_PIXEL_FORMAT_A8P8 = 40,
1194 VBOXVDMA_PIXEL_FORMAT_P8 = 41,
1195 VBOXVDMA_PIXEL_FORMAT_L8 = 50,
1196 VBOXVDMA_PIXEL_FORMAT_A8L8 = 51,
1197 VBOXVDMA_PIXEL_FORMAT_A4L4 = 52,
1198 VBOXVDMA_PIXEL_FORMAT_V8U8 = 60,
1199 VBOXVDMA_PIXEL_FORMAT_L6V5U5 = 61,
1200 VBOXVDMA_PIXEL_FORMAT_X8L8V8U8 = 62,
1201 VBOXVDMA_PIXEL_FORMAT_Q8W8V8U8 = 63,
1202 VBOXVDMA_PIXEL_FORMAT_V16U16 = 64,
1203 VBOXVDMA_PIXEL_FORMAT_W11V11U10 = 65,
1204 VBOXVDMA_PIXEL_FORMAT_A2W10V10U10 = 67
1205} VBOXVDMA_PIXEL_FORMAT;
1206
1207typedef struct VBOXVDMA_SURF_DESC
1208{
1209 uint32_t width;
1210 uint32_t height;
1211 VBOXVDMA_PIXEL_FORMAT format;
1212 uint32_t bpp;
1213 uint32_t pitch;
1214 uint32_t fFlags;
1215} VBOXVDMA_SURF_DESC, *PVBOXVDMA_SURF_DESC;
1216
1217/*typedef uint64_t VBOXVDMAPHADDRESS;*/
1218typedef uint64_t VBOXVDMASURFHANDLE;
1219
1220/* region specified as a rectangle, otherwize it is a size of memory pointed to by phys address */
1221#define VBOXVDMAOPERAND_FLAGS_RECTL 0x1
1222/* Surface handle is valid */
1223#define VBOXVDMAOPERAND_FLAGS_PRIMARY 0x2
1224/* address is offset in VRAM */
1225#define VBOXVDMAOPERAND_FLAGS_VRAMOFFSET 0x4
1226
1227
1228/* VBOXVDMACBUF_DR::phBuf specifies offset in VRAM */
1229#define VBOXVDMACBUF_FLAG_BUF_VRAM_OFFSET 0x00000001
1230/* command buffer follows the VBOXVDMACBUF_DR in VRAM, VBOXVDMACBUF_DR::phBuf is ignored */
1231#define VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR 0x00000002
1232
1233/*
1234 * We can not submit the DMA command via VRAM since we do not have control over
1235 * DMA command buffer [de]allocation, i.e. we only control the buffer contents.
1236 * In other words the system may call one of our callbacks to fill a command buffer
1237 * with the necessary commands and then discard the buffer w/o any notification.
1238 *
1239 * We have only DMA command buffer physical address at submission time.
1240 *
1241 * so the only way is to */
1242typedef struct VBOXVDMACBUF_DR
1243{
1244 uint16_t fFlags;
1245 uint16_t cbBuf;
1246 /* RT_SUCCESS() - on success
1247 * VERR_INTERRUPTED - on preemption
1248 * VERR_xxx - on error */
1249 int32_t rc;
1250 union
1251 {
1252 uint64_t phBuf;
1253 VBOXVIDEOOFFSET offVramBuf;
1254 } Location;
1255 uint64_t aGuestData[7];
1256} VBOXVDMACBUF_DR, *PVBOXVDMACBUF_DR;
1257
1258#define VBOXVDMACBUF_DR_TAIL(_pCmd, _t) ( (_t*)(((uint8_t*)(_pCmd)) + sizeof (VBOXVDMACBUF_DR)) )
1259#define VBOXVDMACBUF_DR_FROM_TAIL(_pCmd) ( (VBOXVDMACBUF_DR*)(((uint8_t*)(_pCmd)) - sizeof (VBOXVDMACBUF_DR)) )
1260
1261typedef struct VBOXVDMACMD
1262{
1263 VBOXVDMACMD_TYPE enmType;
1264 uint32_t u32CmdSpecific;
1265} VBOXVDMACMD, *PVBOXVDMACMD;
1266
1267#define VBOXVDMACMD_HEADER_SIZE() sizeof (VBOXVDMACMD)
1268#define VBOXVDMACMD_SIZE_FROMBODYSIZE(_s) (VBOXVDMACMD_HEADER_SIZE() + (_s))
1269#define VBOXVDMACMD_SIZE(_t) (VBOXVDMACMD_SIZE_FROMBODYSIZE(sizeof (_t)))
1270#define VBOXVDMACMD_BODY(_pCmd, _t) ( (_t*)(((uint8_t*)(_pCmd)) + VBOXVDMACMD_HEADER_SIZE()) )
1271#define VBOXVDMACMD_FROM_BODY(_pCmd) ( (VBOXVDMACMD*)(((uint8_t*)(_pCmd)) - VBOXVDMACMD_HEADER_SIZE()) )
1272#define VBOXVDMACMD_BODY_FIELD_OFFSET(_ot, _t, _f) ( (_ot)(uintptr_t)( VBOXVDMACMD_BODY(0, uint8_t) + RT_OFFSETOF(_t, _f) ) )
1273
1274typedef struct VBOXVDMACMD_DMA_PRESENT_BLT
1275{
1276 VBOXVIDEOOFFSET offSrc;
1277 VBOXVIDEOOFFSET offDst;
1278 VBOXVDMA_SURF_DESC srcDesc;
1279 VBOXVDMA_SURF_DESC dstDesc;
1280 VBOXVDMA_RECTL srcRectl;
1281 VBOXVDMA_RECTL dstRectl;
1282 uint32_t u32Reserved;
1283 uint32_t cDstSubRects;
1284 VBOXVDMA_RECTL aDstSubRects[1];
1285} VBOXVDMACMD_DMA_PRESENT_BLT, *PVBOXVDMACMD_DMA_PRESENT_BLT;
1286
1287typedef struct VBOXVDMACMD_DMA_PRESENT_SHADOW2PRIMARY
1288{
1289 VBOXVDMA_RECTL Rect;
1290} VBOXVDMACMD_DMA_PRESENT_SHADOW2PRIMARY, *PVBOXVDMACMD_DMA_PRESENT_SHADOW2PRIMARY;
1291
1292
1293#define VBOXVDMACMD_DMA_BPB_TRANSFER_F_SRC_VRAMOFFSET 0x00000001
1294#define VBOXVDMACMD_DMA_BPB_TRANSFER_F_DST_VRAMOFFSET 0x00000002
1295
1296typedef struct VBOXVDMACMD_DMA_BPB_TRANSFER
1297{
1298 uint32_t cbTransferSize;
1299 uint32_t fFlags;
1300 union
1301 {
1302 uint64_t phBuf;
1303 VBOXVIDEOOFFSET offVramBuf;
1304 } Src;
1305 union
1306 {
1307 uint64_t phBuf;
1308 VBOXVIDEOOFFSET offVramBuf;
1309 } Dst;
1310} VBOXVDMACMD_DMA_BPB_TRANSFER, *PVBOXVDMACMD_DMA_BPB_TRANSFER;
1311
1312#define VBOXVDMACMD_SYSMEMEL_F_PAGELIST 0x00000001
1313
1314typedef struct VBOXVDMACMD_SYSMEMEL
1315{
1316 uint32_t cPages;
1317 uint32_t fFlags;
1318 uint64_t phBuf[1];
1319} VBOXVDMACMD_SYSMEMEL, *PVBOXVDMACMD_SYSMEMEL;
1320
1321#define VBOXVDMACMD_SYSMEMEL_NEXT(_pEl) (((_pEl)->fFlags & VBOXVDMACMD_SYSMEMEL_F_PAGELIST) ? \
1322 ((PVBOXVDMACMD_SYSMEMEL)(((uint8_t*)(_pEl))+RT_OFFSETOF(VBOXVDMACMD_SYSMEMEL, phBuf[(_pEl)->cPages]))) \
1323 : \
1324 ((_pEl)+1)
1325
1326#define VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS_SYS2VRAM 0x00000001
1327
1328typedef struct VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS
1329{
1330 uint32_t cTransferPages;
1331 uint32_t fFlags;
1332 VBOXVIDEOOFFSET offVramBuf;
1333 VBOXVDMACMD_SYSMEMEL FirstEl;
1334} VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS, *PVBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS;
1335
1336typedef struct VBOXVDMACMD_DMA_BPB_FILL
1337{
1338 VBOXVIDEOOFFSET offSurf;
1339 uint32_t cbFillSize;
1340 uint32_t u32FillPattern;
1341} VBOXVDMACMD_DMA_BPB_FILL, *PVBOXVDMACMD_DMA_BPB_FILL;
1342
1343#define VBOXVDMA_CHILD_STATUS_F_CONNECTED 0x01
1344#define VBOXVDMA_CHILD_STATUS_F_DISCONNECTED 0x02
1345#define VBOXVDMA_CHILD_STATUS_F_ROTATED 0x04
1346
1347typedef struct VBOXVDMA_CHILD_STATUS
1348{
1349 uint32_t iChild;
1350 uint8_t fFlags;
1351 uint8_t u8RotationAngle;
1352 uint16_t u16Reserved;
1353} VBOXVDMA_CHILD_STATUS, *PVBOXVDMA_CHILD_STATUS;
1354
1355/* apply the aInfos are applied to all targets, the iTarget is ignored */
1356#define VBOXVDMACMD_CHILD_STATUS_IRQ_F_APPLY_TO_ALL 0x00000001
1357
1358typedef struct VBOXVDMACMD_CHILD_STATUS_IRQ
1359{
1360 uint32_t cInfos;
1361 uint32_t fFlags;
1362 VBOXVDMA_CHILD_STATUS aInfos[1];
1363} VBOXVDMACMD_CHILD_STATUS_IRQ, *PVBOXVDMACMD_CHILD_STATUS_IRQ;
1364
1365# pragma pack()
1366#endif /* #ifdef VBOX_WITH_VDMA */
1367
1368#ifdef VBOX_WITH_CRHGSMI
1369# pragma pack(1)
1370typedef struct VBOXVDMACMD_CHROMIUM_BUFFER
1371{
1372 VBOXVIDEOOFFSET offBuffer;
1373 uint32_t cbBuffer;
1374 uint32_t u32GuesData;
1375 uint64_t u64GuesData;
1376} VBOXVDMACMD_CHROMIUM_BUFFER, *PVBOXVDMACMD_CHROMIUM_BUFFER;
1377
1378typedef struct VBOXVDMACMD_CHROMIUM_CMD
1379{
1380 uint32_t cBuffers;
1381 uint32_t u32Reserved;
1382 VBOXVDMACMD_CHROMIUM_BUFFER aBuffers[1];
1383} VBOXVDMACMD_CHROMIUM_CMD, *PVBOXVDMACMD_CHROMIUM_CMD;
1384
1385typedef enum
1386{
1387 VBOXVDMACMD_CHROMIUM_CTL_TYPE_UNKNOWN = 0,
1388 VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP,
1389 VBOXVDMACMD_CHROMIUM_CTL_TYPE_SAVESTATE_BEGIN,
1390 VBOXVDMACMD_CHROMIUM_CTL_TYPE_SAVESTATE_END,
1391 VBOXVDMACMD_CHROMIUM_CTL_TYPE_SIZEHACK = 0xfffffffe
1392} VBOXVDMACMD_CHROMIUM_CTL_TYPE;
1393
1394typedef struct VBOXVDMACMD_CHROMIUM_CTL
1395{
1396 VBOXVDMACMD_CHROMIUM_CTL_TYPE enmType;
1397 uint32_t cbCmd;
1398} VBOXVDMACMD_CHROMIUM_CTL, *PVBOXVDMACMD_CHROMIUM_CTL;
1399
1400typedef struct VBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP
1401{
1402 VBOXVDMACMD_CHROMIUM_CTL Hdr;
1403 union
1404 {
1405 void *pvRamBase;
1406 uint64_t uAlignment;
1407 };
1408} VBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP, *PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP;
1409# pragma pack()
1410#endif
1411
1412#ifdef VBOXVDMA_WITH_VBVA
1413# pragma pack(1)
1414
1415typedef struct VBOXVDMAVBVACMD
1416{
1417 HGSMIOFFSET offCmd;
1418} VBOXVDMAVBVACMD;
1419
1420#pragma pack()
1421#endif
1422
1423#endif
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