1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 ****************************************************************************/
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)
41 #elif defined(HAVE_UDA1341)
43 #elif defined(HAVE_WM8750) || defined(HAVE_WM8751)
45 #elif defined(HAVE_WM8978)
47 #elif defined(HAVE_WM8975)
49 #elif defined(HAVE_WM8985)
51 #elif defined(HAVE_WM8758)
53 #elif defined(HAVE_WM8711) || defined(HAVE_WM8721) || \
56 #elif defined(HAVE_TLV320)
58 #elif defined(HAVE_AS3514)
60 #elif defined(HAVE_MAS35XX)
62 #elif defined(HAVE_TSC2100)
64 #elif defined(HAVE_JZ4740_CODEC)
65 #include "jz4740-codec.h"
66 #elif defined(HAVE_AK4537)
74 #if !defined(VOLUME_MIN) && !defined(VOLUME_MAX)
75 #warning define for VOLUME_MIN and VOLUME_MAX is missing
76 #define VOLUME_MIN -700
80 #ifndef AUDIOHW_NUM_TONE_CONTROLS
81 #define AUDIOHW_NUM_TONE_CONTROLS 0
84 /* volume/balance/treble/bass interdependency main part */
85 #define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN)
88 /* convert caps into defines */
91 #if (AUDIOHW_CAPS & TREBLE_CAP)
92 #define AUDIOHW_HAVE_TREBLE
95 #if (AUDIOHW_CAPS & BASS_CAP)
96 #define AUDIOHW_HAVE_BASS
99 #if (AUDIOHW_CAPS & BASS_CUTOFF_CAP)
100 #define AUDIOHW_HAVE_BASS_CUTOFF
103 #if (AUDIOHW_CAPS & TREBLE_CUTOFF_CAP)
104 #define AUDIOHW_HAVE_TREBLE_CUTOFF
107 #if (AUDIOHW_CAPS & BALANCE_CAP)
108 #define AUDIOHW_HAVE_BALANCE
111 #if (AUDIOHW_CAPS & CLIPPING_CAP)
112 #define AUDIOHW_HAVE_CLIPPING
115 #if (AUDIOHW_CAPS & PRESCALER_CAP)
116 #define AUDIOHW_HAVE_PRESCALER
119 /* Hardware EQ tone controls */
120 #if (AUDIOHW_CAPS & EQ_CAP)
121 /* A hardware equalizer is present (or perhaps some tone control variation
122 * that is not Bass and/or Treble) */
123 #define AUDIOHW_HAVE_EQ
125 /* Defined band indexes for supported bands */
128 /* Band 1 is implied; bands must be contiguous, 1 to N */
129 AUDIOHW_EQ_BAND1
= 0,
130 #define AUDIOHW_HAVE_EQ_BAND1
131 #if (AUDIOHW_EQ_BAND_CAPS & (EQ_CAP << 1))
133 #define AUDIOHW_HAVE_EQ_BAND2
134 #if (AUDIOHW_EQ_BAND_CAPS & (EQ_CAP << 2))
136 #define AUDIOHW_HAVE_EQ_BAND3
137 #if (AUDIOHW_EQ_BAND_CAPS & (EQ_CAP << 3))
139 #define AUDIOHW_HAVE_EQ_BAND4
140 #if (AUDIOHW_EQ_BAND_CAPS & (EQ_CAP << 4))
142 #define AUDIOHW_HAVE_EQ_BAND5
147 AUDIOHW_EQ_BAND_NUM
, /* Keep last */
150 #ifdef AUDIOHW_EQ_FREQUENCY_CAPS
151 /* One or more bands supports frequency cutoff or center adjustment */
152 #define AUDIOHW_HAVE_EQ_FREQUENCY
155 __AUDIOHW_EQ_BAND_FREQUENCY
= -1,
156 #if defined(AUDIOHW_HAVE_EQ_BAND1) && \
157 (AUDIOHW_EQ_FREQUENCY_CAPS & (EQ_CAP << 0))
158 AUDIOHW_EQ_BAND1_FREQUENCY
,
159 #define AUDIOHW_HAVE_EQ_BAND1_FREQUENCY
161 #if defined(AUDIOHW_HAVE_EQ_BAND2) && \
162 (AUDIOHW_EQ_FREQUENCY_CAPS & (EQ_CAP << 1))
163 AUDIOHW_EQ_BAND2_FREQUENCY
,
164 #define AUDIOHW_HAVE_EQ_BAND2_FREQUENCY
166 #if defined(AUDIOHW_HAVE_EQ_BAND3) && \
167 (AUDIOHW_EQ_FREQUENCY_CAPS & (EQ_CAP << 2))
168 AUDIOHW_EQ_BAND3_FREQUENCY
,
169 #define AUDIOHW_HAVE_EQ_BAND3_FREQUENCY
171 #if defined(AUDIOHW_HAVE_EQ_BAND4) && \
172 (AUDIOHW_EQ_FREQUENCY_CAPS & (EQ_CAP << 3))
173 AUDIOHW_EQ_BAND4_FREQUENCY
,
174 #define AUDIOHW_HAVE_EQ_BAND4_FREQUENCY
176 #if defined(AUDIOHW_HAVE_EQ_BAND5) && \
177 (AUDIOHW_EQ_FREQUENCY_CAPS & (EQ_CAP << 4))
178 AUDIOHW_EQ_BAND5_FREQUENCY
,
179 #define AUDIOHW_HAVE_EQ_BAND5_FREQUENCY
181 AUDIOHW_EQ_FREQUENCY_NUM
,
183 #endif /* AUDIOHW_EQ_FREQUENCY_CAPS */
185 #ifdef AUDIOHW_EQ_WIDTH_CAPS
186 /* One or more bands supports bandwidth adjustment */
187 #define AUDIOHW_HAVE_EQ_WIDTH
190 __AUDIOHW_EQ_BAND_WIDTH
= -1,
191 #if defined(AUDIOHW_HAVE_EQ_BAND1) && \
192 (AUDIOHW_EQ_WIDTH_CAPS & (EQ_CAP << 1))
193 AUDIOHW_EQ_BAND2_WIDTH
,
194 #define AUDIOHW_HAVE_EQ_BAND2_WIDTH
196 #if defined(AUDIOHW_HAVE_EQ_BAND2) && \
197 (AUDIOHW_EQ_WIDTH_CAPS & (EQ_CAP << 2))
198 AUDIOHW_EQ_BAND3_WIDTH
,
199 #define AUDIOHW_HAVE_EQ_BAND3_WIDTH
201 #if defined(AUDIOHW_HAVE_EQ_BAND3) && \
202 (AUDIOHW_EQ_WIDTH_CAPS & (EQ_CAP << 3))
203 AUDIOHW_EQ_BAND4_WIDTH
,
204 #define AUDIOHW_HAVE_EQ_BAND4_WIDTH
206 AUDIOHW_EQ_WIDTH_NUM
, /* Keep last */
208 #endif /* AUDIOHW_EQ_WIDTH_CAPS */
210 /* Types and number of settings types (gain, frequency, width) */
211 enum AUDIOHW_EQ_SETTINGS
214 #ifdef AUDIOHW_HAVE_EQ_FREQUENCY
215 AUDIOHW_EQ_FREQUENCY
,
217 #ifdef AUDIOHW_HAVE_EQ_WIDTH
220 AUDIOHW_EQ_SETTING_NUM
223 #endif /* (AUDIOHW_CAPS & EQ_CAP) */
225 #if (AUDIOHW_CAPS & DEPTH_3D_CAP)
226 #define AUDIOHW_HAVE_DEPTH_3D
229 #if defined (HAVE_SW_TONE_CONTROLS)
230 /* Needed for proper sound support */
231 #define AUDIOHW_HAVE_BASS
232 #define AUDIOHW_HAVE_TREBLE
234 #endif /* AUDIOHW_CAPS */
239 #if defined(AUDIOHW_HAVE_BASS)
242 #if defined(AUDIOHW_HAVE_TREBLE)
248 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
258 #if defined(HAVE_RECORDING)
263 /* Bass and treble tone controls */
264 #if defined(AUDIOHW_HAVE_BASS_CUTOFF)
267 #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF)
271 #if defined(AUDIOHW_HAVE_DEPTH_3D)
274 /* Hardware EQ tone controls */
276 #if defined(AUDIOHW_HAVE_EQ)
279 #if defined(AUDIOHW_HAVE_EQ_BAND2)
282 #if defined(AUDIOHW_HAVE_EQ_BAND3)
285 #if defined(AUDIOHW_HAVE_EQ_BAND4)
288 #if defined(AUDIOHW_HAVE_EQ_BAND5)
291 /* Band frequencies */
292 #if defined(AUDIOHW_HAVE_EQ_BAND1_FREQUENCY)
293 SOUND_EQ_BAND1_FREQUENCY
,
295 #if defined(AUDIOHW_HAVE_EQ_BAND2_FREQUENCY)
296 SOUND_EQ_BAND2_FREQUENCY
,
298 #if defined(AUDIOHW_HAVE_EQ_BAND3_FREQUENCY)
299 SOUND_EQ_BAND3_FREQUENCY
,
301 #if defined(AUDIOHW_HAVE_EQ_BAND4_FREQUENCY)
302 SOUND_EQ_BAND4_FREQUENCY
,
304 #if defined(AUDIOHW_HAVE_EQ_BAND5_FREQUENCY)
305 SOUND_EQ_BAND5_FREQUENCY
,
308 #if defined(AUDIOHW_HAVE_EQ_BAND2_WIDTH)
309 SOUND_EQ_BAND2_WIDTH
,
311 #if defined(AUDIOHW_HAVE_EQ_BAND3_WIDTH)
312 SOUND_EQ_BAND3_WIDTH
,
314 #if defined(AUDIOHW_HAVE_EQ_BAND4_WIDTH)
315 SOUND_EQ_BAND4_WIDTH
,
317 #endif /* AUDIOHW_HAVE_EQ */
318 SOUND_LAST_SETTING
, /* Keep this last */
325 SOUND_CHAN_MONO_LEFT
,
326 SOUND_CHAN_MONO_RIGHT
,
328 SOUND_CHAN_NUM_MODES
,
331 struct sound_settings_info
{
340 /* This struct is used by every driver to export its min/max/default values for
341 * its audio settings. Keep in mind that the order must be correct! */
342 extern const struct sound_settings_info audiohw_settings
[];
344 /* All usable functions implemented by a audio codec drivers. Most of
345 * the function in sound settings are only called, when in audio codecs
346 * .h file suitable defines are added.
350 * Initialize audio codec to a well defined state. Includes SoC-specific
353 void audiohw_init(void);
356 * Do initial audio codec setup. Usually called from audiohw_init.
358 void audiohw_preinit(void);
361 * Do some stuff (codec related) after audiohw_init that needs to be
362 * delayed such as enabling outputs to prevent popping. This lets
363 * other inits in the system complete in the meantime.
365 void audiohw_postinit(void);
370 void audiohw_close(void);
372 #ifdef AUDIOHW_HAVE_CLIPPING
374 * Set new volume value
376 * NOTE: AUDIOHW_CAPS need to contain
379 void audiohw_set_volume(int val
);
382 #ifdef AUDIOHW_HAVE_PRESCALER
384 * Set new prescaler value.
386 * NOTE: AUDIOHW_CAPS need to contain
389 void audiohw_set_prescaler(int val
);
392 #ifdef AUDIOHW_HAVE_BALANCE
394 * Set new balance value
396 * NOTE: AUDIOHW_CAPS need to contain
399 void audiohw_set_balance(int val
);
402 #ifdef AUDIOHW_HAVE_TREBLE
404 * Set new treble value.
406 * NOTE: AUDIOHW_CAPS need to contain
409 void audiohw_set_treble(int val
);
412 #ifdef AUDIOHW_HAVE_BASS
414 * Set new bass value.
416 * NOTE: AUDIOHW_CAPS need to contain
419 void audiohw_set_bass(int val
);
422 #ifdef AUDIOHW_HAVE_BASS_CUTOFF
424 * Set new bass cut off value.
426 * NOTE: AUDIOHW_CAPS need to contain
429 void audiohw_set_bass_cutoff(int val
);
432 #ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
434 * Set new treble cut off value.
436 * NOTE: AUDIOHW_CAPS need to contain
439 void audiohw_set_treble_cutoff(int val
);
442 #ifdef AUDIOHW_HAVE_EQ
444 * Set new band gain value.
445 * @param band index to which val is set
447 * NOTE: AUDIOHW_CAPS need to contain
450 * AUDIOHW_EQ_BAND_CAPS must be defined as a bitmask
451 * of EQ_CAP each shifted by the zero-based band number
452 * for each band. Bands 1 to N are indexed 0 to N-1.
454 void audiohw_set_eq_band_gain(unsigned int band
, int val
);
457 #ifdef AUDIOHW_HAVE_EQ_FREQUENCY
459 * Set new band cutoff or center frequency value.
460 * @param band index to which val is set
462 * NOTE: AUDIOHW_CAPS need to contain
465 * AUDIOHW_EQ_FREQUENCY_CAPS must be defined as a bitmask
466 * of EQ_CAP each shifted by the zero-based band number
467 * for each band that supports frequency adjustment.
468 * Bands 1 to N are indexed 0 to N-1.
470 void audiohw_set_eq_band_frequency(unsigned int band
, int val
);
473 #ifdef AUDIOHW_HAVE_EQ_WIDTH
475 * Set new band cutoff or center frequency value.
476 * @param band index to which val is set
478 * NOTE: AUDIOHW_CAPS need to contain
481 * AUDIOHW_EQ_WIDTH_CAPS must be defined as a bitmask
482 * of EQ_CAP each shifted by the zero-based band number
483 * for each band that supports width adjustment.
484 * Bands 1 to N are indexed 0 to N-1.
486 void audiohw_set_eq_band_width(unsigned int band
, int val
);
489 #ifdef AUDIOHW_HAVE_DEPTH_3D
491 * Set new 3-d enhancement (stereo expansion) effect value.
493 * NOTE: AUDIOHW_CAPS need to contain
496 void audiohw_set_depth_3d(int val
);
500 void audiohw_set_frequency(int fsel
);
502 #ifdef HAVE_RECORDING
506 * @param source_mic if this is true, we want to record from microphone,
507 * else we want to record FM/LineIn.
509 void audiohw_enable_recording(bool source_mic
);
514 void audiohw_disable_recording(void);
517 * Set gain of recording source.
518 * @param left gain value.
519 * @param right will not be used if recording from micophone (mono).
520 * @param type AUDIO_GAIN_MIC, AUDIO_GAIN_LINEIN.
522 void audiohw_set_recvol(int left
, int right
, int type
);
524 #endif /*HAVE_RECORDING*/
526 #if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
529 * Enable or disable recording monitor.
530 * @param enable ture or false.
532 void audiohw_set_monitor(bool enable
);
534 #endif /* HAVE_RECORDING || HAVE_FMRADIO_IN */
536 #if CONFIG_CODEC != SWCODEC
538 /* functions which are only used by mas35xx codecs, but are also
539 aviable on SWCODECS through dsp */
542 * Set channel configuration.
543 * @param val new channel value (see enum Channel).
545 void audiohw_set_channel(int val
);
549 * @param val new stereo width value.
551 void audiohw_set_stereo_width(int val
);
553 #endif /* CONFIG_CODEC != SWCODEC */
557 void audiohw_enable_speaker(bool on
);
559 #endif /* HAVE_SPEAKER */
561 #endif /* _AUDIOHW_H_ */