The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 1 | #ifndef CONSOLE_H |
| 2 | #define CONSOLE_H |
| 3 | |
| 4 | #include "qemu-char.h" |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 5 | #include "qdict.h" |
| 6 | #include "notify.h" |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 7 | |
| 8 | /* keyboard/mouse support */ |
| 9 | |
| 10 | #define MOUSE_EVENT_LBUTTON 0x01 |
| 11 | #define MOUSE_EVENT_RBUTTON 0x02 |
| 12 | #define MOUSE_EVENT_MBUTTON 0x04 |
David 'Digit' Turner | 17410ee | 2011-05-10 10:55:21 +0200 | [diff] [blame] | 13 | extern int multitouch_enabled; |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 14 | |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 15 | /* identical to the ps/2 keyboard bits */ |
| 16 | #define QEMU_SCROLL_LOCK_LED (1 << 0) |
| 17 | #define QEMU_NUM_LOCK_LED (1 << 1) |
| 18 | #define QEMU_CAPS_LOCK_LED (1 << 2) |
| 19 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 20 | /* in ms */ |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 21 | #ifdef CONFIG_ANDROID |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 22 | #define GUI_REFRESH_INTERVAL (1000/60) /* 60 frames/s is better */ |
| 23 | #else |
| 24 | #define GUI_REFRESH_INTERVAL 30 |
| 25 | #endif |
| 26 | |
David 'Digit' Turner | 17410ee | 2011-05-10 10:55:21 +0200 | [diff] [blame] | 27 | typedef int QEMUDisplayCloseCallback(void *opaque); |
| 28 | void qemu_set_display_close_handler(QEMUDisplayCloseCallback *cb, void *opaque); |
| 29 | int qemu_run_display_close_handler(void); |
| 30 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 31 | typedef void QEMUPutKBDEvent(void *opaque, int keycode); |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 32 | typedef void QEMUPutLEDEvent(void *opaque, int ledstate); |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 33 | typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state); |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 34 | |
| 35 | typedef struct QEMUPutMouseEntry { |
| 36 | QEMUPutMouseEvent *qemu_put_mouse_event; |
| 37 | void *qemu_put_mouse_event_opaque; |
| 38 | int qemu_put_mouse_event_absolute; |
| 39 | char *qemu_put_mouse_event_name; |
| 40 | |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 41 | int index; |
| 42 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 43 | /* used internally by qemu for handling mice */ |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 44 | QTAILQ_ENTRY(QEMUPutMouseEntry) node; |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 45 | } QEMUPutMouseEntry; |
| 46 | |
David 'Digit' Turner | 17410ee | 2011-05-10 10:55:21 +0200 | [diff] [blame] | 47 | typedef struct QEMUPutKBDEntry { |
| 48 | QEMUPutKBDEvent *put_kbd_event; |
| 49 | void *opaque; |
| 50 | |
| 51 | /* used internally by qemu for handling keyboards */ |
| 52 | QTAILQ_ENTRY(QEMUPutKBDEntry) next; |
| 53 | } QEMUPutKBDEntry; |
| 54 | |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 55 | typedef struct QEMUPutLEDEntry { |
| 56 | QEMUPutLEDEvent *put_led; |
| 57 | void *opaque; |
| 58 | QTAILQ_ENTRY(QEMUPutLEDEntry) next; |
| 59 | } QEMUPutLEDEntry; |
| 60 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 61 | void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); |
David 'Digit' Turner | 17410ee | 2011-05-10 10:55:21 +0200 | [diff] [blame] | 62 | void qemu_remove_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 63 | QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, |
| 64 | void *opaque, int absolute, |
| 65 | const char *name); |
| 66 | void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry); |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 67 | void qemu_activate_mouse_event_handler(QEMUPutMouseEntry *entry); |
| 68 | |
| 69 | QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, void *opaque); |
| 70 | void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry); |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 71 | |
| 72 | void kbd_put_keycode(int keycode); |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 73 | void kbd_put_ledstate(int ledstate); |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 74 | void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 75 | |
| 76 | /* Does the current mouse generate absolute events */ |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 77 | int kbd_mouse_is_absolute(void); |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 78 | void qemu_add_mouse_mode_change_notifier(Notifier *notify); |
| 79 | void qemu_remove_mouse_mode_change_notifier(Notifier *notify); |
| 80 | |
| 81 | /* Of all the mice, is there one that generates absolute events */ |
| 82 | int kbd_mouse_has_absolute(void); |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 83 | |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 84 | struct MouseTransformInfo { |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 85 | /* Touchscreen resolution */ |
| 86 | int x; |
| 87 | int y; |
| 88 | /* Calibration values as used/generated by tslib */ |
| 89 | int a[7]; |
| 90 | }; |
| 91 | |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 92 | void do_info_mice_print(Monitor *mon, const QObject *data); |
| 93 | void do_info_mice(Monitor *mon, QObject **ret_data); |
| 94 | void do_mouse_set(Monitor *mon, const QDict *qdict); |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 95 | |
| 96 | /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx |
| 97 | constants) */ |
| 98 | #define QEMU_KEY_ESC1(c) ((c) | 0xe100) |
| 99 | #define QEMU_KEY_BACKSPACE 0x007f |
| 100 | #define QEMU_KEY_UP QEMU_KEY_ESC1('A') |
| 101 | #define QEMU_KEY_DOWN QEMU_KEY_ESC1('B') |
| 102 | #define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C') |
| 103 | #define QEMU_KEY_LEFT QEMU_KEY_ESC1('D') |
| 104 | #define QEMU_KEY_HOME QEMU_KEY_ESC1(1) |
| 105 | #define QEMU_KEY_END QEMU_KEY_ESC1(4) |
| 106 | #define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5) |
| 107 | #define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6) |
| 108 | #define QEMU_KEY_DELETE QEMU_KEY_ESC1(3) |
| 109 | |
| 110 | #define QEMU_KEY_CTRL_UP 0xe400 |
| 111 | #define QEMU_KEY_CTRL_DOWN 0xe401 |
| 112 | #define QEMU_KEY_CTRL_LEFT 0xe402 |
| 113 | #define QEMU_KEY_CTRL_RIGHT 0xe403 |
| 114 | #define QEMU_KEY_CTRL_HOME 0xe404 |
| 115 | #define QEMU_KEY_CTRL_END 0xe405 |
| 116 | #define QEMU_KEY_CTRL_PAGEUP 0xe406 |
| 117 | #define QEMU_KEY_CTRL_PAGEDOWN 0xe407 |
| 118 | |
| 119 | void kbd_put_keysym(int keysym); |
| 120 | |
| 121 | /* consoles */ |
| 122 | |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 123 | #define QEMU_BIG_ENDIAN_FLAG 0x01 |
| 124 | #define QEMU_ALLOCATED_FLAG 0x02 |
David 'Digit' Turner | dd9cb79 | 2010-05-10 23:52:07 -0700 | [diff] [blame] | 125 | #define QEMU_REALPIXELS_FLAG 0x04 |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 126 | |
| 127 | struct PixelFormat { |
| 128 | uint8_t bits_per_pixel; |
| 129 | uint8_t bytes_per_pixel; |
| 130 | uint8_t depth; /* color depth in bits */ |
| 131 | uint32_t rmask, gmask, bmask, amask; |
| 132 | uint8_t rshift, gshift, bshift, ashift; |
| 133 | uint8_t rmax, gmax, bmax, amax; |
| 134 | uint8_t rbits, gbits, bbits, abits; |
| 135 | }; |
| 136 | |
| 137 | struct DisplaySurface { |
| 138 | uint8_t flags; |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 139 | int width; |
| 140 | int height; |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 141 | int linesize; /* bytes per line */ |
| 142 | uint8_t *data; |
| 143 | |
| 144 | struct PixelFormat pf; |
| 145 | }; |
| 146 | |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 147 | /* cursor data format is 32bit RGBA */ |
| 148 | typedef struct QEMUCursor { |
| 149 | int width, height; |
| 150 | int hot_x, hot_y; |
| 151 | int refcount; |
| 152 | uint32_t data[]; |
| 153 | } QEMUCursor; |
| 154 | |
| 155 | QEMUCursor *cursor_alloc(int width, int height); |
| 156 | void cursor_get(QEMUCursor *c); |
| 157 | void cursor_put(QEMUCursor *c); |
| 158 | QEMUCursor *cursor_builtin_hidden(void); |
| 159 | QEMUCursor *cursor_builtin_left_ptr(void); |
| 160 | void cursor_print_ascii_art(QEMUCursor *c, const char *prefix); |
| 161 | int cursor_get_mono_bpl(QEMUCursor *c); |
| 162 | void cursor_set_mono(QEMUCursor *c, |
| 163 | uint32_t foreground, uint32_t background, uint8_t *image, |
| 164 | int transparent, uint8_t *mask); |
| 165 | void cursor_get_mono_image(QEMUCursor *c, int foreground, uint8_t *mask); |
| 166 | void cursor_get_mono_mask(QEMUCursor *c, int transparent, uint8_t *mask); |
| 167 | |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 168 | struct DisplayChangeListener { |
| 169 | int idle; |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 170 | uint64_t gui_timer_interval; |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 171 | |
| 172 | void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h); |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 173 | void (*dpy_resize)(struct DisplayState *s); |
| 174 | void (*dpy_setdata)(struct DisplayState *s); |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 175 | void (*dpy_refresh)(struct DisplayState *s); |
| 176 | void (*dpy_copy)(struct DisplayState *s, int src_x, int src_y, |
| 177 | int dst_x, int dst_y, int w, int h); |
| 178 | void (*dpy_fill)(struct DisplayState *s, int x, int y, |
| 179 | int w, int h, uint32_t c); |
| 180 | void (*dpy_text_cursor)(struct DisplayState *s, int x, int y); |
David 'Digit' Turner | 17410ee | 2011-05-10 10:55:21 +0200 | [diff] [blame] | 181 | #ifdef CONFIG_GLES2 |
| 182 | void (*dpy_updatecaption)(void); |
| 183 | #endif |
| 184 | #ifdef CONFIG_SKINNING |
| 185 | void (*dpy_enablezoom)(struct DisplayState *s, int width, int height); |
| 186 | void (*dpy_getresolution)(int *width, int *height); |
| 187 | #endif |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 188 | struct DisplayChangeListener *next; |
| 189 | }; |
| 190 | |
David 'Digit' Turner | 7a5ee57 | 2011-02-02 15:58:45 +0100 | [diff] [blame] | 191 | #ifdef CONFIG_ANDROID |
| 192 | /* The problem with DisplayChangeListener is that the callbacks can't |
| 193 | * differentiate between different DisplayChangeListeners. Instead of |
| 194 | * modifying the type above, which is going to generate conflicts with |
| 195 | * upstream changes, we define our own listener type here. |
| 196 | */ |
| 197 | typedef struct DisplayUpdateListener { |
| 198 | void* opaque; |
| 199 | void (*dpy_update)(void* opaque, int x, int y, int w, int h); |
| 200 | struct DisplayUpdateListener *next; |
| 201 | } DisplayUpdateListener; |
| 202 | #endif |
| 203 | |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 204 | struct DisplayAllocator { |
| 205 | DisplaySurface* (*create_displaysurface)(int width, int height); |
| 206 | DisplaySurface* (*resize_displaysurface)(DisplaySurface *surface, int width, int height); |
| 207 | void (*free_displaysurface)(DisplaySurface *surface); |
| 208 | }; |
| 209 | |
| 210 | struct DisplayState { |
| 211 | struct DisplaySurface *surface; |
| 212 | void *opaque; |
| 213 | struct QEMUTimer *gui_timer; |
| 214 | |
| 215 | struct DisplayAllocator* allocator; |
| 216 | struct DisplayChangeListener* listeners; |
David 'Digit' Turner | 7a5ee57 | 2011-02-02 15:58:45 +0100 | [diff] [blame] | 217 | #ifdef CONFIG_ANDROID |
| 218 | struct DisplayUpdateListener* update_listeners; |
| 219 | #endif |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 220 | void (*mouse_set)(int x, int y, int on); |
David Turner | f52506f | 2010-09-10 16:11:22 +0200 | [diff] [blame] | 221 | void (*cursor_define)(QEMUCursor *cursor); |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 222 | |
| 223 | struct DisplayState *next; |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 224 | }; |
| 225 | |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 226 | void register_displaystate(DisplayState *ds); |
| 227 | DisplayState *get_displaystate(void); |
| 228 | DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp, |
| 229 | int linesize, uint8_t *data); |
| 230 | PixelFormat qemu_different_endianness_pixelformat(int bpp); |
| 231 | PixelFormat qemu_default_pixelformat(int bpp); |
| 232 | |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 233 | DisplayAllocator *register_displayallocator(DisplayState *ds, DisplayAllocator *da); |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 234 | |
| 235 | static inline DisplaySurface* qemu_create_displaysurface(DisplayState *ds, int width, int height) |
| 236 | { |
David 'Digit' Turner | 94702b0 | 2011-01-20 02:46:33 +0100 | [diff] [blame] | 237 | return ds->allocator->create_displaysurface(width, height); |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | static inline DisplaySurface* qemu_resize_displaysurface(DisplayState *ds, int width, int height) |
| 241 | { |
| 242 | return ds->allocator->resize_displaysurface(ds->surface, width, height); |
| 243 | } |
| 244 | |
| 245 | static inline void qemu_free_displaysurface(DisplayState *ds) |
| 246 | { |
| 247 | ds->allocator->free_displaysurface(ds->surface); |
| 248 | } |
| 249 | |
| 250 | static inline int is_surface_bgr(DisplaySurface *surface) |
| 251 | { |
| 252 | if (surface->pf.bits_per_pixel == 32 && surface->pf.rshift == 0) |
| 253 | return 1; |
| 254 | else |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | static inline int is_buffer_shared(DisplaySurface *surface) |
| 259 | { |
David Turner | f52506f | 2010-09-10 16:11:22 +0200 | [diff] [blame] | 260 | return (!(surface->flags & QEMU_ALLOCATED_FLAG) && |
| 261 | !(surface->flags & QEMU_REALPIXELS_FLAG)); |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | static inline void register_displaychangelistener(DisplayState *ds, DisplayChangeListener *dcl) |
| 265 | { |
| 266 | dcl->next = ds->listeners; |
| 267 | ds->listeners = dcl; |
| 268 | } |
| 269 | |
David 'Digit' Turner | 7a5ee57 | 2011-02-02 15:58:45 +0100 | [diff] [blame] | 270 | #ifdef CONFIG_ANDROID |
| 271 | static inline void register_displayupdatelistener(DisplayState *ds, DisplayUpdateListener *dul) |
| 272 | { |
| 273 | dul->next = ds->update_listeners; |
| 274 | ds->update_listeners = dul; |
| 275 | } |
| 276 | |
| 277 | void unregister_displayupdatelistener(DisplayState *ds, DisplayUpdateListener *dul); |
David 'Digit' Turner | 7a5ee57 | 2011-02-02 15:58:45 +0100 | [diff] [blame] | 278 | #endif |
| 279 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 280 | static inline void dpy_update(DisplayState *s, int x, int y, int w, int h) |
| 281 | { |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 282 | struct DisplayChangeListener *dcl = s->listeners; |
| 283 | while (dcl != NULL) { |
| 284 | dcl->dpy_update(s, x, y, w, h); |
| 285 | dcl = dcl->next; |
| 286 | } |
David 'Digit' Turner | 7a5ee57 | 2011-02-02 15:58:45 +0100 | [diff] [blame] | 287 | #ifdef CONFIG_ANDROID |
| 288 | DisplayUpdateListener* dul = s->update_listeners; |
| 289 | while (dul != NULL) { |
| 290 | dul->dpy_update(dul->opaque, x, y, w, h); |
| 291 | dul = dul->next; |
| 292 | } |
| 293 | #endif |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 294 | } |
| 295 | |
David 'Digit' Turner | 17410ee | 2011-05-10 10:55:21 +0200 | [diff] [blame] | 296 | #ifdef CONFIG_GLES2 |
| 297 | static inline void dpy_updatecaption(DisplayState *s) |
| 298 | { |
| 299 | struct DisplayChangeListener *dcl = s->listeners; |
| 300 | while (dcl != NULL) { |
| 301 | if(dcl->dpy_updatecaption != NULL) |
| 302 | { |
| 303 | dcl->dpy_updatecaption(); |
| 304 | } |
| 305 | dcl = dcl->next; |
| 306 | } |
| 307 | } |
| 308 | #endif |
| 309 | |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 310 | static inline void dpy_resize(DisplayState *s) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 311 | { |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 312 | struct DisplayChangeListener *dcl = s->listeners; |
| 313 | while (dcl != NULL) { |
| 314 | dcl->dpy_resize(s); |
| 315 | dcl = dcl->next; |
| 316 | } |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 317 | } |
| 318 | |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 319 | static inline void dpy_setdata(DisplayState *s) |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 320 | { |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 321 | struct DisplayChangeListener *dcl = s->listeners; |
| 322 | while (dcl != NULL) { |
| 323 | if (dcl->dpy_setdata) dcl->dpy_setdata(s); |
| 324 | dcl = dcl->next; |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | static inline void dpy_refresh(DisplayState *s) |
| 329 | { |
| 330 | struct DisplayChangeListener *dcl = s->listeners; |
| 331 | while (dcl != NULL) { |
| 332 | if (dcl->dpy_refresh) dcl->dpy_refresh(s); |
| 333 | dcl = dcl->next; |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | static inline void dpy_copy(struct DisplayState *s, int src_x, int src_y, |
| 338 | int dst_x, int dst_y, int w, int h) { |
| 339 | struct DisplayChangeListener *dcl = s->listeners; |
| 340 | while (dcl != NULL) { |
| 341 | if (dcl->dpy_copy) |
| 342 | dcl->dpy_copy(s, src_x, src_y, dst_x, dst_y, w, h); |
| 343 | else /* TODO */ |
| 344 | dcl->dpy_update(s, dst_x, dst_y, w, h); |
| 345 | dcl = dcl->next; |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | static inline void dpy_fill(struct DisplayState *s, int x, int y, |
| 350 | int w, int h, uint32_t c) { |
| 351 | struct DisplayChangeListener *dcl = s->listeners; |
| 352 | while (dcl != NULL) { |
| 353 | if (dcl->dpy_fill) dcl->dpy_fill(s, x, y, w, h, c); |
| 354 | dcl = dcl->next; |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | static inline void dpy_cursor(struct DisplayState *s, int x, int y) { |
| 359 | struct DisplayChangeListener *dcl = s->listeners; |
| 360 | while (dcl != NULL) { |
| 361 | if (dcl->dpy_text_cursor) dcl->dpy_text_cursor(s, x, y); |
| 362 | dcl = dcl->next; |
| 363 | } |
| 364 | } |
| 365 | |
David 'Digit' Turner | 17410ee | 2011-05-10 10:55:21 +0200 | [diff] [blame] | 366 | #ifdef CONFIG_SKINNING |
| 367 | static inline void dpy_enablezoom(struct DisplayState *s, int width, int height) |
| 368 | { |
| 369 | struct DisplayChangeListener *dcl = s->listeners; |
| 370 | while (dcl != NULL) { |
| 371 | if (dcl->dpy_enablezoom) dcl->dpy_enablezoom(s, width, height); |
| 372 | dcl = dcl->next; |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | static inline void dpy_getresolution(struct DisplayState *s, int *width, int *height) |
| 377 | { |
| 378 | struct DisplayChangeListener *dcl = s->listeners; |
| 379 | while (dcl != NULL) { |
| 380 | if (dcl->dpy_getresolution) dcl->dpy_getresolution(width, height); |
| 381 | dcl = dcl->next; |
| 382 | } |
| 383 | } |
| 384 | #endif |
| 385 | |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 386 | static inline int ds_get_linesize(DisplayState *ds) |
| 387 | { |
| 388 | return ds->surface->linesize; |
| 389 | } |
| 390 | |
| 391 | static inline uint8_t* ds_get_data(DisplayState *ds) |
| 392 | { |
| 393 | return ds->surface->data; |
| 394 | } |
| 395 | |
| 396 | static inline int ds_get_width(DisplayState *ds) |
| 397 | { |
| 398 | return ds->surface->width; |
| 399 | } |
| 400 | |
| 401 | static inline int ds_get_height(DisplayState *ds) |
| 402 | { |
| 403 | return ds->surface->height; |
| 404 | } |
| 405 | |
| 406 | static inline int ds_get_bits_per_pixel(DisplayState *ds) |
| 407 | { |
| 408 | return ds->surface->pf.bits_per_pixel; |
| 409 | } |
| 410 | |
| 411 | static inline int ds_get_bytes_per_pixel(DisplayState *ds) |
| 412 | { |
| 413 | return ds->surface->pf.bytes_per_pixel; |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | typedef unsigned long console_ch_t; |
| 417 | static inline void console_write_ch(console_ch_t *dest, uint32_t ch) |
| 418 | { |
David Turner | 025c32f | 2010-09-10 14:52:42 +0200 | [diff] [blame] | 419 | if (!(ch & 0xff)) |
| 420 | ch |= ' '; |
David 'Digit' Turner | 17410ee | 2011-05-10 10:55:21 +0200 | [diff] [blame] | 421 | *dest = ch; |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | typedef void (*vga_hw_update_ptr)(void *); |
| 425 | typedef void (*vga_hw_invalidate_ptr)(void *); |
| 426 | typedef void (*vga_hw_screen_dump_ptr)(void *, const char *); |
| 427 | typedef void (*vga_hw_text_update_ptr)(void *, console_ch_t *); |
| 428 | |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 429 | DisplayState *graphic_console_init(vga_hw_update_ptr update, |
| 430 | vga_hw_invalidate_ptr invalidate, |
| 431 | vga_hw_screen_dump_ptr screen_dump, |
| 432 | vga_hw_text_update_ptr text_update, |
| 433 | void *opaque); |
| 434 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 435 | void vga_hw_update(void); |
| 436 | void vga_hw_invalidate(void); |
| 437 | void vga_hw_screen_dump(const char *filename); |
| 438 | void vga_hw_text_update(console_ch_t *chardata); |
| 439 | |
| 440 | int is_graphic_console(void); |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 441 | int is_fixedsize_console(void); |
David Turner | f52506f | 2010-09-10 16:11:22 +0200 | [diff] [blame] | 442 | CharDriverState *text_console_init(QemuOpts *opts); |
| 443 | CharDriverState* text_console_init_compat(const char *label, const char *p); |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 444 | void text_consoles_set_display(DisplayState *ds); |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 445 | void console_select(unsigned int index); |
| 446 | void console_color_init(DisplayState *ds); |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 447 | void qemu_console_resize(DisplayState *ds, int width, int height); |
| 448 | void qemu_console_copy(DisplayState *ds, int src_x, int src_y, |
| 449 | int dst_x, int dst_y, int w, int h); |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 450 | |
| 451 | /* sdl.c */ |
| 452 | void sdl_display_init(DisplayState *ds, int full_screen, int no_frame); |
| 453 | |
| 454 | /* cocoa.m */ |
| 455 | void cocoa_display_init(DisplayState *ds, int full_screen); |
| 456 | |
| 457 | /* vnc.c */ |
| 458 | void vnc_display_init(DisplayState *ds); |
| 459 | void vnc_display_close(DisplayState *ds); |
| 460 | int vnc_display_open(DisplayState *ds, const char *display); |
| 461 | int vnc_display_password(DisplayState *ds, const char *password); |
David 'Digit' Turner | 5d8f37a | 2009-09-14 14:32:27 -0700 | [diff] [blame] | 462 | void do_info_vnc(Monitor *mon); |
| 463 | char *vnc_display_local_addr(DisplayState *ds); |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 464 | |
| 465 | /* curses.c */ |
| 466 | void curses_display_init(DisplayState *ds, int full_screen); |
| 467 | |
David Turner | f52506f | 2010-09-10 16:11:22 +0200 | [diff] [blame] | 468 | #ifdef CONFIG_ANDROID |
David 'Digit' Turner | 94702b0 | 2011-01-20 02:46:33 +0100 | [diff] [blame] | 469 | void android_display_reset(DisplayState* ds, int width, int height, int bitspp); |
David Turner | f52506f | 2010-09-10 16:11:22 +0200 | [diff] [blame] | 470 | #endif |
| 471 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 472 | #endif |