Christian Gmeiner | cdbf33a | 2007-05-22 15:56:05 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2007 by Christian Gmeiner |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Christian Gmeiner | cdbf33a | 2007-05-22 15:56:05 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | |
| 22 | #ifndef _AUDIOHW_H_ |
| 23 | #define _AUDIOHW_H_ |
| 24 | |
| 25 | #include "config.h" |
Christian Gmeiner | d1178d2 | 2007-06-13 06:33:40 +0000 | [diff] [blame] | 26 | #include <stdbool.h> |
Christian Gmeiner | cdbf33a | 2007-05-22 15:56:05 +0000 | [diff] [blame] | 27 | |
Christian Gmeiner | 8391526 | 2008-04-28 08:37:18 +0000 | [diff] [blame] | 28 | /* define some audiohw caps */ |
Christian Gmeiner | 59357d4 | 2008-05-16 19:28:45 +0000 | [diff] [blame] | 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) |
Christian Gmeiner | 8391526 | 2008-04-28 08:37:18 +0000 | [diff] [blame] | 36 | |
Marcoen Hirschberg | 10e21d1 | 2007-05-22 20:17:35 +0000 | [diff] [blame] | 37 | #ifdef HAVE_UDA1380 |
| 38 | #include "uda1380.h" |
| 39 | #elif defined(HAVE_WM8751) |
| 40 | #include "wm8751.h" |
Michael Sevakis | 27fac88 | 2008-04-27 10:30:54 +0000 | [diff] [blame] | 41 | #elif defined(HAVE_WM8978) |
| 42 | #include "wm8978.h" |
| 43 | #elif defined(HAVE_WM8975) |
Marcoen Hirschberg | 10e21d1 | 2007-05-22 20:17:35 +0000 | [diff] [blame] | 44 | #include "wm8975.h" |
Rob Purchase | 47ea030 | 2008-01-14 22:04:48 +0000 | [diff] [blame] | 45 | #elif defined(HAVE_WM8985) |
| 46 | #include "wm8985.h" |
Marcoen Hirschberg | 10e21d1 | 2007-05-22 20:17:35 +0000 | [diff] [blame] | 47 | #elif defined(HAVE_WM8758) |
| 48 | #include "wm8758.h" |
Michael Sevakis | 15b7321 | 2007-10-02 07:48:50 +0000 | [diff] [blame] | 49 | #elif defined(HAVE_WM8721) |
| 50 | #include "wm8721.h" |
| 51 | #elif defined(HAVE_WM8731) |
| 52 | #include "wm8731.h" |
Marcoen Hirschberg | 10e21d1 | 2007-05-22 20:17:35 +0000 | [diff] [blame] | 53 | #elif defined(HAVE_TLV320) |
| 54 | #include "tlv320.h" |
| 55 | #elif defined(HAVE_AS3514) |
| 56 | #include "as3514.h" |
| 57 | #elif defined(HAVE_MAS35XX) |
| 58 | #include "mas35xx.h" |
Jonathan Gordon | d20d9dd | 2008-04-27 13:43:05 +0000 | [diff] [blame] | 59 | #elif defined(HAVE_TSC2100) |
| 60 | #include "tsc2100.h" |
Marcoen Hirschberg | 10e21d1 | 2007-05-22 20:17:35 +0000 | [diff] [blame] | 61 | #endif |
| 62 | |
Christian Gmeiner | 8391526 | 2008-04-28 08:37:18 +0000 | [diff] [blame] | 63 | /* convert caps into defines */ |
| 64 | #ifdef AUDIOHW_CAPS |
| 65 | #if (AUDIOHW_CAPS & TREBLE_CAP) |
| 66 | #define AUDIOHW_HAVE_TREBLE |
| 67 | #endif |
| 68 | |
| 69 | #if (AUDIOHW_CAPS & BASS_CAP) |
| 70 | #define AUDIOHW_HAVE_BASS |
| 71 | #endif |
Christian Gmeiner | 785e776 | 2008-05-13 06:19:16 +0000 | [diff] [blame] | 72 | |
| 73 | #if (AUDIOHW_CAPS & BALANCE_CAP) |
| 74 | #define AUDIOHW_HAVE_BALANCE |
| 75 | #endif |
| 76 | |
| 77 | #if (AUDIOHW_CAPS & CLIPPING_CAP) |
| 78 | #define AUDIOHW_HAVE_CLIPPING |
| 79 | #endif |
Christian Gmeiner | 05e8488 | 2008-05-14 21:35:19 +0000 | [diff] [blame] | 80 | |
| 81 | #if (AUDIOHW_CAPS & PRESCALER_CAP) |
| 82 | #define AUDIOHW_HAVE_PRESCALER |
| 83 | #endif |
Christian Gmeiner | 59357d4 | 2008-05-16 19:28:45 +0000 | [diff] [blame] | 84 | |
| 85 | #if (AUDIOHW_CAPS & BASS_CUTOFF_CAP) |
| 86 | #define AUDIOHW_HAVE_BASS_CUTOFF |
| 87 | #endif |
| 88 | |
| 89 | #if (AUDIOHW_CAPS & TREBLE_CUTOFF_CAP) |
| 90 | #define AUDIOHW_HAVE_TREBLE_CUTOFF |
| 91 | #endif |
Christian Gmeiner | 8391526 | 2008-04-28 08:37:18 +0000 | [diff] [blame] | 92 | #endif /* AUDIOHW_CAPS */ |
| 93 | |
Christian Gmeiner | cdbf33a | 2007-05-22 15:56:05 +0000 | [diff] [blame] | 94 | enum { |
| 95 | SOUND_VOLUME = 0, |
| 96 | SOUND_BASS, |
| 97 | SOUND_TREBLE, |
| 98 | SOUND_BALANCE, |
| 99 | SOUND_CHANNELS, |
| 100 | SOUND_STEREO_WIDTH, |
| 101 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) |
| 102 | SOUND_LOUDNESS, |
| 103 | SOUND_AVC, |
| 104 | SOUND_MDB_STRENGTH, |
| 105 | SOUND_MDB_HARMONICS, |
| 106 | SOUND_MDB_CENTER, |
| 107 | SOUND_MDB_SHAPE, |
| 108 | SOUND_MDB_ENABLE, |
| 109 | SOUND_SUPERBASS, |
| 110 | #endif |
Christian Gmeiner | 112656b | 2008-05-16 20:26:20 +0000 | [diff] [blame] | 111 | #if defined(HAVE_RECORDING) |
Christian Gmeiner | cdbf33a | 2007-05-22 15:56:05 +0000 | [diff] [blame] | 112 | SOUND_LEFT_GAIN, |
| 113 | SOUND_RIGHT_GAIN, |
| 114 | SOUND_MIC_GAIN, |
| 115 | #endif |
Christian Gmeiner | 59357d4 | 2008-05-16 19:28:45 +0000 | [diff] [blame] | 116 | #if defined(AUDIOHW_HAVE_BASS_CUTOFF) |
Dan Everton | d7e1f77 | 2007-11-24 07:51:00 +0000 | [diff] [blame] | 117 | SOUND_BASS_CUTOFF, |
Christian Gmeiner | 59357d4 | 2008-05-16 19:28:45 +0000 | [diff] [blame] | 118 | #endif |
| 119 | #if defined(AUDIOHW_HAVE_TREBLE_CUTOFF) |
Dan Everton | d7e1f77 | 2007-11-24 07:51:00 +0000 | [diff] [blame] | 120 | SOUND_TREBLE_CUTOFF, |
| 121 | #endif |
Christian Gmeiner | cdbf33a | 2007-05-22 15:56:05 +0000 | [diff] [blame] | 122 | }; |
| 123 | |
| 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, |
| 132 | }; |
| 133 | |
| 134 | struct sound_settings_info { |
| 135 | const char *unit; |
| 136 | int numdecimals; |
| 137 | int steps; |
| 138 | int minval; |
| 139 | int maxval; |
| 140 | int defaultval; |
| 141 | }; |
| 142 | |
| 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[]; |
| 146 | |
Christian Gmeiner | 23279cd | 2007-06-11 23:39:07 +0000 | [diff] [blame] | 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. |
| 150 | */ |
| 151 | |
Christian Gmeiner | d1178d2 | 2007-06-13 06:33:40 +0000 | [diff] [blame] | 152 | /** |
| 153 | * Initialize audio codec to a well defined state. |
| 154 | */ |
| 155 | void audiohw_init(void); |
| 156 | |
| 157 | /** |
Michael Sevakis | 27fac88 | 2008-04-27 10:30:54 +0000 | [diff] [blame] | 158 | * Do initial audio codec setup. |
| 159 | */ |
| 160 | void audiohw_preinit(void); |
| 161 | |
| 162 | /** |
| 163 | * Do some stuff (codec related) after audiohw_init that needs to be |
| 164 | * delayed such as enabling outputs to prevent popping. This lets |
| 165 | * other inits in the system complete in the meantime. |
Christian Gmeiner | 341188d | 2008-02-12 20:40:53 +0000 | [diff] [blame] | 166 | */ |
| 167 | void audiohw_postinit(void); |
| 168 | |
| 169 | /** |
Christian Gmeiner | d1178d2 | 2007-06-13 06:33:40 +0000 | [diff] [blame] | 170 | * Close audio codec. |
| 171 | */ |
| 172 | void audiohw_close(void); |
| 173 | |
Christian Gmeiner | 785e776 | 2008-05-13 06:19:16 +0000 | [diff] [blame] | 174 | #ifdef AUDIOHW_HAVE_CLIPPING |
| 175 | /** |
| 176 | * Set new volume value |
| 177 | * @param val to set. |
| 178 | * NOTE: AUDIOHW_CAPS need to contain |
| 179 | * CLIPPING_CAP |
| 180 | */ |
| 181 | void audiohw_set_volume(int val); |
| 182 | #endif |
| 183 | |
Christian Gmeiner | 05e8488 | 2008-05-14 21:35:19 +0000 | [diff] [blame] | 184 | #ifdef AUDIOHW_HAVE_PRESCALER |
| 185 | /** |
| 186 | * Set new prescaler value. |
| 187 | * @param val to set. |
| 188 | * NOTE: AUDIOHW_CAPS need to contain |
| 189 | * PRESCALER_CAP |
| 190 | */ |
| 191 | void audiohw_set_prescaler(int val); |
| 192 | #endif |
| 193 | |
Christian Gmeiner | 785e776 | 2008-05-13 06:19:16 +0000 | [diff] [blame] | 194 | #ifdef AUDIOHW_HAVE_BALANCE |
| 195 | /** |
| 196 | * Set new balance value |
| 197 | * @param val to set. |
| 198 | * NOTE: AUDIOHW_CAPS need to contain |
| 199 | * BALANCE_CAP |
| 200 | */ |
| 201 | void audiohw_set_balance(int val); |
| 202 | #endif |
| 203 | |
Christian Gmeiner | d1178d2 | 2007-06-13 06:33:40 +0000 | [diff] [blame] | 204 | /** |
| 205 | * Mute or enable sound. |
Christian Gmeiner | c583f3c | 2007-11-19 15:50:52 +0000 | [diff] [blame] | 206 | * @param mute true or false. |
Christian Gmeiner | d1178d2 | 2007-06-13 06:33:40 +0000 | [diff] [blame] | 207 | */ |
| 208 | void audiohw_mute(bool mute); |
Christian Gmeiner | 23279cd | 2007-06-11 23:39:07 +0000 | [diff] [blame] | 209 | |
Christian Gmeiner | c6e9b8b | 2008-02-09 14:43:36 +0000 | [diff] [blame] | 210 | /** |
| 211 | * Silently en/disable audio output. |
| 212 | * @param enable true or false. |
| 213 | */ |
| 214 | void audiohw_enable_output(bool enable); |
| 215 | |
Christian Gmeiner | 8391526 | 2008-04-28 08:37:18 +0000 | [diff] [blame] | 216 | #ifdef AUDIOHW_HAVE_TREBLE |
| 217 | /** |
| 218 | * Set new treble value. |
| 219 | * @param val to set. |
| 220 | * NOTE: AUDIOHW_CAPS need to contain |
| 221 | * TREBLE_CAP |
| 222 | */ |
| 223 | void audiohw_set_treble(int val); |
| 224 | #endif |
| 225 | |
| 226 | #ifdef AUDIOHW_HAVE_BASS |
| 227 | /** |
| 228 | * Set new bass value. |
| 229 | * @param val to set. |
| 230 | * NOTE: AUDIOHW_CAPS need to contain |
| 231 | * BASS_CAP |
| 232 | */ |
| 233 | void audiohw_set_bass(int val); |
| 234 | #endif |
| 235 | |
Christian Gmeiner | 59357d4 | 2008-05-16 19:28:45 +0000 | [diff] [blame] | 236 | #ifdef AUDIOHW_HAVE_BASS_CUTOFF |
| 237 | /** |
| 238 | * Set new bass cut off value. |
| 239 | * @param val to set. |
| 240 | * NOTE: AUDIOHW_CAPS need to contain |
| 241 | * BASS_CUTOFF_CAP |
| 242 | */ |
| 243 | void audiohw_set_bass_cutoff(int val); |
| 244 | #endif |
| 245 | |
| 246 | #ifdef AUDIOHW_HAVE_TREBLE_CUTOFF |
| 247 | /** |
| 248 | * Set new treble cut off value. |
| 249 | * @param val to set. |
| 250 | * NOTE: AUDIOHW_CAPS need to contain |
| 251 | * TREBLE_CUTOFF_CAP |
| 252 | */ |
| 253 | void audiohw_set_treble_cutoff(int val); |
| 254 | #endif |
| 255 | |
Christian Gmeiner | c583f3c | 2007-11-19 15:50:52 +0000 | [diff] [blame] | 256 | #ifdef HAVE_RECORDING |
| 257 | |
| 258 | /** |
| 259 | * Enable recording. |
| 260 | * @param source_mic if this is true, we want to record from microphone, |
| 261 | * else we want to record FM/LineIn. |
| 262 | */ |
| 263 | void audiohw_enable_recording(bool source_mic); |
| 264 | |
| 265 | /** |
| 266 | * Disable recording. |
| 267 | */ |
| 268 | void audiohw_disable_recording(void); |
| 269 | |
| 270 | /** |
| 271 | * Set gain of recording source. |
| 272 | * @param left gain value. |
| 273 | * @param right will not be used if recording from micophone (mono). |
| 274 | * @param type AUDIO_GAIN_MIC, AUDIO_GAIN_LINEIN. |
| 275 | */ |
| 276 | void audiohw_set_recvol(int left, int right, int type); |
| 277 | |
| 278 | /** |
| 279 | * Enable or disable recording monitor. |
| 280 | * @param enable ture or false. |
| 281 | */ |
| 282 | void audiohw_set_monitor(bool enable); |
| 283 | |
| 284 | #endif /*HAVE_RECORDING*/ |
| 285 | |
Christian Gmeiner | b1806b2 | 2008-04-22 13:43:01 +0000 | [diff] [blame] | 286 | |
| 287 | #if CONFIG_CODEC != SWCODEC |
| 288 | |
| 289 | /* functions which are only used by mas35xx codecs, but are also |
| 290 | aviable on SWCODECS through dsp */ |
| 291 | |
| 292 | /** |
| 293 | * Set channel configuration. |
| 294 | * @param val new channel value (see enum Channel). |
| 295 | */ |
| 296 | void audiohw_set_channel(int val); |
| 297 | |
| 298 | /** |
| 299 | * Set stereo width. |
| 300 | * @param val new stereo width value. |
| 301 | */ |
| 302 | void audiohw_set_stereo_width(int val); |
| 303 | |
| 304 | #endif /* CONFIG_CODEC != SWCODEC */ |
| 305 | |
Christian Gmeiner | cdbf33a | 2007-05-22 15:56:05 +0000 | [diff] [blame] | 306 | #endif /* _AUDIOHW_H_ */ |