Move the PCM/audio playback part of SDL into the target tree.
[kugel-rb.git] / firmware / export / audiohw.h
blob23757e07f6caf85174a57756f5679ecef18c75c6
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 by Christian Gmeiner
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 #ifndef _AUDIOHW_H_
23 #define _AUDIOHW_H_
25 #include "config.h"
26 #include <stdbool.h>
28 /* define some audiohw caps */
29 #define TREBLE_CAP (1 << 0)
30 #define BASS_CAP (1 << 1)
31 #define BALANCE_CAP (1 << 2)
32 #define CLIPPING_CAP (1 << 3)
33 #define PRESCALER_CAP (1 << 4)
34 #define BASS_CUTOFF_CAP (1 << 5)
35 #define TREBLE_CUTOFF_CAP (1 << 6)
37 #ifdef HAVE_UDA1380
38 #include "uda1380.h"
39 #elif defined(HAVE_UDA1341)
40 #include "uda1341.h"
41 #elif defined(HAVE_WM8750) || defined(HAVE_WM8751)
42 #include "wm8751.h"
43 #elif defined(HAVE_WM8978)
44 #include "wm8978.h"
45 #elif defined(HAVE_WM8975)
46 #include "wm8975.h"
47 #elif defined(HAVE_WM8985)
48 #include "wm8985.h"
49 #elif defined(HAVE_WM8758)
50 #include "wm8758.h"
51 #elif defined(HAVE_WM8711) || defined(HAVE_WM8721) || \
52 defined(HAVE_WM8731)
53 #include "wm8731.h"
54 #elif defined(HAVE_TLV320)
55 #include "tlv320.h"
56 #elif defined(HAVE_AS3514)
57 #include "as3514.h"
58 #elif defined(HAVE_MAS35XX)
59 #include "mas35xx.h"
60 #elif defined(HAVE_TSC2100)
61 #include "tsc2100.h"
62 #elif defined(HAVE_JZ4740_CODEC)
63 #include "jz4740-codec.h"
64 #elif defined(HAVE_AK4537)
65 #include "ak4537.h"
66 #endif
67 #if defined(HAVE_SDL_AUDIO)
68 #include <SDL.h>
69 #endif
73 #define ONE_DB 10
75 #if !defined(VOLUME_MIN) && !defined(VOLUME_MAX)
76 #warning define for VOLUME_MIN and VOLUME_MAX is missing
77 #define VOLUME_MIN -700
78 #define VOLUME_MAX 0
79 #endif
81 /* volume/balance/treble/bass interdependency main part */
82 #define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN)
85 /* convert caps into defines */
86 #ifdef AUDIOHW_CAPS
87 #if (AUDIOHW_CAPS & TREBLE_CAP)
88 #define AUDIOHW_HAVE_TREBLE
89 #endif
91 #if (AUDIOHW_CAPS & BASS_CAP)
92 #define AUDIOHW_HAVE_BASS
93 #endif
95 #if (AUDIOHW_CAPS & BALANCE_CAP)
96 #define AUDIOHW_HAVE_BALANCE
97 #endif
99 #if (AUDIOHW_CAPS & CLIPPING_CAP)
100 #define AUDIOHW_HAVE_CLIPPING
101 #endif
103 #if (AUDIOHW_CAPS & PRESCALER_CAP)
104 #define AUDIOHW_HAVE_PRESCALER
105 #endif
107 #if (AUDIOHW_CAPS & BASS_CUTOFF_CAP)
108 #define AUDIOHW_HAVE_BASS_CUTOFF
109 #endif
111 #if (AUDIOHW_CAPS & TREBLE_CUTOFF_CAP)
112 #define AUDIOHW_HAVE_TREBLE_CUTOFF
113 #endif
114 #endif /* AUDIOHW_CAPS */
116 enum {
117 SOUND_VOLUME = 0,
118 SOUND_BASS,
119 SOUND_TREBLE,
120 SOUND_BALANCE,
121 SOUND_CHANNELS,
122 SOUND_STEREO_WIDTH,
123 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
124 SOUND_LOUDNESS,
125 SOUND_AVC,
126 SOUND_MDB_STRENGTH,
127 SOUND_MDB_HARMONICS,
128 SOUND_MDB_CENTER,
129 SOUND_MDB_SHAPE,
130 SOUND_MDB_ENABLE,
131 SOUND_SUPERBASS,
132 #endif
133 #if defined(HAVE_RECORDING)
134 SOUND_LEFT_GAIN,
135 SOUND_RIGHT_GAIN,
136 SOUND_MIC_GAIN,
137 #endif
138 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
139 SOUND_BASS_CUTOFF,
140 #endif
141 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
142 SOUND_TREBLE_CUTOFF,
143 #endif
144 SOUND_LAST_SETTING, /* Keep this last */
147 enum Channel {
148 SOUND_CHAN_STEREO,
149 SOUND_CHAN_MONO,
150 SOUND_CHAN_CUSTOM,
151 SOUND_CHAN_MONO_LEFT,
152 SOUND_CHAN_MONO_RIGHT,
153 SOUND_CHAN_KARAOKE,
154 SOUND_CHAN_NUM_MODES,
157 struct sound_settings_info {
158 const char *unit;
159 char numdecimals;
160 char steps;
161 short minval;
162 short maxval;
163 short defaultval;
166 /* This struct is used by every driver to export its min/max/default values for
167 * its audio settings. Keep in mind that the order must be correct! */
168 extern const struct sound_settings_info audiohw_settings[];
170 /* All usable functions implemented by a audio codec drivers. Most of
171 * the function in sound settings are only called, when in audio codecs
172 * .h file suitable defines are added.
176 * Initialize audio codec to a well defined state. Includes SoC-specific
177 * setup.
179 void audiohw_init(void);
182 * Do initial audio codec setup. Usually called from audiohw_init.
184 void audiohw_preinit(void);
187 * Do some stuff (codec related) after audiohw_init that needs to be
188 * delayed such as enabling outputs to prevent popping. This lets
189 * other inits in the system complete in the meantime.
191 void audiohw_postinit(void);
194 * Close audio codec.
196 void audiohw_close(void);
198 #if defined(AUDIOHW_HAVE_CLIPPING) || defined(HAVE_SDL_AUDIO)
200 * Set new volume value
201 * @param val to set.
202 * NOTE: AUDIOHW_CAPS need to contain
203 * CLIPPING_CAP
205 void audiohw_set_volume(int val);
206 #endif
208 #ifdef AUDIOHW_HAVE_PRESCALER
210 * Set new prescaler value.
211 * @param val to set.
212 * NOTE: AUDIOHW_CAPS need to contain
213 * PRESCALER_CAP
215 void audiohw_set_prescaler(int val);
216 #endif
218 #ifdef AUDIOHW_HAVE_BALANCE
220 * Set new balance value
221 * @param val to set.
222 * NOTE: AUDIOHW_CAPS need to contain
223 * BALANCE_CAP
225 void audiohw_set_balance(int val);
226 #endif
228 #ifdef AUDIOHW_HAVE_TREBLE
230 * Set new treble value.
231 * @param val to set.
232 * NOTE: AUDIOHW_CAPS need to contain
233 * TREBLE_CAP
235 void audiohw_set_treble(int val);
236 #endif
238 #ifdef AUDIOHW_HAVE_BASS
240 * Set new bass value.
241 * @param val to set.
242 * NOTE: AUDIOHW_CAPS need to contain
243 * BASS_CAP
245 void audiohw_set_bass(int val);
246 #endif
248 #ifdef AUDIOHW_HAVE_BASS_CUTOFF
250 * Set new bass cut off value.
251 * @param val to set.
252 * NOTE: AUDIOHW_CAPS need to contain
253 * BASS_CUTOFF_CAP
255 void audiohw_set_bass_cutoff(int val);
256 #endif
258 #ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
260 * Set new treble cut off value.
261 * @param val to set.
262 * NOTE: AUDIOHW_CAPS need to contain
263 * TREBLE_CUTOFF_CAP
265 void audiohw_set_treble_cutoff(int val);
266 #endif
268 void audiohw_set_frequency(int fsel);
270 #ifdef HAVE_RECORDING
273 * Enable recording.
274 * @param source_mic if this is true, we want to record from microphone,
275 * else we want to record FM/LineIn.
277 void audiohw_enable_recording(bool source_mic);
280 * Disable recording.
282 void audiohw_disable_recording(void);
285 * Set gain of recording source.
286 * @param left gain value.
287 * @param right will not be used if recording from micophone (mono).
288 * @param type AUDIO_GAIN_MIC, AUDIO_GAIN_LINEIN.
290 void audiohw_set_recvol(int left, int right, int type);
292 #endif /*HAVE_RECORDING*/
294 #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
297 * Enable or disable recording monitor.
298 * @param enable ture or false.
300 void audiohw_set_monitor(bool enable);
302 #endif /* HAVE_RECORDING || HAVE_FMRADIO_IN */
304 #if CONFIG_CODEC != SWCODEC
306 /* functions which are only used by mas35xx codecs, but are also
307 aviable on SWCODECS through dsp */
310 * Set channel configuration.
311 * @param val new channel value (see enum Channel).
313 void audiohw_set_channel(int val);
316 * Set stereo width.
317 * @param val new stereo width value.
319 void audiohw_set_stereo_width(int val);
321 #endif /* CONFIG_CODEC != SWCODEC */
323 #ifdef HAVE_SPEAKER
325 void audiohw_enable_speaker(bool on);
327 #endif /* HAVE_SPEAKER */
329 #endif /* _AUDIOHW_H_ */