commit FS#9027 - conditional viewports
[kugel-rb.git] / firmware / export / audiohw.h
blobb61fea9baa84cf08bc0523b7fc6601d1a21e5f5a
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 by Christian Gmeiner
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #ifndef _AUDIOHW_H_
21 #define _AUDIOHW_H_
23 #include "config.h"
24 #include <stdbool.h>
26 /* define some audiohw caps */
27 #define TREBLE_CAP (1 << 0)
28 #define BASS_CAP (1 << 1)
29 #define BALANCE_CAP (1 << 2)
30 #define CLIPPING_CAP (1 << 3)
31 #define PRESCALER_CAP (1 << 4)
32 #define BASS_CUTOFF_CAP (1 << 5)
33 #define TREBLE_CUTOFF_CAP (1 << 6)
35 #ifdef HAVE_UDA1380
36 #include "uda1380.h"
37 #elif defined(HAVE_WM8751)
38 #include "wm8751.h"
39 #elif defined(HAVE_WM8978)
40 #include "wm8978.h"
41 #elif defined(HAVE_WM8975)
42 #include "wm8975.h"
43 #elif defined(HAVE_WM8985)
44 #include "wm8985.h"
45 #elif defined(HAVE_WM8758)
46 #include "wm8758.h"
47 #elif defined(HAVE_WM8721)
48 #include "wm8721.h"
49 #elif defined(HAVE_WM8731)
50 #include "wm8731.h"
51 #elif defined(HAVE_TLV320)
52 #include "tlv320.h"
53 #elif defined(HAVE_AS3514)
54 #include "as3514.h"
55 #elif defined(HAVE_MAS35XX)
56 #include "mas35xx.h"
57 #elif defined(HAVE_TSC2100)
58 #include "tsc2100.h"
59 #endif
61 /* convert caps into defines */
62 #ifdef AUDIOHW_CAPS
63 #if (AUDIOHW_CAPS & TREBLE_CAP)
64 #define AUDIOHW_HAVE_TREBLE
65 #endif
67 #if (AUDIOHW_CAPS & BASS_CAP)
68 #define AUDIOHW_HAVE_BASS
69 #endif
71 #if (AUDIOHW_CAPS & BALANCE_CAP)
72 #define AUDIOHW_HAVE_BALANCE
73 #endif
75 #if (AUDIOHW_CAPS & CLIPPING_CAP)
76 #define AUDIOHW_HAVE_CLIPPING
77 #endif
79 #if (AUDIOHW_CAPS & PRESCALER_CAP)
80 #define AUDIOHW_HAVE_PRESCALER
81 #endif
83 #if (AUDIOHW_CAPS & BASS_CUTOFF_CAP)
84 #define AUDIOHW_HAVE_BASS_CUTOFF
85 #endif
87 #if (AUDIOHW_CAPS & TREBLE_CUTOFF_CAP)
88 #define AUDIOHW_HAVE_TREBLE_CUTOFF
89 #endif
90 #endif /* AUDIOHW_CAPS */
92 enum {
93 SOUND_VOLUME = 0,
94 SOUND_BASS,
95 SOUND_TREBLE,
96 SOUND_BALANCE,
97 SOUND_CHANNELS,
98 SOUND_STEREO_WIDTH,
99 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
100 SOUND_LOUDNESS,
101 SOUND_AVC,
102 SOUND_MDB_STRENGTH,
103 SOUND_MDB_HARMONICS,
104 SOUND_MDB_CENTER,
105 SOUND_MDB_SHAPE,
106 SOUND_MDB_ENABLE,
107 SOUND_SUPERBASS,
108 #endif
109 #if defined(HAVE_RECORDING)
110 SOUND_LEFT_GAIN,
111 SOUND_RIGHT_GAIN,
112 SOUND_MIC_GAIN,
113 #endif
114 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
115 SOUND_BASS_CUTOFF,
116 #endif
117 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
118 SOUND_TREBLE_CUTOFF,
119 #endif
122 enum Channel {
123 SOUND_CHAN_STEREO,
124 SOUND_CHAN_MONO,
125 SOUND_CHAN_CUSTOM,
126 SOUND_CHAN_MONO_LEFT,
127 SOUND_CHAN_MONO_RIGHT,
128 SOUND_CHAN_KARAOKE,
129 SOUND_CHAN_NUM_MODES,
132 struct sound_settings_info {
133 const char *unit;
134 int numdecimals;
135 int steps;
136 int minval;
137 int maxval;
138 int defaultval;
141 /* This struct is used by every driver to export its min/max/default values for
142 * its audio settings. Keep in mind that the order must be correct! */
143 extern const struct sound_settings_info audiohw_settings[];
145 /* All usable functions implemented by a audio codec drivers. Most of
146 * the function in sound settings are only called, when in audio codecs
147 * .h file suitable defines are added.
151 * Initialize audio codec to a well defined state.
153 void audiohw_init(void);
156 * Do initial audio codec setup.
158 void audiohw_preinit(void);
161 * Do some stuff (codec related) after audiohw_init that needs to be
162 * delayed such as enabling outputs to prevent popping. This lets
163 * other inits in the system complete in the meantime.
165 void audiohw_postinit(void);
168 * Close audio codec.
170 void audiohw_close(void);
172 #ifdef AUDIOHW_HAVE_CLIPPING
174 * Set new volume value
175 * @param val to set.
176 * NOTE: AUDIOHW_CAPS need to contain
177 * CLIPPING_CAP
179 void audiohw_set_volume(int val);
180 #endif
182 #ifdef AUDIOHW_HAVE_PRESCALER
184 * Set new prescaler value.
185 * @param val to set.
186 * NOTE: AUDIOHW_CAPS need to contain
187 * PRESCALER_CAP
189 void audiohw_set_prescaler(int val);
190 #endif
192 #ifdef AUDIOHW_HAVE_BALANCE
194 * Set new balance value
195 * @param val to set.
196 * NOTE: AUDIOHW_CAPS need to contain
197 * BALANCE_CAP
199 void audiohw_set_balance(int val);
200 #endif
203 * Mute or enable sound.
204 * @param mute true or false.
206 void audiohw_mute(bool mute);
209 * Silently en/disable audio output.
210 * @param enable true or false.
212 void audiohw_enable_output(bool enable);
214 #ifdef AUDIOHW_HAVE_TREBLE
216 * Set new treble value.
217 * @param val to set.
218 * NOTE: AUDIOHW_CAPS need to contain
219 * TREBLE_CAP
221 void audiohw_set_treble(int val);
222 #endif
224 #ifdef AUDIOHW_HAVE_BASS
226 * Set new bass value.
227 * @param val to set.
228 * NOTE: AUDIOHW_CAPS need to contain
229 * BASS_CAP
231 void audiohw_set_bass(int val);
232 #endif
234 #ifdef AUDIOHW_HAVE_BASS_CUTOFF
236 * Set new bass cut off value.
237 * @param val to set.
238 * NOTE: AUDIOHW_CAPS need to contain
239 * BASS_CUTOFF_CAP
241 void audiohw_set_bass_cutoff(int val);
242 #endif
244 #ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
246 * Set new treble cut off value.
247 * @param val to set.
248 * NOTE: AUDIOHW_CAPS need to contain
249 * TREBLE_CUTOFF_CAP
251 void audiohw_set_treble_cutoff(int val);
252 #endif
254 #ifdef HAVE_RECORDING
257 * Enable recording.
258 * @param source_mic if this is true, we want to record from microphone,
259 * else we want to record FM/LineIn.
261 void audiohw_enable_recording(bool source_mic);
264 * Disable recording.
266 void audiohw_disable_recording(void);
269 * Set gain of recording source.
270 * @param left gain value.
271 * @param right will not be used if recording from micophone (mono).
272 * @param type AUDIO_GAIN_MIC, AUDIO_GAIN_LINEIN.
274 void audiohw_set_recvol(int left, int right, int type);
277 * Enable or disable recording monitor.
278 * @param enable ture or false.
280 void audiohw_set_monitor(bool enable);
282 #endif /*HAVE_RECORDING*/
285 #if CONFIG_CODEC != SWCODEC
287 /* functions which are only used by mas35xx codecs, but are also
288 aviable on SWCODECS through dsp */
291 * Set channel configuration.
292 * @param val new channel value (see enum Channel).
294 void audiohw_set_channel(int val);
297 * Set stereo width.
298 * @param val new stereo width value.
300 void audiohw_set_stereo_width(int val);
302 #endif /* CONFIG_CODEC != SWCODEC */
304 #endif /* _AUDIOHW_H_ */