erosqnative: Repurpose stereosw_select setting for output select

Turns out they did not swap the stereo switch lines on us,
so this setting isn't really useful. Repurpose it to allow
the user to force the device into headphone or line output mode.

Note that settings other than "Automatic" will cause jack detection
to not work.

Default Automatic.

Change-Id: If94499fbb8f0d92111811fe51f6107ce213b66ad
This commit is contained in:
Dana Conrad 2024-11-30 21:48:16 +00:00 committed by Solomon Peachy
parent a29b570ac4
commit 5ed0db6e90
7 changed files with 98 additions and 82 deletions

View file

@ -16357,62 +16357,6 @@
*: "Expert"
</voice>
</phrase>
<phrase>
id: LANG_STEREOSW_MODE
desc: Stereo Switch Mode
user: core
<source>
*: "Stereo Switch Mode"
</source>
<dest>
*: "Stereo Switch Mode"
</dest>
<voice>
*: "Stereo Switch Mode"
</voice>
</phrase>
<phrase>
id: LANG_REVERSE
desc: in settings_menu
user: core
<source>
*: "Reverse"
</source>
<dest>
*: "Reverse"
</dest>
<voice>
*: "Reverse"
</voice>
</phrase>
<phrase>
id: LANG_ALWAYS_ZERO
desc: in settings_menu
user: core
<source>
*: "Always 0"
</source>
<dest>
*: "Always 0"
</dest>
<voice>
*: "Always 0"
</voice>
</phrase>
<phrase>
id: LANG_ALWAYS_ONE
desc: in settings_menu
user: core
<source>
*: "Always 1"
</source>
<dest>
*: "Always 1"
</dest>
<voice>
*: "Always 1"
</voice>
</phrase>
<phrase>
id: LANG_LEGAL_NOTICES
desc: in system menu
@ -16581,3 +16525,45 @@
*: "View Album Art"
</voice>
</phrase>
<phrase>
id: LANG_HP_LO_SELECT
desc: Output Select
user: core
<source>
*: "Output Select"
</source>
<dest>
*: "Output Select"
</dest>
<voice>
*: "Output Select"
</voice>
</phrase>
<phrase>
id: LANG_HEADPHONE
desc: in settings_menu
user: core
<source>
*: "Headphone"
</source>
<dest>
*: "Headphone"
</dest>
<voice>
*: "Headphone"
</voice>
</phrase>
<phrase>
id: LANG_LINEOUT
desc: in settings_menu
user: core
<source>
*: "Lineout"
</source>
<dest>
*: "Lineout"
</dest>
<voice>
*: "Lineout"
</voice>
</phrase>

View file

@ -136,7 +136,7 @@ MENUITEM_SETTING(roll_off, &global_settings.roll_off, NULL);
#endif
#ifdef HAVE_EROS_QN_CODEC
MENUITEM_SETTING(stereosw_mode, &global_settings.stereosw_mode,NULL);
MENUITEM_SETTING(hp_lo_select, &global_settings.hp_lo_select,NULL);
#endif
#ifdef AUDIOHW_HAVE_POWER_MODE
@ -258,7 +258,7 @@ MAKE_MENU(sound_settings, ID2P(LANG_SOUND_SETTINGS), NULL, Icon_Audio,
,&roll_off
#endif
#ifdef HAVE_EROS_QN_CODEC
,&stereosw_mode
,&hp_lo_select
#endif
#ifdef AUDIOHW_HAVE_POWER_MODE
,&power_mode

View file

@ -909,7 +909,7 @@ struct user_settings
bool clear_settings_on_hold;
#endif
#if defined(HAVE_EROS_QN_CODEC)
int stereosw_mode; /* indicates normal, reverse, always 0, always 1 operation */
int hp_lo_select; /* indicates automatic, headphone-only, or lineout-only operation */
#endif
};

View file

@ -819,7 +819,7 @@ static void volume_limit_set_default(void* setting, void* defaultval)
}
#if defined(HAVE_EROS_QN_CODEC)
static void stereosw_apply(int arg)
static void hp_lo_select_apply(int arg)
{
(void)arg;
@ -2312,9 +2312,9 @@ const struct settings_list settings[] = {
true, "clear settings on hold", NULL),
#endif
#if defined(HAVE_EROS_QN_CODEC)
CHOICE_SETTING(0, stereosw_mode, LANG_STEREOSW_MODE, 0, "stereo switch mode",
"normal,reverse,always0,always1", stereosw_apply, 4,
ID2P(LANG_NORMAL), ID2P(LANG_REVERSE), ID2P(LANG_ALWAYS_ZERO), ID2P(LANG_ALWAYS_ONE)),
CHOICE_SETTING(0, hp_lo_select, LANG_HP_LO_SELECT, 0, "headphone lineout select",
"auto,headphone,lineout", hp_lo_select_apply, 3,
ID2P(LANG_AUTO), ID2P(LANG_HEADPHONE), ID2P(LANG_LINEOUT)),
#endif
};

View file

@ -58,14 +58,12 @@ int eros_qn_get_volume_limit(void)
void eros_qn_switch_output(int select)
{
/* normal operation 0, reverse operation 1, or always 0 */
if ((select == 0 && global_settings.stereosw_mode == 0) \
|| (select == 1 && global_settings.stereosw_mode == 1) \
|| global_settings.stereosw_mode == 2)
/* normal operation 0 */
if (select == 0)
{
gpio_set_level(GPIO_STEREOSW_SEL, 0);
}
/* normal operation 1, reverse operation 0, or always 1 */
/* normal operation 1 */
else
{
gpio_set_level(GPIO_STEREOSW_SEL, 1);

View file

@ -34,6 +34,7 @@
#include "devicedata.h"
#ifndef BOOTLOADER
# include "settings.h"
# include "lcd.h"
# include "font.h"
#endif
@ -166,7 +167,20 @@ bool headphones_inserted(void)
eros_qn_set_outputs();
#endif
}
return hp_detect_reg & 0x10 ? false : true;
#if !defined(BOOTLOADER)
if (global_settings.hp_lo_select == 1) // force headphones
{
return true;
}
else if (global_settings.hp_lo_select == 2) // force lineout
{
return false;
}
else // automatic
#endif
{
return hp_detect_reg & 0x10 ? false : true;
}
}
bool lineout_inserted(void)
@ -182,7 +196,20 @@ bool lineout_inserted(void)
eros_qn_set_outputs();
#endif
}
return hp_detect_reg & 0x20 ? false : true;
#if !defined(BOOTLOADER)
if (global_settings.hp_lo_select == 1) // force headphones
{
return false;
}
else if (global_settings.hp_lo_select == 2) // force lineout
{
return true;
}
else // automatic
#endif
{
return hp_detect_reg & 0x20 ? false : true;
}
}
/* Rockbox interface */

View file

@ -190,19 +190,24 @@ change to customise your listening experience.
stereo field unaltered.
\opt{erosqnative}{
\section{Stereo Switch Mode}
The Eros Q and related devices contain a stereo switch in the audio path.
This setting allows the behavior of the stereo switch to be changed if one of
the two outputs (Headphones or Line Out) is not working. There are four modes:
\section{Output Select}
The \dap{} has two output ports: Headphones and Line Out. This setting selects
either automatic detection, or forces the player to use Headphone output or
Line output.
\note{The headphone jack will only detect a pair of headphones or similar devices with low impedance.
An amplifier or other high-impedance device will not be detected. The lineout jack
will detect a high-impedance device.}
\note{Line output volume is fixed to Volume Limit value. Please see \setting{Volume} section.}
\begin{description}
\item[Normal.]
Headphones output uses a value of 0, and Line Out uses a value of 1.
\item[Reverse.]
Headphones output uses a value of 1, and Line Out uses a value of 0.
\item[Always 0.]
Both outputs use a value of 0.
\item[Always 1.]
Both outputs use a value of 1.
\item[Automatic.]
Automatically detect which output to use. If both outputs are plugged in,
headphones will take precedence. Jack detection is enabled.
\item[Headphone.]
Force the headphone output to be active. Jack detection is disabled. Automatic
play/pause jack detection will not work.
\item[Lineout.]
Force the line output to be active. Jack detection is disabled. Automatic
play/pause jack detection will not work.
\end{description}
\section{DAC filter roll-off}