diff options
author | Dana Conrad <dconrad@fastmail.com> | 2023-01-22 12:33:15 -0600 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2023-01-22 15:11:35 -0500 |
commit | 66519000f47cfb5c58be68ab2335b7cbc0bce35b (patch) | |
tree | 92701a200a68da3afd6336a3954fe02c840ae82d /firmware | |
parent | c307d98e3fbe5e867cd6e6e3c61f4937021c6b4c (diff) | |
download | rockbox-66519000f47cfb5c58be68ab2335b7cbc0bce35b.tar.gz rockbox-66519000f47cfb5c58be68ab2335b7cbc0bce35b.zip |
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
Diffstat (limited to 'firmware')
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 @@ | |||
31 | static long int vol_l_hw = 0; | 31 | static long int vol_l_hw = 0; |
32 | static long int vol_r_hw = 0; | 32 | static long int vol_r_hw = 0; |
33 | 33 | ||
34 | /* internal: mute the headphone amp. 0 - unmuted, 1 - muted */ | 34 | /* internal: Switch the output sink. 0 - headphones, 1 - line out */ |
35 | void audiohw_mute_hp(int mute); | 35 | void audiohw_switch_output(int select); |
36 | 36 | ||
37 | void pcm5102_set_outputs(void) | 37 | void dac_set_outputs(void) |
38 | { | 38 | { |
39 | audiohw_set_volume(vol_l_hw, vol_r_hw); | 39 | audiohw_set_volume(vol_l_hw, vol_r_hw); |
40 | } | 40 | } |
@@ -56,15 +56,14 @@ void audiohw_set_volume(int vol_l, int vol_r) | |||
56 | * blow out our eardrums cranking it to full */ | 56 | * blow out our eardrums cranking it to full */ |
57 | if (lineout_inserted() && !headphones_inserted()) | 57 | if (lineout_inserted() && !headphones_inserted()) |
58 | { | 58 | { |
59 | l = r = global_settings.volume_limit * 10; | 59 | audiohw_switch_output(1); |
60 | 60 | ||
61 | /* mute the headphone amp if not plugged in */ | 61 | l = r = global_settings.volume_limit * 10; |
62 | audiohw_mute_hp(1); | ||
63 | } | 62 | } |
64 | else | 63 | else |
65 | { | 64 | { |
66 | /* unmute the headphone amp when plugged in */ | 65 | audiohw_switch_output(0); |
67 | audiohw_mute_hp(0); | 66 | |
68 | l = vol_l; | 67 | l = vol_l; |
69 | r = vol_r; | 68 | r = vol_r; |
70 | } | 69 | } |
@@ -76,14 +75,14 @@ void audiohw_set_volume(int vol_l, int vol_r) | |||
76 | pcm_set_master_volume(l, r); | 75 | pcm_set_master_volume(l, r); |
77 | } | 76 | } |
78 | 77 | ||
79 | void audiohw_mute_hp(int mute) | 78 | void audiohw_switch_output(int select) |
80 | { | 79 | { |
81 | if (mute == 0) | 80 | if (select == 0) |
82 | { | 81 | { |
83 | gpio_set_level(GPIO_MAX97220_SHDN, 1); | 82 | gpio_set_level(GPIO_STEREOSW_SEL, 0); |
84 | } | 83 | } |
85 | else | 84 | else |
86 | { | 85 | { |
87 | gpio_set_level(GPIO_MAX97220_SHDN, 0); | 86 | gpio_set_level(GPIO_STEREOSW_SEL, 1); |
88 | } | 87 | } |
89 | } | 88 | } |
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/ | |||
39 | 39 | ||
40 | /* this just calls audiohw_set_volume() with the last (locally) known volume, | 40 | /* this just calls audiohw_set_volume() with the last (locally) known volume, |
41 | * used for switching to/from fixed line out volume. */ | 41 | * used for switching to/from fixed line out volume. */ |
42 | void pcm5102_set_outputs(void); | 42 | void dac_set_outputs(void); |
43 | 43 | ||
44 | #endif | 44 | #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 @@ | |||
27 | #include "gpio-x1000.h" | 27 | #include "gpio-x1000.h" |
28 | #include "logf.h" | 28 | #include "logf.h" |
29 | 29 | ||
30 | /* Audio path appears to be: | 30 | /* |
31 | * DAC --> HP Amp --> Stereo Switch --> HP OUT | 31 | * Earlier devices audio path appears to be: |
32 | * \--> LO OUT | 32 | * DAC \--> HP Amp --> Stereo Switch --> HP OUT |
33 | * \-> LO OUT | ||
33 | * | 34 | * |
34 | * The real purpose of the Stereo Switch is not clear. | 35 | * Recent devices, the audio path seems to have changed to: |
35 | * It appears to switch sources between the HP amp and something, | 36 | * DAC --> HP Amp --> Stereo Switch \--> HP OUT |
36 | * likely something unimplemented. */ | 37 | * \-> LO OUT |
38 | */ | ||
37 | 39 | ||
38 | void audiohw_init(void) | 40 | void audiohw_init(void) |
39 | { | 41 | { |
40 | /* explicitly mute everything */ | 42 | /* explicitly mute everything */ |
41 | gpio_set_level(GPIO_MAX97220_SHDN, 0); | 43 | gpio_set_level(GPIO_HPAMP_SHDN, 0); |
42 | gpio_set_level(GPIO_ISL54405_MUTE, 1); | 44 | gpio_set_level(GPIO_STEREOSW_MUTE, 1); |
43 | gpio_set_level(GPIO_PCM5102A_XMIT, 0); | 45 | gpio_set_level(GPIO_DAC_XMIT, 0); |
44 | 46 | ||
45 | aic_set_play_last_sample(true); | 47 | aic_set_play_last_sample(true); |
46 | aic_set_external_codec(true); | 48 | aic_set_external_codec(true); |
@@ -53,8 +55,8 @@ void audiohw_init(void) | |||
53 | mdelay(10); | 55 | mdelay(10); |
54 | 56 | ||
55 | /* power on DAC and HP Amp */ | 57 | /* power on DAC and HP Amp */ |
56 | gpio_set_level(GPIO_PCM5102A_ANALOG_PWR, 1); | 58 | gpio_set_level(GPIO_DAC_ANALOG_PWR, 1); |
57 | gpio_set_level(GPIO_MAX97220_POWER, 1); | 59 | gpio_set_level(GPIO_HPAMP_POWER, 1); |
58 | } | 60 | } |
59 | 61 | ||
60 | void audiohw_postinit(void) | 62 | void audiohw_postinit(void) |
@@ -76,23 +78,23 @@ void audiohw_postinit(void) | |||
76 | jz_writef(AIC_CCR, ERPL(0)); | 78 | jz_writef(AIC_CCR, ERPL(0)); |
77 | 79 | ||
78 | /* unmute - attempt to make power-on pop-free */ | 80 | /* unmute - attempt to make power-on pop-free */ |
79 | gpio_set_level(GPIO_ISL54405_SEL, 0); | 81 | gpio_set_level(GPIO_STEREOSW_SEL, 0); |
80 | gpio_set_level(GPIO_MAX97220_SHDN, 1); | 82 | gpio_set_level(GPIO_HPAMP_SHDN, 1); |
81 | mdelay(10); | 83 | mdelay(10); |
82 | gpio_set_level(GPIO_PCM5102A_XMIT, 1); | 84 | gpio_set_level(GPIO_DAC_XMIT, 1); |
83 | mdelay(10); | 85 | mdelay(10); |
84 | gpio_set_level(GPIO_ISL54405_MUTE, 0); | 86 | gpio_set_level(GPIO_STEREOSW_MUTE, 0); |
85 | } | 87 | } |
86 | 88 | ||
87 | /* TODO: get shutdown just right according to dac datasheet */ | 89 | /* TODO: get shutdown just right according to dac datasheet */ |
88 | void audiohw_close(void) | 90 | void audiohw_close(void) |
89 | { | 91 | { |
90 | /* mute - attempt to make power-off pop-free */ | 92 | /* mute - attempt to make power-off pop-free */ |
91 | gpio_set_level(GPIO_ISL54405_MUTE, 1); | 93 | gpio_set_level(GPIO_STEREOSW_MUTE, 1); |
92 | mdelay(10); | 94 | mdelay(10); |
93 | gpio_set_level(GPIO_PCM5102A_XMIT, 0); | 95 | gpio_set_level(GPIO_DAC_XMIT, 0); |
94 | mdelay(10); | 96 | mdelay(10); |
95 | gpio_set_level(GPIO_MAX97220_SHDN, 0); | 97 | gpio_set_level(GPIO_HPAMP_SHDN, 0); |
96 | } | 98 | } |
97 | 99 | ||
98 | void audiohw_set_frequency(int fsel) | 100 | 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) | |||
127 | { | 127 | { |
128 | hp_detect_reg_old = hp_detect_reg; | 128 | hp_detect_reg_old = hp_detect_reg; |
129 | #if !defined(BOOTLOADER) | 129 | #if !defined(BOOTLOADER) |
130 | pcm5102_set_outputs(); | 130 | dac_set_outputs(); |
131 | #endif | 131 | #endif |
132 | } | 132 | } |
133 | return hp_detect_reg & 0x10 ? false : true; | 133 | return hp_detect_reg & 0x10 ? false : true; |
@@ -140,7 +140,7 @@ bool lineout_inserted(void) | |||
140 | { | 140 | { |
141 | hp_detect_reg_old = hp_detect_reg; | 141 | hp_detect_reg_old = hp_detect_reg; |
142 | #if !defined(BOOTLOADER) | 142 | #if !defined(BOOTLOADER) |
143 | pcm5102_set_outputs(); | 143 | dac_set_outputs(); |
144 | #endif | 144 | #endif |
145 | } | 145 | } |
146 | return hp_detect_reg & 0x20 ? false : true; | 146 | 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)) | |||
24 | DEFINE_PINGROUP(I2C2, GPIO_D, 3 << 0, GPIOF_DEVICE(1)) | 24 | DEFINE_PINGROUP(I2C2, GPIO_D, 3 << 0, GPIOF_DEVICE(1)) |
25 | 25 | ||
26 | /* Name Pin Function */ | 26 | /* Name Pin Function */ |
27 | /* mute DAC - 0 - mute, 1 - play. Affects both HP and LO. */ | 27 | /* mute DAC: 0 - mute, 1 - play */ |
28 | DEFINE_GPIO(PCM5102A_XMIT, GPIO_PB(12), GPIOF_OUTPUT(0)) | 28 | DEFINE_GPIO(DAC_XMIT, GPIO_PB(12), GPIOF_OUTPUT(0)) |
29 | 29 | ||
30 | /* mute HP amp, no effect on LO. 0 - mute, 1 - play */ | 30 | /* mute HP amp: 0 - mute, 1 - play */ |
31 | DEFINE_GPIO(MAX97220_SHDN, GPIO_PB(8), GPIOF_OUTPUT(0)) | 31 | DEFINE_GPIO(HPAMP_SHDN, GPIO_PB(8), GPIOF_OUTPUT(0)) |
32 | 32 | ||
33 | /* mute audio mux, only affects Headphone out. | 33 | /* mute audio mux: 0 - play, 1 - mute */ |
34 | * 0 - play, 1 - mute */ | 34 | DEFINE_GPIO(STEREOSW_MUTE, GPIO_PB(15), GPIOF_OUTPUT(1)) |
35 | DEFINE_GPIO(ISL54405_MUTE, GPIO_PB(15), GPIOF_OUTPUT(1)) | ||
36 | 35 | ||
37 | /* switches HP on/off - 0 HP on, 1 hp off, has no effect on LO. | 36 | /* |
38 | * As best I can tell, it switches HP Out sources between HP amp and something | 37 | * Original devices: switches HP on/off - 0 HP on, 1 HP off, no effect on LO. |
39 | * not implemented - there seem to be resistors missing. */ | 38 | * Newer devices: switches between HP and LO - 0 HP, 1 LO. |
40 | DEFINE_GPIO(ISL54405_SEL, GPIO_PB(5), GPIOF_OUTPUT(0)) | 39 | */ |
40 | DEFINE_GPIO(STEREOSW_SEL, GPIO_PB(5), GPIOF_OUTPUT(0)) | ||
41 | 41 | ||
42 | /* DAC AVDD */ | 42 | /* DAC AVDD */ |
43 | DEFINE_GPIO(PCM5102A_ANALOG_PWR, GPIO_PB(9), GPIOF_OUTPUT(0)) | 43 | DEFINE_GPIO(DAC_ANALOG_PWR, GPIO_PB(9), GPIOF_OUTPUT(0)) |
44 | 44 | ||
45 | /* Headphone Amp power */ | 45 | /* Headphone Amp power */ |
46 | DEFINE_GPIO(MAX97220_POWER, GPIO_PB(6), GPIOF_OUTPUT(0)) | 46 | DEFINE_GPIO(HPAMP_POWER, GPIO_PB(6), GPIOF_OUTPUT(0)) |
47 | 47 | ||
48 | /* SD card */ | 48 | /* SD card */ |
49 | DEFINE_GPIO(MSC0_CD, GPIO_PB(11), GPIOF_INPUT) | 49 | DEFINE_GPIO(MSC0_CD, GPIO_PB(11), GPIOF_INPUT) |