summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/wm8975.c37
-rw-r--r--firmware/sound.c13
2 files changed, 26 insertions, 24 deletions
diff --git a/firmware/drivers/wm8975.c b/firmware/drivers/wm8975.c
index 89e0b155da..9052236131 100644
--- a/firmware/drivers/wm8975.c
+++ b/firmware/drivers/wm8975.c
@@ -53,7 +53,7 @@ int tenthdb2master(int db)
53 /* 1111111 == +6dB (0x7f) */ 53 /* 1111111 == +6dB (0x7f) */
54 /* 1111001 == 0dB (0x79) */ 54 /* 1111001 == 0dB (0x79) */
55 /* 0110000 == -73dB (0x30 */ 55 /* 0110000 == -73dB (0x30 */
56 /* 0101111 == mute (0x2f) */ 56 /* 0101111..0000000 == mute (0x2f) */
57 57
58 if (db < VOLUME_MIN) { 58 if (db < VOLUME_MIN) {
59 return 0x0; 59 return 0x0;
@@ -65,14 +65,8 @@ int tenthdb2master(int db)
65/* convert tenth of dB volume (-780..0) to mixer volume register value */ 65/* convert tenth of dB volume (-780..0) to mixer volume register value */
66int tenthdb2mixer(int db) 66int tenthdb2mixer(int db)
67{ 67{
68 if (db < -660) /* 1.5 dB steps */ 68 (void)db;
69 return (2640 - db) / 15; 69 return 0;
70 else if (db < -600) /* 0.75 dB steps */
71 return (990 - db) * 2 / 15;
72 else if (db < -460) /* 0.5 dB steps */
73 return (460 - db) / 5;
74 else /* 0.25 dB steps */
75 return -db * 2 / 5;
76} 70}
77 71
78 72
@@ -171,25 +165,28 @@ int audiohw_set_mixer_vol(int channel1, int channel2)
171 return 0; 165 return 0;
172} 166}
173 167
174/* We are using Linear bass control */
175void audiohw_set_bass(int value) 168void audiohw_set_bass(int value)
176{ 169{
177 int regvalues[]={11, 10, 10, 9, 8, 8, 0xf , 6, 6, 5, 4, 4, 3, 2, 1, 0}; 170 const int regvalues[] = {
171 11, 10, 10, 9, 8, 8, 0xf, 6, 6, 5, 4, 4, 3, 2, 1, 0
172 };
178 173
179 if ((value >= -6) && (value <= 9)) { 174 if ((value >= -6) && (value <= 9)) {
180 /* We use linear bass control with 130Hz cutoff */ 175 /* We use linear bass control with 200 Hz cutoff */
181 wmcodec_write(BASSCTRL, regvalues[value+6]); 176 wmcodec_write(BASSCTRL, regvalues[value + 6] | 0x40);
182 } 177 }
183} 178}
184 179
185void audiohw_set_treble(int value) 180void audiohw_set_treble(int value)
186{ 181{
187 int regvalues[]={11, 10, 10, 9, 8, 8, 0xf , 6, 6, 5, 4, 4, 3, 2, 1, 0}; 182 const int regvalues[] = {
183 11, 10, 10, 9, 8, 8, 0xf, 6, 6, 5, 4, 4, 3, 2, 1, 0
184 };
188 185
189 if ((value >= -6) && (value <= 9)) { 186 if ((value >= -6) && (value <= 9)) {
190 /* We use a 8Khz cutoff */ 187 /* We use linear treble control with 4 kHz cutoff */
191 wmcodec_write(TREBCTRL, regvalues[value+6]); 188 wmcodec_write(TREBCTRL, regvalues[value + 6] | 0x40);
192 } 189 }
193} 190}
194 191
195int audiohw_mute(int mute) 192int audiohw_mute(int mute)
diff --git a/firmware/sound.c b/firmware/sound.c
index 01d76a0a39..6182e6b567 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -312,9 +312,14 @@ int current_bass = 0; /* -150..+150 0..+240 */
312 312
313static void set_prescaled_volume(void) 313static void set_prescaled_volume(void)
314{ 314{
315 int prescale; 315 int prescale = 0;
316 int l, r; 316 int l, r;
317 317
318/* The WM codecs listed don't have suitable prescaler functionality, so we let
319 * the prescaler stay at 0 for these unless SW tone controls are in use */
320#if defined(HAVE_SW_TONE_CONTROLS) || !(defined(HAVE_WM8975) \
321 || defined(HAVE_WM8731) || defined(HAVE_WM8721) || defined(HAVE_WM8751))
322
318 prescale = MAX(current_bass, current_treble); 323 prescale = MAX(current_bass, current_treble);
319 if (prescale < 0) 324 if (prescale < 0)
320 prescale = 0; /* no need to prescale if we don't boost 325 prescale = 0; /* no need to prescale if we don't boost
@@ -325,13 +330,13 @@ static void set_prescaled_volume(void)
325 * instead (might cause clipping). */ 330 * instead (might cause clipping). */
326 if (current_volume + prescale > VOLUME_MAX) 331 if (current_volume + prescale > VOLUME_MAX)
327 prescale = VOLUME_MAX - current_volume; 332 prescale = VOLUME_MAX - current_volume;
328 333#endif
334
329#if defined(HAVE_SW_TONE_CONTROLS) 335#if defined(HAVE_SW_TONE_CONTROLS)
330 dsp_callback(DSP_CALLBACK_SET_PRESCALE, prescale); 336 dsp_callback(DSP_CALLBACK_SET_PRESCALE, prescale);
331#elif CONFIG_CODEC == MAS3507D 337#elif CONFIG_CODEC == MAS3507D
332 mas_writereg(MAS_REG_KPRESCALE, prescale_table[prescale/10]); 338 mas_writereg(MAS_REG_KPRESCALE, prescale_table[prescale/10]);
333#elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \ 339#elif defined(HAVE_UDA1380) || defined(HAVE_WM8758)
334 || defined(HAVE_WM8731) || defined(HAVE_WM8721) || defined(HAVE_WM8751)
335 audiohw_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale)); 340 audiohw_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale));
336#endif 341#endif
337 342