153476e07SGerd Hoffmann /* 253476e07SGerd Hoffmann * Virtio GPU Device 353476e07SGerd Hoffmann * 453476e07SGerd Hoffmann * Copyright Red Hat, Inc. 2013-2014 553476e07SGerd Hoffmann * 653476e07SGerd Hoffmann * Authors: 753476e07SGerd Hoffmann * Dave Airlie <airlied@redhat.com> 853476e07SGerd Hoffmann * Gerd Hoffmann <kraxel@redhat.com> 953476e07SGerd Hoffmann * 1053476e07SGerd Hoffmann * This header is BSD licensed so anyone can use the definitions 1153476e07SGerd Hoffmann * to implement compatible drivers/servers: 1253476e07SGerd Hoffmann * 1353476e07SGerd Hoffmann * Redistribution and use in source and binary forms, with or without 1453476e07SGerd Hoffmann * modification, are permitted provided that the following conditions 1553476e07SGerd Hoffmann * are met: 1653476e07SGerd Hoffmann * 1. Redistributions of source code must retain the above copyright 1753476e07SGerd Hoffmann * notice, this list of conditions and the following disclaimer. 1853476e07SGerd Hoffmann * 2. Redistributions in binary form must reproduce the above copyright 1953476e07SGerd Hoffmann * notice, this list of conditions and the following disclaimer in the 2053476e07SGerd Hoffmann * documentation and/or other materials provided with the distribution. 2153476e07SGerd Hoffmann * 3. Neither the name of IBM nor the names of its contributors 2253476e07SGerd Hoffmann * may be used to endorse or promote products derived from this software 2353476e07SGerd Hoffmann * without specific prior written permission. 2453476e07SGerd Hoffmann * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2553476e07SGerd Hoffmann * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2653476e07SGerd Hoffmann * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 2753476e07SGerd Hoffmann * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR 2853476e07SGerd Hoffmann * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2953476e07SGerd Hoffmann * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3053476e07SGerd Hoffmann * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 3153476e07SGerd Hoffmann * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 3253476e07SGerd Hoffmann * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 3353476e07SGerd Hoffmann * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 3453476e07SGerd Hoffmann * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3553476e07SGerd Hoffmann * SUCH DAMAGE. 3653476e07SGerd Hoffmann */ 3753476e07SGerd Hoffmann 3853476e07SGerd Hoffmann #ifndef VIRTIO_GPU_HW_H 3953476e07SGerd Hoffmann #define VIRTIO_GPU_HW_H 4053476e07SGerd Hoffmann 4125b8b39bSAlexey Kardashevskiy #include "standard-headers/linux/types.h" 4225b8b39bSAlexey Kardashevskiy 43d9cb4336SCornelia Huck /* 44d9cb4336SCornelia Huck * VIRTIO_GPU_CMD_CTX_* 45d9cb4336SCornelia Huck * VIRTIO_GPU_CMD_*_3D 46d9cb4336SCornelia Huck */ 47fff02bc0SPaolo Bonzini #define VIRTIO_GPU_F_VIRGL 0 48d9cb4336SCornelia Huck 49d9cb4336SCornelia Huck /* 50d9cb4336SCornelia Huck * VIRTIO_GPU_CMD_GET_EDID 51d9cb4336SCornelia Huck */ 52da054c64SPaolo Bonzini #define VIRTIO_GPU_F_EDID 1 5353ba2eeeSMatthew Rosato /* 5453ba2eeeSMatthew Rosato * VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID 5553ba2eeeSMatthew Rosato */ 5653ba2eeeSMatthew Rosato #define VIRTIO_GPU_F_RESOURCE_UUID 2 57bc79e964SGerd Hoffmann 58b3c818a4SEric Farman /* 59b3c818a4SEric Farman * VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB 60b3c818a4SEric Farman */ 61b3c818a4SEric Farman #define VIRTIO_GPU_F_RESOURCE_BLOB 3 62*43709a0cSPaolo Bonzini /* 63*43709a0cSPaolo Bonzini * VIRTIO_GPU_CMD_CREATE_CONTEXT with 64*43709a0cSPaolo Bonzini * context_init and multiple timelines 65*43709a0cSPaolo Bonzini */ 66*43709a0cSPaolo Bonzini #define VIRTIO_GPU_F_CONTEXT_INIT 4 67b3c818a4SEric Farman 6853476e07SGerd Hoffmann enum virtio_gpu_ctrl_type { 6953476e07SGerd Hoffmann VIRTIO_GPU_UNDEFINED = 0, 7053476e07SGerd Hoffmann 7153476e07SGerd Hoffmann /* 2d commands */ 7253476e07SGerd Hoffmann VIRTIO_GPU_CMD_GET_DISPLAY_INFO = 0x0100, 7353476e07SGerd Hoffmann VIRTIO_GPU_CMD_RESOURCE_CREATE_2D, 7453476e07SGerd Hoffmann VIRTIO_GPU_CMD_RESOURCE_UNREF, 7553476e07SGerd Hoffmann VIRTIO_GPU_CMD_SET_SCANOUT, 7653476e07SGerd Hoffmann VIRTIO_GPU_CMD_RESOURCE_FLUSH, 7753476e07SGerd Hoffmann VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D, 7853476e07SGerd Hoffmann VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING, 7953476e07SGerd Hoffmann VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING, 80bc79e964SGerd Hoffmann VIRTIO_GPU_CMD_GET_CAPSET_INFO, 81bc79e964SGerd Hoffmann VIRTIO_GPU_CMD_GET_CAPSET, 82da054c64SPaolo Bonzini VIRTIO_GPU_CMD_GET_EDID, 8353ba2eeeSMatthew Rosato VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID, 84b3c818a4SEric Farman VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB, 85b3c818a4SEric Farman VIRTIO_GPU_CMD_SET_SCANOUT_BLOB, 86bc79e964SGerd Hoffmann 87bc79e964SGerd Hoffmann /* 3d commands */ 88bc79e964SGerd Hoffmann VIRTIO_GPU_CMD_CTX_CREATE = 0x0200, 89bc79e964SGerd Hoffmann VIRTIO_GPU_CMD_CTX_DESTROY, 90bc79e964SGerd Hoffmann VIRTIO_GPU_CMD_CTX_ATTACH_RESOURCE, 91bc79e964SGerd Hoffmann VIRTIO_GPU_CMD_CTX_DETACH_RESOURCE, 92bc79e964SGerd Hoffmann VIRTIO_GPU_CMD_RESOURCE_CREATE_3D, 93bc79e964SGerd Hoffmann VIRTIO_GPU_CMD_TRANSFER_TO_HOST_3D, 94bc79e964SGerd Hoffmann VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D, 95bc79e964SGerd Hoffmann VIRTIO_GPU_CMD_SUBMIT_3D, 96b3c818a4SEric Farman VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB, 97b3c818a4SEric Farman VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB, 9853476e07SGerd Hoffmann 9953476e07SGerd Hoffmann /* cursor commands */ 10053476e07SGerd Hoffmann VIRTIO_GPU_CMD_UPDATE_CURSOR = 0x0300, 10153476e07SGerd Hoffmann VIRTIO_GPU_CMD_MOVE_CURSOR, 10253476e07SGerd Hoffmann 10353476e07SGerd Hoffmann /* success responses */ 10453476e07SGerd Hoffmann VIRTIO_GPU_RESP_OK_NODATA = 0x1100, 10553476e07SGerd Hoffmann VIRTIO_GPU_RESP_OK_DISPLAY_INFO, 106bc79e964SGerd Hoffmann VIRTIO_GPU_RESP_OK_CAPSET_INFO, 107bc79e964SGerd Hoffmann VIRTIO_GPU_RESP_OK_CAPSET, 108da054c64SPaolo Bonzini VIRTIO_GPU_RESP_OK_EDID, 10953ba2eeeSMatthew Rosato VIRTIO_GPU_RESP_OK_RESOURCE_UUID, 110b3c818a4SEric Farman VIRTIO_GPU_RESP_OK_MAP_INFO, 11153476e07SGerd Hoffmann 11253476e07SGerd Hoffmann /* error responses */ 11353476e07SGerd Hoffmann VIRTIO_GPU_RESP_ERR_UNSPEC = 0x1200, 11453476e07SGerd Hoffmann VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY, 11553476e07SGerd Hoffmann VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID, 11653476e07SGerd Hoffmann VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID, 11753476e07SGerd Hoffmann VIRTIO_GPU_RESP_ERR_INVALID_CONTEXT_ID, 11853476e07SGerd Hoffmann VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER, 11953476e07SGerd Hoffmann }; 12053476e07SGerd Hoffmann 121b3c818a4SEric Farman enum virtio_gpu_shm_id { 122b3c818a4SEric Farman VIRTIO_GPU_SHM_ID_UNDEFINED = 0, 123b3c818a4SEric Farman /* 124b3c818a4SEric Farman * VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB 125b3c818a4SEric Farman * VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB 126b3c818a4SEric Farman */ 127b3c818a4SEric Farman VIRTIO_GPU_SHM_ID_HOST_VISIBLE = 1 128b3c818a4SEric Farman }; 129b3c818a4SEric Farman 13053476e07SGerd Hoffmann #define VIRTIO_GPU_FLAG_FENCE (1 << 0) 131*43709a0cSPaolo Bonzini /* 132*43709a0cSPaolo Bonzini * If the following flag is set, then ring_idx contains the index 133*43709a0cSPaolo Bonzini * of the command ring that needs to used when creating the fence 134*43709a0cSPaolo Bonzini */ 135*43709a0cSPaolo Bonzini #define VIRTIO_GPU_FLAG_INFO_RING_IDX (1 << 1) 13653476e07SGerd Hoffmann 13753476e07SGerd Hoffmann struct virtio_gpu_ctrl_hdr { 13853476e07SGerd Hoffmann uint32_t type; 13953476e07SGerd Hoffmann uint32_t flags; 14053476e07SGerd Hoffmann uint64_t fence_id; 14153476e07SGerd Hoffmann uint32_t ctx_id; 142*43709a0cSPaolo Bonzini uint8_t ring_idx; 143*43709a0cSPaolo Bonzini uint8_t padding[3]; 14453476e07SGerd Hoffmann }; 14553476e07SGerd Hoffmann 14653476e07SGerd Hoffmann /* data passed in the cursor vq */ 14753476e07SGerd Hoffmann 14853476e07SGerd Hoffmann struct virtio_gpu_cursor_pos { 14953476e07SGerd Hoffmann uint32_t scanout_id; 15053476e07SGerd Hoffmann uint32_t x; 15153476e07SGerd Hoffmann uint32_t y; 15253476e07SGerd Hoffmann uint32_t padding; 15353476e07SGerd Hoffmann }; 15453476e07SGerd Hoffmann 15553476e07SGerd Hoffmann /* VIRTIO_GPU_CMD_UPDATE_CURSOR, VIRTIO_GPU_CMD_MOVE_CURSOR */ 15653476e07SGerd Hoffmann struct virtio_gpu_update_cursor { 15753476e07SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 15853476e07SGerd Hoffmann struct virtio_gpu_cursor_pos pos; /* update & move */ 15953476e07SGerd Hoffmann uint32_t resource_id; /* update only */ 16053476e07SGerd Hoffmann uint32_t hot_x; /* update only */ 16153476e07SGerd Hoffmann uint32_t hot_y; /* update only */ 16253476e07SGerd Hoffmann uint32_t padding; 16353476e07SGerd Hoffmann }; 16453476e07SGerd Hoffmann 16553476e07SGerd Hoffmann /* data passed in the control vq, 2d related */ 16653476e07SGerd Hoffmann 16753476e07SGerd Hoffmann struct virtio_gpu_rect { 16853476e07SGerd Hoffmann uint32_t x; 16953476e07SGerd Hoffmann uint32_t y; 17053476e07SGerd Hoffmann uint32_t width; 17153476e07SGerd Hoffmann uint32_t height; 17253476e07SGerd Hoffmann }; 17353476e07SGerd Hoffmann 17453476e07SGerd Hoffmann /* VIRTIO_GPU_CMD_RESOURCE_UNREF */ 17553476e07SGerd Hoffmann struct virtio_gpu_resource_unref { 17653476e07SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 17753476e07SGerd Hoffmann uint32_t resource_id; 17853476e07SGerd Hoffmann uint32_t padding; 17953476e07SGerd Hoffmann }; 18053476e07SGerd Hoffmann 18153476e07SGerd Hoffmann /* VIRTIO_GPU_CMD_RESOURCE_CREATE_2D: create a 2d resource with a format */ 18253476e07SGerd Hoffmann struct virtio_gpu_resource_create_2d { 18353476e07SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 18453476e07SGerd Hoffmann uint32_t resource_id; 18553476e07SGerd Hoffmann uint32_t format; 18653476e07SGerd Hoffmann uint32_t width; 18753476e07SGerd Hoffmann uint32_t height; 18853476e07SGerd Hoffmann }; 18953476e07SGerd Hoffmann 19053476e07SGerd Hoffmann /* VIRTIO_GPU_CMD_SET_SCANOUT */ 19153476e07SGerd Hoffmann struct virtio_gpu_set_scanout { 19253476e07SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 19353476e07SGerd Hoffmann struct virtio_gpu_rect r; 19453476e07SGerd Hoffmann uint32_t scanout_id; 19553476e07SGerd Hoffmann uint32_t resource_id; 19653476e07SGerd Hoffmann }; 19753476e07SGerd Hoffmann 19853476e07SGerd Hoffmann /* VIRTIO_GPU_CMD_RESOURCE_FLUSH */ 19953476e07SGerd Hoffmann struct virtio_gpu_resource_flush { 20053476e07SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 20153476e07SGerd Hoffmann struct virtio_gpu_rect r; 20253476e07SGerd Hoffmann uint32_t resource_id; 20353476e07SGerd Hoffmann uint32_t padding; 20453476e07SGerd Hoffmann }; 20553476e07SGerd Hoffmann 20653476e07SGerd Hoffmann /* VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D: simple transfer to_host */ 20753476e07SGerd Hoffmann struct virtio_gpu_transfer_to_host_2d { 20853476e07SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 20953476e07SGerd Hoffmann struct virtio_gpu_rect r; 21053476e07SGerd Hoffmann uint64_t offset; 21153476e07SGerd Hoffmann uint32_t resource_id; 21253476e07SGerd Hoffmann uint32_t padding; 21353476e07SGerd Hoffmann }; 21453476e07SGerd Hoffmann 21553476e07SGerd Hoffmann struct virtio_gpu_mem_entry { 21653476e07SGerd Hoffmann uint64_t addr; 21753476e07SGerd Hoffmann uint32_t length; 21853476e07SGerd Hoffmann uint32_t padding; 21953476e07SGerd Hoffmann }; 22053476e07SGerd Hoffmann 22153476e07SGerd Hoffmann /* VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING */ 22253476e07SGerd Hoffmann struct virtio_gpu_resource_attach_backing { 22353476e07SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 22453476e07SGerd Hoffmann uint32_t resource_id; 22553476e07SGerd Hoffmann uint32_t nr_entries; 22653476e07SGerd Hoffmann }; 22753476e07SGerd Hoffmann 22853476e07SGerd Hoffmann /* VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING */ 22953476e07SGerd Hoffmann struct virtio_gpu_resource_detach_backing { 23053476e07SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 23153476e07SGerd Hoffmann uint32_t resource_id; 23253476e07SGerd Hoffmann uint32_t padding; 23353476e07SGerd Hoffmann }; 23453476e07SGerd Hoffmann 23553476e07SGerd Hoffmann /* VIRTIO_GPU_RESP_OK_DISPLAY_INFO */ 23653476e07SGerd Hoffmann #define VIRTIO_GPU_MAX_SCANOUTS 16 23753476e07SGerd Hoffmann struct virtio_gpu_resp_display_info { 23853476e07SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 23953476e07SGerd Hoffmann struct virtio_gpu_display_one { 24053476e07SGerd Hoffmann struct virtio_gpu_rect r; 24153476e07SGerd Hoffmann uint32_t enabled; 24253476e07SGerd Hoffmann uint32_t flags; 24353476e07SGerd Hoffmann } pmodes[VIRTIO_GPU_MAX_SCANOUTS]; 24453476e07SGerd Hoffmann }; 24553476e07SGerd Hoffmann 246bc79e964SGerd Hoffmann /* data passed in the control vq, 3d related */ 247bc79e964SGerd Hoffmann 248bc79e964SGerd Hoffmann struct virtio_gpu_box { 249bc79e964SGerd Hoffmann uint32_t x, y, z; 250bc79e964SGerd Hoffmann uint32_t w, h, d; 251bc79e964SGerd Hoffmann }; 252bc79e964SGerd Hoffmann 253bc79e964SGerd Hoffmann /* VIRTIO_GPU_CMD_TRANSFER_TO_HOST_3D, VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D */ 254bc79e964SGerd Hoffmann struct virtio_gpu_transfer_host_3d { 255bc79e964SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 256bc79e964SGerd Hoffmann struct virtio_gpu_box box; 257bc79e964SGerd Hoffmann uint64_t offset; 258bc79e964SGerd Hoffmann uint32_t resource_id; 259bc79e964SGerd Hoffmann uint32_t level; 260bc79e964SGerd Hoffmann uint32_t stride; 261bc79e964SGerd Hoffmann uint32_t layer_stride; 262bc79e964SGerd Hoffmann }; 263bc79e964SGerd Hoffmann 264bc79e964SGerd Hoffmann /* VIRTIO_GPU_CMD_RESOURCE_CREATE_3D */ 265bc79e964SGerd Hoffmann #define VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP (1 << 0) 266bc79e964SGerd Hoffmann struct virtio_gpu_resource_create_3d { 267bc79e964SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 268bc79e964SGerd Hoffmann uint32_t resource_id; 269bc79e964SGerd Hoffmann uint32_t target; 270bc79e964SGerd Hoffmann uint32_t format; 271bc79e964SGerd Hoffmann uint32_t bind; 272bc79e964SGerd Hoffmann uint32_t width; 273bc79e964SGerd Hoffmann uint32_t height; 274bc79e964SGerd Hoffmann uint32_t depth; 275bc79e964SGerd Hoffmann uint32_t array_size; 276bc79e964SGerd Hoffmann uint32_t last_level; 277bc79e964SGerd Hoffmann uint32_t nr_samples; 278bc79e964SGerd Hoffmann uint32_t flags; 279bc79e964SGerd Hoffmann uint32_t padding; 280bc79e964SGerd Hoffmann }; 281bc79e964SGerd Hoffmann 282bc79e964SGerd Hoffmann /* VIRTIO_GPU_CMD_CTX_CREATE */ 283*43709a0cSPaolo Bonzini #define VIRTIO_GPU_CONTEXT_INIT_CAPSET_ID_MASK 0x000000ff 284bc79e964SGerd Hoffmann struct virtio_gpu_ctx_create { 285bc79e964SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 286bc79e964SGerd Hoffmann uint32_t nlen; 287*43709a0cSPaolo Bonzini uint32_t context_init; 288bc79e964SGerd Hoffmann char debug_name[64]; 289bc79e964SGerd Hoffmann }; 290bc79e964SGerd Hoffmann 291bc79e964SGerd Hoffmann /* VIRTIO_GPU_CMD_CTX_DESTROY */ 292bc79e964SGerd Hoffmann struct virtio_gpu_ctx_destroy { 293bc79e964SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 294bc79e964SGerd Hoffmann }; 295bc79e964SGerd Hoffmann 296bc79e964SGerd Hoffmann /* VIRTIO_GPU_CMD_CTX_ATTACH_RESOURCE, VIRTIO_GPU_CMD_CTX_DETACH_RESOURCE */ 297bc79e964SGerd Hoffmann struct virtio_gpu_ctx_resource { 298bc79e964SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 299bc79e964SGerd Hoffmann uint32_t resource_id; 300bc79e964SGerd Hoffmann uint32_t padding; 301bc79e964SGerd Hoffmann }; 302bc79e964SGerd Hoffmann 303bc79e964SGerd Hoffmann /* VIRTIO_GPU_CMD_SUBMIT_3D */ 304bc79e964SGerd Hoffmann struct virtio_gpu_cmd_submit { 305bc79e964SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 306bc79e964SGerd Hoffmann uint32_t size; 307bc79e964SGerd Hoffmann uint32_t padding; 308bc79e964SGerd Hoffmann }; 309bc79e964SGerd Hoffmann 310bc79e964SGerd Hoffmann #define VIRTIO_GPU_CAPSET_VIRGL 1 31177d361b1SEric Auger #define VIRTIO_GPU_CAPSET_VIRGL2 2 312bc79e964SGerd Hoffmann 313bc79e964SGerd Hoffmann /* VIRTIO_GPU_CMD_GET_CAPSET_INFO */ 314bc79e964SGerd Hoffmann struct virtio_gpu_get_capset_info { 315bc79e964SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 316bc79e964SGerd Hoffmann uint32_t capset_index; 317bc79e964SGerd Hoffmann uint32_t padding; 318bc79e964SGerd Hoffmann }; 319bc79e964SGerd Hoffmann 320bc79e964SGerd Hoffmann /* VIRTIO_GPU_RESP_OK_CAPSET_INFO */ 321bc79e964SGerd Hoffmann struct virtio_gpu_resp_capset_info { 322bc79e964SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 323bc79e964SGerd Hoffmann uint32_t capset_id; 324bc79e964SGerd Hoffmann uint32_t capset_max_version; 325bc79e964SGerd Hoffmann uint32_t capset_max_size; 326bc79e964SGerd Hoffmann uint32_t padding; 327bc79e964SGerd Hoffmann }; 328bc79e964SGerd Hoffmann 329bc79e964SGerd Hoffmann /* VIRTIO_GPU_CMD_GET_CAPSET */ 330bc79e964SGerd Hoffmann struct virtio_gpu_get_capset { 331bc79e964SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 332bc79e964SGerd Hoffmann uint32_t capset_id; 333bc79e964SGerd Hoffmann uint32_t capset_version; 334bc79e964SGerd Hoffmann }; 335bc79e964SGerd Hoffmann 336bc79e964SGerd Hoffmann /* VIRTIO_GPU_RESP_OK_CAPSET */ 337bc79e964SGerd Hoffmann struct virtio_gpu_resp_capset { 338bc79e964SGerd Hoffmann struct virtio_gpu_ctrl_hdr hdr; 339bc79e964SGerd Hoffmann uint8_t capset_data[]; 340bc79e964SGerd Hoffmann }; 341bc79e964SGerd Hoffmann 342da054c64SPaolo Bonzini /* VIRTIO_GPU_CMD_GET_EDID */ 343da054c64SPaolo Bonzini struct virtio_gpu_cmd_get_edid { 344da054c64SPaolo Bonzini struct virtio_gpu_ctrl_hdr hdr; 345da054c64SPaolo Bonzini uint32_t scanout; 346da054c64SPaolo Bonzini uint32_t padding; 347da054c64SPaolo Bonzini }; 348da054c64SPaolo Bonzini 349da054c64SPaolo Bonzini /* VIRTIO_GPU_RESP_OK_EDID */ 350da054c64SPaolo Bonzini struct virtio_gpu_resp_edid { 351da054c64SPaolo Bonzini struct virtio_gpu_ctrl_hdr hdr; 352da054c64SPaolo Bonzini uint32_t size; 353da054c64SPaolo Bonzini uint32_t padding; 354da054c64SPaolo Bonzini uint8_t edid[1024]; 355da054c64SPaolo Bonzini }; 356da054c64SPaolo Bonzini 35753476e07SGerd Hoffmann #define VIRTIO_GPU_EVENT_DISPLAY (1 << 0) 35853476e07SGerd Hoffmann 35953476e07SGerd Hoffmann struct virtio_gpu_config { 36053476e07SGerd Hoffmann uint32_t events_read; 36153476e07SGerd Hoffmann uint32_t events_clear; 36253476e07SGerd Hoffmann uint32_t num_scanouts; 363bc79e964SGerd Hoffmann uint32_t num_capsets; 36453476e07SGerd Hoffmann }; 36553476e07SGerd Hoffmann 36653476e07SGerd Hoffmann /* simple formats for fbcon/X use */ 36753476e07SGerd Hoffmann enum virtio_gpu_formats { 36853476e07SGerd Hoffmann VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM = 1, 36953476e07SGerd Hoffmann VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM = 2, 37053476e07SGerd Hoffmann VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM = 3, 37153476e07SGerd Hoffmann VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM = 4, 37253476e07SGerd Hoffmann 37353476e07SGerd Hoffmann VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM = 67, 37453476e07SGerd Hoffmann VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM = 68, 37553476e07SGerd Hoffmann 37653476e07SGerd Hoffmann VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM = 121, 37753476e07SGerd Hoffmann VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM = 134, 37853476e07SGerd Hoffmann }; 37953476e07SGerd Hoffmann 38053ba2eeeSMatthew Rosato /* VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID */ 38153ba2eeeSMatthew Rosato struct virtio_gpu_resource_assign_uuid { 38253ba2eeeSMatthew Rosato struct virtio_gpu_ctrl_hdr hdr; 38353ba2eeeSMatthew Rosato uint32_t resource_id; 38453ba2eeeSMatthew Rosato uint32_t padding; 38553ba2eeeSMatthew Rosato }; 38653ba2eeeSMatthew Rosato 38753ba2eeeSMatthew Rosato /* VIRTIO_GPU_RESP_OK_RESOURCE_UUID */ 38853ba2eeeSMatthew Rosato struct virtio_gpu_resp_resource_uuid { 38953ba2eeeSMatthew Rosato struct virtio_gpu_ctrl_hdr hdr; 39053ba2eeeSMatthew Rosato uint8_t uuid[16]; 39153ba2eeeSMatthew Rosato }; 39253ba2eeeSMatthew Rosato 393b3c818a4SEric Farman /* VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB */ 394b3c818a4SEric Farman struct virtio_gpu_resource_create_blob { 395b3c818a4SEric Farman struct virtio_gpu_ctrl_hdr hdr; 396b3c818a4SEric Farman uint32_t resource_id; 397b3c818a4SEric Farman #define VIRTIO_GPU_BLOB_MEM_GUEST 0x0001 398b3c818a4SEric Farman #define VIRTIO_GPU_BLOB_MEM_HOST3D 0x0002 399b3c818a4SEric Farman #define VIRTIO_GPU_BLOB_MEM_HOST3D_GUEST 0x0003 400b3c818a4SEric Farman 401b3c818a4SEric Farman #define VIRTIO_GPU_BLOB_FLAG_USE_MAPPABLE 0x0001 402b3c818a4SEric Farman #define VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE 0x0002 403b3c818a4SEric Farman #define VIRTIO_GPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004 404b3c818a4SEric Farman /* zero is invalid blob mem */ 405b3c818a4SEric Farman uint32_t blob_mem; 406b3c818a4SEric Farman uint32_t blob_flags; 407b3c818a4SEric Farman uint32_t nr_entries; 408b3c818a4SEric Farman uint64_t blob_id; 409b3c818a4SEric Farman uint64_t size; 410b3c818a4SEric Farman /* 411b3c818a4SEric Farman * sizeof(nr_entries * virtio_gpu_mem_entry) bytes follow 412b3c818a4SEric Farman */ 413b3c818a4SEric Farman }; 414b3c818a4SEric Farman 415b3c818a4SEric Farman /* VIRTIO_GPU_CMD_SET_SCANOUT_BLOB */ 416b3c818a4SEric Farman struct virtio_gpu_set_scanout_blob { 417b3c818a4SEric Farman struct virtio_gpu_ctrl_hdr hdr; 418b3c818a4SEric Farman struct virtio_gpu_rect r; 419b3c818a4SEric Farman uint32_t scanout_id; 420b3c818a4SEric Farman uint32_t resource_id; 421b3c818a4SEric Farman uint32_t width; 422b3c818a4SEric Farman uint32_t height; 423b3c818a4SEric Farman uint32_t format; 424b3c818a4SEric Farman uint32_t padding; 425b3c818a4SEric Farman uint32_t strides[4]; 426b3c818a4SEric Farman uint32_t offsets[4]; 427b3c818a4SEric Farman }; 428b3c818a4SEric Farman 429b3c818a4SEric Farman /* VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB */ 430b3c818a4SEric Farman struct virtio_gpu_resource_map_blob { 431b3c818a4SEric Farman struct virtio_gpu_ctrl_hdr hdr; 432b3c818a4SEric Farman uint32_t resource_id; 433b3c818a4SEric Farman uint32_t padding; 434b3c818a4SEric Farman uint64_t offset; 435b3c818a4SEric Farman }; 436b3c818a4SEric Farman 437b3c818a4SEric Farman /* VIRTIO_GPU_RESP_OK_MAP_INFO */ 438b3c818a4SEric Farman #define VIRTIO_GPU_MAP_CACHE_MASK 0x0f 439b3c818a4SEric Farman #define VIRTIO_GPU_MAP_CACHE_NONE 0x00 440b3c818a4SEric Farman #define VIRTIO_GPU_MAP_CACHE_CACHED 0x01 441b3c818a4SEric Farman #define VIRTIO_GPU_MAP_CACHE_UNCACHED 0x02 442b3c818a4SEric Farman #define VIRTIO_GPU_MAP_CACHE_WC 0x03 443b3c818a4SEric Farman struct virtio_gpu_resp_map_info { 444b3c818a4SEric Farman struct virtio_gpu_ctrl_hdr hdr; 445b3c818a4SEric Farman uint32_t map_info; 446b3c818a4SEric Farman uint32_t padding; 447b3c818a4SEric Farman }; 448b3c818a4SEric Farman 449b3c818a4SEric Farman /* VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB */ 450b3c818a4SEric Farman struct virtio_gpu_resource_unmap_blob { 451b3c818a4SEric Farman struct virtio_gpu_ctrl_hdr hdr; 452b3c818a4SEric Farman uint32_t resource_id; 453b3c818a4SEric Farman uint32_t padding; 454b3c818a4SEric Farman }; 455b3c818a4SEric Farman 45653476e07SGerd Hoffmann #endif 457