diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2010-05-11 04:02:45 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2010-05-11 04:02:45 +0000 |
commit | 8ce5b01ec717a8ee1d765ec9c0d4d6f20868092e (patch) | |
tree | 00469290ec43bbf5493c14226d766a164b6562d6 | |
parent | 7d21e5ab32ef24724c201b5ffc4df3a2637966e7 (diff) | |
download | rockbox-8ce5b01ec717a8ee1d765ec9c0d4d6f20868092e.tar.gz rockbox-8ce5b01ec717a8ee1d765ec9c0d4d6f20868092e.zip |
MRobe100, HD200, Gigabeat F/X (anything with wm8750 or wm8751). Properly prescale bass and treble controls to avoid clipping.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25940 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/drivers/audio/wm8751.c | 14 | ||||
-rw-r--r-- | firmware/export/wm8751.h | 8 | ||||
-rw-r--r-- | firmware/sound.c | 7 |
3 files changed, 21 insertions, 8 deletions
diff --git a/firmware/drivers/audio/wm8751.c b/firmware/drivers/audio/wm8751.c index 18441826d4..e7c0b18da3 100644 --- a/firmware/drivers/audio/wm8751.c +++ b/firmware/drivers/audio/wm8751.c | |||
@@ -61,6 +61,8 @@ const struct sound_settings_info audiohw_settings[] = { | |||
61 | /* We use linear treble control with 4 kHz cutoff */ | 61 | /* We use linear treble control with 4 kHz cutoff */ |
62 | #define TREBCTRL_BITS (TREBCTRL_TC) | 62 | #define TREBCTRL_BITS (TREBCTRL_TC) |
63 | 63 | ||
64 | static int prescaler = 0; | ||
65 | |||
64 | /* convert tenth of dB volume (-730..60) to master volume register value */ | 66 | /* convert tenth of dB volume (-730..60) to master volume register value */ |
65 | int tenthdb2master(int db) | 67 | int tenthdb2master(int db) |
66 | { | 68 | { |
@@ -173,6 +175,10 @@ void audiohw_postinit(void) | |||
173 | PWRMGMT2_ROUT2); | 175 | PWRMGMT2_ROUT2); |
174 | #endif | 176 | #endif |
175 | 177 | ||
178 | /* Full -0dB on the DACS */ | ||
179 | wmcodec_write(LEFTGAIN, 0xff); | ||
180 | wmcodec_write(RIGHTGAIN, RIGHTGAIN_RDVU | 0xff); | ||
181 | |||
176 | wmcodec_write(ADDITIONAL1, ADDITIONAL1_TSDEN | ADDITIONAL1_TOEN | | 182 | wmcodec_write(ADDITIONAL1, ADDITIONAL1_TSDEN | ADDITIONAL1_TOEN | |
177 | ADDITIONAL1_DMONOMIX_LLRR | ADDITIONAL1_VSEL_DEFAULT); | 183 | ADDITIONAL1_DMONOMIX_LLRR | ADDITIONAL1_VSEL_DEFAULT); |
178 | 184 | ||
@@ -249,6 +255,14 @@ void audiohw_set_treble(int value) | |||
249 | TREBCTRL_TREB(tone_tenthdb2hw(value))); | 255 | TREBCTRL_TREB(tone_tenthdb2hw(value))); |
250 | } | 256 | } |
251 | 257 | ||
258 | void audiohw_set_prescaler(int value) | ||
259 | { | ||
260 | prescaler = 2 * value; | ||
261 | wmcodec_write(LEFTGAIN, 0xff - (prescaler & LEFTGAIN_LDACVOL)); | ||
262 | wmcodec_write(RIGHTGAIN, RIGHTGAIN_RDVU | | ||
263 | (0xff - (prescaler & RIGHTGAIN_RDACVOL))); | ||
264 | } | ||
265 | |||
252 | /* Nice shutdown of WM8751 codec */ | 266 | /* Nice shutdown of WM8751 codec */ |
253 | void audiohw_close(void) | 267 | void audiohw_close(void) |
254 | { | 268 | { |
diff --git a/firmware/export/wm8751.h b/firmware/export/wm8751.h index fb7532bfd8..8992c88076 100644 --- a/firmware/export/wm8751.h +++ b/firmware/export/wm8751.h | |||
@@ -25,7 +25,7 @@ | |||
25 | #define VOLUME_MIN -730 | 25 | #define VOLUME_MIN -730 |
26 | #define VOLUME_MAX 60 | 26 | #define VOLUME_MAX 60 |
27 | 27 | ||
28 | #define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP) | 28 | #define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | PRESCALER_CAP) |
29 | 29 | ||
30 | extern int tenthdb2master(int db); | 30 | extern int tenthdb2master(int db); |
31 | 31 | ||
@@ -96,12 +96,12 @@ void audiohw_set_recsrc(int source, bool recording); | |||
96 | #define CLOCKING_BCLK_DIV2 (1 << 7) | 96 | #define CLOCKING_BCLK_DIV2 (1 << 7) |
97 | 97 | ||
98 | #define LEFTGAIN 0x0a | 98 | #define LEFTGAIN 0x0a |
99 | #define LEFTGAIN_LDACVOL(x) ((x) & 0xff) | 99 | #define LEFTGAIN_LDACVOL 0xff |
100 | #define LEFTGAIN_LDVU (1 << 8) | 100 | #define LEFTGAIN_LDVU (1 << 8) |
101 | 101 | ||
102 | #define RIGHTGAIN 0x0b | 102 | #define RIGHTGAIN 0x0b |
103 | #define RIGHTGAIN_LDACVOL(x) ((x) & 0xff) | 103 | #define RIGHTGAIN_RDACVOL 0xff |
104 | #define RIGHTGAIN_LDVU (1 << 8) | 104 | #define RIGHTGAIN_RDVU (1 << 8) |
105 | 105 | ||
106 | #define BASSCTRL 0x0c | 106 | #define BASSCTRL 0x0c |
107 | #define BASSCTRL_BASS(x) ((x) & 0xf) | 107 | #define BASSCTRL_BASS(x) ((x) & 0xf) |
diff --git a/firmware/sound.c b/firmware/sound.c index 4f95b6ed50..2973721e1c 100644 --- a/firmware/sound.c +++ b/firmware/sound.c | |||
@@ -189,8 +189,7 @@ static void set_prescaled_volume(void) | |||
189 | */ | 189 | */ |
190 | #if defined(HAVE_SW_TONE_CONTROLS) || !(defined(HAVE_WM8975) \ | 190 | #if defined(HAVE_SW_TONE_CONTROLS) || !(defined(HAVE_WM8975) \ |
191 | || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \ | 191 | || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \ |
192 | || defined(HAVE_WM8751) || defined(HAVE_WM8758) || defined(HAVE_WM8985) \ | 192 | || defined(HAVE_WM8758) || defined(HAVE_WM8985) || defined(HAVE_UDA1341)) |
193 | || defined(HAVE_UDA1341)) | ||
194 | 193 | ||
195 | prescale = MAX(current_bass, current_treble); | 194 | prescale = MAX(current_bass, current_treble); |
196 | if (prescale < 0) | 195 | if (prescale < 0) |
@@ -297,7 +296,7 @@ void sound_set_bass(int value) | |||
297 | 296 | ||
298 | #if !defined(AUDIOHW_HAVE_CLIPPING) | 297 | #if !defined(AUDIOHW_HAVE_CLIPPING) |
299 | #if defined(HAVE_WM8750) || defined(HAVE_WM8751) | 298 | #if defined(HAVE_WM8750) || defined(HAVE_WM8751) |
300 | current_bass = value; | 299 | current_bass = value / 15; |
301 | #else | 300 | #else |
302 | current_bass = value * 10; | 301 | current_bass = value * 10; |
303 | #endif | 302 | #endif |
@@ -321,7 +320,7 @@ void sound_set_treble(int value) | |||
321 | 320 | ||
322 | #if !defined(AUDIOHW_HAVE_CLIPPING) | 321 | #if !defined(AUDIOHW_HAVE_CLIPPING) |
323 | #if defined(HAVE_WM8750) || defined(HAVE_WM8751) | 322 | #if defined(HAVE_WM8750) || defined(HAVE_WM8751) |
324 | current_treble = value; | 323 | current_treble = value / 15; |
325 | #else | 324 | #else |
326 | current_treble = value * 10; | 325 | current_treble = value * 10; |
327 | #endif | 326 | #endif |