pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 1 | #ifndef CONSOLE_H |
| 2 | #define CONSOLE_H |
| 3 | |
Paolo Bonzini | 28ecbae | 2012-11-28 12:06:30 +0100 | [diff] [blame] | 4 | #include "ui/qemu-pixman.h" |
Gerd Hoffmann | 95be066 | 2013-04-17 09:45:10 +0200 | [diff] [blame] | 5 | #include "qom/object.h" |
Paolo Bonzini | 7b1b5d1 | 2012-12-17 18:19:43 +0100 | [diff] [blame] | 6 | #include "qapi/qmp/qdict.h" |
Paolo Bonzini | 1de7afc | 2012-12-17 18:20:00 +0100 | [diff] [blame] | 7 | #include "qemu/notify.h" |
Amos Kong | 1048c88 | 2012-08-31 10:56:25 +0800 | [diff] [blame] | 8 | #include "qapi-types.h" |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 9 | |
Gerd Hoffmann | cd2bc88 | 2015-01-09 11:40:23 +0100 | [diff] [blame] | 10 | #ifdef CONFIG_OPENGL |
Gerd Hoffmann | dcf3002 | 2015-05-11 12:24:43 +0200 | [diff] [blame] | 11 | # include <epoxy/gl.h> |
Gerd Hoffmann | cd2bc88 | 2015-01-09 11:40:23 +0100 | [diff] [blame] | 12 | #endif |
| 13 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 14 | /* keyboard/mouse support */ |
| 15 | |
| 16 | #define MOUSE_EVENT_LBUTTON 0x01 |
| 17 | #define MOUSE_EVENT_RBUTTON 0x02 |
| 18 | #define MOUSE_EVENT_MBUTTON 0x04 |
Gerd Hoffmann | 21bae11 | 2013-12-04 14:08:04 +0100 | [diff] [blame] | 19 | #define MOUSE_EVENT_WHEELUP 0x08 |
| 20 | #define MOUSE_EVENT_WHEELDN 0x10 |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 21 | |
Gerd Hoffmann | 03a23a8 | 2010-02-26 17:17:36 +0100 | [diff] [blame] | 22 | /* 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 | |
aliguori | 7ed9eba | 2008-08-21 20:12:05 +0000 | [diff] [blame] | 27 | /* in ms */ |
Gerd Hoffmann | 0f7b286 | 2013-03-14 11:56:16 +0100 | [diff] [blame] | 28 | #define GUI_REFRESH_INTERVAL_DEFAULT 30 |
| 29 | #define GUI_REFRESH_INTERVAL_IDLE 3000 |
aliguori | 7ed9eba | 2008-08-21 20:12:05 +0000 | [diff] [blame] | 30 | |
OGAWA Hirofumi | 4083733 | 2015-11-29 22:28:24 +0900 | [diff] [blame] | 31 | /* Color number is match to standard vga palette */ |
| 32 | enum 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 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 46 | typedef void QEMUPutKBDEvent(void *opaque, int keycode); |
Gerd Hoffmann | 03a23a8 | 2010-02-26 17:17:36 +0100 | [diff] [blame] | 47 | typedef void QEMUPutLEDEvent(void *opaque, int ledstate); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 48 | typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state); |
| 49 | |
Gerd Hoffmann | 72711ef | 2013-04-24 12:08:37 +0200 | [diff] [blame] | 50 | typedef struct QEMUPutMouseEntry QEMUPutMouseEntry; |
Gerd Hoffmann | 5a37532 | 2013-04-24 12:08:38 +0200 | [diff] [blame] | 51 | typedef struct QEMUPutKbdEntry QEMUPutKbdEntry; |
Gerd Hoffmann | 72711ef | 2013-04-24 12:08:37 +0200 | [diff] [blame] | 52 | typedef struct QEMUPutLEDEntry QEMUPutLEDEntry; |
Gerd Hoffmann | 03a23a8 | 2010-02-26 17:17:36 +0100 | [diff] [blame] | 53 | |
Gerd Hoffmann | 5a37532 | 2013-04-24 12:08:38 +0200 | [diff] [blame] | 54 | QEMUPutKbdEntry *qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, |
| 55 | void *opaque); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 56 | QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, |
| 57 | void *opaque, int absolute, |
| 58 | const char *name); |
| 59 | void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry); |
Anthony Liguori | 6fef28e | 2010-03-09 20:52:22 -0600 | [diff] [blame] | 60 | void qemu_activate_mouse_event_handler(QEMUPutMouseEntry *entry); |
| 61 | |
Gerd Hoffmann | 03a23a8 | 2010-02-26 17:17:36 +0100 | [diff] [blame] | 62 | QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, void *opaque); |
| 63 | void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 64 | |
Gerd Hoffmann | 03a23a8 | 2010-02-26 17:17:36 +0100 | [diff] [blame] | 65 | void kbd_put_ledstate(int ledstate); |
Anthony Liguori | eb2e259 | 2010-03-09 14:26:40 -0600 | [diff] [blame] | 66 | |
Paul Brook | bc24a22 | 2009-05-10 01:44:56 +0100 | [diff] [blame] | 67 | struct MouseTransformInfo { |
balrog | a5d7eb6 | 2008-04-14 21:28:11 +0000 | [diff] [blame] | 68 | /* Touchscreen resolution */ |
| 69 | int x; |
| 70 | int y; |
| 71 | /* Calibration values as used/generated by tslib */ |
| 72 | int a[7]; |
| 73 | }; |
| 74 | |
Markus Armbruster | 3e5a50d | 2015-02-06 13:55:43 +0100 | [diff] [blame] | 75 | void hmp_mouse_set(Monitor *mon, const QDict *qdict); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 76 | |
| 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 Hoffmann | 3f9a6e8 | 2014-05-22 12:05:52 +0200 | [diff] [blame] | 100 | void kbd_put_keysym_console(QemuConsole *s, int keysym); |
Gerd Hoffmann | 50ef467 | 2014-05-27 09:28:38 +0200 | [diff] [blame] | 101 | bool kbd_put_qcode_console(QemuConsole *s, int qcode); |
Gerd Hoffmann | bdef972 | 2014-05-27 09:32:36 +0200 | [diff] [blame] | 102 | void kbd_put_string_console(QemuConsole *s, const char *str, int len); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 103 | void kbd_put_keysym(int keysym); |
| 104 | |
| 105 | /* consoles */ |
| 106 | |
Gerd Hoffmann | 95be066 | 2013-04-17 09:45:10 +0200 | [diff] [blame] | 107 | #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 | |
| 115 | typedef struct QemuConsoleClass QemuConsoleClass; |
| 116 | |
| 117 | struct QemuConsoleClass { |
| 118 | ObjectClass parent_class; |
| 119 | }; |
| 120 | |
Benjamin Herrenschmidt | 77bfcf2 | 2014-06-21 14:58:06 +1000 | [diff] [blame] | 121 | #define QEMU_ALLOCATED_FLAG 0x01 |
aliguori | 7d957bd | 2009-01-15 22:14:11 +0000 | [diff] [blame] | 122 | |
| 123 | struct 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; |
aliguori | 90a1e3c | 2009-01-26 15:37:30 +0000 | [diff] [blame] | 130 | uint8_t rbits, gbits, bbits, abits; |
aliguori | 7d957bd | 2009-01-15 22:14:11 +0000 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | struct DisplaySurface { |
Gerd Hoffmann | 69c7777 | 2012-09-26 15:20:05 +0200 | [diff] [blame] | 134 | pixman_format_code_t format; |
| 135 | pixman_image_t *image; |
aliguori | 7d957bd | 2009-01-15 22:14:11 +0000 | [diff] [blame] | 136 | uint8_t flags; |
Gerd Hoffmann | cd2bc88 | 2015-01-09 11:40:23 +0100 | [diff] [blame] | 137 | #ifdef CONFIG_OPENGL |
| 138 | GLenum glformat; |
| 139 | GLenum gltype; |
| 140 | GLuint texture; |
| 141 | #endif |
aliguori | 7d957bd | 2009-01-15 22:14:11 +0000 | [diff] [blame] | 142 | }; |
| 143 | |
Gerd Hoffmann | 6f90f3d | 2014-01-24 17:38:20 +0100 | [diff] [blame] | 144 | typedef struct QemuUIInfo { |
| 145 | /* geometry */ |
| 146 | int xoff; |
| 147 | int yoff; |
| 148 | uint32_t width; |
| 149 | uint32_t height; |
| 150 | } QemuUIInfo; |
| 151 | |
Gerd Hoffmann | 254e595 | 2010-05-21 11:54:32 +0200 | [diff] [blame] | 152 | /* cursor data format is 32bit RGBA */ |
| 153 | typedef struct QEMUCursor { |
| 154 | int width, height; |
| 155 | int hot_x, hot_y; |
| 156 | int refcount; |
| 157 | uint32_t data[]; |
| 158 | } QEMUCursor; |
| 159 | |
| 160 | QEMUCursor *cursor_alloc(int width, int height); |
| 161 | void cursor_get(QEMUCursor *c); |
| 162 | void cursor_put(QEMUCursor *c); |
| 163 | QEMUCursor *cursor_builtin_hidden(void); |
| 164 | QEMUCursor *cursor_builtin_left_ptr(void); |
| 165 | void cursor_print_ascii_art(QEMUCursor *c, const char *prefix); |
| 166 | int cursor_get_mono_bpl(QEMUCursor *c); |
| 167 | void cursor_set_mono(QEMUCursor *c, |
| 168 | uint32_t foreground, uint32_t background, uint8_t *image, |
| 169 | int transparent, uint8_t *mask); |
| 170 | void cursor_get_mono_image(QEMUCursor *c, int foreground, uint8_t *mask); |
| 171 | void cursor_get_mono_mask(QEMUCursor *c, int transparent, uint8_t *mask); |
| 172 | |
Gerd Hoffmann | 06020b9 | 2014-07-11 13:56:51 +0200 | [diff] [blame] | 173 | typedef void *QEMUGLContext; |
| 174 | typedef struct QEMUGLParams QEMUGLParams; |
| 175 | |
| 176 | struct QEMUGLParams { |
| 177 | int major_ver; |
| 178 | int minor_ver; |
| 179 | }; |
| 180 | |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 181 | typedef struct DisplayChangeListenerOps { |
| 182 | const char *dpy_name; |
| 183 | |
Gerd Hoffmann | bc2ed97 | 2013-03-01 13:03:04 +0100 | [diff] [blame] | 184 | void (*dpy_refresh)(DisplayChangeListener *dcl); |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 185 | |
| 186 | void (*dpy_gfx_update)(DisplayChangeListener *dcl, |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 187 | int x, int y, int w, int h); |
Gerd Hoffmann | c12aeb8 | 2013-02-28 15:03:04 +0100 | [diff] [blame] | 188 | void (*dpy_gfx_switch)(DisplayChangeListener *dcl, |
Gerd Hoffmann | c12aeb8 | 2013-02-28 15:03:04 +0100 | [diff] [blame] | 189 | struct DisplaySurface *new_surface); |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 190 | void (*dpy_gfx_copy)(DisplayChangeListener *dcl, |
Gerd Hoffmann | bc2ed97 | 2013-03-01 13:03:04 +0100 | [diff] [blame] | 191 | int src_x, int src_y, |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 192 | int dst_x, int dst_y, int w, int h); |
Benjamin Herrenschmidt | 49743df | 2014-07-07 16:39:05 +1000 | [diff] [blame] | 193 | bool (*dpy_gfx_check_format)(DisplayChangeListener *dcl, |
| 194 | pixman_format_code_t format); |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 195 | |
| 196 | void (*dpy_text_cursor)(DisplayChangeListener *dcl, |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 197 | int x, int y); |
| 198 | void (*dpy_text_resize)(DisplayChangeListener *dcl, |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 199 | int w, int h); |
| 200 | void (*dpy_text_update)(DisplayChangeListener *dcl, |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 201 | int x, int y, int w, int h); |
| 202 | |
| 203 | void (*dpy_mouse_set)(DisplayChangeListener *dcl, |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 204 | int x, int y, int on); |
| 205 | void (*dpy_cursor_define)(DisplayChangeListener *dcl, |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 206 | QEMUCursor *cursor); |
Gerd Hoffmann | 06020b9 | 2014-07-11 13:56:51 +0200 | [diff] [blame] | 207 | |
| 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 Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 222 | } DisplayChangeListenerOps; |
| 223 | |
aliguori | 7d957bd | 2009-01-15 22:14:11 +0000 | [diff] [blame] | 224 | struct DisplayChangeListener { |
Gerd Hoffmann | 0f7b286 | 2013-03-14 11:56:16 +0100 | [diff] [blame] | 225 | uint64_t update_interval; |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 226 | const DisplayChangeListenerOps *ops; |
| 227 | DisplayState *ds; |
Gerd Hoffmann | 284d1c6 | 2013-03-15 15:45:54 +0100 | [diff] [blame] | 228 | QemuConsole *con; |
Gerd Hoffmann | bf2fde7 | 2012-09-12 07:56:45 +0200 | [diff] [blame] | 229 | |
Gerd Hoffmann | 87e487a | 2010-06-04 11:46:35 +0200 | [diff] [blame] | 230 | QLIST_ENTRY(DisplayChangeListener) next; |
aliguori | 7d957bd | 2009-01-15 22:14:11 +0000 | [diff] [blame] | 231 | }; |
| 232 | |
Gerd Hoffmann | 64840c6 | 2013-03-07 17:08:29 +0100 | [diff] [blame] | 233 | DisplayState *init_displaystate(void); |
Gerd Hoffmann | 30f1e66 | 2014-06-18 11:03:15 +0200 | [diff] [blame] | 234 | DisplaySurface *qemu_create_displaysurface_from(int width, int height, |
| 235 | pixman_format_code_t format, |
| 236 | int linesize, uint8_t *data); |
Gerd Hoffmann | ca58b45 | 2016-04-01 10:27:20 +0200 | [diff] [blame^] | 237 | DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image); |
Gerd Hoffmann | a77549b | 2014-06-19 08:46:08 +0200 | [diff] [blame] | 238 | DisplaySurface *qemu_create_displaysurface_guestmem(int width, int height, |
| 239 | pixman_format_code_t format, |
| 240 | int linesize, |
| 241 | uint64_t addr); |
malc | 0da2ea1 | 2009-01-23 19:56:19 +0000 | [diff] [blame] | 242 | PixelFormat qemu_default_pixelformat(int bpp); |
aliguori | 7d957bd | 2009-01-15 22:14:11 +0000 | [diff] [blame] | 243 | |
Gerd Hoffmann | da229ef | 2013-02-28 10:48:02 +0100 | [diff] [blame] | 244 | DisplaySurface *qemu_create_displaysurface(int width, int height); |
| 245 | void qemu_free_displaysurface(DisplaySurface *surface); |
aliguori | 7b5d76d | 2009-03-13 15:02:13 +0000 | [diff] [blame] | 246 | |
| 247 | static inline int is_surface_bgr(DisplaySurface *surface) |
| 248 | { |
Gerd Hoffmann | 30f1e66 | 2014-06-18 11:03:15 +0200 | [diff] [blame] | 249 | if (PIXMAN_FORMAT_BPP(surface->format) == 32 && |
| 250 | PIXMAN_FORMAT_TYPE(surface->format) == PIXMAN_TYPE_ABGR) { |
aliguori | 7b5d76d | 2009-03-13 15:02:13 +0000 | [diff] [blame] | 251 | return 1; |
Gerd Hoffmann | 30f1e66 | 2014-06-18 11:03:15 +0200 | [diff] [blame] | 252 | } else { |
aliguori | 7b5d76d | 2009-03-13 15:02:13 +0000 | [diff] [blame] | 253 | return 0; |
Gerd Hoffmann | 30f1e66 | 2014-06-18 11:03:15 +0200 | [diff] [blame] | 254 | } |
aliguori | 7b5d76d | 2009-03-13 15:02:13 +0000 | [diff] [blame] | 255 | } |
| 256 | |
aliguori | 7d957bd | 2009-01-15 22:14:11 +0000 | [diff] [blame] | 257 | static inline int is_buffer_shared(DisplaySurface *surface) |
| 258 | { |
Gerd Hoffmann | 187cd1d | 2012-09-26 07:46:20 +0200 | [diff] [blame] | 259 | return !(surface->flags & QEMU_ALLOCATED_FLAG); |
aliguori | 7d957bd | 2009-01-15 22:14:11 +0000 | [diff] [blame] | 260 | } |
| 261 | |
Gerd Hoffmann | 5209089 | 2013-04-23 15:44:31 +0200 | [diff] [blame] | 262 | void register_displaychangelistener(DisplayChangeListener *dcl); |
Gerd Hoffmann | 0f7b286 | 2013-03-14 11:56:16 +0100 | [diff] [blame] | 263 | void update_displaychangelistener(DisplayChangeListener *dcl, |
| 264 | uint64_t interval); |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 265 | void unregister_displaychangelistener(DisplayChangeListener *dcl); |
Gerd Hoffmann | 35c9e0a | 2010-06-04 11:51:31 +0200 | [diff] [blame] | 266 | |
Gerd Hoffmann | b7fb49f | 2015-03-13 12:21:14 +0100 | [diff] [blame] | 267 | bool dpy_ui_info_supported(QemuConsole *con); |
Gerd Hoffmann | 6f90f3d | 2014-01-24 17:38:20 +0100 | [diff] [blame] | 268 | int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info); |
| 269 | |
Gerd Hoffmann | c78f713 | 2013-03-05 15:24:14 +0100 | [diff] [blame] | 270 | void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h); |
| 271 | void dpy_gfx_replace_surface(QemuConsole *con, |
Gerd Hoffmann | da229ef | 2013-02-28 10:48:02 +0100 | [diff] [blame] | 272 | DisplaySurface *surface); |
Gerd Hoffmann | c78f713 | 2013-03-05 15:24:14 +0100 | [diff] [blame] | 273 | void dpy_gfx_copy(QemuConsole *con, int src_x, int src_y, |
Gerd Hoffmann | 7c20b4a | 2012-11-13 14:51:41 +0100 | [diff] [blame] | 274 | int dst_x, int dst_y, int w, int h); |
Gerd Hoffmann | c78f713 | 2013-03-05 15:24:14 +0100 | [diff] [blame] | 275 | void dpy_text_cursor(QemuConsole *con, int x, int y); |
| 276 | void dpy_text_update(QemuConsole *con, int x, int y, int w, int h); |
| 277 | void dpy_text_resize(QemuConsole *con, int w, int h); |
| 278 | void dpy_mouse_set(QemuConsole *con, int x, int y, int on); |
| 279 | void dpy_cursor_define(QemuConsole *con, QEMUCursor *cursor); |
| 280 | bool dpy_cursor_define_supported(QemuConsole *con); |
Benjamin Herrenschmidt | 49743df | 2014-07-07 16:39:05 +1000 | [diff] [blame] | 281 | bool dpy_gfx_check_format(QemuConsole *con, |
| 282 | pixman_format_code_t format); |
Gerd Hoffmann | bf2fde7 | 2012-09-12 07:56:45 +0200 | [diff] [blame] | 283 | |
Gerd Hoffmann | 06020b9 | 2014-07-11 13:56:51 +0200 | [diff] [blame] | 284 | void 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); |
| 287 | void dpy_gl_update(QemuConsole *con, |
| 288 | uint32_t x, uint32_t y, uint32_t w, uint32_t h); |
| 289 | |
| 290 | QEMUGLContext dpy_gl_ctx_create(QemuConsole *con, |
| 291 | QEMUGLParams *params); |
| 292 | void dpy_gl_ctx_destroy(QemuConsole *con, QEMUGLContext ctx); |
| 293 | int dpy_gl_ctx_make_current(QemuConsole *con, QEMUGLContext ctx); |
| 294 | QEMUGLContext dpy_gl_ctx_get_current(QemuConsole *con); |
| 295 | |
| 296 | bool console_has_gl(QemuConsole *con); |
| 297 | |
Gerd Hoffmann | 626e3b3 | 2013-02-28 15:24:14 +0100 | [diff] [blame] | 298 | static inline int surface_stride(DisplaySurface *s) |
| 299 | { |
| 300 | return pixman_image_get_stride(s->image); |
| 301 | } |
| 302 | |
| 303 | static inline void *surface_data(DisplaySurface *s) |
| 304 | { |
| 305 | return pixman_image_get_data(s->image); |
| 306 | } |
| 307 | |
| 308 | static inline int surface_width(DisplaySurface *s) |
| 309 | { |
| 310 | return pixman_image_get_width(s->image); |
| 311 | } |
| 312 | |
| 313 | static inline int surface_height(DisplaySurface *s) |
| 314 | { |
| 315 | return pixman_image_get_height(s->image); |
| 316 | } |
| 317 | |
| 318 | static inline int surface_bits_per_pixel(DisplaySurface *s) |
| 319 | { |
| 320 | int bits = PIXMAN_FORMAT_BPP(s->format); |
| 321 | return bits; |
| 322 | } |
| 323 | |
| 324 | static 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 Reitz | e444ea3 | 2015-03-03 12:25:27 -0500 | [diff] [blame] | 330 | static inline pixman_format_code_t surface_format(DisplaySurface *s) |
| 331 | { |
| 332 | return s->format; |
| 333 | } |
| 334 | |
Devin J. Pohly | df00bed | 2011-09-07 15:44:36 -0400 | [diff] [blame] | 335 | #ifdef CONFIG_CURSES |
| 336 | #include <curses.h> |
| 337 | typedef chtype console_ch_t; |
OGAWA Hirofumi | e2368dc | 2015-10-19 21:23:46 +0900 | [diff] [blame] | 338 | extern chtype vga_to_curses[]; |
Devin J. Pohly | df00bed | 2011-09-07 15:44:36 -0400 | [diff] [blame] | 339 | #else |
Anthony Liguori | c227f09 | 2009-10-01 16:12:16 -0500 | [diff] [blame] | 340 | typedef unsigned long console_ch_t; |
Devin J. Pohly | df00bed | 2011-09-07 15:44:36 -0400 | [diff] [blame] | 341 | #endif |
Anthony Liguori | c227f09 | 2009-10-01 16:12:16 -0500 | [diff] [blame] | 342 | static inline void console_write_ch(console_ch_t *dest, uint32_t ch) |
balrog | 4d3b6f6 | 2008-02-10 16:33:14 +0000 | [diff] [blame] | 343 | { |
OGAWA Hirofumi | e2368dc | 2015-10-19 21:23:46 +0900 | [diff] [blame] | 344 | 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 Kauer | f6d20d0 | 2010-05-21 14:05:55 +0200 | [diff] [blame] | 352 | ch |= ' '; |
OGAWA Hirofumi | e2368dc | 2015-10-19 21:23:46 +0900 | [diff] [blame] | 353 | } |
| 354 | #endif |
Aurelien Jarno | 9ae19b6 | 2011-01-04 21:58:24 +0100 | [diff] [blame] | 355 | *dest = ch; |
balrog | 4d3b6f6 | 2008-02-10 16:33:14 +0000 | [diff] [blame] | 356 | } |
| 357 | |
Gerd Hoffmann | 380cd05 | 2013-03-13 14:04:18 +0100 | [diff] [blame] | 358 | typedef struct GraphicHwOps { |
| 359 | void (*invalidate)(void *opaque); |
| 360 | void (*gfx_update)(void *opaque); |
| 361 | void (*text_update)(void *opaque, console_ch_t *text); |
Gerd Hoffmann | dea1b0b | 2013-03-19 15:01:02 +0100 | [diff] [blame] | 362 | void (*update_interval)(void *opaque, uint64_t interval); |
Gerd Hoffmann | 6f90f3d | 2014-01-24 17:38:20 +0100 | [diff] [blame] | 363 | int (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); |
Gerd Hoffmann | bba19b8 | 2015-12-03 12:34:25 +0100 | [diff] [blame] | 364 | void (*gl_block)(void *opaque, bool block); |
Gerd Hoffmann | 380cd05 | 2013-03-13 14:04:18 +0100 | [diff] [blame] | 365 | } GraphicHwOps; |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 366 | |
Gerd Hoffmann | 5643706 | 2014-01-24 15:35:21 +0100 | [diff] [blame] | 367 | QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head, |
Gerd Hoffmann | aa2beaa | 2013-04-17 10:21:27 +0200 | [diff] [blame] | 368 | const GraphicHwOps *ops, |
Gerd Hoffmann | c78f713 | 2013-03-05 15:24:14 +0100 | [diff] [blame] | 369 | void *opaque); |
Gerd Hoffmann | 1c1f949 | 2014-09-24 17:05:27 +0200 | [diff] [blame] | 370 | void graphic_console_set_hwops(QemuConsole *con, |
| 371 | const GraphicHwOps *hw_ops, |
| 372 | void *opaque); |
aliguori | 3023f33 | 2009-01-16 19:04:14 +0000 | [diff] [blame] | 373 | |
Gerd Hoffmann | 1dbfa00 | 2013-03-12 13:44:38 +0100 | [diff] [blame] | 374 | void graphic_hw_update(QemuConsole *con); |
| 375 | void graphic_hw_invalidate(QemuConsole *con); |
| 376 | void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata); |
Gerd Hoffmann | bba19b8 | 2015-12-03 12:34:25 +0100 | [diff] [blame] | 377 | void graphic_hw_gl_block(QemuConsole *con, bool block); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 378 | |
Gerd Hoffmann | 284d1c6 | 2013-03-15 15:45:54 +0100 | [diff] [blame] | 379 | QemuConsole *qemu_console_lookup_by_index(unsigned int index); |
Gerd Hoffmann | 5643706 | 2014-01-24 15:35:21 +0100 | [diff] [blame] | 380 | QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head); |
Gerd Hoffmann | f2c1d54 | 2016-01-12 11:45:43 +0100 | [diff] [blame] | 381 | QemuConsole *qemu_console_lookup_by_device_name(const char *device_id, |
| 382 | uint32_t head, Error **errp); |
Gerd Hoffmann | 81c0d5a | 2013-03-14 14:27:08 +0100 | [diff] [blame] | 383 | bool qemu_console_is_visible(QemuConsole *con); |
| 384 | bool qemu_console_is_graphic(QemuConsole *con); |
| 385 | bool qemu_console_is_fixedsize(QemuConsole *con); |
Gerd Hoffmann | 779ce88 | 2015-02-17 10:41:08 +0100 | [diff] [blame] | 386 | char *qemu_console_get_label(QemuConsole *con); |
Gerd Hoffmann | d4c8533 | 2013-11-28 09:58:18 +0100 | [diff] [blame] | 387 | int qemu_console_get_index(QemuConsole *con); |
Gerd Hoffmann | 5643706 | 2014-01-24 15:35:21 +0100 | [diff] [blame] | 388 | uint32_t qemu_console_get_head(QemuConsole *con); |
Gerd Hoffmann | 6f90f3d | 2014-01-24 17:38:20 +0100 | [diff] [blame] | 389 | QemuUIInfo *qemu_console_get_ui_info(QemuConsole *con); |
Gerd Hoffmann | d4c8533 | 2013-11-28 09:58:18 +0100 | [diff] [blame] | 390 | int qemu_console_get_width(QemuConsole *con, int fallback); |
| 391 | int qemu_console_get_height(QemuConsole *con, int fallback); |
Gerd Hoffmann | 81c0d5a | 2013-03-14 14:27:08 +0100 | [diff] [blame] | 392 | |
aliguori | 2796dae | 2009-01-16 20:23:27 +0000 | [diff] [blame] | 393 | void text_consoles_set_display(DisplayState *ds); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 394 | void console_select(unsigned int index); |
| 395 | void console_color_init(DisplayState *ds); |
Gerd Hoffmann | c78f713 | 2013-03-05 15:24:14 +0100 | [diff] [blame] | 396 | void qemu_console_resize(QemuConsole *con, int width, int height); |
| 397 | void qemu_console_copy(QemuConsole *con, int src_x, int src_y, |
aliguori | 3023f33 | 2009-01-16 19:04:14 +0000 | [diff] [blame] | 398 | int dst_x, int dst_y, int w, int h); |
Gerd Hoffmann | c78f713 | 2013-03-05 15:24:14 +0100 | [diff] [blame] | 399 | DisplaySurface *qemu_console_surface(QemuConsole *con); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 400 | |
Gerd Hoffmann | cd2bc88 | 2015-01-09 11:40:23 +0100 | [diff] [blame] | 401 | /* console-gl.c */ |
| 402 | typedef struct ConsoleGLState ConsoleGLState; |
| 403 | #ifdef CONFIG_OPENGL |
| 404 | ConsoleGLState *console_gl_init_context(void); |
| 405 | void console_gl_fini_context(ConsoleGLState *gls); |
| 406 | bool console_gl_check_format(DisplayChangeListener *dcl, |
| 407 | pixman_format_code_t format); |
| 408 | void surface_gl_create_texture(ConsoleGLState *gls, |
| 409 | DisplaySurface *surface); |
| 410 | void surface_gl_update_texture(ConsoleGLState *gls, |
| 411 | DisplaySurface *surface, |
| 412 | int x, int y, int w, int h); |
| 413 | void surface_gl_render_texture(ConsoleGLState *gls, |
| 414 | DisplaySurface *surface); |
| 415 | void surface_gl_destroy_texture(ConsoleGLState *gls, |
| 416 | DisplaySurface *surface); |
| 417 | void surface_gl_setup_viewport(ConsoleGLState *gls, |
| 418 | DisplaySurface *surface, |
| 419 | int ww, int wh); |
| 420 | #endif |
| 421 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 422 | /* sdl.c */ |
Gerd Hoffmann | 0b71a5d | 2014-11-11 16:54:45 +0100 | [diff] [blame] | 423 | void sdl_display_early_init(int opengl); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 424 | void sdl_display_init(DisplayState *ds, int full_screen, int no_frame); |
| 425 | |
| 426 | /* cocoa.m */ |
| 427 | void cocoa_display_init(DisplayState *ds, int full_screen); |
| 428 | |
| 429 | /* vnc.c */ |
Gerd Hoffmann | 14f7143 | 2014-07-29 12:24:55 +0200 | [diff] [blame] | 430 | void vnc_display_init(const char *id); |
Gerd Hoffmann | 4db1462 | 2014-09-16 12:33:03 +0200 | [diff] [blame] | 431 | void vnc_display_open(const char *id, Error **errp); |
Gerd Hoffmann | 14f7143 | 2014-07-29 12:24:55 +0200 | [diff] [blame] | 432 | void vnc_display_add_client(const char *id, int csock, bool skipauth); |
| 433 | char *vnc_display_local_addr(const char *id); |
Jes Sorensen | 821601e | 2011-03-16 13:33:36 +0100 | [diff] [blame] | 434 | #ifdef CONFIG_VNC |
Gerd Hoffmann | 14f7143 | 2014-07-29 12:24:55 +0200 | [diff] [blame] | 435 | int vnc_display_password(const char *id, const char *password); |
| 436 | int vnc_display_pw_expire(const char *id, time_t expires); |
Markus Armbruster | 70b9433 | 2015-02-13 12:50:26 +0100 | [diff] [blame] | 437 | QemuOpts *vnc_parse(const char *str, Error **errp); |
Markus Armbruster | 28d0de7 | 2015-03-13 13:35:14 +0100 | [diff] [blame] | 438 | int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp); |
Jes Sorensen | 821601e | 2011-03-16 13:33:36 +0100 | [diff] [blame] | 439 | #else |
Gerd Hoffmann | 14f7143 | 2014-07-29 12:24:55 +0200 | [diff] [blame] | 440 | static inline int vnc_display_password(const char *id, const char *password) |
Jes Sorensen | 821601e | 2011-03-16 13:33:36 +0100 | [diff] [blame] | 441 | { |
Jes Sorensen | 821601e | 2011-03-16 13:33:36 +0100 | [diff] [blame] | 442 | return -ENODEV; |
| 443 | } |
Gerd Hoffmann | 14f7143 | 2014-07-29 12:24:55 +0200 | [diff] [blame] | 444 | static inline int vnc_display_pw_expire(const char *id, time_t expires) |
Jes Sorensen | 821601e | 2011-03-16 13:33:36 +0100 | [diff] [blame] | 445 | { |
Jes Sorensen | 821601e | 2011-03-16 13:33:36 +0100 | [diff] [blame] | 446 | return -ENODEV; |
| 447 | }; |
Jes Sorensen | 821601e | 2011-03-16 13:33:36 +0100 | [diff] [blame] | 448 | #endif |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 449 | |
balrog | 4d3b6f6 | 2008-02-10 16:33:14 +0000 | [diff] [blame] | 450 | /* curses.c */ |
| 451 | void curses_display_init(DisplayState *ds, int full_screen); |
| 452 | |
Amos Kong | 1048c88 | 2012-08-31 10:56:25 +0800 | [diff] [blame] | 453 | /* input.c */ |
Wolfgang Bumiller | 64ffbe0 | 2016-01-13 09:09:58 +0100 | [diff] [blame] | 454 | int index_from_key(const char *key, size_t key_length); |
Amos Kong | 1048c88 | 2012-08-31 10:56:25 +0800 | [diff] [blame] | 455 | |
Anthony Liguori | a4ccabc | 2013-02-20 07:43:20 -0600 | [diff] [blame] | 456 | /* gtk.c */ |
Gerd Hoffmann | 97edf3b | 2015-01-20 12:43:28 +0100 | [diff] [blame] | 457 | void early_gtk_display_init(int opengl); |
Jan Kiszka | 881249c | 2014-03-12 08:33:50 +0100 | [diff] [blame] | 458 | void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover); |
Anthony Liguori | a4ccabc | 2013-02-20 07:43:20 -0600 | [diff] [blame] | 459 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 460 | #endif |