aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Chtchetkine <vchtchetkine@google.com>2010-07-30 09:16:41 -0700
committerVladimir Chtchetkine <vchtchetkine@google.com>2010-08-02 09:49:50 -0700
commitdd50f7d7d919dfa2a2cebd383635ba74c10e3777 (patch)
tree9f5aa1ee2da3bc1af50791cd8caa8d124c939fcc
parent66ce9b1ec72bff7b3186c9fbdd2a7a5d96d146bd (diff)
downloadexternal_qemu-dd50f7d7d919dfa2a2cebd383635ba74c10e3777.zip
external_qemu-dd50f7d7d919dfa2a2cebd383635ba74c10e3777.tar.gz
external_qemu-dd50f7d7d919dfa2a2cebd383635ba74c10e3777.tar.bz2
Added -android-gui command line option to qemu-android
Change-Id: I9fd9170f2b2e3ad7d80071888f7da2ead54c21cf
-rw-r--r--console.c21
-rw-r--r--qemu-options.hx4
-rw-r--r--vl-android.c86
3 files changed, 102 insertions, 9 deletions
diff --git a/console.c b/console.c
index d55e0fd..7563d18 100644
--- a/console.c
+++ b/console.c
@@ -158,6 +158,13 @@ static TextConsole *active_console;
static TextConsole *consoles[MAX_CONSOLES];
static int nb_consoles = 0;
+/* Graphic console width, height and bits per pixel.
+ * These default values can be changed with the "-android-gui" option.
+ */
+int android_display_width = 640;
+int android_display_height = 480;
+int android_display_bpp = 32;
+
void vga_hw_update(void)
{
if (active_console && active_console->hw_update)
@@ -1275,8 +1282,8 @@ DisplayState *graphic_console_init(vga_hw_update_ptr update,
DisplayState *ds;
ds = (DisplayState *) qemu_mallocz(sizeof(DisplayState));
- ds->allocator = &default_allocator;
- ds->surface = qemu_create_displaysurface(ds, 640, 480);
+ ds->allocator = &default_allocator;
+ ds->surface = qemu_create_displaysurface(ds, android_display_width, android_display_height);
s = new_console(ds, GRAPHIC_CONSOLE);
if (s == NULL) {
@@ -1557,8 +1564,8 @@ DisplaySurface* defaultallocator_create_displaysurface(int width, int height)
surface->width = width;
surface->height = height;
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
+ surface->pf = qemu_default_pixelformat(android_display_bpp);
+ surface->linesize = width * surface->pf.bytes_per_pixel;
#ifdef HOST_WORDS_BIGENDIAN
surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
#else
@@ -1570,12 +1577,12 @@ DisplaySurface* defaultallocator_create_displaysurface(int width, int height)
}
DisplaySurface* defaultallocator_resize_displaysurface(DisplaySurface *surface,
- int width, int height)
+ int width, int height)
{
surface->width = width;
surface->height = height;
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
+ surface->pf = qemu_default_pixelformat(android_display_bpp);
+ surface->linesize = width * surface->pf.bytes_per_pixel;
if (surface->flags & QEMU_ALLOCATED_FLAG)
surface->data = (uint8_t*) qemu_realloc(surface->data, surface->linesize * surface->height);
else
diff --git a/qemu-options.hx b/qemu-options.hx
index ed89bc5..41a16e7 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1623,4 +1623,8 @@ DEF("charmap", HAS_ARG, QEMU_OPTION_charmap, \
"-charmap <file>"
" use specific key character map\n")
+DEF("android-gui", HAS_ARG, QEMU_OPTION_android_gui, \
+ "-android-gui width=<width>,height=<height>,bpp=<bits per pixel>"
+ " width, height, and bits per pixel for the graphic console\n")
+
#endif
diff --git a/vl-android.c b/vl-android.c
index ea40275..c09d8a7 100644
--- a/vl-android.c
+++ b/vl-android.c
@@ -337,6 +337,13 @@ extern char* op_http_proxy;
// Path to the file containing specific key character map.
char* op_charmap_file = NULL;
+/* Framebuffer dimensions, passed with -android-gui option. */
+char* android_op_gui = NULL;
+
+extern int android_display_width;
+extern int android_display_height;
+extern int android_display_bpp;
+
extern void dprint( const char* format, ... );
#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
@@ -423,6 +430,42 @@ static void default_ioport_writel(void *opaque, uint32_t address, uint32_t data)
#endif
}
+/* Parses -android-gui command line option, extracting width, height and bits
+ * per pixel parameters for the GUI console used in this session of the
+ * emulator. -android-gui option contains exactly three comma-separated positive
+ * integer numbers in strict order: width goes first, width goes next, and bits
+ * per pixel goes third. This routine verifies that format and return 0 if all
+ * three numbers were extracted, or -1 if string format was incorrect for that
+ * option. Note that this routine does not verify that extracted values are
+ * correct!
+ */
+static int
+parse_androig_gui_option(const char* op, int* width, int* height, int* bpp)
+{
+ char val[128];
+
+ if (get_param_value(val, 128, "width", op)) {
+ *width = strtol(val, NULL, 0);
+ } else {
+ fprintf(stderr, "option -android-gui is missing width parameter\n");
+ return -1;
+ }
+ if (get_param_value(val, 128, "height", op)) {
+ *height = strtol(val, NULL, 0);
+ } else {
+ fprintf(stderr, "option -android-gui is missing height parameter\n");
+ return -1;
+ }
+ if (get_param_value(val, 128, "bpp", op)) {
+ *bpp = strtol(val, NULL, 0);
+ } else {
+ fprintf(stderr, "option -android-gui is missing bpp parameter\n");
+ return -1;
+ }
+
+ return 0;
+}
+
/***********************************************************/
void hw_error(const char *fmt, ...)
{
@@ -2859,6 +2902,15 @@ static void dumb_display_init(void)
register_displaystate(ds);
}
+static void
+android_display_init_from(int width, int height, int rotation, int bpp)
+{
+ DisplayState *ds = qemu_mallocz(sizeof(DisplayState));
+ ds->allocator = &default_allocator;
+ ds->surface = qemu_create_displaysurface(ds, width, height);
+ register_displaystate(ds);
+}
+
/***********************************************************/
/* I/O handling */
@@ -5746,6 +5798,10 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_charmap:
op_charmap_file = (char*)optarg;
break;
+
+ case QEMU_OPTION_android_gui:
+ android_op_gui = (char*)optarg;
+ break;
}
}
}
@@ -6169,8 +6225,34 @@ int main(int argc, char **argv, char **envp)
}
}
- if (!display_state)
- dumb_display_init();
+ if (!display_state) {
+ if (android_op_gui) {
+ /* Initialize display from the command line parameters. */
+ if (parse_androig_gui_option(android_op_gui,
+ &android_display_width,
+ &android_display_height,
+ &android_display_bpp)) {
+ exit(1);
+ }
+ android_display_init_from(android_display_width,
+ android_display_height, 0,
+ android_display_bpp);
+ } else {
+ dumb_display_init();
+ }
+ } else if (android_op_gui) {
+ /* Resize display from the command line parameters. */
+ if (parse_androig_gui_option(android_op_gui,
+ &android_display_width,
+ &android_display_height,
+ &android_display_bpp)) {
+ exit(1);
+ }
+ display_state->surface = qemu_resize_displaysurface(display_state,
+ android_display_width,
+ android_display_height);
+ }
+
/* just use the first displaystate for the moment */
ds = display_state;