diff options
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/codec-jz4760.c')
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/codec-jz4760.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/codec-jz4760.c b/firmware/target/mips/ingenic_jz47xx/codec-jz4760.c index 09d4858b34..a2de80a914 100644 --- a/firmware/target/mips/ingenic_jz47xx/codec-jz4760.c +++ b/firmware/target/mips/ingenic_jz47xx/codec-jz4760.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "pcm_sw_volume.h" | 26 | #include "pcm_sw_volume.h" |
27 | #include "cs4398.h" | 27 | #include "cs4398.h" |
28 | #include "kernel.h" | 28 | #include "kernel.h" |
29 | #include "button.h" | ||
29 | 30 | ||
30 | #define PIN_CS_RST (32*1+10) | 31 | #define PIN_CS_RST (32*1+10) |
31 | #define PIN_CODEC_PWRON (32*1+13) | 32 | #define PIN_CODEC_PWRON (32*1+13) |
@@ -140,7 +141,11 @@ static int vol_tenthdb2hw(const int tdb) | |||
140 | } | 141 | } |
141 | } | 142 | } |
142 | 143 | ||
143 | void audiohw_set_volume(int vol_l, int vol_r) | 144 | #ifdef HAVE_LINEOUT_DETECTION |
145 | static int real_vol_l, real_vol_r; | ||
146 | #endif | ||
147 | |||
148 | static void jz4760_set_vol(int vol_l, int vol_r) | ||
144 | { | 149 | { |
145 | uint8_t val = cs4398_read_reg(CS4398_REG_MISC) &~ CS4398_FREEZE; | 150 | uint8_t val = cs4398_read_reg(CS4398_REG_MISC) &~ CS4398_FREEZE; |
146 | cs4398_write_reg(CS4398_REG_MISC, val | CS4398_FREEZE); | 151 | cs4398_write_reg(CS4398_REG_MISC, val | CS4398_FREEZE); |
@@ -149,14 +154,31 @@ void audiohw_set_volume(int vol_l, int vol_r) | |||
149 | cs4398_write_reg(CS4398_REG_MISC, val); | 154 | cs4398_write_reg(CS4398_REG_MISC, val); |
150 | } | 155 | } |
151 | 156 | ||
157 | void audiohw_set_volume(int vol_l, int vol_r) | ||
158 | { | ||
159 | #ifdef HAVE_LINEOUT_DETECTION | ||
160 | real_vol_l = vol_l; | ||
161 | real_vol_r = vol_r; | ||
162 | |||
163 | if (lineout_inserted()) { | ||
164 | vol_l = 0; | ||
165 | vol_r = 0; | ||
166 | } | ||
167 | #endif | ||
168 | jz4760_set_vol(vol_l, vol_r); | ||
169 | } | ||
170 | |||
152 | void audiohw_set_lineout_volume(int vol_l, int vol_r) | 171 | void audiohw_set_lineout_volume(int vol_l, int vol_r) |
153 | { | 172 | { |
154 | #if 0 /* unused */ | ||
155 | cs4398_write_reg(CS4398_REG_VOL_A, vol_tenthdb2hw(vol_l)); | ||
156 | cs4398_write_reg(CS4398_REG_VOL_B, vol_tenthdb2hw(vol_r)); | ||
157 | #else | ||
158 | (void)vol_l; | 173 | (void)vol_l; |
159 | (void)vol_r; | 174 | (void)vol_r; |
175 | |||
176 | #ifdef HAVE_LINEOUT_DETECTION | ||
177 | if (lineout_inserted()) { | ||
178 | jz4760_set_vol(0, 0); | ||
179 | } else { | ||
180 | jz4760_set_vol(real_vol_l, real_vol_r); | ||
181 | } | ||
160 | #endif | 182 | #endif |
161 | } | 183 | } |
162 | 184 | ||