summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio/uda1380.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/uda1380.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/uda1380.c')
-rw-r--r--firmware/drivers/audio/uda1380.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/firmware/drivers/audio/uda1380.c b/firmware/drivers/audio/uda1380.c
index fd32b398ca..9d6ece105b 100644
--- a/firmware/drivers/audio/uda1380.c
+++ b/firmware/drivers/audio/uda1380.c
@@ -40,22 +40,8 @@
40#define USE_WSPLL 40#define USE_WSPLL
41#endif 41#endif
42 42
43const struct sound_settings_info audiohw_settings[] = {
44 [SOUND_VOLUME] = {"dB", 0, 1, -84, 0, -25},
45 [SOUND_BASS] = {"dB", 0, 2, 0, 24, 0},
46 [SOUND_TREBLE] = {"dB", 0, 2, 0, 6, 0},
47 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
48 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
49 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
50#ifdef HAVE_RECORDING
51 [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0},
52 [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0},
53 [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16},
54#endif
55};
56
57/* convert tenth of dB volume (-840..0) to master volume register value */ 43/* convert tenth of dB volume (-840..0) to master volume register value */
58int tenthdb2master(int db) 44static int vol_tenthdb2hw(int db)
59{ 45{
60 if (db < -720) /* 1.5 dB steps */ 46 if (db < -720) /* 1.5 dB steps */
61 return (2940 - db) / 15; 47 return (2940 - db) / 15;
@@ -68,7 +54,7 @@ int tenthdb2master(int db)
68} 54}
69 55
70/* convert tenth of dB volume (-780..0) to mixer volume register value */ 56/* convert tenth of dB volume (-780..0) to mixer volume register value */
71int tenthdb2mixer(int db) 57static int mixer_tenthdb2hw(int db)
72{ 58{
73 if (db < -660) /* 1.5 dB steps */ 59 if (db < -660) /* 1.5 dB steps */
74 return (2640 - db) / 15; 60 return (2640 - db) / 15;
@@ -138,19 +124,12 @@ static int uda1380_write_reg(unsigned char reg, unsigned short value)
138/** 124/**
139 * Sets left and right master volume (0(max) to 252(muted)) 125 * Sets left and right master volume (0(max) to 252(muted))
140 */ 126 */
141void audiohw_set_master_vol(int vol_l, int vol_r) 127void audiohw_set_volume(int vol_l, int vol_r)
142{ 128{
129 vol_l = vol_tenthdb2hw(vol_l);
130 vol_r = vol_tenthdb2hw(vol_r);
143 uda1380_write_reg(REG_MASTER_VOL, 131 uda1380_write_reg(REG_MASTER_VOL,
144 MASTER_VOL_LEFT(vol_l) | MASTER_VOL_RIGHT(vol_r)); 132 MASTER_VOL_LEFT(vol_l) | MASTER_VOL_RIGHT(vol_r));
145}
146
147/**
148 * Sets mixer volume for both channels (0(max) to 228(muted))
149 */
150void audiohw_set_mixer_vol(int channel1, int channel2)
151{
152 uda1380_write_reg(REG_MIX_VOL,
153 MIX_VOL_CH_1(channel1) | MIX_VOL_CH_2(channel2));
154} 133}
155 134
156/** 135/**
@@ -285,7 +264,9 @@ void audiohw_postinit(void)
285 264
286void audiohw_set_prescaler(int val) 265void audiohw_set_prescaler(int val)
287{ 266{
288 audiohw_set_mixer_vol(tenthdb2mixer(-val), tenthdb2mixer(-val)); 267 val = mixer_tenthdb2hw(-val);
268 uda1380_write_reg(REG_MIX_VOL,
269 MIX_VOL_CH_1(val) | MIX_VOL_CH_2(val));
289} 270}
290 271
291/* Nice shutdown of UDA1380 codec */ 272/* Nice shutdown of UDA1380 codec */