diff options
| author | Dave Chapman <dave@dchapman.com> | 2006-02-26 15:59:46 +0000 |
|---|---|---|
| committer | Dave Chapman <dave@dchapman.com> | 2006-02-26 15:59:46 +0000 |
| commit | 2f76763d73c7be641cd55c30ff15f6ff9dda5fe0 (patch) | |
| tree | 29179e6843bf4de0bdedf9ed40e07cfb520bdad8 /firmware/sound.c | |
| parent | 4b9fbd168713e572f9a73a7bacaa850e8c961994 (diff) | |
| download | rockbox-2f76763d73c7be641cd55c30ff15f6ff9dda5fe0.zip rockbox-2f76763d73c7be641cd55c30ff15f6ff9dda5fe0.tar.gz rockbox-2f76763d73c7be641cd55c30ff15f6ff9dda5fe0.tar.bz2 rockbox-2f76763d73c7be641cd55c30ff15f6ff9dda5fe0.tar.xz | |
iPod 3G - initial (completely untested) attempt at audio support
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8847 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/sound.c')
| -rw-r--r-- | firmware/sound.c | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/firmware/sound.c b/firmware/sound.c index a039cca..f1c9ff7 100644 --- a/firmware/sound.c +++ b/firmware/sound.c @@ -30,6 +30,8 @@ #include "wm8975.h" #elif defined(HAVE_WM8758) #include "wm8758.h" +#elif defined(HAVE_WM8731) +#include "wm8731l.h" #elif defined(HAVE_TLV320) #include "tlv320.h" #endif @@ -77,6 +79,10 @@ static const struct sound_settings_info sound_settings_table[] = { [SOUND_VOLUME] = {"dB", 0, 1, -57, 6, -25, sound_set_volume}, [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass}, [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble}, +#elif defined(HAVE_WM8731) + [SOUND_VOLUME] = {"dB", 0, 1, -73, 6, -25, sound_set_volume}, + [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass}, + [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble}, #else /* MAS3507D */ [SOUND_VOLUME] = {"dB", 0, 1, -78, 18, -18, sound_set_volume}, [SOUND_BASS] = {"dB", 0, 1, -15, 15, 7, sound_set_bass}, @@ -350,10 +356,44 @@ static int tenthdb2mixer(int db) return -db * 2 / 5; } +#elif defined(HAVE_WM8731) +/* volume/balance/treble/bass interdependency */ +#define VOLUME_MIN -730 +#define VOLUME_MAX 60 + +/* convert tenth of dB volume (-730..60) to master volume register value */ +static int tenthdb2master(int db) +{ + /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ + /* 1111111 == +6dB (0x7f) */ + /* 1111001 == 0dB (0x79) */ + /* 0110000 == -73dB (0x30 */ + /* 0101111 == mute (0x2f) */ + + if (db <= -570) { + return 0x0; + } else { + return((db/10)+57); + } +} + +/* convert tenth of dB volume (-780..0) to mixer volume register value */ +static int tenthdb2mixer(int db) +{ + if (db < -660) /* 1.5 dB steps */ + return (2640 - db) / 15; + else if (db < -600) /* 0.75 dB steps */ + return (990 - db) * 2 / 15; + else if (db < -460) /* 0.5 dB steps */ + return (460 - db) / 5; + else /* 0.25 dB steps */ + return -db * 2 / 5; +} + #endif #if (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 || \ - defined HAVE_WM8975 || defined HAVE_WM8758 + defined HAVE_WM8975 || defined HAVE_WM8758 || defined(HAVE_WM8731) /* volume/balance/treble/bass interdependency main part */ #define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN) @@ -383,7 +423,7 @@ static void set_prescaled_volume(void) mas_writereg(MAS_REG_KPRESCALE, prescale_table[prescale/10]); #elif defined(HAVE_UDA1380) uda1380_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale)); -#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) +#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) wmcodec_set_mixer_vol(tenthdb2mixer(-prescale), tenthdb2mixer(-prescale)); #endif @@ -409,7 +449,7 @@ static void set_prescaled_volume(void) dac_volume(tenthdb2reg(l), tenthdb2reg(r), false); #elif defined(HAVE_UDA1380) uda1380_set_master_vol(tenthdb2master(l), tenthdb2master(r)); -#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) +#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) wmcodec_set_master_vol(tenthdb2master(l), tenthdb2master(r)); #endif } @@ -511,7 +551,7 @@ void sound_set_volume(int value) unsigned tmp = ((unsigned)(value + 115) & 0xff) << 8; mas_codec_writereg(0x10, tmp); #elif (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 || \ - defined HAVE_WM8975 || defined HAVE_WM8758 + defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 current_volume = value * 10; /* tenth of dB */ set_prescaled_volume(); #elif CONFIG_CPU == PNX0101 @@ -528,7 +568,7 @@ void sound_set_balance(int value) unsigned tmp = ((unsigned)(value * 127 / 100) & 0xff) << 8; mas_codec_writereg(0x11, tmp); #elif CONFIG_CODEC == MAS3507D || defined HAVE_UDA1380 || \ - defined HAVE_WM8975 || defined HAVE_WM8758 + defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */ set_prescaled_volume(); #elif CONFIG_CPU == PNX0101 @@ -552,7 +592,7 @@ void sound_set_bass(int value) uda1380_set_bass(value >> 1); current_bass = value * 10; set_prescaled_volume(); -#elif defined HAVE_WM8975 || defined HAVE_WM8758 +#elif defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 current_bass = value * 10; wmcodec_set_bass(value); set_prescaled_volume(); @@ -577,7 +617,7 @@ void sound_set_treble(int value) uda1380_set_treble(value >> 1); current_treble = value * 10; set_prescaled_volume(); -#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) +#elif defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) wmcodec_set_treble(value); current_treble = value * 10; set_prescaled_volume(); |