xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/qxl/qxl_dev.h (revision 8ecbf5f02b752fcb7debe1a8fab1dc82602bc760)
1 /*	$NetBSD: qxl_dev.h,v 1.2 2018/08/27 04:58:35 riastradh Exp $	*/
2 
3 /*
4    Copyright (C) 2009 Red Hat, Inc.
5 
6    Redistribution and use in source and binary forms, with or without
7    modification, are permitted provided that the following conditions are
8    met:
9 
10        * Redistributions of source code must retain the above copyright
11 	 notice, this list of conditions and the following disclaimer.
12        * Redistributions in binary form must reproduce the above copyright
13 	 notice, this list of conditions and the following disclaimer in
14 	 the documentation and/or other materials provided with the
15 	 distribution.
16        * Neither the name of the copyright holder nor the names of its
17 	 contributors may be used to endorse or promote products derived
18 	 from this software without specific prior written permission.
19 
20    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
21    IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22    TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24    HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 
33 
34 #ifndef H_QXL_DEV
35 #define H_QXL_DEV
36 
37 #include <linux/types.h>
38 
39 /*
40  * from spice-protocol
41  * Release 0.10.0
42  */
43 
44 /* enums.h */
45 
46 enum SpiceImageType {
47 	SPICE_IMAGE_TYPE_BITMAP,
48 	SPICE_IMAGE_TYPE_QUIC,
49 	SPICE_IMAGE_TYPE_RESERVED,
50 	SPICE_IMAGE_TYPE_LZ_PLT = 100,
51 	SPICE_IMAGE_TYPE_LZ_RGB,
52 	SPICE_IMAGE_TYPE_GLZ_RGB,
53 	SPICE_IMAGE_TYPE_FROM_CACHE,
54 	SPICE_IMAGE_TYPE_SURFACE,
55 	SPICE_IMAGE_TYPE_JPEG,
56 	SPICE_IMAGE_TYPE_FROM_CACHE_LOSSLESS,
57 	SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB,
58 	SPICE_IMAGE_TYPE_JPEG_ALPHA,
59 
60 	SPICE_IMAGE_TYPE_ENUM_END
61 };
62 
63 enum SpiceBitmapFmt {
64 	SPICE_BITMAP_FMT_INVALID,
65 	SPICE_BITMAP_FMT_1BIT_LE,
66 	SPICE_BITMAP_FMT_1BIT_BE,
67 	SPICE_BITMAP_FMT_4BIT_LE,
68 	SPICE_BITMAP_FMT_4BIT_BE,
69 	SPICE_BITMAP_FMT_8BIT,
70 	SPICE_BITMAP_FMT_16BIT,
71 	SPICE_BITMAP_FMT_24BIT,
72 	SPICE_BITMAP_FMT_32BIT,
73 	SPICE_BITMAP_FMT_RGBA,
74 
75 	SPICE_BITMAP_FMT_ENUM_END
76 };
77 
78 enum SpiceSurfaceFmt {
79 	SPICE_SURFACE_FMT_INVALID,
80 	SPICE_SURFACE_FMT_1_A,
81 	SPICE_SURFACE_FMT_8_A = 8,
82 	SPICE_SURFACE_FMT_16_555 = 16,
83 	SPICE_SURFACE_FMT_32_xRGB = 32,
84 	SPICE_SURFACE_FMT_16_565 = 80,
85 	SPICE_SURFACE_FMT_32_ARGB = 96,
86 
87 	SPICE_SURFACE_FMT_ENUM_END
88 };
89 
90 enum SpiceClipType {
91 	SPICE_CLIP_TYPE_NONE,
92 	SPICE_CLIP_TYPE_RECTS,
93 
94 	SPICE_CLIP_TYPE_ENUM_END
95 };
96 
97 enum SpiceRopd {
98 	SPICE_ROPD_INVERS_SRC = (1 << 0),
99 	SPICE_ROPD_INVERS_BRUSH = (1 << 1),
100 	SPICE_ROPD_INVERS_DEST = (1 << 2),
101 	SPICE_ROPD_OP_PUT = (1 << 3),
102 	SPICE_ROPD_OP_OR = (1 << 4),
103 	SPICE_ROPD_OP_AND = (1 << 5),
104 	SPICE_ROPD_OP_XOR = (1 << 6),
105 	SPICE_ROPD_OP_BLACKNESS = (1 << 7),
106 	SPICE_ROPD_OP_WHITENESS = (1 << 8),
107 	SPICE_ROPD_OP_INVERS = (1 << 9),
108 	SPICE_ROPD_INVERS_RES = (1 << 10),
109 
110 	SPICE_ROPD_MASK = 0x7ff
111 };
112 
113 enum SpiceBrushType {
114 	SPICE_BRUSH_TYPE_NONE,
115 	SPICE_BRUSH_TYPE_SOLID,
116 	SPICE_BRUSH_TYPE_PATTERN,
117 
118 	SPICE_BRUSH_TYPE_ENUM_END
119 };
120 
121 enum SpiceCursorType {
122 	SPICE_CURSOR_TYPE_ALPHA,
123 	SPICE_CURSOR_TYPE_MONO,
124 	SPICE_CURSOR_TYPE_COLOR4,
125 	SPICE_CURSOR_TYPE_COLOR8,
126 	SPICE_CURSOR_TYPE_COLOR16,
127 	SPICE_CURSOR_TYPE_COLOR24,
128 	SPICE_CURSOR_TYPE_COLOR32,
129 
130 	SPICE_CURSOR_TYPE_ENUM_END
131 };
132 
133 /* qxl_dev.h */
134 
135 #pragma pack(push, 1)
136 
137 #define REDHAT_PCI_VENDOR_ID 0x1b36
138 
139 /* 0x100-0x11f reserved for spice, 0x1ff used for unstable work */
140 #define QXL_DEVICE_ID_STABLE 0x0100
141 
142 enum {
143 	QXL_REVISION_STABLE_V04 = 0x01,
144 	QXL_REVISION_STABLE_V06 = 0x02,
145 	QXL_REVISION_STABLE_V10 = 0x03,
146 	QXL_REVISION_STABLE_V12 = 0x04,
147 };
148 
149 #define QXL_DEVICE_ID_DEVEL 0x01ff
150 #define QXL_REVISION_DEVEL 0x01
151 
152 #define QXL_ROM_MAGIC (*(uint32_t *)"QXRO")
153 #define QXL_RAM_MAGIC (*(uint32_t *)"QXRA")
154 
155 enum {
156 	QXL_RAM_RANGE_INDEX,
157 	QXL_VRAM_RANGE_INDEX,
158 	QXL_ROM_RANGE_INDEX,
159 	QXL_IO_RANGE_INDEX,
160 
161 	QXL_PCI_RANGES
162 };
163 
164 /* qxl-1 compat: append only */
165 enum {
166 	QXL_IO_NOTIFY_CMD,
167 	QXL_IO_NOTIFY_CURSOR,
168 	QXL_IO_UPDATE_AREA,
169 	QXL_IO_UPDATE_IRQ,
170 	QXL_IO_NOTIFY_OOM,
171 	QXL_IO_RESET,
172 	QXL_IO_SET_MODE,                  /* qxl-1 */
173 	QXL_IO_LOG,
174 	/* appended for qxl-2 */
175 	QXL_IO_MEMSLOT_ADD,
176 	QXL_IO_MEMSLOT_DEL,
177 	QXL_IO_DETACH_PRIMARY,
178 	QXL_IO_ATTACH_PRIMARY,
179 	QXL_IO_CREATE_PRIMARY,
180 	QXL_IO_DESTROY_PRIMARY,
181 	QXL_IO_DESTROY_SURFACE_WAIT,
182 	QXL_IO_DESTROY_ALL_SURFACES,
183 	/* appended for qxl-3 */
184 	QXL_IO_UPDATE_AREA_ASYNC,
185 	QXL_IO_MEMSLOT_ADD_ASYNC,
186 	QXL_IO_CREATE_PRIMARY_ASYNC,
187 	QXL_IO_DESTROY_PRIMARY_ASYNC,
188 	QXL_IO_DESTROY_SURFACE_ASYNC,
189 	QXL_IO_DESTROY_ALL_SURFACES_ASYNC,
190 	QXL_IO_FLUSH_SURFACES_ASYNC,
191 	QXL_IO_FLUSH_RELEASE,
192 	/* appended for qxl-4 */
193 	QXL_IO_MONITORS_CONFIG_ASYNC,
194 
195 	QXL_IO_RANGE_SIZE
196 };
197 
198 typedef uint64_t QXLPHYSICAL;
199 typedef int32_t QXLFIXED; /* fixed 28.4 */
200 
201 struct qxl_point_fix {
202 	QXLFIXED x;
203 	QXLFIXED y;
204 };
205 
206 struct qxl_point {
207 	int32_t x;
208 	int32_t y;
209 };
210 
211 struct qxl_point_1_6 {
212 	int16_t x;
213 	int16_t y;
214 };
215 
216 struct qxl_rect {
217 	int32_t top;
218 	int32_t left;
219 	int32_t bottom;
220 	int32_t right;
221 };
222 
223 struct qxl_urect {
224 	uint32_t top;
225 	uint32_t left;
226 	uint32_t bottom;
227 	uint32_t right;
228 };
229 
230 /* qxl-1 compat: append only */
231 struct qxl_rom {
232 	uint32_t magic;
233 	uint32_t id;
234 	uint32_t update_id;
235 	uint32_t compression_level;
236 	uint32_t log_level;
237 	uint32_t mode;			  /* qxl-1 */
238 	uint32_t modes_offset;
239 	uint32_t num_io_pages;
240 	uint32_t pages_offset;		  /* qxl-1 */
241 	uint32_t draw_area_offset;	  /* qxl-1 */
242 	uint32_t surface0_area_size;	  /* qxl-1 name: draw_area_size */
243 	uint32_t ram_header_offset;
244 	uint32_t mm_clock;
245 	/* appended for qxl-2 */
246 	uint32_t n_surfaces;
247 	uint64_t flags;
248 	uint8_t slots_start;
249 	uint8_t slots_end;
250 	uint8_t slot_gen_bits;
251 	uint8_t slot_id_bits;
252 	uint8_t slot_generation;
253 	/* appended for qxl-4 */
254 	uint8_t client_present;
255 	uint8_t client_capabilities[58];
256 	uint32_t client_monitors_config_crc;
257 	struct {
258 		uint16_t count;
259 	uint16_t padding;
260 		struct qxl_urect heads[64];
261 	} client_monitors_config;
262 };
263 
264 /* qxl-1 compat: fixed */
265 struct qxl_mode {
266 	uint32_t id;
267 	uint32_t x_res;
268 	uint32_t y_res;
269 	uint32_t bits;
270 	uint32_t stride;
271 	uint32_t x_mili;
272 	uint32_t y_mili;
273 	uint32_t orientation;
274 };
275 
276 /* qxl-1 compat: fixed */
277 struct qxl_modes {
278 	uint32_t n_modes;
279 	struct qxl_mode modes[0];
280 };
281 
282 /* qxl-1 compat: append only */
283 enum qxl_cmd_type {
284 	QXL_CMD_NOP,
285 	QXL_CMD_DRAW,
286 	QXL_CMD_UPDATE,
287 	QXL_CMD_CURSOR,
288 	QXL_CMD_MESSAGE,
289 	QXL_CMD_SURFACE,
290 };
291 
292 /* qxl-1 compat: fixed */
293 struct qxl_command {
294 	QXLPHYSICAL data;
295 	uint32_t type;
296 	uint32_t padding;
297 };
298 
299 #define QXL_COMMAND_FLAG_COMPAT		(1<<0)
300 #define QXL_COMMAND_FLAG_COMPAT_16BPP	(2<<0)
301 
302 struct qxl_command_ext {
303 	struct qxl_command cmd;
304 	uint32_t group_id;
305 	uint32_t flags;
306 };
307 
308 struct qxl_mem_slot {
309 	uint64_t mem_start;
310 	uint64_t mem_end;
311 };
312 
313 #define QXL_SURF_TYPE_PRIMARY	   0
314 
315 #define QXL_SURF_FLAG_KEEP_DATA	   (1 << 0)
316 
317 struct qxl_surface_create {
318 	uint32_t width;
319 	uint32_t height;
320 	int32_t stride;
321 	uint32_t format;
322 	uint32_t position;
323 	uint32_t mouse_mode;
324 	uint32_t flags;
325 	uint32_t type;
326 	QXLPHYSICAL mem;
327 };
328 
329 #define QXL_COMMAND_RING_SIZE 32
330 #define QXL_CURSOR_RING_SIZE 32
331 #define QXL_RELEASE_RING_SIZE 8
332 
333 #define QXL_LOG_BUF_SIZE 4096
334 
335 #define QXL_INTERRUPT_DISPLAY (1 << 0)
336 #define QXL_INTERRUPT_CURSOR (1 << 1)
337 #define QXL_INTERRUPT_IO_CMD (1 << 2)
338 #define QXL_INTERRUPT_ERROR  (1 << 3)
339 #define QXL_INTERRUPT_CLIENT (1 << 4)
340 #define QXL_INTERRUPT_CLIENT_MONITORS_CONFIG  (1 << 5)
341 
342 struct qxl_ring_header {
343 	uint32_t num_items;
344 	uint32_t prod;
345 	uint32_t notify_on_prod;
346 	uint32_t cons;
347 	uint32_t notify_on_cons;
348 };
349 
350 /* qxl-1 compat: append only */
351 struct qxl_ram_header {
352 	uint32_t magic;
353 	uint32_t int_pending;
354 	uint32_t int_mask;
355 	uint8_t log_buf[QXL_LOG_BUF_SIZE];
356 	struct qxl_ring_header  cmd_ring_hdr;
357 	struct qxl_command	cmd_ring[QXL_COMMAND_RING_SIZE];
358 	struct qxl_ring_header  cursor_ring_hdr;
359 	struct qxl_command	cursor_ring[QXL_CURSOR_RING_SIZE];
360 	struct qxl_ring_header  release_ring_hdr;
361 	uint64_t		release_ring[QXL_RELEASE_RING_SIZE];
362 	struct qxl_rect update_area;
363 	/* appended for qxl-2 */
364 	uint32_t update_surface;
365 	struct qxl_mem_slot mem_slot;
366 	struct qxl_surface_create create_surface;
367 	uint64_t flags;
368 
369 	/* appended for qxl-4 */
370 
371 	/* used by QXL_IO_MONITORS_CONFIG_ASYNC */
372 	QXLPHYSICAL monitors_config;
373 	uint8_t guest_capabilities[64];
374 };
375 
376 union qxl_release_info {
377 	uint64_t id;	  /* in  */
378 	uint64_t next;	  /* out */
379 };
380 
381 struct qxl_release_info_ext {
382 	union qxl_release_info *info;
383 	uint32_t group_id;
384 };
385 
386 struct qxl_data_chunk {
387 	uint32_t data_size;
388 	QXLPHYSICAL prev_chunk;
389 	QXLPHYSICAL next_chunk;
390 	uint8_t data[0];
391 };
392 
393 struct qxl_message {
394 	union qxl_release_info release_info;
395 	uint8_t data[0];
396 };
397 
398 struct qxl_compat_update_cmd {
399 	union qxl_release_info release_info;
400 	struct qxl_rect area;
401 	uint32_t update_id;
402 };
403 
404 struct qxl_update_cmd {
405 	union qxl_release_info release_info;
406 	struct qxl_rect area;
407 	uint32_t update_id;
408 	uint32_t surface_id;
409 };
410 
411 struct qxl_cursor_header {
412 	uint64_t unique;
413 	uint16_t type;
414 	uint16_t width;
415 	uint16_t height;
416 	uint16_t hot_spot_x;
417 	uint16_t hot_spot_y;
418 };
419 
420 struct qxl_cursor {
421 	struct qxl_cursor_header header;
422 	uint32_t data_size;
423 	struct qxl_data_chunk chunk;
424 };
425 
426 enum {
427 	QXL_CURSOR_SET,
428 	QXL_CURSOR_MOVE,
429 	QXL_CURSOR_HIDE,
430 	QXL_CURSOR_TRAIL,
431 };
432 
433 #define QXL_CURSOR_DEVICE_DATA_SIZE 128
434 
435 struct qxl_cursor_cmd {
436 	union qxl_release_info release_info;
437 	uint8_t type;
438 	union {
439 		struct {
440 			struct qxl_point_1_6 position;
441 			uint8_t visible;
442 			QXLPHYSICAL shape;
443 		} set;
444 		struct {
445 			uint16_t length;
446 			uint16_t frequency;
447 		} trail;
448 		struct qxl_point_1_6 position;
449 	} u;
450 	/* todo: dynamic size from rom */
451 	uint8_t device_data[QXL_CURSOR_DEVICE_DATA_SIZE];
452 };
453 
454 enum {
455 	QXL_DRAW_NOP,
456 	QXL_DRAW_FILL,
457 	QXL_DRAW_OPAQUE,
458 	QXL_DRAW_COPY,
459 	QXL_COPY_BITS,
460 	QXL_DRAW_BLEND,
461 	QXL_DRAW_BLACKNESS,
462 	QXL_DRAW_WHITENESS,
463 	QXL_DRAW_INVERS,
464 	QXL_DRAW_ROP3,
465 	QXL_DRAW_STROKE,
466 	QXL_DRAW_TEXT,
467 	QXL_DRAW_TRANSPARENT,
468 	QXL_DRAW_ALPHA_BLEND,
469 	QXL_DRAW_COMPOSITE
470 };
471 
472 struct qxl_raster_glyph {
473 	struct qxl_point render_pos;
474 	struct qxl_point glyph_origin;
475 	uint16_t width;
476 	uint16_t height;
477 	uint8_t data[0];
478 };
479 
480 struct qxl_string {
481 	uint32_t data_size;
482 	uint16_t length;
483 	uint16_t flags;
484 	struct qxl_data_chunk chunk;
485 };
486 
487 struct qxl_copy_bits {
488 	struct qxl_point src_pos;
489 };
490 
491 enum qxl_effect_type {
492 	QXL_EFFECT_BLEND = 0,
493 	QXL_EFFECT_OPAQUE = 1,
494 	QXL_EFFECT_REVERT_ON_DUP = 2,
495 	QXL_EFFECT_BLACKNESS_ON_DUP = 3,
496 	QXL_EFFECT_WHITENESS_ON_DUP = 4,
497 	QXL_EFFECT_NOP_ON_DUP = 5,
498 	QXL_EFFECT_NOP = 6,
499 	QXL_EFFECT_OPAQUE_BRUSH = 7
500 };
501 
502 struct qxl_pattern {
503 	QXLPHYSICAL pat;
504 	struct qxl_point pos;
505 };
506 
507 struct qxl_brush {
508 	uint32_t type;
509 	union {
510 		uint32_t color;
511 		struct qxl_pattern pattern;
512 	} u;
513 };
514 
515 struct qxl_q_mask {
516 	uint8_t flags;
517 	struct qxl_point pos;
518 	QXLPHYSICAL bitmap;
519 };
520 
521 struct qxl_fill {
522 	struct qxl_brush brush;
523 	uint16_t rop_descriptor;
524 	struct qxl_q_mask mask;
525 };
526 
527 struct qxl_opaque {
528 	QXLPHYSICAL src_bitmap;
529 	struct qxl_rect src_area;
530 	struct qxl_brush brush;
531 	uint16_t rop_descriptor;
532 	uint8_t scale_mode;
533 	struct qxl_q_mask mask;
534 };
535 
536 struct qxl_copy {
537 	QXLPHYSICAL src_bitmap;
538 	struct qxl_rect src_area;
539 	uint16_t rop_descriptor;
540 	uint8_t scale_mode;
541 	struct qxl_q_mask mask;
542 };
543 
544 struct qxl_transparent {
545 	QXLPHYSICAL src_bitmap;
546 	struct qxl_rect src_area;
547 	uint32_t src_color;
548 	uint32_t true_color;
549 };
550 
551 struct qxl_alpha_blend {
552 	uint16_t alpha_flags;
553 	uint8_t alpha;
554 	QXLPHYSICAL src_bitmap;
555 	struct qxl_rect src_area;
556 };
557 
558 struct qxl_compat_alpha_blend {
559 	uint8_t alpha;
560 	QXLPHYSICAL src_bitmap;
561 	struct qxl_rect src_area;
562 };
563 
564 struct qxl_rop_3 {
565 	QXLPHYSICAL src_bitmap;
566 	struct qxl_rect src_area;
567 	struct qxl_brush brush;
568 	uint8_t rop3;
569 	uint8_t scale_mode;
570 	struct qxl_q_mask mask;
571 };
572 
573 struct qxl_line_attr {
574 	uint8_t flags;
575 	uint8_t join_style;
576 	uint8_t end_style;
577 	uint8_t style_nseg;
578 	QXLFIXED width;
579 	QXLFIXED miter_limit;
580 	QXLPHYSICAL style;
581 };
582 
583 struct qxl_stroke {
584 	QXLPHYSICAL path;
585 	struct qxl_line_attr attr;
586 	struct qxl_brush brush;
587 	uint16_t fore_mode;
588 	uint16_t back_mode;
589 };
590 
591 struct qxl_text {
592 	QXLPHYSICAL str;
593 	struct qxl_rect back_area;
594 	struct qxl_brush fore_brush;
595 	struct qxl_brush back_brush;
596 	uint16_t fore_mode;
597 	uint16_t back_mode;
598 };
599 
600 struct qxl_mask {
601 	struct qxl_q_mask mask;
602 };
603 
604 struct qxl_clip {
605 	uint32_t type;
606 	QXLPHYSICAL data;
607 };
608 
609 enum qxl_operator {
610 	QXL_OP_CLEAR			 = 0x00,
611 	QXL_OP_SOURCE			 = 0x01,
612 	QXL_OP_DST			 = 0x02,
613 	QXL_OP_OVER			 = 0x03,
614 	QXL_OP_OVER_REVERSE		 = 0x04,
615 	QXL_OP_IN			 = 0x05,
616 	QXL_OP_IN_REVERSE		 = 0x06,
617 	QXL_OP_OUT			 = 0x07,
618 	QXL_OP_OUT_REVERSE		 = 0x08,
619 	QXL_OP_ATOP			 = 0x09,
620 	QXL_OP_ATOP_REVERSE		 = 0x0a,
621 	QXL_OP_XOR			 = 0x0b,
622 	QXL_OP_ADD			 = 0x0c,
623 	QXL_OP_SATURATE			 = 0x0d,
624 	/* Note the jump here from 0x0d to 0x30 */
625 	QXL_OP_MULTIPLY			 = 0x30,
626 	QXL_OP_SCREEN			 = 0x31,
627 	QXL_OP_OVERLAY			 = 0x32,
628 	QXL_OP_DARKEN			 = 0x33,
629 	QXL_OP_LIGHTEN			 = 0x34,
630 	QXL_OP_COLOR_DODGE		 = 0x35,
631 	QXL_OP_COLOR_BURN		 = 0x36,
632 	QXL_OP_HARD_LIGHT		 = 0x37,
633 	QXL_OP_SOFT_LIGHT		 = 0x38,
634 	QXL_OP_DIFFERENCE		 = 0x39,
635 	QXL_OP_EXCLUSION		 = 0x3a,
636 	QXL_OP_HSL_HUE			 = 0x3b,
637 	QXL_OP_HSL_SATURATION		 = 0x3c,
638 	QXL_OP_HSL_COLOR		 = 0x3d,
639 	QXL_OP_HSL_LUMINOSITY		 = 0x3e
640 };
641 
642 struct qxl_transform {
643 	uint32_t	t00;
644 	uint32_t	t01;
645 	uint32_t	t02;
646 	uint32_t	t10;
647 	uint32_t	t11;
648 	uint32_t	t12;
649 };
650 
651 /* The flags field has the following bit fields:
652  *
653  *     operator:		[  0 -  7 ]
654  *     src_filter:		[  8 - 10 ]
655  *     mask_filter:		[ 11 - 13 ]
656  *     src_repeat:		[ 14 - 15 ]
657  *     mask_repeat:		[ 16 - 17 ]
658  *     component_alpha:		[ 18 - 18 ]
659  *     reserved:		[ 19 - 31 ]
660  *
661  * The repeat and filter values are those of pixman:
662  *		REPEAT_NONE =		0
663  *              REPEAT_NORMAL =		1
664  *		REPEAT_PAD =		2
665  *		REPEAT_REFLECT =	3
666  *
667  * The filter values are:
668  *		FILTER_NEAREST =	0
669  *		FILTER_BILINEAR	=	1
670  */
671 struct qxl_composite {
672 	uint32_t		flags;
673 
674 	QXLPHYSICAL			src;
675 	QXLPHYSICAL			src_transform;	/* May be NULL */
676 	QXLPHYSICAL			mask;		/* May be NULL */
677 	QXLPHYSICAL			mask_transform;	/* May be NULL */
678 	struct qxl_point_1_6	src_origin;
679 	struct qxl_point_1_6	mask_origin;
680 };
681 
682 struct qxl_compat_drawable {
683 	union qxl_release_info release_info;
684 	uint8_t effect;
685 	uint8_t type;
686 	uint16_t bitmap_offset;
687 	struct qxl_rect bitmap_area;
688 	struct qxl_rect bbox;
689 	struct qxl_clip clip;
690 	uint32_t mm_time;
691 	union {
692 		struct qxl_fill fill;
693 		struct qxl_opaque opaque;
694 		struct qxl_copy copy;
695 		struct qxl_transparent transparent;
696 		struct qxl_compat_alpha_blend alpha_blend;
697 		struct qxl_copy_bits copy_bits;
698 		struct qxl_copy blend;
699 		struct qxl_rop_3 rop3;
700 		struct qxl_stroke stroke;
701 		struct qxl_text text;
702 		struct qxl_mask blackness;
703 		struct qxl_mask invers;
704 		struct qxl_mask whiteness;
705 	} u;
706 };
707 
708 struct qxl_drawable {
709 	union qxl_release_info release_info;
710 	uint32_t surface_id;
711 	uint8_t effect;
712 	uint8_t type;
713 	uint8_t self_bitmap;
714 	struct qxl_rect self_bitmap_area;
715 	struct qxl_rect bbox;
716 	struct qxl_clip clip;
717 	uint32_t mm_time;
718 	int32_t surfaces_dest[3];
719 	struct qxl_rect surfaces_rects[3];
720 	union {
721 		struct qxl_fill fill;
722 		struct qxl_opaque opaque;
723 		struct qxl_copy copy;
724 		struct qxl_transparent transparent;
725 		struct qxl_alpha_blend alpha_blend;
726 		struct qxl_copy_bits copy_bits;
727 		struct qxl_copy blend;
728 		struct qxl_rop_3 rop3;
729 		struct qxl_stroke stroke;
730 		struct qxl_text text;
731 		struct qxl_mask blackness;
732 		struct qxl_mask invers;
733 		struct qxl_mask whiteness;
734 		struct qxl_composite composite;
735 	} u;
736 };
737 
738 enum qxl_surface_cmd_type {
739 	QXL_SURFACE_CMD_CREATE,
740 	QXL_SURFACE_CMD_DESTROY,
741 };
742 
743 struct qxl_surface {
744 	uint32_t format;
745 	uint32_t width;
746 	uint32_t height;
747 	int32_t stride;
748 	QXLPHYSICAL data;
749 };
750 
751 struct qxl_surface_cmd {
752 	union qxl_release_info release_info;
753 	uint32_t surface_id;
754 	uint8_t type;
755 	uint32_t flags;
756 	union {
757 		struct qxl_surface surface_create;
758 	} u;
759 };
760 
761 struct qxl_clip_rects {
762 	uint32_t num_rects;
763 	struct qxl_data_chunk chunk;
764 };
765 
766 enum {
767 	QXL_PATH_BEGIN = (1 << 0),
768 	QXL_PATH_END = (1 << 1),
769 	QXL_PATH_CLOSE = (1 << 3),
770 	QXL_PATH_BEZIER = (1 << 4),
771 };
772 
773 struct qxl_path_seg {
774 	uint32_t flags;
775 	uint32_t count;
776 	struct qxl_point_fix points[0];
777 };
778 
779 struct qxl_path {
780 	uint32_t data_size;
781 	struct qxl_data_chunk chunk;
782 };
783 
784 enum {
785 	QXL_IMAGE_GROUP_DRIVER,
786 	QXL_IMAGE_GROUP_DEVICE,
787 	QXL_IMAGE_GROUP_RED,
788 	QXL_IMAGE_GROUP_DRIVER_DONT_CACHE,
789 };
790 
791 struct qxl_image_id {
792 	uint32_t group;
793 	uint32_t unique;
794 };
795 
796 union qxl_image_id_union {
797 	struct qxl_image_id id;
798 	uint64_t value;
799 };
800 
801 enum qxl_image_flags {
802 	QXL_IMAGE_CACHE = (1 << 0),
803 	QXL_IMAGE_HIGH_BITS_SET = (1 << 1),
804 };
805 
806 enum qxl_bitmap_flags {
807 	QXL_BITMAP_DIRECT = (1 << 0),
808 	QXL_BITMAP_UNSTABLE = (1 << 1),
809 	QXL_BITMAP_TOP_DOWN = (1 << 2), /* == SPICE_BITMAP_FLAGS_TOP_DOWN */
810 };
811 
812 #define QXL_SET_IMAGE_ID(image, _group, _unique) {              \
813 	(image)->descriptor.id = (((uint64_t)_unique) << 32) | _group;	\
814 }
815 
816 struct qxl_image_descriptor {
817 	uint64_t id;
818 	uint8_t type;
819 	uint8_t flags;
820 	uint32_t width;
821 	uint32_t height;
822 };
823 
824 struct qxl_palette {
825 	uint64_t unique;
826 	uint16_t num_ents;
827 	uint32_t ents[0];
828 };
829 
830 struct qxl_bitmap {
831 	uint8_t format;
832 	uint8_t flags;
833 	uint32_t x;
834 	uint32_t y;
835 	uint32_t stride;
836 	QXLPHYSICAL palette;
837 	QXLPHYSICAL data; /* data[0] ? */
838 };
839 
840 struct qxl_surface_id {
841 	uint32_t surface_id;
842 };
843 
844 struct qxl_encoder_data {
845 	uint32_t data_size;
846 	uint8_t data[0];
847 };
848 
849 struct qxl_image {
850 	struct qxl_image_descriptor descriptor;
851 	union { /* variable length */
852 		struct qxl_bitmap bitmap;
853 		struct qxl_encoder_data quic;
854 		struct qxl_surface_id surface_image;
855 	} u;
856 };
857 
858 /* A QXLHead is a single monitor output backed by a QXLSurface.
859  * x and y offsets are unsigned since they are used in relation to
860  * the given surface, not the same as the x, y coordinates in the guest
861  * screen reference frame. */
862 struct qxl_head {
863 	uint32_t id;
864 	uint32_t surface_id;
865 	uint32_t width;
866 	uint32_t height;
867 	uint32_t x;
868 	uint32_t y;
869 	uint32_t flags;
870 };
871 
872 struct qxl_monitors_config {
873 	uint16_t count;
874 	uint16_t max_allowed; /* If it is 0 no fixed limit is given by the
875 				 driver */
876 	struct qxl_head heads[0];
877 };
878 
879 #pragma pack(pop)
880 
881 #endif /* _H_QXL_DEV */
882