blob: d5a88d93e8e7b9b3d0d106b79dd1d043d96deb5c [file] [log] [blame]
pbrook87ecb682007-11-17 17:14:51 +00001#ifndef CONSOLE_H
2#define CONSOLE_H
3
Paolo Bonzini28ecbae2012-11-28 12:06:30 +01004#include "ui/qemu-pixman.h"
Gerd Hoffmann95be0662013-04-17 09:45:10 +02005#include "qom/object.h"
Paolo Bonzini7b1b5d12012-12-17 18:19:43 +01006#include "qapi/qmp/qdict.h"
Paolo Bonzini1de7afc2012-12-17 18:20:00 +01007#include "qemu/notify.h"
Amos Kong1048c882012-08-31 10:56:25 +08008#include "qapi-types.h"
pbrook87ecb682007-11-17 17:14:51 +00009
Gerd Hoffmanncd2bc882015-01-09 11:40:23 +010010#ifdef CONFIG_OPENGL
Gerd Hoffmanndcf30022015-05-11 12:24:43 +020011# include <epoxy/gl.h>
Gerd Hoffmanncd2bc882015-01-09 11:40:23 +010012#endif
13
pbrook87ecb682007-11-17 17:14:51 +000014/* keyboard/mouse support */
15
16#define MOUSE_EVENT_LBUTTON 0x01
17#define MOUSE_EVENT_RBUTTON 0x02
18#define MOUSE_EVENT_MBUTTON 0x04
Gerd Hoffmann21bae112013-12-04 14:08:04 +010019#define MOUSE_EVENT_WHEELUP 0x08
20#define MOUSE_EVENT_WHEELDN 0x10
pbrook87ecb682007-11-17 17:14:51 +000021
Gerd Hoffmann03a23a82010-02-26 17:17:36 +010022/* identical to the ps/2 keyboard bits */
23#define QEMU_SCROLL_LOCK_LED (1 << 0)
24#define QEMU_NUM_LOCK_LED (1 << 1)
25#define QEMU_CAPS_LOCK_LED (1 << 2)
26
aliguori7ed9eba2008-08-21 20:12:05 +000027/* in ms */
Gerd Hoffmann0f7b2862013-03-14 11:56:16 +010028#define GUI_REFRESH_INTERVAL_DEFAULT 30
29#define GUI_REFRESH_INTERVAL_IDLE 3000
aliguori7ed9eba2008-08-21 20:12:05 +000030
OGAWA Hirofumi40837332015-11-29 22:28:24 +090031/* Color number is match to standard vga palette */
32enum qemu_color_names {
33 QEMU_COLOR_BLACK = 0,
34 QEMU_COLOR_BLUE = 1,
35 QEMU_COLOR_GREEN = 2,
36 QEMU_COLOR_CYAN = 3,
37 QEMU_COLOR_RED = 4,
38 QEMU_COLOR_MAGENTA = 5,
39 QEMU_COLOR_YELLOW = 6,
40 QEMU_COLOR_WHITE = 7
41};
42/* Convert to curses char attributes */
43#define ATTR2CHTYPE(c, fg, bg, bold) \
44 ((bold) << 21 | (bg) << 11 | (fg) << 8 | (c))
45
pbrook87ecb682007-11-17 17:14:51 +000046typedef void QEMUPutKBDEvent(void *opaque, int keycode);
Gerd Hoffmann03a23a82010-02-26 17:17:36 +010047typedef void QEMUPutLEDEvent(void *opaque, int ledstate);
pbrook87ecb682007-11-17 17:14:51 +000048typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
49
Gerd Hoffmann72711ef2013-04-24 12:08:37 +020050typedef struct QEMUPutMouseEntry QEMUPutMouseEntry;
Gerd Hoffmann5a375322013-04-24 12:08:38 +020051typedef struct QEMUPutKbdEntry QEMUPutKbdEntry;
Gerd Hoffmann72711ef2013-04-24 12:08:37 +020052typedef struct QEMUPutLEDEntry QEMUPutLEDEntry;
Gerd Hoffmann03a23a82010-02-26 17:17:36 +010053
Gerd Hoffmann5a375322013-04-24 12:08:38 +020054QEMUPutKbdEntry *qemu_add_kbd_event_handler(QEMUPutKBDEvent *func,
55 void *opaque);
pbrook87ecb682007-11-17 17:14:51 +000056QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
57 void *opaque, int absolute,
58 const char *name);
59void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry);
Anthony Liguori6fef28e2010-03-09 20:52:22 -060060void qemu_activate_mouse_event_handler(QEMUPutMouseEntry *entry);
61
Gerd Hoffmann03a23a82010-02-26 17:17:36 +010062QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, void *opaque);
63void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry);
pbrook87ecb682007-11-17 17:14:51 +000064
Gerd Hoffmann03a23a82010-02-26 17:17:36 +010065void kbd_put_ledstate(int ledstate);
Anthony Liguorieb2e2592010-03-09 14:26:40 -060066
Paul Brookbc24a222009-05-10 01:44:56 +010067struct MouseTransformInfo {
balroga5d7eb62008-04-14 21:28:11 +000068 /* Touchscreen resolution */
69 int x;
70 int y;
71 /* Calibration values as used/generated by tslib */
72 int a[7];
73};
74
Markus Armbruster3e5a50d2015-02-06 13:55:43 +010075void hmp_mouse_set(Monitor *mon, const QDict *qdict);
pbrook87ecb682007-11-17 17:14:51 +000076
77/* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
78 constants) */
79#define QEMU_KEY_ESC1(c) ((c) | 0xe100)
80#define QEMU_KEY_BACKSPACE 0x007f
81#define QEMU_KEY_UP QEMU_KEY_ESC1('A')
82#define QEMU_KEY_DOWN QEMU_KEY_ESC1('B')
83#define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C')
84#define QEMU_KEY_LEFT QEMU_KEY_ESC1('D')
85#define QEMU_KEY_HOME QEMU_KEY_ESC1(1)
86#define QEMU_KEY_END QEMU_KEY_ESC1(4)
87#define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5)
88#define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6)
89#define QEMU_KEY_DELETE QEMU_KEY_ESC1(3)
90
91#define QEMU_KEY_CTRL_UP 0xe400
92#define QEMU_KEY_CTRL_DOWN 0xe401
93#define QEMU_KEY_CTRL_LEFT 0xe402
94#define QEMU_KEY_CTRL_RIGHT 0xe403
95#define QEMU_KEY_CTRL_HOME 0xe404
96#define QEMU_KEY_CTRL_END 0xe405
97#define QEMU_KEY_CTRL_PAGEUP 0xe406
98#define QEMU_KEY_CTRL_PAGEDOWN 0xe407
99
Gerd Hoffmann3f9a6e82014-05-22 12:05:52 +0200100void kbd_put_keysym_console(QemuConsole *s, int keysym);
Gerd Hoffmann50ef4672014-05-27 09:28:38 +0200101bool kbd_put_qcode_console(QemuConsole *s, int qcode);
Gerd Hoffmannbdef9722014-05-27 09:32:36 +0200102void kbd_put_string_console(QemuConsole *s, const char *str, int len);
pbrook87ecb682007-11-17 17:14:51 +0000103void kbd_put_keysym(int keysym);
104
105/* consoles */
106
Gerd Hoffmann95be0662013-04-17 09:45:10 +0200107#define TYPE_QEMU_CONSOLE "qemu-console"
108#define QEMU_CONSOLE(obj) \
109 OBJECT_CHECK(QemuConsole, (obj), TYPE_QEMU_CONSOLE)
110#define QEMU_CONSOLE_GET_CLASS(obj) \
111 OBJECT_GET_CLASS(QemuConsoleClass, (obj), TYPE_QEMU_CONSOLE)
112#define QEMU_CONSOLE_CLASS(klass) \
113 OBJECT_CLASS_CHECK(QemuConsoleClass, (klass), TYPE_QEMU_CONSOLE)
114
115typedef struct QemuConsoleClass QemuConsoleClass;
116
117struct QemuConsoleClass {
118 ObjectClass parent_class;
119};
120
Benjamin Herrenschmidt77bfcf22014-06-21 14:58:06 +1000121#define QEMU_ALLOCATED_FLAG 0x01
aliguori7d957bd2009-01-15 22:14:11 +0000122
123struct PixelFormat {
124 uint8_t bits_per_pixel;
125 uint8_t bytes_per_pixel;
126 uint8_t depth; /* color depth in bits */
127 uint32_t rmask, gmask, bmask, amask;
128 uint8_t rshift, gshift, bshift, ashift;
129 uint8_t rmax, gmax, bmax, amax;
aliguori90a1e3c2009-01-26 15:37:30 +0000130 uint8_t rbits, gbits, bbits, abits;
aliguori7d957bd2009-01-15 22:14:11 +0000131};
132
133struct DisplaySurface {
Gerd Hoffmann69c77772012-09-26 15:20:05 +0200134 pixman_format_code_t format;
135 pixman_image_t *image;
aliguori7d957bd2009-01-15 22:14:11 +0000136 uint8_t flags;
Gerd Hoffmanncd2bc882015-01-09 11:40:23 +0100137#ifdef CONFIG_OPENGL
138 GLenum glformat;
139 GLenum gltype;
140 GLuint texture;
141#endif
aliguori7d957bd2009-01-15 22:14:11 +0000142};
143
Gerd Hoffmann6f90f3d2014-01-24 17:38:20 +0100144typedef struct QemuUIInfo {
145 /* geometry */
146 int xoff;
147 int yoff;
148 uint32_t width;
149 uint32_t height;
150} QemuUIInfo;
151
Gerd Hoffmann254e5952010-05-21 11:54:32 +0200152/* cursor data format is 32bit RGBA */
153typedef struct QEMUCursor {
154 int width, height;
155 int hot_x, hot_y;
156 int refcount;
157 uint32_t data[];
158} QEMUCursor;
159
160QEMUCursor *cursor_alloc(int width, int height);
161void cursor_get(QEMUCursor *c);
162void cursor_put(QEMUCursor *c);
163QEMUCursor *cursor_builtin_hidden(void);
164QEMUCursor *cursor_builtin_left_ptr(void);
165void cursor_print_ascii_art(QEMUCursor *c, const char *prefix);
166int cursor_get_mono_bpl(QEMUCursor *c);
167void cursor_set_mono(QEMUCursor *c,
168 uint32_t foreground, uint32_t background, uint8_t *image,
169 int transparent, uint8_t *mask);
170void cursor_get_mono_image(QEMUCursor *c, int foreground, uint8_t *mask);
171void cursor_get_mono_mask(QEMUCursor *c, int transparent, uint8_t *mask);
172
Gerd Hoffmann06020b92014-07-11 13:56:51 +0200173typedef void *QEMUGLContext;
174typedef struct QEMUGLParams QEMUGLParams;
175
176struct QEMUGLParams {
177 int major_ver;
178 int minor_ver;
179};
180
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100181typedef struct DisplayChangeListenerOps {
182 const char *dpy_name;
183
Gerd Hoffmannbc2ed972013-03-01 13:03:04 +0100184 void (*dpy_refresh)(DisplayChangeListener *dcl);
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100185
186 void (*dpy_gfx_update)(DisplayChangeListener *dcl,
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100187 int x, int y, int w, int h);
Gerd Hoffmannc12aeb82013-02-28 15:03:04 +0100188 void (*dpy_gfx_switch)(DisplayChangeListener *dcl,
Gerd Hoffmannc12aeb82013-02-28 15:03:04 +0100189 struct DisplaySurface *new_surface);
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100190 void (*dpy_gfx_copy)(DisplayChangeListener *dcl,
Gerd Hoffmannbc2ed972013-03-01 13:03:04 +0100191 int src_x, int src_y,
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100192 int dst_x, int dst_y, int w, int h);
Benjamin Herrenschmidt49743df2014-07-07 16:39:05 +1000193 bool (*dpy_gfx_check_format)(DisplayChangeListener *dcl,
194 pixman_format_code_t format);
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100195
196 void (*dpy_text_cursor)(DisplayChangeListener *dcl,
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100197 int x, int y);
198 void (*dpy_text_resize)(DisplayChangeListener *dcl,
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100199 int w, int h);
200 void (*dpy_text_update)(DisplayChangeListener *dcl,
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100201 int x, int y, int w, int h);
202
203 void (*dpy_mouse_set)(DisplayChangeListener *dcl,
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100204 int x, int y, int on);
205 void (*dpy_cursor_define)(DisplayChangeListener *dcl,
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100206 QEMUCursor *cursor);
Gerd Hoffmann06020b92014-07-11 13:56:51 +0200207
208 QEMUGLContext (*dpy_gl_ctx_create)(DisplayChangeListener *dcl,
209 QEMUGLParams *params);
210 void (*dpy_gl_ctx_destroy)(DisplayChangeListener *dcl,
211 QEMUGLContext ctx);
212 int (*dpy_gl_ctx_make_current)(DisplayChangeListener *dcl,
213 QEMUGLContext ctx);
214 QEMUGLContext (*dpy_gl_ctx_get_current)(DisplayChangeListener *dcl);
215
216 void (*dpy_gl_scanout)(DisplayChangeListener *dcl,
217 uint32_t backing_id, bool backing_y_0_top,
218 uint32_t x, uint32_t y, uint32_t w, uint32_t h);
219 void (*dpy_gl_update)(DisplayChangeListener *dcl,
220 uint32_t x, uint32_t y, uint32_t w, uint32_t h);
221
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100222} DisplayChangeListenerOps;
223
aliguori7d957bd2009-01-15 22:14:11 +0000224struct DisplayChangeListener {
Gerd Hoffmann0f7b2862013-03-14 11:56:16 +0100225 uint64_t update_interval;
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100226 const DisplayChangeListenerOps *ops;
227 DisplayState *ds;
Gerd Hoffmann284d1c62013-03-15 15:45:54 +0100228 QemuConsole *con;
Gerd Hoffmannbf2fde72012-09-12 07:56:45 +0200229
Gerd Hoffmann87e487a2010-06-04 11:46:35 +0200230 QLIST_ENTRY(DisplayChangeListener) next;
aliguori7d957bd2009-01-15 22:14:11 +0000231};
232
Gerd Hoffmann64840c62013-03-07 17:08:29 +0100233DisplayState *init_displaystate(void);
Gerd Hoffmann30f1e662014-06-18 11:03:15 +0200234DisplaySurface *qemu_create_displaysurface_from(int width, int height,
235 pixman_format_code_t format,
236 int linesize, uint8_t *data);
Gerd Hoffmannca58b452016-04-01 10:27:20 +0200237DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image);
Gerd Hoffmanna77549b2014-06-19 08:46:08 +0200238DisplaySurface *qemu_create_displaysurface_guestmem(int width, int height,
239 pixman_format_code_t format,
240 int linesize,
241 uint64_t addr);
malc0da2ea12009-01-23 19:56:19 +0000242PixelFormat qemu_default_pixelformat(int bpp);
aliguori7d957bd2009-01-15 22:14:11 +0000243
Gerd Hoffmannda229ef2013-02-28 10:48:02 +0100244DisplaySurface *qemu_create_displaysurface(int width, int height);
245void qemu_free_displaysurface(DisplaySurface *surface);
aliguori7b5d76d2009-03-13 15:02:13 +0000246
247static inline int is_surface_bgr(DisplaySurface *surface)
248{
Gerd Hoffmann30f1e662014-06-18 11:03:15 +0200249 if (PIXMAN_FORMAT_BPP(surface->format) == 32 &&
250 PIXMAN_FORMAT_TYPE(surface->format) == PIXMAN_TYPE_ABGR) {
aliguori7b5d76d2009-03-13 15:02:13 +0000251 return 1;
Gerd Hoffmann30f1e662014-06-18 11:03:15 +0200252 } else {
aliguori7b5d76d2009-03-13 15:02:13 +0000253 return 0;
Gerd Hoffmann30f1e662014-06-18 11:03:15 +0200254 }
aliguori7b5d76d2009-03-13 15:02:13 +0000255}
256
aliguori7d957bd2009-01-15 22:14:11 +0000257static inline int is_buffer_shared(DisplaySurface *surface)
258{
Gerd Hoffmann187cd1d2012-09-26 07:46:20 +0200259 return !(surface->flags & QEMU_ALLOCATED_FLAG);
aliguori7d957bd2009-01-15 22:14:11 +0000260}
261
Gerd Hoffmann52090892013-04-23 15:44:31 +0200262void register_displaychangelistener(DisplayChangeListener *dcl);
Gerd Hoffmann0f7b2862013-03-14 11:56:16 +0100263void update_displaychangelistener(DisplayChangeListener *dcl,
264 uint64_t interval);
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100265void unregister_displaychangelistener(DisplayChangeListener *dcl);
Gerd Hoffmann35c9e0a2010-06-04 11:51:31 +0200266
Gerd Hoffmannb7fb49f2015-03-13 12:21:14 +0100267bool dpy_ui_info_supported(QemuConsole *con);
Gerd Hoffmann6f90f3d2014-01-24 17:38:20 +0100268int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info);
269
Gerd Hoffmannc78f7132013-03-05 15:24:14 +0100270void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h);
271void dpy_gfx_replace_surface(QemuConsole *con,
Gerd Hoffmannda229ef2013-02-28 10:48:02 +0100272 DisplaySurface *surface);
Gerd Hoffmannc78f7132013-03-05 15:24:14 +0100273void dpy_gfx_copy(QemuConsole *con, int src_x, int src_y,
Gerd Hoffmann7c20b4a2012-11-13 14:51:41 +0100274 int dst_x, int dst_y, int w, int h);
Gerd Hoffmannc78f7132013-03-05 15:24:14 +0100275void dpy_text_cursor(QemuConsole *con, int x, int y);
276void dpy_text_update(QemuConsole *con, int x, int y, int w, int h);
277void dpy_text_resize(QemuConsole *con, int w, int h);
278void dpy_mouse_set(QemuConsole *con, int x, int y, int on);
279void dpy_cursor_define(QemuConsole *con, QEMUCursor *cursor);
280bool dpy_cursor_define_supported(QemuConsole *con);
Benjamin Herrenschmidt49743df2014-07-07 16:39:05 +1000281bool dpy_gfx_check_format(QemuConsole *con,
282 pixman_format_code_t format);
Gerd Hoffmannbf2fde72012-09-12 07:56:45 +0200283
Gerd Hoffmann06020b92014-07-11 13:56:51 +0200284void dpy_gl_scanout(QemuConsole *con,
285 uint32_t backing_id, bool backing_y_0_top,
286 uint32_t x, uint32_t y, uint32_t w, uint32_t h);
287void dpy_gl_update(QemuConsole *con,
288 uint32_t x, uint32_t y, uint32_t w, uint32_t h);
289
290QEMUGLContext dpy_gl_ctx_create(QemuConsole *con,
291 QEMUGLParams *params);
292void dpy_gl_ctx_destroy(QemuConsole *con, QEMUGLContext ctx);
293int dpy_gl_ctx_make_current(QemuConsole *con, QEMUGLContext ctx);
294QEMUGLContext dpy_gl_ctx_get_current(QemuConsole *con);
295
296bool console_has_gl(QemuConsole *con);
297
Gerd Hoffmann626e3b32013-02-28 15:24:14 +0100298static inline int surface_stride(DisplaySurface *s)
299{
300 return pixman_image_get_stride(s->image);
301}
302
303static inline void *surface_data(DisplaySurface *s)
304{
305 return pixman_image_get_data(s->image);
306}
307
308static inline int surface_width(DisplaySurface *s)
309{
310 return pixman_image_get_width(s->image);
311}
312
313static inline int surface_height(DisplaySurface *s)
314{
315 return pixman_image_get_height(s->image);
316}
317
318static inline int surface_bits_per_pixel(DisplaySurface *s)
319{
320 int bits = PIXMAN_FORMAT_BPP(s->format);
321 return bits;
322}
323
324static inline int surface_bytes_per_pixel(DisplaySurface *s)
325{
326 int bits = PIXMAN_FORMAT_BPP(s->format);
327 return (bits + 7) / 8;
328}
329
Max Reitze444ea32015-03-03 12:25:27 -0500330static inline pixman_format_code_t surface_format(DisplaySurface *s)
331{
332 return s->format;
333}
334
Devin J. Pohlydf00bed2011-09-07 15:44:36 -0400335#ifdef CONFIG_CURSES
336#include <curses.h>
337typedef chtype console_ch_t;
OGAWA Hirofumie2368dc2015-10-19 21:23:46 +0900338extern chtype vga_to_curses[];
Devin J. Pohlydf00bed2011-09-07 15:44:36 -0400339#else
Anthony Liguoric227f092009-10-01 16:12:16 -0500340typedef unsigned long console_ch_t;
Devin J. Pohlydf00bed2011-09-07 15:44:36 -0400341#endif
Anthony Liguoric227f092009-10-01 16:12:16 -0500342static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
balrog4d3b6f62008-02-10 16:33:14 +0000343{
OGAWA Hirofumie2368dc2015-10-19 21:23:46 +0900344 uint8_t c = ch;
345#ifdef CONFIG_CURSES
346 if (vga_to_curses[c]) {
347 ch &= ~(console_ch_t)0xff;
348 ch |= vga_to_curses[c];
349 }
350#else
351 if (c == '\0') {
Bernhard Kauerf6d20d02010-05-21 14:05:55 +0200352 ch |= ' ';
OGAWA Hirofumie2368dc2015-10-19 21:23:46 +0900353 }
354#endif
Aurelien Jarno9ae19b62011-01-04 21:58:24 +0100355 *dest = ch;
balrog4d3b6f62008-02-10 16:33:14 +0000356}
357
Gerd Hoffmann380cd052013-03-13 14:04:18 +0100358typedef struct GraphicHwOps {
359 void (*invalidate)(void *opaque);
360 void (*gfx_update)(void *opaque);
361 void (*text_update)(void *opaque, console_ch_t *text);
Gerd Hoffmanndea1b0b2013-03-19 15:01:02 +0100362 void (*update_interval)(void *opaque, uint64_t interval);
Gerd Hoffmann6f90f3d2014-01-24 17:38:20 +0100363 int (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info);
Gerd Hoffmannbba19b82015-12-03 12:34:25 +0100364 void (*gl_block)(void *opaque, bool block);
Gerd Hoffmann380cd052013-03-13 14:04:18 +0100365} GraphicHwOps;
pbrook87ecb682007-11-17 17:14:51 +0000366
Gerd Hoffmann56437062014-01-24 15:35:21 +0100367QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head,
Gerd Hoffmannaa2beaa2013-04-17 10:21:27 +0200368 const GraphicHwOps *ops,
Gerd Hoffmannc78f7132013-03-05 15:24:14 +0100369 void *opaque);
Gerd Hoffmann1c1f9492014-09-24 17:05:27 +0200370void graphic_console_set_hwops(QemuConsole *con,
371 const GraphicHwOps *hw_ops,
372 void *opaque);
aliguori3023f332009-01-16 19:04:14 +0000373
Gerd Hoffmann1dbfa002013-03-12 13:44:38 +0100374void graphic_hw_update(QemuConsole *con);
375void graphic_hw_invalidate(QemuConsole *con);
376void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata);
Gerd Hoffmannbba19b82015-12-03 12:34:25 +0100377void graphic_hw_gl_block(QemuConsole *con, bool block);
pbrook87ecb682007-11-17 17:14:51 +0000378
Gerd Hoffmann284d1c62013-03-15 15:45:54 +0100379QemuConsole *qemu_console_lookup_by_index(unsigned int index);
Gerd Hoffmann56437062014-01-24 15:35:21 +0100380QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head);
Gerd Hoffmannf2c1d542016-01-12 11:45:43 +0100381QemuConsole *qemu_console_lookup_by_device_name(const char *device_id,
382 uint32_t head, Error **errp);
Gerd Hoffmann81c0d5a2013-03-14 14:27:08 +0100383bool qemu_console_is_visible(QemuConsole *con);
384bool qemu_console_is_graphic(QemuConsole *con);
385bool qemu_console_is_fixedsize(QemuConsole *con);
Gerd Hoffmann779ce882015-02-17 10:41:08 +0100386char *qemu_console_get_label(QemuConsole *con);
Gerd Hoffmannd4c85332013-11-28 09:58:18 +0100387int qemu_console_get_index(QemuConsole *con);
Gerd Hoffmann56437062014-01-24 15:35:21 +0100388uint32_t qemu_console_get_head(QemuConsole *con);
Gerd Hoffmann6f90f3d2014-01-24 17:38:20 +0100389QemuUIInfo *qemu_console_get_ui_info(QemuConsole *con);
Gerd Hoffmannd4c85332013-11-28 09:58:18 +0100390int qemu_console_get_width(QemuConsole *con, int fallback);
391int qemu_console_get_height(QemuConsole *con, int fallback);
Gerd Hoffmann81c0d5a2013-03-14 14:27:08 +0100392
aliguori2796dae2009-01-16 20:23:27 +0000393void text_consoles_set_display(DisplayState *ds);
pbrook87ecb682007-11-17 17:14:51 +0000394void console_select(unsigned int index);
395void console_color_init(DisplayState *ds);
Gerd Hoffmannc78f7132013-03-05 15:24:14 +0100396void qemu_console_resize(QemuConsole *con, int width, int height);
397void qemu_console_copy(QemuConsole *con, int src_x, int src_y,
aliguori3023f332009-01-16 19:04:14 +0000398 int dst_x, int dst_y, int w, int h);
Gerd Hoffmannc78f7132013-03-05 15:24:14 +0100399DisplaySurface *qemu_console_surface(QemuConsole *con);
pbrook87ecb682007-11-17 17:14:51 +0000400
Gerd Hoffmanncd2bc882015-01-09 11:40:23 +0100401/* console-gl.c */
402typedef struct ConsoleGLState ConsoleGLState;
403#ifdef CONFIG_OPENGL
404ConsoleGLState *console_gl_init_context(void);
405void console_gl_fini_context(ConsoleGLState *gls);
406bool console_gl_check_format(DisplayChangeListener *dcl,
407 pixman_format_code_t format);
408void surface_gl_create_texture(ConsoleGLState *gls,
409 DisplaySurface *surface);
410void surface_gl_update_texture(ConsoleGLState *gls,
411 DisplaySurface *surface,
412 int x, int y, int w, int h);
413void surface_gl_render_texture(ConsoleGLState *gls,
414 DisplaySurface *surface);
415void surface_gl_destroy_texture(ConsoleGLState *gls,
416 DisplaySurface *surface);
417void surface_gl_setup_viewport(ConsoleGLState *gls,
418 DisplaySurface *surface,
419 int ww, int wh);
420#endif
421
pbrook87ecb682007-11-17 17:14:51 +0000422/* sdl.c */
Gerd Hoffmann0b71a5d2014-11-11 16:54:45 +0100423void sdl_display_early_init(int opengl);
pbrook87ecb682007-11-17 17:14:51 +0000424void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
425
426/* cocoa.m */
427void cocoa_display_init(DisplayState *ds, int full_screen);
428
429/* vnc.c */
Gerd Hoffmann14f71432014-07-29 12:24:55 +0200430void vnc_display_init(const char *id);
Gerd Hoffmann4db14622014-09-16 12:33:03 +0200431void vnc_display_open(const char *id, Error **errp);
Gerd Hoffmann14f71432014-07-29 12:24:55 +0200432void vnc_display_add_client(const char *id, int csock, bool skipauth);
433char *vnc_display_local_addr(const char *id);
Jes Sorensen821601e2011-03-16 13:33:36 +0100434#ifdef CONFIG_VNC
Gerd Hoffmann14f71432014-07-29 12:24:55 +0200435int vnc_display_password(const char *id, const char *password);
436int vnc_display_pw_expire(const char *id, time_t expires);
Markus Armbruster70b94332015-02-13 12:50:26 +0100437QemuOpts *vnc_parse(const char *str, Error **errp);
Markus Armbruster28d0de72015-03-13 13:35:14 +0100438int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp);
Jes Sorensen821601e2011-03-16 13:33:36 +0100439#else
Gerd Hoffmann14f71432014-07-29 12:24:55 +0200440static inline int vnc_display_password(const char *id, const char *password)
Jes Sorensen821601e2011-03-16 13:33:36 +0100441{
Jes Sorensen821601e2011-03-16 13:33:36 +0100442 return -ENODEV;
443}
Gerd Hoffmann14f71432014-07-29 12:24:55 +0200444static inline int vnc_display_pw_expire(const char *id, time_t expires)
Jes Sorensen821601e2011-03-16 13:33:36 +0100445{
Jes Sorensen821601e2011-03-16 13:33:36 +0100446 return -ENODEV;
447};
Jes Sorensen821601e2011-03-16 13:33:36 +0100448#endif
pbrook87ecb682007-11-17 17:14:51 +0000449
balrog4d3b6f62008-02-10 16:33:14 +0000450/* curses.c */
451void curses_display_init(DisplayState *ds, int full_screen);
452
Amos Kong1048c882012-08-31 10:56:25 +0800453/* input.c */
Wolfgang Bumiller64ffbe02016-01-13 09:09:58 +0100454int index_from_key(const char *key, size_t key_length);
Amos Kong1048c882012-08-31 10:56:25 +0800455
Anthony Liguoria4ccabc2013-02-20 07:43:20 -0600456/* gtk.c */
Gerd Hoffmann97edf3b2015-01-20 12:43:28 +0100457void early_gtk_display_init(int opengl);
Jan Kiszka881249c2014-03-12 08:33:50 +0100458void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover);
Anthony Liguoria4ccabc2013-02-20 07:43:20 -0600459
pbrook87ecb682007-11-17 17:14:51 +0000460#endif