VirtualBox

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

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

Automated rebranding to Oracle copyright/license strings via filemuncher

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

© 2023 Oracle
ContactPrivacy policyTerms of Use