summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio/uda1341.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-04-12 23:35:47 -0400
committerMichael Sevakis <jethead71@rockbox.org>2013-04-15 12:02:05 -0400
commit0c7b7873984e04941c9f21fa272638018fdb9a16 (patch)
treefb6afca45d2bef0a2c91732a39ffc0b965f5c557 /firmware/drivers/audio/uda1341.c
parentfd9e2568908f91b5bcf7378dc28f6ec070d6027a (diff)
downloadrockbox-0c7b7873984e04941c9f21fa272638018fdb9a16.tar.gz
rockbox-0c7b7873984e04941c9f21fa272638018fdb9a16.zip
Straighten out the mad twisted state of sound.c and related areas.
This is going right in since it's long overdue. If anything is goofed, drop me a line or just tweak it yourself if you know what's wrong. :-) Make HW/SW codec interface more uniform when emulating HW functionality on SWCODEC for functions such as "audiohw_set_pitch". The firmware-to- DSP plumbing is in firmware/drivers/audiohw-swcodec.c. "sound_XXX" APIs are all in sound.c with none in DSP code any longer. Reduce number of settings definitions needed by each codec by providing defaults for common ones like balance, channels and SW tone controls. Remove need for separate SIM code and tables and add virtual codec header for hosted targets. Change-Id: I3f23702bca054fc9bda40f49824ce681bb7f777b
Diffstat (limited to 'firmware/drivers/audio/uda1341.c')
-rw-r--r--firmware/drivers/audio/uda1341.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/firmware/drivers/audio/uda1341.c b/firmware/drivers/audio/uda1341.c
index 6b38353afe..ac3bcedb7d 100644
--- a/firmware/drivers/audio/uda1341.c
+++ b/firmware/drivers/audio/uda1341.c
@@ -28,23 +28,8 @@
28 28
29#include "audiohw.h" 29#include "audiohw.h"
30 30
31 31/* convert tenth of dB volume (-600..0) to volume register value */
32const struct sound_settings_info audiohw_settings[] = { 32static int vol_tenthdb2hw(int db)
33 [SOUND_VOLUME] = {"dB", 0, 1, -84, 0, -25},
34 [SOUND_BASS] = {"dB", 0, 2, 0, 24, 0},
35 [SOUND_TREBLE] = {"dB", 0, 2, 0, 6, 0},
36 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, /* not used */
37 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, /* not used */
38 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100}, /* not used */
39#ifdef HAVE_RECORDING
40 [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0},
41 [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0},
42 [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16},
43#endif
44};
45
46/* convert tenth of dB volume (-600..0) to master volume register value */
47int tenthdb2master(int db)
48{ 33{
49 if (db < -600) 34 if (db < -600)
50 return 63; 35 return 63;
@@ -229,11 +214,12 @@ void audiohw_set_prescaler(int val)
229#endif /* AUDIOHW_HAVE_PRESCALER */ 214#endif /* AUDIOHW_HAVE_PRESCALER */
230 215
231/** 216/**
232 * Sets left and right master volume (1(max) to 62(muted)) 217 * Set master volume (1(max) to 62(muted))
233 */ 218 */
234void audiohw_set_master_vol(int vol_l, int vol_r) 219void audiohw_set_volume(int volume)
235{ 220{
236 uda_regs[UDA_REG_ID_CTRL0] = (vol_l + vol_r) / 2; 221 volume = vol_tenthdb2hw(volume) / 2;
222 uda_regs[UDA_REG_ID_CTRL0] = volume;
237 udacodec_write (UDA_REG_DATA0, UDA_DATA_CTRL0 | uda_regs[UDA_REG_ID_CTRL0]); 223 udacodec_write (UDA_REG_DATA0, UDA_DATA_CTRL0 | uda_regs[UDA_REG_ID_CTRL0]);
238} 224}
239 225