diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2007-05-22 15:56:05 +0000 |
---|---|---|
committer | Christian Gmeiner <christian.gmeiner@gmail.com> | 2007-05-22 15:56:05 +0000 |
commit | cdbf33adf719a54221f4f5aac4b15b0dfe54d24d (patch) | |
tree | 9a3a38da744860df4fc2ffd591f848fd02b4094b | |
parent | e7075db2a76425051b2ecfdd14f14b07384c7e08 (diff) |
* move audio settings into audio codec drivers
* add mas35xx driver for all mas35xx targets. Later
mas35xx code from sound.c will move to this new driver
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13464 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/SOURCES | 2 | ||||
-rw-r--r-- | firmware/drivers/audio/as3514.c | 10 | ||||
-rw-r--r-- | firmware/drivers/audio/mas35xx.c | 54 | ||||
-rw-r--r-- | firmware/drivers/audio/tlv320.c | 13 | ||||
-rw-r--r-- | firmware/drivers/audio/uda1380.c | 12 | ||||
-rw-r--r-- | firmware/drivers/audio/wm8731l.c | 13 | ||||
-rw-r--r-- | firmware/drivers/audio/wm8751.c | 9 | ||||
-rw-r--r-- | firmware/drivers/audio/wm8758.c | 12 | ||||
-rw-r--r-- | firmware/drivers/audio/wm8975.c | 12 | ||||
-rw-r--r-- | firmware/export/as3514.h | 1 | ||||
-rw-r--r-- | firmware/export/audiohw.h | 73 | ||||
-rw-r--r-- | firmware/export/config.h | 5 | ||||
-rw-r--r-- | firmware/export/mas35xx.h | 27 | ||||
-rw-r--r-- | firmware/export/sound.h | 37 | ||||
-rw-r--r-- | firmware/export/tlv320.h | 2 | ||||
-rw-r--r-- | firmware/export/uda1380.h | 2 | ||||
-rw-r--r-- | firmware/export/wm8731l.h | 2 | ||||
-rw-r--r-- | firmware/export/wm8751.h | 2 | ||||
-rw-r--r-- | firmware/export/wm8758.h | 2 | ||||
-rw-r--r-- | firmware/export/wm8975.h | 2 | ||||
-rw-r--r-- | firmware/mp3_playback.c | 1 | ||||
-rw-r--r-- | firmware/sound.c | 176 |
22 files changed, 336 insertions, 133 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index ab9e722b0e..ad802dabcb 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -207,6 +207,8 @@ drivers/audio/wm8731l.c drivers/audio/as3514.c #elif defined(HAVE_TLV320) drivers/audio/tlv320.c +#elif defined(HAVE_MAS35XX) +drivers/audio/mas35xx.c #endif /* defined(HAVE_*) */ #endif /* SIMULATOR */ diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c index d068e08081..98e3e439a0 100644 --- a/firmware/drivers/audio/as3514.c +++ b/firmware/drivers/audio/as3514.c @@ -27,6 +27,16 @@ #include "i2s.h" #include "i2c-pp.h" +const struct sound_settings_info audiohw_settings[] = { + [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, + /* HAVE_SW_TONE_CONTROLS */ + [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0}, + [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0}, + [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, + [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, + [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, +}; + /* Shadow registers */ int as3514_regs[0x1E]; /* last audio register: PLLMODE 0x1d */ diff --git a/firmware/drivers/audio/mas35xx.c b/firmware/drivers/audio/mas35xx.c new file mode 100644 index 0000000000..6a9d290049 --- /dev/null +++ b/firmware/drivers/audio/mas35xx.c @@ -0,0 +1,54 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: wm8975.c 13453 2007-05-20 23:10:15Z christian $ + * + * Driver for MAS35xx audio codec + * + * + * Copyright (c) 2007 by Christian Gmeiner + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "mas35xx.h" + +const struct sound_settings_info audiohw_settings[] = { +#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) + [SOUND_VOLUME] = {"dB", 0, 1,-100, 12, -25}, + [SOUND_BASS] = {"dB", 0, 1, -12, 12, 6}, + [SOUND_TREBLE] = {"dB", 0, 1, -12, 12, 6}, +#else /* MAS3507D */ + [SOUND_VOLUME] = {"dB", 0, 1, -78, 18, -18}, + [SOUND_BASS] = {"dB", 0, 1, -15, 15, 7}, + [SOUND_TREBLE] = {"dB", 0, 1, -15, 15, 7}, +#endif + [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, + [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, + [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, +#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) + [SOUND_LOUDNESS] = {"dB", 0, 1, 0, 17, 0}, + [SOUND_AVC] = {"", 0, 1, -1, 4, 0}, + [SOUND_MDB_STRENGTH] = {"dB", 0, 1, 0, 127, 48}, + [SOUND_MDB_HARMONICS] = {"%", 0, 1, 0, 100, 50}, + [SOUND_MDB_CENTER] = {"Hz", 0, 10, 20, 300, 60}, + [SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90}, + [SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0}, + [SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0}, +#endif +#if CONFIG_CODEC == MAS3587F + [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 15, 8}, + [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 15, 8}, + [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2}, +#endif +}; diff --git a/firmware/drivers/audio/tlv320.c b/firmware/drivers/audio/tlv320.c index 90587fc23a..95945883bf 100644 --- a/firmware/drivers/audio/tlv320.c +++ b/firmware/drivers/audio/tlv320.c @@ -24,6 +24,19 @@ #include "i2c-coldfire.h" #include "tlv320.h" +const struct sound_settings_info audiohw_settings[] = { + [SOUND_VOLUME] = {"dB", 0, 1, -73, 6, -20}, + /* HAVE_SW_TONE_CONTROLS */ + [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0}, + [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0}, + [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, + [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, + [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, + [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 31, 23}, + [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 31, 23}, + [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 1, 1}, +}; + /* convert tenth of dB volume (-840..0) to master volume register value */ int tenthdb2master(int db) { diff --git a/firmware/drivers/audio/uda1380.c b/firmware/drivers/audio/uda1380.c index ae0d1e841d..6ee35fab4d 100644 --- a/firmware/drivers/audio/uda1380.c +++ b/firmware/drivers/audio/uda1380.c @@ -26,6 +26,18 @@ #include "uda1380.h" #include "pcf50606.h" +const struct sound_settings_info audiohw_settings[] = { + [SOUND_VOLUME] = {"dB", 0, 1, -84, 0, -25}, + [SOUND_BASS] = {"dB", 0, 2, 0, 24, 0}, + [SOUND_TREBLE] = {"dB", 0, 2, 0, 6, 0}, + [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, + [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, + [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 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}, +}; + /* convert tenth of dB volume (-840..0) to master volume register value */ int tenthdb2master(int db) { diff --git a/firmware/drivers/audio/wm8731l.c b/firmware/drivers/audio/wm8731l.c index ffed5c9347..dcf7c4eca0 100644 --- a/firmware/drivers/audio/wm8731l.c +++ b/firmware/drivers/audio/wm8731l.c @@ -37,6 +37,19 @@ /* use zero crossing to reduce clicks during volume changes */ #define VOLUME_ZC_WAIT (1<<7) +const struct sound_settings_info audiohw_settings[] = { + [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, + /* HAVE_SW_TONE_CONTROLS */ + [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0}, + [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0}, + [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, + [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, + [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 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}, +}; + /* convert tenth of dB volume (-730..60) to master volume register value */ int tenthdb2master(int db) { diff --git a/firmware/drivers/audio/wm8751.c b/firmware/drivers/audio/wm8751.c index 2f79f27c7c..bb2b40bbbd 100644 --- a/firmware/drivers/audio/wm8751.c +++ b/firmware/drivers/audio/wm8751.c @@ -29,6 +29,15 @@ #include "audio.h" #include "sound.h" +const struct sound_settings_info audiohw_settings[] = { + [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, + [SOUND_BASS] = {"dB", 1, 15, -60, 90, 0}, + [SOUND_TREBLE] = {"dB", 1, 15, -60, 90, 0}, + [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, + [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, + [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, +}; + /* Flags used in combination with settings */ /* use zero crossing to reduce clicks during volume changes */ diff --git a/firmware/drivers/audio/wm8758.c b/firmware/drivers/audio/wm8758.c index b8e220753c..34f95a989d 100644 --- a/firmware/drivers/audio/wm8758.c +++ b/firmware/drivers/audio/wm8758.c @@ -31,6 +31,18 @@ #include "wm8758.h" #include "i2s.h" +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_BALANCE] = {"%", 0, 1,-100, 100, 0}, + [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, + [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 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}, +}; + /* convert tenth of dB volume (-57..6) to master volume register value */ int tenthdb2master(int db) { diff --git a/firmware/drivers/audio/wm8975.c b/firmware/drivers/audio/wm8975.c index 3d870a8f90..4b018b985b 100644 --- a/firmware/drivers/audio/wm8975.c +++ b/firmware/drivers/audio/wm8975.c @@ -35,7 +35,17 @@ /* use zero crossing to reduce clicks during volume changes */ #define VOLUME_ZC_WAIT (1<<7) - +const struct sound_settings_info audiohw_settings[] = { + [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, + [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0}, + [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0}, + [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, + [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, + [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 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}, +}; /* convert tenth of dB volume (-730..60) to master volume register value */ int tenthdb2master(int db) diff --git a/firmware/export/as3514.h b/firmware/export/as3514.h index 5f37fd7fcf..406857f491 100644 --- a/firmware/export/as3514.h +++ b/firmware/export/as3514.h @@ -21,6 +21,7 @@ #define _AS3514_H #include <stdbool.h> +#include "audiohw.h" extern int tenthdb2master(int db); diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h new file mode 100644 index 0000000000..38e68138c9 --- /dev/null +++ b/firmware/export/audiohw.h @@ -0,0 +1,73 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 by Christian Gmeiner + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _AUDIOHW_H_ +#define _AUDIOHW_H_ + +#include "config.h" + +enum { + SOUND_VOLUME = 0, + SOUND_BASS, + SOUND_TREBLE, + SOUND_BALANCE, + SOUND_CHANNELS, + SOUND_STEREO_WIDTH, +#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) + SOUND_LOUDNESS, + SOUND_AVC, + SOUND_MDB_STRENGTH, + SOUND_MDB_HARMONICS, + SOUND_MDB_CENTER, + SOUND_MDB_SHAPE, + SOUND_MDB_ENABLE, + SOUND_SUPERBASS, +#endif +#if CONFIG_CODEC == MAS3587F || defined(HAVE_UDA1380) || defined(HAVE_TLV320)\ + || defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) + SOUND_LEFT_GAIN, + SOUND_RIGHT_GAIN, + SOUND_MIC_GAIN, +#endif +}; + +enum Channel { + SOUND_CHAN_STEREO, + SOUND_CHAN_MONO, + SOUND_CHAN_CUSTOM, + SOUND_CHAN_MONO_LEFT, + SOUND_CHAN_MONO_RIGHT, + SOUND_CHAN_KARAOKE, + SOUND_CHAN_NUM_MODES, +}; + +struct sound_settings_info { + const char *unit; + int numdecimals; + int steps; + int minval; + int maxval; + int defaultval; +}; + +/* This struct is used by every driver to export its min/max/default values for + * its audio settings. Keep in mind that the order must be correct! */ +extern const struct sound_settings_info audiohw_settings[]; + +#endif /* _AUDIOHW_H_ */ diff --git a/firmware/export/config.h b/firmware/export/config.h index 0ad4fabbe1..dd4eaf4488 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -253,6 +253,11 @@ #endif #endif +/* Add one HAVE_ define for all mas35xx targets */ +#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3507D) || (CONFIG_CODEC == MAS3539F) +#define HAVE_MAS35XX +#endif + #if CONFIG_CODEC == SWCODEC && !defined(BOOTLOADER) #define HAVE_EXTENDED_MESSAGING_AND_NAME #endif diff --git a/firmware/export/mas35xx.h b/firmware/export/mas35xx.h new file mode 100644 index 0000000000..1239454a3f --- /dev/null +++ b/firmware/export/mas35xx.h @@ -0,0 +1,27 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Implementation of MAS35xx audiohw api driver. + * + * Copyright (C) 2007 by Christian Gmeiner + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _MAS35XX_H +#define _MAS35XX_H + +#include "audiohw.h" + +#endif /* _MAS35XX_H */ diff --git a/firmware/export/sound.h b/firmware/export/sound.h index b060b97312..d405e99fbf 100644 --- a/firmware/export/sound.h +++ b/firmware/export/sound.h @@ -34,45 +34,12 @@ #include "tlv320.h" #elif defined(HAVE_AS3514) #include "as3514.h" +#elif defined(HAVE_MAS35XX) +#include "mas35xx.h" #endif extern void audiohw_postinit(void); -enum { - SOUND_VOLUME = 0, - SOUND_BASS, - SOUND_TREBLE, - SOUND_BALANCE, - SOUND_CHANNELS, - SOUND_STEREO_WIDTH, -#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) - SOUND_LOUDNESS, - SOUND_AVC, - SOUND_MDB_STRENGTH, - SOUND_MDB_HARMONICS, - SOUND_MDB_CENTER, - SOUND_MDB_SHAPE, - SOUND_MDB_ENABLE, - SOUND_SUPERBASS, -#endif -#if CONFIG_CODEC == MAS3587F || defined(HAVE_UDA1380) || defined(HAVE_TLV320)\ - || defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) - SOUND_LEFT_GAIN, - SOUND_RIGHT_GAIN, - SOUND_MIC_GAIN, -#endif -}; - -enum { - SOUND_CHAN_STEREO = 0, - SOUND_CHAN_MONO, - SOUND_CHAN_CUSTOM, - SOUND_CHAN_MONO_LEFT, - SOUND_CHAN_MONO_RIGHT, - SOUND_CHAN_KARAOKE, - SOUND_CHAN_NUM_MODES -}; - typedef void sound_set_type(int value); const char *sound_unit(int setting); diff --git a/firmware/export/tlv320.h b/firmware/export/tlv320.h index ebb126ddf5..73cf297a3e 100644 --- a/firmware/export/tlv320.h +++ b/firmware/export/tlv320.h @@ -23,6 +23,8 @@ #define VOLUME_MIN -730 #define VOLUME_MAX 60 +#include "audiohw.h" + extern int tenthdb2master(int db); /*** definitions ***/ diff --git a/firmware/export/uda1380.h b/firmware/export/uda1380.h index c1fb6421ff..a92e2a3212 100644 --- a/firmware/export/uda1380.h +++ b/firmware/export/uda1380.h @@ -20,6 +20,8 @@ #ifndef _UDA1380_H #define _UDA1380_H +#include "audiohw.h" + /* volume/balance/treble/bass interdependency */ #define VOLUME_MIN -840 #define VOLUME_MAX 0 diff --git a/firmware/export/wm8731l.h b/firmware/export/wm8731l.h index 5ef6d694e5..76b2a9c960 100644 --- a/firmware/export/wm8731l.h +++ b/firmware/export/wm8731l.h @@ -24,6 +24,8 @@ #define VOLUME_MIN -730 #define VOLUME_MAX 60 +#include "audiohw.h" + extern int tenthdb2master(int db); extern int tenthdb2mixer(int db); diff --git a/firmware/export/wm8751.h b/firmware/export/wm8751.h index efeaa3609d..85d206cae4 100644 --- a/firmware/export/wm8751.h +++ b/firmware/export/wm8751.h @@ -23,6 +23,8 @@ #define VOLUME_MIN -730 #define VOLUME_MAX 60 +#include "audiohw.h" + extern int tenthdb2master(int db); extern int tenthdb2mixer(int db); diff --git a/firmware/export/wm8758.h b/firmware/export/wm8758.h index 5715f100da..7fa2181679 100644 --- a/firmware/export/wm8758.h +++ b/firmware/export/wm8758.h @@ -24,6 +24,8 @@ #define VOLUME_MIN -570 #define VOLUME_MAX 60 +#include "audiohw.h" + extern int tenthdb2master(int db); extern int tenthdb2mixer(int db); diff --git a/firmware/export/wm8975.h b/firmware/export/wm8975.h index c00303a6a8..bbaa8d3554 100644 --- a/firmware/export/wm8975.h +++ b/firmware/export/wm8975.h @@ -24,6 +24,8 @@ #define VOLUME_MIN -730 #define VOLUME_MAX 60 +#include "audiohw.h" + extern int tenthdb2master(int db); extern int tenthdb2mixer(int db); diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c index b692a01746..68fa96d619 100644 --- a/firmware/mp3_playback.c +++ b/firmware/mp3_playback.c @@ -33,6 +33,7 @@ #include "dac.h" #include "system.h" #endif +#include "audiohw.h" /* hacking into mpeg.c, recording is still there */ #if CONFIG_CODEC == MAS3587F diff --git a/firmware/sound.c b/firmware/sound.c index 9c2a8ffb35..fcb95ead7c 100644 --- a/firmware/sound.c +++ b/firmware/sound.c @@ -8,6 +8,7 @@ * $Id$ * * Copyright (C) 2005 by Linus Nielsen Feltzing + * Copyright (C) 2007 by Christian Gmeiner * * All files in this archive are subject to the GNU General Public License. * See the file COPYING in the source tree root for full license agreement. @@ -43,132 +44,113 @@ extern unsigned shadow_codec_reg0; #endif #endif /* SIMULATOR */ -struct sound_settings_info { - const char *unit; - int numdecimals; - int steps; - int minval; - int maxval; - int defaultval; - sound_set_type *setfn; +#ifdef SIMULATOR +/* dummy for sim */ +const struct sound_settings_info audiohw_settings[] = { + [SOUND_VOLUME] = {"dB", 0, 1, -40, 6, -25}, + [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0}, + [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0}, + [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, + [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, + [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, }; - -static const struct sound_settings_info sound_settings_table[] = { -#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) - [SOUND_VOLUME] = {"dB", 0, 1,-100, 12, -25, sound_set_volume}, - [SOUND_BASS] = {"dB", 0, 1, -12, 12, 6, sound_set_bass}, - [SOUND_TREBLE] = {"dB", 0, 1, -12, 12, 6, sound_set_treble}, -#elif defined(HAVE_UDA1380) - [SOUND_VOLUME] = {"dB", 0, 1, -84, 0, -25, sound_set_volume}, - [SOUND_BASS] = {"dB", 0, 2, 0, 24, 0, sound_set_bass}, - [SOUND_TREBLE] = {"dB", 0, 2, 0, 6, 0, sound_set_treble}, -#elif defined(HAVE_TLV320) - [SOUND_VOLUME] = {"dB", 0, 1, -73, 6, -20, sound_set_volume}, -#elif defined(HAVE_WM8751) - [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25, sound_set_volume}, - [SOUND_BASS] = {"dB", 1, 15, -60, 90, 0, sound_set_bass}, - [SOUND_TREBLE] = {"dB", 1, 15, -60, 90, 0, sound_set_treble}, -#elif defined(HAVE_WM8975) - [SOUND_VOLUME] = {"dB", 0, 1, -74, 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_WM8758) - [SOUND_VOLUME] = {"dB", 0, 1, -58, 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) || defined(HAVE_WM8721) - [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25, sound_set_volume}, -#elif (CONFIG_CPU == PNX0101) - [SOUND_VOLUME] = {"dB", 0, 1, -48, 15, 0, sound_set_volume}, -#elif defined(HAVE_AS3514) - [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25, sound_set_volume}, -#else /* MAS3507D */ - [SOUND_VOLUME] = {"dB", 0, 1, -78, 18, -18, sound_set_volume}, - [SOUND_BASS] = {"dB", 0, 1, -15, 15, 7, sound_set_bass}, - [SOUND_TREBLE] = {"dB", 0, 1, -15, 15, 7, sound_set_treble}, -#endif -/* Override any other potentially existing treble/bass controllers if wanted */ -#ifdef HAVE_SW_TONE_CONTROLS - [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0, sound_set_bass}, - [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0, sound_set_treble}, -#endif - [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0, sound_set_balance}, - [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0, sound_set_channels}, - [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100, sound_set_stereo_width}, -#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) - [SOUND_LOUDNESS] = {"dB", 0, 1, 0, 17, 0, sound_set_loudness}, - [SOUND_AVC] = {"", 0, 1, -1, 4, 0, sound_set_avc}, - [SOUND_MDB_STRENGTH] = {"dB", 0, 1, 0, 127, 48, sound_set_mdb_strength}, - [SOUND_MDB_HARMONICS] = {"%", 0, 1, 0, 100, 50, sound_set_mdb_harmonics}, - [SOUND_MDB_CENTER] = {"Hz", 0, 10, 20, 300, 60, sound_set_mdb_center}, - [SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90, sound_set_mdb_shape}, - [SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0, sound_set_mdb_enable}, - [SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0, sound_set_superbass}, -#endif -#if CONFIG_CODEC == MAS3587F - [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 15, 8, NULL}, - [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 15, 8, NULL}, - [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2, NULL}, -#elif defined(HAVE_UDA1380) - [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, - [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, - [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16, NULL}, -#elif defined(HAVE_TLV320) - [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 31, 23, NULL}, - [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 31, 23, NULL}, - [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 1, 1, NULL}, -#elif defined(HAVE_WM8975) - [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, - [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, - [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16, NULL}, -#elif defined(HAVE_WM8758) - [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, - [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, - [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16, NULL}, -#elif defined(HAVE_WM8731) - [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, - [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, - [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16, NULL}, #endif -}; const char *sound_unit(int setting) { - return sound_settings_table[setting].unit; + return audiohw_settings[setting].unit; } int sound_numdecimals(int setting) { - return sound_settings_table[setting].numdecimals; + return audiohw_settings[setting].numdecimals; } int sound_steps(int setting) { - return sound_settings_table[setting].steps; + return audiohw_settings[setting].steps; } int sound_min(int setting) { - return sound_settings_table[setting].minval; + return audiohw_settings[setting].minval; } int sound_max(int setting) { - return sound_settings_table[setting].maxval; + return audiohw_settings[setting].maxval; } int sound_default(int setting) { - return sound_settings_table[setting].defaultval; + return audiohw_settings[setting].defaultval; } sound_set_type* sound_get_fn(int setting) { - if ((unsigned)setting < (sizeof(sound_settings_table) - / sizeof(struct sound_settings_info))) - return sound_settings_table[setting].setfn; - else - return NULL; + sound_set_type* result = NULL; + + switch (setting) { + case SOUND_VOLUME: + result = sound_set_volume; + break; + + case SOUND_BASS: + result = sound_set_bass; + break; + + case SOUND_TREBLE: + result = sound_set_treble; + break; + + case SOUND_BALANCE: + result = sound_set_balance; + break; + + case SOUND_CHANNELS: + result = sound_set_channels; + break; + + case SOUND_STEREO_WIDTH: + result = sound_set_stereo_width; + break; + +#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) + case SOUND_LOUDNESS: + result = sound_set_loudness; + break; + + case SOUND_AVC: + result = sound_set_avc; + break; + + case SOUND_MDB_STRENGTH: + result = sound_set_mdb_strength; + break; + + case SOUND_MDB_HARMONICS: + result = sound_set_mdb_harmonics; + break; + + case SOUND_MDB_CENTER: + result = sound_set_mdb_center; + break; + + case SOUND_MDB_SHAPE: + result = sound_set_mdb_shape; + break; + + case SOUND_MDB_ENABLE: + result = sound_set_mdb_enable; + break; + + case SOUND_SUPERBASS: + result = sound_set_superbass; + break; +#endif + } + + return result; } #if CONFIG_CODEC == SWCODEC |