summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio/wm8751.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/audio/wm8751.c')
-rw-r--r--firmware/drivers/audio/wm8751.c75
1 files changed, 13 insertions, 62 deletions
diff --git a/firmware/drivers/audio/wm8751.c b/firmware/drivers/audio/wm8751.c
index 4cb85db436..feba05e504 100644
--- a/firmware/drivers/audio/wm8751.c
+++ b/firmware/drivers/audio/wm8751.c
@@ -32,35 +32,6 @@
32#include "system.h" 32#include "system.h"
33#include "sound.h" 33#include "sound.h"
34 34
35const struct sound_settings_info audiohw_settings[] = {
36 [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25},
37 [SOUND_BASS] = {"dB", 1, 15, -60, 90, 0},
38 [SOUND_TREBLE] = {"dB", 1, 15, -60, 90, 0},
39 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
40 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
41 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
42#ifdef HAVE_RECORDING
43 /* PGA -17.25dB to 30.0dB in 0.75dB increments 64 steps
44 * digital gain 0dB to 30.0dB in 0.5dB increments
45 * we use 0.75dB fake steps through whole range
46 *
47 * This combined gives -17.25 to 60.0dB
48 */
49 [SOUND_LEFT_GAIN] = {"dB", 2, 75, -1725, 6000, 0},
50 [SOUND_RIGHT_GAIN] = {"dB", 2, 75, -1725, 6000, 0},
51 [SOUND_MIC_GAIN] = {"dB", 2, 75, -1725, 6000, 3000},
52#endif
53#ifdef AUDIOHW_HAVE_BASS_CUTOFF
54 [SOUND_BASS_CUTOFF] = {"Hz", 0, 70, 130, 200, 200},
55#endif
56#ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
57 [SOUND_TREBLE_CUTOFF] = {"kHz", 0, 4, 4, 8, 4},
58#endif
59#ifdef AUDIOHW_HAVE_DEPTH_3D
60 [SOUND_DEPTH_3D] = {"%", 0, 1, 0, 15, 0},
61#endif
62};
63
64static uint16_t wmcodec_regs[WM_NUM_REGS] = 35static uint16_t wmcodec_regs[WM_NUM_REGS] =
65{ 36{
66 [0 ... WM_NUM_REGS-1] = 0x200, /* set invalid data in gaps */ 37 [0 ... WM_NUM_REGS-1] = 0x200, /* set invalid data in gaps */
@@ -139,7 +110,7 @@ static void wmcodec_set_masked(unsigned int reg, unsigned int val,
139} 110}
140 111
141/* convert tenth of dB volume (-730..60) to master volume register value */ 112/* convert tenth of dB volume (-730..60) to master volume register value */
142int tenthdb2master(int db) 113static int vol_tenthdb2hw(int db)
143{ 114{
144 /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ 115 /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */
145 /* 1111111 == +6dB (0x7f) */ 116 /* 1111111 == +6dB (0x7f) */
@@ -186,25 +157,6 @@ void audiohw_set_treble_cutoff(int val)
186} 157}
187#endif 158#endif
188 159
189
190int sound_val2phys(int setting, int value)
191{
192 int result;
193
194 switch (setting)
195 {
196#ifdef AUDIOHW_HAVE_DEPTH_3D
197 case SOUND_DEPTH_3D:
198 result = (100 * value + 8) / 15;
199 break;
200#endif
201 default:
202 result = value;
203 }
204
205 return result;
206}
207
208static void audiohw_mute(bool mute) 160static void audiohw_mute(bool mute)
209{ 161{
210 /* Mute: Set DACMU = 1 to soft-mute the audio DACs. */ 162 /* Mute: Set DACMU = 1 to soft-mute the audio DACs. */
@@ -335,40 +287,39 @@ void audiohw_postinit(void)
335#endif 287#endif
336} 288}
337 289
338void audiohw_set_master_vol(int vol_l, int vol_r) 290void audiohw_set_volume(int vol_l, int vol_r)
339{ 291{
340 /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ 292 vol_l = vol_tenthdb2hw(vol_l);
341 /* 1111111 == +6dB */ 293 vol_r = vol_tenthdb2hw(vol_r);
342 /* 1111001 == 0dB */
343 /* 0110000 == -73dB */
344 /* 0101111 == mute (0x2f) */
345
346 wmcodec_set_masked(LOUT1, LOUT1_LOUT1VOL(vol_l), 294 wmcodec_set_masked(LOUT1, LOUT1_LOUT1VOL(vol_l),
347 LOUT1_LOUT1VOL_MASK); 295 LOUT1_LOUT1VOL_MASK);
348 wmcodec_set_masked(ROUT1, ROUT1_RO1VU | ROUT1_ROUT1VOL(vol_r), 296 wmcodec_set_masked(ROUT1, ROUT1_RO1VU | ROUT1_ROUT1VOL(vol_r),
349 ROUT1_ROUT1VOL_MASK); 297 ROUT1_ROUT1VOL_MASK);
350} 298}
351 299
352#ifdef TOSHIBA_GIGABEAT_F 300#ifdef AUDIOHW_HAVE_LINEOUT
353void audiohw_set_lineout_vol(int vol_l, int vol_r) 301void audiohw_set_lineout_volume(int vol_l, int vol_r)
354{ 302{
303 vol_l = vol_tenthdb2hw(vol_l);
304 vol_r = vol_tenthdb2hw(vol_r);
355 wmcodec_set_masked(LOUT2, LOUT2_LOUT2VOL(vol_l), 305 wmcodec_set_masked(LOUT2, LOUT2_LOUT2VOL(vol_l),
356 LOUT2_LOUT2VOL_MASK); 306 LOUT2_LOUT2VOL_MASK);
357 wmcodec_set_masked(ROUT2, ROUT2_RO2VU | ROUT2_ROUT2VOL(vol_r), 307 wmcodec_set_masked(ROUT2, ROUT2_RO2VU | ROUT2_ROUT2VOL(vol_r),
358 ROUT2_ROUT2VOL_MASK); 308 ROUT2_ROUT2VOL_MASK);
359} 309}
360#endif 310#endif /* AUDIOHW_HAVE_LINEOUT */
361 311
362void audiohw_set_bass(int value) 312void audiohw_set_bass(int value)
363{ 313{
364 wmcodec_set_masked(BASSCTRL, 314 value = tone_tenthdb2hw(value);
365 BASSCTRL_BASS(tone_tenthdb2hw(value)), 315 wmcodec_set_masked(BASSCTRL, BASSCTRL_BASS(value),
366 BASSCTRL_BASS_MASK); 316 BASSCTRL_BASS_MASK);
367} 317}
368 318
369void audiohw_set_treble(int value) 319void audiohw_set_treble(int value)
370{ 320{
371 wmcodec_set_masked(TREBCTRL, TREBCTRL_TREB(tone_tenthdb2hw(value)), 321 value = tone_tenthdb2hw(value);
322 wmcodec_set_masked(TREBCTRL, TREBCTRL_TREB(value),
372 TREBCTRL_TREB_MASK); 323 TREBCTRL_TREB_MASK);
373} 324}
374 325