summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio/wm8985.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/audio/wm8985.c')
-rw-r--r--firmware/drivers/audio/wm8985.c46
1 files changed, 17 insertions, 29 deletions
diff --git a/firmware/drivers/audio/wm8985.c b/firmware/drivers/audio/wm8985.c
index 06b3fa3b44..2d49e706c8 100644
--- a/firmware/drivers/audio/wm8985.c
+++ b/firmware/drivers/audio/wm8985.c
@@ -88,32 +88,12 @@
88#define OUT4MIX 0x39 88#define OUT4MIX 0x39
89#define BIASCTL 0x3d 89#define BIASCTL 0x3d
90 90
91const struct sound_settings_info audiohw_settings[] = {
92 [SOUND_VOLUME] = {"dB", 0, 1, -90, 6, -25},
93 [SOUND_BASS] = {"dB", 0, 1, -12, 12, 0},
94 [SOUND_TREBLE] = {"dB", 0, 1, -12, 12, 0},
95 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
96 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
97 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
98#ifdef HAVE_RECORDING
99 [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0},
100 [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0},
101 [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16},
102#endif
103#ifdef AUDIOHW_HAVE_BASS_CUTOFF
104 [SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 1},
105#endif
106#ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
107 [SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1},
108#endif
109};
110
111/* shadow registers */ 91/* shadow registers */
112static unsigned int eq1_reg; 92static unsigned int eq1_reg;
113static unsigned int eq5_reg; 93static unsigned int eq5_reg;
114 94
115/* convert tenth of dB volume (-89..6) to master volume register value */ 95/* convert tenth of dB volume (-89..6) to master volume register value */
116int tenthdb2master(int db) 96static int vol_tenthdb2hw(int db)
117{ 97{
118 /* Might have no sense, taken from wm8758.c : 98 /* Might have no sense, taken from wm8758.c :
119 att DAC AMP result 99 att DAC AMP result
@@ -216,9 +196,13 @@ void audiohw_postinit(void)
216 audiohw_mute(0); 196 audiohw_mute(0);
217} 197}
218 198
219void audiohw_set_headphone_vol(int vol_l, int vol_r) 199void audiohw_set_volume(int vol_l, int vol_r)
220{ 200{
221 int dac_l, amp_l, dac_r, amp_r; 201 int dac_l, amp_l, dac_r, amp_r;
202
203 vol_l = vol_tenthdb2hw(vol_l);
204 vol_r = vol_tenthdb2hw(vol_r);
205
222 get_volume_params(vol_l, &dac_l, &amp_l); 206 get_volume_params(vol_l, &dac_l, &amp_l);
223 get_volume_params(vol_r, &dac_r, &amp_r); 207 get_volume_params(vol_r, &dac_r, &amp_r);
224 208
@@ -232,15 +216,19 @@ void audiohw_set_headphone_vol(int vol_l, int vol_r)
232 wmcodec_write(ROUT1VOL, amp_r | 0x180); 216 wmcodec_write(ROUT1VOL, amp_r | 0x180);
233} 217}
234 218
235void audiohw_set_lineout_vol(int vol_l, int vol_r) 219void audiohw_set_lineout_volume(int vol_l, int vol_r)
236{ 220{
237 int dac_l, amp_l, dac_r, amp_r; 221 int dac_l, amp_l, dac_r, amp_r;
238 get_volume_params(vol_l, &dac_l, &amp_l); 222
239 get_volume_params(vol_r, &dac_r, &amp_r); 223 vol_l = vol_tenthdb2hw(vol_l);
224 vol_r = vol_tenthdb2hw(vol_r);
225
226 get_volume_params(vol_l, &dac_l, &amp_l);
227 get_volume_params(vol_r, &dac_r, &amp_r);
240 228
241 /* set lineout amp OUT2 */ 229 /* set lineout amp OUT2 */
242 wmcodec_write(LOUT2VOL, amp_l); 230 wmcodec_write(LOUT2VOL, amp_l);
243 wmcodec_write(ROUT2VOL, amp_r | 0x100); 231 wmcodec_write(ROUT2VOL, amp_r | 0x100);
244} 232}
245 233
246void audiohw_set_aux_vol(int vol_l, int vol_r) 234void audiohw_set_aux_vol(int vol_l, int vol_r)