summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2020-09-17 14:53:29 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2020-09-18 00:22:52 +0000
commit2df3a5b04c40d548391c69c18780fefd420fac02 (patch)
tree48f56c70a30c688e9360a03eff836de7fba9f73b
parent4fa945d810a574c96503834d1c9324d02f17fc4b (diff)
downloadrockbox-2df3a5b.tar.gz
rockbox-2df3a5b.zip
Headphone / lineout pause/resume #FS13237
Allow Lineout to behave like headphone port in regards to plug/unplug pause/resume Change-Id: I9cb2c9c40e0bdf3bf7e1e272164acd343f6b3850
-rw-r--r--apps/audio_path.c13
-rw-r--r--apps/misc.c33
-rw-r--r--apps/root_menu.c15
-rw-r--r--apps/settings.h2
-rw-r--r--firmware/drivers/button.c2
-rw-r--r--firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c4
6 files changed, 56 insertions, 13 deletions
diff --git a/apps/audio_path.c b/apps/audio_path.c
index bb73052a95..f908017bc3 100644
--- a/apps/audio_path.c
+++ b/apps/audio_path.c
@@ -169,10 +169,19 @@ int audio_get_spdif_sample_rate(void)
#ifdef HAVE_SPEAKER
void audio_enable_speaker(int mode)
{
-#ifdef HAVE_HEADPHONE_DETECTION
+#if defined(HAVE_HEADPHONE_DETECTION) || defined(HAVE_LINEOUT_DETECTION)
/* if needed, query jack state */
if(mode == 2)
- mode = !headphones_inserted();
+ {
+#ifdef HAVE_HEADPHONE_DETECTION
+ if (headphones_inserted())
+ mode = 0;
+#endif
+#ifdef HAVE_LINEOUT_DETECTION
+ if (lineout_inserted())
+ mode = 0;
+#endif
+ }
#endif
/* treat any nonzero value as enable */
audiohw_enable_speaker(mode);
diff --git a/apps/misc.c b/apps/misc.c
index 2d60ecca49..d255eaf766 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -498,7 +498,7 @@ void car_adapter_mode_init(void)
#ifdef HAVE_HEADPHONE_DETECTION
static void hp_unplug_change(bool inserted)
{
- static bool headphone_caused_pause = false;
+ static bool headphone_caused_pause = true;
if (global_settings.unplug_mode)
{
@@ -526,7 +526,7 @@ static void hp_unplug_change(bool inserted)
audio_enable_speaker(global_settings.speaker_mode);
#endif
}
-#endif
+#endif /*HAVE_HEADPHONE_DETECTION*/
#ifdef HAVE_LINEOUT_DETECTION
static void lo_unplug_change(bool inserted)
@@ -534,11 +534,32 @@ static void lo_unplug_change(bool inserted)
#ifdef HAVE_LINEOUT_POWEROFF
lineout_set(inserted);
#else
- (void)inserted;
- audiohw_set_lineout_volume(0,0);
-#endif
+ audiohw_set_lineout_volume(0,0); /*hp vol re-set by this function as well*/
+ static bool lineout_caused_pause = true;
+
+ if (global_settings.unplug_mode)
+ {
+ int audio_stat = audio_status();
+ if (inserted)
+ {
+ backlight_on();
+ if ((audio_stat & AUDIO_STATUS_PLAY) &&
+ lineout_caused_pause &&
+ global_settings.unplug_mode > 1 )
+ unpause_action(true, true);
+ lineout_caused_pause = false;
+ } else {
+ if ((audio_stat & AUDIO_STATUS_PLAY) &&
+ !(audio_stat & AUDIO_STATUS_PAUSE))
+ {
+ lineout_caused_pause = true;
+ pause_action(false, false);
+ }
+ }
+ }
+#endif /*HAVE_LINEOUT_POWEROFF*/
}
-#endif
+#endif /*HAVE_LINEOUT_DETECTION*/
long default_event_handler_ex(long event, void (*callback)(void *), void *parameter)
{
diff --git a/apps/root_menu.c b/apps/root_menu.c
index 2a8662a170..77a092018a 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -767,11 +767,20 @@ void root_menu(void)
}
#endif /* HAVE_RTC_ALARM */
+#if defined(HAVE_HEADPHONE_DETECTION) || defined(HAVE_LINEOUT_DETECTION)
+ if (next_screen == GO_TO_WPS && global_settings.unplug_autoresume)
+ {
+ next_screen = GO_TO_ROOT;
#ifdef HAVE_HEADPHONE_DETECTION
- if (next_screen == GO_TO_WPS &&
- (global_settings.unplug_autoresume && !headphones_inserted() ))
- next_screen = GO_TO_ROOT;
+ if (headphones_inserted())
+ next_screen = GO_TO_WPS;
+#endif
+#ifdef HAVE_LINEOUT_DETECTION
+ if (lineout_inserted())
+ next_screen = GO_TO_WPS;
#endif
+ }
+#endif /*(HAVE_HEADPHONE_DETECTION) || (HAVE_LINEOUT_DETECTION)*/
while (true)
{
diff --git a/apps/settings.h b/apps/settings.h
index 405a31d052..ec66553660 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -448,7 +448,7 @@ struct user_settings
#endif
int pause_rewind; /* time in s to rewind when pausing */
-#ifdef HAVE_HEADPHONE_DETECTION
+#if defined(HAVE_HEADPHONE_DETECTION) || defined(HAVE_LINEOUT_DETECTION)
int unplug_mode; /* pause on headphone unplug */
bool unplug_autoresume; /* disable auto-resume if no phones */
#endif
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index f2408d891e..58a9ab0b94 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -112,6 +112,7 @@ static int hp_detect_callback(struct timeout *tmo)
queue_remove_from_head(&button_queue, id);
queue_post(&button_queue, id, 0);
return 0;
+ /*misc.c:hp_unplug_change*/
}
#endif
@@ -125,6 +126,7 @@ static int lo_detect_callback(struct timeout *tmo)
queue_remove_from_head(&button_queue, id);
queue_post(&button_queue, id, 0);
return 0;
+ /*misc.c:lo_unplug_change*/
}
#endif
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 0db1bada9b..ebf3c64b47 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
@@ -89,10 +89,12 @@ void button_init_device(void)
__gpio_as_output(PIN_CHARGE_CON);
__gpio_as_input(PIN_PH_DECT);
+ __gpio_enable_pull(PIN_PH_DECT);
/*__gpio_disable_pull(PIN_PH_DECT); // Spurious Detections */
__gpio_as_input(PIN_LO_DECT);
- __gpio_disable_pull(PIN_LO_DECT);
+ __gpio_enable_pull(PIN_LO_DECT);
+ /*__gpio_disable_pull(PIN_LO_DECT); // Spurious Detections */
}
bool button_hold(void)