diff options
author | William Wilgus <wilgus.william@gmail.com> | 2020-09-17 14:53:29 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2020-09-18 00:22:52 +0000 |
commit | 2df3a5b04c40d548391c69c18780fefd420fac02 (patch) | |
tree | 48f56c70a30c688e9360a03eff836de7fba9f73b | |
parent | 4fa945d810a574c96503834d1c9324d02f17fc4b (diff) | |
download | rockbox-2df3a5b04c40d548391c69c18780fefd420fac02.tar.gz rockbox-2df3a5b04c40d548391c69c18780fefd420fac02.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.c | 13 | ||||
-rw-r--r-- | apps/misc.c | 33 | ||||
-rw-r--r-- | apps/root_menu.c | 15 | ||||
-rw-r--r-- | apps/settings.h | 2 | ||||
-rw-r--r-- | firmware/drivers/button.c | 2 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c | 4 |
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) | |||
169 | #ifdef HAVE_SPEAKER | 169 | #ifdef HAVE_SPEAKER |
170 | void audio_enable_speaker(int mode) | 170 | void audio_enable_speaker(int mode) |
171 | { | 171 | { |
172 | #ifdef HAVE_HEADPHONE_DETECTION | 172 | #if defined(HAVE_HEADPHONE_DETECTION) || defined(HAVE_LINEOUT_DETECTION) |
173 | /* if needed, query jack state */ | 173 | /* if needed, query jack state */ |
174 | if(mode == 2) | 174 | if(mode == 2) |
175 | mode = !headphones_inserted(); | 175 | { |
176 | #ifdef HAVE_HEADPHONE_DETECTION | ||
177 | if (headphones_inserted()) | ||
178 | mode = 0; | ||
179 | #endif | ||
180 | #ifdef HAVE_LINEOUT_DETECTION | ||
181 | if (lineout_inserted()) | ||
182 | mode = 0; | ||
183 | #endif | ||
184 | } | ||
176 | #endif | 185 | #endif |
177 | /* treat any nonzero value as enable */ | 186 | /* treat any nonzero value as enable */ |
178 | audiohw_enable_speaker(mode); | 187 | 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) | |||
498 | #ifdef HAVE_HEADPHONE_DETECTION | 498 | #ifdef HAVE_HEADPHONE_DETECTION |
499 | static void hp_unplug_change(bool inserted) | 499 | static void hp_unplug_change(bool inserted) |
500 | { | 500 | { |
501 | static bool headphone_caused_pause = false; | 501 | static bool headphone_caused_pause = true; |
502 | 502 | ||
503 | if (global_settings.unplug_mode) | 503 | if (global_settings.unplug_mode) |
504 | { | 504 | { |
@@ -526,7 +526,7 @@ static void hp_unplug_change(bool inserted) | |||
526 | audio_enable_speaker(global_settings.speaker_mode); | 526 | audio_enable_speaker(global_settings.speaker_mode); |
527 | #endif | 527 | #endif |
528 | } | 528 | } |
529 | #endif | 529 | #endif /*HAVE_HEADPHONE_DETECTION*/ |
530 | 530 | ||
531 | #ifdef HAVE_LINEOUT_DETECTION | 531 | #ifdef HAVE_LINEOUT_DETECTION |
532 | static void lo_unplug_change(bool inserted) | 532 | static void lo_unplug_change(bool inserted) |
@@ -534,11 +534,32 @@ static void lo_unplug_change(bool inserted) | |||
534 | #ifdef HAVE_LINEOUT_POWEROFF | 534 | #ifdef HAVE_LINEOUT_POWEROFF |
535 | lineout_set(inserted); | 535 | lineout_set(inserted); |
536 | #else | 536 | #else |
537 | (void)inserted; | 537 | audiohw_set_lineout_volume(0,0); /*hp vol re-set by this function as well*/ |
538 | audiohw_set_lineout_volume(0,0); | 538 | static bool lineout_caused_pause = true; |
539 | #endif | 539 | |
540 | if (global_settings.unplug_mode) | ||
541 | { | ||
542 | int audio_stat = audio_status(); | ||
543 | if (inserted) | ||
544 | { | ||
545 | backlight_on(); | ||
546 | if ((audio_stat & AUDIO_STATUS_PLAY) && | ||
547 | lineout_caused_pause && | ||
548 | global_settings.unplug_mode > 1 ) | ||
549 | unpause_action(true, true); | ||
550 | lineout_caused_pause = false; | ||
551 | } else { | ||
552 | if ((audio_stat & AUDIO_STATUS_PLAY) && | ||
553 | !(audio_stat & AUDIO_STATUS_PAUSE)) | ||
554 | { | ||
555 | lineout_caused_pause = true; | ||
556 | pause_action(false, false); | ||
557 | } | ||
558 | } | ||
559 | } | ||
560 | #endif /*HAVE_LINEOUT_POWEROFF*/ | ||
540 | } | 561 | } |
541 | #endif | 562 | #endif /*HAVE_LINEOUT_DETECTION*/ |
542 | 563 | ||
543 | long default_event_handler_ex(long event, void (*callback)(void *), void *parameter) | 564 | long default_event_handler_ex(long event, void (*callback)(void *), void *parameter) |
544 | { | 565 | { |
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) | |||
767 | } | 767 | } |
768 | #endif /* HAVE_RTC_ALARM */ | 768 | #endif /* HAVE_RTC_ALARM */ |
769 | 769 | ||
770 | #if defined(HAVE_HEADPHONE_DETECTION) || defined(HAVE_LINEOUT_DETECTION) | ||
771 | if (next_screen == GO_TO_WPS && global_settings.unplug_autoresume) | ||
772 | { | ||
773 | next_screen = GO_TO_ROOT; | ||
770 | #ifdef HAVE_HEADPHONE_DETECTION | 774 | #ifdef HAVE_HEADPHONE_DETECTION |
771 | if (next_screen == GO_TO_WPS && | 775 | if (headphones_inserted()) |
772 | (global_settings.unplug_autoresume && !headphones_inserted() )) | 776 | next_screen = GO_TO_WPS; |
773 | next_screen = GO_TO_ROOT; | 777 | #endif |
778 | #ifdef HAVE_LINEOUT_DETECTION | ||
779 | if (lineout_inserted()) | ||
780 | next_screen = GO_TO_WPS; | ||
774 | #endif | 781 | #endif |
782 | } | ||
783 | #endif /*(HAVE_HEADPHONE_DETECTION) || (HAVE_LINEOUT_DETECTION)*/ | ||
775 | 784 | ||
776 | while (true) | 785 | while (true) |
777 | { | 786 | { |
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 | |||
448 | #endif | 448 | #endif |
449 | 449 | ||
450 | int pause_rewind; /* time in s to rewind when pausing */ | 450 | int pause_rewind; /* time in s to rewind when pausing */ |
451 | #ifdef HAVE_HEADPHONE_DETECTION | 451 | #if defined(HAVE_HEADPHONE_DETECTION) || defined(HAVE_LINEOUT_DETECTION) |
452 | int unplug_mode; /* pause on headphone unplug */ | 452 | int unplug_mode; /* pause on headphone unplug */ |
453 | bool unplug_autoresume; /* disable auto-resume if no phones */ | 453 | bool unplug_autoresume; /* disable auto-resume if no phones */ |
454 | #endif | 454 | #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) | |||
112 | queue_remove_from_head(&button_queue, id); | 112 | queue_remove_from_head(&button_queue, id); |
113 | queue_post(&button_queue, id, 0); | 113 | queue_post(&button_queue, id, 0); |
114 | return 0; | 114 | return 0; |
115 | /*misc.c:hp_unplug_change*/ | ||
115 | } | 116 | } |
116 | #endif | 117 | #endif |
117 | 118 | ||
@@ -125,6 +126,7 @@ static int lo_detect_callback(struct timeout *tmo) | |||
125 | queue_remove_from_head(&button_queue, id); | 126 | queue_remove_from_head(&button_queue, id); |
126 | queue_post(&button_queue, id, 0); | 127 | queue_post(&button_queue, id, 0); |
127 | return 0; | 128 | return 0; |
129 | /*misc.c:lo_unplug_change*/ | ||
128 | } | 130 | } |
129 | #endif | 131 | #endif |
130 | 132 | ||
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) | |||
89 | __gpio_as_output(PIN_CHARGE_CON); | 89 | __gpio_as_output(PIN_CHARGE_CON); |
90 | 90 | ||
91 | __gpio_as_input(PIN_PH_DECT); | 91 | __gpio_as_input(PIN_PH_DECT); |
92 | __gpio_enable_pull(PIN_PH_DECT); | ||
92 | /*__gpio_disable_pull(PIN_PH_DECT); // Spurious Detections */ | 93 | /*__gpio_disable_pull(PIN_PH_DECT); // Spurious Detections */ |
93 | 94 | ||
94 | __gpio_as_input(PIN_LO_DECT); | 95 | __gpio_as_input(PIN_LO_DECT); |
95 | __gpio_disable_pull(PIN_LO_DECT); | 96 | __gpio_enable_pull(PIN_LO_DECT); |
97 | /*__gpio_disable_pull(PIN_LO_DECT); // Spurious Detections */ | ||
96 | } | 98 | } |
97 | 99 | ||
98 | bool button_hold(void) | 100 | bool button_hold(void) |