2 Copyright (C) 2009 Red Hat, Inc.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in
12 the documentation and/or other materials provided with the
14 * Neither the name of the copyright holder nor the names of its
15 contributors may be used to endorse or promote products derived
16 from this software without specific prior written permission.
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
19 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include <linux/types.h>
45 SPICE_IMAGE_TYPE_BITMAP
,
46 SPICE_IMAGE_TYPE_QUIC
,
47 SPICE_IMAGE_TYPE_RESERVED
,
48 SPICE_IMAGE_TYPE_LZ_PLT
= 100,
49 SPICE_IMAGE_TYPE_LZ_RGB
,
50 SPICE_IMAGE_TYPE_GLZ_RGB
,
51 SPICE_IMAGE_TYPE_FROM_CACHE
,
52 SPICE_IMAGE_TYPE_SURFACE
,
53 SPICE_IMAGE_TYPE_JPEG
,
54 SPICE_IMAGE_TYPE_FROM_CACHE_LOSSLESS
,
55 SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB
,
56 SPICE_IMAGE_TYPE_JPEG_ALPHA
,
58 SPICE_IMAGE_TYPE_ENUM_END
62 SPICE_BITMAP_FMT_INVALID
,
63 SPICE_BITMAP_FMT_1BIT_LE
,
64 SPICE_BITMAP_FMT_1BIT_BE
,
65 SPICE_BITMAP_FMT_4BIT_LE
,
66 SPICE_BITMAP_FMT_4BIT_BE
,
67 SPICE_BITMAP_FMT_8BIT
,
68 SPICE_BITMAP_FMT_16BIT
,
69 SPICE_BITMAP_FMT_24BIT
,
70 SPICE_BITMAP_FMT_32BIT
,
71 SPICE_BITMAP_FMT_RGBA
,
73 SPICE_BITMAP_FMT_ENUM_END
76 enum SpiceSurfaceFmt
{
77 SPICE_SURFACE_FMT_INVALID
,
78 SPICE_SURFACE_FMT_1_A
,
79 SPICE_SURFACE_FMT_8_A
= 8,
80 SPICE_SURFACE_FMT_16_555
= 16,
81 SPICE_SURFACE_FMT_32_xRGB
= 32,
82 SPICE_SURFACE_FMT_16_565
= 80,
83 SPICE_SURFACE_FMT_32_ARGB
= 96,
85 SPICE_SURFACE_FMT_ENUM_END
90 SPICE_CLIP_TYPE_RECTS
,
92 SPICE_CLIP_TYPE_ENUM_END
96 SPICE_ROPD_INVERS_SRC
= (1 << 0),
97 SPICE_ROPD_INVERS_BRUSH
= (1 << 1),
98 SPICE_ROPD_INVERS_DEST
= (1 << 2),
99 SPICE_ROPD_OP_PUT
= (1 << 3),
100 SPICE_ROPD_OP_OR
= (1 << 4),
101 SPICE_ROPD_OP_AND
= (1 << 5),
102 SPICE_ROPD_OP_XOR
= (1 << 6),
103 SPICE_ROPD_OP_BLACKNESS
= (1 << 7),
104 SPICE_ROPD_OP_WHITENESS
= (1 << 8),
105 SPICE_ROPD_OP_INVERS
= (1 << 9),
106 SPICE_ROPD_INVERS_RES
= (1 << 10),
108 SPICE_ROPD_MASK
= 0x7ff
111 enum SpiceBrushType
{
112 SPICE_BRUSH_TYPE_NONE
,
113 SPICE_BRUSH_TYPE_SOLID
,
114 SPICE_BRUSH_TYPE_PATTERN
,
116 SPICE_BRUSH_TYPE_ENUM_END
119 enum SpiceCursorType
{
120 SPICE_CURSOR_TYPE_ALPHA
,
121 SPICE_CURSOR_TYPE_MONO
,
122 SPICE_CURSOR_TYPE_COLOR4
,
123 SPICE_CURSOR_TYPE_COLOR8
,
124 SPICE_CURSOR_TYPE_COLOR16
,
125 SPICE_CURSOR_TYPE_COLOR24
,
126 SPICE_CURSOR_TYPE_COLOR32
,
128 SPICE_CURSOR_TYPE_ENUM_END
133 #pragma pack(push, 1)
135 #define REDHAT_PCI_VENDOR_ID 0x1b36
137 /* 0x100-0x11f reserved for spice, 0x1ff used for unstable work */
138 #define QXL_DEVICE_ID_STABLE 0x0100
141 QXL_REVISION_STABLE_V04
= 0x01,
142 QXL_REVISION_STABLE_V06
= 0x02,
143 QXL_REVISION_STABLE_V10
= 0x03,
144 QXL_REVISION_STABLE_V12
= 0x04,
147 #define QXL_DEVICE_ID_DEVEL 0x01ff
148 #define QXL_REVISION_DEVEL 0x01
150 #define QXL_ROM_MAGIC (*(uint32_t *)"QXRO")
151 #define QXL_RAM_MAGIC (*(uint32_t *)"QXRA")
155 QXL_VRAM_RANGE_INDEX
,
162 /* qxl-1 compat: append only */
165 QXL_IO_NOTIFY_CURSOR
,
170 QXL_IO_SET_MODE
, /* qxl-1 */
172 /* appended for qxl-2 */
175 QXL_IO_DETACH_PRIMARY
,
176 QXL_IO_ATTACH_PRIMARY
,
177 QXL_IO_CREATE_PRIMARY
,
178 QXL_IO_DESTROY_PRIMARY
,
179 QXL_IO_DESTROY_SURFACE_WAIT
,
180 QXL_IO_DESTROY_ALL_SURFACES
,
181 /* appended for qxl-3 */
182 QXL_IO_UPDATE_AREA_ASYNC
,
183 QXL_IO_MEMSLOT_ADD_ASYNC
,
184 QXL_IO_CREATE_PRIMARY_ASYNC
,
185 QXL_IO_DESTROY_PRIMARY_ASYNC
,
186 QXL_IO_DESTROY_SURFACE_ASYNC
,
187 QXL_IO_DESTROY_ALL_SURFACES_ASYNC
,
188 QXL_IO_FLUSH_SURFACES_ASYNC
,
189 QXL_IO_FLUSH_RELEASE
,
190 /* appended for qxl-4 */
191 QXL_IO_MONITORS_CONFIG_ASYNC
,
196 typedef uint64_t QXLPHYSICAL
;
197 typedef int32_t QXLFIXED
; /* fixed 28.4 */
199 struct qxl_point_fix
{
209 struct qxl_point_1_6
{
228 /* qxl-1 compat: append only */
233 uint32_t compression_level
;
235 uint32_t mode
; /* qxl-1 */
236 uint32_t modes_offset
;
237 uint32_t num_io_pages
;
238 uint32_t pages_offset
; /* qxl-1 */
239 uint32_t draw_area_offset
; /* qxl-1 */
240 uint32_t surface0_area_size
; /* qxl-1 name: draw_area_size */
241 uint32_t ram_header_offset
;
243 /* appended for qxl-2 */
248 uint8_t slot_gen_bits
;
249 uint8_t slot_id_bits
;
250 uint8_t slot_generation
;
251 /* appended for qxl-4 */
252 uint8_t client_present
;
253 uint8_t client_capabilities
[58];
254 uint32_t client_monitors_config_crc
;
258 struct qxl_urect heads
[64];
259 } client_monitors_config
;
262 /* qxl-1 compat: fixed */
271 uint32_t orientation
;
274 /* qxl-1 compat: fixed */
277 struct qxl_mode modes
[0];
280 /* qxl-1 compat: append only */
290 /* qxl-1 compat: fixed */
297 #define QXL_COMMAND_FLAG_COMPAT (1<<0)
298 #define QXL_COMMAND_FLAG_COMPAT_16BPP (2<<0)
300 struct qxl_command_ext
{
301 struct qxl_command cmd
;
306 struct qxl_mem_slot
{
311 #define QXL_SURF_TYPE_PRIMARY 0
313 #define QXL_SURF_FLAG_KEEP_DATA (1 << 0)
315 struct qxl_surface_create
{
327 #define QXL_COMMAND_RING_SIZE 32
328 #define QXL_CURSOR_RING_SIZE 32
329 #define QXL_RELEASE_RING_SIZE 8
331 #define QXL_LOG_BUF_SIZE 4096
333 #define QXL_INTERRUPT_DISPLAY (1 << 0)
334 #define QXL_INTERRUPT_CURSOR (1 << 1)
335 #define QXL_INTERRUPT_IO_CMD (1 << 2)
336 #define QXL_INTERRUPT_ERROR (1 << 3)
337 #define QXL_INTERRUPT_CLIENT (1 << 4)
338 #define QXL_INTERRUPT_CLIENT_MONITORS_CONFIG (1 << 5)
340 struct qxl_ring_header
{
343 uint32_t notify_on_prod
;
345 uint32_t notify_on_cons
;
348 /* qxl-1 compat: append only */
349 struct qxl_ram_header
{
351 uint32_t int_pending
;
353 uint8_t log_buf
[QXL_LOG_BUF_SIZE
];
354 struct qxl_ring_header cmd_ring_hdr
;
355 struct qxl_command cmd_ring
[QXL_COMMAND_RING_SIZE
];
356 struct qxl_ring_header cursor_ring_hdr
;
357 struct qxl_command cursor_ring
[QXL_CURSOR_RING_SIZE
];
358 struct qxl_ring_header release_ring_hdr
;
359 uint64_t release_ring
[QXL_RELEASE_RING_SIZE
];
360 struct qxl_rect update_area
;
361 /* appended for qxl-2 */
362 uint32_t update_surface
;
363 struct qxl_mem_slot mem_slot
;
364 struct qxl_surface_create create_surface
;
367 /* appended for qxl-4 */
369 /* used by QXL_IO_MONITORS_CONFIG_ASYNC */
370 QXLPHYSICAL monitors_config
;
371 uint8_t guest_capabilities
[64];
374 union qxl_release_info
{
375 uint64_t id
; /* in */
376 uint64_t next
; /* out */
379 struct qxl_release_info_ext
{
380 union qxl_release_info
*info
;
384 struct qxl_data_chunk
{
386 QXLPHYSICAL prev_chunk
;
387 QXLPHYSICAL next_chunk
;
392 union qxl_release_info release_info
;
396 struct qxl_compat_update_cmd
{
397 union qxl_release_info release_info
;
398 struct qxl_rect area
;
402 struct qxl_update_cmd
{
403 union qxl_release_info release_info
;
404 struct qxl_rect area
;
409 struct qxl_cursor_header
{
419 struct qxl_cursor_header header
;
421 struct qxl_data_chunk chunk
;
431 #define QXL_CURSOR_DEVICE_DATA_SIZE 128
433 struct qxl_cursor_cmd
{
434 union qxl_release_info release_info
;
438 struct qxl_point_1_6 position
;
446 struct qxl_point_1_6 position
;
448 /* todo: dynamic size from rom */
449 uint8_t device_data
[QXL_CURSOR_DEVICE_DATA_SIZE
];
465 QXL_DRAW_TRANSPARENT
,
466 QXL_DRAW_ALPHA_BLEND
,
470 struct qxl_raster_glyph
{
471 struct qxl_point render_pos
;
472 struct qxl_point glyph_origin
;
482 struct qxl_data_chunk chunk
;
485 struct qxl_copy_bits
{
486 struct qxl_point src_pos
;
489 enum qxl_effect_type
{
490 QXL_EFFECT_BLEND
= 0,
491 QXL_EFFECT_OPAQUE
= 1,
492 QXL_EFFECT_REVERT_ON_DUP
= 2,
493 QXL_EFFECT_BLACKNESS_ON_DUP
= 3,
494 QXL_EFFECT_WHITENESS_ON_DUP
= 4,
495 QXL_EFFECT_NOP_ON_DUP
= 5,
497 QXL_EFFECT_OPAQUE_BRUSH
= 7
502 struct qxl_point pos
;
509 struct qxl_pattern pattern
;
515 struct qxl_point pos
;
520 struct qxl_brush brush
;
521 uint16_t rop_descriptor
;
522 struct qxl_q_mask mask
;
526 QXLPHYSICAL src_bitmap
;
527 struct qxl_rect src_area
;
528 struct qxl_brush brush
;
529 uint16_t rop_descriptor
;
531 struct qxl_q_mask mask
;
535 QXLPHYSICAL src_bitmap
;
536 struct qxl_rect src_area
;
537 uint16_t rop_descriptor
;
539 struct qxl_q_mask mask
;
542 struct qxl_transparent
{
543 QXLPHYSICAL src_bitmap
;
544 struct qxl_rect src_area
;
549 struct qxl_alpha_blend
{
550 uint16_t alpha_flags
;
552 QXLPHYSICAL src_bitmap
;
553 struct qxl_rect src_area
;
556 struct qxl_compat_alpha_blend
{
558 QXLPHYSICAL src_bitmap
;
559 struct qxl_rect src_area
;
563 QXLPHYSICAL src_bitmap
;
564 struct qxl_rect src_area
;
565 struct qxl_brush brush
;
568 struct qxl_q_mask mask
;
571 struct qxl_line_attr
{
577 QXLFIXED miter_limit
;
583 struct qxl_line_attr attr
;
584 struct qxl_brush brush
;
591 struct qxl_rect back_area
;
592 struct qxl_brush fore_brush
;
593 struct qxl_brush back_brush
;
599 struct qxl_q_mask mask
;
609 QXL_OP_SOURCE
= 0x01,
612 QXL_OP_OVER_REVERSE
= 0x04,
614 QXL_OP_IN_REVERSE
= 0x06,
616 QXL_OP_OUT_REVERSE
= 0x08,
618 QXL_OP_ATOP_REVERSE
= 0x0a,
621 QXL_OP_SATURATE
= 0x0d,
622 /* Note the jump here from 0x0d to 0x30 */
623 QXL_OP_MULTIPLY
= 0x30,
624 QXL_OP_SCREEN
= 0x31,
625 QXL_OP_OVERLAY
= 0x32,
626 QXL_OP_DARKEN
= 0x33,
627 QXL_OP_LIGHTEN
= 0x34,
628 QXL_OP_COLOR_DODGE
= 0x35,
629 QXL_OP_COLOR_BURN
= 0x36,
630 QXL_OP_HARD_LIGHT
= 0x37,
631 QXL_OP_SOFT_LIGHT
= 0x38,
632 QXL_OP_DIFFERENCE
= 0x39,
633 QXL_OP_EXCLUSION
= 0x3a,
634 QXL_OP_HSL_HUE
= 0x3b,
635 QXL_OP_HSL_SATURATION
= 0x3c,
636 QXL_OP_HSL_COLOR
= 0x3d,
637 QXL_OP_HSL_LUMINOSITY
= 0x3e
640 struct qxl_transform
{
649 /* The flags field has the following bit fields:
651 * operator: [ 0 - 7 ]
652 * src_filter: [ 8 - 10 ]
653 * mask_filter: [ 11 - 13 ]
654 * src_repeat: [ 14 - 15 ]
655 * mask_repeat: [ 16 - 17 ]
656 * component_alpha: [ 18 - 18 ]
657 * reserved: [ 19 - 31 ]
659 * The repeat and filter values are those of pixman:
665 * The filter values are:
667 * FILTER_BILINEAR = 1
669 struct qxl_composite
{
673 QXLPHYSICAL src_transform
; /* May be NULL */
674 QXLPHYSICAL mask
; /* May be NULL */
675 QXLPHYSICAL mask_transform
; /* May be NULL */
676 struct qxl_point_1_6 src_origin
;
677 struct qxl_point_1_6 mask_origin
;
680 struct qxl_compat_drawable
{
681 union qxl_release_info release_info
;
684 uint16_t bitmap_offset
;
685 struct qxl_rect bitmap_area
;
686 struct qxl_rect bbox
;
687 struct qxl_clip clip
;
690 struct qxl_fill fill
;
691 struct qxl_opaque opaque
;
692 struct qxl_copy copy
;
693 struct qxl_transparent transparent
;
694 struct qxl_compat_alpha_blend alpha_blend
;
695 struct qxl_copy_bits copy_bits
;
696 struct qxl_copy blend
;
697 struct qxl_rop_3 rop3
;
698 struct qxl_stroke stroke
;
699 struct qxl_text text
;
700 struct qxl_mask blackness
;
701 struct qxl_mask invers
;
702 struct qxl_mask whiteness
;
706 struct qxl_drawable
{
707 union qxl_release_info release_info
;
712 struct qxl_rect self_bitmap_area
;
713 struct qxl_rect bbox
;
714 struct qxl_clip clip
;
716 int32_t surfaces_dest
[3];
717 struct qxl_rect surfaces_rects
[3];
719 struct qxl_fill fill
;
720 struct qxl_opaque opaque
;
721 struct qxl_copy copy
;
722 struct qxl_transparent transparent
;
723 struct qxl_alpha_blend alpha_blend
;
724 struct qxl_copy_bits copy_bits
;
725 struct qxl_copy blend
;
726 struct qxl_rop_3 rop3
;
727 struct qxl_stroke stroke
;
728 struct qxl_text text
;
729 struct qxl_mask blackness
;
730 struct qxl_mask invers
;
731 struct qxl_mask whiteness
;
732 struct qxl_composite composite
;
736 enum qxl_surface_cmd_type
{
737 QXL_SURFACE_CMD_CREATE
,
738 QXL_SURFACE_CMD_DESTROY
,
749 struct qxl_surface_cmd
{
750 union qxl_release_info release_info
;
755 struct qxl_surface surface_create
;
759 struct qxl_clip_rects
{
761 struct qxl_data_chunk chunk
;
765 QXL_PATH_BEGIN
= (1 << 0),
766 QXL_PATH_END
= (1 << 1),
767 QXL_PATH_CLOSE
= (1 << 3),
768 QXL_PATH_BEZIER
= (1 << 4),
771 struct qxl_path_seg
{
774 struct qxl_point_fix points
[0];
779 struct qxl_data_chunk chunk
;
783 QXL_IMAGE_GROUP_DRIVER
,
784 QXL_IMAGE_GROUP_DEVICE
,
786 QXL_IMAGE_GROUP_DRIVER_DONT_CACHE
,
789 struct qxl_image_id
{
794 union qxl_image_id_union
{
795 struct qxl_image_id id
;
799 enum qxl_image_flags
{
800 QXL_IMAGE_CACHE
= (1 << 0),
801 QXL_IMAGE_HIGH_BITS_SET
= (1 << 1),
804 enum qxl_bitmap_flags
{
805 QXL_BITMAP_DIRECT
= (1 << 0),
806 QXL_BITMAP_UNSTABLE
= (1 << 1),
807 QXL_BITMAP_TOP_DOWN
= (1 << 2), /* == SPICE_BITMAP_FLAGS_TOP_DOWN */
810 #define QXL_SET_IMAGE_ID(image, _group, _unique) { \
811 (image)->descriptor.id = (((uint64_t)_unique) << 32) | _group; \
814 struct qxl_image_descriptor
{
835 QXLPHYSICAL data
; /* data[0] ? */
838 struct qxl_surface_id
{
842 struct qxl_encoder_data
{
848 struct qxl_image_descriptor descriptor
;
849 union { /* variable length */
850 struct qxl_bitmap bitmap
;
851 struct qxl_encoder_data quic
;
852 struct qxl_surface_id surface_image
;
856 /* A QXLHead is a single monitor output backed by a QXLSurface.
857 * x and y offsets are unsigned since they are used in relation to
858 * the given surface, not the same as the x, y coordinates in the guest
859 * screen reference frame. */
870 struct qxl_monitors_config
{
872 uint16_t max_allowed
; /* If it is 0 no fixed limit is given by the
874 struct qxl_head heads
[0];
879 #endif /* _H_QXL_DEV */