MPEGPlayer: Skip to next file when there is a problem with a video file in all-play...
[kugel-rb.git] / firmware / export / audiohw.h
blob930c671c20571ab57a6bf7b1b9299ef321d330fa
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)
36 #define EQ_CAP (1 << 7)
37 #define DEPTH_3D_CAP (1 << 8)
39 #ifdef HAVE_UDA1380
40 #include "uda1380.h"
41 #elif defined(HAVE_UDA1341)
42 #include "uda1341.h"
43 #elif defined(HAVE_WM8750) || defined(HAVE_WM8751)
44 #include "wm8751.h"
45 #elif defined(HAVE_WM8978)
46 #include "wm8978.h"
47 #elif defined(HAVE_WM8975)
48 #include "wm8975.h"
49 #elif defined(HAVE_WM8985)
50 #include "wm8985.h"
51 #elif defined(HAVE_WM8758)
52 #include "wm8758.h"
53 #elif defined(HAVE_WM8711) || defined(HAVE_WM8721) || \
54 defined(HAVE_WM8731)
55 #include "wm8731.h"
56 #elif defined(HAVE_TLV320)
57 #include "tlv320.h"
58 #elif defined(HAVE_AS3514)
59 #include "as3514.h"
60 #elif defined(HAVE_MAS35XX)
61 #include "mas35xx.h"
62 #if defined(HAVE_DAC3550A)
63 #include "dac3550a.h"
64 #endif /* HAVE_DAC3550A */
65 #elif defined(HAVE_TSC2100)
66 #include "tsc2100.h"
67 #elif defined(HAVE_JZ4740_CODEC)
68 #include "jz4740-codec.h"
69 #elif defined(HAVE_AK4537)
70 #include "ak4537.h"
71 #endif
72 #if (CONFIG_PLATFORM & PLATFORM_HOSTED)
73 /* #include <SDL_audio.h> gives errors in other code areas,
74 * we don't really need it here, so don't. but it should maybe be fixed */
75 #ifndef SIMULATOR /* simulator gets values from the target .h files */
76 #define VOLUME_MIN -990
77 #define VOLUME_MAX 0
78 #endif
79 #endif
83 #define ONE_DB 10
85 #if !defined(VOLUME_MIN) && !defined(VOLUME_MAX)
86 #warning define for VOLUME_MIN and VOLUME_MAX is missing
87 #define VOLUME_MIN -700
88 #define VOLUME_MAX 0
89 #endif
91 #ifndef AUDIOHW_NUM_TONE_CONTROLS
92 #define AUDIOHW_NUM_TONE_CONTROLS 0
93 #endif
95 /* volume/balance/treble/bass interdependency main part */
96 #define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN)
99 /* convert caps into defines */
100 #ifdef AUDIOHW_CAPS
101 /* Tone controls */
102 #if (AUDIOHW_CAPS & TREBLE_CAP)
103 #define AUDIOHW_HAVE_TREBLE
104 #endif
106 #if (AUDIOHW_CAPS & BASS_CAP)
107 #define AUDIOHW_HAVE_BASS
108 #endif
110 #if (AUDIOHW_CAPS & BASS_CUTOFF_CAP)
111 #define AUDIOHW_HAVE_BASS_CUTOFF
112 #endif
114 #if (AUDIOHW_CAPS & TREBLE_CUTOFF_CAP)
115 #define AUDIOHW_HAVE_TREBLE_CUTOFF
116 #endif
118 #if (AUDIOHW_CAPS & BALANCE_CAP)
119 #define AUDIOHW_HAVE_BALANCE
120 #endif
122 #if (AUDIOHW_CAPS & CLIPPING_CAP)
123 #define AUDIOHW_HAVE_CLIPPING
124 #endif
126 #if (AUDIOHW_CAPS & PRESCALER_CAP)
127 #define AUDIOHW_HAVE_PRESCALER
128 #endif
130 /* Hardware EQ tone controls */
131 #if (AUDIOHW_CAPS & EQ_CAP)
132 /* A hardware equalizer is present (or perhaps some tone control variation
133 * that is not Bass and/or Treble) */
134 #define AUDIOHW_HAVE_EQ
136 /* Defined band indexes for supported bands */
137 enum
139 /* Band 1 is implied; bands must be contiguous, 1 to N */
140 AUDIOHW_EQ_BAND1 = 0,
141 #define AUDIOHW_HAVE_EQ_BAND1
142 #if (AUDIOHW_EQ_BAND_CAPS & (EQ_CAP << 1))
143 AUDIOHW_EQ_BAND2,
144 #define AUDIOHW_HAVE_EQ_BAND2
145 #if (AUDIOHW_EQ_BAND_CAPS & (EQ_CAP << 2))
146 AUDIOHW_EQ_BAND3,
147 #define AUDIOHW_HAVE_EQ_BAND3
148 #if (AUDIOHW_EQ_BAND_CAPS & (EQ_CAP << 3))
149 AUDIOHW_EQ_BAND4,
150 #define AUDIOHW_HAVE_EQ_BAND4
151 #if (AUDIOHW_EQ_BAND_CAPS & (EQ_CAP << 4))
152 AUDIOHW_EQ_BAND5,
153 #define AUDIOHW_HAVE_EQ_BAND5
154 #endif /* 5 */
155 #endif /* 4 */
156 #endif /* 3 */
157 #endif /* 2 */
158 AUDIOHW_EQ_BAND_NUM, /* Keep last */
161 #ifdef AUDIOHW_EQ_FREQUENCY_CAPS
162 /* One or more bands supports frequency cutoff or center adjustment */
163 #define AUDIOHW_HAVE_EQ_FREQUENCY
164 enum
166 __AUDIOHW_EQ_BAND_FREQUENCY = -1,
167 #if defined(AUDIOHW_HAVE_EQ_BAND1) && \
168 (AUDIOHW_EQ_FREQUENCY_CAPS & (EQ_CAP << 0))
169 AUDIOHW_EQ_BAND1_FREQUENCY,
170 #define AUDIOHW_HAVE_EQ_BAND1_FREQUENCY
171 #endif
172 #if defined(AUDIOHW_HAVE_EQ_BAND2) && \
173 (AUDIOHW_EQ_FREQUENCY_CAPS & (EQ_CAP << 1))
174 AUDIOHW_EQ_BAND2_FREQUENCY,
175 #define AUDIOHW_HAVE_EQ_BAND2_FREQUENCY
176 #endif
177 #if defined(AUDIOHW_HAVE_EQ_BAND3) && \
178 (AUDIOHW_EQ_FREQUENCY_CAPS & (EQ_CAP << 2))
179 AUDIOHW_EQ_BAND3_FREQUENCY,
180 #define AUDIOHW_HAVE_EQ_BAND3_FREQUENCY
181 #endif
182 #if defined(AUDIOHW_HAVE_EQ_BAND4) && \
183 (AUDIOHW_EQ_FREQUENCY_CAPS & (EQ_CAP << 3))
184 AUDIOHW_EQ_BAND4_FREQUENCY,
185 #define AUDIOHW_HAVE_EQ_BAND4_FREQUENCY
186 #endif
187 #if defined(AUDIOHW_HAVE_EQ_BAND5) && \
188 (AUDIOHW_EQ_FREQUENCY_CAPS & (EQ_CAP << 4))
189 AUDIOHW_EQ_BAND5_FREQUENCY,
190 #define AUDIOHW_HAVE_EQ_BAND5_FREQUENCY
191 #endif
192 AUDIOHW_EQ_FREQUENCY_NUM,
194 #endif /* AUDIOHW_EQ_FREQUENCY_CAPS */
196 #ifdef AUDIOHW_EQ_WIDTH_CAPS
197 /* One or more bands supports bandwidth adjustment */
198 #define AUDIOHW_HAVE_EQ_WIDTH
199 enum
201 __AUDIOHW_EQ_BAND_WIDTH = -1,
202 #if defined(AUDIOHW_HAVE_EQ_BAND1) && \
203 (AUDIOHW_EQ_WIDTH_CAPS & (EQ_CAP << 1))
204 AUDIOHW_EQ_BAND2_WIDTH,
205 #define AUDIOHW_HAVE_EQ_BAND2_WIDTH
206 #endif
207 #if defined(AUDIOHW_HAVE_EQ_BAND2) && \
208 (AUDIOHW_EQ_WIDTH_CAPS & (EQ_CAP << 2))
209 AUDIOHW_EQ_BAND3_WIDTH,
210 #define AUDIOHW_HAVE_EQ_BAND3_WIDTH
211 #endif
212 #if defined(AUDIOHW_HAVE_EQ_BAND3) && \
213 (AUDIOHW_EQ_WIDTH_CAPS & (EQ_CAP << 3))
214 AUDIOHW_EQ_BAND4_WIDTH,
215 #define AUDIOHW_HAVE_EQ_BAND4_WIDTH
216 #endif
217 AUDIOHW_EQ_WIDTH_NUM, /* Keep last */
219 #endif /* AUDIOHW_EQ_WIDTH_CAPS */
221 /* Types and number of settings types (gain, frequency, width) */
222 enum AUDIOHW_EQ_SETTINGS
224 AUDIOHW_EQ_GAIN = 0,
225 #ifdef AUDIOHW_HAVE_EQ_FREQUENCY
226 AUDIOHW_EQ_FREQUENCY,
227 #endif
228 #ifdef AUDIOHW_HAVE_EQ_WIDTH
229 AUDIOHW_EQ_WIDTH,
230 #endif
231 AUDIOHW_EQ_SETTING_NUM
234 #endif /* (AUDIOHW_CAPS & EQ_CAP) */
236 #if (AUDIOHW_CAPS & DEPTH_3D_CAP)
237 #define AUDIOHW_HAVE_DEPTH_3D
238 #endif
239 #else
240 #if defined (HAVE_SW_TONE_CONTROLS)
241 /* Needed for proper sound support */
242 #define AUDIOHW_HAVE_BASS
243 #define AUDIOHW_HAVE_TREBLE
244 #endif
245 #endif /* AUDIOHW_CAPS */
247 enum {
248 SOUND_VOLUME = 0,
249 /* Tone control */
250 #if defined(AUDIOHW_HAVE_BASS)
251 SOUND_BASS,
252 #endif
253 #if defined(AUDIOHW_HAVE_TREBLE)
254 SOUND_TREBLE,
255 #endif
256 SOUND_BALANCE,
257 SOUND_CHANNELS,
258 SOUND_STEREO_WIDTH,
259 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
260 SOUND_LOUDNESS,
261 SOUND_AVC,
262 SOUND_MDB_STRENGTH,
263 SOUND_MDB_HARMONICS,
264 SOUND_MDB_CENTER,
265 SOUND_MDB_SHAPE,
266 SOUND_MDB_ENABLE,
267 SOUND_SUPERBASS,
268 #endif
269 #if defined(HAVE_RECORDING)
270 SOUND_LEFT_GAIN,
271 SOUND_RIGHT_GAIN,
272 SOUND_MIC_GAIN,
273 #endif
274 /* Bass and treble tone controls */
275 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
276 SOUND_BASS_CUTOFF,
277 #endif
278 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
279 SOUND_TREBLE_CUTOFF,
280 #endif
281 /* 3D effect */
282 #if defined(AUDIOHW_HAVE_DEPTH_3D)
283 SOUND_DEPTH_3D,
284 #endif
285 /* Hardware EQ tone controls */
286 /* Band gains */
287 #if defined(AUDIOHW_HAVE_EQ)
288 /* Band 1 implied */
289 SOUND_EQ_BAND1_GAIN,
290 #if defined(AUDIOHW_HAVE_EQ_BAND2)
291 SOUND_EQ_BAND2_GAIN,
292 #endif
293 #if defined(AUDIOHW_HAVE_EQ_BAND3)
294 SOUND_EQ_BAND3_GAIN,
295 #endif
296 #if defined(AUDIOHW_HAVE_EQ_BAND4)
297 SOUND_EQ_BAND4_GAIN,
298 #endif
299 #if defined(AUDIOHW_HAVE_EQ_BAND5)
300 SOUND_EQ_BAND5_GAIN,
301 #endif
302 /* Band frequencies */
303 #if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
304 SOUND_EQ_BAND1_FREQUENCY,
305 #endif
306 #if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
307 SOUND_EQ_BAND2_FREQUENCY,
308 #endif
309 #if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
310 SOUND_EQ_BAND3_FREQUENCY,
311 #endif
312 #if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
313 SOUND_EQ_BAND4_FREQUENCY,
314 #endif
315 #if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
316 SOUND_EQ_BAND5_FREQUENCY,
317 #endif
318 /* Band widths */
319 #if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
320 SOUND_EQ_BAND2_WIDTH,
321 #endif
322 #if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
323 SOUND_EQ_BAND3_WIDTH,
324 #endif
325 #if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
326 SOUND_EQ_BAND4_WIDTH,
327 #endif
328 #endif /* AUDIOHW_HAVE_EQ */
329 SOUND_LAST_SETTING, /* Keep this last */
332 enum Channel {
333 SOUND_CHAN_STEREO,
334 SOUND_CHAN_MONO,
335 SOUND_CHAN_CUSTOM,
336 SOUND_CHAN_MONO_LEFT,
337 SOUND_CHAN_MONO_RIGHT,
338 SOUND_CHAN_KARAOKE,
339 SOUND_CHAN_NUM_MODES,
342 struct sound_settings_info {
343 const char *unit;
344 char numdecimals;
345 char steps;
346 short minval;
347 short maxval;
348 short defaultval;
351 /* This struct is used by every driver to export its min/max/default values for
352 * its audio settings. Keep in mind that the order must be correct! */
353 extern const struct sound_settings_info audiohw_settings[];
355 /* All usable functions implemented by a audio codec drivers. Most of
356 * the function in sound settings are only called, when in audio codecs
357 * .h file suitable defines are added.
361 * Initialize audio codec to a well defined state. Includes SoC-specific
362 * setup.
364 void audiohw_init(void);
367 * Do initial audio codec setup. Usually called from audiohw_init.
369 void audiohw_preinit(void);
372 * Do some stuff (codec related) after audiohw_init that needs to be
373 * delayed such as enabling outputs to prevent popping. This lets
374 * other inits in the system complete in the meantime.
376 void audiohw_postinit(void);
379 * Close audio codec.
381 void audiohw_close(void);
383 #if defined(AUDIOHW_HAVE_CLIPPING) || defined(HAVE_SDL_AUDIO) || defined(ANDROID)
385 * Set new volume value
386 * @param val to set.
387 * NOTE: AUDIOHW_CAPS need to contain
388 * CLIPPING_CAP
390 void audiohw_set_volume(int val);
391 #endif
393 #ifdef AUDIOHW_HAVE_PRESCALER
395 * Set new prescaler value.
396 * @param val to set.
397 * NOTE: AUDIOHW_CAPS need to contain
398 * PRESCALER_CAP
400 void audiohw_set_prescaler(int val);
401 #endif
403 #ifdef AUDIOHW_HAVE_BALANCE
405 * Set new balance value
406 * @param val to set.
407 * NOTE: AUDIOHW_CAPS need to contain
408 * BALANCE_CAP
410 void audiohw_set_balance(int val);
411 #endif
413 #ifdef AUDIOHW_HAVE_TREBLE
415 * Set new treble value.
416 * @param val to set.
417 * NOTE: AUDIOHW_CAPS need to contain
418 * TREBLE_CAP
420 void audiohw_set_treble(int val);
421 #endif
423 #ifdef AUDIOHW_HAVE_BASS
425 * Set new bass value.
426 * @param val to set.
427 * NOTE: AUDIOHW_CAPS need to contain
428 * BASS_CAP
430 void audiohw_set_bass(int val);
431 #endif
433 #ifdef AUDIOHW_HAVE_BASS_CUTOFF
435 * Set new bass cut off value.
436 * @param val to set.
437 * NOTE: AUDIOHW_CAPS need to contain
438 * BASS_CUTOFF_CAP
440 void audiohw_set_bass_cutoff(int val);
441 #endif
443 #ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
445 * Set new treble cut off value.
446 * @param val to set.
447 * NOTE: AUDIOHW_CAPS need to contain
448 * TREBLE_CUTOFF_CAP
450 void audiohw_set_treble_cutoff(int val);
451 #endif
453 #ifdef AUDIOHW_HAVE_EQ
455 * Set new band gain value.
456 * @param band index to which val is set
457 * @param val to set.
458 * NOTE: AUDIOHW_CAPS need to contain
459 * EQ_CAP
461 * AUDIOHW_EQ_BAND_CAPS must be defined as a bitmask
462 * of EQ_CAP each shifted by the zero-based band number
463 * for each band. Bands 1 to N are indexed 0 to N-1.
465 void audiohw_set_eq_band_gain(unsigned int band, int val);
466 #endif
468 #ifdef AUDIOHW_HAVE_EQ_FREQUENCY
470 * Set new band cutoff or center frequency value.
471 * @param band index to which val is set
472 * @param val to set.
473 * NOTE: AUDIOHW_CAPS need to contain
474 * EQ_CAP
476 * AUDIOHW_EQ_FREQUENCY_CAPS must be defined as a bitmask
477 * of EQ_CAP each shifted by the zero-based band number
478 * for each band that supports frequency adjustment.
479 * Bands 1 to N are indexed 0 to N-1.
481 void audiohw_set_eq_band_frequency(unsigned int band, int val);
482 #endif
484 #ifdef AUDIOHW_HAVE_EQ_WIDTH
486 * Set new band cutoff or center frequency value.
487 * @param band index to which val is set
488 * @param val to set.
489 * NOTE: AUDIOHW_CAPS need to contain
490 * EQ_CAP
492 * AUDIOHW_EQ_WIDTH_CAPS must be defined as a bitmask
493 * of EQ_CAP each shifted by the zero-based band number
494 * for each band that supports width adjustment.
495 * Bands 1 to N are indexed 0 to N-1.
497 void audiohw_set_eq_band_width(unsigned int band, int val);
498 #endif
500 #ifdef AUDIOHW_HAVE_DEPTH_3D
502 * Set new 3-d enhancement (stereo expansion) effect value.
503 * @param val to set.
504 * NOTE: AUDIOHW_CAPS need to contain
505 * DEPTH_3D_CAP
507 void audiohw_set_depth_3d(int val);
508 #endif
511 void audiohw_set_frequency(int fsel);
513 #ifdef HAVE_RECORDING
516 * Enable recording.
517 * @param source_mic if this is true, we want to record from microphone,
518 * else we want to record FM/LineIn.
520 void audiohw_enable_recording(bool source_mic);
523 * Disable recording.
525 void audiohw_disable_recording(void);
528 * Set gain of recording source.
529 * @param left gain value.
530 * @param right will not be used if recording from micophone (mono).
531 * @param type AUDIO_GAIN_MIC, AUDIO_GAIN_LINEIN.
533 void audiohw_set_recvol(int left, int right, int type);
535 #endif /* HAVE_RECORDING */
537 #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
539 * Enable or disable recording monitor.
540 * @param enable true or false.
542 void audiohw_set_monitor(bool enable);
543 #endif
547 #if CONFIG_CODEC != SWCODEC
549 /* functions which are only used by mas35xx codecs, but are also
550 aviable on SWCODECS through dsp */
553 * Set channel configuration.
554 * @param val new channel value (see enum Channel).
556 void audiohw_set_channel(int val);
559 * Set stereo width.
560 * @param val new stereo width value.
562 void audiohw_set_stereo_width(int val);
564 #endif /* CONFIG_CODEC != SWCODEC */
566 #ifdef HAVE_SPEAKER
568 void audiohw_enable_speaker(bool on);
570 #endif /* HAVE_SPEAKER */
572 #endif /* _AUDIOHW_H_ */