From d24edc605b9b52d3610efbb9cf691c437ea00746 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Thu, 3 Jan 2019 20:46:54 -0500 Subject: Add HAVE_LINEOUT_DETECTION and associated logic This allows targets to automatically switch audio settings when the line out is plugged/unplugged. Only hooked up on the xDuoo X3, but there are other potential users. Change-Id: Ic46a329bc955cca2e2ad0335ca16295eab24ad59 --- firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c') diff --git a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c index be02167a5d..d227255b8a 100644 --- a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c +++ b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c @@ -53,6 +53,13 @@ bool headphones_inserted(void) return (__gpio_get_pin(PIN_PH_DECT) != 0); } +bool lineout_inserted(void) +{ + /* We want to prevent LO being "enabled" if HP is attached + to avoid potential eardrum damage */ + return (__gpio_get_pin(PIN_LO_DECT) == 0) && !headphones_inserted(); +} + void button_init_device(void) { key_val = 0xfff; @@ -72,11 +79,11 @@ void button_init_device(void) __gpio_set_pin(PIN_CHARGE_CON); /* 0.7 A */ __gpio_as_output(PIN_CHARGE_CON); - __gpio_as_input(PIN_LO_DECT); __gpio_as_input(PIN_PH_DECT); + __gpio_disable_pull(PIN_PH_DECT); + __gpio_as_input(PIN_LO_DECT); __gpio_disable_pull(PIN_LO_DECT); - __gpio_disable_pull(PIN_PH_DECT); } bool button_hold(void) -- cgit v1.2.3