| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | *  linux/include/linux/l3/uda1341.h | 
|  | 3 | * | 
|  | 4 | * Philips UDA1341 mixer device driver for ALSA | 
|  | 5 | * | 
|  | 6 | * Copyright (c) 2002 Tomas Kasparek <tomas.kasparek@seznam.cz> | 
|  | 7 | * | 
|  | 8 | * This program is free software; you can redistribute it and/or | 
|  | 9 | * modify it under the terms of the GNU General Public License. | 
|  | 10 | * | 
|  | 11 | * History: | 
|  | 12 | * | 
|  | 13 | * 2002-03-13 Tomas Kasparek Initial release - based on uda1341.h from OSS | 
|  | 14 | * 2002-03-30 Tomas Kasparek Proc filesystem support, complete mixer and DSP | 
|  | 15 | *                           features support | 
|  | 16 | */ | 
|  | 17 |  | 
|  | 18 | /* $Id: uda1341.h,v 1.6 2004/05/03 17:36:50 tiwai Exp $ */ | 
|  | 19 |  | 
|  | 20 | #define UDA1341_ALSA_NAME "snd-uda1341" | 
|  | 21 |  | 
|  | 22 | /* | 
|  | 23 | * Default rate set after inicialization | 
|  | 24 | */ | 
|  | 25 | #define AUDIO_RATE_DEFAULT	44100 | 
|  | 26 |  | 
|  | 27 | /* | 
|  | 28 | * UDA1341 L3 address and command types | 
|  | 29 | */ | 
|  | 30 | #define UDA1341_L3ADDR		5 | 
|  | 31 | #define UDA1341_DATA0		(UDA1341_L3ADDR << 2 | 0) | 
|  | 32 | #define UDA1341_DATA1		(UDA1341_L3ADDR << 2 | 1) | 
|  | 33 | #define UDA1341_STATUS		(UDA1341_L3ADDR << 2 | 2) | 
|  | 34 |  | 
|  | 35 | enum uda1341_onoff { | 
|  | 36 | OFF=0, | 
|  | 37 | ON, | 
|  | 38 | }; | 
|  | 39 |  | 
|  | 40 | const char *onoff_names[] = { | 
|  | 41 | "Off", | 
|  | 42 | "On", | 
|  | 43 | }; | 
|  | 44 |  | 
|  | 45 | enum uda1341_format { | 
|  | 46 | I2S=0, | 
|  | 47 | LSB16, | 
|  | 48 | LSB18, | 
|  | 49 | LSB20, | 
|  | 50 | MSB, | 
|  | 51 | LSB16MSB, | 
|  | 52 | LSB18MSB, | 
|  | 53 | LSB20MSB, | 
|  | 54 | }; | 
|  | 55 |  | 
|  | 56 | const char *format_names[] = { | 
|  | 57 | "I2S-bus", | 
|  | 58 | "LSB 16bits", | 
|  | 59 | "LSB 18bits", | 
|  | 60 | "LSB 20bits", | 
|  | 61 | "MSB", | 
|  | 62 | "in LSB 16bits/out MSB", | 
|  | 63 | "in LSB 18bits/out MSB", | 
|  | 64 | "in LSB 20bits/out MSB", | 
|  | 65 | }; | 
|  | 66 |  | 
|  | 67 | enum uda1341_fs { | 
|  | 68 | F512=0, | 
|  | 69 | F384, | 
|  | 70 | F256, | 
|  | 71 | Funused, | 
|  | 72 | }; | 
|  | 73 |  | 
|  | 74 | const char *fs_names[] = { | 
|  | 75 | "512*fs", | 
|  | 76 | "384*fs", | 
|  | 77 | "256*fs", | 
|  | 78 | "Unused - bad value!", | 
|  | 79 | }; | 
|  | 80 |  | 
|  | 81 | enum uda1341_peak { | 
|  | 82 | BEFORE=0, | 
|  | 83 | AFTER, | 
|  | 84 | }; | 
|  | 85 |  | 
|  | 86 | const char *peak_names[] = { | 
|  | 87 | "before", | 
|  | 88 | "after", | 
|  | 89 | }; | 
|  | 90 |  | 
|  | 91 | enum uda1341_filter { | 
|  | 92 | FLAT=0, | 
|  | 93 | MIN, | 
|  | 94 | MIN2, | 
|  | 95 | MAX, | 
|  | 96 | }; | 
|  | 97 |  | 
|  | 98 | const char *filter_names[] = { | 
|  | 99 | "flat", | 
|  | 100 | "min", | 
|  | 101 | "min", | 
|  | 102 | "max", | 
|  | 103 | }; | 
|  | 104 |  | 
|  | 105 | const char*bass_values[][16] = { | 
|  | 106 | {"0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", | 
|  | 107 | "0 dB", "0 dB", "0 dB", "0 dB", "undefined", }, //flat | 
|  | 108 | {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "18 dB", | 
|  | 109 | "18 dB", "18 dB", "18 dB", "18 dB", "undefined",}, // min | 
|  | 110 | {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "18 dB", | 
|  | 111 | "18 dB", "18 dB", "18 dB", "18 dB", "undefined",}, // min | 
|  | 112 | {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "20 dB", | 
|  | 113 | "22 dB", "24 dB", "24 dB", "24 dB", "undefined",}, // max | 
|  | 114 | }; | 
|  | 115 |  | 
|  | 116 | enum uda1341_mixer { | 
|  | 117 | DOUBLE, | 
|  | 118 | LINE, | 
|  | 119 | MIC, | 
|  | 120 | MIXER, | 
|  | 121 | }; | 
|  | 122 |  | 
|  | 123 | const char *mixer_names[] = { | 
|  | 124 | "double differential", | 
|  | 125 | "input channel 1 (line in)", | 
|  | 126 | "input channel 2 (microphone)", | 
|  | 127 | "digital mixer", | 
|  | 128 | }; | 
|  | 129 |  | 
|  | 130 | enum uda1341_deemp { | 
|  | 131 | NONE, | 
|  | 132 | D32, | 
|  | 133 | D44, | 
|  | 134 | D48, | 
|  | 135 | }; | 
|  | 136 |  | 
|  | 137 | const char *deemp_names[] = { | 
|  | 138 | "none", | 
|  | 139 | "32 kHz", | 
|  | 140 | "44.1 kHz", | 
|  | 141 | "48 kHz", | 
|  | 142 | }; | 
|  | 143 |  | 
|  | 144 | const char *mic_sens_value[] = { | 
|  | 145 | "-3 dB", "0 dB", "3 dB", "9 dB", "15 dB", "21 dB", "27 dB", "not used", | 
|  | 146 | }; | 
|  | 147 |  | 
|  | 148 | const unsigned short AGC_atime[] = { | 
|  | 149 | 11, 16, 11, 16, 21, 11, 16, 21, | 
|  | 150 | }; | 
|  | 151 |  | 
|  | 152 | const unsigned short AGC_dtime[] = { | 
|  | 153 | 100, 100, 200, 200, 200, 400, 400, 400, | 
|  | 154 | }; | 
|  | 155 |  | 
|  | 156 | const char *AGC_level[] = { | 
|  | 157 | "-9.0", "-11.5", "-15.0", "-17.5", | 
|  | 158 | }; | 
|  | 159 |  | 
|  | 160 | const char *ig_small_value[] = { | 
|  | 161 | "-3.0", "-2.5", "-2.0", "-1.5", "-1.0", "-0.5", | 
|  | 162 | }; | 
|  | 163 |  | 
|  | 164 | /* | 
|  | 165 | * this was computed as peak_value[i] = pow((63-i)*1.42,1.013) | 
|  | 166 | * | 
|  | 167 | * UDA1341 datasheet on page 21: Peak value (dB) = (Peak level - 63.5)*5*log2 | 
|  | 168 | * There is an table with these values [level]=value: [3]=-90.31, [7]=-84.29 | 
|  | 169 | * [61]=-2.78, [62] = -1.48, [63] = 0.0 | 
|  | 170 | * I tried to compute it, but using but even using logarithm with base either 10 or 2 | 
|  | 171 | * i was'n able to get values in the table from the formula. So I constructed another | 
|  | 172 | * formula (see above) to interpolate the values as good as possible. If there is some | 
|  | 173 | * mistake, please contact me on tomas.kasparek@seznam.cz. Thanks. | 
|  | 174 | * UDA1341TS datasheet is available at: | 
|  | 175 | *   http://www-us9.semiconductors.com/acrobat/datasheets/UDA1341TS_3.pdf | 
|  | 176 | */ | 
|  | 177 | const char *peak_value[] = { | 
|  | 178 | "-INF dB", "N.A.", "N.A", "90.31 dB", "N.A.", "N.A.", "N.A.", "-84.29 dB", | 
|  | 179 | "-82.65 dB", "-81.13 dB", "-79.61 dB", "-78.09 dB", "-76.57 dB", "-75.05 dB", "-73.53 dB", | 
|  | 180 | "-72.01 dB", "-70.49 dB", "-68.97 dB", "-67.45 dB", "-65.93 dB", "-64.41 dB", "-62.90 dB", | 
|  | 181 | "-61.38 dB", "-59.86 dB", "-58.35 dB", "-56.83 dB", "-55.32 dB", "-53.80 dB", "-52.29 dB", | 
|  | 182 | "-50.78 dB", "-49.26 dB", "-47.75 dB", "-46.24 dB", "-44.73 dB", "-43.22 dB", "-41.71 dB", | 
|  | 183 | "-40.20 dB", "-38.69 dB", "-37.19 dB", "-35.68 dB", "-34.17 dB", "-32.67 dB", "-31.17 dB", | 
|  | 184 | "-29.66 dB", "-28.16 dB", "-26.66 dB", "-25.16 dB", "-23.66 dB", "-22.16 dB", "-20.67 dB", | 
|  | 185 | "-19.17 dB", "-17.68 dB", "-16.19 dB", "-14.70 dB", "-13.21 dB", "-11.72 dB", "-10.24 dB", | 
|  | 186 | "-8.76 dB", "-7.28 dB", "-5.81 dB", "-4.34 dB", "-2.88 dB", "-1.43 dB", "0.00 dB", | 
|  | 187 | }; | 
|  | 188 |  | 
|  | 189 | enum uda1341_config { | 
|  | 190 | CMD_READ_REG = 0, | 
|  | 191 | CMD_RESET, | 
|  | 192 | CMD_FS, | 
|  | 193 | CMD_FORMAT, | 
|  | 194 | CMD_OGAIN, | 
|  | 195 | CMD_IGAIN, | 
|  | 196 | CMD_DAC, | 
|  | 197 | CMD_ADC, | 
|  | 198 | CMD_VOLUME, | 
|  | 199 | CMD_BASS, | 
|  | 200 | CMD_TREBBLE, | 
|  | 201 | CMD_PEAK, | 
|  | 202 | CMD_DEEMP, | 
|  | 203 | CMD_MUTE, | 
|  | 204 | CMD_FILTER, | 
|  | 205 | CMD_CH1, | 
|  | 206 | CMD_CH2, | 
|  | 207 | CMD_MIC, | 
|  | 208 | CMD_MIXER, | 
|  | 209 | CMD_AGC, | 
|  | 210 | CMD_IG, | 
|  | 211 | CMD_AGC_TIME, | 
|  | 212 | CMD_AGC_LEVEL, | 
|  | 213 | #ifdef CONFIG_PM | 
|  | 214 | CMD_SUSPEND, | 
|  | 215 | CMD_RESUME, | 
|  | 216 | #endif | 
|  | 217 | CMD_LAST, | 
|  | 218 | }; | 
|  | 219 |  | 
|  | 220 | enum write_through { | 
|  | 221 | //used in update_bits (write_cfg) to avoid l3_write - just update local copy of regs. | 
|  | 222 | REGS_ONLY=0, | 
|  | 223 | //update local regs and write value to uda1341 - do l3_write | 
|  | 224 | FLUSH, | 
|  | 225 | }; | 
|  | 226 |  | 
|  | 227 | int __init snd_chip_uda1341_mixer_new(snd_card_t *card, struct l3_client **clnt); | 
|  | 228 |  | 
|  | 229 | /* | 
|  | 230 | * Local variables: | 
|  | 231 | * indent-tabs-mode: t | 
|  | 232 | * End: | 
|  | 233 | */ |