aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2014-12-18 15:15:08 +0000
committerAlex Bennée <alex.bennee@linaro.org>2014-12-27 14:16:37 +0000
commit4f7a2887aacfcdbba27a8bc2caceb98fc3b060cf (patch)
tree457a1ac0cd96932bc9eb1adb45ed3f24df98ec41
parent98b2c93b214333865272d74c6a4f753ce546efda (diff)
ranchu: trigger goldfish_fb rotation on command
It seems QEMU is turning the display around in a counter-clockwise maner, but Android understands degrees of rotations as clockwise rotations. Tweaking the input values and the actual rotation of the framebuffer accordingly makes things work as expected. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> [CD: rotation mapping fix] Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
-rw-r--r--hw/arm/ranchu.c19
-rw-r--r--hw/display/goldfish_fb.c18
-rw-r--r--include/hw/display/goldfish_fb.h23
3 files changed, 60 insertions, 0 deletions
diff --git a/hw/arm/ranchu.c b/hw/arm/ranchu.c
index 167a28050..f483094da 100644
--- a/hw/arm/ranchu.c
+++ b/hw/arm/ranchu.c
@@ -39,6 +39,7 @@
#include "sysemu/char.h"
#include "monitor/monitor.h"
#include "hw/misc/android_pipe.h"
+#include "hw/display/goldfish_fb.h"
/* Maximum number of emulators that can run at once (affects how
* far through the TCP port space from 5554 we will scan to find
@@ -470,6 +471,24 @@ static int ranchu_rotation_state = 0; /* 0-3 */
static void android_console_rotate_screen(Monitor *mon, const QDict *qdict)
{
ranchu_rotation_state = ((ranchu_rotation_state + 1) % 4);
+ /* The mapping between QEMU and Android's idea of rotation are
+ reversed */
+ switch (ranchu_rotation_state) {
+ case 0:
+ goldfish_fb_set_rotation(0);
+ break;
+ case 1:
+ goldfish_fb_set_rotation(3);
+ break;
+ case 2:
+ goldfish_fb_set_rotation(2);
+ break;
+ case 3:
+ goldfish_fb_set_rotation(1);
+ break;
+ default:
+ g_assert_not_reached();
+ }
}
static mon_cmd_t rotate_cmd = {
diff --git a/hw/display/goldfish_fb.c b/hw/display/goldfish_fb.c
index f590bc1fd..9083dd5f0 100644
--- a/hw/display/goldfish_fb.c
+++ b/hw/display/goldfish_fb.c
@@ -15,6 +15,7 @@
#include "ui/console.h"
#include "ui/pixel_ops.h"
#include "trace.h"
+#include "hw/display/goldfish_fb.h"
#define BITS 8
#include "goldfish_fb_template.h"
@@ -65,6 +66,21 @@ struct goldfish_fb_state {
#define GOLDFISH_FB_SAVE_VERSION 3
+/* Console hooks */
+void goldfish_fb_set_rotation(int rotation)
+{
+ DeviceState *dev = qdev_find_recursive(sysbus_get_default(), TYPE_GOLDFISH_FB);
+ if (dev) {
+ struct goldfish_fb_state *s = GOLDFISH_FB(dev);
+ DisplaySurface *ds = qemu_console_surface(s->con);
+ s->rotation = rotation;
+ s->need_update = 1;
+ qemu_console_resize(s->con, surface_height(ds), surface_width(ds));
+ } else {
+ fprintf(stderr,"%s: unable to find FB dev\n", __func__);
+ }
+}
+
static void goldfish_fb_save(QEMUFile* f, void* opaque)
{
struct goldfish_fb_state* s = opaque;
@@ -395,6 +411,8 @@ static int goldfish_fb_init(SysBusDevice *sbdev)
DeviceState *dev = DEVICE(sbdev);
struct goldfish_fb_state *s = GOLDFISH_FB(dev);
+ dev->id = g_strdup(TYPE_GOLDFISH_FB);
+
sysbus_init_irq(sbdev, &s->irq);
s->con = graphic_console_init(dev, 0, &goldfish_fb_ops, s);
diff --git a/include/hw/display/goldfish_fb.h b/include/hw/display/goldfish_fb.h
new file mode 100644
index 000000000..0de06fe2f
--- /dev/null
+++ b/include/hw/display/goldfish_fb.h
@@ -0,0 +1,23 @@
+/*
+ * Goldfish Framebuffer public declarations.
+ *
+ * Copyright (C) 2014 Alex Bennée <alex.bennee@linaor.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef HW_DISPLAY_GOLDFISH_FB_H
+#define HW_DISPLAY_GOLDFISH_FB_H
+
+void goldfish_fb_set_rotation(int rotation);
+
+#endif /* HW_DISPLAY_GOLDFISH_FB_H */