Minor quickscreen and pitchscreen fixes
[kugel-rb.git] / firmware / export / audiohw.h
blob7dba54a8a27338f91a7098de0912b135544a324e
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_WM8751)
40 #include "wm8751.h"
41 #elif defined(HAVE_WM8978)
42 #include "wm8978.h"
43 #elif defined(HAVE_WM8975)
44 #include "wm8975.h"
45 #elif defined(HAVE_WM8985)
46 #include "wm8985.h"
47 #elif defined(HAVE_WM8758)
48 #include "wm8758.h"
49 #elif defined(HAVE_WM8711) || defined(HAVE_WM8721) || \
50 defined(HAVE_WM8731)
51 #include "wm8731.h"
52 #elif defined(HAVE_TLV320)
53 #include "tlv320.h"
54 #elif defined(HAVE_AS3514)
55 #include "as3514.h"
56 #elif defined(HAVE_MAS35XX)
57 #include "mas35xx.h"
58 #elif defined(HAVE_TSC2100)
59 #include "tsc2100.h"
60 #endif
62 /* convert caps into defines */
63 #ifdef AUDIOHW_CAPS
64 #if (AUDIOHW_CAPS & TREBLE_CAP)
65 #define AUDIOHW_HAVE_TREBLE
66 #endif
68 #if (AUDIOHW_CAPS & BASS_CAP)
69 #define AUDIOHW_HAVE_BASS
70 #endif
72 #if (AUDIOHW_CAPS & BALANCE_CAP)
73 #define AUDIOHW_HAVE_BALANCE
74 #endif
76 #if (AUDIOHW_CAPS & CLIPPING_CAP)
77 #define AUDIOHW_HAVE_CLIPPING
78 #endif
80 #if (AUDIOHW_CAPS & PRESCALER_CAP)
81 #define AUDIOHW_HAVE_PRESCALER
82 #endif
84 #if (AUDIOHW_CAPS & BASS_CUTOFF_CAP)
85 #define AUDIOHW_HAVE_BASS_CUTOFF
86 #endif
88 #if (AUDIOHW_CAPS & TREBLE_CUTOFF_CAP)
89 #define AUDIOHW_HAVE_TREBLE_CUTOFF
90 #endif
91 #endif /* AUDIOHW_CAPS */
93 enum {
94 SOUND_VOLUME = 0,
95 SOUND_BASS,
96 SOUND_TREBLE,
97 SOUND_BALANCE,
98 SOUND_CHANNELS,
99 SOUND_STEREO_WIDTH,
100 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
101 SOUND_LOUDNESS,
102 SOUND_AVC,
103 SOUND_MDB_STRENGTH,
104 SOUND_MDB_HARMONICS,
105 SOUND_MDB_CENTER,
106 SOUND_MDB_SHAPE,
107 SOUND_MDB_ENABLE,
108 SOUND_SUPERBASS,
109 #endif
110 #if defined(HAVE_RECORDING)
111 SOUND_LEFT_GAIN,
112 SOUND_RIGHT_GAIN,
113 SOUND_MIC_GAIN,
114 #endif
115 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
116 SOUND_BASS_CUTOFF,
117 #endif
118 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
119 SOUND_TREBLE_CUTOFF,
120 #endif
121 SOUND_LAST_SETTING, /* Keep this last */
124 enum Channel {
125 SOUND_CHAN_STEREO,
126 SOUND_CHAN_MONO,
127 SOUND_CHAN_CUSTOM,
128 SOUND_CHAN_MONO_LEFT,
129 SOUND_CHAN_MONO_RIGHT,
130 SOUND_CHAN_KARAOKE,
131 SOUND_CHAN_NUM_MODES,
134 struct sound_settings_info {
135 const char *unit;
136 char numdecimals;
137 char steps;
138 short minval;
139 short maxval;
140 short defaultval;
143 /* This struct is used by every driver to export its min/max/default values for
144 * its audio settings. Keep in mind that the order must be correct! */
145 extern const struct sound_settings_info audiohw_settings[];
147 /* All usable functions implemented by a audio codec drivers. Most of
148 * the function in sound settings are only called, when in audio codecs
149 * .h file suitable defines are added.
153 * Initialize audio codec to a well defined state. Includes SoC-specific
154 * setup.
156 void audiohw_init(void);
159 * Do initial audio codec setup. Usually called from audiohw_init.
161 void audiohw_preinit(void);
164 * Do some stuff (codec related) after audiohw_init that needs to be
165 * delayed such as enabling outputs to prevent popping. This lets
166 * other inits in the system complete in the meantime.
168 void audiohw_postinit(void);
171 * Close audio codec.
173 void audiohw_close(void);
175 #ifdef AUDIOHW_HAVE_CLIPPING
177 * Set new volume value
178 * @param val to set.
179 * NOTE: AUDIOHW_CAPS need to contain
180 * CLIPPING_CAP
182 void audiohw_set_volume(int val);
183 #endif
185 #ifdef AUDIOHW_HAVE_PRESCALER
187 * Set new prescaler value.
188 * @param val to set.
189 * NOTE: AUDIOHW_CAPS need to contain
190 * PRESCALER_CAP
192 void audiohw_set_prescaler(int val);
193 #endif
195 #ifdef AUDIOHW_HAVE_BALANCE
197 * Set new balance value
198 * @param val to set.
199 * NOTE: AUDIOHW_CAPS need to contain
200 * BALANCE_CAP
202 void audiohw_set_balance(int val);
203 #endif
206 * Mute or enable sound.
207 * @param mute true or false.
209 void audiohw_mute(bool mute);
211 #ifdef AUDIOHW_HAVE_TREBLE
213 * Set new treble value.
214 * @param val to set.
215 * NOTE: AUDIOHW_CAPS need to contain
216 * TREBLE_CAP
218 void audiohw_set_treble(int val);
219 #endif
221 #ifdef AUDIOHW_HAVE_BASS
223 * Set new bass value.
224 * @param val to set.
225 * NOTE: AUDIOHW_CAPS need to contain
226 * BASS_CAP
228 void audiohw_set_bass(int val);
229 #endif
231 #ifdef AUDIOHW_HAVE_BASS_CUTOFF
233 * Set new bass cut off value.
234 * @param val to set.
235 * NOTE: AUDIOHW_CAPS need to contain
236 * BASS_CUTOFF_CAP
238 void audiohw_set_bass_cutoff(int val);
239 #endif
241 #ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
243 * Set new treble cut off value.
244 * @param val to set.
245 * NOTE: AUDIOHW_CAPS need to contain
246 * TREBLE_CUTOFF_CAP
248 void audiohw_set_treble_cutoff(int val);
249 #endif
251 void audiohw_set_frequency(int fsel);
253 #ifdef HAVE_RECORDING
256 * Enable recording.
257 * @param source_mic if this is true, we want to record from microphone,
258 * else we want to record FM/LineIn.
260 void audiohw_enable_recording(bool source_mic);
263 * Disable recording.
265 void audiohw_disable_recording(void);
268 * Set gain of recording source.
269 * @param left gain value.
270 * @param right will not be used if recording from micophone (mono).
271 * @param type AUDIO_GAIN_MIC, AUDIO_GAIN_LINEIN.
273 void audiohw_set_recvol(int left, int right, int type);
276 * Enable or disable recording monitor.
277 * @param enable ture or false.
279 void audiohw_set_monitor(bool enable);
281 #endif /*HAVE_RECORDING*/
284 #if CONFIG_CODEC != SWCODEC
286 /* functions which are only used by mas35xx codecs, but are also
287 aviable on SWCODECS through dsp */
290 * Set channel configuration.
291 * @param val new channel value (see enum Channel).
293 void audiohw_set_channel(int val);
296 * Set stereo width.
297 * @param val new stereo width value.
299 void audiohw_set_stereo_width(int val);
301 #endif /* CONFIG_CODEC != SWCODEC */
303 #endif /* _AUDIOHW_H_ */