blob: 71622268d9d7a3cf3bdf70e450b769a14902e507 [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 Ferris05d08e92016-02-04 13:16:38 -0800197struct virtio_gpu_get_capset_info {
198 struct virtio_gpu_ctrl_hdr hdr;
199 __le32 capset_index;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800200 __le32 padding;
201};
202struct virtio_gpu_resp_capset_info {
203 struct virtio_gpu_ctrl_hdr hdr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800204 __le32 capset_id;
205 __le32 capset_max_version;
206 __le32 capset_max_size;
207 __le32 padding;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800208};
209struct virtio_gpu_get_capset {
210 struct virtio_gpu_ctrl_hdr hdr;
211 __le32 capset_id;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800212 __le32 capset_version;
213};
214struct virtio_gpu_resp_capset {
215 struct virtio_gpu_ctrl_hdr hdr;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700216 __u8 capset_data[];
Christopher Ferris05d08e92016-02-04 13:16:38 -0800217};
Christopher Ferrisd842e432019-03-07 10:21:59 -0800218struct virtio_gpu_cmd_get_edid {
219 struct virtio_gpu_ctrl_hdr hdr;
220 __le32 scanout;
221 __le32 padding;
222};
223struct virtio_gpu_resp_edid {
224 struct virtio_gpu_ctrl_hdr hdr;
225 __le32 size;
226 __le32 padding;
227 __u8 edid[1024];
228};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800229#define VIRTIO_GPU_EVENT_DISPLAY (1 << 0)
230struct virtio_gpu_config {
Christopher Ferris25c18d42020-10-14 17:42:58 -0700231 __le32 events_read;
232 __le32 events_clear;
233 __le32 num_scanouts;
234 __le32 num_capsets;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800235};
236enum virtio_gpu_formats {
237 VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM = 1,
238 VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM = 2,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800239 VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM = 3,
240 VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM = 4,
241 VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM = 67,
242 VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM = 68,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800243 VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM = 121,
244 VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM = 134,
245};
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800246struct virtio_gpu_resource_assign_uuid {
247 struct virtio_gpu_ctrl_hdr hdr;
248 __le32 resource_id;
249 __le32 padding;
250};
251struct virtio_gpu_resp_resource_uuid {
252 struct virtio_gpu_ctrl_hdr hdr;
253 __u8 uuid[16];
254};
Christopher Ferris05667cd2021-02-16 16:01:34 -0800255struct virtio_gpu_resource_create_blob {
256 struct virtio_gpu_ctrl_hdr hdr;
257 __le32 resource_id;
258#define VIRTIO_GPU_BLOB_MEM_GUEST 0x0001
259#define VIRTIO_GPU_BLOB_MEM_HOST3D 0x0002
260#define VIRTIO_GPU_BLOB_MEM_HOST3D_GUEST 0x0003
261#define VIRTIO_GPU_BLOB_FLAG_USE_MAPPABLE 0x0001
262#define VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE 0x0002
263#define VIRTIO_GPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004
264 __le32 blob_mem;
265 __le32 blob_flags;
266 __le32 nr_entries;
267 __le64 blob_id;
268 __le64 size;
269};
270struct virtio_gpu_set_scanout_blob {
271 struct virtio_gpu_ctrl_hdr hdr;
272 struct virtio_gpu_rect r;
273 __le32 scanout_id;
274 __le32 resource_id;
275 __le32 width;
276 __le32 height;
277 __le32 format;
278 __le32 padding;
279 __le32 strides[4];
280 __le32 offsets[4];
281};
282struct virtio_gpu_resource_map_blob {
283 struct virtio_gpu_ctrl_hdr hdr;
284 __le32 resource_id;
285 __le32 padding;
286 __le64 offset;
287};
288#define VIRTIO_GPU_MAP_CACHE_MASK 0x0f
289#define VIRTIO_GPU_MAP_CACHE_NONE 0x00
290#define VIRTIO_GPU_MAP_CACHE_CACHED 0x01
291#define VIRTIO_GPU_MAP_CACHE_UNCACHED 0x02
292#define VIRTIO_GPU_MAP_CACHE_WC 0x03
293struct virtio_gpu_resp_map_info {
294 struct virtio_gpu_ctrl_hdr hdr;
295 __u32 map_info;
296 __u32 padding;
297};
298struct virtio_gpu_resource_unmap_blob {
299 struct virtio_gpu_ctrl_hdr hdr;
300 __le32 resource_id;
301 __le32 padding;
302};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800303#endif