diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-10-01 14:06:48 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-10-01 15:41:30 -0400 |
commit | b030bf5885dc5e018dd38eacbb294f1321f2b400 (patch) | |
tree | 4d9f06c7928fa44d225477b5551c69c29617a98a /firmware/target/hosted/xduoo/button-xduoo.c | |
parent | 6d47dc9a8860a17a9e630b8662f33df63011bad9 (diff) | |
download | rockbox-b030bf5885dc5e018dd38eacbb294f1321f2b400.tar.gz 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/hosted/xduoo/button-xduoo.c')
-rw-r--r-- | firmware/target/hosted/xduoo/button-xduoo.c | 23 |
1 files changed, 7 insertions, 16 deletions
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) | |||
166 | 166 | ||
167 | bool headphones_inserted(void) | 167 | bool headphones_inserted(void) |
168 | { | 168 | { |
169 | int status = 0; | 169 | int ps = xduoo_get_outputs(); |
170 | const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state"; | ||
171 | const char * const sysfs_hs_switch = "/sys/class/switch/headset/state"; | ||
172 | #ifdef XDUOO_X20 | ||
173 | const char * const sysfs_bal_switch = "/sys/class/switch/balance/state"; | ||
174 | #endif | ||
175 | |||
176 | sysfs_get_int(sysfs_lo_switch, &status); | ||
177 | if (status) return true; | ||
178 | 170 | ||
179 | sysfs_get_int(sysfs_hs_switch, &status); | 171 | return (ps == 2 || ps == 3); |
180 | if (status) return true; | 172 | } |
181 | 173 | ||
182 | #ifdef XDUOO_X20 | 174 | bool lineout_inserted(void) |
183 | sysfs_get_int(sysfs_bal_switch, &status); | 175 | { |
184 | if (status) return true; | 176 | int ps = xduoo_get_outputs(); |
185 | #endif | ||
186 | 177 | ||
187 | return false; | 178 | return (ps == 1); |
188 | } | 179 | } |
189 | 180 | ||
190 | void button_close_device(void) | 181 | void button_close_device(void) |