diff options
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/codec-jz4740.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/codec-jz4740.c b/firmware/target/mips/ingenic_jz47xx/codec-jz4740.c index ab9efc91b0..065433e12a 100644 --- a/firmware/target/mips/ingenic_jz47xx/codec-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/codec-jz4740.c | |||
@@ -24,11 +24,12 @@ | |||
24 | #include "sound.h" | 24 | #include "sound.h" |
25 | #include "jz4740.h" | 25 | #include "jz4740.h" |
26 | #include "system.h" | 26 | #include "system.h" |
27 | #include "pcm_sw_volume.h" | ||
27 | 28 | ||
28 | /* TODO */ | 29 | /* TODO */ |
29 | const struct sound_settings_info audiohw_settings[] = { | 30 | const struct sound_settings_info audiohw_settings[] = { |
30 | #ifdef HAVE_SW_VOLUME_CONTROL | 31 | #ifdef HAVE_SW_VOLUME_CONTROL |
31 | [SOUND_VOLUME] = {"dB", 0, 1, SW_VOLUME_MIN, 6, 0}, | 32 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, |
32 | #else | 33 | #else |
33 | [SOUND_VOLUME] = {"dB", 0, 1, 0, 6, 0}, | 34 | [SOUND_VOLUME] = {"dB", 0, 1, 0, 6, 0}, |
34 | #endif | 35 | #endif |
@@ -293,16 +294,24 @@ void audiohw_init(void) | |||
293 | i2s_codec_init(); | 294 | i2s_codec_init(); |
294 | } | 295 | } |
295 | 296 | ||
296 | void audiohw_set_volume(int v) | 297 | void audiohw_set_master_vol(int vol_l, int vol_r) |
297 | { | 298 | { |
298 | if(v >= 0) | 299 | #ifdef HAVE_SW_VOLUME_CONTROL |
299 | { | 300 | /* SW volume for <= 1.0 gain, HW at unity, < VOLUME_MIN == MUTE */ |
300 | /* 0 <= v <= 60 */ | 301 | int sw_volume_l = vol_l < VOLUME_MIN ? PCM_MUTE_LEVEL : MIN(vol_l, 0); |
301 | unsigned int codec_volume = ICDC_CDCCR2_HPVOL(v / 20); | 302 | int sw_volume_r = vol_r < VOLUME_MIN ? PCM_MUTE_LEVEL : MIN(vol_r, 0); |
303 | pcm_set_master_volume(sw_volume_l, sw_volume_r); | ||
304 | #endif /* HAVE_SW_VOLUME_CONTROL */ | ||
302 | 305 | ||
303 | if((REG_ICDC_CDCCR2 & ICDC_CDCCR2_HPVOL(0x3)) != codec_volume) | 306 | /* NOTE: the channel being cut if balance is not equal will need |
304 | REG_ICDC_CDCCR2 = (REG_ICDC_CDCCR2 & ~ICDC_CDCCR2_HPVOL(0x3)) | codec_volume; | 307 | adjusting downward so maintain proportion if using volume boost */ |
305 | } | 308 | |
309 | /* HW volume for > 1.0 gain */ | ||
310 | int v = MAX(vol_l, vol_r); | ||
311 | unsigned int hw_volume = v > 0 ? ICDC_CDCCR2_HPVOL(v / 20) : 0; | ||
312 | |||
313 | if((REG_ICDC_CDCCR2 & ICDC_CDCCR2_HPVOL(0x3)) != hw_volume) | ||
314 | REG_ICDC_CDCCR2 = (REG_ICDC_CDCCR2 & ~ICDC_CDCCR2_HPVOL(0x3)) | hw_volume; | ||
306 | } | 315 | } |
307 | 316 | ||
308 | void audiohw_set_frequency(int freq) | 317 | void audiohw_set_frequency(int freq) |