162306a36Sopenharmony_ci/* SPDX-License-Identifier: MIT */
262306a36Sopenharmony_ci/* Copyright (C) 2006-2016 Oracle Corporation */
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#ifndef __VBOXVIDEO_H__
562306a36Sopenharmony_ci#define __VBOXVIDEO_H__
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#define VBOX_VIDEO_MAX_SCREENS 64
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci/*
1062306a36Sopenharmony_ci * The last 4096 bytes of the guest VRAM contains the generic info for all
1162306a36Sopenharmony_ci * DualView chunks: sizes and offsets of chunks. This is filled by miniport.
1262306a36Sopenharmony_ci *
1362306a36Sopenharmony_ci * Last 4096 bytes of each chunk contain chunk specific data: framebuffer info,
1462306a36Sopenharmony_ci * etc. This is used exclusively by the corresponding instance of a display
1562306a36Sopenharmony_ci * driver.
1662306a36Sopenharmony_ci *
1762306a36Sopenharmony_ci * The VRAM layout:
1862306a36Sopenharmony_ci *   Last 4096 bytes - Adapter information area.
1962306a36Sopenharmony_ci *   4096 bytes aligned miniport heap (value specified in the config rouded up).
2062306a36Sopenharmony_ci *   Slack - what left after dividing the VRAM.
2162306a36Sopenharmony_ci *   4096 bytes aligned framebuffers:
2262306a36Sopenharmony_ci *     last 4096 bytes of each framebuffer is the display information area.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * The Virtual Graphics Adapter information in the guest VRAM is stored by the
2562306a36Sopenharmony_ci * guest video driver using structures prepended by VBOXVIDEOINFOHDR.
2662306a36Sopenharmony_ci *
2762306a36Sopenharmony_ci * When the guest driver writes dword 0 to the VBE_DISPI_INDEX_VBOX_VIDEO
2862306a36Sopenharmony_ci * the host starts to process the info. The first element at the start of
2962306a36Sopenharmony_ci * the 4096 bytes region should be normally be a LINK that points to
3062306a36Sopenharmony_ci * actual information chain. That way the guest driver can have some
3162306a36Sopenharmony_ci * fixed layout of the information memory block and just rewrite
3262306a36Sopenharmony_ci * the link to point to relevant memory chain.
3362306a36Sopenharmony_ci *
3462306a36Sopenharmony_ci * The processing stops at the END element.
3562306a36Sopenharmony_ci *
3662306a36Sopenharmony_ci * The host can access the memory only when the port IO is processed.
3762306a36Sopenharmony_ci * All data that will be needed later must be copied from these 4096 bytes.
3862306a36Sopenharmony_ci * But other VRAM can be used by host until the mode is disabled.
3962306a36Sopenharmony_ci *
4062306a36Sopenharmony_ci * The guest driver writes dword 0xffffffff to the VBE_DISPI_INDEX_VBOX_VIDEO
4162306a36Sopenharmony_ci * to disable the mode.
4262306a36Sopenharmony_ci *
4362306a36Sopenharmony_ci * VBE_DISPI_INDEX_VBOX_VIDEO is used to read the configuration information
4462306a36Sopenharmony_ci * from the host and issue commands to the host.
4562306a36Sopenharmony_ci *
4662306a36Sopenharmony_ci * The guest writes the VBE_DISPI_INDEX_VBOX_VIDEO index register, the
4762306a36Sopenharmony_ci * following operations with the VBE data register can be performed:
4862306a36Sopenharmony_ci *
4962306a36Sopenharmony_ci * Operation            Result
5062306a36Sopenharmony_ci * write 16 bit value   NOP
5162306a36Sopenharmony_ci * read 16 bit value    count of monitors
5262306a36Sopenharmony_ci * write 32 bit value   set the vbox cmd value and the cmd processed by the host
5362306a36Sopenharmony_ci * read 32 bit value    result of the last vbox command is returned
5462306a36Sopenharmony_ci */
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_cistruct vbva_cmd_hdr {
5762306a36Sopenharmony_ci	s16 x;
5862306a36Sopenharmony_ci	s16 y;
5962306a36Sopenharmony_ci	u16 w;
6062306a36Sopenharmony_ci	u16 h;
6162306a36Sopenharmony_ci} __packed;
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci/*
6462306a36Sopenharmony_ci * The VBVA ring buffer is suitable for transferring large (< 2GB) amount of
6562306a36Sopenharmony_ci * data. For example big bitmaps which do not fit to the buffer.
6662306a36Sopenharmony_ci *
6762306a36Sopenharmony_ci * Guest starts writing to the buffer by initializing a record entry in the
6862306a36Sopenharmony_ci * records queue. VBVA_F_RECORD_PARTIAL indicates that the record is being
6962306a36Sopenharmony_ci * written. As data is written to the ring buffer, the guest increases
7062306a36Sopenharmony_ci * free_offset.
7162306a36Sopenharmony_ci *
7262306a36Sopenharmony_ci * The host reads the records on flushes and processes all completed records.
7362306a36Sopenharmony_ci * When host encounters situation when only a partial record presents and
7462306a36Sopenharmony_ci * len_and_flags & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE -
7562306a36Sopenharmony_ci * VBVA_RING_BUFFER_THRESHOLD, the host fetched all record data and updates
7662306a36Sopenharmony_ci * data_offset. After that on each flush the host continues fetching the data
7762306a36Sopenharmony_ci * until the record is completed.
7862306a36Sopenharmony_ci */
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci#define VBVA_RING_BUFFER_SIZE        (4194304 - 1024)
8162306a36Sopenharmony_ci#define VBVA_RING_BUFFER_THRESHOLD   (4096)
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci#define VBVA_MAX_RECORDS (64)
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci#define VBVA_F_MODE_ENABLED         0x00000001u
8662306a36Sopenharmony_ci#define VBVA_F_MODE_VRDP            0x00000002u
8762306a36Sopenharmony_ci#define VBVA_F_MODE_VRDP_RESET      0x00000004u
8862306a36Sopenharmony_ci#define VBVA_F_MODE_VRDP_ORDER_MASK 0x00000008u
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci#define VBVA_F_STATE_PROCESSING     0x00010000u
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci#define VBVA_F_RECORD_PARTIAL       0x80000000u
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_cistruct vbva_record {
9562306a36Sopenharmony_ci	u32 len_and_flags;
9662306a36Sopenharmony_ci} __packed;
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci/*
9962306a36Sopenharmony_ci * The minimum HGSMI heap size is PAGE_SIZE (4096 bytes) and is a restriction of
10062306a36Sopenharmony_ci * the runtime heapsimple API. Use minimum 2 pages here, because the info area
10162306a36Sopenharmony_ci * also may contain other data (for example hgsmi_host_flags structure).
10262306a36Sopenharmony_ci */
10362306a36Sopenharmony_ci#define VBVA_ADAPTER_INFORMATION_SIZE 65536
10462306a36Sopenharmony_ci#define VBVA_MIN_BUFFER_SIZE          65536
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci/* The value for port IO to let the adapter to interpret the adapter memory. */
10762306a36Sopenharmony_ci#define VBOX_VIDEO_DISABLE_ADAPTER_MEMORY        0xFFFFFFFF
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci/* The value for port IO to let the adapter to interpret the adapter memory. */
11062306a36Sopenharmony_ci#define VBOX_VIDEO_INTERPRET_ADAPTER_MEMORY      0x00000000
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci/*
11362306a36Sopenharmony_ci * The value for port IO to let the adapter to interpret the display memory.
11462306a36Sopenharmony_ci * The display number is encoded in low 16 bits.
11562306a36Sopenharmony_ci */
11662306a36Sopenharmony_ci#define VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE 0x00010000
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_cistruct vbva_host_flags {
11962306a36Sopenharmony_ci	u32 host_events;
12062306a36Sopenharmony_ci	u32 supported_orders;
12162306a36Sopenharmony_ci} __packed;
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_cistruct vbva_buffer {
12462306a36Sopenharmony_ci	struct vbva_host_flags host_flags;
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci	/* The offset where the data start in the buffer. */
12762306a36Sopenharmony_ci	u32 data_offset;
12862306a36Sopenharmony_ci	/* The offset where next data must be placed in the buffer. */
12962306a36Sopenharmony_ci	u32 free_offset;
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ci	/* The queue of record descriptions. */
13262306a36Sopenharmony_ci	struct vbva_record records[VBVA_MAX_RECORDS];
13362306a36Sopenharmony_ci	u32 record_first_index;
13462306a36Sopenharmony_ci	u32 record_free_index;
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci	/* Space to leave free when large partial records are transferred. */
13762306a36Sopenharmony_ci	u32 partial_write_tresh;
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci	u32 data_len;
14062306a36Sopenharmony_ci	/* variable size for the rest of the vbva_buffer area in VRAM. */
14162306a36Sopenharmony_ci	u8 data[];
14262306a36Sopenharmony_ci} __packed;
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci#define VBVA_MAX_RECORD_SIZE (128 * 1024 * 1024)
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci/* guest->host commands */
14762306a36Sopenharmony_ci#define VBVA_QUERY_CONF32			 1
14862306a36Sopenharmony_ci#define VBVA_SET_CONF32				 2
14962306a36Sopenharmony_ci#define VBVA_INFO_VIEW				 3
15062306a36Sopenharmony_ci#define VBVA_INFO_HEAP				 4
15162306a36Sopenharmony_ci#define VBVA_FLUSH				 5
15262306a36Sopenharmony_ci#define VBVA_INFO_SCREEN			 6
15362306a36Sopenharmony_ci#define VBVA_ENABLE				 7
15462306a36Sopenharmony_ci#define VBVA_MOUSE_POINTER_SHAPE		 8
15562306a36Sopenharmony_ci/* informs host about HGSMI caps. see vbva_caps below */
15662306a36Sopenharmony_ci#define VBVA_INFO_CAPS				12
15762306a36Sopenharmony_ci/* configures scanline, see VBVASCANLINECFG below */
15862306a36Sopenharmony_ci#define VBVA_SCANLINE_CFG			13
15962306a36Sopenharmony_ci/* requests scanline info, see VBVASCANLINEINFO below */
16062306a36Sopenharmony_ci#define VBVA_SCANLINE_INFO			14
16162306a36Sopenharmony_ci/* inform host about VBVA Command submission */
16262306a36Sopenharmony_ci#define VBVA_CMDVBVA_SUBMIT			16
16362306a36Sopenharmony_ci/* inform host about VBVA Command submission */
16462306a36Sopenharmony_ci#define VBVA_CMDVBVA_FLUSH			17
16562306a36Sopenharmony_ci/* G->H DMA command */
16662306a36Sopenharmony_ci#define VBVA_CMDVBVA_CTL			18
16762306a36Sopenharmony_ci/* Query most recent mode hints sent */
16862306a36Sopenharmony_ci#define VBVA_QUERY_MODE_HINTS			19
16962306a36Sopenharmony_ci/*
17062306a36Sopenharmony_ci * Report the guest virtual desktop position and size for mapping host and
17162306a36Sopenharmony_ci * guest pointer positions.
17262306a36Sopenharmony_ci */
17362306a36Sopenharmony_ci#define VBVA_REPORT_INPUT_MAPPING		20
17462306a36Sopenharmony_ci/* Report the guest cursor position and query the host position. */
17562306a36Sopenharmony_ci#define VBVA_CURSOR_POSITION			21
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_ci/* host->guest commands */
17862306a36Sopenharmony_ci#define VBVAHG_EVENT				1
17962306a36Sopenharmony_ci#define VBVAHG_DISPLAY_CUSTOM			2
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ci/* vbva_conf32::index */
18262306a36Sopenharmony_ci#define VBOX_VBVA_CONF32_MONITOR_COUNT		0
18362306a36Sopenharmony_ci#define VBOX_VBVA_CONF32_HOST_HEAP_SIZE		1
18462306a36Sopenharmony_ci/*
18562306a36Sopenharmony_ci * Returns VINF_SUCCESS if the host can report mode hints via VBVA.
18662306a36Sopenharmony_ci * Set value to VERR_NOT_SUPPORTED before calling.
18762306a36Sopenharmony_ci */
18862306a36Sopenharmony_ci#define VBOX_VBVA_CONF32_MODE_HINT_REPORTING	2
18962306a36Sopenharmony_ci/*
19062306a36Sopenharmony_ci * Returns VINF_SUCCESS if the host can report guest cursor enabled status via
19162306a36Sopenharmony_ci * VBVA.  Set value to VERR_NOT_SUPPORTED before calling.
19262306a36Sopenharmony_ci */
19362306a36Sopenharmony_ci#define VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING	3
19462306a36Sopenharmony_ci/*
19562306a36Sopenharmony_ci * Returns the currently available host cursor capabilities.  Available if
19662306a36Sopenharmony_ci * VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING returns success.
19762306a36Sopenharmony_ci */
19862306a36Sopenharmony_ci#define VBOX_VBVA_CONF32_CURSOR_CAPABILITIES	4
19962306a36Sopenharmony_ci/* Returns the supported flags in vbva_infoscreen.flags. */
20062306a36Sopenharmony_ci#define VBOX_VBVA_CONF32_SCREEN_FLAGS		5
20162306a36Sopenharmony_ci/* Returns the max size of VBVA record. */
20262306a36Sopenharmony_ci#define VBOX_VBVA_CONF32_MAX_RECORD_SIZE	6
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_cistruct vbva_conf32 {
20562306a36Sopenharmony_ci	u32 index;
20662306a36Sopenharmony_ci	u32 value;
20762306a36Sopenharmony_ci} __packed;
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_ci/* Reserved for historical reasons. */
21062306a36Sopenharmony_ci#define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED0   BIT(0)
21162306a36Sopenharmony_ci/*
21262306a36Sopenharmony_ci * Guest cursor capability: can the host show a hardware cursor at the host
21362306a36Sopenharmony_ci * pointer location?
21462306a36Sopenharmony_ci */
21562306a36Sopenharmony_ci#define VBOX_VBVA_CURSOR_CAPABILITY_HARDWARE    BIT(1)
21662306a36Sopenharmony_ci/* Reserved for historical reasons. */
21762306a36Sopenharmony_ci#define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED2   BIT(2)
21862306a36Sopenharmony_ci/* Reserved for historical reasons.  Must always be unset. */
21962306a36Sopenharmony_ci#define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED3   BIT(3)
22062306a36Sopenharmony_ci/* Reserved for historical reasons. */
22162306a36Sopenharmony_ci#define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED4   BIT(4)
22262306a36Sopenharmony_ci/* Reserved for historical reasons. */
22362306a36Sopenharmony_ci#define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED5   BIT(5)
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_cistruct vbva_infoview {
22662306a36Sopenharmony_ci	/* Index of the screen, assigned by the guest. */
22762306a36Sopenharmony_ci	u32 view_index;
22862306a36Sopenharmony_ci
22962306a36Sopenharmony_ci	/* The screen offset in VRAM, the framebuffer starts here. */
23062306a36Sopenharmony_ci	u32 view_offset;
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci	/* The size of the VRAM memory that can be used for the view. */
23362306a36Sopenharmony_ci	u32 view_size;
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ci	/* The recommended maximum size of the VRAM memory for the screen. */
23662306a36Sopenharmony_ci	u32 max_screen_size;
23762306a36Sopenharmony_ci} __packed;
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_cistruct vbva_flush {
24062306a36Sopenharmony_ci	u32 reserved;
24162306a36Sopenharmony_ci} __packed;
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci/* vbva_infoscreen.flags */
24462306a36Sopenharmony_ci#define VBVA_SCREEN_F_NONE			0x0000
24562306a36Sopenharmony_ci#define VBVA_SCREEN_F_ACTIVE			0x0001
24662306a36Sopenharmony_ci/*
24762306a36Sopenharmony_ci * The virtual monitor has been disabled by the guest and should be removed
24862306a36Sopenharmony_ci * by the host and ignored for purposes of pointer position calculation.
24962306a36Sopenharmony_ci */
25062306a36Sopenharmony_ci#define VBVA_SCREEN_F_DISABLED			0x0002
25162306a36Sopenharmony_ci/*
25262306a36Sopenharmony_ci * The virtual monitor has been blanked by the guest and should be blacked
25362306a36Sopenharmony_ci * out by the host using width, height, etc values from the vbva_infoscreen
25462306a36Sopenharmony_ci * request.
25562306a36Sopenharmony_ci */
25662306a36Sopenharmony_ci#define VBVA_SCREEN_F_BLANK			0x0004
25762306a36Sopenharmony_ci/*
25862306a36Sopenharmony_ci * The virtual monitor has been blanked by the guest and should be blacked
25962306a36Sopenharmony_ci * out by the host using the previous mode values for width. height, etc.
26062306a36Sopenharmony_ci */
26162306a36Sopenharmony_ci#define VBVA_SCREEN_F_BLANK2			0x0008
26262306a36Sopenharmony_ci
26362306a36Sopenharmony_cistruct vbva_infoscreen {
26462306a36Sopenharmony_ci	/* Which view contains the screen. */
26562306a36Sopenharmony_ci	u32 view_index;
26662306a36Sopenharmony_ci
26762306a36Sopenharmony_ci	/* Physical X origin relative to the primary screen. */
26862306a36Sopenharmony_ci	s32 origin_x;
26962306a36Sopenharmony_ci
27062306a36Sopenharmony_ci	/* Physical Y origin relative to the primary screen. */
27162306a36Sopenharmony_ci	s32 origin_y;
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci	/* Offset of visible framebuffer relative to the framebuffer start. */
27462306a36Sopenharmony_ci	u32 start_offset;
27562306a36Sopenharmony_ci
27662306a36Sopenharmony_ci	/* The scan line size in bytes. */
27762306a36Sopenharmony_ci	u32 line_size;
27862306a36Sopenharmony_ci
27962306a36Sopenharmony_ci	/* Width of the screen. */
28062306a36Sopenharmony_ci	u32 width;
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_ci	/* Height of the screen. */
28362306a36Sopenharmony_ci	u32 height;
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ci	/* Color depth. */
28662306a36Sopenharmony_ci	u16 bits_per_pixel;
28762306a36Sopenharmony_ci
28862306a36Sopenharmony_ci	/* VBVA_SCREEN_F_* */
28962306a36Sopenharmony_ci	u16 flags;
29062306a36Sopenharmony_ci} __packed;
29162306a36Sopenharmony_ci
29262306a36Sopenharmony_ci/* vbva_enable.flags */
29362306a36Sopenharmony_ci#define VBVA_F_NONE				0x00000000
29462306a36Sopenharmony_ci#define VBVA_F_ENABLE				0x00000001
29562306a36Sopenharmony_ci#define VBVA_F_DISABLE				0x00000002
29662306a36Sopenharmony_ci/* extended VBVA to be used with WDDM */
29762306a36Sopenharmony_ci#define VBVA_F_EXTENDED				0x00000004
29862306a36Sopenharmony_ci/* vbva offset is absolute VRAM offset */
29962306a36Sopenharmony_ci#define VBVA_F_ABSOFFSET			0x00000008
30062306a36Sopenharmony_ci
30162306a36Sopenharmony_cistruct vbva_enable {
30262306a36Sopenharmony_ci	u32 flags;
30362306a36Sopenharmony_ci	u32 offset;
30462306a36Sopenharmony_ci	s32 result;
30562306a36Sopenharmony_ci} __packed;
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_cistruct vbva_enable_ex {
30862306a36Sopenharmony_ci	struct vbva_enable base;
30962306a36Sopenharmony_ci	u32 screen_id;
31062306a36Sopenharmony_ci} __packed;
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_cistruct vbva_mouse_pointer_shape {
31362306a36Sopenharmony_ci	/* The host result. */
31462306a36Sopenharmony_ci	s32 result;
31562306a36Sopenharmony_ci
31662306a36Sopenharmony_ci	/* VBOX_MOUSE_POINTER_* bit flags. */
31762306a36Sopenharmony_ci	u32 flags;
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_ci	/* X coordinate of the hot spot. */
32062306a36Sopenharmony_ci	u32 hot_X;
32162306a36Sopenharmony_ci
32262306a36Sopenharmony_ci	/* Y coordinate of the hot spot. */
32362306a36Sopenharmony_ci	u32 hot_y;
32462306a36Sopenharmony_ci
32562306a36Sopenharmony_ci	/* Width of the pointer in pixels. */
32662306a36Sopenharmony_ci	u32 width;
32762306a36Sopenharmony_ci
32862306a36Sopenharmony_ci	/* Height of the pointer in scanlines. */
32962306a36Sopenharmony_ci	u32 height;
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_ci	/* Pointer data.
33262306a36Sopenharmony_ci	 *
33362306a36Sopenharmony_ci	 * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color)
33462306a36Sopenharmony_ci	 * mask.
33562306a36Sopenharmony_ci	 *
33662306a36Sopenharmony_ci	 * For pointers without alpha channel the XOR mask pixels are 32 bit
33762306a36Sopenharmony_ci	 * values: (lsb)BGR0(msb). For pointers with alpha channel the XOR mask
33862306a36Sopenharmony_ci	 * consists of (lsb)BGRA(msb) 32 bit values.
33962306a36Sopenharmony_ci	 *
34062306a36Sopenharmony_ci	 * Guest driver must create the AND mask for pointers with alpha chan.,
34162306a36Sopenharmony_ci	 * so if host does not support alpha, the pointer could be displayed as
34262306a36Sopenharmony_ci	 * a normal color pointer. The AND mask can be constructed from alpha
34362306a36Sopenharmony_ci	 * values. For example alpha value >= 0xf0 means bit 0 in the AND mask.
34462306a36Sopenharmony_ci	 *
34562306a36Sopenharmony_ci	 * The AND mask is 1 bpp bitmap with byte aligned scanlines. Size of AND
34662306a36Sopenharmony_ci	 * mask, therefore, is and_len = (width + 7) / 8 * height. The padding
34762306a36Sopenharmony_ci	 * bits at the end of any scanline are undefined.
34862306a36Sopenharmony_ci	 *
34962306a36Sopenharmony_ci	 * The XOR mask follows the AND mask on the next 4 bytes aligned offset:
35062306a36Sopenharmony_ci	 * u8 *xor = and + (and_len + 3) & ~3
35162306a36Sopenharmony_ci	 * Bytes in the gap between the AND and the XOR mask are undefined.
35262306a36Sopenharmony_ci	 * XOR mask scanlines have no gap between them and size of XOR mask is:
35362306a36Sopenharmony_ci	 * xor_len = width * 4 * height.
35462306a36Sopenharmony_ci	 *
35562306a36Sopenharmony_ci	 * Preallocate 4 bytes for accessing actual data as p->data.
35662306a36Sopenharmony_ci	 */
35762306a36Sopenharmony_ci	u8 data[4];
35862306a36Sopenharmony_ci} __packed;
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ci/* pointer is visible */
36162306a36Sopenharmony_ci#define VBOX_MOUSE_POINTER_VISIBLE		0x0001
36262306a36Sopenharmony_ci/* pointer has alpha channel */
36362306a36Sopenharmony_ci#define VBOX_MOUSE_POINTER_ALPHA		0x0002
36462306a36Sopenharmony_ci/* pointerData contains new pointer shape */
36562306a36Sopenharmony_ci#define VBOX_MOUSE_POINTER_SHAPE		0x0004
36662306a36Sopenharmony_ci
36762306a36Sopenharmony_ci/*
36862306a36Sopenharmony_ci * The guest driver can handle asynch guest cmd completion by reading the
36962306a36Sopenharmony_ci * command offset from io port.
37062306a36Sopenharmony_ci */
37162306a36Sopenharmony_ci#define VBVACAPS_COMPLETEGCMD_BY_IOREAD		0x00000001
37262306a36Sopenharmony_ci/* the guest driver can handle video adapter IRQs */
37362306a36Sopenharmony_ci#define VBVACAPS_IRQ				0x00000002
37462306a36Sopenharmony_ci/* The guest can read video mode hints sent via VBVA. */
37562306a36Sopenharmony_ci#define VBVACAPS_VIDEO_MODE_HINTS		0x00000004
37662306a36Sopenharmony_ci/* The guest can switch to a software cursor on demand. */
37762306a36Sopenharmony_ci#define VBVACAPS_DISABLE_CURSOR_INTEGRATION	0x00000008
37862306a36Sopenharmony_ci/* The guest does not depend on host handling the VBE registers. */
37962306a36Sopenharmony_ci#define VBVACAPS_USE_VBVA_ONLY			0x00000010
38062306a36Sopenharmony_ci
38162306a36Sopenharmony_cistruct vbva_caps {
38262306a36Sopenharmony_ci	s32 rc;
38362306a36Sopenharmony_ci	u32 caps;
38462306a36Sopenharmony_ci} __packed;
38562306a36Sopenharmony_ci
38662306a36Sopenharmony_ci/* Query the most recent mode hints received from the host. */
38762306a36Sopenharmony_cistruct vbva_query_mode_hints {
38862306a36Sopenharmony_ci	/* The maximum number of screens to return hints for. */
38962306a36Sopenharmony_ci	u16 hints_queried_count;
39062306a36Sopenharmony_ci	/* The size of the mode hint structures directly following this one. */
39162306a36Sopenharmony_ci	u16 hint_structure_guest_size;
39262306a36Sopenharmony_ci	/* Return code for the operation. Initialise to VERR_NOT_SUPPORTED. */
39362306a36Sopenharmony_ci	s32 rc;
39462306a36Sopenharmony_ci} __packed;
39562306a36Sopenharmony_ci
39662306a36Sopenharmony_ci/*
39762306a36Sopenharmony_ci * Structure in which a mode hint is returned. The guest allocates an array
39862306a36Sopenharmony_ci * of these immediately after the vbva_query_mode_hints structure.
39962306a36Sopenharmony_ci * To accommodate future extensions, the vbva_query_mode_hints structure
40062306a36Sopenharmony_ci * specifies the size of the vbva_modehint structures allocated by the guest,
40162306a36Sopenharmony_ci * and the host only fills out structure elements which fit into that size. The
40262306a36Sopenharmony_ci * host should fill any unused members (e.g. dx, dy) or structure space on the
40362306a36Sopenharmony_ci * end with ~0. The whole structure can legally be set to ~0 to skip a screen.
40462306a36Sopenharmony_ci */
40562306a36Sopenharmony_cistruct vbva_modehint {
40662306a36Sopenharmony_ci	u32 magic;
40762306a36Sopenharmony_ci	u32 cx;
40862306a36Sopenharmony_ci	u32 cy;
40962306a36Sopenharmony_ci	u32 bpp;		/* Which has never been used... */
41062306a36Sopenharmony_ci	u32 display;
41162306a36Sopenharmony_ci	u32 dx;			/* X offset into the virtual frame-buffer. */
41262306a36Sopenharmony_ci	u32 dy;			/* Y offset into the virtual frame-buffer. */
41362306a36Sopenharmony_ci	u32 enabled;		/* Not flags. Add new members for new flags. */
41462306a36Sopenharmony_ci} __packed;
41562306a36Sopenharmony_ci
41662306a36Sopenharmony_ci#define VBVAMODEHINT_MAGIC 0x0801add9u
41762306a36Sopenharmony_ci
41862306a36Sopenharmony_ci/*
41962306a36Sopenharmony_ci * Report the rectangle relative to which absolute pointer events should be
42062306a36Sopenharmony_ci * expressed. This information remains valid until the next VBVA resize event
42162306a36Sopenharmony_ci * for any screen, at which time it is reset to the bounding rectangle of all
42262306a36Sopenharmony_ci * virtual screens and must be re-set.
42362306a36Sopenharmony_ci */
42462306a36Sopenharmony_cistruct vbva_report_input_mapping {
42562306a36Sopenharmony_ci	s32 x;	/* Upper left X co-ordinate relative to the first screen. */
42662306a36Sopenharmony_ci	s32 y;	/* Upper left Y co-ordinate relative to the first screen. */
42762306a36Sopenharmony_ci	u32 cx;	/* Rectangle width. */
42862306a36Sopenharmony_ci	u32 cy;	/* Rectangle height. */
42962306a36Sopenharmony_ci} __packed;
43062306a36Sopenharmony_ci
43162306a36Sopenharmony_ci/*
43262306a36Sopenharmony_ci * Report the guest cursor position and query the host one. The host may wish
43362306a36Sopenharmony_ci * to use the guest information to re-position its own cursor (though this is
43462306a36Sopenharmony_ci * currently unlikely).
43562306a36Sopenharmony_ci */
43662306a36Sopenharmony_cistruct vbva_cursor_position {
43762306a36Sopenharmony_ci	u32 report_position;	/* Are we reporting a position? */
43862306a36Sopenharmony_ci	u32 x;			/* Guest cursor X position */
43962306a36Sopenharmony_ci	u32 y;			/* Guest cursor Y position */
44062306a36Sopenharmony_ci} __packed;
44162306a36Sopenharmony_ci
44262306a36Sopenharmony_ci#endif
443