blob: 42a5cb3c40f4e99cb8c53b6801e6961b61f28785 [file] [log] [blame]
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +02001/*
2 * QEMU graphical console
3 *
4 * Copyright (c) 2004 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24#include "qemu-common.h"
25#include "console.h"
26#include "qemu-timer.h"
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +020027#include "android/utils/system.h"
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +020028
29//#define DEBUG_CONSOLE
30#define DEFAULT_BACKSCROLL 512
31#define MAX_CONSOLES 12
32
33#define QEMU_RGBA(r, g, b, a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
34#define QEMU_RGB(r, g, b) QEMU_RGBA(r, g, b, 0xff)
35
36typedef struct TextAttributes {
37 uint8_t fgcol:4;
38 uint8_t bgcol:4;
39 uint8_t bold:1;
40 uint8_t uline:1;
41 uint8_t blink:1;
42 uint8_t invers:1;
43 uint8_t unvisible:1;
44} TextAttributes;
45
46typedef struct TextCell {
47 uint8_t ch;
48 TextAttributes t_attrib;
49} TextCell;
50
51#define MAX_ESC_PARAMS 3
52
53enum TTYState {
54 TTY_STATE_NORM,
55 TTY_STATE_ESC,
56 TTY_STATE_CSI,
57};
58
59typedef struct QEMUFIFO {
60 uint8_t *buf;
61 int buf_size;
62 int count, wptr, rptr;
63} QEMUFIFO;
64
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +020065typedef enum {
66 GRAPHIC_CONSOLE,
67 TEXT_CONSOLE,
68 TEXT_CONSOLE_FIXED_SIZE
69} console_type_t;
70
71/* ??? This is mis-named.
72 It is used for both text and graphical consoles. */
73struct TextConsole {
74 console_type_t console_type;
75 DisplayState *ds;
76 /* Graphic console state. */
77 vga_hw_update_ptr hw_update;
78 vga_hw_invalidate_ptr hw_invalidate;
79 vga_hw_screen_dump_ptr hw_screen_dump;
80 vga_hw_text_update_ptr hw_text_update;
81 void *hw;
82
83 int g_width, g_height;
84 int width;
85 int height;
86 int total_height;
87 int backscroll_height;
88 int x, y;
89 int x_saved, y_saved;
90 int y_displayed;
91 int y_base;
92 TextAttributes t_attrib_default; /* default text attributes */
93 TextAttributes t_attrib; /* currently active text attributes */
94 TextCell *cells;
95 int text_x[2], text_y[2], cursor_invalidate;
96
97 int update_x0;
98 int update_y0;
99 int update_x1;
100 int update_y1;
101
102 enum TTYState state;
103 int esc_params[MAX_ESC_PARAMS];
104 int nb_esc_params;
105
106 /* fifo for key pressed */
107 QEMUFIFO out_fifo;
108 uint8_t out_fifo_buf[16];
109 QEMUTimer *kbd_timer;
110};
111
112static DisplayState *display_state;
113static TextConsole *active_console;
114static TextConsole *consoles[MAX_CONSOLES];
115static int nb_consoles = 0;
116
117#ifdef CONFIG_ANDROID
118/* Graphic console width, height and bits per pixel.
119 * These default values can be changed with the "-android-gui" option.
120 */
121int android_display_width = 640;
122int android_display_height = 480;
123int android_display_bpp = 32;
124#endif
125
126void vga_hw_update(void)
127{
128 if (active_console && active_console->hw_update)
129 active_console->hw_update(active_console->hw);
130}
131
132void vga_hw_invalidate(void)
133{
134 if (active_console && active_console->hw_invalidate)
135 active_console->hw_invalidate(active_console->hw);
136}
137
138void vga_hw_screen_dump(const char *filename)
139{
140 TextConsole *previous_active_console;
141
142 previous_active_console = active_console;
143 active_console = consoles[0];
144 /* There is currently no way of specifying which screen we want to dump,
145 so always dump the first one. */
146 if (consoles[0]->hw_screen_dump)
147 consoles[0]->hw_screen_dump(consoles[0]->hw, filename);
148 active_console = previous_active_console;
149}
150
151void vga_hw_text_update(console_ch_t *chardata)
152{
153 if (active_console && active_console->hw_text_update)
154 active_console->hw_text_update(active_console->hw, chardata);
155}
156
157/* convert a RGBA color to a color index usable in graphic primitives */
158static unsigned int vga_get_color(DisplayState *ds, unsigned int rgba)
159{
160 unsigned int r, g, b, color;
161
162 switch(ds_get_bits_per_pixel(ds)) {
163#if 0
164 case 8:
165 r = (rgba >> 16) & 0xff;
166 g = (rgba >> 8) & 0xff;
167 b = (rgba) & 0xff;
168 color = (rgb_to_index[r] * 6 * 6) +
169 (rgb_to_index[g] * 6) +
170 (rgb_to_index[b]);
171 break;
172#endif
173 case 15:
174 r = (rgba >> 16) & 0xff;
175 g = (rgba >> 8) & 0xff;
176 b = (rgba) & 0xff;
177 color = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
178 break;
179 case 16:
180 r = (rgba >> 16) & 0xff;
181 g = (rgba >> 8) & 0xff;
182 b = (rgba) & 0xff;
183 color = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
184 break;
185 case 32:
186 default:
187 color = rgba;
188 break;
189 }
190 return color;
191}
192
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200193/***********************************************************/
194/* basic char display */
195
196#define FONT_HEIGHT 16
197#define FONT_WIDTH 8
198
199#include "vgafont.h"
200
201#define cbswap_32(__x) \
202((uint32_t)( \
203 (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
204 (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \
205 (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
206 (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) ))
207
208#ifdef HOST_WORDS_BIGENDIAN
209#define PAT(x) x
210#else
211#define PAT(x) cbswap_32(x)
212#endif
213
214static const uint32_t dmask16[16] = {
215 PAT(0x00000000),
216 PAT(0x000000ff),
217 PAT(0x0000ff00),
218 PAT(0x0000ffff),
219 PAT(0x00ff0000),
220 PAT(0x00ff00ff),
221 PAT(0x00ffff00),
222 PAT(0x00ffffff),
223 PAT(0xff000000),
224 PAT(0xff0000ff),
225 PAT(0xff00ff00),
226 PAT(0xff00ffff),
227 PAT(0xffff0000),
228 PAT(0xffff00ff),
229 PAT(0xffffff00),
230 PAT(0xffffffff),
231};
232
233static const uint32_t dmask4[4] = {
234 PAT(0x00000000),
235 PAT(0x0000ffff),
236 PAT(0xffff0000),
237 PAT(0xffffffff),
238};
239
240static uint32_t color_table[2][8];
241
242enum color_names {
243 COLOR_BLACK = 0,
244 COLOR_RED = 1,
245 COLOR_GREEN = 2,
246 COLOR_YELLOW = 3,
247 COLOR_BLUE = 4,
248 COLOR_MAGENTA = 5,
249 COLOR_CYAN = 6,
250 COLOR_WHITE = 7
251};
252
253static const uint32_t color_table_rgb[2][8] = {
254 { /* dark */
255 QEMU_RGB(0x00, 0x00, 0x00), /* black */
256 QEMU_RGB(0xaa, 0x00, 0x00), /* red */
257 QEMU_RGB(0x00, 0xaa, 0x00), /* green */
258 QEMU_RGB(0xaa, 0xaa, 0x00), /* yellow */
259 QEMU_RGB(0x00, 0x00, 0xaa), /* blue */
260 QEMU_RGB(0xaa, 0x00, 0xaa), /* magenta */
261 QEMU_RGB(0x00, 0xaa, 0xaa), /* cyan */
262 QEMU_RGB(0xaa, 0xaa, 0xaa), /* white */
263 },
264 { /* bright */
265 QEMU_RGB(0x00, 0x00, 0x00), /* black */
266 QEMU_RGB(0xff, 0x00, 0x00), /* red */
267 QEMU_RGB(0x00, 0xff, 0x00), /* green */
268 QEMU_RGB(0xff, 0xff, 0x00), /* yellow */
269 QEMU_RGB(0x00, 0x00, 0xff), /* blue */
270 QEMU_RGB(0xff, 0x00, 0xff), /* magenta */
271 QEMU_RGB(0x00, 0xff, 0xff), /* cyan */
272 QEMU_RGB(0xff, 0xff, 0xff), /* white */
273 }
274};
275
276static inline unsigned int col_expand(DisplayState *ds, unsigned int col)
277{
278 switch(ds_get_bits_per_pixel(ds)) {
279 case 8:
280 col |= col << 8;
281 col |= col << 16;
282 break;
283 case 15:
284 case 16:
285 col |= col << 16;
286 break;
287 default:
288 break;
289 }
290
291 return col;
292}
293#ifdef DEBUG_CONSOLE
294static void console_print_text_attributes(TextAttributes *t_attrib, char ch)
295{
296 if (t_attrib->bold) {
297 printf("b");
298 } else {
299 printf(" ");
300 }
301 if (t_attrib->uline) {
302 printf("u");
303 } else {
304 printf(" ");
305 }
306 if (t_attrib->blink) {
307 printf("l");
308 } else {
309 printf(" ");
310 }
311 if (t_attrib->invers) {
312 printf("i");
313 } else {
314 printf(" ");
315 }
316 if (t_attrib->unvisible) {
317 printf("n");
318 } else {
319 printf(" ");
320 }
321
322 printf(" fg: %d bg: %d ch:'%2X' '%c'\n", t_attrib->fgcol, t_attrib->bgcol, ch, ch);
323}
324#endif
325
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200326void console_select(unsigned int index)
327{
328 TextConsole *s;
329
330 if (index >= MAX_CONSOLES)
331 return;
332 active_console->g_width = ds_get_width(active_console->ds);
333 active_console->g_height = ds_get_height(active_console->ds);
334 s = consoles[index];
335 if (s) {
336 DisplayState *ds = s->ds;
337 active_console = s;
338 if (ds_get_bits_per_pixel(s->ds)) {
339 ds->surface = qemu_resize_displaysurface(ds, s->g_width, s->g_height);
340 } else {
341 s->ds->surface->width = s->width;
342 s->ds->surface->height = s->height;
343 }
344 dpy_resize(s->ds);
345 vga_hw_invalidate();
346 }
347}
348
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200349static TextConsole *get_graphic_console(DisplayState *ds)
350{
351 int i;
352 TextConsole *s;
353 for (i = 0; i < nb_consoles; i++) {
354 s = consoles[i];
355 if (s->console_type == GRAPHIC_CONSOLE && s->ds == ds)
356 return s;
357 }
358 return NULL;
359}
360
361static TextConsole *new_console(DisplayState *ds, console_type_t console_type)
362{
363 TextConsole *s;
364 int i;
365
366 if (nb_consoles >= MAX_CONSOLES)
367 return NULL;
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200368 ANEW0(s);
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200369 if (!active_console || ((active_console->console_type != GRAPHIC_CONSOLE) &&
370 (console_type == GRAPHIC_CONSOLE))) {
371 active_console = s;
372 }
373 s->ds = ds;
374 s->console_type = console_type;
375 if (console_type != GRAPHIC_CONSOLE) {
376 consoles[nb_consoles++] = s;
377 } else {
378 /* HACK: Put graphical consoles before text consoles. */
379 for (i = nb_consoles; i > 0; i--) {
380 if (consoles[i - 1]->console_type == GRAPHIC_CONSOLE)
381 break;
382 consoles[i] = consoles[i - 1];
383 }
384 consoles[i] = s;
385 nb_consoles++;
386 }
387 return s;
388}
389
390static DisplaySurface* defaultallocator_create_displaysurface(int width, int height)
391{
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200392 DisplaySurface *surface;
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200393
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200394 ANEW0(surface);
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200395 surface->width = width;
396 surface->height = height;
397 surface->linesize = width * 4;
398 surface->pf = qemu_default_pixelformat(32);
399#ifdef HOST_WORDS_BIGENDIAN
400 surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
401#else
402 surface->flags = QEMU_ALLOCATED_FLAG;
403#endif
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200404 surface->data = (uint8_t*) android_alloc0(surface->linesize * surface->height);
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200405
406 return surface;
407}
408
409static DisplaySurface* defaultallocator_resize_displaysurface(DisplaySurface *surface,
410 int width, int height)
411{
412 surface->width = width;
413 surface->height = height;
414 surface->linesize = width * 4;
415 surface->pf = qemu_default_pixelformat(32);
416 if (surface->flags & QEMU_ALLOCATED_FLAG)
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200417 surface->data = (uint8_t*) android_realloc(surface->data, surface->linesize * surface->height);
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200418 else
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200419 surface->data = (uint8_t*) android_alloc(surface->linesize * surface->height);
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200420#ifdef HOST_WORDS_BIGENDIAN
421 surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
422#else
423 surface->flags = QEMU_ALLOCATED_FLAG;
424#endif
425
426 return surface;
427}
428
429DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
430 int linesize, uint8_t *data)
431{
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200432 DisplaySurface *surface;
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200433
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200434 ANEW0(surface);
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200435 surface->width = width;
436 surface->height = height;
437 surface->linesize = linesize;
438 surface->pf = qemu_default_pixelformat(bpp);
439#ifdef HOST_WORDS_BIGENDIAN
440 surface->flags = QEMU_BIG_ENDIAN_FLAG;
441#endif
442 surface->data = data;
443
444 return surface;
445}
446
447static void defaultallocator_free_displaysurface(DisplaySurface *surface)
448{
449 if (surface == NULL)
450 return;
451 if (surface->flags & QEMU_ALLOCATED_FLAG)
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200452 AFREE(surface->data);
453 AFREE(surface);
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200454}
455
456static struct DisplayAllocator default_allocator = {
457 defaultallocator_create_displaysurface,
458 defaultallocator_resize_displaysurface,
459 defaultallocator_free_displaysurface
460};
461
462static void dumb_display_init(void)
463{
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200464 DisplayState *ds;
465 ANEW0(ds);
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200466 ds->allocator = &default_allocator;
467 ds->surface = qemu_create_displaysurface(ds, 640, 480);
468 register_displaystate(ds);
469}
470
471/***********************************************************/
472/* register display */
473
474void register_displaystate(DisplayState *ds)
475{
476 DisplayState **s;
477 s = &display_state;
478 while (*s != NULL)
479 s = &(*s)->next;
480 ds->next = NULL;
481 *s = ds;
482}
483
484DisplayState *get_displaystate(void)
485{
486 if (!display_state) {
487 dumb_display_init ();
488 }
489 return display_state;
490}
491
492DisplayAllocator *register_displayallocator(DisplayState *ds, DisplayAllocator *da)
493{
494 if(ds->allocator == &default_allocator) {
495 DisplaySurface *surf;
496 surf = da->create_displaysurface(ds_get_width(ds), ds_get_height(ds));
497 defaultallocator_free_displaysurface(ds->surface);
498 ds->surface = surf;
499 ds->allocator = da;
500 }
501 return ds->allocator;
502}
503
504DisplayState *graphic_console_init(vga_hw_update_ptr update,
505 vga_hw_invalidate_ptr invalidate,
506 vga_hw_screen_dump_ptr screen_dump,
507 vga_hw_text_update_ptr text_update,
508 void *opaque)
509{
510 TextConsole *s;
511 DisplayState *ds;
512
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200513 ANEW0(ds);
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200514 ds->allocator = &default_allocator;
515#ifdef CONFIG_ANDROID
516 ds->surface = qemu_create_displaysurface(ds, android_display_width, android_display_height);
517#else
518 ds->surface = qemu_create_displaysurface(ds, 640, 480);
519#endif
520
521 s = new_console(ds, GRAPHIC_CONSOLE);
522 if (s == NULL) {
523 qemu_free_displaysurface(ds);
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200524 AFREE(ds);
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200525 return NULL;
526 }
527 s->hw_update = update;
528 s->hw_invalidate = invalidate;
529 s->hw_screen_dump = screen_dump;
530 s->hw_text_update = text_update;
531 s->hw = opaque;
532
533 register_displaystate(ds);
534 return ds;
535}
536
537int is_graphic_console(void)
538{
539 return active_console && active_console->console_type == GRAPHIC_CONSOLE;
540}
541
542int is_fixedsize_console(void)
543{
544 return active_console && active_console->console_type != TEXT_CONSOLE;
545}
546
547void console_color_init(DisplayState *ds)
548{
549 int i, j;
550 for (j = 0; j < 2; j++) {
551 for (i = 0; i < 8; i++) {
552 color_table[j][i] = col_expand(ds,
553 vga_get_color(ds, color_table_rgb[j][i]));
554 }
555 }
556}
557
558void qemu_console_resize(DisplayState *ds, int width, int height)
559{
560 TextConsole *s = get_graphic_console(ds);
561 if (!s) return;
562
563 s->g_width = width;
564 s->g_height = height;
565 if (is_graphic_console()) {
566 ds->surface = qemu_resize_displaysurface(ds, width, height);
567 dpy_resize(ds);
568 }
569}
570
571void qemu_console_copy(DisplayState *ds, int src_x, int src_y,
572 int dst_x, int dst_y, int w, int h)
573{
574 if (is_graphic_console()) {
575 dpy_copy(ds, src_x, src_y, dst_x, dst_y, w, h);
576 }
577}
578
579PixelFormat qemu_different_endianness_pixelformat(int bpp)
580{
581 PixelFormat pf;
582
583 memset(&pf, 0x00, sizeof(PixelFormat));
584
585 pf.bits_per_pixel = bpp;
586 pf.bytes_per_pixel = bpp / 8;
587 pf.depth = bpp == 32 ? 24 : bpp;
588
589 switch (bpp) {
590 case 24:
591 pf.rmask = 0x000000FF;
592 pf.gmask = 0x0000FF00;
593 pf.bmask = 0x00FF0000;
594 pf.rmax = 255;
595 pf.gmax = 255;
596 pf.bmax = 255;
597 pf.rshift = 0;
598 pf.gshift = 8;
599 pf.bshift = 16;
600 pf.rbits = 8;
601 pf.gbits = 8;
602 pf.bbits = 8;
603 break;
604 case 32:
605 pf.rmask = 0x0000FF00;
606 pf.gmask = 0x00FF0000;
607 pf.bmask = 0xFF000000;
608 pf.amask = 0x00000000;
609 pf.amax = 255;
610 pf.rmax = 255;
611 pf.gmax = 255;
612 pf.bmax = 255;
613 pf.ashift = 0;
614 pf.rshift = 8;
615 pf.gshift = 16;
616 pf.bshift = 24;
617 pf.rbits = 8;
618 pf.gbits = 8;
619 pf.bbits = 8;
620 pf.abits = 8;
621 break;
622 default:
623 break;
624 }
625 return pf;
626}
627
628PixelFormat qemu_default_pixelformat(int bpp)
629{
630 PixelFormat pf;
631
632 memset(&pf, 0x00, sizeof(PixelFormat));
633
634 pf.bits_per_pixel = bpp;
635 pf.bytes_per_pixel = bpp / 8;
636 pf.depth = bpp == 32 ? 24 : bpp;
637
638 switch (bpp) {
639 case 15:
640 pf.bits_per_pixel = 16;
641 pf.bytes_per_pixel = 2;
642 pf.rmask = 0x00007c00;
643 pf.gmask = 0x000003E0;
644 pf.bmask = 0x0000001F;
645 pf.rmax = 31;
646 pf.gmax = 31;
647 pf.bmax = 31;
648 pf.rshift = 10;
649 pf.gshift = 5;
650 pf.bshift = 0;
651 pf.rbits = 5;
652 pf.gbits = 5;
653 pf.bbits = 5;
654 break;
655 case 16:
656 pf.rmask = 0x0000F800;
657 pf.gmask = 0x000007E0;
658 pf.bmask = 0x0000001F;
659 pf.rmax = 31;
660 pf.gmax = 63;
661 pf.bmax = 31;
662 pf.rshift = 11;
663 pf.gshift = 5;
664 pf.bshift = 0;
665 pf.rbits = 5;
666 pf.gbits = 6;
667 pf.bbits = 5;
668 break;
669 case 24:
670 pf.rmask = 0x00FF0000;
671 pf.gmask = 0x0000FF00;
672 pf.bmask = 0x000000FF;
673 pf.rmax = 255;
674 pf.gmax = 255;
675 pf.bmax = 255;
676 pf.rshift = 16;
677 pf.gshift = 8;
678 pf.bshift = 0;
679 pf.rbits = 8;
680 pf.gbits = 8;
681 pf.bbits = 8;
682 case 32:
683 pf.rmask = 0x00FF0000;
684 pf.gmask = 0x0000FF00;
685 pf.bmask = 0x000000FF;
686 pf.amax = 255;
687 pf.rmax = 255;
688 pf.gmax = 255;
689 pf.bmax = 255;
690 pf.ashift = 24;
691 pf.rshift = 16;
692 pf.gshift = 8;
693 pf.bshift = 0;
694 pf.rbits = 8;
695 pf.gbits = 8;
696 pf.bbits = 8;
697 pf.abits = 8;
698 break;
699 default:
700 break;
701 }
702 return pf;
703}
704
705#ifdef CONFIG_ANDROID
706void
707android_display_init_from(int width, int height, int rotation, int bpp)
708{
David 'Digit' Turner18fe86e2010-10-19 08:07:11 +0200709 DisplayState *ds;
710 ANEW0(ds);
David 'Digit' Turnerf59442f2010-10-08 16:22:10 +0200711 ds->allocator = &default_allocator;
712 ds->surface = qemu_create_displaysurface(ds, width, height);
713 register_displaystate(ds);
714}
715#endif