![]() |
|
|||
0001 /* SPDX-License-Identifier: MIT */ 0002 /* Copyright (C) 2006-2016 Oracle Corporation */ 0003 0004 #ifndef __VBOXVIDEO_H__ 0005 #define __VBOXVIDEO_H__ 0006 0007 #define VBOX_VIDEO_MAX_SCREENS 64 0008 0009 /* 0010 * The last 4096 bytes of the guest VRAM contains the generic info for all 0011 * DualView chunks: sizes and offsets of chunks. This is filled by miniport. 0012 * 0013 * Last 4096 bytes of each chunk contain chunk specific data: framebuffer info, 0014 * etc. This is used exclusively by the corresponding instance of a display 0015 * driver. 0016 * 0017 * The VRAM layout: 0018 * Last 4096 bytes - Adapter information area. 0019 * 4096 bytes aligned miniport heap (value specified in the config rouded up). 0020 * Slack - what left after dividing the VRAM. 0021 * 4096 bytes aligned framebuffers: 0022 * last 4096 bytes of each framebuffer is the display information area. 0023 * 0024 * The Virtual Graphics Adapter information in the guest VRAM is stored by the 0025 * guest video driver using structures prepended by VBOXVIDEOINFOHDR. 0026 * 0027 * When the guest driver writes dword 0 to the VBE_DISPI_INDEX_VBOX_VIDEO 0028 * the host starts to process the info. The first element at the start of 0029 * the 4096 bytes region should be normally be a LINK that points to 0030 * actual information chain. That way the guest driver can have some 0031 * fixed layout of the information memory block and just rewrite 0032 * the link to point to relevant memory chain. 0033 * 0034 * The processing stops at the END element. 0035 * 0036 * The host can access the memory only when the port IO is processed. 0037 * All data that will be needed later must be copied from these 4096 bytes. 0038 * But other VRAM can be used by host until the mode is disabled. 0039 * 0040 * The guest driver writes dword 0xffffffff to the VBE_DISPI_INDEX_VBOX_VIDEO 0041 * to disable the mode. 0042 * 0043 * VBE_DISPI_INDEX_VBOX_VIDEO is used to read the configuration information 0044 * from the host and issue commands to the host. 0045 * 0046 * The guest writes the VBE_DISPI_INDEX_VBOX_VIDEO index register, the the 0047 * following operations with the VBE data register can be performed: 0048 * 0049 * Operation Result 0050 * write 16 bit value NOP 0051 * read 16 bit value count of monitors 0052 * write 32 bit value set the vbox cmd value and the cmd processed by the host 0053 * read 32 bit value result of the last vbox command is returned 0054 */ 0055 0056 struct vbva_cmd_hdr { 0057 s16 x; 0058 s16 y; 0059 u16 w; 0060 u16 h; 0061 } __packed; 0062 0063 /* 0064 * The VBVA ring buffer is suitable for transferring large (< 2GB) amount of 0065 * data. For example big bitmaps which do not fit to the buffer. 0066 * 0067 * Guest starts writing to the buffer by initializing a record entry in the 0068 * records queue. VBVA_F_RECORD_PARTIAL indicates that the record is being 0069 * written. As data is written to the ring buffer, the guest increases 0070 * free_offset. 0071 * 0072 * The host reads the records on flushes and processes all completed records. 0073 * When host encounters situation when only a partial record presents and 0074 * len_and_flags & ~VBVA_F_RECORD_PARTIAL >= VBVA_RING_BUFFER_SIZE - 0075 * VBVA_RING_BUFFER_THRESHOLD, the host fetched all record data and updates 0076 * data_offset. After that on each flush the host continues fetching the data 0077 * until the record is completed. 0078 */ 0079 0080 #define VBVA_RING_BUFFER_SIZE (4194304 - 1024) 0081 #define VBVA_RING_BUFFER_THRESHOLD (4096) 0082 0083 #define VBVA_MAX_RECORDS (64) 0084 0085 #define VBVA_F_MODE_ENABLED 0x00000001u 0086 #define VBVA_F_MODE_VRDP 0x00000002u 0087 #define VBVA_F_MODE_VRDP_RESET 0x00000004u 0088 #define VBVA_F_MODE_VRDP_ORDER_MASK 0x00000008u 0089 0090 #define VBVA_F_STATE_PROCESSING 0x00010000u 0091 0092 #define VBVA_F_RECORD_PARTIAL 0x80000000u 0093 0094 struct vbva_record { 0095 u32 len_and_flags; 0096 } __packed; 0097 0098 /* 0099 * The minimum HGSMI heap size is PAGE_SIZE (4096 bytes) and is a restriction of 0100 * the runtime heapsimple API. Use minimum 2 pages here, because the info area 0101 * also may contain other data (for example hgsmi_host_flags structure). 0102 */ 0103 #define VBVA_ADAPTER_INFORMATION_SIZE 65536 0104 #define VBVA_MIN_BUFFER_SIZE 65536 0105 0106 /* The value for port IO to let the adapter to interpret the adapter memory. */ 0107 #define VBOX_VIDEO_DISABLE_ADAPTER_MEMORY 0xFFFFFFFF 0108 0109 /* The value for port IO to let the adapter to interpret the adapter memory. */ 0110 #define VBOX_VIDEO_INTERPRET_ADAPTER_MEMORY 0x00000000 0111 0112 /* 0113 * The value for port IO to let the adapter to interpret the display memory. 0114 * The display number is encoded in low 16 bits. 0115 */ 0116 #define VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE 0x00010000 0117 0118 struct vbva_host_flags { 0119 u32 host_events; 0120 u32 supported_orders; 0121 } __packed; 0122 0123 struct vbva_buffer { 0124 struct vbva_host_flags host_flags; 0125 0126 /* The offset where the data start in the buffer. */ 0127 u32 data_offset; 0128 /* The offset where next data must be placed in the buffer. */ 0129 u32 free_offset; 0130 0131 /* The queue of record descriptions. */ 0132 struct vbva_record records[VBVA_MAX_RECORDS]; 0133 u32 record_first_index; 0134 u32 record_free_index; 0135 0136 /* Space to leave free when large partial records are transferred. */ 0137 u32 partial_write_tresh; 0138 0139 u32 data_len; 0140 /* variable size for the rest of the vbva_buffer area in VRAM. */ 0141 u8 data[]; 0142 } __packed; 0143 0144 #define VBVA_MAX_RECORD_SIZE (128 * 1024 * 1024) 0145 0146 /* guest->host commands */ 0147 #define VBVA_QUERY_CONF32 1 0148 #define VBVA_SET_CONF32 2 0149 #define VBVA_INFO_VIEW 3 0150 #define VBVA_INFO_HEAP 4 0151 #define VBVA_FLUSH 5 0152 #define VBVA_INFO_SCREEN 6 0153 #define VBVA_ENABLE 7 0154 #define VBVA_MOUSE_POINTER_SHAPE 8 0155 /* informs host about HGSMI caps. see vbva_caps below */ 0156 #define VBVA_INFO_CAPS 12 0157 /* configures scanline, see VBVASCANLINECFG below */ 0158 #define VBVA_SCANLINE_CFG 13 0159 /* requests scanline info, see VBVASCANLINEINFO below */ 0160 #define VBVA_SCANLINE_INFO 14 0161 /* inform host about VBVA Command submission */ 0162 #define VBVA_CMDVBVA_SUBMIT 16 0163 /* inform host about VBVA Command submission */ 0164 #define VBVA_CMDVBVA_FLUSH 17 0165 /* G->H DMA command */ 0166 #define VBVA_CMDVBVA_CTL 18 0167 /* Query most recent mode hints sent */ 0168 #define VBVA_QUERY_MODE_HINTS 19 0169 /* 0170 * Report the guest virtual desktop position and size for mapping host and 0171 * guest pointer positions. 0172 */ 0173 #define VBVA_REPORT_INPUT_MAPPING 20 0174 /* Report the guest cursor position and query the host position. */ 0175 #define VBVA_CURSOR_POSITION 21 0176 0177 /* host->guest commands */ 0178 #define VBVAHG_EVENT 1 0179 #define VBVAHG_DISPLAY_CUSTOM 2 0180 0181 /* vbva_conf32::index */ 0182 #define VBOX_VBVA_CONF32_MONITOR_COUNT 0 0183 #define VBOX_VBVA_CONF32_HOST_HEAP_SIZE 1 0184 /* 0185 * Returns VINF_SUCCESS if the host can report mode hints via VBVA. 0186 * Set value to VERR_NOT_SUPPORTED before calling. 0187 */ 0188 #define VBOX_VBVA_CONF32_MODE_HINT_REPORTING 2 0189 /* 0190 * Returns VINF_SUCCESS if the host can report guest cursor enabled status via 0191 * VBVA. Set value to VERR_NOT_SUPPORTED before calling. 0192 */ 0193 #define VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING 3 0194 /* 0195 * Returns the currently available host cursor capabilities. Available if 0196 * VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING returns success. 0197 */ 0198 #define VBOX_VBVA_CONF32_CURSOR_CAPABILITIES 4 0199 /* Returns the supported flags in vbva_infoscreen.flags. */ 0200 #define VBOX_VBVA_CONF32_SCREEN_FLAGS 5 0201 /* Returns the max size of VBVA record. */ 0202 #define VBOX_VBVA_CONF32_MAX_RECORD_SIZE 6 0203 0204 struct vbva_conf32 { 0205 u32 index; 0206 u32 value; 0207 } __packed; 0208 0209 /* Reserved for historical reasons. */ 0210 #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED0 BIT(0) 0211 /* 0212 * Guest cursor capability: can the host show a hardware cursor at the host 0213 * pointer location? 0214 */ 0215 #define VBOX_VBVA_CURSOR_CAPABILITY_HARDWARE BIT(1) 0216 /* Reserved for historical reasons. */ 0217 #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED2 BIT(2) 0218 /* Reserved for historical reasons. Must always be unset. */ 0219 #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED3 BIT(3) 0220 /* Reserved for historical reasons. */ 0221 #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED4 BIT(4) 0222 /* Reserved for historical reasons. */ 0223 #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED5 BIT(5) 0224 0225 struct vbva_infoview { 0226 /* Index of the screen, assigned by the guest. */ 0227 u32 view_index; 0228 0229 /* The screen offset in VRAM, the framebuffer starts here. */ 0230 u32 view_offset; 0231 0232 /* The size of the VRAM memory that can be used for the view. */ 0233 u32 view_size; 0234 0235 /* The recommended maximum size of the VRAM memory for the screen. */ 0236 u32 max_screen_size; 0237 } __packed; 0238 0239 struct vbva_flush { 0240 u32 reserved; 0241 } __packed; 0242 0243 /* vbva_infoscreen.flags */ 0244 #define VBVA_SCREEN_F_NONE 0x0000 0245 #define VBVA_SCREEN_F_ACTIVE 0x0001 0246 /* 0247 * The virtual monitor has been disabled by the guest and should be removed 0248 * by the host and ignored for purposes of pointer position calculation. 0249 */ 0250 #define VBVA_SCREEN_F_DISABLED 0x0002 0251 /* 0252 * The virtual monitor has been blanked by the guest and should be blacked 0253 * out by the host using width, height, etc values from the vbva_infoscreen 0254 * request. 0255 */ 0256 #define VBVA_SCREEN_F_BLANK 0x0004 0257 /* 0258 * The virtual monitor has been blanked by the guest and should be blacked 0259 * out by the host using the previous mode values for width. height, etc. 0260 */ 0261 #define VBVA_SCREEN_F_BLANK2 0x0008 0262 0263 struct vbva_infoscreen { 0264 /* Which view contains the screen. */ 0265 u32 view_index; 0266 0267 /* Physical X origin relative to the primary screen. */ 0268 s32 origin_x; 0269 0270 /* Physical Y origin relative to the primary screen. */ 0271 s32 origin_y; 0272 0273 /* Offset of visible framebuffer relative to the framebuffer start. */ 0274 u32 start_offset; 0275 0276 /* The scan line size in bytes. */ 0277 u32 line_size; 0278 0279 /* Width of the screen. */ 0280 u32 width; 0281 0282 /* Height of the screen. */ 0283 u32 height; 0284 0285 /* Color depth. */ 0286 u16 bits_per_pixel; 0287 0288 /* VBVA_SCREEN_F_* */ 0289 u16 flags; 0290 } __packed; 0291 0292 /* vbva_enable.flags */ 0293 #define VBVA_F_NONE 0x00000000 0294 #define VBVA_F_ENABLE 0x00000001 0295 #define VBVA_F_DISABLE 0x00000002 0296 /* extended VBVA to be used with WDDM */ 0297 #define VBVA_F_EXTENDED 0x00000004 0298 /* vbva offset is absolute VRAM offset */ 0299 #define VBVA_F_ABSOFFSET 0x00000008 0300 0301 struct vbva_enable { 0302 u32 flags; 0303 u32 offset; 0304 s32 result; 0305 } __packed; 0306 0307 struct vbva_enable_ex { 0308 struct vbva_enable base; 0309 u32 screen_id; 0310 } __packed; 0311 0312 struct vbva_mouse_pointer_shape { 0313 /* The host result. */ 0314 s32 result; 0315 0316 /* VBOX_MOUSE_POINTER_* bit flags. */ 0317 u32 flags; 0318 0319 /* X coordinate of the hot spot. */ 0320 u32 hot_X; 0321 0322 /* Y coordinate of the hot spot. */ 0323 u32 hot_y; 0324 0325 /* Width of the pointer in pixels. */ 0326 u32 width; 0327 0328 /* Height of the pointer in scanlines. */ 0329 u32 height; 0330 0331 /* Pointer data. 0332 * 0333 * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color) 0334 * mask. 0335 * 0336 * For pointers without alpha channel the XOR mask pixels are 32 bit 0337 * values: (lsb)BGR0(msb). For pointers with alpha channel the XOR mask 0338 * consists of (lsb)BGRA(msb) 32 bit values. 0339 * 0340 * Guest driver must create the AND mask for pointers with alpha chan., 0341 * so if host does not support alpha, the pointer could be displayed as 0342 * a normal color pointer. The AND mask can be constructed from alpha 0343 * values. For example alpha value >= 0xf0 means bit 0 in the AND mask. 0344 * 0345 * The AND mask is 1 bpp bitmap with byte aligned scanlines. Size of AND 0346 * mask, therefore, is and_len = (width + 7) / 8 * height. The padding 0347 * bits at the end of any scanline are undefined. 0348 * 0349 * The XOR mask follows the AND mask on the next 4 bytes aligned offset: 0350 * u8 *xor = and + (and_len + 3) & ~3 0351 * Bytes in the gap between the AND and the XOR mask are undefined. 0352 * XOR mask scanlines have no gap between them and size of XOR mask is: 0353 * xor_len = width * 4 * height. 0354 * 0355 * Preallocate 4 bytes for accessing actual data as p->data. 0356 */ 0357 u8 data[4]; 0358 } __packed; 0359 0360 /* pointer is visible */ 0361 #define VBOX_MOUSE_POINTER_VISIBLE 0x0001 0362 /* pointer has alpha channel */ 0363 #define VBOX_MOUSE_POINTER_ALPHA 0x0002 0364 /* pointerData contains new pointer shape */ 0365 #define VBOX_MOUSE_POINTER_SHAPE 0x0004 0366 0367 /* 0368 * The guest driver can handle asynch guest cmd completion by reading the 0369 * command offset from io port. 0370 */ 0371 #define VBVACAPS_COMPLETEGCMD_BY_IOREAD 0x00000001 0372 /* the guest driver can handle video adapter IRQs */ 0373 #define VBVACAPS_IRQ 0x00000002 0374 /* The guest can read video mode hints sent via VBVA. */ 0375 #define VBVACAPS_VIDEO_MODE_HINTS 0x00000004 0376 /* The guest can switch to a software cursor on demand. */ 0377 #define VBVACAPS_DISABLE_CURSOR_INTEGRATION 0x00000008 0378 /* The guest does not depend on host handling the VBE registers. */ 0379 #define VBVACAPS_USE_VBVA_ONLY 0x00000010 0380 0381 struct vbva_caps { 0382 s32 rc; 0383 u32 caps; 0384 } __packed; 0385 0386 /* Query the most recent mode hints received from the host. */ 0387 struct vbva_query_mode_hints { 0388 /* The maximum number of screens to return hints for. */ 0389 u16 hints_queried_count; 0390 /* The size of the mode hint structures directly following this one. */ 0391 u16 hint_structure_guest_size; 0392 /* Return code for the operation. Initialise to VERR_NOT_SUPPORTED. */ 0393 s32 rc; 0394 } __packed; 0395 0396 /* 0397 * Structure in which a mode hint is returned. The guest allocates an array 0398 * of these immediately after the vbva_query_mode_hints structure. 0399 * To accommodate future extensions, the vbva_query_mode_hints structure 0400 * specifies the size of the vbva_modehint structures allocated by the guest, 0401 * and the host only fills out structure elements which fit into that size. The 0402 * host should fill any unused members (e.g. dx, dy) or structure space on the 0403 * end with ~0. The whole structure can legally be set to ~0 to skip a screen. 0404 */ 0405 struct vbva_modehint { 0406 u32 magic; 0407 u32 cx; 0408 u32 cy; 0409 u32 bpp; /* Which has never been used... */ 0410 u32 display; 0411 u32 dx; /* X offset into the virtual frame-buffer. */ 0412 u32 dy; /* Y offset into the virtual frame-buffer. */ 0413 u32 enabled; /* Not flags. Add new members for new flags. */ 0414 } __packed; 0415 0416 #define VBVAMODEHINT_MAGIC 0x0801add9u 0417 0418 /* 0419 * Report the rectangle relative to which absolute pointer events should be 0420 * expressed. This information remains valid until the next VBVA resize event 0421 * for any screen, at which time it is reset to the bounding rectangle of all 0422 * virtual screens and must be re-set. 0423 */ 0424 struct vbva_report_input_mapping { 0425 s32 x; /* Upper left X co-ordinate relative to the first screen. */ 0426 s32 y; /* Upper left Y co-ordinate relative to the first screen. */ 0427 u32 cx; /* Rectangle width. */ 0428 u32 cy; /* Rectangle height. */ 0429 } __packed; 0430 0431 /* 0432 * Report the guest cursor position and query the host one. The host may wish 0433 * to use the guest information to re-position its own cursor (though this is 0434 * currently unlikely). 0435 */ 0436 struct vbva_cursor_position { 0437 u32 report_position; /* Are we reporting a position? */ 0438 u32 x; /* Guest cursor X position */ 0439 u32 y; /* Guest cursor Y position */ 0440 } __packed; 0441 0442 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |