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) | |
download | rockbox-cdbf33adf719a54221f4f5aac4b15b0dfe54d24d.tar.gz rockbox-cdbf33adf719a54221f4f5aac4b15b0dfe54d24d.zip |
* 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 | |||
207 | drivers/audio/as3514.c | 207 | drivers/audio/as3514.c |
208 | #elif defined(HAVE_TLV320) | 208 | #elif defined(HAVE_TLV320) |
209 | drivers/audio/tlv320.c | 209 | drivers/audio/tlv320.c |
210 | #elif defined(HAVE_MAS35XX) | ||
211 | drivers/audio/mas35xx.c | ||
210 | #endif /* defined(HAVE_*) */ | 212 | #endif /* defined(HAVE_*) */ |
211 | #endif /* SIMULATOR */ | 213 | #endif /* SIMULATOR */ |
212 | 214 | ||
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 @@ | |||
27 | #include "i2s.h" | 27 | #include "i2s.h" |
28 | #include "i2c-pp.h" | 28 | #include "i2c-pp.h" |
29 | 29 | ||
30 | const struct sound_settings_info audiohw_settings[] = { | ||
31 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, | ||
32 | /* HAVE_SW_TONE_CONTROLS */ | ||
33 | [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0}, | ||
34 | [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0}, | ||
35 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, | ||
36 | [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, | ||
37 | [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, | ||
38 | }; | ||
39 | |||
30 | /* Shadow registers */ | 40 | /* Shadow registers */ |
31 | int as3514_regs[0x1E]; /* last audio register: PLLMODE 0x1d */ | 41 | int as3514_regs[0x1E]; /* last audio register: PLLMODE 0x1d */ |
32 | 42 | ||
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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: wm8975.c 13453 2007-05-20 23:10:15Z christian $ | ||
9 | * | ||
10 | * Driver for MAS35xx audio codec | ||
11 | * | ||
12 | * | ||
13 | * Copyright (c) 2007 by Christian Gmeiner | ||
14 | * | ||
15 | * All files in this archive are subject to the GNU General Public License. | ||
16 | * See the file COPYING in the source tree root for full license agreement. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | |||
23 | #include "config.h" | ||
24 | #include "mas35xx.h" | ||
25 | |||
26 | const struct sound_settings_info audiohw_settings[] = { | ||
27 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
28 | [SOUND_VOLUME] = {"dB", 0, 1,-100, 12, -25}, | ||
29 | [SOUND_BASS] = {"dB", 0, 1, -12, 12, 6}, | ||
30 | [SOUND_TREBLE] = {"dB", 0, 1, -12, 12, 6}, | ||
31 | #else /* MAS3507D */ | ||
32 | [SOUND_VOLUME] = {"dB", 0, 1, -78, 18, -18}, | ||
33 | [SOUND_BASS] = {"dB", 0, 1, -15, 15, 7}, | ||
34 | [SOUND_TREBLE] = {"dB", 0, 1, -15, 15, 7}, | ||
35 | #endif | ||
36 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, | ||
37 | [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, | ||
38 | [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, | ||
39 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
40 | [SOUND_LOUDNESS] = {"dB", 0, 1, 0, 17, 0}, | ||
41 | [SOUND_AVC] = {"", 0, 1, -1, 4, 0}, | ||
42 | [SOUND_MDB_STRENGTH] = {"dB", 0, 1, 0, 127, 48}, | ||
43 | [SOUND_MDB_HARMONICS] = {"%", 0, 1, 0, 100, 50}, | ||
44 | [SOUND_MDB_CENTER] = {"Hz", 0, 10, 20, 300, 60}, | ||
45 | [SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90}, | ||
46 | [SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0}, | ||
47 | [SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0}, | ||
48 | #endif | ||
49 | #if CONFIG_CODEC == MAS3587F | ||
50 | [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 15, 8}, | ||
51 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 15, 8}, | ||
52 | [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2}, | ||
53 | #endif | ||
54 | }; | ||
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 @@ | |||
24 | #include "i2c-coldfire.h" | 24 | #include "i2c-coldfire.h" |
25 | #include "tlv320.h" | 25 | #include "tlv320.h" |
26 | 26 | ||
27 | const struct sound_settings_info audiohw_settings[] = { | ||
28 | [SOUND_VOLUME] = {"dB", 0, 1, -73, 6, -20}, | ||
29 | /* HAVE_SW_TONE_CONTROLS */ | ||
30 | [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0}, | ||
31 | [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0}, | ||
32 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, | ||
33 | [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, | ||
34 | [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, | ||
35 | [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 31, 23}, | ||
36 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 31, 23}, | ||
37 | [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 1, 1}, | ||
38 | }; | ||
39 | |||
27 | /* convert tenth of dB volume (-840..0) to master volume register value */ | 40 | /* convert tenth of dB volume (-840..0) to master volume register value */ |
28 | int tenthdb2master(int db) | 41 | int tenthdb2master(int db) |
29 | { | 42 | { |
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 @@ | |||
26 | #include "uda1380.h" | 26 | #include "uda1380.h" |
27 | #include "pcf50606.h" | 27 | #include "pcf50606.h" |
28 | 28 | ||
29 | const struct sound_settings_info audiohw_settings[] = { | ||
30 | [SOUND_VOLUME] = {"dB", 0, 1, -84, 0, -25}, | ||
31 | [SOUND_BASS] = {"dB", 0, 2, 0, 24, 0}, | ||
32 | [SOUND_TREBLE] = {"dB", 0, 2, 0, 6, 0}, | ||
33 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, | ||
34 | [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, | ||
35 | [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, | ||
36 | [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0}, | ||
37 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0}, | ||
38 | [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16}, | ||
39 | }; | ||
40 | |||
29 | /* convert tenth of dB volume (-840..0) to master volume register value */ | 41 | /* convert tenth of dB volume (-840..0) to master volume register value */ |
30 | int tenthdb2master(int db) | 42 | int tenthdb2master(int db) |
31 | { | 43 | { |
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 @@ | |||
37 | /* use zero crossing to reduce clicks during volume changes */ | 37 | /* use zero crossing to reduce clicks during volume changes */ |
38 | #define VOLUME_ZC_WAIT (1<<7) | 38 | #define VOLUME_ZC_WAIT (1<<7) |
39 | 39 | ||
40 | const struct sound_settings_info audiohw_settings[] = { | ||
41 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, | ||
42 | /* HAVE_SW_TONE_CONTROLS */ | ||
43 | [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0}, | ||
44 | [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0}, | ||
45 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, | ||
46 | [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, | ||
47 | [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, | ||
48 | [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0}, | ||
49 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0}, | ||
50 | [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16}, | ||
51 | }; | ||
52 | |||
40 | /* convert tenth of dB volume (-730..60) to master volume register value */ | 53 | /* convert tenth of dB volume (-730..60) to master volume register value */ |
41 | int tenthdb2master(int db) | 54 | int tenthdb2master(int db) |
42 | { | 55 | { |
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 @@ | |||
29 | #include "audio.h" | 29 | #include "audio.h" |
30 | #include "sound.h" | 30 | #include "sound.h" |
31 | 31 | ||
32 | const struct sound_settings_info audiohw_settings[] = { | ||
33 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, | ||
34 | [SOUND_BASS] = {"dB", 1, 15, -60, 90, 0}, | ||
35 | [SOUND_TREBLE] = {"dB", 1, 15, -60, 90, 0}, | ||
36 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, | ||
37 | [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, | ||
38 | [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, | ||
39 | }; | ||
40 | |||
32 | /* Flags used in combination with settings */ | 41 | /* Flags used in combination with settings */ |
33 | 42 | ||
34 | /* use zero crossing to reduce clicks during volume changes */ | 43 | /* 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 @@ | |||
31 | #include "wm8758.h" | 31 | #include "wm8758.h" |
32 | #include "i2s.h" | 32 | #include "i2s.h" |
33 | 33 | ||
34 | const struct sound_settings_info audiohw_settings[] = { | ||
35 | [SOUND_VOLUME] = {"dB", 0, 1, -58, 6, -25}, | ||
36 | [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0}, | ||
37 | [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0}, | ||
38 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, | ||
39 | [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, | ||
40 | [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, | ||
41 | [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0}, | ||
42 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0}, | ||
43 | [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16}, | ||
44 | }; | ||
45 | |||
34 | /* convert tenth of dB volume (-57..6) to master volume register value */ | 46 | /* convert tenth of dB volume (-57..6) to master volume register value */ |
35 | int tenthdb2master(int db) | 47 | int tenthdb2master(int db) |
36 | { | 48 | { |
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 @@ | |||
35 | /* use zero crossing to reduce clicks during volume changes */ | 35 | /* use zero crossing to reduce clicks during volume changes */ |
36 | #define VOLUME_ZC_WAIT (1<<7) | 36 | #define VOLUME_ZC_WAIT (1<<7) |
37 | 37 | ||
38 | 38 | const struct sound_settings_info audiohw_settings[] = { | |
39 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, | ||
40 | [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0}, | ||
41 | [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0}, | ||
42 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, | ||
43 | [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, | ||
44 | [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, | ||
45 | [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0}, | ||
46 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0}, | ||
47 | [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16}, | ||
48 | }; | ||
39 | 49 | ||
40 | /* convert tenth of dB volume (-730..60) to master volume register value */ | 50 | /* convert tenth of dB volume (-730..60) to master volume register value */ |
41 | int tenthdb2master(int db) | 51 | 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 @@ | |||
21 | #define _AS3514_H | 21 | #define _AS3514_H |
22 | 22 | ||
23 | #include <stdbool.h> | 23 | #include <stdbool.h> |
24 | #include "audiohw.h" | ||
24 | 25 | ||
25 | extern int tenthdb2master(int db); | 26 | extern int tenthdb2master(int db); |
26 | 27 | ||
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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Christian Gmeiner | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #ifndef _AUDIOHW_H_ | ||
21 | #define _AUDIOHW_H_ | ||
22 | |||
23 | #include "config.h" | ||
24 | |||
25 | enum { | ||
26 | SOUND_VOLUME = 0, | ||
27 | SOUND_BASS, | ||
28 | SOUND_TREBLE, | ||
29 | SOUND_BALANCE, | ||
30 | SOUND_CHANNELS, | ||
31 | SOUND_STEREO_WIDTH, | ||
32 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
33 | SOUND_LOUDNESS, | ||
34 | SOUND_AVC, | ||
35 | SOUND_MDB_STRENGTH, | ||
36 | SOUND_MDB_HARMONICS, | ||
37 | SOUND_MDB_CENTER, | ||
38 | SOUND_MDB_SHAPE, | ||
39 | SOUND_MDB_ENABLE, | ||
40 | SOUND_SUPERBASS, | ||
41 | #endif | ||
42 | #if CONFIG_CODEC == MAS3587F || defined(HAVE_UDA1380) || defined(HAVE_TLV320)\ | ||
43 | || defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) | ||
44 | SOUND_LEFT_GAIN, | ||
45 | SOUND_RIGHT_GAIN, | ||
46 | SOUND_MIC_GAIN, | ||
47 | #endif | ||
48 | }; | ||
49 | |||
50 | enum Channel { | ||
51 | SOUND_CHAN_STEREO, | ||
52 | SOUND_CHAN_MONO, | ||
53 | SOUND_CHAN_CUSTOM, | ||
54 | SOUND_CHAN_MONO_LEFT, | ||
55 | SOUND_CHAN_MONO_RIGHT, | ||
56 | SOUND_CHAN_KARAOKE, | ||
57 | SOUND_CHAN_NUM_MODES, | ||
58 | }; | ||
59 | |||
60 | struct sound_settings_info { | ||
61 | const char *unit; | ||
62 | int numdecimals; | ||
63 | int steps; | ||
64 | int minval; | ||
65 | int maxval; | ||
66 | int defaultval; | ||
67 | }; | ||
68 | |||
69 | /* This struct is used by every driver to export its min/max/default values for | ||
70 | * its audio settings. Keep in mind that the order must be correct! */ | ||
71 | extern const struct sound_settings_info audiohw_settings[]; | ||
72 | |||
73 | #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 @@ | |||
253 | #endif | 253 | #endif |
254 | #endif | 254 | #endif |
255 | 255 | ||
256 | /* Add one HAVE_ define for all mas35xx targets */ | ||
257 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3507D) || (CONFIG_CODEC == MAS3539F) | ||
258 | #define HAVE_MAS35XX | ||
259 | #endif | ||
260 | |||
256 | #if CONFIG_CODEC == SWCODEC && !defined(BOOTLOADER) | 261 | #if CONFIG_CODEC == SWCODEC && !defined(BOOTLOADER) |
257 | #define HAVE_EXTENDED_MESSAGING_AND_NAME | 262 | #define HAVE_EXTENDED_MESSAGING_AND_NAME |
258 | #endif | 263 | #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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Implementation of MAS35xx audiohw api driver. | ||
11 | * | ||
12 | * Copyright (C) 2007 by Christian Gmeiner | ||
13 | * | ||
14 | * All files in this archive are subject to the GNU General Public License. | ||
15 | * See the file COPYING in the source tree root for full license agreement. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef _MAS35XX_H | ||
23 | #define _MAS35XX_H | ||
24 | |||
25 | #include "audiohw.h" | ||
26 | |||
27 | #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 @@ | |||
34 | #include "tlv320.h" | 34 | #include "tlv320.h" |
35 | #elif defined(HAVE_AS3514) | 35 | #elif defined(HAVE_AS3514) |
36 | #include "as3514.h" | 36 | #include "as3514.h" |
37 | #elif defined(HAVE_MAS35XX) | ||
38 | #include "mas35xx.h" | ||
37 | #endif | 39 | #endif |
38 | 40 | ||
39 | extern void audiohw_postinit(void); | 41 | extern void audiohw_postinit(void); |
40 | 42 | ||
41 | enum { | ||
42 | SOUND_VOLUME = 0, | ||
43 | SOUND_BASS, | ||
44 | SOUND_TREBLE, | ||
45 | SOUND_BALANCE, | ||
46 | SOUND_CHANNELS, | ||
47 | SOUND_STEREO_WIDTH, | ||
48 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
49 | SOUND_LOUDNESS, | ||
50 | SOUND_AVC, | ||
51 | SOUND_MDB_STRENGTH, | ||
52 | SOUND_MDB_HARMONICS, | ||
53 | SOUND_MDB_CENTER, | ||
54 | SOUND_MDB_SHAPE, | ||
55 | SOUND_MDB_ENABLE, | ||
56 | SOUND_SUPERBASS, | ||
57 | #endif | ||
58 | #if CONFIG_CODEC == MAS3587F || defined(HAVE_UDA1380) || defined(HAVE_TLV320)\ | ||
59 | || defined(HAVE_WM8975) || defined(HAVE_WM8758) || defined(HAVE_WM8731) | ||
60 | SOUND_LEFT_GAIN, | ||
61 | SOUND_RIGHT_GAIN, | ||
62 | SOUND_MIC_GAIN, | ||
63 | #endif | ||
64 | }; | ||
65 | |||
66 | enum { | ||
67 | SOUND_CHAN_STEREO = 0, | ||
68 | SOUND_CHAN_MONO, | ||
69 | SOUND_CHAN_CUSTOM, | ||
70 | SOUND_CHAN_MONO_LEFT, | ||
71 | SOUND_CHAN_MONO_RIGHT, | ||
72 | SOUND_CHAN_KARAOKE, | ||
73 | SOUND_CHAN_NUM_MODES | ||
74 | }; | ||
75 | |||
76 | typedef void sound_set_type(int value); | 43 | typedef void sound_set_type(int value); |
77 | 44 | ||
78 | const char *sound_unit(int setting); | 45 | 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 @@ | |||
23 | #define VOLUME_MIN -730 | 23 | #define VOLUME_MIN -730 |
24 | #define VOLUME_MAX 60 | 24 | #define VOLUME_MAX 60 |
25 | 25 | ||
26 | #include "audiohw.h" | ||
27 | |||
26 | extern int tenthdb2master(int db); | 28 | extern int tenthdb2master(int db); |
27 | 29 | ||
28 | /*** definitions ***/ | 30 | /*** 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 @@ | |||
20 | #ifndef _UDA1380_H | 20 | #ifndef _UDA1380_H |
21 | #define _UDA1380_H | 21 | #define _UDA1380_H |
22 | 22 | ||
23 | #include "audiohw.h" | ||
24 | |||
23 | /* volume/balance/treble/bass interdependency */ | 25 | /* volume/balance/treble/bass interdependency */ |
24 | #define VOLUME_MIN -840 | 26 | #define VOLUME_MIN -840 |
25 | #define VOLUME_MAX 0 | 27 | #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 @@ | |||
24 | #define VOLUME_MIN -730 | 24 | #define VOLUME_MIN -730 |
25 | #define VOLUME_MAX 60 | 25 | #define VOLUME_MAX 60 |
26 | 26 | ||
27 | #include "audiohw.h" | ||
28 | |||
27 | extern int tenthdb2master(int db); | 29 | extern int tenthdb2master(int db); |
28 | extern int tenthdb2mixer(int db); | 30 | extern int tenthdb2mixer(int db); |
29 | 31 | ||
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 @@ | |||
23 | #define VOLUME_MIN -730 | 23 | #define VOLUME_MIN -730 |
24 | #define VOLUME_MAX 60 | 24 | #define VOLUME_MAX 60 |
25 | 25 | ||
26 | #include "audiohw.h" | ||
27 | |||
26 | extern int tenthdb2master(int db); | 28 | extern int tenthdb2master(int db); |
27 | extern int tenthdb2mixer(int db); | 29 | extern int tenthdb2mixer(int db); |
28 | 30 | ||
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 @@ | |||
24 | #define VOLUME_MIN -570 | 24 | #define VOLUME_MIN -570 |
25 | #define VOLUME_MAX 60 | 25 | #define VOLUME_MAX 60 |
26 | 26 | ||
27 | #include "audiohw.h" | ||
28 | |||
27 | extern int tenthdb2master(int db); | 29 | extern int tenthdb2master(int db); |
28 | extern int tenthdb2mixer(int db); | 30 | extern int tenthdb2mixer(int db); |
29 | 31 | ||
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 @@ | |||
24 | #define VOLUME_MIN -730 | 24 | #define VOLUME_MIN -730 |
25 | #define VOLUME_MAX 60 | 25 | #define VOLUME_MAX 60 |
26 | 26 | ||
27 | #include "audiohw.h" | ||
28 | |||
27 | extern int tenthdb2master(int db); | 29 | extern int tenthdb2master(int db); |
28 | extern int tenthdb2mixer(int db); | 30 | extern int tenthdb2mixer(int db); |
29 | 31 | ||
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 @@ | |||
33 | #include "dac.h" | 33 | #include "dac.h" |
34 | #include "system.h" | 34 | #include "system.h" |
35 | #endif | 35 | #endif |
36 | #include "audiohw.h" | ||
36 | 37 | ||
37 | /* hacking into mpeg.c, recording is still there */ | 38 | /* hacking into mpeg.c, recording is still there */ |
38 | #if CONFIG_CODEC == MAS3587F | 39 | #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 @@ | |||
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2005 by Linus Nielsen Feltzing | 10 | * Copyright (C) 2005 by Linus Nielsen Feltzing |
11 | * Copyright (C) 2007 by Christian Gmeiner | ||
11 | * | 12 | * |
12 | * All files in this archive are subject to the GNU General Public License. | 13 | * All files in this archive are subject to the GNU General Public License. |
13 | * See the file COPYING in the source tree root for full license agreement. | 14 | * See the file COPYING in the source tree root for full license agreement. |
@@ -43,132 +44,113 @@ extern unsigned shadow_codec_reg0; | |||
43 | #endif | 44 | #endif |
44 | #endif /* SIMULATOR */ | 45 | #endif /* SIMULATOR */ |
45 | 46 | ||
46 | struct sound_settings_info { | 47 | #ifdef SIMULATOR |
47 | const char *unit; | 48 | /* dummy for sim */ |
48 | int numdecimals; | 49 | const struct sound_settings_info audiohw_settings[] = { |
49 | int steps; | 50 | [SOUND_VOLUME] = {"dB", 0, 1, -40, 6, -25}, |
50 | int minval; | 51 | [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0}, |
51 | int maxval; | 52 | [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0}, |
52 | int defaultval; | 53 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, |
53 | sound_set_type *setfn; | 54 | [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, |
55 | [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100}, | ||
54 | }; | 56 | }; |
55 | |||
56 | static const struct sound_settings_info sound_settings_table[] = { | ||
57 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
58 | [SOUND_VOLUME] = {"dB", 0, 1,-100, 12, -25, sound_set_volume}, | ||
59 | [SOUND_BASS] = {"dB", 0, 1, -12, 12, 6, sound_set_bass}, | ||
60 | [SOUND_TREBLE] = {"dB", 0, 1, -12, 12, 6, sound_set_treble}, | ||
61 | #elif defined(HAVE_UDA1380) | ||
62 | [SOUND_VOLUME] = {"dB", 0, 1, -84, 0, -25, sound_set_volume}, | ||
63 | [SOUND_BASS] = {"dB", 0, 2, 0, 24, 0, sound_set_bass}, | ||
64 | [SOUND_TREBLE] = {"dB", 0, 2, 0, 6, 0, sound_set_treble}, | ||
65 | #elif defined(HAVE_TLV320) | ||
66 | [SOUND_VOLUME] = {"dB", 0, 1, -73, 6, -20, sound_set_volume}, | ||
67 | #elif defined(HAVE_WM8751) | ||
68 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25, sound_set_volume}, | ||
69 | [SOUND_BASS] = {"dB", 1, 15, -60, 90, 0, sound_set_bass}, | ||
70 | [SOUND_TREBLE] = {"dB", 1, 15, -60, 90, 0, sound_set_treble}, | ||
71 | #elif defined(HAVE_WM8975) | ||
72 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25, sound_set_volume}, | ||
73 | [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass}, | ||
74 | [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble}, | ||
75 | #elif defined(HAVE_WM8758) | ||
76 | [SOUND_VOLUME] = {"dB", 0, 1, -58, 6, -25, sound_set_volume}, | ||
77 | [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0, sound_set_bass}, | ||
78 | [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble}, | ||
79 | #elif defined(HAVE_WM8731) || defined(HAVE_WM8721) | ||
80 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25, sound_set_volume}, | ||
81 | #elif (CONFIG_CPU == PNX0101) | ||
82 | [SOUND_VOLUME] = {"dB", 0, 1, -48, 15, 0, sound_set_volume}, | ||
83 | #elif defined(HAVE_AS3514) | ||
84 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25, sound_set_volume}, | ||
85 | #else /* MAS3507D */ | ||
86 | [SOUND_VOLUME] = {"dB", 0, 1, -78, 18, -18, sound_set_volume}, | ||
87 | [SOUND_BASS] = {"dB", 0, 1, -15, 15, 7, sound_set_bass}, | ||
88 | [SOUND_TREBLE] = {"dB", 0, 1, -15, 15, 7, sound_set_treble}, | ||
89 | #endif | ||
90 | /* Override any other potentially existing treble/bass controllers if wanted */ | ||
91 | #ifdef HAVE_SW_TONE_CONTROLS | ||
92 | [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0, sound_set_bass}, | ||
93 | [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0, sound_set_treble}, | ||
94 | #endif | ||
95 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0, sound_set_balance}, | ||
96 | [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0, sound_set_channels}, | ||
97 | [SOUND_STEREO_WIDTH] = {"%", 0, 1, 0, 255, 100, sound_set_stereo_width}, | ||
98 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
99 | [SOUND_LOUDNESS] = {"dB", 0, 1, 0, 17, 0, sound_set_loudness}, | ||
100 | [SOUND_AVC] = {"", 0, 1, -1, 4, 0, sound_set_avc}, | ||
101 | [SOUND_MDB_STRENGTH] = {"dB", 0, 1, 0, 127, 48, sound_set_mdb_strength}, | ||
102 | [SOUND_MDB_HARMONICS] = {"%", 0, 1, 0, 100, 50, sound_set_mdb_harmonics}, | ||
103 | [SOUND_MDB_CENTER] = {"Hz", 0, 10, 20, 300, 60, sound_set_mdb_center}, | ||
104 | [SOUND_MDB_SHAPE] = {"Hz", 0, 10, 50, 300, 90, sound_set_mdb_shape}, | ||
105 | [SOUND_MDB_ENABLE] = {"", 0, 1, 0, 1, 0, sound_set_mdb_enable}, | ||
106 | [SOUND_SUPERBASS] = {"", 0, 1, 0, 1, 0, sound_set_superbass}, | ||
107 | #endif | ||
108 | #if CONFIG_CODEC == MAS3587F | ||
109 | [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 15, 8, NULL}, | ||
110 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 15, 8, NULL}, | ||
111 | [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 15, 2, NULL}, | ||
112 | #elif defined(HAVE_UDA1380) | ||
113 | [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, | ||
114 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, | ||
115 | [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16, NULL}, | ||
116 | #elif defined(HAVE_TLV320) | ||
117 | [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 31, 23, NULL}, | ||
118 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 31, 23, NULL}, | ||
119 | [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 1, 1, NULL}, | ||
120 | #elif defined(HAVE_WM8975) | ||
121 | [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, | ||
122 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, | ||
123 | [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16, NULL}, | ||
124 | #elif defined(HAVE_WM8758) | ||
125 | [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, | ||
126 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, | ||
127 | [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16, NULL}, | ||
128 | #elif defined(HAVE_WM8731) | ||
129 | [SOUND_LEFT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, | ||
130 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1,-128, 96, 0, NULL}, | ||
131 | [SOUND_MIC_GAIN] = {"dB", 1, 1,-128, 108, 16, NULL}, | ||
132 | #endif | 57 | #endif |
133 | }; | ||
134 | 58 | ||
135 | const char *sound_unit(int setting) | 59 | const char *sound_unit(int setting) |
136 | { | 60 | { |
137 | return sound_settings_table[setting].unit; | 61 | return audiohw_settings[setting].unit; |
138 | } | 62 | } |
139 | 63 | ||
140 | int sound_numdecimals(int setting) | 64 | int sound_numdecimals(int setting) |
141 | { | 65 | { |
142 | return sound_settings_table[setting].numdecimals; | 66 | return audiohw_settings[setting].numdecimals; |
143 | } | 67 | } |
144 | 68 | ||
145 | int sound_steps(int setting) | 69 | int sound_steps(int setting) |
146 | { | 70 | { |
147 | return sound_settings_table[setting].steps; | 71 | return audiohw_settings[setting].steps; |
148 | } | 72 | } |
149 | 73 | ||
150 | int sound_min(int setting) | 74 | int sound_min(int setting) |
151 | { | 75 | { |
152 | return sound_settings_table[setting].minval; | 76 | return audiohw_settings[setting].minval; |
153 | } | 77 | } |
154 | 78 | ||
155 | int sound_max(int setting) | 79 | int sound_max(int setting) |
156 | { | 80 | { |
157 | return sound_settings_table[setting].maxval; | 81 | return audiohw_settings[setting].maxval; |
158 | } | 82 | } |
159 | 83 | ||
160 | int sound_default(int setting) | 84 | int sound_default(int setting) |
161 | { | 85 | { |
162 | return sound_settings_table[setting].defaultval; | 86 | return audiohw_settings[setting].defaultval; |
163 | } | 87 | } |
164 | 88 | ||
165 | sound_set_type* sound_get_fn(int setting) | 89 | sound_set_type* sound_get_fn(int setting) |
166 | { | 90 | { |
167 | if ((unsigned)setting < (sizeof(sound_settings_table) | 91 | sound_set_type* result = NULL; |
168 | / sizeof(struct sound_settings_info))) | 92 | |
169 | return sound_settings_table[setting].setfn; | 93 | switch (setting) { |
170 | else | 94 | case SOUND_VOLUME: |
171 | return NULL; | 95 | result = sound_set_volume; |
96 | break; | ||
97 | |||
98 | case SOUND_BASS: | ||
99 | result = sound_set_bass; | ||
100 | break; | ||
101 | |||
102 | case SOUND_TREBLE: | ||
103 | result = sound_set_treble; | ||
104 | break; | ||
105 | |||
106 | case SOUND_BALANCE: | ||
107 | result = sound_set_balance; | ||
108 | break; | ||
109 | |||
110 | case SOUND_CHANNELS: | ||
111 | result = sound_set_channels; | ||
112 | break; | ||
113 | |||
114 | case SOUND_STEREO_WIDTH: | ||
115 | result = sound_set_stereo_width; | ||
116 | break; | ||
117 | |||
118 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
119 | case SOUND_LOUDNESS: | ||
120 | result = sound_set_loudness; | ||
121 | break; | ||
122 | |||
123 | case SOUND_AVC: | ||
124 | result = sound_set_avc; | ||
125 | break; | ||
126 | |||
127 | case SOUND_MDB_STRENGTH: | ||
128 | result = sound_set_mdb_strength; | ||
129 | break; | ||
130 | |||
131 | case SOUND_MDB_HARMONICS: | ||
132 | result = sound_set_mdb_harmonics; | ||
133 | break; | ||
134 | |||
135 | case SOUND_MDB_CENTER: | ||
136 | result = sound_set_mdb_center; | ||
137 | break; | ||
138 | |||
139 | case SOUND_MDB_SHAPE: | ||
140 | result = sound_set_mdb_shape; | ||
141 | break; | ||
142 | |||
143 | case SOUND_MDB_ENABLE: | ||
144 | result = sound_set_mdb_enable; | ||
145 | break; | ||
146 | |||
147 | case SOUND_SUPERBASS: | ||
148 | result = sound_set_superbass; | ||
149 | break; | ||
150 | #endif | ||
151 | } | ||
152 | |||
153 | return result; | ||
172 | } | 154 | } |
173 | 155 | ||
174 | #if CONFIG_CODEC == SWCODEC | 156 | #if CONFIG_CODEC == SWCODEC |