blob: 28f02175778bfb361be3303ea6d793bf93539a5d [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Christopher Ferris05d08e92016-02-04 13:16:38 -08007#ifndef VIRTIO_GPU_HW_H
8#define VIRTIO_GPU_HW_H
9#include <linux/types.h>
10#define VIRTIO_GPU_F_VIRGL 0
Christopher Ferrisd842e432019-03-07 10:21:59 -080011#define VIRTIO_GPU_F_EDID 1
Christopher Ferris32ff3f82020-12-14 13:10:04 -080012#define VIRTIO_GPU_F_RESOURCE_UUID 2
Christopher Ferris05667cd2021-02-16 16:01:34 -080013#define VIRTIO_GPU_F_RESOURCE_BLOB 3
Christopher Ferrisa4792612022-01-10 13:51:15 -080014#define VIRTIO_GPU_F_CONTEXT_INIT 4
Christopher Ferris05d08e92016-02-04 13:16:38 -080015enum virtio_gpu_ctrl_type {
16 VIRTIO_GPU_UNDEFINED = 0,
17 VIRTIO_GPU_CMD_GET_DISPLAY_INFO = 0x0100,
18 VIRTIO_GPU_CMD_RESOURCE_CREATE_2D,
Christopher Ferris05d08e92016-02-04 13:16:38 -080019 VIRTIO_GPU_CMD_RESOURCE_UNREF,
20 VIRTIO_GPU_CMD_SET_SCANOUT,
21 VIRTIO_GPU_CMD_RESOURCE_FLUSH,
22 VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D,
Christopher Ferris05d08e92016-02-04 13:16:38 -080023 VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING,
24 VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING,
25 VIRTIO_GPU_CMD_GET_CAPSET_INFO,
26 VIRTIO_GPU_CMD_GET_CAPSET,
Christopher Ferrisd842e432019-03-07 10:21:59 -080027 VIRTIO_GPU_CMD_GET_EDID,
Christopher Ferris32ff3f82020-12-14 13:10:04 -080028 VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID,
Christopher Ferris05667cd2021-02-16 16:01:34 -080029 VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB,
30 VIRTIO_GPU_CMD_SET_SCANOUT_BLOB,
Christopher Ferris05d08e92016-02-04 13:16:38 -080031 VIRTIO_GPU_CMD_CTX_CREATE = 0x0200,
32 VIRTIO_GPU_CMD_CTX_DESTROY,
33 VIRTIO_GPU_CMD_CTX_ATTACH_RESOURCE,
34 VIRTIO_GPU_CMD_CTX_DETACH_RESOURCE,
Christopher Ferris05d08e92016-02-04 13:16:38 -080035 VIRTIO_GPU_CMD_RESOURCE_CREATE_3D,
36 VIRTIO_GPU_CMD_TRANSFER_TO_HOST_3D,
37 VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D,
38 VIRTIO_GPU_CMD_SUBMIT_3D,
Christopher Ferris05667cd2021-02-16 16:01:34 -080039 VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB,
40 VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB,
Christopher Ferris05d08e92016-02-04 13:16:38 -080041 VIRTIO_GPU_CMD_UPDATE_CURSOR = 0x0300,
42 VIRTIO_GPU_CMD_MOVE_CURSOR,
43 VIRTIO_GPU_RESP_OK_NODATA = 0x1100,
44 VIRTIO_GPU_RESP_OK_DISPLAY_INFO,
Christopher Ferris05d08e92016-02-04 13:16:38 -080045 VIRTIO_GPU_RESP_OK_CAPSET_INFO,
46 VIRTIO_GPU_RESP_OK_CAPSET,
Christopher Ferrisd842e432019-03-07 10:21:59 -080047 VIRTIO_GPU_RESP_OK_EDID,
Christopher Ferris32ff3f82020-12-14 13:10:04 -080048 VIRTIO_GPU_RESP_OK_RESOURCE_UUID,
Christopher Ferris05667cd2021-02-16 16:01:34 -080049 VIRTIO_GPU_RESP_OK_MAP_INFO,
Christopher Ferris05d08e92016-02-04 13:16:38 -080050 VIRTIO_GPU_RESP_ERR_UNSPEC = 0x1200,
51 VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY,
Christopher Ferris05d08e92016-02-04 13:16:38 -080052 VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID,
53 VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID,
54 VIRTIO_GPU_RESP_ERR_INVALID_CONTEXT_ID,
55 VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER,
Christopher Ferris05d08e92016-02-04 13:16:38 -080056};
Christopher Ferris05667cd2021-02-16 16:01:34 -080057enum virtio_gpu_shm_id {
58 VIRTIO_GPU_SHM_ID_UNDEFINED = 0,
59 VIRTIO_GPU_SHM_ID_HOST_VISIBLE = 1
60};
Christopher Ferris05d08e92016-02-04 13:16:38 -080061#define VIRTIO_GPU_FLAG_FENCE (1 << 0)
Christopher Ferrisa4792612022-01-10 13:51:15 -080062#define VIRTIO_GPU_FLAG_INFO_RING_IDX (1 << 1)
Christopher Ferris05d08e92016-02-04 13:16:38 -080063struct virtio_gpu_ctrl_hdr {
64 __le32 type;
Christopher Ferris05d08e92016-02-04 13:16:38 -080065 __le32 flags;
66 __le64 fence_id;
67 __le32 ctx_id;
Christopher Ferrisa4792612022-01-10 13:51:15 -080068 __u8 ring_idx;
69 __u8 padding[3];
Christopher Ferris05d08e92016-02-04 13:16:38 -080070};
71struct virtio_gpu_cursor_pos {
72 __le32 scanout_id;
73 __le32 x;
Christopher Ferris05d08e92016-02-04 13:16:38 -080074 __le32 y;
75 __le32 padding;
76};
77struct virtio_gpu_update_cursor {
Christopher Ferris05d08e92016-02-04 13:16:38 -080078 struct virtio_gpu_ctrl_hdr hdr;
79 struct virtio_gpu_cursor_pos pos;
80 __le32 resource_id;
81 __le32 hot_x;
Christopher Ferris05d08e92016-02-04 13:16:38 -080082 __le32 hot_y;
83 __le32 padding;
84};
85struct virtio_gpu_rect {
Christopher Ferris05d08e92016-02-04 13:16:38 -080086 __le32 x;
87 __le32 y;
88 __le32 width;
89 __le32 height;
Christopher Ferris05d08e92016-02-04 13:16:38 -080090};
91struct virtio_gpu_resource_unref {
92 struct virtio_gpu_ctrl_hdr hdr;
93 __le32 resource_id;
Christopher Ferris05d08e92016-02-04 13:16:38 -080094 __le32 padding;
95};
96struct virtio_gpu_resource_create_2d {
97 struct virtio_gpu_ctrl_hdr hdr;
Christopher Ferris05d08e92016-02-04 13:16:38 -080098 __le32 resource_id;
99 __le32 format;
100 __le32 width;
101 __le32 height;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800102};
103struct virtio_gpu_set_scanout {
104 struct virtio_gpu_ctrl_hdr hdr;
105 struct virtio_gpu_rect r;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800106 __le32 scanout_id;
107 __le32 resource_id;
108};
109struct virtio_gpu_resource_flush {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800110 struct virtio_gpu_ctrl_hdr hdr;
111 struct virtio_gpu_rect r;
112 __le32 resource_id;
113 __le32 padding;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800114};
115struct virtio_gpu_transfer_to_host_2d {
116 struct virtio_gpu_ctrl_hdr hdr;
117 struct virtio_gpu_rect r;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800118 __le64 offset;
119 __le32 resource_id;
120 __le32 padding;
121};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800122struct virtio_gpu_mem_entry {
123 __le64 addr;
124 __le32 length;
125 __le32 padding;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800126};
127struct virtio_gpu_resource_attach_backing {
128 struct virtio_gpu_ctrl_hdr hdr;
129 __le32 resource_id;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800130 __le32 nr_entries;
131};
132struct virtio_gpu_resource_detach_backing {
133 struct virtio_gpu_ctrl_hdr hdr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800134 __le32 resource_id;
135 __le32 padding;
136};
137#define VIRTIO_GPU_MAX_SCANOUTS 16
Christopher Ferris05d08e92016-02-04 13:16:38 -0800138struct virtio_gpu_resp_display_info {
139 struct virtio_gpu_ctrl_hdr hdr;
140 struct virtio_gpu_display_one {
141 struct virtio_gpu_rect r;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800142 __le32 enabled;
143 __le32 flags;
144 } pmodes[VIRTIO_GPU_MAX_SCANOUTS];
145};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800146struct virtio_gpu_box {
147 __le32 x, y, z;
148 __le32 w, h, d;
149};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800150struct virtio_gpu_transfer_host_3d {
151 struct virtio_gpu_ctrl_hdr hdr;
152 struct virtio_gpu_box box;
153 __le64 offset;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800154 __le32 resource_id;
155 __le32 level;
156 __le32 stride;
157 __le32 layer_stride;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800158};
159#define VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP (1 << 0)
160struct virtio_gpu_resource_create_3d {
161 struct virtio_gpu_ctrl_hdr hdr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800162 __le32 resource_id;
163 __le32 target;
164 __le32 format;
165 __le32 bind;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800166 __le32 width;
167 __le32 height;
168 __le32 depth;
169 __le32 array_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800170 __le32 last_level;
171 __le32 nr_samples;
172 __le32 flags;
173 __le32 padding;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800174};
Christopher Ferrisa4792612022-01-10 13:51:15 -0800175#define VIRTIO_GPU_CONTEXT_INIT_CAPSET_ID_MASK 0x000000ff
Christopher Ferris05d08e92016-02-04 13:16:38 -0800176struct virtio_gpu_ctx_create {
177 struct virtio_gpu_ctrl_hdr hdr;
178 __le32 nlen;
Christopher Ferrisa4792612022-01-10 13:51:15 -0800179 __le32 context_init;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800180 char debug_name[64];
181};
182struct virtio_gpu_ctx_destroy {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800183 struct virtio_gpu_ctrl_hdr hdr;
184};
185struct virtio_gpu_ctx_resource {
186 struct virtio_gpu_ctrl_hdr hdr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800187 __le32 resource_id;
188 __le32 padding;
189};
190struct virtio_gpu_cmd_submit {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800191 struct virtio_gpu_ctrl_hdr hdr;
192 __le32 size;
193 __le32 padding;
194};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800195#define VIRTIO_GPU_CAPSET_VIRGL 1
Christopher Ferris9ce28842018-10-25 12:11:39 -0700196#define VIRTIO_GPU_CAPSET_VIRGL2 2
Christopher Ferris39650b72025-07-29 09:30:15 -0700197#define VIRTIO_GPU_CAPSET_GFXSTREAM_VULKAN 3
Christopher Ferris7f4c8372024-06-03 14:22:19 -0700198#define VIRTIO_GPU_CAPSET_VENUS 4
Christopher Ferris39650b72025-07-29 09:30:15 -0700199#define VIRTIO_GPU_CAPSET_CROSS_DOMAIN 5
Christopher Ferris65552ba2024-11-20 17:55:06 +0000200#define VIRTIO_GPU_CAPSET_DRM 6
Christopher Ferris05d08e92016-02-04 13:16:38 -0800201struct virtio_gpu_get_capset_info {
202 struct virtio_gpu_ctrl_hdr hdr;
203 __le32 capset_index;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800204 __le32 padding;
205};
206struct virtio_gpu_resp_capset_info {
207 struct virtio_gpu_ctrl_hdr hdr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800208 __le32 capset_id;
209 __le32 capset_max_version;
210 __le32 capset_max_size;
211 __le32 padding;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800212};
213struct virtio_gpu_get_capset {
214 struct virtio_gpu_ctrl_hdr hdr;
215 __le32 capset_id;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800216 __le32 capset_version;
217};
218struct virtio_gpu_resp_capset {
219 struct virtio_gpu_ctrl_hdr hdr;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700220 __u8 capset_data[];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800221};
Christopher Ferrisd842e432019-03-07 10:21:59 -0800222struct virtio_gpu_cmd_get_edid {
223 struct virtio_gpu_ctrl_hdr hdr;
224 __le32 scanout;
225 __le32 padding;
226};
227struct virtio_gpu_resp_edid {
228 struct virtio_gpu_ctrl_hdr hdr;
229 __le32 size;
230 __le32 padding;
231 __u8 edid[1024];
232};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800233#define VIRTIO_GPU_EVENT_DISPLAY (1 << 0)
234struct virtio_gpu_config {
Christopher Ferris25c18d42020-10-14 17:42:58 -0700235 __le32 events_read;
236 __le32 events_clear;
237 __le32 num_scanouts;
238 __le32 num_capsets;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800239};
240enum virtio_gpu_formats {
241 VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM = 1,
242 VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM = 2,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800243 VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM = 3,
244 VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM = 4,
245 VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM = 67,
246 VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM = 68,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800247 VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM = 121,
248 VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM = 134,
249};
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800250struct virtio_gpu_resource_assign_uuid {
251 struct virtio_gpu_ctrl_hdr hdr;
252 __le32 resource_id;
253 __le32 padding;
254};
255struct virtio_gpu_resp_resource_uuid {
256 struct virtio_gpu_ctrl_hdr hdr;
257 __u8 uuid[16];
258};
Christopher Ferris05667cd2021-02-16 16:01:34 -0800259struct virtio_gpu_resource_create_blob {
260 struct virtio_gpu_ctrl_hdr hdr;
261 __le32 resource_id;
262#define VIRTIO_GPU_BLOB_MEM_GUEST 0x0001
263#define VIRTIO_GPU_BLOB_MEM_HOST3D 0x0002
264#define VIRTIO_GPU_BLOB_MEM_HOST3D_GUEST 0x0003
265#define VIRTIO_GPU_BLOB_FLAG_USE_MAPPABLE 0x0001
266#define VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE 0x0002
267#define VIRTIO_GPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004
268 __le32 blob_mem;
269 __le32 blob_flags;
270 __le32 nr_entries;
271 __le64 blob_id;
272 __le64 size;
273};
274struct virtio_gpu_set_scanout_blob {
275 struct virtio_gpu_ctrl_hdr hdr;
276 struct virtio_gpu_rect r;
277 __le32 scanout_id;
278 __le32 resource_id;
279 __le32 width;
280 __le32 height;
281 __le32 format;
282 __le32 padding;
283 __le32 strides[4];
284 __le32 offsets[4];
285};
286struct virtio_gpu_resource_map_blob {
287 struct virtio_gpu_ctrl_hdr hdr;
288 __le32 resource_id;
289 __le32 padding;
290 __le64 offset;
291};
292#define VIRTIO_GPU_MAP_CACHE_MASK 0x0f
293#define VIRTIO_GPU_MAP_CACHE_NONE 0x00
294#define VIRTIO_GPU_MAP_CACHE_CACHED 0x01
295#define VIRTIO_GPU_MAP_CACHE_UNCACHED 0x02
296#define VIRTIO_GPU_MAP_CACHE_WC 0x03
297struct virtio_gpu_resp_map_info {
298 struct virtio_gpu_ctrl_hdr hdr;
299 __u32 map_info;
300 __u32 padding;
301};
302struct virtio_gpu_resource_unmap_blob {
303 struct virtio_gpu_ctrl_hdr hdr;
304 __le32 resource_id;
305 __le32 padding;
306};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800307#endif