summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-03-07 12:27:22 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-03-25 21:36:51 +0000
commitbd8cd58568a845b876861e81af9f13a07f563060 (patch)
tree0f0d544fe88ac9935fb66aa8d1d70eb913ea26b5
parentcda8bd5437bdcfb0918186352e19011960f05de6 (diff)
downloadrockbox-bd8cd58568.tar.gz
rockbox-bd8cd58568.zip
x1000: bootloader: Add button handlers for OF boot
The SPL soon won't be paying attention to buttons, so the bootloader should check them. Change-Id: I2048ca9fd19193f329bebecfefd986760c33fd68
-rw-r--r--bootloader/x1000/main.c37
-rw-r--r--bootloader/x1000/x1000bootloader.h4
2 files changed, 31 insertions, 10 deletions
diff --git a/bootloader/x1000/main.c b/bootloader/x1000/main.c
index 4db172b3f0..b948b030f1 100644
--- a/bootloader/x1000/main.c
+++ b/bootloader/x1000/main.c
@@ -33,6 +33,16 @@
#include "boot-x1000.h"
#include <stdbool.h>
+static int read_btn(void)
+{
+#ifdef HAVE_BUTTON_DATA
+ int bdata;
+ return button_read_device(&bdata);
+#else
+ return button_read_device();
+#endif
+}
+
void main(void)
{
system_init();
@@ -65,17 +75,24 @@ void main(void)
* let's not force them to hold down the recovery key. */
bool recovery_mode = get_boot_flag(BOOT_FLAG_USB_BOOT);
-#ifdef HAVE_BUTTON_DATA
- int bdata;
- if(button_read_device(&bdata) & BL_RECOVERY)
-#else
- if(button_read_device() & BL_RECOVERY)
-#endif
- recovery_mode = true;
+ /* Normal boot - if it fails, we bail to the recovery menu */
+ if(!recovery_mode) {
+ int btn = read_btn();
+ btn &= ~BUTTON_POWER; /* ignore power button */
- /* If boot fails, it will return and continue on below */
- if(!recovery_mode)
- boot_rockbox();
+ if(btn == BL_RECOVERY)
+ recovery_mode = true;
+#if defined(OF_PLAYER_BTN)
+ else if(btn == OF_PLAYER_BTN)
+ boot_of_player();
+#endif
+#if defined(OF_RECOVERY_BTN)
+ else if(btn == OF_RECOVERY_BTN)
+ boot_of_recovery();
+#endif
+ else
+ boot_rockbox();
+ }
/* This function does not return. */
recovery_menu();
diff --git a/bootloader/x1000/x1000bootloader.h b/bootloader/x1000/x1000bootloader.h
index f7acd8a675..1fba9a29a1 100644
--- a/bootloader/x1000/x1000bootloader.h
+++ b/bootloader/x1000/x1000bootloader.h
@@ -54,11 +54,13 @@ struct uimage_header;
* bug may not affect the Q1. */
# define OF_PLAYER_ARGS OF_RECOVERY_ARGS \
" init=/linuxrc ubi.mtd=3 root=ubi0:rootfs ubi.mtd=4 rootfstype=ubifs rw"
+# define OF_PLAYER_BTN BUTTON_PLAY
# define OF_RECOVERY_NAME "FiiO recovery"
# define OF_RECOVERY_ADDR 0x420000
# define OF_RECOVERY_LENGTH (5 * 1024 * 1024)
# define OF_RECOVERY_ARGS \
"mem=64M console=ttyS2"
+# define OF_RECOVERY_BTN (BUTTON_PLAY|BUTTON_VOL_UP)
#elif defined(SHANLING_Q1)
# define BL_RECOVERY BUTTON_NEXT
# define BL_UP BUTTON_PREV
@@ -77,11 +79,13 @@ struct uimage_header;
# define OF_PLAYER_LENGTH (8 * 1024 * 1024)
# define OF_PLAYER_ARGS OF_RECOVERY_ARGS \
" init=/linuxrc ubi.mtd=5 root=ubi0:rootfs ubi.mtd=6 rootfstype=ubifs rw"
+# define OF_PLAYER_BTN BUTTON_PREV
# define OF_RECOVERY_NAME "Shanling recovery"
# define OF_RECOVERY_ADDR 0x940000
# define OF_RECOVERY_LENGTH (10 * 1024 * 1024)
# define OF_RECOVERY_ARGS \
"mem=64M@0x0 no_console_suspend console=ttyS2,115200n8 lpj=5009408 ip=off"
+# define OF_RECOVERY_BTN (BUTTON_PREV|BUTTON_NEXT)
#elif defined(EROS_QN)
# define BL_RECOVERY BUTTON_VOL_UP
# define BL_UP BUTTON_SCROLL_BACK