All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [RFC][PATCH 2/2] MusicPal: Add specific -hold-button option
Date: Sat, 17 May 2008 15:34:57 +0200	[thread overview]
Message-ID: <482EDF01.5040001@web.de> (raw)

MusicPal's U-Boot is able to start in a special mode (firmware recovery)
in case one of the control buttons is pressed during power-up. As with
QEMU there is no chance to achieve this manually (without delaying the
power-up with sleep()), this patch adds a MusicPal-specific command line
option -hold-button. This option that takes button codes and simulates
that the provided ones are pressed on power-up.

Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
---
 hw/musicpal.c |   49 ++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 7 deletions(-)

Index: b/hw/musicpal.c
===================================================================
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -62,6 +62,7 @@ static uint32_t gpio_in_state = 0xffffff
 static uint32_t gpio_isr;
 static uint32_t gpio_out_state;
 static ram_addr_t sram_off;
+static int powerup_hold_button;
 
 /* Address conversion helpers */
 static void *target2host_addr(uint32_t addr)
@@ -1344,6 +1345,12 @@ static void musicpal_key_event(void *opa
     uint32_t event = 0;
     static int kbd_extended;
 
+    if (powerup_hold_button) {
+        powerup_hold_button = 0;
+        gpio_in_state |= MP_GPIO_BTN_FAVORITS | MP_GPIO_BTN_VOLUME |
+                         MP_GPIO_BTN_NAVIGATION | MP_GPIO_BTN_MENU;
+    }
+
     if (keycode == KEYCODE_EXTENDED) {
         kbd_extended = 1;
         return;
@@ -1491,12 +1498,6 @@ static void musicpal_init(ram_addr_t ram
 
     qemu_add_kbd_event_handler(musicpal_key_event, pic[MP_GPIO_IRQ]);
 
-    /*
-     * Wait a bit to catch menu button during U-Boot start-up
-     * (to trigger emergency update).
-     */
-    sleep(1);
-
     mv88w8618_eth_init(&nd_table[0], MP_ETH_BASE, pic[MP_ETH_IRQ]);
 
     mixer_i2c = musicpal_audio_init(MP_AUDIO_BASE, pic[MP_AUDIO_IRQ]);
@@ -1508,9 +1509,43 @@ static void musicpal_init(ram_addr_t ram
     arm_load_kernel(env, &musicpal_binfo);
 }
 
+int musicpal_parse_option(const char *optname, const char *optarg)
+{
+    if (strcmp(optname, "-hold-button") == 0) {
+        while (optarg && *optarg != 0) {
+            switch (*optarg) {
+            case 'f':
+                gpio_in_state &= ~MP_GPIO_BTN_FAVORITS;
+                break;
+            case 'm':
+                gpio_in_state &= ~MP_GPIO_BTN_MENU;
+                break;
+            case 'n':
+                gpio_in_state &= ~MP_GPIO_BTN_NAVIGATION;
+                break;
+            case 'v':
+                gpio_in_state &= ~MP_GPIO_BTN_VOLUME;
+                break;
+            default:
+                fprintf(stderr, "Invalid button specified: %c\n", *optarg);
+                exit(1);
+            }
+            optarg++;
+            powerup_hold_button = 1;
+        }
+        return 1;
+    }
+    return -1;
+}
+
 QEMUMachine musicpal_machine = {
     "musicpal",
     "Marvell 88w8618 / MusicPal (ARM926EJ-S)",
     musicpal_init,
-    MP_RAM_DEFAULT_SIZE + MP_SRAM_SIZE + MP_FLASH_SIZE_MAX + RAMSIZE_FIXED
+    MP_RAM_DEFAULT_SIZE + MP_SRAM_SIZE + MP_FLASH_SIZE_MAX + RAMSIZE_FIXED,
+    "-hold-button [f][m][n][v]\n"
+    "                Hold favorits (f), menu (m), navigation (n), or volume(v)\n"
+    "                button on power-up to trigger special services. The button\n"
+    "                is released on next keystroke.\n",
+    musicpal_parse_option
 };

                 reply	other threads:[~2008-05-17 13:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=482EDF01.5040001@web.de \
    --to=jan.kiszka@web.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.