summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio/wm8758.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/audio/wm8758.c')
-rw-r--r--firmware/drivers/audio/wm8758.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/firmware/drivers/audio/wm8758.c b/firmware/drivers/audio/wm8758.c
index 1cfac7c7cb..a9f10fbe67 100644
--- a/firmware/drivers/audio/wm8758.c
+++ b/firmware/drivers/audio/wm8758.c
@@ -33,16 +33,22 @@
33 33
34const struct sound_settings_info audiohw_settings[] = { 34const struct sound_settings_info audiohw_settings[] = {
35 [SOUND_VOLUME] = {"dB", 0, 1, -58, 6, -25}, 35 [SOUND_VOLUME] = {"dB", 0, 1, -58, 6, -25},
36 [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0}, 36 [SOUND_BASS] = {"dB", 0, 1, -12, 12, 0},
37 [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0}, 37 [SOUND_TREBLE] = {"dB", 0, 1, -12, 12, 0},
38 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, 38 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
39 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, 39 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
40 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100}, 40 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
41 [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0}, 41 [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0},
42 [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0}, 42 [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0},
43 [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16}, 43 [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16},
44 [SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 1},
45 [SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1},
44}; 46};
45 47
48/* shadow registers */
49unsigned int eq1_reg;
50unsigned int eq5_reg;
51
46/* convert tenth of dB volume (-57..6) to master volume register value */ 52/* convert tenth of dB volume (-57..6) to master volume register value */
47int tenthdb2master(int db) 53int tenthdb2master(int db)
48{ 54{
@@ -138,15 +144,28 @@ int audiohw_set_mixer_vol(int channel1, int channel2)
138 return 0; 144 return 0;
139} 145}
140 146
141/* We are using Linear bass control */
142void audiohw_set_bass(int value) 147void audiohw_set_bass(int value)
143{ 148{
144 (void)value; 149 eq1_reg = (eq1_reg & ~EQ_GAIN_MASK) | EQ_GAIN_VALUE(value);
150 wmcodec_write(EQ1, 0x100 | eq1_reg);
151}
152
153void audiohw_set_bass_cutoff(int value)
154{
155 eq1_reg = (eq1_reg & ~EQ_CUTOFF_MASK) | EQ_CUTOFF_VALUE(value);
156 wmcodec_write(EQ1, 0x100 | eq1_reg);
145} 157}
146 158
147void audiohw_set_treble(int value) 159void audiohw_set_treble(int value)
148{ 160{
149 (void)value; 161 eq5_reg = (eq5_reg & ~EQ_GAIN_MASK) | EQ_GAIN_VALUE(value);
162 wmcodec_write(EQ5, eq5_reg);
163}
164
165void audiohw_set_treble_cutoff(int value)
166{
167 eq5_reg = (eq5_reg & ~EQ_CUTOFF_MASK) | EQ_CUTOFF_VALUE(value);
168 wmcodec_write(EQ5, eq5_reg);
150} 169}
151 170
152void audiohw_mute(bool mute) 171void audiohw_mute(bool mute)
@@ -271,27 +290,3 @@ void audiohw_set_monitor(bool enable) {
271 (void)enable; 290 (void)enable;
272} 291}
273 292
274void audiohw_set_equalizer_band(int band, int freq, int bw, int gain)
275{
276 unsigned int eq = 0;
277
278 /* Band 1..3 are peak filters */
279 if (band >= 1 && band <= 3) {
280 eq |= (bw << 8);
281 }
282
283 eq |= (freq << 5);
284 eq |= 12 - gain;
285
286 if (band == 0) {
287 wmcodec_write(EQ1, eq | 0x100); /* Always apply EQ to the DAC path */
288 } else if (band == 1) {
289 wmcodec_write(EQ2, eq);
290 } else if (band == 2) {
291 wmcodec_write(EQ3, eq);
292 } else if (band == 3) {
293 wmcodec_write(EQ4, eq);
294 } else if (band == 4) {
295 wmcodec_write(EQ5, eq);
296 }
297}