aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiodrag Dinic <miodrag.dinic@imgtec.com>2015-03-10 13:42:16 +0100
committerBo Hu <bohu@google.com>2015-03-27 16:45:08 +0000
commit1386b9d7e6b0302eeb86731865947566cf414ff9 (patch)
tree7794f0f1627705d3c605d6c24c52e9909e9b37a4
parent7fa62cff5d1bf5067b9f4f92fd63272356a5b9ff (diff)
downloadqemu-android-1386b9d7e6b0302eeb86731865947566cf414ff9.tar.gz
hw/mips/mips_ranchu.c: Trigger goldfish_fb rotation on command
For reference take a look at : 4f7a288 ranchu: trigger goldfish_fb rotation on command Change-Id: Ic4feed7ebf7e4aeb81657fe123d176f68057c129
-rw-r--r--hw/mips/mips_ranchu.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/hw/mips/mips_ranchu.c b/hw/mips/mips_ranchu.c
index 9490502e55..388387b884 100644
--- a/hw/mips/mips_ranchu.c
+++ b/hw/mips/mips_ranchu.c
@@ -18,6 +18,8 @@
#include "elf.h"
#include "hw/intc/goldfish_pic.h"
#include "hw/irq.h"
+#include "hw/display/goldfish_fb.h"
+#include "hw/input/goldfish_sensors.h"
#define PHYS_TO_VIRT(x) ((x) | ~(target_ulong)0x7fffffff)
@@ -101,6 +103,44 @@ struct machine_params {
MIPSCPU *cpu;
} ranchu_params;
+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);
+ goldfish_sensors_set_rotation(ranchu_rotation_state);
+ /* The mapping between QEMU and Android's idea of rotation are
+ reversed */
+ switch (ranchu_rotation_state) {
+ case 0:
+ goldfish_fb_set_rotation(0);
+ graphic_rotate = 0;
+ break;
+ case 1:
+ goldfish_fb_set_rotation(3);
+ graphic_rotate = 90;
+ break;
+ case 2:
+ goldfish_fb_set_rotation(2);
+ graphic_rotate = 180;
+ break;
+ case 3:
+ goldfish_fb_set_rotation(1);
+ graphic_rotate = 270;
+ break;
+ default:
+ g_assert_not_reached();
+ }
+}
+
+static mon_cmd_t rotate_cmd = {
+ .name = "rotate",
+ .args_type = "",
+ .params = "",
+ .help = "rotate the screen by 90 degrees",
+ .mhandler.cmd = android_console_rotate_screen,
+};
+
static void main_cpu_reset(void* opaque1)
{
struct machine_params *opaque = (struct machine_params *)opaque1;
@@ -156,6 +196,7 @@ static void initialize_console_and_adb(void)
int baseport = ANDROID_CONSOLE_BASEPORT;
int tries = MAX_ANDROID_EMULATORS;
CharDriverState *chr;
+ struct Monitor* android_monitor;
for (; tries > 0; tries--, baseport += 2) {
chr = try_to_create_console_chardev(baseport);
@@ -173,7 +214,13 @@ static void initialize_console_and_adb(void)
* This is equivalent to
* "-mon chardev=private-chardev,mode=android-console"
*/
- monitor_init(chr, MONITOR_ANDROID_CONSOLE | MONITOR_USE_READLINE);
+ /* monitor_init(chr, MONITOR_ANDROID_CONSOLE | MONITOR_USE_READLINE); */
+ android_monitor = monitor_init(chr,
+ MONITOR_ANDROID_CONSOLE |
+ MONITOR_USE_READLINE |
+ MONITOR_DYNAMIC_CMDS);
+ monitor_add_command(android_monitor,
+ &rotate_cmd);
printf("console on port %d, ADB on port %d\n", baseport, baseport + 1);
return;