1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright © 2010 Thomas Martitz
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include <SDL_audio.h>
27 * Audio Hardware api. Make them do nothing as we cannot properly simulate with
28 * SDL. if we used DSP we would run code that doesn't actually run on the target
31 extern void pcm_set_mixer_volume(int);
33 void audiohw_set_volume(int volume
)
35 #if CONFIG_CODEC == SWCODEC
37 SDL_MIX_MAXVOLUME
* ((volume
- VOLUME_MIN
) / 10) / (VOLUME_RANGE
/ 10));
43 const struct sound_settings_info audiohw_settings
[] = {
44 [SOUND_VOLUME
] = {"dB", 0, 1, VOLUME_MIN
/ 10, VOLUME_MAX
/ 10, -25},
45 /* Bass and treble tone controls */
46 #ifdef AUDIOHW_HAVE_BASS
47 [SOUND_BASS
] = {"dB", 0, 1, -24, 24, 0},
49 #ifdef AUDIOHW_HAVE_TREBLE
50 [SOUND_TREBLE
] = {"dB", 0, 1, -24, 24, 0},
52 [SOUND_BALANCE
] = {"%", 0, 1,-100, 100, 0},
53 [SOUND_CHANNELS
] = {"", 0, 1, 0, 5, 0},
54 [SOUND_STEREO_WIDTH
] = {"%", 0, 5, 0, 250, 100},
55 #if defined(HAVE_RECORDING)
56 [SOUND_LEFT_GAIN
] = {"dB", 1, 1,-128, 96, 0},
57 [SOUND_RIGHT_GAIN
] = {"dB", 1, 1,-128, 96, 0},
58 [SOUND_MIC_GAIN
] = {"dB", 1, 1,-128, 108, 16},
60 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
61 [SOUND_BASS_CUTOFF
] = {"", 0, 1, 1, 4, 1},
63 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
64 [SOUND_TREBLE_CUTOFF
] = {"", 0, 1, 1, 4, 1},
66 #if defined(AUDIOHW_HAVE_DEPTH_3D)
67 [SOUND_DEPTH_3D
] = {"%", 0, 1, 0, 15, 0},
69 /* Hardware EQ tone controls */
70 #if defined(AUDIOHW_HAVE_EQ_BAND1)
71 [SOUND_EQ_BAND1_GAIN
] = {"dB", 0, 1, -12, 12, 0},
73 #if defined(AUDIOHW_HAVE_EQ_BAND2)
74 [SOUND_EQ_BAND2_GAIN
] = {"dB", 0, 1, -12, 12, 0},
76 #if defined(AUDIOHW_HAVE_EQ_BAND3)
77 [SOUND_EQ_BAND3_GAIN
] = {"dB", 0, 1, -12, 12, 0},
79 #if defined(AUDIOHW_HAVE_EQ_BAND4)
80 [SOUND_EQ_BAND4_GAIN
] = {"dB", 0, 1, -12, 12, 0},
82 #if defined(AUDIOHW_HAVE_EQ_BAND5)
83 [SOUND_EQ_BAND5_GAIN
] = {"dB", 0, 1, -12, 12, 0},
85 #if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
86 [SOUND_EQ_BAND1_FREQUENCY
] = {"", 0, 1, 1, 4, 1},
88 #if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
89 [SOUND_EQ_BAND2_FREQUENCY
] = {"", 0, 1, 1, 4, 1},
91 #if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
92 [SOUND_EQ_BAND3_FREQUENCY
] = {"", 0, 1, 1, 4, 1},
94 #if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
95 [SOUND_EQ_BAND4_FREQUENCY
] = {"", 0, 1, 1, 4, 1},
97 #if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
98 [SOUND_EQ_BAND5_FREQUENCY
] = {"", 0, 1, 1, 4, 1},
100 #if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
101 [SOUND_EQ_BAND2_WIDTH
] = {"", 0, 1, 0, 1, 0},
103 #if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
104 [SOUND_EQ_BAND3_WIDTH
] = {"", 0, 1, 0, 1, 0},
106 #if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
107 [SOUND_EQ_BAND4_WIDTH
] = {"", 0, 1, 0, 1, 0},
110 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
111 [SOUND_LOUDNESS
] = {"dB", 0, 1, 0, 17, 0},
112 [SOUND_AVC
] = {"", 0, 1, -1, 4, 0},
113 [SOUND_MDB_STRENGTH
] = {"dB", 0, 1, 0, 127, 48},
114 [SOUND_MDB_HARMONICS
] = {"%", 0, 1, 0, 100, 50},
115 [SOUND_MDB_CENTER
] = {"Hz", 0, 10, 20, 300, 60},
116 [SOUND_MDB_SHAPE
] = {"Hz", 0, 10, 50, 300, 90},
117 [SOUND_MDB_ENABLE
] = {"", 0, 1, 0, 1, 0},
118 [SOUND_SUPERBASS
] = {"", 0, 1, 0, 1, 0},
119 #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
123 * stubs here, for the simulator
126 #if defined(AUDIOHW_HAVE_PRESCALER)
127 void audiohw_set_prescaler(int value
) { (void)value
; }
129 #if defined(AUDIOHW_HAVE_BALANCE)
130 void audiohw_set_balance(int value
) { (void)value
; }
132 #if defined(AUDIOHW_HAVE_BASS)
133 void audiohw_set_bass(int value
) { (void)value
; }
135 #if defined(AUDIOHW_HAVE_TREBLE)
136 void audiohw_set_treble(int value
) { (void)value
; }
138 #if CONFIG_CODEC != SWCODEC
139 void audiohw_set_channel(int value
) { (void)value
; }
140 void audiohw_set_stereo_width(int value
){ (void)value
; }
142 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
143 void audiohw_set_bass_cutoff(int value
) { (void)value
; }
145 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
146 void audiohw_set_treble_cutoff(int value
){ (void)value
; }
148 /* EQ-based tone controls */
149 #if defined(AUDIOHW_HAVE_EQ)
150 void audiohw_set_eq_band_gain(unsigned int band
, int value
)
151 { (void)band
; (void)value
; }
153 #if defined(AUDIOHW_HAVE_EQ_FREQUENCY)
154 void audiohw_set_eq_band_frequency(unsigned int band
, int value
)
155 { (void)band
; (void)value
; }
157 #if defined(AUDIOHW_HAVE_EQ_WIDTH)
158 void audiohw_set_eq_band_width(unsigned int band
, int value
)
159 { (void)band
; (void)value
; }
161 #if defined(AUDIOHW_HAVE_DEPTH_3D)
162 void audiohw_set_depth_3d(int value
)
165 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
166 int mas_codec_readreg(int reg
)
172 int mas_codec_writereg(int reg
, unsigned int val
)
178 int mas_writemem(int bank
, int addr
, const unsigned long* src
, int len
)