From b030bf5885dc5e018dd38eacbb294f1321f2b400 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Thu, 1 Oct 2020 14:06:48 -0400 Subject: xduoox3ii/x20: Proper lineout detection and volume mangling. hotplugging hp and lineout works, without blowing out eardrums. Change-Id: I2df5c7a618bb2d1d77d416548d45dff9cfc619db --- firmware/target/hosted/xduoo/button-xduoo.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'firmware/target/hosted/xduoo/button-xduoo.c') 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) -- cgit v1.2.3