xref: /OK3568_Linux_fs/kernel/drivers/gpu/drm/vboxvideo/vboxvideo.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: MIT */
2*4882a593Smuzhiyun /* Copyright (C) 2006-2016 Oracle Corporation */
3*4882a593Smuzhiyun 
4*4882a593Smuzhiyun #ifndef __VBOXVIDEO_H__
5*4882a593Smuzhiyun #define __VBOXVIDEO_H__
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #define VBOX_VIDEO_MAX_SCREENS 64
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun /*
10*4882a593Smuzhiyun  * The last 4096 bytes of the guest VRAM contains the generic info for all
11*4882a593Smuzhiyun  * DualView chunks: sizes and offsets of chunks. This is filled by miniport.
12*4882a593Smuzhiyun  *
13*4882a593Smuzhiyun  * Last 4096 bytes of each chunk contain chunk specific data: framebuffer info,
14*4882a593Smuzhiyun  * etc. This is used exclusively by the corresponding instance of a display
15*4882a593Smuzhiyun  * driver.
16*4882a593Smuzhiyun  *
17*4882a593Smuzhiyun  * The VRAM layout:
18*4882a593Smuzhiyun  *   Last 4096 bytes - Adapter information area.
19*4882a593Smuzhiyun  *   4096 bytes aligned miniport heap (value specified in the config rouded up).
20*4882a593Smuzhiyun  *   Slack - what left after dividing the VRAM.
21*4882a593Smuzhiyun  *   4096 bytes aligned framebuffers:
22*4882a593Smuzhiyun  *     last 4096 bytes of each framebuffer is the display information area.
23*4882a593Smuzhiyun  *
24*4882a593Smuzhiyun  * The Virtual Graphics Adapter information in the guest VRAM is stored by the
25*4882a593Smuzhiyun  * guest video driver using structures prepended by VBOXVIDEOINFOHDR.
26*4882a593Smuzhiyun  *
27*4882a593Smuzhiyun  * When the guest driver writes dword 0 to the VBE_DISPI_INDEX_VBOX_VIDEO
28*4882a593Smuzhiyun  * the host starts to process the info. The first element at the start of
29*4882a593Smuzhiyun  * the 4096 bytes region should be normally be a LINK that points to
30*4882a593Smuzhiyun  * actual information chain. That way the guest driver can have some
31*4882a593Smuzhiyun  * fixed layout of the information memory block and just rewrite
32*4882a593Smuzhiyun  * the link to point to relevant memory chain.
33*4882a593Smuzhiyun  *
34*4882a593Smuzhiyun  * The processing stops at the END element.
35*4882a593Smuzhiyun  *
36*4882a593Smuzhiyun  * The host can access the memory only when the port IO is processed.
37*4882a593Smuzhiyun  * All data that will be needed later must be copied from these 4096 bytes.
38*4882a593Smuzhiyun  * But other VRAM can be used by host until the mode is disabled.
39*4882a593Smuzhiyun  *
40*4882a593Smuzhiyun  * The guest driver writes dword 0xffffffff to the VBE_DISPI_INDEX_VBOX_VIDEO
41*4882a593Smuzhiyun  * to disable the mode.
42*4882a593Smuzhiyun  *
43*4882a593Smuzhiyun  * VBE_DISPI_INDEX_VBOX_VIDEO is used to read the configuration information
44*4882a593Smuzhiyun  * from the host and issue commands to the host.
45*4882a593Smuzhiyun  *
46*4882a593Smuzhiyun  * The guest writes the VBE_DISPI_INDEX_VBOX_VIDEO index register, the the
47*4882a593Smuzhiyun  * following operations with the VBE data register can be performed:
48*4882a593Smuzhiyun  *
49*4882a593Smuzhiyun  * Operation            Result
50*4882a593Smuzhiyun  * write 16 bit value   NOP
51*4882a593Smuzhiyun  * read 16 bit value    count of monitors
52*4882a593Smuzhiyun  * write 32 bit value   set the vbox cmd value and the cmd processed by the host
53*4882a593Smuzhiyun  * read 32 bit value    result of the last vbox command is returned
54*4882a593Smuzhiyun  */
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun struct vbva_cmd_hdr {
57*4882a593Smuzhiyun 	s16 x;
58*4882a593Smuzhiyun 	s16 y;
59*4882a593Smuzhiyun 	u16 w;
60*4882a593Smuzhiyun 	u16 h;
61*4882a593Smuzhiyun } __packed;
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun /*
64*4882a593Smuzhiyun  * The VBVA ring buffer is suitable for transferring large (< 2GB) amount of
65*4882a593Smuzhiyun  * data. For example big bitmaps which do not fit to the buffer.
66*4882a593Smuzhiyun  *
67*4882a593Smuzhiyun  * Guest starts writing to the buffer by initializing a record entry in the
68*4882a593Smuzhiyun  * records queue. VBVA_F_RECORD_PARTIAL indicates that the record is being
69*4882a593Smuzhiyun  * written. As data is written to the ring buffer, the guest increases
70*4882a593Smuzhiyun  * free_offset.
71*4882a593Smuzhiyun  *
72*4882a593Smuzhiyun  * The host reads the records on flushes and processes all completed records.
73*4882a593Smuzhiyun  * When host encounters situation when only a partial record presents and
74*4882a593Smuzhiyun  * len_and_flags & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE -
75*4882a593Smuzhiyun  * VBVA_RING_BUFFER_THRESHOLD, the host fetched all record data and updates
76*4882a593Smuzhiyun  * data_offset. After that on each flush the host continues fetching the data
77*4882a593Smuzhiyun  * until the record is completed.
78*4882a593Smuzhiyun  */
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun #define VBVA_RING_BUFFER_SIZE        (4194304 - 1024)
81*4882a593Smuzhiyun #define VBVA_RING_BUFFER_THRESHOLD   (4096)
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun #define VBVA_MAX_RECORDS (64)
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun #define VBVA_F_MODE_ENABLED         0x00000001u
86*4882a593Smuzhiyun #define VBVA_F_MODE_VRDP            0x00000002u
87*4882a593Smuzhiyun #define VBVA_F_MODE_VRDP_RESET      0x00000004u
88*4882a593Smuzhiyun #define VBVA_F_MODE_VRDP_ORDER_MASK 0x00000008u
89*4882a593Smuzhiyun 
90*4882a593Smuzhiyun #define VBVA_F_STATE_PROCESSING     0x00010000u
91*4882a593Smuzhiyun 
92*4882a593Smuzhiyun #define VBVA_F_RECORD_PARTIAL       0x80000000u
93*4882a593Smuzhiyun 
94*4882a593Smuzhiyun struct vbva_record {
95*4882a593Smuzhiyun 	u32 len_and_flags;
96*4882a593Smuzhiyun } __packed;
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun /*
99*4882a593Smuzhiyun  * The minimum HGSMI heap size is PAGE_SIZE (4096 bytes) and is a restriction of
100*4882a593Smuzhiyun  * the runtime heapsimple API. Use minimum 2 pages here, because the info area
101*4882a593Smuzhiyun  * also may contain other data (for example hgsmi_host_flags structure).
102*4882a593Smuzhiyun  */
103*4882a593Smuzhiyun #define VBVA_ADAPTER_INFORMATION_SIZE 65536
104*4882a593Smuzhiyun #define VBVA_MIN_BUFFER_SIZE          65536
105*4882a593Smuzhiyun 
106*4882a593Smuzhiyun /* The value for port IO to let the adapter to interpret the adapter memory. */
107*4882a593Smuzhiyun #define VBOX_VIDEO_DISABLE_ADAPTER_MEMORY        0xFFFFFFFF
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun /* The value for port IO to let the adapter to interpret the adapter memory. */
110*4882a593Smuzhiyun #define VBOX_VIDEO_INTERPRET_ADAPTER_MEMORY      0x00000000
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun /*
113*4882a593Smuzhiyun  * The value for port IO to let the adapter to interpret the display memory.
114*4882a593Smuzhiyun  * The display number is encoded in low 16 bits.
115*4882a593Smuzhiyun  */
116*4882a593Smuzhiyun #define VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE 0x00010000
117*4882a593Smuzhiyun 
118*4882a593Smuzhiyun struct vbva_host_flags {
119*4882a593Smuzhiyun 	u32 host_events;
120*4882a593Smuzhiyun 	u32 supported_orders;
121*4882a593Smuzhiyun } __packed;
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun struct vbva_buffer {
124*4882a593Smuzhiyun 	struct vbva_host_flags host_flags;
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun 	/* The offset where the data start in the buffer. */
127*4882a593Smuzhiyun 	u32 data_offset;
128*4882a593Smuzhiyun 	/* The offset where next data must be placed in the buffer. */
129*4882a593Smuzhiyun 	u32 free_offset;
130*4882a593Smuzhiyun 
131*4882a593Smuzhiyun 	/* The queue of record descriptions. */
132*4882a593Smuzhiyun 	struct vbva_record records[VBVA_MAX_RECORDS];
133*4882a593Smuzhiyun 	u32 record_first_index;
134*4882a593Smuzhiyun 	u32 record_free_index;
135*4882a593Smuzhiyun 
136*4882a593Smuzhiyun 	/* Space to leave free when large partial records are transferred. */
137*4882a593Smuzhiyun 	u32 partial_write_tresh;
138*4882a593Smuzhiyun 
139*4882a593Smuzhiyun 	u32 data_len;
140*4882a593Smuzhiyun 	/* variable size for the rest of the vbva_buffer area in VRAM. */
141*4882a593Smuzhiyun 	u8 data[];
142*4882a593Smuzhiyun } __packed;
143*4882a593Smuzhiyun 
144*4882a593Smuzhiyun #define VBVA_MAX_RECORD_SIZE (128 * 1024 * 1024)
145*4882a593Smuzhiyun 
146*4882a593Smuzhiyun /* guest->host commands */
147*4882a593Smuzhiyun #define VBVA_QUERY_CONF32			 1
148*4882a593Smuzhiyun #define VBVA_SET_CONF32				 2
149*4882a593Smuzhiyun #define VBVA_INFO_VIEW				 3
150*4882a593Smuzhiyun #define VBVA_INFO_HEAP				 4
151*4882a593Smuzhiyun #define VBVA_FLUSH				 5
152*4882a593Smuzhiyun #define VBVA_INFO_SCREEN			 6
153*4882a593Smuzhiyun #define VBVA_ENABLE				 7
154*4882a593Smuzhiyun #define VBVA_MOUSE_POINTER_SHAPE		 8
155*4882a593Smuzhiyun /* informs host about HGSMI caps. see vbva_caps below */
156*4882a593Smuzhiyun #define VBVA_INFO_CAPS				12
157*4882a593Smuzhiyun /* configures scanline, see VBVASCANLINECFG below */
158*4882a593Smuzhiyun #define VBVA_SCANLINE_CFG			13
159*4882a593Smuzhiyun /* requests scanline info, see VBVASCANLINEINFO below */
160*4882a593Smuzhiyun #define VBVA_SCANLINE_INFO			14
161*4882a593Smuzhiyun /* inform host about VBVA Command submission */
162*4882a593Smuzhiyun #define VBVA_CMDVBVA_SUBMIT			16
163*4882a593Smuzhiyun /* inform host about VBVA Command submission */
164*4882a593Smuzhiyun #define VBVA_CMDVBVA_FLUSH			17
165*4882a593Smuzhiyun /* G->H DMA command */
166*4882a593Smuzhiyun #define VBVA_CMDVBVA_CTL			18
167*4882a593Smuzhiyun /* Query most recent mode hints sent */
168*4882a593Smuzhiyun #define VBVA_QUERY_MODE_HINTS			19
169*4882a593Smuzhiyun /*
170*4882a593Smuzhiyun  * Report the guest virtual desktop position and size for mapping host and
171*4882a593Smuzhiyun  * guest pointer positions.
172*4882a593Smuzhiyun  */
173*4882a593Smuzhiyun #define VBVA_REPORT_INPUT_MAPPING		20
174*4882a593Smuzhiyun /* Report the guest cursor position and query the host position. */
175*4882a593Smuzhiyun #define VBVA_CURSOR_POSITION			21
176*4882a593Smuzhiyun 
177*4882a593Smuzhiyun /* host->guest commands */
178*4882a593Smuzhiyun #define VBVAHG_EVENT				1
179*4882a593Smuzhiyun #define VBVAHG_DISPLAY_CUSTOM			2
180*4882a593Smuzhiyun 
181*4882a593Smuzhiyun /* vbva_conf32::index */
182*4882a593Smuzhiyun #define VBOX_VBVA_CONF32_MONITOR_COUNT		0
183*4882a593Smuzhiyun #define VBOX_VBVA_CONF32_HOST_HEAP_SIZE		1
184*4882a593Smuzhiyun /*
185*4882a593Smuzhiyun  * Returns VINF_SUCCESS if the host can report mode hints via VBVA.
186*4882a593Smuzhiyun  * Set value to VERR_NOT_SUPPORTED before calling.
187*4882a593Smuzhiyun  */
188*4882a593Smuzhiyun #define VBOX_VBVA_CONF32_MODE_HINT_REPORTING	2
189*4882a593Smuzhiyun /*
190*4882a593Smuzhiyun  * Returns VINF_SUCCESS if the host can report guest cursor enabled status via
191*4882a593Smuzhiyun  * VBVA.  Set value to VERR_NOT_SUPPORTED before calling.
192*4882a593Smuzhiyun  */
193*4882a593Smuzhiyun #define VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING	3
194*4882a593Smuzhiyun /*
195*4882a593Smuzhiyun  * Returns the currently available host cursor capabilities.  Available if
196*4882a593Smuzhiyun  * VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING returns success.
197*4882a593Smuzhiyun  */
198*4882a593Smuzhiyun #define VBOX_VBVA_CONF32_CURSOR_CAPABILITIES	4
199*4882a593Smuzhiyun /* Returns the supported flags in vbva_infoscreen.flags. */
200*4882a593Smuzhiyun #define VBOX_VBVA_CONF32_SCREEN_FLAGS		5
201*4882a593Smuzhiyun /* Returns the max size of VBVA record. */
202*4882a593Smuzhiyun #define VBOX_VBVA_CONF32_MAX_RECORD_SIZE	6
203*4882a593Smuzhiyun 
204*4882a593Smuzhiyun struct vbva_conf32 {
205*4882a593Smuzhiyun 	u32 index;
206*4882a593Smuzhiyun 	u32 value;
207*4882a593Smuzhiyun } __packed;
208*4882a593Smuzhiyun 
209*4882a593Smuzhiyun /* Reserved for historical reasons. */
210*4882a593Smuzhiyun #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED0   BIT(0)
211*4882a593Smuzhiyun /*
212*4882a593Smuzhiyun  * Guest cursor capability: can the host show a hardware cursor at the host
213*4882a593Smuzhiyun  * pointer location?
214*4882a593Smuzhiyun  */
215*4882a593Smuzhiyun #define VBOX_VBVA_CURSOR_CAPABILITY_HARDWARE    BIT(1)
216*4882a593Smuzhiyun /* Reserved for historical reasons. */
217*4882a593Smuzhiyun #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED2   BIT(2)
218*4882a593Smuzhiyun /* Reserved for historical reasons.  Must always be unset. */
219*4882a593Smuzhiyun #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED3   BIT(3)
220*4882a593Smuzhiyun /* Reserved for historical reasons. */
221*4882a593Smuzhiyun #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED4   BIT(4)
222*4882a593Smuzhiyun /* Reserved for historical reasons. */
223*4882a593Smuzhiyun #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED5   BIT(5)
224*4882a593Smuzhiyun 
225*4882a593Smuzhiyun struct vbva_infoview {
226*4882a593Smuzhiyun 	/* Index of the screen, assigned by the guest. */
227*4882a593Smuzhiyun 	u32 view_index;
228*4882a593Smuzhiyun 
229*4882a593Smuzhiyun 	/* The screen offset in VRAM, the framebuffer starts here. */
230*4882a593Smuzhiyun 	u32 view_offset;
231*4882a593Smuzhiyun 
232*4882a593Smuzhiyun 	/* The size of the VRAM memory that can be used for the view. */
233*4882a593Smuzhiyun 	u32 view_size;
234*4882a593Smuzhiyun 
235*4882a593Smuzhiyun 	/* The recommended maximum size of the VRAM memory for the screen. */
236*4882a593Smuzhiyun 	u32 max_screen_size;
237*4882a593Smuzhiyun } __packed;
238*4882a593Smuzhiyun 
239*4882a593Smuzhiyun struct vbva_flush {
240*4882a593Smuzhiyun 	u32 reserved;
241*4882a593Smuzhiyun } __packed;
242*4882a593Smuzhiyun 
243*4882a593Smuzhiyun /* vbva_infoscreen.flags */
244*4882a593Smuzhiyun #define VBVA_SCREEN_F_NONE			0x0000
245*4882a593Smuzhiyun #define VBVA_SCREEN_F_ACTIVE			0x0001
246*4882a593Smuzhiyun /*
247*4882a593Smuzhiyun  * The virtual monitor has been disabled by the guest and should be removed
248*4882a593Smuzhiyun  * by the host and ignored for purposes of pointer position calculation.
249*4882a593Smuzhiyun  */
250*4882a593Smuzhiyun #define VBVA_SCREEN_F_DISABLED			0x0002
251*4882a593Smuzhiyun /*
252*4882a593Smuzhiyun  * The virtual monitor has been blanked by the guest and should be blacked
253*4882a593Smuzhiyun  * out by the host using width, height, etc values from the vbva_infoscreen
254*4882a593Smuzhiyun  * request.
255*4882a593Smuzhiyun  */
256*4882a593Smuzhiyun #define VBVA_SCREEN_F_BLANK			0x0004
257*4882a593Smuzhiyun /*
258*4882a593Smuzhiyun  * The virtual monitor has been blanked by the guest and should be blacked
259*4882a593Smuzhiyun  * out by the host using the previous mode values for width. height, etc.
260*4882a593Smuzhiyun  */
261*4882a593Smuzhiyun #define VBVA_SCREEN_F_BLANK2			0x0008
262*4882a593Smuzhiyun 
263*4882a593Smuzhiyun struct vbva_infoscreen {
264*4882a593Smuzhiyun 	/* Which view contains the screen. */
265*4882a593Smuzhiyun 	u32 view_index;
266*4882a593Smuzhiyun 
267*4882a593Smuzhiyun 	/* Physical X origin relative to the primary screen. */
268*4882a593Smuzhiyun 	s32 origin_x;
269*4882a593Smuzhiyun 
270*4882a593Smuzhiyun 	/* Physical Y origin relative to the primary screen. */
271*4882a593Smuzhiyun 	s32 origin_y;
272*4882a593Smuzhiyun 
273*4882a593Smuzhiyun 	/* Offset of visible framebuffer relative to the framebuffer start. */
274*4882a593Smuzhiyun 	u32 start_offset;
275*4882a593Smuzhiyun 
276*4882a593Smuzhiyun 	/* The scan line size in bytes. */
277*4882a593Smuzhiyun 	u32 line_size;
278*4882a593Smuzhiyun 
279*4882a593Smuzhiyun 	/* Width of the screen. */
280*4882a593Smuzhiyun 	u32 width;
281*4882a593Smuzhiyun 
282*4882a593Smuzhiyun 	/* Height of the screen. */
283*4882a593Smuzhiyun 	u32 height;
284*4882a593Smuzhiyun 
285*4882a593Smuzhiyun 	/* Color depth. */
286*4882a593Smuzhiyun 	u16 bits_per_pixel;
287*4882a593Smuzhiyun 
288*4882a593Smuzhiyun 	/* VBVA_SCREEN_F_* */
289*4882a593Smuzhiyun 	u16 flags;
290*4882a593Smuzhiyun } __packed;
291*4882a593Smuzhiyun 
292*4882a593Smuzhiyun /* vbva_enable.flags */
293*4882a593Smuzhiyun #define VBVA_F_NONE				0x00000000
294*4882a593Smuzhiyun #define VBVA_F_ENABLE				0x00000001
295*4882a593Smuzhiyun #define VBVA_F_DISABLE				0x00000002
296*4882a593Smuzhiyun /* extended VBVA to be used with WDDM */
297*4882a593Smuzhiyun #define VBVA_F_EXTENDED				0x00000004
298*4882a593Smuzhiyun /* vbva offset is absolute VRAM offset */
299*4882a593Smuzhiyun #define VBVA_F_ABSOFFSET			0x00000008
300*4882a593Smuzhiyun 
301*4882a593Smuzhiyun struct vbva_enable {
302*4882a593Smuzhiyun 	u32 flags;
303*4882a593Smuzhiyun 	u32 offset;
304*4882a593Smuzhiyun 	s32 result;
305*4882a593Smuzhiyun } __packed;
306*4882a593Smuzhiyun 
307*4882a593Smuzhiyun struct vbva_enable_ex {
308*4882a593Smuzhiyun 	struct vbva_enable base;
309*4882a593Smuzhiyun 	u32 screen_id;
310*4882a593Smuzhiyun } __packed;
311*4882a593Smuzhiyun 
312*4882a593Smuzhiyun struct vbva_mouse_pointer_shape {
313*4882a593Smuzhiyun 	/* The host result. */
314*4882a593Smuzhiyun 	s32 result;
315*4882a593Smuzhiyun 
316*4882a593Smuzhiyun 	/* VBOX_MOUSE_POINTER_* bit flags. */
317*4882a593Smuzhiyun 	u32 flags;
318*4882a593Smuzhiyun 
319*4882a593Smuzhiyun 	/* X coordinate of the hot spot. */
320*4882a593Smuzhiyun 	u32 hot_X;
321*4882a593Smuzhiyun 
322*4882a593Smuzhiyun 	/* Y coordinate of the hot spot. */
323*4882a593Smuzhiyun 	u32 hot_y;
324*4882a593Smuzhiyun 
325*4882a593Smuzhiyun 	/* Width of the pointer in pixels. */
326*4882a593Smuzhiyun 	u32 width;
327*4882a593Smuzhiyun 
328*4882a593Smuzhiyun 	/* Height of the pointer in scanlines. */
329*4882a593Smuzhiyun 	u32 height;
330*4882a593Smuzhiyun 
331*4882a593Smuzhiyun 	/* Pointer data.
332*4882a593Smuzhiyun 	 *
333*4882a593Smuzhiyun 	 * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color)
334*4882a593Smuzhiyun 	 * mask.
335*4882a593Smuzhiyun 	 *
336*4882a593Smuzhiyun 	 * For pointers without alpha channel the XOR mask pixels are 32 bit
337*4882a593Smuzhiyun 	 * values: (lsb)BGR0(msb). For pointers with alpha channel the XOR mask
338*4882a593Smuzhiyun 	 * consists of (lsb)BGRA(msb) 32 bit values.
339*4882a593Smuzhiyun 	 *
340*4882a593Smuzhiyun 	 * Guest driver must create the AND mask for pointers with alpha chan.,
341*4882a593Smuzhiyun 	 * so if host does not support alpha, the pointer could be displayed as
342*4882a593Smuzhiyun 	 * a normal color pointer. The AND mask can be constructed from alpha
343*4882a593Smuzhiyun 	 * values. For example alpha value >= 0xf0 means bit 0 in the AND mask.
344*4882a593Smuzhiyun 	 *
345*4882a593Smuzhiyun 	 * The AND mask is 1 bpp bitmap with byte aligned scanlines. Size of AND
346*4882a593Smuzhiyun 	 * mask, therefore, is and_len = (width + 7) / 8 * height. The padding
347*4882a593Smuzhiyun 	 * bits at the end of any scanline are undefined.
348*4882a593Smuzhiyun 	 *
349*4882a593Smuzhiyun 	 * The XOR mask follows the AND mask on the next 4 bytes aligned offset:
350*4882a593Smuzhiyun 	 * u8 *xor = and + (and_len + 3) & ~3
351*4882a593Smuzhiyun 	 * Bytes in the gap between the AND and the XOR mask are undefined.
352*4882a593Smuzhiyun 	 * XOR mask scanlines have no gap between them and size of XOR mask is:
353*4882a593Smuzhiyun 	 * xor_len = width * 4 * height.
354*4882a593Smuzhiyun 	 *
355*4882a593Smuzhiyun 	 * Preallocate 4 bytes for accessing actual data as p->data.
356*4882a593Smuzhiyun 	 */
357*4882a593Smuzhiyun 	u8 data[4];
358*4882a593Smuzhiyun } __packed;
359*4882a593Smuzhiyun 
360*4882a593Smuzhiyun /* pointer is visible */
361*4882a593Smuzhiyun #define VBOX_MOUSE_POINTER_VISIBLE		0x0001
362*4882a593Smuzhiyun /* pointer has alpha channel */
363*4882a593Smuzhiyun #define VBOX_MOUSE_POINTER_ALPHA		0x0002
364*4882a593Smuzhiyun /* pointerData contains new pointer shape */
365*4882a593Smuzhiyun #define VBOX_MOUSE_POINTER_SHAPE		0x0004
366*4882a593Smuzhiyun 
367*4882a593Smuzhiyun /*
368*4882a593Smuzhiyun  * The guest driver can handle asynch guest cmd completion by reading the
369*4882a593Smuzhiyun  * command offset from io port.
370*4882a593Smuzhiyun  */
371*4882a593Smuzhiyun #define VBVACAPS_COMPLETEGCMD_BY_IOREAD		0x00000001
372*4882a593Smuzhiyun /* the guest driver can handle video adapter IRQs */
373*4882a593Smuzhiyun #define VBVACAPS_IRQ				0x00000002
374*4882a593Smuzhiyun /* The guest can read video mode hints sent via VBVA. */
375*4882a593Smuzhiyun #define VBVACAPS_VIDEO_MODE_HINTS		0x00000004
376*4882a593Smuzhiyun /* The guest can switch to a software cursor on demand. */
377*4882a593Smuzhiyun #define VBVACAPS_DISABLE_CURSOR_INTEGRATION	0x00000008
378*4882a593Smuzhiyun /* The guest does not depend on host handling the VBE registers. */
379*4882a593Smuzhiyun #define VBVACAPS_USE_VBVA_ONLY			0x00000010
380*4882a593Smuzhiyun 
381*4882a593Smuzhiyun struct vbva_caps {
382*4882a593Smuzhiyun 	s32 rc;
383*4882a593Smuzhiyun 	u32 caps;
384*4882a593Smuzhiyun } __packed;
385*4882a593Smuzhiyun 
386*4882a593Smuzhiyun /* Query the most recent mode hints received from the host. */
387*4882a593Smuzhiyun struct vbva_query_mode_hints {
388*4882a593Smuzhiyun 	/* The maximum number of screens to return hints for. */
389*4882a593Smuzhiyun 	u16 hints_queried_count;
390*4882a593Smuzhiyun 	/* The size of the mode hint structures directly following this one. */
391*4882a593Smuzhiyun 	u16 hint_structure_guest_size;
392*4882a593Smuzhiyun 	/* Return code for the operation. Initialise to VERR_NOT_SUPPORTED. */
393*4882a593Smuzhiyun 	s32 rc;
394*4882a593Smuzhiyun } __packed;
395*4882a593Smuzhiyun 
396*4882a593Smuzhiyun /*
397*4882a593Smuzhiyun  * Structure in which a mode hint is returned. The guest allocates an array
398*4882a593Smuzhiyun  * of these immediately after the vbva_query_mode_hints structure.
399*4882a593Smuzhiyun  * To accommodate future extensions, the vbva_query_mode_hints structure
400*4882a593Smuzhiyun  * specifies the size of the vbva_modehint structures allocated by the guest,
401*4882a593Smuzhiyun  * and the host only fills out structure elements which fit into that size. The
402*4882a593Smuzhiyun  * host should fill any unused members (e.g. dx, dy) or structure space on the
403*4882a593Smuzhiyun  * end with ~0. The whole structure can legally be set to ~0 to skip a screen.
404*4882a593Smuzhiyun  */
405*4882a593Smuzhiyun struct vbva_modehint {
406*4882a593Smuzhiyun 	u32 magic;
407*4882a593Smuzhiyun 	u32 cx;
408*4882a593Smuzhiyun 	u32 cy;
409*4882a593Smuzhiyun 	u32 bpp;		/* Which has never been used... */
410*4882a593Smuzhiyun 	u32 display;
411*4882a593Smuzhiyun 	u32 dx;			/* X offset into the virtual frame-buffer. */
412*4882a593Smuzhiyun 	u32 dy;			/* Y offset into the virtual frame-buffer. */
413*4882a593Smuzhiyun 	u32 enabled;		/* Not flags. Add new members for new flags. */
414*4882a593Smuzhiyun } __packed;
415*4882a593Smuzhiyun 
416*4882a593Smuzhiyun #define VBVAMODEHINT_MAGIC 0x0801add9u
417*4882a593Smuzhiyun 
418*4882a593Smuzhiyun /*
419*4882a593Smuzhiyun  * Report the rectangle relative to which absolute pointer events should be
420*4882a593Smuzhiyun  * expressed. This information remains valid until the next VBVA resize event
421*4882a593Smuzhiyun  * for any screen, at which time it is reset to the bounding rectangle of all
422*4882a593Smuzhiyun  * virtual screens and must be re-set.
423*4882a593Smuzhiyun  */
424*4882a593Smuzhiyun struct vbva_report_input_mapping {
425*4882a593Smuzhiyun 	s32 x;	/* Upper left X co-ordinate relative to the first screen. */
426*4882a593Smuzhiyun 	s32 y;	/* Upper left Y co-ordinate relative to the first screen. */
427*4882a593Smuzhiyun 	u32 cx;	/* Rectangle width. */
428*4882a593Smuzhiyun 	u32 cy;	/* Rectangle height. */
429*4882a593Smuzhiyun } __packed;
430*4882a593Smuzhiyun 
431*4882a593Smuzhiyun /*
432*4882a593Smuzhiyun  * Report the guest cursor position and query the host one. The host may wish
433*4882a593Smuzhiyun  * to use the guest information to re-position its own cursor (though this is
434*4882a593Smuzhiyun  * currently unlikely).
435*4882a593Smuzhiyun  */
436*4882a593Smuzhiyun struct vbva_cursor_position {
437*4882a593Smuzhiyun 	u32 report_position;	/* Are we reporting a position? */
438*4882a593Smuzhiyun 	u32 x;			/* Guest cursor X position */
439*4882a593Smuzhiyun 	u32 y;			/* Guest cursor Y position */
440*4882a593Smuzhiyun } __packed;
441*4882a593Smuzhiyun 
442*4882a593Smuzhiyun #endif
443