VirtualBox

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

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

Additions/common/VBoxVideo and Additions/WINNT/Graphics: some adjustments to the common VBoxVideo code

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 41.6 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
951typedef struct VBVAINFOSCREEN
952{
953 /* Which view contains the screen. */
954 uint32_t u32ViewIndex;
955
956 /* Physical X origin relative to the primary screen. */
957 int32_t i32OriginX;
958
959 /* Physical Y origin relative to the primary screen. */
960 int32_t i32OriginY;
961
962 /* Offset of visible framebuffer relative to the framebuffer start. */
963 uint32_t u32StartOffset;
964
965 /* The scan line size in bytes. */
966 uint32_t u32LineSize;
967
968 /* Width of the screen. */
969 uint32_t u32Width;
970
971 /* Height of the screen. */
972 uint32_t u32Height;
973
974 /* Color depth. */
975 uint16_t u16BitsPerPixel;
976
977 /* VBVA_SCREEN_F_* */
978 uint16_t u16Flags;
979} VBVAINFOSCREEN;
980
981
982/* VBVAENABLE::u32Flags */
983#define VBVA_F_NONE 0x00000000
984#define VBVA_F_ENABLE 0x00000001
985#define VBVA_F_DISABLE 0x00000002
986/* extended VBVA to be used with WDDM */
987#define VBVA_F_EXTENDED 0x00000004
988/* vbva offset is absolute VRAM offset */
989#define VBVA_F_ABSOFFSET 0x00000008
990
991typedef struct VBVAENABLE
992{
993 uint32_t u32Flags;
994 uint32_t u32Offset;
995 int32_t i32Result;
996} VBVAENABLE;
997
998typedef struct VBVAENABLE_EX
999{
1000 VBVAENABLE Base;
1001 uint32_t u32ScreenId;
1002} VBVAENABLE_EX;
1003
1004
1005typedef struct VBVAMOUSEPOINTERSHAPE
1006{
1007 /* The host result. */
1008 int32_t i32Result;
1009
1010 /* VBOX_MOUSE_POINTER_* bit flags. */
1011 uint32_t fu32Flags;
1012
1013 /* X coordinate of the hot spot. */
1014 uint32_t u32HotX;
1015
1016 /* Y coordinate of the hot spot. */
1017 uint32_t u32HotY;
1018
1019 /* Width of the pointer in pixels. */
1020 uint32_t u32Width;
1021
1022 /* Height of the pointer in scanlines. */
1023 uint32_t u32Height;
1024
1025 /* Pointer data.
1026 *
1027 ****
1028 * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color) mask.
1029 *
1030 * For pointers without alpha channel the XOR mask pixels are 32 bit values: (lsb)BGR0(msb).
1031 * For pointers with alpha channel the XOR mask consists of (lsb)BGRA(msb) 32 bit values.
1032 *
1033 * Guest driver must create the AND mask for pointers with alpha channel, so if host does not
1034 * support alpha, the pointer could be displayed as a normal color pointer. The AND mask can
1035 * be constructed from alpha values. For example alpha value >= 0xf0 means bit 0 in the AND mask.
1036 *
1037 * The AND mask is 1 bpp bitmap with byte aligned scanlines. Size of AND mask,
1038 * therefore, is cbAnd = (width + 7) / 8 * height. The padding bits at the
1039 * end of any scanline are undefined.
1040 *
1041 * The XOR mask follows the AND mask on the next 4 bytes aligned offset:
1042 * uint8_t *pXor = pAnd + (cbAnd + 3) & ~3
1043 * Bytes in the gap between the AND and the XOR mask are undefined.
1044 * XOR mask scanlines have no gap between them and size of XOR mask is:
1045 * cXor = width * 4 * height.
1046 ****
1047 *
1048 * Preallocate 4 bytes for accessing actual data as p->au8Data.
1049 */
1050 uint8_t au8Data[4];
1051
1052} VBVAMOUSEPOINTERSHAPE;
1053
1054/* the guest driver can handle asynch guest cmd completion by reading the command offset from io port */
1055#define VBVACAPS_COMPLETEGCMD_BY_IOREAD 0x00000001
1056/* the guest driver can handle video adapter IRQs */
1057#define VBVACAPS_IRQ 0x00000002
1058typedef struct VBVACAPS
1059{
1060 int32_t rc;
1061 uint32_t fCaps;
1062} VBVACAPS;
1063
1064#pragma pack()
1065
1066typedef uint64_t VBOXVIDEOOFFSET;
1067
1068#define VBOXVIDEOOFFSET_VOID ((VBOXVIDEOOFFSET)~0)
1069
1070#ifdef VBOX_WITH_WDDM
1071# pragma pack(1)
1072
1073/*
1074 * VBOXSHGSMI made on top HGSMI and allows receiving notifications
1075 * about G->H command completion
1076 */
1077/* SHGSMI command header */
1078typedef struct VBOXSHGSMIHEADER
1079{
1080 uint64_t pvNext; /*<- completion processing queue */
1081 uint32_t fFlags; /*<- see VBOXSHGSMI_FLAG_XXX Flags */
1082 uint32_t cRefs; /*<- command referece count */
1083 uint64_t u64Info1; /*<- contents depends on the fFlags value */
1084 uint64_t u64Info2; /*<- contents depends on the fFlags value */
1085} VBOXSHGSMIHEADER, *PVBOXSHGSMIHEADER;
1086
1087/* the command processing was asynch, set by the host to indicate asynch command completion
1088 * must not be cleared once set, the command completion is performed by issuing a host->guest completion command
1089 * while keeping this flag unchanged */
1090#define VBOXSHGSMI_FLAG_HG_ASYNCH 0x00010000
1091#if 0
1092/* if set - asynch completion is performed by issuing the event,
1093 * if cleared - asynch completion is performed by calling a callback */
1094#define VBOXSHGSMI_FLAG_GH_ASYNCH_EVENT 0x00000001
1095#endif
1096/* issue interrupt on asynch completion, used for critical G->H commands,
1097 * i.e. for completion of which guest is waiting. */
1098#define VBOXSHGSMI_FLAG_GH_ASYNCH_IRQ 0x00000002
1099/* guest does not do any op on completion of this command,
1100 * the host may copy the command and indicate that it does not need the command anymore
1101 * by not setting VBOXSHGSMI_FLAG_HG_ASYNCH */
1102#define VBOXSHGSMI_FLAG_GH_ASYNCH_NOCOMPLETION 0x00000004
1103/* guest requires the command to be processed asynchronously,
1104 * not setting VBOXSHGSMI_FLAG_HG_ASYNCH by the host in this case is treated as command failure */
1105#define VBOXSHGSMI_FLAG_GH_ASYNCH_FORCE 0x00000008
1106/* force IRQ on cmd completion */
1107#define VBOXSHGSMI_FLAG_GH_ASYNCH_IRQ_FORCE 0x00000010
1108/* an IRQ-level callback is associated with the command */
1109#define VBOXSHGSMI_FLAG_GH_ASYNCH_CALLBACK_IRQ 0x00000020
1110/* guest expects this command to be completed synchronously */
1111#define VBOXSHGSMI_FLAG_GH_SYNCH 0x00000040
1112
1113DECLINLINE(uint8_t *) VBoxSHGSMIBufferData (const VBOXSHGSMIHEADER* pHeader)
1114{
1115 return (uint8_t *)pHeader + sizeof (VBOXSHGSMIHEADER);
1116}
1117
1118DECLINLINE(PVBOXSHGSMIHEADER) VBoxSHGSMIBufferHeader (const void *pvData)
1119{
1120 return (PVBOXSHGSMIHEADER)((uint8_t *)pvData - sizeof (VBOXSHGSMIHEADER));
1121}
1122
1123typedef enum
1124{
1125 VBOXVDMACMD_TYPE_UNDEFINED = 0,
1126 VBOXVDMACMD_TYPE_DMA_PRESENT_BLT = 1,
1127 VBOXVDMACMD_TYPE_DMA_BPB_TRANSFER,
1128 VBOXVDMACMD_TYPE_DMA_BPB_FILL,
1129 VBOXVDMACMD_TYPE_DMA_PRESENT_SHADOW2PRIMARY,
1130 VBOXVDMACMD_TYPE_DMA_PRESENT_CLRFILL,
1131 VBOXVDMACMD_TYPE_DMA_PRESENT_FLIP,
1132 VBOXVDMACMD_TYPE_DMA_NOP,
1133 VBOXVDMACMD_TYPE_CHROMIUM_CMD,
1134 VBOXVDMACMD_TYPE_DMA_BPB_TRANSFER_VRAMSYS
1135} VBOXVDMACMD_TYPE;
1136
1137# pragma pack()
1138#endif
1139
1140#ifdef VBOX_WITH_VDMA
1141# pragma pack(1)
1142
1143/* VDMA - Video DMA */
1144
1145/* VDMA Control API */
1146/* VBOXVDMA_CTL::u32Flags */
1147typedef enum
1148{
1149 VBOXVDMA_CTL_TYPE_NONE = 0,
1150 VBOXVDMA_CTL_TYPE_ENABLE,
1151 VBOXVDMA_CTL_TYPE_DISABLE,
1152 VBOXVDMA_CTL_TYPE_FLUSH
1153} VBOXVDMA_CTL_TYPE;
1154
1155typedef struct VBOXVDMA_CTL
1156{
1157 VBOXVDMA_CTL_TYPE enmCtl;
1158 uint32_t u32Offset;
1159 int32_t i32Result;
1160} VBOXVDMA_CTL, *PVBOXVDMA_CTL;
1161
1162typedef struct VBOXVDMA_RECTL
1163{
1164 int16_t left;
1165 int16_t top;
1166 uint16_t width;
1167 uint16_t height;
1168} VBOXVDMA_RECTL, *PVBOXVDMA_RECTL;
1169
1170typedef enum
1171{
1172 VBOXVDMA_PIXEL_FORMAT_UNKNOWN = 0,
1173 VBOXVDMA_PIXEL_FORMAT_R8G8B8 = 20,
1174 VBOXVDMA_PIXEL_FORMAT_A8R8G8B8 = 21,
1175 VBOXVDMA_PIXEL_FORMAT_X8R8G8B8 = 22,
1176 VBOXVDMA_PIXEL_FORMAT_R5G6B5 = 23,
1177 VBOXVDMA_PIXEL_FORMAT_X1R5G5B5 = 24,
1178 VBOXVDMA_PIXEL_FORMAT_A1R5G5B5 = 25,
1179 VBOXVDMA_PIXEL_FORMAT_A4R4G4B4 = 26,
1180 VBOXVDMA_PIXEL_FORMAT_R3G3B2 = 27,
1181 VBOXVDMA_PIXEL_FORMAT_A8 = 28,
1182 VBOXVDMA_PIXEL_FORMAT_A8R3G3B2 = 29,
1183 VBOXVDMA_PIXEL_FORMAT_X4R4G4B4 = 30,
1184 VBOXVDMA_PIXEL_FORMAT_A2B10G10R10 = 31,
1185 VBOXVDMA_PIXEL_FORMAT_A8B8G8R8 = 32,
1186 VBOXVDMA_PIXEL_FORMAT_X8B8G8R8 = 33,
1187 VBOXVDMA_PIXEL_FORMAT_G16R16 = 34,
1188 VBOXVDMA_PIXEL_FORMAT_A2R10G10B10 = 35,
1189 VBOXVDMA_PIXEL_FORMAT_A16B16G16R16 = 36,
1190 VBOXVDMA_PIXEL_FORMAT_A8P8 = 40,
1191 VBOXVDMA_PIXEL_FORMAT_P8 = 41,
1192 VBOXVDMA_PIXEL_FORMAT_L8 = 50,
1193 VBOXVDMA_PIXEL_FORMAT_A8L8 = 51,
1194 VBOXVDMA_PIXEL_FORMAT_A4L4 = 52,
1195 VBOXVDMA_PIXEL_FORMAT_V8U8 = 60,
1196 VBOXVDMA_PIXEL_FORMAT_L6V5U5 = 61,
1197 VBOXVDMA_PIXEL_FORMAT_X8L8V8U8 = 62,
1198 VBOXVDMA_PIXEL_FORMAT_Q8W8V8U8 = 63,
1199 VBOXVDMA_PIXEL_FORMAT_V16U16 = 64,
1200 VBOXVDMA_PIXEL_FORMAT_W11V11U10 = 65,
1201 VBOXVDMA_PIXEL_FORMAT_A2W10V10U10 = 67
1202} VBOXVDMA_PIXEL_FORMAT;
1203
1204typedef struct VBOXVDMA_SURF_DESC
1205{
1206 uint32_t width;
1207 uint32_t height;
1208 VBOXVDMA_PIXEL_FORMAT format;
1209 uint32_t bpp;
1210 uint32_t pitch;
1211 uint32_t fFlags;
1212} VBOXVDMA_SURF_DESC, *PVBOXVDMA_SURF_DESC;
1213
1214/*typedef uint64_t VBOXVDMAPHADDRESS;*/
1215typedef uint64_t VBOXVDMASURFHANDLE;
1216
1217/* region specified as a rectangle, otherwize it is a size of memory pointed to by phys address */
1218#define VBOXVDMAOPERAND_FLAGS_RECTL 0x1
1219/* Surface handle is valid */
1220#define VBOXVDMAOPERAND_FLAGS_PRIMARY 0x2
1221/* address is offset in VRAM */
1222#define VBOXVDMAOPERAND_FLAGS_VRAMOFFSET 0x4
1223
1224
1225/* VBOXVDMACBUF_DR::phBuf specifies offset in VRAM */
1226#define VBOXVDMACBUF_FLAG_BUF_VRAM_OFFSET 0x00000001
1227/* command buffer follows the VBOXVDMACBUF_DR in VRAM, VBOXVDMACBUF_DR::phBuf is ignored */
1228#define VBOXVDMACBUF_FLAG_BUF_FOLLOWS_DR 0x00000002
1229
1230/*
1231 * We can not submit the DMA command via VRAM since we do not have control over
1232 * DMA command buffer [de]allocation, i.e. we only control the buffer contents.
1233 * In other words the system may call one of our callbacks to fill a command buffer
1234 * with the necessary commands and then discard the buffer w/o any notification.
1235 *
1236 * We have only DMA command buffer physical address at submission time.
1237 *
1238 * so the only way is to */
1239typedef struct VBOXVDMACBUF_DR
1240{
1241 uint16_t fFlags;
1242 uint16_t cbBuf;
1243 /* RT_SUCCESS() - on success
1244 * VERR_INTERRUPTED - on preemption
1245 * VERR_xxx - on error */
1246 int32_t rc;
1247 union
1248 {
1249 uint64_t phBuf;
1250 VBOXVIDEOOFFSET offVramBuf;
1251 } Location;
1252 uint64_t aGuestData[7];
1253} VBOXVDMACBUF_DR, *PVBOXVDMACBUF_DR;
1254
1255#define VBOXVDMACBUF_DR_TAIL(_pCmd, _t) ( (_t*)(((uint8_t*)(_pCmd)) + sizeof (VBOXVDMACBUF_DR)) )
1256#define VBOXVDMACBUF_DR_FROM_TAIL(_pCmd) ( (VBOXVDMACBUF_DR*)(((uint8_t*)(_pCmd)) - sizeof (VBOXVDMACBUF_DR)) )
1257
1258typedef struct VBOXVDMACMD
1259{
1260 VBOXVDMACMD_TYPE enmType;
1261 uint32_t u32CmdSpecific;
1262} VBOXVDMACMD, *PVBOXVDMACMD;
1263
1264#define VBOXVDMACMD_HEADER_SIZE() sizeof (VBOXVDMACMD)
1265#define VBOXVDMACMD_SIZE_FROMBODYSIZE(_s) (VBOXVDMACMD_HEADER_SIZE() + (_s))
1266#define VBOXVDMACMD_SIZE(_t) (VBOXVDMACMD_SIZE_FROMBODYSIZE(sizeof (_t)))
1267#define VBOXVDMACMD_BODY(_pCmd, _t) ( (_t*)(((uint8_t*)(_pCmd)) + VBOXVDMACMD_HEADER_SIZE()) )
1268#define VBOXVDMACMD_FROM_BODY(_pCmd) ( (VBOXVDMACMD*)(((uint8_t*)(_pCmd)) - VBOXVDMACMD_HEADER_SIZE()) )
1269#define VBOXVDMACMD_BODY_FIELD_OFFSET(_ot, _t, _f) ( (_ot)(uintptr_t)( VBOXVDMACMD_BODY(0, uint8_t) + RT_OFFSETOF(_t, _f) ) )
1270
1271typedef struct VBOXVDMACMD_DMA_PRESENT_BLT
1272{
1273 VBOXVIDEOOFFSET offSrc;
1274 VBOXVIDEOOFFSET offDst;
1275 VBOXVDMA_SURF_DESC srcDesc;
1276 VBOXVDMA_SURF_DESC dstDesc;
1277 VBOXVDMA_RECTL srcRectl;
1278 VBOXVDMA_RECTL dstRectl;
1279 uint32_t u32Reserved;
1280 uint32_t cDstSubRects;
1281 VBOXVDMA_RECTL aDstSubRects[1];
1282} VBOXVDMACMD_DMA_PRESENT_BLT, *PVBOXVDMACMD_DMA_PRESENT_BLT;
1283
1284typedef struct VBOXVDMACMD_DMA_PRESENT_SHADOW2PRIMARY
1285{
1286 VBOXVDMA_RECTL Rect;
1287} VBOXVDMACMD_DMA_PRESENT_SHADOW2PRIMARY, *PVBOXVDMACMD_DMA_PRESENT_SHADOW2PRIMARY;
1288
1289
1290#define VBOXVDMACMD_DMA_BPB_TRANSFER_F_SRC_VRAMOFFSET 0x00000001
1291#define VBOXVDMACMD_DMA_BPB_TRANSFER_F_DST_VRAMOFFSET 0x00000002
1292
1293typedef struct VBOXVDMACMD_DMA_BPB_TRANSFER
1294{
1295 uint32_t cbTransferSize;
1296 uint32_t fFlags;
1297 union
1298 {
1299 uint64_t phBuf;
1300 VBOXVIDEOOFFSET offVramBuf;
1301 } Src;
1302 union
1303 {
1304 uint64_t phBuf;
1305 VBOXVIDEOOFFSET offVramBuf;
1306 } Dst;
1307} VBOXVDMACMD_DMA_BPB_TRANSFER, *PVBOXVDMACMD_DMA_BPB_TRANSFER;
1308
1309#define VBOXVDMACMD_SYSMEMEL_F_PAGELIST 0x00000001
1310
1311typedef struct VBOXVDMACMD_SYSMEMEL
1312{
1313 uint32_t cPages;
1314 uint32_t fFlags;
1315 uint64_t phBuf[1];
1316} VBOXVDMACMD_SYSMEMEL, *PVBOXVDMACMD_SYSMEMEL;
1317
1318#define VBOXVDMACMD_SYSMEMEL_NEXT(_pEl) (((_pEl)->fFlags & VBOXVDMACMD_SYSMEMEL_F_PAGELIST) ? \
1319 ((PVBOXVDMACMD_SYSMEMEL)(((uint8_t*)(_pEl))+RT_OFFSETOF(VBOXVDMACMD_SYSMEMEL, phBuf[(_pEl)->cPages]))) \
1320 : \
1321 ((_pEl)+1)
1322
1323#define VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS_SYS2VRAM 0x00000001
1324
1325typedef struct VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS
1326{
1327 uint32_t cTransferPages;
1328 uint32_t fFlags;
1329 VBOXVIDEOOFFSET offVramBuf;
1330 VBOXVDMACMD_SYSMEMEL FirstEl;
1331} VBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS, *PVBOXVDMACMD_DMA_BPB_TRANSFER_VRAMSYS;
1332
1333typedef struct VBOXVDMACMD_DMA_BPB_FILL
1334{
1335 VBOXVIDEOOFFSET offSurf;
1336 uint32_t cbFillSize;
1337 uint32_t u32FillPattern;
1338} VBOXVDMACMD_DMA_BPB_FILL, *PVBOXVDMACMD_DMA_BPB_FILL;
1339
1340# pragma pack()
1341#endif /* #ifdef VBOX_WITH_VDMA */
1342
1343#ifdef VBOX_WITH_CRHGSMI
1344# pragma pack(1)
1345typedef struct VBOXVDMACMD_CHROMIUM_BUFFER
1346{
1347 VBOXVIDEOOFFSET offBuffer;
1348 uint32_t cbBuffer;
1349 uint32_t u32GuesData;
1350 uint64_t u64GuesData;
1351} VBOXVDMACMD_CHROMIUM_BUFFER, *PVBOXVDMACMD_CHROMIUM_BUFFER;
1352
1353typedef struct VBOXVDMACMD_CHROMIUM_CMD
1354{
1355 uint32_t cBuffers;
1356 uint32_t u32Reserved;
1357 VBOXVDMACMD_CHROMIUM_BUFFER aBuffers[1];
1358} VBOXVDMACMD_CHROMIUM_CMD, *PVBOXVDMACMD_CHROMIUM_CMD;
1359
1360typedef enum
1361{
1362 VBOXVDMACMD_CHROMIUM_CTL_TYPE_UNKNOWN = 0,
1363 VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP,
1364 VBOXVDMACMD_CHROMIUM_CTL_TYPE_SAVESTATE_BEGIN,
1365 VBOXVDMACMD_CHROMIUM_CTL_TYPE_SAVESTATE_END,
1366 VBOXVDMACMD_CHROMIUM_CTL_TYPE_SIZEHACK = 0xfffffffe
1367} VBOXVDMACMD_CHROMIUM_CTL_TYPE;
1368
1369typedef struct VBOXVDMACMD_CHROMIUM_CTL
1370{
1371 VBOXVDMACMD_CHROMIUM_CTL_TYPE enmType;
1372 uint32_t cbCmd;
1373} VBOXVDMACMD_CHROMIUM_CTL, *PVBOXVDMACMD_CHROMIUM_CTL;
1374
1375typedef struct VBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP
1376{
1377 VBOXVDMACMD_CHROMIUM_CTL Hdr;
1378 union
1379 {
1380 void *pvRamBase;
1381 uint64_t uAlignment;
1382 };
1383} VBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP, *PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP;
1384# pragma pack()
1385#endif
1386
1387#ifdef VBOXVDMA_WITH_VBVA
1388# pragma pack(1)
1389
1390typedef struct VBOXVDMAVBVACMD
1391{
1392 HGSMIOFFSET offCmd;
1393} VBOXVDMAVBVACMD;
1394
1395#pragma pack()
1396#endif
1397
1398#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