]> git.proxmox.com Git - qemu.git/blob - hw/qxl.h
qxl: make qxl_render_update async
[qemu.git] / hw / qxl.h
1 #include "qemu-common.h"
2
3 #include "console.h"
4 #include "hw.h"
5 #include "pci.h"
6 #include "vga_int.h"
7 #include "qemu-thread.h"
8
9 #include "ui/qemu-spice.h"
10 #include "ui/spice-display.h"
11
12 enum qxl_mode {
13 QXL_MODE_UNDEFINED,
14 QXL_MODE_VGA,
15 QXL_MODE_COMPAT, /* spice 0.4.x */
16 QXL_MODE_NATIVE,
17 };
18
19 #define QXL_UNDEFINED_IO UINT32_MAX
20
21 #define QXL_NUM_DIRTY_RECTS 64
22
23 typedef struct PCIQXLDevice {
24 PCIDevice pci;
25 SimpleSpiceDisplay ssd;
26 int id;
27 uint32_t debug;
28 uint32_t guestdebug;
29 uint32_t cmdlog;
30 enum qxl_mode mode;
31 uint32_t cmdflags;
32 int generation;
33 uint32_t revision;
34
35 int32_t num_memslots;
36 int32_t num_surfaces;
37
38 uint32_t current_async;
39 QemuMutex async_lock;
40
41 struct guest_slots {
42 QXLMemSlot slot;
43 void *ptr;
44 uint64_t size;
45 uint64_t delta;
46 uint32_t active;
47 } guest_slots[NUM_MEMSLOTS];
48
49 struct guest_primary {
50 QXLSurfaceCreate surface;
51 uint32_t commands;
52 uint32_t resized;
53 int32_t qxl_stride;
54 uint32_t abs_stride;
55 uint32_t bits_pp;
56 uint32_t bytes_pp;
57 uint8_t *data;
58 } guest_primary;
59
60 struct surfaces {
61 QXLPHYSICAL cmds[NUM_SURFACES];
62 uint32_t count;
63 uint32_t max;
64 } guest_surfaces;
65 QXLPHYSICAL guest_cursor;
66
67 QemuMutex track_lock;
68
69 /* thread signaling */
70 QemuThread main;
71 int pipe[2];
72
73 /* ram pci bar */
74 QXLRam *ram;
75 VGACommonState vga;
76 uint32_t num_free_res;
77 QXLReleaseInfo *last_release;
78 uint32_t last_release_offset;
79 uint32_t oom_running;
80
81 /* rom pci bar */
82 QXLRom shadow_rom;
83 QXLRom *rom;
84 QXLModes *modes;
85 uint32_t rom_size;
86 MemoryRegion rom_bar;
87
88 /* vram pci bar */
89 uint32_t vram_size;
90 MemoryRegion vram_bar;
91
92 /* io bar */
93 MemoryRegion io_bar;
94
95 /* user-friendly properties (in megabytes) */
96 uint32_t ram_size_mb;
97 uint32_t vram_size_mb;
98
99 /* qxl_render_update state */
100 int render_update_cookie_num;
101 int num_dirty_rects;
102 QXLRect dirty[QXL_NUM_DIRTY_RECTS];
103 QEMUBH *update_area_bh;
104 } PCIQXLDevice;
105
106 #define PANIC_ON(x) if ((x)) { \
107 printf("%s: PANIC %s failed\n", __FUNCTION__, #x); \
108 abort(); \
109 }
110
111 #define dprint(_qxl, _level, _fmt, ...) \
112 do { \
113 if (_qxl->debug >= _level) { \
114 fprintf(stderr, "qxl-%d: ", _qxl->id); \
115 fprintf(stderr, _fmt, ## __VA_ARGS__); \
116 } \
117 } while (0)
118
119 #define QXL_DEFAULT_REVISION QXL_REVISION_STABLE_V10
120
121 /* qxl.c */
122 void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL phys, int group_id);
123 void qxl_guest_bug(PCIQXLDevice *qxl, const char *msg, ...);
124
125 void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id,
126 struct QXLRect *area, struct QXLRect *dirty_rects,
127 uint32_t num_dirty_rects,
128 uint32_t clear_dirty_region,
129 qxl_async_io async, QXLCookie *cookie);
130 void qxl_spice_loadvm_commands(PCIQXLDevice *qxl, struct QXLCommandExt *ext,
131 uint32_t count);
132 void qxl_spice_oom(PCIQXLDevice *qxl);
133 void qxl_spice_reset_memslots(PCIQXLDevice *qxl);
134 void qxl_spice_reset_image_cache(PCIQXLDevice *qxl);
135 void qxl_spice_reset_cursor(PCIQXLDevice *qxl);
136
137 /* qxl-logger.c */
138 void qxl_log_cmd_cursor(PCIQXLDevice *qxl, QXLCursorCmd *cmd, int group_id);
139 void qxl_log_command(PCIQXLDevice *qxl, const char *ring, QXLCommandExt *ext);
140
141 /* qxl-render.c */
142 void qxl_render_resize(PCIQXLDevice *qxl);
143 void qxl_render_update(PCIQXLDevice *qxl);
144 void qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext);
145 void qxl_render_update_area_done(PCIQXLDevice *qxl, QXLCookie *cookie);
146 void qxl_render_update_area_bh(void *opaque);