summaryrefslogtreecommitdiffstats
path: root/firmware/target
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-10-01 14:06:48 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-10-01 15:41:30 -0400
commitb030bf5885dc5e018dd38eacbb294f1321f2b400 (patch)
tree4d9f06c7928fa44d225477b5551c69c29617a98a /firmware/target
parent6d47dc9a8860a17a9e630b8662f33df63011bad9 (diff)
downloadrockbox-b030bf5885dc5e018dd38eacbb294f1321f2b400.tar.gz
rockbox-b030bf5885dc5e018dd38eacbb294f1321f2b400.tar.bz2
rockbox-b030bf5885dc5e018dd38eacbb294f1321f2b400.zip
xduoox3ii/x20: Proper lineout detection and volume mangling.
hotplugging hp and lineout works, without blowing out eardrums. Change-Id: I2df5c7a618bb2d1d77d416548d45dff9cfc619db
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/hosted/agptek/debug-agptek.c7
-rw-r--r--firmware/target/hosted/alsa-controls.c10
-rw-r--r--firmware/target/hosted/xduoo/button-xduoo.c23
3 files changed, 19 insertions, 21 deletions
diff --git a/firmware/target/hosted/agptek/debug-agptek.c b/firmware/target/hosted/agptek/debug-agptek.c
index b4fcb4246b..7f794a7073 100644
--- a/firmware/target/hosted/agptek/debug-agptek.c
+++ b/firmware/target/hosted/agptek/debug-agptek.c
@@ -41,6 +41,13 @@ bool dbg_hw_info(void)
line = 0;
lcd_putsf(0, line++, "pcm srate: %d", pcm_alsa_get_rate());
+#ifdef HAVE_HEADPHONE_DETECTION
+ lcd_putsf(0, line++, "hp: %d", headphones_inserted());
+#endif
+#ifdef HAVE_LINEOUT_DETECTION
+ lcd_putsf(0, line++, "lo: %d", lineout_inserted());
+#endif
+
btn = button_read_device();
lcd_update();
diff --git a/firmware/target/hosted/alsa-controls.c b/firmware/target/hosted/alsa-controls.c
index 19de7aea44..f4914aa216 100644
--- a/firmware/target/hosted/alsa-controls.c
+++ b/firmware/target/hosted/alsa-controls.c
@@ -1,10 +1,10 @@
/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
+ * \/ \/ \/ \/ \/
*
* Copyright (C) 2016 Amaury Pouly
*
diff --git a/firmware/target/hosted/xduoo/button-xduoo.c b/firmware/target/hosted/xduoo/button-xduoo.c
index 9fd1392b89..03bb7bbfc9 100644
--- a/firmware/target/hosted/xduoo/button-xduoo.c
+++ b/firmware/target/hosted/xduoo/button-xduoo.c
@@ -166,25 +166,16 @@ int button_read_device(void)
bool headphones_inserted(void)
{
- int status = 0;
- const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state";
- const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
-#ifdef XDUOO_X20
- const char * const sysfs_bal_switch = "/sys/class/switch/balance/state";
-#endif
-
- sysfs_get_int(sysfs_lo_switch, &status);
- if (status) return true;
+ int ps = xduoo_get_outputs();
- sysfs_get_int(sysfs_hs_switch, &status);
- if (status) return true;
+ return (ps == 2 || ps == 3);
+}
-#ifdef XDUOO_X20
- sysfs_get_int(sysfs_bal_switch, &status);
- if (status) return true;
-#endif
+bool lineout_inserted(void)
+{
+ int ps = xduoo_get_outputs();
- return false;
+ return (ps == 1);
}
void button_close_device(void)