diff options
| author | Dan Everton <dan@iocaine.org> | 2007-11-24 07:51:00 +0000 |
|---|---|---|
| committer | Dan Everton <dan@iocaine.org> | 2007-11-24 07:51:00 +0000 |
| commit | d7e1f7714699fa201bda4f14ed38bfce10949d94 (patch) | |
| tree | 594b7a18c82f9fcedc8cd8681bb5e8aa196e1bfd /firmware | |
| parent | a334bd2891d50fca3b073e2262d6b37ae624f1a0 (diff) | |
| download | rockbox-d7e1f7714699fa201bda4f14ed38bfce10949d94.zip rockbox-d7e1f7714699fa201bda4f14ed38bfce10949d94.tar.gz rockbox-d7e1f7714699fa201bda4f14ed38bfce10949d94.tar.bz2 rockbox-d7e1f7714699fa201bda4f14ed38bfce10949d94.tar.xz | |
Commit FS#7440. The iPod Video doesn't actually have a hardware equalizer. It does have hardware bass/treble settings with configurable cutoff. So make the bass/treble settings use the hardware and remove the hardware equalizer configuration.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15782 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
| -rw-r--r-- | firmware/drivers/audio/wm8758.c | 53 | ||||
| -rw-r--r-- | firmware/export/audiohw.h | 4 | ||||
| -rw-r--r-- | firmware/export/sound.h | 4 | ||||
| -rw-r--r-- | firmware/export/wm8758.h | 8 | ||||
| -rw-r--r-- | firmware/sound.c | 50 |
5 files changed, 86 insertions, 33 deletions
diff --git a/firmware/drivers/audio/wm8758.c b/firmware/drivers/audio/wm8758.c index 1cfac7c..a9f10fb 100644 --- a/firmware/drivers/audio/wm8758.c +++ b/firmware/drivers/audio/wm8758.c @@ -33,16 +33,22 @@ const struct sound_settings_info audiohw_settings[] = { [SOUND_VOLUME] = {"dB", 0, 1, -58, 6, -25}, - [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0}, - [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0}, + [SOUND_BASS] = {"dB", 0, 1, -12, 12, 0}, + [SOUND_TREBLE] = {"dB", 0, 1, -12, 12, 0}, [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100}, [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0}, [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0}, [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16}, + [SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 1}, + [SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1}, }; +/* shadow registers */ +unsigned int eq1_reg; +unsigned int eq5_reg; + /* convert tenth of dB volume (-57..6) to master volume register value */ int tenthdb2master(int db) { @@ -138,15 +144,28 @@ int audiohw_set_mixer_vol(int channel1, int channel2) return 0; } -/* We are using Linear bass control */ void audiohw_set_bass(int value) { - (void)value; + eq1_reg = (eq1_reg & ~EQ_GAIN_MASK) | EQ_GAIN_VALUE(value); + wmcodec_write(EQ1, 0x100 | eq1_reg); +} + +void audiohw_set_bass_cutoff(int value) +{ + eq1_reg = (eq1_reg & ~EQ_CUTOFF_MASK) | EQ_CUTOFF_VALUE(value); + wmcodec_write(EQ1, 0x100 | eq1_reg); } void audiohw_set_treble(int value) { - (void)value; + eq5_reg = (eq5_reg & ~EQ_GAIN_MASK) | EQ_GAIN_VALUE(value); + wmcodec_write(EQ5, eq5_reg); +} + +void audiohw_set_treble_cutoff(int value) +{ + eq5_reg = (eq5_reg & ~EQ_CUTOFF_MASK) | EQ_CUTOFF_VALUE(value); + wmcodec_write(EQ5, eq5_reg); } void audiohw_mute(bool mute) @@ -271,27 +290,3 @@ void audiohw_set_monitor(bool enable) { (void)enable; } -void audiohw_set_equalizer_band(int band, int freq, int bw, int gain) -{ - unsigned int eq = 0; - - /* Band 1..3 are peak filters */ - if (band >= 1 && band <= 3) { - eq |= (bw << 8); - } - - eq |= (freq << 5); - eq |= 12 - gain; - - if (band == 0) { - wmcodec_write(EQ1, eq | 0x100); /* Always apply EQ to the DAC path */ - } else if (band == 1) { - wmcodec_write(EQ2, eq); - } else if (band == 2) { - wmcodec_write(EQ3, eq); - } else if (band == 3) { - wmcodec_write(EQ4, eq); - } else if (band == 4) { - wmcodec_write(EQ5, eq); - } -} diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h index c5093a1..5dc7550 100644 --- a/firmware/export/audiohw.h +++ b/firmware/export/audiohw.h @@ -67,6 +67,10 @@ enum { SOUND_RIGHT_GAIN, SOUND_MIC_GAIN, #endif +#ifdef HAVE_WM8758 + SOUND_BASS_CUTOFF, + SOUND_TREBLE_CUTOFF, +#endif }; enum Channel { diff --git a/firmware/export/sound.h b/firmware/export/sound.h index 929b83b..5933f4c 100644 --- a/firmware/export/sound.h +++ b/firmware/export/sound.h @@ -41,6 +41,10 @@ void sound_set_bass(int value); void sound_set_treble(int value); void sound_set_channels(int value); void sound_set_stereo_width(int value); +#ifdef HAVE_WM8758 +void sound_set_bass_cutoff(int value); +void sound_set_treble_cutoff(int value); +#endif #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) void sound_set_loudness(int value); void sound_set_avc(int value); diff --git a/firmware/export/wm8758.h b/firmware/export/wm8758.h index 6d3220a..df60851 100644 --- a/firmware/export/wm8758.h +++ b/firmware/export/wm8758.h @@ -32,12 +32,12 @@ extern int audiohw_set_master_vol(int vol_l, int vol_r); extern int audiohw_set_lineout_vol(int vol_l, int vol_r); extern int audiohw_set_mixer_vol(int channel1, int channel2); extern void audiohw_set_bass(int value); +extern void audiohw_set_bass_cutoff(int value); extern void audiohw_set_treble(int value); +extern void audiohw_set_treble_cutoff(int value); extern void audiohw_set_nsorder(int order); extern void audiohw_set_sample_rate(int sampling_control); -extern void audiohw_set_equalizer_band(int band, int freq, int bw, int gain); - #define RESET 0x00 #define PWRMGMT1 0x01 #define PWRMGMT2 0x02 @@ -70,6 +70,10 @@ extern void audiohw_set_equalizer_band(int band, int freq, int bw, int gain); #define EQ3 0x14 #define EQ4 0x15 #define EQ5 0x16 +#define EQ_GAIN_MASK 0x001f +#define EQ_CUTOFF_MASK 0x0060 +#define EQ_GAIN_VALUE(x) (((-x) + 12) & 0x1f) +#define EQ_CUTOFF_VALUE(x) ((((x) - 1) & 0x03) << 5) /* Register settings for the supported samplerates: */ #define WM8758_8000HZ 0x4d diff --git a/firmware/sound.c b/firmware/sound.c index 9cb4c28..0e1e7c5 100644 --- a/firmware/sound.c +++ b/firmware/sound.c @@ -70,6 +70,10 @@ const struct sound_settings_info audiohw_settings[] = { [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0}, [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16}, #endif +#if defined(HAVE_WM8758) + [SOUND_BASS_CUTOFF] = {"", 0, 1, 1, 4, 1}, + [SOUND_TREBLE_CUTOFF] = {"", 0, 1, 1, 4, 1}, +#endif }; #endif @@ -132,6 +136,16 @@ sound_set_type* sound_get_fn(int setting) result = sound_set_stereo_width; break; +#ifdef HAVE_WM8758 + case SOUND_BASS_CUTOFF: + result = sound_set_bass_cutoff; + break; + + case SOUND_TREBLE_CUTOFF: + result = sound_set_treble_cutoff; + break; +#endif + #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) case SOUND_LOUDNESS: result = sound_set_loudness; @@ -219,7 +233,8 @@ static void set_prescaled_volume(void) /* The WM codecs listed don't have suitable prescaler functionality, so we let * the prescaler stay at 0 for these unless SW tone controls are in use */ #if defined(HAVE_SW_TONE_CONTROLS) || !(defined(HAVE_WM8975) \ - || defined(HAVE_WM8731) || defined(HAVE_WM8721) || defined(HAVE_WM8751)) + || defined(HAVE_WM8731) || defined(HAVE_WM8721) || defined(HAVE_WM8751) \ + || defined(HAVE_WM8758)) prescale = MAX(current_bass, current_treble); if (prescale < 0) @@ -237,7 +252,7 @@ static void set_prescaled_volume(void) dsp_callback(DSP_CALLBACK_SET_PRESCALE, prescale); #elif CONFIG_CODEC == MAS3507D mas_writereg(MAS_REG_KPRESCALE, prescale_table[prescale/10]); -#elif defined(HAVE_UDA1380) || defined(HAVE_WM8758) +#elif defined(HAVE_UDA1380) audiohw_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale)); #endif @@ -492,6 +507,24 @@ void sound_set_stereo_width(int value) #endif } +#ifdef HAVE_WM8758 +void sound_set_bass_cutoff(int value) +{ + if(!audio_is_initialized) + return; + + audiohw_set_bass_cutoff(value); +} + +void sound_set_treble_cutoff(int value) +{ + if(!audio_is_initialized) + return; + + audiohw_set_treble_cutoff(value); +} +#endif + #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) void sound_set_loudness(int value) { @@ -652,6 +685,19 @@ void sound_set_superbass(int value) (void)value; } #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */ + +#ifdef HAVE_WM8758 +void sound_set_bass_cutoff(int value) +{ + (void) value; +} + +void sound_set_treble_cutoff(int value) +{ + (void) value; +} +#endif /* HAVE_WM8758 */ + #endif /* SIMULATOR */ void sound_set(int setting, int value) |