22f6e685623ce79a78de2170800275846c485c27
[kugel-rb.git] / firmware / export / audiohw.h
blob22f6e685623ce79a78de2170800275846c485c27
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
70 #define ONE_DB 10
72 #if !defined(VOLUME_MIN) && !defined(VOLUME_MAX)
73 #warning define for VOLUME_MIN and VOLUME_MAX is missing
74 #define VOLUME_MIN -700
75 #define VOLUME_MAX 0
76 #endif
78 /* volume/balance/treble/bass interdependency main part */
79 #define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN)
82 /* convert caps into defines */
83 #ifdef AUDIOHW_CAPS
84 #if (AUDIOHW_CAPS & TREBLE_CAP)
85 #define AUDIOHW_HAVE_TREBLE
86 #endif
88 #if (AUDIOHW_CAPS & BASS_CAP)
89 #define AUDIOHW_HAVE_BASS
90 #endif
92 #if (AUDIOHW_CAPS & BALANCE_CAP)
93 #define AUDIOHW_HAVE_BALANCE
94 #endif
96 #if (AUDIOHW_CAPS & CLIPPING_CAP)
97 #define AUDIOHW_HAVE_CLIPPING
98 #endif
100 #if (AUDIOHW_CAPS & PRESCALER_CAP)
101 #define AUDIOHW_HAVE_PRESCALER
102 #endif
104 #if (AUDIOHW_CAPS & BASS_CUTOFF_CAP)
105 #define AUDIOHW_HAVE_BASS_CUTOFF
106 #endif
108 #if (AUDIOHW_CAPS & TREBLE_CUTOFF_CAP)
109 #define AUDIOHW_HAVE_TREBLE_CUTOFF
110 #endif
111 #endif /* AUDIOHW_CAPS */
113 enum {
114 SOUND_VOLUME = 0,
115 SOUND_BASS,
116 SOUND_TREBLE,
117 SOUND_BALANCE,
118 SOUND_CHANNELS,
119 SOUND_STEREO_WIDTH,
120 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
121 SOUND_LOUDNESS,
122 SOUND_AVC,
123 SOUND_MDB_STRENGTH,
124 SOUND_MDB_HARMONICS,
125 SOUND_MDB_CENTER,
126 SOUND_MDB_SHAPE,
127 SOUND_MDB_ENABLE,
128 SOUND_SUPERBASS,
129 #endif
130 #if defined(HAVE_RECORDING)
131 SOUND_LEFT_GAIN,
132 SOUND_RIGHT_GAIN,
133 SOUND_MIC_GAIN,
134 #endif
135 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
136 SOUND_BASS_CUTOFF,
137 #endif
138 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
139 SOUND_TREBLE_CUTOFF,
140 #endif
141 SOUND_LAST_SETTING, /* Keep this last */
144 enum Channel {
145 SOUND_CHAN_STEREO,
146 SOUND_CHAN_MONO,
147 SOUND_CHAN_CUSTOM,
148 SOUND_CHAN_MONO_LEFT,
149 SOUND_CHAN_MONO_RIGHT,
150 SOUND_CHAN_KARAOKE,
151 SOUND_CHAN_NUM_MODES,
154 struct sound_settings_info {
155 const char *unit;
156 char numdecimals;
157 char steps;
158 short minval;
159 short maxval;
160 short defaultval;
163 /* This struct is used by every driver to export its min/max/default values for
164 * its audio settings. Keep in mind that the order must be correct! */
165 extern const struct sound_settings_info audiohw_settings[];
167 /* All usable functions implemented by a audio codec drivers. Most of
168 * the function in sound settings are only called, when in audio codecs
169 * .h file suitable defines are added.
173 * Initialize audio codec to a well defined state. Includes SoC-specific
174 * setup.
176 void audiohw_init(void);
179 * Do initial audio codec setup. Usually called from audiohw_init.
181 void audiohw_preinit(void);
184 * Do some stuff (codec related) after audiohw_init that needs to be
185 * delayed such as enabling outputs to prevent popping. This lets
186 * other inits in the system complete in the meantime.
188 void audiohw_postinit(void);
191 * Close audio codec.
193 void audiohw_close(void);
195 #ifdef AUDIOHW_HAVE_CLIPPING
197 * Set new volume value
198 * @param val to set.
199 * NOTE: AUDIOHW_CAPS need to contain
200 * CLIPPING_CAP
202 void audiohw_set_volume(int val);
203 #endif
205 #ifdef AUDIOHW_HAVE_PRESCALER
207 * Set new prescaler value.
208 * @param val to set.
209 * NOTE: AUDIOHW_CAPS need to contain
210 * PRESCALER_CAP
212 void audiohw_set_prescaler(int val);
213 #endif
215 #ifdef AUDIOHW_HAVE_BALANCE
217 * Set new balance value
218 * @param val to set.
219 * NOTE: AUDIOHW_CAPS need to contain
220 * BALANCE_CAP
222 void audiohw_set_balance(int val);
223 #endif
225 #ifdef AUDIOHW_HAVE_TREBLE
227 * Set new treble value.
228 * @param val to set.
229 * NOTE: AUDIOHW_CAPS need to contain
230 * TREBLE_CAP
232 void audiohw_set_treble(int val);
233 #endif
235 #ifdef AUDIOHW_HAVE_BASS
237 * Set new bass value.
238 * @param val to set.
239 * NOTE: AUDIOHW_CAPS need to contain
240 * BASS_CAP
242 void audiohw_set_bass(int val);
243 #endif
245 #ifdef AUDIOHW_HAVE_BASS_CUTOFF
247 * Set new bass cut off value.
248 * @param val to set.
249 * NOTE: AUDIOHW_CAPS need to contain
250 * BASS_CUTOFF_CAP
252 void audiohw_set_bass_cutoff(int val);
253 #endif
255 #ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
257 * Set new treble cut off value.
258 * @param val to set.
259 * NOTE: AUDIOHW_CAPS need to contain
260 * TREBLE_CUTOFF_CAP
262 void audiohw_set_treble_cutoff(int val);
263 #endif
265 void audiohw_set_frequency(int fsel);
267 #ifdef HAVE_RECORDING
270 * Enable recording.
271 * @param source_mic if this is true, we want to record from microphone,
272 * else we want to record FM/LineIn.
274 void audiohw_enable_recording(bool source_mic);
277 * Disable recording.
279 void audiohw_disable_recording(void);
282 * Set gain of recording source.
283 * @param left gain value.
284 * @param right will not be used if recording from micophone (mono).
285 * @param type AUDIO_GAIN_MIC, AUDIO_GAIN_LINEIN.
287 void audiohw_set_recvol(int left, int right, int type);
289 #endif /*HAVE_RECORDING*/
291 #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
294 * Enable or disable recording monitor.
295 * @param enable ture or false.
297 void audiohw_set_monitor(bool enable);
299 #endif /* HAVE_RECORDING || HAVE_FMRADIO_IN */
301 #if CONFIG_CODEC != SWCODEC
303 /* functions which are only used by mas35xx codecs, but are also
304 aviable on SWCODECS through dsp */
307 * Set channel configuration.
308 * @param val new channel value (see enum Channel).
310 void audiohw_set_channel(int val);
313 * Set stereo width.
314 * @param val new stereo width value.
316 void audiohw_set_stereo_width(int val);
318 #endif /* CONFIG_CODEC != SWCODEC */
320 #ifdef HAVE_SPEAKER
322 void audiohw_enable_speaker(bool on);
324 #endif /* HAVE_SPEAKER */
326 #endif /* _AUDIOHW_H_ */