From 66519000f47cfb5c58be68ab2335b7cbc0bce35b Mon Sep 17 00:00:00 2001 From: Dana Conrad Date: Sun, 22 Jan 2023 12:33:15 -0600 Subject: ErosQNative: Enable Line Out capabilities on new revision players The newer players have some changed hardware, but most importantly the line out now appears to be routed through the stereo switch instead of being hardwired directly off the DAC. Disable muting the headphone amp, enable switching the stereo switch, and rename some of the GPIOs to be more generic since the DAC, headphone amp, and stereo switch all appear to have changed. Change-Id: I220fe5e37bcbcd959b544183e1fcf70673a83c13 --- firmware/drivers/audio/eros_qn_codec.c | 23 +++++++------ firmware/export/eros_qn_codec.h | 2 +- .../erosqnative/audiohw-erosqnative.c | 38 ++++++++++++---------- .../ingenic_x1000/erosqnative/button-erosqnative.c | 4 +-- .../mips/ingenic_x1000/erosqnative/gpio-target.h | 26 +++++++-------- 5 files changed, 47 insertions(+), 46 deletions(-) diff --git a/firmware/drivers/audio/eros_qn_codec.c b/firmware/drivers/audio/eros_qn_codec.c index da50d62fe5..39a421ee92 100644 --- a/firmware/drivers/audio/eros_qn_codec.c +++ b/firmware/drivers/audio/eros_qn_codec.c @@ -31,10 +31,10 @@ static long int vol_l_hw = 0; static long int vol_r_hw = 0; -/* internal: mute the headphone amp. 0 - unmuted, 1 - muted */ -void audiohw_mute_hp(int mute); +/* internal: Switch the output sink. 0 - headphones, 1 - line out */ +void audiohw_switch_output(int select); -void pcm5102_set_outputs(void) +void dac_set_outputs(void) { audiohw_set_volume(vol_l_hw, vol_r_hw); } @@ -56,15 +56,14 @@ void audiohw_set_volume(int vol_l, int vol_r) * blow out our eardrums cranking it to full */ if (lineout_inserted() && !headphones_inserted()) { - l = r = global_settings.volume_limit * 10; + audiohw_switch_output(1); - /* mute the headphone amp if not plugged in */ - audiohw_mute_hp(1); + l = r = global_settings.volume_limit * 10; } else { - /* unmute the headphone amp when plugged in */ - audiohw_mute_hp(0); + audiohw_switch_output(0); + l = vol_l; r = vol_r; } @@ -76,14 +75,14 @@ void audiohw_set_volume(int vol_l, int vol_r) pcm_set_master_volume(l, r); } -void audiohw_mute_hp(int mute) +void audiohw_switch_output(int select) { - if (mute == 0) + if (select == 0) { - gpio_set_level(GPIO_MAX97220_SHDN, 1); + gpio_set_level(GPIO_STEREOSW_SEL, 0); } else { - gpio_set_level(GPIO_MAX97220_SHDN, 0); + gpio_set_level(GPIO_STEREOSW_SEL, 1); } } diff --git a/firmware/export/eros_qn_codec.h b/firmware/export/eros_qn_codec.h index 851ab63362..bf108aa1c7 100644 --- a/firmware/export/eros_qn_codec.h +++ b/firmware/export/eros_qn_codec.h @@ -39,6 +39,6 @@ AUDIOHW_SETTING(VOLUME, "dB", 0, 2, PCM5102A_VOLUME_MIN/10, PCM5102A_VOLUME_MAX/ /* this just calls audiohw_set_volume() with the last (locally) known volume, * used for switching to/from fixed line out volume. */ -void pcm5102_set_outputs(void); +void dac_set_outputs(void); #endif diff --git a/firmware/target/mips/ingenic_x1000/erosqnative/audiohw-erosqnative.c b/firmware/target/mips/ingenic_x1000/erosqnative/audiohw-erosqnative.c index b32a32a3a3..c53da728ff 100644 --- a/firmware/target/mips/ingenic_x1000/erosqnative/audiohw-erosqnative.c +++ b/firmware/target/mips/ingenic_x1000/erosqnative/audiohw-erosqnative.c @@ -27,20 +27,22 @@ #include "gpio-x1000.h" #include "logf.h" -/* Audio path appears to be: - * DAC --> HP Amp --> Stereo Switch --> HP OUT - * \--> LO OUT +/* + * Earlier devices audio path appears to be: + * DAC \--> HP Amp --> Stereo Switch --> HP OUT + * \-> LO OUT * - * The real purpose of the Stereo Switch is not clear. - * It appears to switch sources between the HP amp and something, - * likely something unimplemented. */ + * Recent devices, the audio path seems to have changed to: + * DAC --> HP Amp --> Stereo Switch \--> HP OUT + * \-> LO OUT + */ void audiohw_init(void) { /* explicitly mute everything */ - gpio_set_level(GPIO_MAX97220_SHDN, 0); - gpio_set_level(GPIO_ISL54405_MUTE, 1); - gpio_set_level(GPIO_PCM5102A_XMIT, 0); + gpio_set_level(GPIO_HPAMP_SHDN, 0); + gpio_set_level(GPIO_STEREOSW_MUTE, 1); + gpio_set_level(GPIO_DAC_XMIT, 0); aic_set_play_last_sample(true); aic_set_external_codec(true); @@ -53,8 +55,8 @@ void audiohw_init(void) mdelay(10); /* power on DAC and HP Amp */ - gpio_set_level(GPIO_PCM5102A_ANALOG_PWR, 1); - gpio_set_level(GPIO_MAX97220_POWER, 1); + gpio_set_level(GPIO_DAC_ANALOG_PWR, 1); + gpio_set_level(GPIO_HPAMP_POWER, 1); } void audiohw_postinit(void) @@ -76,23 +78,23 @@ void audiohw_postinit(void) jz_writef(AIC_CCR, ERPL(0)); /* unmute - attempt to make power-on pop-free */ - gpio_set_level(GPIO_ISL54405_SEL, 0); - gpio_set_level(GPIO_MAX97220_SHDN, 1); + gpio_set_level(GPIO_STEREOSW_SEL, 0); + gpio_set_level(GPIO_HPAMP_SHDN, 1); mdelay(10); - gpio_set_level(GPIO_PCM5102A_XMIT, 1); + gpio_set_level(GPIO_DAC_XMIT, 1); mdelay(10); - gpio_set_level(GPIO_ISL54405_MUTE, 0); + gpio_set_level(GPIO_STEREOSW_MUTE, 0); } /* TODO: get shutdown just right according to dac datasheet */ void audiohw_close(void) { /* mute - attempt to make power-off pop-free */ - gpio_set_level(GPIO_ISL54405_MUTE, 1); + gpio_set_level(GPIO_STEREOSW_MUTE, 1); mdelay(10); - gpio_set_level(GPIO_PCM5102A_XMIT, 0); + gpio_set_level(GPIO_DAC_XMIT, 0); mdelay(10); - gpio_set_level(GPIO_MAX97220_SHDN, 0); + gpio_set_level(GPIO_HPAMP_SHDN, 0); } void audiohw_set_frequency(int fsel) diff --git a/firmware/target/mips/ingenic_x1000/erosqnative/button-erosqnative.c b/firmware/target/mips/ingenic_x1000/erosqnative/button-erosqnative.c index 6c50021ce1..d82cb5b5dc 100644 --- a/firmware/target/mips/ingenic_x1000/erosqnative/button-erosqnative.c +++ b/firmware/target/mips/ingenic_x1000/erosqnative/button-erosqnative.c @@ -127,7 +127,7 @@ bool headphones_inserted(void) { hp_detect_reg_old = hp_detect_reg; #if !defined(BOOTLOADER) - pcm5102_set_outputs(); + dac_set_outputs(); #endif } return hp_detect_reg & 0x10 ? false : true; @@ -140,7 +140,7 @@ bool lineout_inserted(void) { hp_detect_reg_old = hp_detect_reg; #if !defined(BOOTLOADER) - pcm5102_set_outputs(); + dac_set_outputs(); #endif } return hp_detect_reg & 0x20 ? false : true; diff --git a/firmware/target/mips/ingenic_x1000/erosqnative/gpio-target.h b/firmware/target/mips/ingenic_x1000/erosqnative/gpio-target.h index 376eae136e..3318a39786 100644 --- a/firmware/target/mips/ingenic_x1000/erosqnative/gpio-target.h +++ b/firmware/target/mips/ingenic_x1000/erosqnative/gpio-target.h @@ -24,26 +24,26 @@ DEFINE_PINGROUP(I2S, GPIO_B, 0x1f << 0, GPIOF_DEVICE(1)) DEFINE_PINGROUP(I2C2, GPIO_D, 3 << 0, GPIOF_DEVICE(1)) /* Name Pin Function */ -/* mute DAC - 0 - mute, 1 - play. Affects both HP and LO. */ -DEFINE_GPIO(PCM5102A_XMIT, GPIO_PB(12), GPIOF_OUTPUT(0)) +/* mute DAC: 0 - mute, 1 - play */ +DEFINE_GPIO(DAC_XMIT, GPIO_PB(12), GPIOF_OUTPUT(0)) -/* mute HP amp, no effect on LO. 0 - mute, 1 - play */ -DEFINE_GPIO(MAX97220_SHDN, GPIO_PB(8), GPIOF_OUTPUT(0)) +/* mute HP amp: 0 - mute, 1 - play */ +DEFINE_GPIO(HPAMP_SHDN, GPIO_PB(8), GPIOF_OUTPUT(0)) -/* mute audio mux, only affects Headphone out. - * 0 - play, 1 - mute */ -DEFINE_GPIO(ISL54405_MUTE, GPIO_PB(15), GPIOF_OUTPUT(1)) +/* mute audio mux: 0 - play, 1 - mute */ +DEFINE_GPIO(STEREOSW_MUTE, GPIO_PB(15), GPIOF_OUTPUT(1)) -/* switches HP on/off - 0 HP on, 1 hp off, has no effect on LO. - * As best I can tell, it switches HP Out sources between HP amp and something - * not implemented - there seem to be resistors missing. */ -DEFINE_GPIO(ISL54405_SEL, GPIO_PB(5), GPIOF_OUTPUT(0)) +/* + * Original devices: switches HP on/off - 0 HP on, 1 HP off, no effect on LO. + * Newer devices: switches between HP and LO - 0 HP, 1 LO. + */ +DEFINE_GPIO(STEREOSW_SEL, GPIO_PB(5), GPIOF_OUTPUT(0)) /* DAC AVDD */ -DEFINE_GPIO(PCM5102A_ANALOG_PWR, GPIO_PB(9), GPIOF_OUTPUT(0)) +DEFINE_GPIO(DAC_ANALOG_PWR, GPIO_PB(9), GPIOF_OUTPUT(0)) /* Headphone Amp power */ -DEFINE_GPIO(MAX97220_POWER, GPIO_PB(6), GPIOF_OUTPUT(0)) +DEFINE_GPIO(HPAMP_POWER, GPIO_PB(6), GPIOF_OUTPUT(0)) /* SD card */ DEFINE_GPIO(MSC0_CD, GPIO_PB(11), GPIOF_INPUT) -- cgit v1.2.3