diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2008-04-28 08:37:18 +0000 |
---|---|---|
committer | Christian Gmeiner <christian.gmeiner@gmail.com> | 2008-04-28 08:37:18 +0000 |
commit | 8391526f794b296e5b6edd5707bbf25b5be73e17 (patch) | |
tree | c35e4565831b3a822394e98da32dc79db339345b /firmware/sound.c | |
parent | 17f7adb90d232e6dece891790405d1b99b5b8215 (diff) | |
download | rockbox-8391526f794b296e5b6edd5707bbf25b5be73e17.tar.gz rockbox-8391526f794b296e5b6edd5707bbf25b5be73e17.zip |
* introduce AUDIOHW_CAPS to define which audio codec can do what kind of operations in hw, e.g. setting bass
* added documentation why and when we need the software based prescaler
* implement audiohw_set_bass and audiohw_set_treble for mas35xx
* clean up sound_set_bass and sound_set_treble
* simplify some #ifdef logic
* fix special handling of WM8751 - looking for tester :)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17274 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/sound.c')
-rw-r--r-- | firmware/sound.c | 74 |
1 files changed, 29 insertions, 45 deletions
diff --git a/firmware/sound.c b/firmware/sound.c index eda223bff0..325c42639a 100644 --- a/firmware/sound.c +++ b/firmware/sound.c | |||
@@ -222,10 +222,20 @@ static int tenthdb2reg(int db) | |||
222 | } | 222 | } |
223 | #endif | 223 | #endif |
224 | 224 | ||
225 | #if (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 \ | 225 | |
226 | || defined HAVE_WM8975 || defined HAVE_WM8758 || defined(HAVE_WM8731) \ | 226 | /* MAS3587F and MAS3539F handle clipping prevention internally so we do not need |
227 | || defined(HAVE_WM8721) || defined(HAVE_TLV320) || defined(HAVE_WM8751) \ | 227 | * the prescaler. |
228 | || defined(HAVE_AS3514) || defined(HAVE_WM8985) || defined(HAVE_TSC2100) | 228 | */ |
229 | #if (CONFIG_CODEC != MAS3587F) && (CONFIG_CODEC != MAS3539F) | ||
230 | |||
231 | /* | ||
232 | * The prescaler compensates for any kind of boosts, to prevent clipping. | ||
233 | * | ||
234 | * It's basically just a measure to make sure that audio does not clip during | ||
235 | * tone controls processing, like if i want to boost bass 12 dB, i can decrease | ||
236 | * the audio amplitude by -12 dB before processing, then increase master gain | ||
237 | * by 12 dB after processing. | ||
238 | */ | ||
229 | 239 | ||
230 | /* all values in tenth of dB MAS3507D UDA1380 */ | 240 | /* all values in tenth of dB MAS3507D UDA1380 */ |
231 | int current_volume = 0; /* -780..+180 -840.. 0 */ | 241 | int current_volume = 0; /* -780..+180 -840.. 0 */ |
@@ -352,60 +362,34 @@ void sound_set_bass(int value) | |||
352 | { | 362 | { |
353 | if(!audio_is_initialized) | 363 | if(!audio_is_initialized) |
354 | return; | 364 | return; |
355 | #if defined(HAVE_SW_TONE_CONTROLS) | 365 | |
356 | current_bass = value * 10; | 366 | #if defined(AUDIOHW_HAVE_BASS) |
357 | dsp_callback(DSP_CALLBACK_SET_BASS, current_bass); | ||
358 | set_prescaled_volume(); | ||
359 | #elif (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
360 | unsigned tmp = ((unsigned)(value * 8) & 0xff) << 8; | ||
361 | mas_codec_writereg(0x14, tmp); | ||
362 | #elif CONFIG_CODEC == MAS3507D | ||
363 | mas_writereg(MAS_REG_KBASS, bass_table[value+15]); | ||
364 | current_bass = value * 10; | ||
365 | set_prescaled_volume(); | ||
366 | #elif defined(HAVE_WM8751) | ||
367 | current_bass = value; | ||
368 | audiohw_set_bass(value); | 367 | audiohw_set_bass(value); |
369 | set_prescaled_volume(); | 368 | #else |
370 | #elif defined HAVE_WM8975 || defined HAVE_WM8758 || defined(HAVE_UDA1380) \ | 369 | dsp_callback(DSP_CALLBACK_SET_BASS, current_bass); |
371 | || defined HAVE_WM8731 || defined(HAVE_WM8721) || defined(HAVE_WM8985) | 370 | #endif |
371 | |||
372 | #if (CONFIG_CODEC != MAS3587F) && (CONFIG_CODEC != MAS3539F) | ||
372 | current_bass = value * 10; | 373 | current_bass = value * 10; |
373 | audiohw_set_bass(value); | ||
374 | set_prescaled_volume(); | 374 | set_prescaled_volume(); |
375 | #elif CONFIG_CPU == PNX0101 | 375 | #endif |
376 | /* TODO: implement for iFP */ | ||
377 | #endif | ||
378 | (void)value; | ||
379 | } | 376 | } |
380 | 377 | ||
381 | void sound_set_treble(int value) | 378 | void sound_set_treble(int value) |
382 | { | 379 | { |
383 | if(!audio_is_initialized) | 380 | if(!audio_is_initialized) |
384 | return; | 381 | return; |
385 | #if defined(HAVE_SW_TONE_CONTROLS) | 382 | |
386 | current_treble = value * 10; | 383 | #if defined(AUDIOHW_HAVE_TREBLE) |
387 | dsp_callback(DSP_CALLBACK_SET_TREBLE, current_treble); | ||
388 | set_prescaled_volume(); | ||
389 | #elif (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
390 | unsigned tmp = ((unsigned)(value * 8) & 0xff) << 8; | ||
391 | mas_codec_writereg(0x15, tmp); | ||
392 | #elif CONFIG_CODEC == MAS3507D | ||
393 | mas_writereg(MAS_REG_KTREBLE, treble_table[value+15]); | ||
394 | current_treble = value * 10; | ||
395 | set_prescaled_volume(); | ||
396 | #elif defined(HAVE_WM8751) | ||
397 | audiohw_set_treble(value); | ||
398 | current_treble = value; | ||
399 | set_prescaled_volume(); | ||
400 | #elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_UDA1380) \ | ||
401 | || defined(HAVE_WM8731) || defined(HAVE_WM8721) || defined(HAVE_WM8985) | ||
402 | audiohw_set_treble(value); | 384 | audiohw_set_treble(value); |
385 | #else | ||
386 | dsp_callback(DSP_CALLBACK_SET_TREBLE, current_treble); | ||
387 | #endif | ||
388 | |||
389 | #if (CONFIG_CODEC != MAS3587F) && (CONFIG_CODEC != MAS3539F) | ||
403 | current_treble = value * 10; | 390 | current_treble = value * 10; |
404 | set_prescaled_volume(); | 391 | set_prescaled_volume(); |
405 | #elif CONFIG_CPU == PNX0101 | ||
406 | /* TODO: implement for iFP */ | ||
407 | #endif | 392 | #endif |
408 | (void)value; | ||
409 | } | 393 | } |
410 | 394 | ||
411 | void sound_set_channels(int value) | 395 | void sound_set_channels(int value) |