aboutsummaryrefslogtreecommitdiffstats
path: root/vl-android.c
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 /vl-android.c
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
Diffstat (limited to 'vl-android.c')
-rw-r--r--vl-android.c86
1 files changed, 84 insertions, 2 deletions
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;