diff options
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/codec-jz4740.c')
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/codec-jz4740.c | 92 |
1 files changed, 47 insertions, 45 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/codec-jz4740.c b/firmware/target/mips/ingenic_jz47xx/codec-jz4740.c index 0b187be1cc..05ca2d02d4 100644 --- a/firmware/target/mips/ingenic_jz47xx/codec-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/codec-jz4740.c | |||
@@ -40,11 +40,13 @@ const struct sound_settings_info audiohw_settings[] = { | |||
40 | #endif | 40 | #endif |
41 | }; | 41 | }; |
42 | 42 | ||
43 | #if 0 | ||
43 | static unsigned short codec_volume; | 44 | static unsigned short codec_volume; |
44 | static unsigned short codec_base_gain; | 45 | static unsigned short codec_base_gain; |
45 | static unsigned short codec_mic_gain; | 46 | static unsigned short codec_mic_gain; |
47 | static int HP_register_value; | ||
48 | #endif | ||
46 | static bool HP_on_off_flag; | 49 | static bool HP_on_off_flag; |
47 | static int HP_register_value; | ||
48 | 50 | ||
49 | static void i2s_codec_set_samplerate(unsigned short rate); | 51 | static void i2s_codec_set_samplerate(unsigned short rate); |
50 | 52 | ||
@@ -77,7 +79,7 @@ static void i2s_codec_init(void) | |||
77 | i2s_codec_reset(); | 79 | i2s_codec_reset(); |
78 | 80 | ||
79 | //REG_ICDC_CDCCR2 = (ICDC_CDCCR2_AINVOL(ICDC_CDCCR2_AINVOL_DB(0)) | ICDC_CDCCR2_SMPR(ICDC_CDCCR2_SMPR_48) | 81 | //REG_ICDC_CDCCR2 = (ICDC_CDCCR2_AINVOL(ICDC_CDCCR2_AINVOL_DB(0)) | ICDC_CDCCR2_SMPR(ICDC_CDCCR2_SMPR_48) |
80 | REG_ICDC_CDCCR2 = ( ICDC_CDCCR2_AINVOL(23) | ICDC_CDCCR2_SMPR(ICDC_CDCCR2_SMPR_44) | 82 | REG_ICDC_CDCCR2 = ( ICDC_CDCCR2_AINVOL(14) | ICDC_CDCCR2_SMPR(ICDC_CDCCR2_SMPR_44) |
81 | | ICDC_CDCCR2_HPVOL(ICDC_CDCCR2_HPVOL_6)); | 83 | | ICDC_CDCCR2_HPVOL(ICDC_CDCCR2_HPVOL_6)); |
82 | 84 | ||
83 | REG_ICDC_CDCCR1 &= ~(ICDC_CDCCR1_SUSPD | ICDC_CDCCR1_RST); | 85 | REG_ICDC_CDCCR1 &= ~(ICDC_CDCCR1_SUSPD | ICDC_CDCCR1_RST); |
@@ -101,6 +103,7 @@ static void i2s_codec_init(void) | |||
101 | HP_on_off_flag = 1; /* HP is on */ | 103 | HP_on_off_flag = 1; /* HP is on */ |
102 | } | 104 | } |
103 | 105 | ||
106 | #if 0 | ||
104 | static void i2s_codec_set_mic(unsigned short v) /* 0 <= v <= 100 */ | 107 | static void i2s_codec_set_mic(unsigned short v) /* 0 <= v <= 100 */ |
105 | { | 108 | { |
106 | v &= 0xff; | 109 | v &= 0xff; |
@@ -201,48 +204,6 @@ static unsigned short i2s_codec_get_volume(void) | |||
201 | return val; | 204 | return val; |
202 | } | 205 | } |
203 | 206 | ||
204 | static void i2s_codec_set_samplerate(unsigned short rate) | ||
205 | { | ||
206 | unsigned short speed = 0; | ||
207 | |||
208 | switch (rate) | ||
209 | { | ||
210 | case 8000: | ||
211 | speed = 0 << 8; | ||
212 | break; | ||
213 | case 11025: | ||
214 | speed = 1 << 8; | ||
215 | break; | ||
216 | case 12000: | ||
217 | speed = 2 << 8; | ||
218 | break; | ||
219 | case 16000: | ||
220 | speed = 3 << 8; | ||
221 | break; | ||
222 | case 22050: | ||
223 | speed = 4 << 8; | ||
224 | break; | ||
225 | case 24000: | ||
226 | speed = 5 << 8; | ||
227 | break; | ||
228 | case 32000: | ||
229 | speed = 6 << 8; | ||
230 | break; | ||
231 | case 44100: | ||
232 | speed = 7 << 8; | ||
233 | break; | ||
234 | case 48000: | ||
235 | speed = 8 << 8; | ||
236 | break; | ||
237 | default: | ||
238 | break; | ||
239 | } | ||
240 | REG_ICDC_CDCCR2 |= 0x00000f00; | ||
241 | |||
242 | speed |= 0xfffff0ff; | ||
243 | REG_ICDC_CDCCR2 &= speed; | ||
244 | } | ||
245 | |||
246 | static void HP_turn_on(void) | 207 | static void HP_turn_on(void) |
247 | { | 208 | { |
248 | //see 1.3.4.1 | 209 | //see 1.3.4.1 |
@@ -274,7 +235,6 @@ static void HP_turn_on(void) | |||
274 | HP_register_value = REG_ICDC_CDCCR1;*/ | 235 | HP_register_value = REG_ICDC_CDCCR1;*/ |
275 | 236 | ||
276 | //see 1.3.4.3 | 237 | //see 1.3.4.3 |
277 | |||
278 | } | 238 | } |
279 | 239 | ||
280 | 240 | ||
@@ -302,7 +262,49 @@ static void HP_turn_off(void) | |||
302 | REG_ICDC_CDCCR1 |= 0x00000002;*/ | 262 | REG_ICDC_CDCCR1 |= 0x00000002;*/ |
303 | 263 | ||
304 | //see 1.3.4.3 | 264 | //see 1.3.4.3 |
265 | } | ||
266 | #endif | ||
305 | 267 | ||
268 | static void i2s_codec_set_samplerate(unsigned short rate) | ||
269 | { | ||
270 | unsigned short speed = 0; | ||
271 | |||
272 | switch (rate) | ||
273 | { | ||
274 | case 8000: | ||
275 | speed = 0 << 8; | ||
276 | break; | ||
277 | case 11025: | ||
278 | speed = 1 << 8; | ||
279 | break; | ||
280 | case 12000: | ||
281 | speed = 2 << 8; | ||
282 | break; | ||
283 | case 16000: | ||
284 | speed = 3 << 8; | ||
285 | break; | ||
286 | case 22050: | ||
287 | speed = 4 << 8; | ||
288 | break; | ||
289 | case 24000: | ||
290 | speed = 5 << 8; | ||
291 | break; | ||
292 | case 32000: | ||
293 | speed = 6 << 8; | ||
294 | break; | ||
295 | case 44100: | ||
296 | speed = 7 << 8; | ||
297 | break; | ||
298 | case 48000: | ||
299 | speed = 8 << 8; | ||
300 | break; | ||
301 | default: | ||
302 | break; | ||
303 | } | ||
304 | REG_ICDC_CDCCR2 |= 0x00000f00; | ||
305 | |||
306 | speed |= 0xfffff0ff; | ||
307 | REG_ICDC_CDCCR2 &= speed; | ||
306 | } | 308 | } |
307 | 309 | ||
308 | void audiohw_mute(bool mute) | 310 | void audiohw_mute(bool mute) |