Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 1 | /* |
| 2 | * ALSA SoC TLV320AIC23 codec driver |
| 3 | * |
| 4 | * Author: Arun KS, <arunks@mistralsolutions.com> |
| 5 | * Copyright: (C) 2008 Mistral Solutions Pvt Ltd., |
| 6 | * |
| 7 | * Based on sound/soc/codecs/wm8731.c by Richard Purdie |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | * |
| 13 | * Notes: |
| 14 | * The AIC23 is a driver for a low power stereo audio |
| 15 | * codec tlv320aic23 |
| 16 | * |
| 17 | * The machine layer should disable unsupported inputs/outputs by |
| 18 | * snd_soc_dapm_disable_pin(codec, "LHPOUT"), etc. |
| 19 | */ |
| 20 | |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/moduleparam.h> |
| 23 | #include <linux/init.h> |
| 24 | #include <linux/delay.h> |
| 25 | #include <linux/pm.h> |
| 26 | #include <linux/i2c.h> |
| 27 | #include <linux/platform_device.h> |
| 28 | #include <sound/core.h> |
| 29 | #include <sound/pcm.h> |
| 30 | #include <sound/pcm_params.h> |
| 31 | #include <sound/soc.h> |
| 32 | #include <sound/soc-dapm.h> |
| 33 | #include <sound/tlv.h> |
| 34 | #include <sound/initval.h> |
| 35 | |
| 36 | #include "tlv320aic23.h" |
| 37 | |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 38 | #define AIC23_VERSION "0.1" |
| 39 | |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 40 | /* |
| 41 | * AIC23 register cache |
| 42 | */ |
| 43 | static const u16 tlv320aic23_reg[] = { |
| 44 | 0x0097, 0x0097, 0x00F9, 0x00F9, /* 0 */ |
| 45 | 0x001A, 0x0004, 0x0007, 0x0001, /* 4 */ |
| 46 | 0x0020, 0x0000, 0x0000, 0x0000, /* 8 */ |
| 47 | 0x0000, 0x0000, 0x0000, 0x0000, /* 12 */ |
| 48 | }; |
| 49 | |
| 50 | /* |
| 51 | * read tlv320aic23 register cache |
| 52 | */ |
| 53 | static inline unsigned int tlv320aic23_read_reg_cache(struct snd_soc_codec |
| 54 | *codec, unsigned int reg) |
| 55 | { |
| 56 | u16 *cache = codec->reg_cache; |
| 57 | if (reg >= ARRAY_SIZE(tlv320aic23_reg)) |
| 58 | return -1; |
| 59 | return cache[reg]; |
| 60 | } |
| 61 | |
| 62 | /* |
| 63 | * write tlv320aic23 register cache |
| 64 | */ |
| 65 | static inline void tlv320aic23_write_reg_cache(struct snd_soc_codec *codec, |
| 66 | u8 reg, u16 value) |
| 67 | { |
| 68 | u16 *cache = codec->reg_cache; |
| 69 | if (reg >= ARRAY_SIZE(tlv320aic23_reg)) |
| 70 | return; |
| 71 | cache[reg] = value; |
| 72 | } |
| 73 | |
| 74 | /* |
| 75 | * write to the tlv320aic23 register space |
| 76 | */ |
| 77 | static int tlv320aic23_write(struct snd_soc_codec *codec, unsigned int reg, |
| 78 | unsigned int value) |
| 79 | { |
| 80 | |
Arun KS | 4aa0239 | 2008-10-13 15:47:25 +0530 | [diff] [blame] | 81 | u8 data[2]; |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 82 | |
| 83 | /* TLV320AIC23 has 7 bit address and 9 bits of data |
| 84 | * so we need to switch one data bit into reg and rest |
| 85 | * of data into val |
| 86 | */ |
| 87 | |
| 88 | if ((reg < 0 || reg > 9) && (reg != 15)) { |
| 89 | printk(KERN_WARNING "%s Invalid register R%d\n", __func__, reg); |
| 90 | return -1; |
| 91 | } |
| 92 | |
Arun KS | 4aa0239 | 2008-10-13 15:47:25 +0530 | [diff] [blame] | 93 | data[0] = (reg << 1) | (value >> 8 & 0x01); |
| 94 | data[1] = value & 0xff; |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 95 | |
| 96 | tlv320aic23_write_reg_cache(codec, reg, value); |
| 97 | |
Arun KS | 4aa0239 | 2008-10-13 15:47:25 +0530 | [diff] [blame] | 98 | if (codec->hw_write(codec->control_data, data, 2) == 2) |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 99 | return 0; |
| 100 | |
| 101 | printk(KERN_ERR "%s cannot write %03x to register R%d\n", __func__, |
| 102 | value, reg); |
| 103 | |
| 104 | return -EIO; |
| 105 | } |
| 106 | |
| 107 | static const char *rec_src_text[] = { "Line", "Mic" }; |
| 108 | static const char *deemph_text[] = {"None", "32Khz", "44.1Khz", "48Khz"}; |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 109 | |
| 110 | static const struct soc_enum rec_src_enum = |
| 111 | SOC_ENUM_SINGLE(TLV320AIC23_ANLG, 2, 2, rec_src_text); |
| 112 | |
| 113 | static const struct snd_kcontrol_new tlv320aic23_rec_src_mux_controls = |
| 114 | SOC_DAPM_ENUM("Input Select", rec_src_enum); |
| 115 | |
| 116 | static const struct soc_enum tlv320aic23_rec_src = |
| 117 | SOC_ENUM_SINGLE(TLV320AIC23_ANLG, 2, 2, rec_src_text); |
| 118 | static const struct soc_enum tlv320aic23_deemph = |
| 119 | SOC_ENUM_SINGLE(TLV320AIC23_DIGT, 1, 4, deemph_text); |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 120 | |
| 121 | static const DECLARE_TLV_DB_SCALE(out_gain_tlv, -12100, 100, 0); |
| 122 | static const DECLARE_TLV_DB_SCALE(input_gain_tlv, -1725, 75, 0); |
Arun KS | df91ddf | 2008-10-03 17:07:30 +0530 | [diff] [blame] | 123 | static const DECLARE_TLV_DB_SCALE(sidetone_vol_tlv, -1800, 300, 0); |
| 124 | |
| 125 | static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, |
| 126 | struct snd_ctl_elem_value *ucontrol) |
| 127 | { |
| 128 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 129 | u16 val, reg; |
| 130 | |
| 131 | val = (ucontrol->value.integer.value[0] & 0x07); |
| 132 | |
| 133 | /* linear conversion to userspace |
| 134 | * 000 = -6db |
| 135 | * 001 = -9db |
| 136 | * 010 = -12db |
| 137 | * 011 = -18db (Min) |
| 138 | * 100 = 0db (Max) |
| 139 | */ |
| 140 | val = (val >= 4) ? 4 : (3 - val); |
| 141 | |
| 142 | reg = tlv320aic23_read_reg_cache(codec, TLV320AIC23_ANLG) & (~0x1C0); |
| 143 | tlv320aic23_write(codec, TLV320AIC23_ANLG, reg | (val << 6)); |
| 144 | |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | static int snd_soc_tlv320aic23_get_volsw(struct snd_kcontrol *kcontrol, |
| 149 | struct snd_ctl_elem_value *ucontrol) |
| 150 | { |
| 151 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); |
| 152 | u16 val; |
| 153 | |
| 154 | val = tlv320aic23_read_reg_cache(codec, TLV320AIC23_ANLG) & (0x1C0); |
| 155 | val = val >> 6; |
| 156 | val = (val >= 4) ? 4 : (3 - val); |
| 157 | ucontrol->value.integer.value[0] = val; |
| 158 | return 0; |
| 159 | |
| 160 | } |
| 161 | |
| 162 | #define SOC_TLV320AIC23_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ |
| 163 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 164 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ |
| 165 | SNDRV_CTL_ELEM_ACCESS_READWRITE,\ |
| 166 | .tlv.p = (tlv_array), \ |
| 167 | .info = snd_soc_info_volsw, .get = snd_soc_tlv320aic23_get_volsw,\ |
| 168 | .put = snd_soc_tlv320aic23_put_volsw, \ |
| 169 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) } |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 170 | |
| 171 | static const struct snd_kcontrol_new tlv320aic23_snd_controls[] = { |
| 172 | SOC_DOUBLE_R_TLV("Digital Playback Volume", TLV320AIC23_LCHNVOL, |
| 173 | TLV320AIC23_RCHNVOL, 0, 127, 0, out_gain_tlv), |
| 174 | SOC_SINGLE("Digital Playback Switch", TLV320AIC23_DIGT, 3, 1, 1), |
| 175 | SOC_DOUBLE_R("Line Input Switch", TLV320AIC23_LINVOL, |
| 176 | TLV320AIC23_RINVOL, 7, 1, 0), |
| 177 | SOC_DOUBLE_R_TLV("Line Input Volume", TLV320AIC23_LINVOL, |
| 178 | TLV320AIC23_RINVOL, 0, 31, 0, input_gain_tlv), |
| 179 | SOC_SINGLE("Mic Input Switch", TLV320AIC23_ANLG, 1, 1, 1), |
| 180 | SOC_SINGLE("Mic Booster Switch", TLV320AIC23_ANLG, 0, 1, 0), |
Arun KS | df91ddf | 2008-10-03 17:07:30 +0530 | [diff] [blame] | 181 | SOC_TLV320AIC23_SINGLE_TLV("Sidetone Volume", TLV320AIC23_ANLG, |
| 182 | 6, 4, 0, sidetone_vol_tlv), |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 183 | SOC_ENUM("Playback De-emphasis", tlv320aic23_deemph), |
| 184 | }; |
| 185 | |
| 186 | /* add non dapm controls */ |
| 187 | static int tlv320aic23_add_controls(struct snd_soc_codec *codec) |
| 188 | { |
| 189 | |
| 190 | int err, i; |
| 191 | |
| 192 | for (i = 0; i < ARRAY_SIZE(tlv320aic23_snd_controls); i++) { |
| 193 | err = snd_ctl_add(codec->card, |
| 194 | snd_soc_cnew(&tlv320aic23_snd_controls[i], |
| 195 | codec, NULL)); |
| 196 | if (err < 0) |
| 197 | return err; |
| 198 | } |
| 199 | |
| 200 | return 0; |
| 201 | |
| 202 | } |
| 203 | |
| 204 | /* PGA Mixer controls for Line and Mic switch */ |
| 205 | static const struct snd_kcontrol_new tlv320aic23_output_mixer_controls[] = { |
| 206 | SOC_DAPM_SINGLE("Line Bypass Switch", TLV320AIC23_ANLG, 3, 1, 0), |
| 207 | SOC_DAPM_SINGLE("Mic Sidetone Switch", TLV320AIC23_ANLG, 5, 1, 0), |
| 208 | SOC_DAPM_SINGLE("Playback Switch", TLV320AIC23_ANLG, 4, 1, 0), |
| 209 | }; |
| 210 | |
| 211 | static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets[] = { |
| 212 | SND_SOC_DAPM_DAC("DAC", "Playback", TLV320AIC23_PWR, 3, 1), |
| 213 | SND_SOC_DAPM_ADC("ADC", "Capture", TLV320AIC23_PWR, 2, 1), |
| 214 | SND_SOC_DAPM_MUX("Capture Source", SND_SOC_NOPM, 0, 0, |
| 215 | &tlv320aic23_rec_src_mux_controls), |
| 216 | SND_SOC_DAPM_MIXER("Output Mixer", TLV320AIC23_PWR, 4, 1, |
| 217 | &tlv320aic23_output_mixer_controls[0], |
| 218 | ARRAY_SIZE(tlv320aic23_output_mixer_controls)), |
| 219 | SND_SOC_DAPM_PGA("Line Input", TLV320AIC23_PWR, 0, 1, NULL, 0), |
| 220 | SND_SOC_DAPM_PGA("Mic Input", TLV320AIC23_PWR, 1, 1, NULL, 0), |
| 221 | |
| 222 | SND_SOC_DAPM_OUTPUT("LHPOUT"), |
| 223 | SND_SOC_DAPM_OUTPUT("RHPOUT"), |
| 224 | SND_SOC_DAPM_OUTPUT("LOUT"), |
| 225 | SND_SOC_DAPM_OUTPUT("ROUT"), |
| 226 | |
| 227 | SND_SOC_DAPM_INPUT("LLINEIN"), |
| 228 | SND_SOC_DAPM_INPUT("RLINEIN"), |
| 229 | |
| 230 | SND_SOC_DAPM_INPUT("MICIN"), |
| 231 | }; |
| 232 | |
| 233 | static const struct snd_soc_dapm_route intercon[] = { |
| 234 | /* Output Mixer */ |
| 235 | {"Output Mixer", "Line Bypass Switch", "Line Input"}, |
| 236 | {"Output Mixer", "Playback Switch", "DAC"}, |
| 237 | {"Output Mixer", "Mic Sidetone Switch", "Mic Input"}, |
| 238 | |
| 239 | /* Outputs */ |
| 240 | {"RHPOUT", NULL, "Output Mixer"}, |
| 241 | {"LHPOUT", NULL, "Output Mixer"}, |
| 242 | {"LOUT", NULL, "Output Mixer"}, |
| 243 | {"ROUT", NULL, "Output Mixer"}, |
| 244 | |
| 245 | /* Inputs */ |
| 246 | {"Line Input", "NULL", "LLINEIN"}, |
| 247 | {"Line Input", "NULL", "RLINEIN"}, |
| 248 | |
| 249 | {"Mic Input", "NULL", "MICIN"}, |
| 250 | |
| 251 | /* input mux */ |
| 252 | {"Capture Source", "Line", "Line Input"}, |
| 253 | {"Capture Source", "Mic", "Mic Input"}, |
| 254 | {"ADC", NULL, "Capture Source"}, |
| 255 | |
| 256 | }; |
| 257 | |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 258 | /* AIC23 driver data */ |
| 259 | struct aic23 { |
| 260 | struct snd_soc_codec codec; |
| 261 | int mclk; |
| 262 | int requested_adc; |
| 263 | int requested_dac; |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 264 | }; |
| 265 | |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 266 | /* |
| 267 | * Common Crystals used |
| 268 | * 11.2896 Mhz /128 = *88.2k /192 = 58.8k |
| 269 | * 12.0000 Mhz /125 = *96k /136 = 88.235K |
| 270 | * 12.2880 Mhz /128 = *96k /192 = 64k |
| 271 | * 16.9344 Mhz /128 = 132.3k /192 = *88.2k |
| 272 | * 18.4320 Mhz /128 = 144k /192 = *96k |
| 273 | */ |
| 274 | |
| 275 | /* |
| 276 | * Normal BOSR 0-256/2 = 128, 1-384/2 = 192 |
| 277 | * USB BOSR 0-250/2 = 125, 1-272/2 = 136 |
| 278 | */ |
| 279 | static const int bosr_usb_divisor_table[] = { |
| 280 | 128, 125, 192, 136 |
| 281 | }; |
| 282 | #define LOWER_GROUP ((1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<6) | (1<<7)) |
| 283 | #define UPPER_GROUP ((1<<8) | (1<<9) | (1<<10) | (1<<11) | (1<<15)) |
| 284 | static const unsigned short sr_valid_mask[] = { |
| 285 | LOWER_GROUP|UPPER_GROUP, /* Normal, bosr - 0*/ |
| 286 | LOWER_GROUP|UPPER_GROUP, /* Normal, bosr - 1*/ |
| 287 | LOWER_GROUP, /* Usb, bosr - 0*/ |
| 288 | UPPER_GROUP, /* Usb, bosr - 1*/ |
| 289 | }; |
| 290 | /* |
| 291 | * Every divisor is a factor of 11*12 |
| 292 | */ |
| 293 | #define SR_MULT (11*12) |
| 294 | #define A(x) (x) ? (SR_MULT/x) : 0 |
| 295 | static const unsigned char sr_adc_mult_table[] = { |
| 296 | A(2), A(2), A(12), A(12), A(0), A(0), A(3), A(1), |
| 297 | A(2), A(2), A(11), A(11), A(0), A(0), A(0), A(1) |
| 298 | }; |
| 299 | static const unsigned char sr_dac_mult_table[] = { |
| 300 | A(2), A(12), A(2), A(12), A(0), A(0), A(3), A(1), |
| 301 | A(2), A(11), A(2), A(11), A(0), A(0), A(0), A(1) |
| 302 | }; |
| 303 | |
| 304 | static unsigned get_score(int adc, int adc_l, int adc_h, int need_adc, |
| 305 | int dac, int dac_l, int dac_h, int need_dac) |
| 306 | { |
| 307 | if ((adc >= adc_l) && (adc <= adc_h) && |
| 308 | (dac >= dac_l) && (dac <= dac_h)) { |
| 309 | int diff_adc = need_adc - adc; |
| 310 | int diff_dac = need_dac - dac; |
| 311 | return abs(diff_adc) + abs(diff_dac); |
| 312 | } |
| 313 | return UINT_MAX; |
| 314 | } |
| 315 | |
| 316 | static int find_rate(int mclk, u32 need_adc, u32 need_dac) |
| 317 | { |
| 318 | int i, j; |
| 319 | int best_i = -1; |
| 320 | int best_j = -1; |
| 321 | int best_div = 0; |
| 322 | unsigned best_score = UINT_MAX; |
| 323 | int adc_l, adc_h, dac_l, dac_h; |
| 324 | |
| 325 | need_adc *= SR_MULT; |
| 326 | need_dac *= SR_MULT; |
| 327 | /* |
| 328 | * rates given are +/- 1/32 |
| 329 | */ |
| 330 | adc_l = need_adc - (need_adc >> 5); |
| 331 | adc_h = need_adc + (need_adc >> 5); |
| 332 | dac_l = need_dac - (need_dac >> 5); |
| 333 | dac_h = need_dac + (need_dac >> 5); |
Mark Brown | 8d702f2 | 2008-11-17 21:42:01 +0000 | [diff] [blame] | 334 | for (i = 0; i < ARRAY_SIZE(bosr_usb_divisor_table); i++) { |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 335 | int base = mclk / bosr_usb_divisor_table[i]; |
| 336 | int mask = sr_valid_mask[i]; |
Mark Brown | 8d702f2 | 2008-11-17 21:42:01 +0000 | [diff] [blame] | 337 | for (j = 0; j < ARRAY_SIZE(sr_adc_mult_table); |
| 338 | j++, mask >>= 1) { |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 339 | int adc; |
| 340 | int dac; |
| 341 | int score; |
| 342 | if ((mask & 1) == 0) |
| 343 | continue; |
| 344 | adc = base * sr_adc_mult_table[j]; |
| 345 | dac = base * sr_dac_mult_table[j]; |
| 346 | score = get_score(adc, adc_l, adc_h, need_adc, |
| 347 | dac, dac_l, dac_h, need_dac); |
| 348 | if (best_score > score) { |
| 349 | best_score = score; |
| 350 | best_i = i; |
| 351 | best_j = j; |
| 352 | best_div = 0; |
| 353 | } |
| 354 | score = get_score((adc >> 1), adc_l, adc_h, need_adc, |
| 355 | (dac >> 1), dac_l, dac_h, need_dac); |
| 356 | /* prefer to have a /2 */ |
| 357 | if ((score != UINT_MAX) && (best_score >= score)) { |
| 358 | best_score = score; |
| 359 | best_i = i; |
| 360 | best_j = j; |
| 361 | best_div = 1; |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | return (best_j << 2) | best_i | (best_div << TLV320AIC23_CLKIN_SHIFT); |
| 366 | } |
| 367 | |
Mark Brown | 8d702f2 | 2008-11-17 21:42:01 +0000 | [diff] [blame] | 368 | #ifdef DEBUG |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 369 | static void get_current_sample_rates(struct snd_soc_codec *codec, int mclk, |
| 370 | u32 *sample_rate_adc, u32 *sample_rate_dac) |
| 371 | { |
| 372 | int src = tlv320aic23_read_reg_cache(codec, TLV320AIC23_SRATE); |
| 373 | int sr = (src >> 2) & 0x0f; |
| 374 | int val = (mclk / bosr_usb_divisor_table[src & 3]); |
| 375 | int adc = (val * sr_adc_mult_table[sr]) / SR_MULT; |
| 376 | int dac = (val * sr_dac_mult_table[sr]) / SR_MULT; |
| 377 | if (src & TLV320AIC23_CLKIN_HALF) { |
| 378 | adc >>= 1; |
| 379 | dac >>= 1; |
| 380 | } |
| 381 | *sample_rate_adc = adc; |
| 382 | *sample_rate_dac = dac; |
| 383 | } |
Mark Brown | 8d702f2 | 2008-11-17 21:42:01 +0000 | [diff] [blame] | 384 | #endif |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 385 | |
| 386 | static int set_sample_rate_control(struct snd_soc_codec *codec, int mclk, |
| 387 | u32 sample_rate_adc, u32 sample_rate_dac) |
| 388 | { |
| 389 | /* Search for the right sample rate */ |
| 390 | int data = find_rate(mclk, sample_rate_adc, sample_rate_dac); |
| 391 | if (data < 0) { |
| 392 | printk(KERN_ERR "%s:Invalid rate %u,%u requested\n", |
| 393 | __func__, sample_rate_adc, sample_rate_dac); |
| 394 | return -EINVAL; |
| 395 | } |
| 396 | tlv320aic23_write(codec, TLV320AIC23_SRATE, data); |
Mark Brown | 8d702f2 | 2008-11-17 21:42:01 +0000 | [diff] [blame] | 397 | #ifdef DEBUG |
| 398 | { |
| 399 | u32 adc, dac; |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 400 | get_current_sample_rates(codec, mclk, &adc, &dac); |
| 401 | printk(KERN_DEBUG "actual samplerate = %u,%u reg=%x\n", |
| 402 | adc, dac, data); |
| 403 | } |
Mark Brown | 8d702f2 | 2008-11-17 21:42:01 +0000 | [diff] [blame] | 404 | #endif |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 405 | return 0; |
| 406 | } |
| 407 | |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 408 | static int tlv320aic23_add_widgets(struct snd_soc_codec *codec) |
| 409 | { |
| 410 | snd_soc_dapm_new_controls(codec, tlv320aic23_dapm_widgets, |
| 411 | ARRAY_SIZE(tlv320aic23_dapm_widgets)); |
| 412 | |
| 413 | /* set up audio path interconnects */ |
| 414 | snd_soc_dapm_add_routes(codec, intercon, ARRAY_SIZE(intercon)); |
| 415 | |
| 416 | snd_soc_dapm_new_widgets(codec); |
| 417 | return 0; |
| 418 | } |
| 419 | |
| 420 | static int tlv320aic23_hw_params(struct snd_pcm_substream *substream, |
Mark Brown | dee89c4 | 2008-11-18 22:11:38 +0000 | [diff] [blame] | 421 | struct snd_pcm_hw_params *params, |
| 422 | struct snd_soc_dai *dai) |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 423 | { |
| 424 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 425 | struct snd_soc_device *socdev = rtd->socdev; |
| 426 | struct snd_soc_codec *codec = socdev->codec; |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 427 | u16 iface_reg; |
| 428 | int ret; |
| 429 | struct aic23 *aic23 = container_of(codec, struct aic23, codec); |
| 430 | u32 sample_rate_adc = aic23->requested_adc; |
| 431 | u32 sample_rate_dac = aic23->requested_dac; |
| 432 | u32 sample_rate = params_rate(params); |
| 433 | |
| 434 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 435 | aic23->requested_dac = sample_rate_dac = sample_rate; |
| 436 | if (!sample_rate_adc) |
| 437 | sample_rate_adc = sample_rate; |
| 438 | } else { |
| 439 | aic23->requested_adc = sample_rate_adc = sample_rate; |
| 440 | if (!sample_rate_dac) |
| 441 | sample_rate_dac = sample_rate; |
| 442 | } |
| 443 | ret = set_sample_rate_control(codec, aic23->mclk, sample_rate_adc, |
| 444 | sample_rate_dac); |
| 445 | if (ret < 0) |
| 446 | return ret; |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 447 | |
| 448 | iface_reg = |
| 449 | tlv320aic23_read_reg_cache(codec, |
| 450 | TLV320AIC23_DIGT_FMT) & ~(0x03 << 2); |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 451 | switch (params_format(params)) { |
| 452 | case SNDRV_PCM_FORMAT_S16_LE: |
| 453 | break; |
| 454 | case SNDRV_PCM_FORMAT_S20_3LE: |
| 455 | iface_reg |= (0x01 << 2); |
| 456 | break; |
| 457 | case SNDRV_PCM_FORMAT_S24_LE: |
| 458 | iface_reg |= (0x02 << 2); |
| 459 | break; |
| 460 | case SNDRV_PCM_FORMAT_S32_LE: |
| 461 | iface_reg |= (0x03 << 2); |
| 462 | break; |
| 463 | } |
| 464 | tlv320aic23_write(codec, TLV320AIC23_DIGT_FMT, iface_reg); |
| 465 | |
| 466 | return 0; |
| 467 | } |
| 468 | |
Mark Brown | dee89c4 | 2008-11-18 22:11:38 +0000 | [diff] [blame] | 469 | static int tlv320aic23_pcm_prepare(struct snd_pcm_substream *substream, |
| 470 | struct snd_soc_dai *dai) |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 471 | { |
| 472 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 473 | struct snd_soc_device *socdev = rtd->socdev; |
| 474 | struct snd_soc_codec *codec = socdev->codec; |
| 475 | |
| 476 | /* set active */ |
| 477 | tlv320aic23_write(codec, TLV320AIC23_ACTIVE, 0x0001); |
| 478 | |
| 479 | return 0; |
| 480 | } |
| 481 | |
Mark Brown | dee89c4 | 2008-11-18 22:11:38 +0000 | [diff] [blame] | 482 | static void tlv320aic23_shutdown(struct snd_pcm_substream *substream, |
| 483 | struct snd_soc_dai *dai) |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 484 | { |
| 485 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 486 | struct snd_soc_device *socdev = rtd->socdev; |
| 487 | struct snd_soc_codec *codec = socdev->codec; |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 488 | struct aic23 *aic23 = container_of(codec, struct aic23, codec); |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 489 | |
| 490 | /* deactivate */ |
| 491 | if (!codec->active) { |
| 492 | udelay(50); |
| 493 | tlv320aic23_write(codec, TLV320AIC23_ACTIVE, 0x0); |
| 494 | } |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 495 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 496 | aic23->requested_dac = 0; |
| 497 | else |
| 498 | aic23->requested_adc = 0; |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | static int tlv320aic23_mute(struct snd_soc_dai *dai, int mute) |
| 502 | { |
| 503 | struct snd_soc_codec *codec = dai->codec; |
| 504 | u16 reg; |
| 505 | |
| 506 | reg = tlv320aic23_read_reg_cache(codec, TLV320AIC23_DIGT); |
| 507 | if (mute) |
| 508 | reg |= TLV320AIC23_DACM_MUTE; |
| 509 | |
| 510 | else |
| 511 | reg &= ~TLV320AIC23_DACM_MUTE; |
| 512 | |
| 513 | tlv320aic23_write(codec, TLV320AIC23_DIGT, reg); |
| 514 | |
| 515 | return 0; |
| 516 | } |
| 517 | |
| 518 | static int tlv320aic23_set_dai_fmt(struct snd_soc_dai *codec_dai, |
| 519 | unsigned int fmt) |
| 520 | { |
| 521 | struct snd_soc_codec *codec = codec_dai->codec; |
| 522 | u16 iface_reg; |
| 523 | |
| 524 | iface_reg = |
| 525 | tlv320aic23_read_reg_cache(codec, TLV320AIC23_DIGT_FMT) & (~0x03); |
| 526 | |
| 527 | /* set master/slave audio interface */ |
| 528 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 529 | case SND_SOC_DAIFMT_CBM_CFM: |
| 530 | iface_reg |= TLV320AIC23_MS_MASTER; |
| 531 | break; |
| 532 | case SND_SOC_DAIFMT_CBS_CFS: |
| 533 | break; |
| 534 | default: |
| 535 | return -EINVAL; |
| 536 | |
| 537 | } |
| 538 | |
| 539 | /* interface format */ |
| 540 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
| 541 | case SND_SOC_DAIFMT_I2S: |
| 542 | iface_reg |= TLV320AIC23_FOR_I2S; |
| 543 | break; |
| 544 | case SND_SOC_DAIFMT_DSP_A: |
| 545 | iface_reg |= TLV320AIC23_FOR_DSP; |
| 546 | break; |
| 547 | case SND_SOC_DAIFMT_RIGHT_J: |
| 548 | break; |
| 549 | case SND_SOC_DAIFMT_LEFT_J: |
| 550 | iface_reg |= TLV320AIC23_FOR_LJUST; |
| 551 | break; |
| 552 | default: |
| 553 | return -EINVAL; |
| 554 | |
| 555 | } |
| 556 | |
| 557 | tlv320aic23_write(codec, TLV320AIC23_DIGT_FMT, iface_reg); |
| 558 | |
| 559 | return 0; |
| 560 | } |
| 561 | |
| 562 | static int tlv320aic23_set_dai_sysclk(struct snd_soc_dai *codec_dai, |
| 563 | int clk_id, unsigned int freq, int dir) |
| 564 | { |
| 565 | struct snd_soc_codec *codec = codec_dai->codec; |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 566 | struct aic23 *aic23 = container_of(codec, struct aic23, codec); |
| 567 | aic23->mclk = freq; |
| 568 | return 0; |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | static int tlv320aic23_set_bias_level(struct snd_soc_codec *codec, |
| 572 | enum snd_soc_bias_level level) |
| 573 | { |
| 574 | u16 reg = tlv320aic23_read_reg_cache(codec, TLV320AIC23_PWR) & 0xff7f; |
| 575 | |
| 576 | switch (level) { |
| 577 | case SND_SOC_BIAS_ON: |
| 578 | /* vref/mid, osc on, dac unmute */ |
| 579 | tlv320aic23_write(codec, TLV320AIC23_PWR, reg); |
| 580 | break; |
| 581 | case SND_SOC_BIAS_PREPARE: |
| 582 | break; |
| 583 | case SND_SOC_BIAS_STANDBY: |
| 584 | /* everything off except vref/vmid, */ |
| 585 | tlv320aic23_write(codec, TLV320AIC23_PWR, reg | 0x0040); |
| 586 | break; |
| 587 | case SND_SOC_BIAS_OFF: |
| 588 | /* everything off, dac mute, inactive */ |
| 589 | tlv320aic23_write(codec, TLV320AIC23_ACTIVE, 0x0); |
| 590 | tlv320aic23_write(codec, TLV320AIC23_PWR, 0xffff); |
| 591 | break; |
| 592 | } |
| 593 | codec->bias_level = level; |
| 594 | return 0; |
| 595 | } |
| 596 | |
| 597 | #define AIC23_RATES SNDRV_PCM_RATE_8000_96000 |
| 598 | #define AIC23_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ |
| 599 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE) |
| 600 | |
| 601 | struct snd_soc_dai tlv320aic23_dai = { |
| 602 | .name = "tlv320aic23", |
| 603 | .playback = { |
| 604 | .stream_name = "Playback", |
| 605 | .channels_min = 2, |
| 606 | .channels_max = 2, |
| 607 | .rates = AIC23_RATES, |
| 608 | .formats = AIC23_FORMATS,}, |
| 609 | .capture = { |
| 610 | .stream_name = "Capture", |
| 611 | .channels_min = 2, |
| 612 | .channels_max = 2, |
| 613 | .rates = AIC23_RATES, |
| 614 | .formats = AIC23_FORMATS,}, |
| 615 | .ops = { |
| 616 | .prepare = tlv320aic23_pcm_prepare, |
| 617 | .hw_params = tlv320aic23_hw_params, |
| 618 | .shutdown = tlv320aic23_shutdown, |
Mark Brown | dee89c4 | 2008-11-18 22:11:38 +0000 | [diff] [blame] | 619 | .digital_mute = tlv320aic23_mute, |
| 620 | .set_fmt = tlv320aic23_set_dai_fmt, |
| 621 | .set_sysclk = tlv320aic23_set_dai_sysclk, |
| 622 | } |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 623 | }; |
| 624 | EXPORT_SYMBOL_GPL(tlv320aic23_dai); |
| 625 | |
| 626 | static int tlv320aic23_suspend(struct platform_device *pdev, |
| 627 | pm_message_t state) |
| 628 | { |
| 629 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
| 630 | struct snd_soc_codec *codec = socdev->codec; |
| 631 | |
| 632 | tlv320aic23_write(codec, TLV320AIC23_ACTIVE, 0x0); |
| 633 | tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_OFF); |
| 634 | |
| 635 | return 0; |
| 636 | } |
| 637 | |
| 638 | static int tlv320aic23_resume(struct platform_device *pdev) |
| 639 | { |
| 640 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
| 641 | struct snd_soc_codec *codec = socdev->codec; |
| 642 | int i; |
| 643 | u16 reg; |
| 644 | |
| 645 | /* Sync reg_cache with the hardware */ |
| 646 | for (reg = 0; reg < ARRAY_SIZE(tlv320aic23_reg); i++) { |
| 647 | u16 val = tlv320aic23_read_reg_cache(codec, reg); |
| 648 | tlv320aic23_write(codec, reg, val); |
| 649 | } |
| 650 | |
| 651 | tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
| 652 | tlv320aic23_set_bias_level(codec, codec->suspend_bias_level); |
| 653 | |
| 654 | return 0; |
| 655 | } |
| 656 | |
| 657 | /* |
| 658 | * initialise the AIC23 driver |
| 659 | * register the mixer and dsp interfaces with the kernel |
| 660 | */ |
| 661 | static int tlv320aic23_init(struct snd_soc_device *socdev) |
| 662 | { |
| 663 | struct snd_soc_codec *codec = socdev->codec; |
| 664 | int ret = 0; |
| 665 | u16 reg; |
| 666 | |
| 667 | codec->name = "tlv320aic23"; |
| 668 | codec->owner = THIS_MODULE; |
| 669 | codec->read = tlv320aic23_read_reg_cache; |
| 670 | codec->write = tlv320aic23_write; |
| 671 | codec->set_bias_level = tlv320aic23_set_bias_level; |
| 672 | codec->dai = &tlv320aic23_dai; |
| 673 | codec->num_dai = 1; |
| 674 | codec->reg_cache_size = ARRAY_SIZE(tlv320aic23_reg); |
| 675 | codec->reg_cache = |
| 676 | kmemdup(tlv320aic23_reg, sizeof(tlv320aic23_reg), GFP_KERNEL); |
| 677 | if (codec->reg_cache == NULL) |
| 678 | return -ENOMEM; |
| 679 | |
| 680 | /* Reset codec */ |
| 681 | tlv320aic23_write(codec, TLV320AIC23_RESET, 0); |
| 682 | |
| 683 | /* register pcms */ |
| 684 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); |
| 685 | if (ret < 0) { |
| 686 | printk(KERN_ERR "tlv320aic23: failed to create pcms\n"); |
| 687 | goto pcm_err; |
| 688 | } |
| 689 | |
| 690 | /* power on device */ |
| 691 | tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
| 692 | |
| 693 | tlv320aic23_write(codec, TLV320AIC23_DIGT, TLV320AIC23_DEEMP_44K); |
| 694 | |
| 695 | /* Unmute input */ |
| 696 | reg = tlv320aic23_read_reg_cache(codec, TLV320AIC23_LINVOL); |
| 697 | tlv320aic23_write(codec, TLV320AIC23_LINVOL, |
| 698 | (reg & (~TLV320AIC23_LIM_MUTED)) | |
| 699 | (TLV320AIC23_LRS_ENABLED)); |
| 700 | |
| 701 | reg = tlv320aic23_read_reg_cache(codec, TLV320AIC23_RINVOL); |
| 702 | tlv320aic23_write(codec, TLV320AIC23_RINVOL, |
| 703 | (reg & (~TLV320AIC23_LIM_MUTED)) | |
| 704 | TLV320AIC23_LRS_ENABLED); |
| 705 | |
| 706 | reg = tlv320aic23_read_reg_cache(codec, TLV320AIC23_ANLG); |
| 707 | tlv320aic23_write(codec, TLV320AIC23_ANLG, |
| 708 | (reg) & (~TLV320AIC23_BYPASS_ON) & |
| 709 | (~TLV320AIC23_MICM_MUTED)); |
| 710 | |
| 711 | /* Default output volume */ |
| 712 | tlv320aic23_write(codec, TLV320AIC23_LCHNVOL, |
| 713 | TLV320AIC23_DEFAULT_OUT_VOL & |
| 714 | TLV320AIC23_OUT_VOL_MASK); |
| 715 | tlv320aic23_write(codec, TLV320AIC23_RCHNVOL, |
| 716 | TLV320AIC23_DEFAULT_OUT_VOL & |
| 717 | TLV320AIC23_OUT_VOL_MASK); |
| 718 | |
| 719 | tlv320aic23_write(codec, TLV320AIC23_ACTIVE, 0x1); |
| 720 | |
| 721 | tlv320aic23_add_controls(codec); |
| 722 | tlv320aic23_add_widgets(codec); |
Mark Brown | 968a602 | 2008-11-28 11:49:07 +0000 | [diff] [blame] | 723 | ret = snd_soc_init_card(socdev); |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 724 | if (ret < 0) { |
| 725 | printk(KERN_ERR "tlv320aic23: failed to register card\n"); |
| 726 | goto card_err; |
| 727 | } |
| 728 | |
| 729 | return ret; |
| 730 | |
| 731 | card_err: |
| 732 | snd_soc_free_pcms(socdev); |
| 733 | snd_soc_dapm_free(socdev); |
| 734 | pcm_err: |
| 735 | kfree(codec->reg_cache); |
| 736 | return ret; |
| 737 | } |
| 738 | static struct snd_soc_device *tlv320aic23_socdev; |
| 739 | |
| 740 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
| 741 | /* |
| 742 | * If the i2c layer weren't so broken, we could pass this kind of data |
| 743 | * around |
| 744 | */ |
| 745 | static int tlv320aic23_codec_probe(struct i2c_client *i2c, |
| 746 | const struct i2c_device_id *i2c_id) |
| 747 | { |
| 748 | struct snd_soc_device *socdev = tlv320aic23_socdev; |
| 749 | struct snd_soc_codec *codec = socdev->codec; |
| 750 | int ret; |
| 751 | |
| 752 | if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
| 753 | return -EINVAL; |
| 754 | |
| 755 | i2c_set_clientdata(i2c, codec); |
| 756 | codec->control_data = i2c; |
| 757 | |
| 758 | ret = tlv320aic23_init(socdev); |
| 759 | if (ret < 0) { |
| 760 | printk(KERN_ERR "tlv320aic23: failed to initialise AIC23\n"); |
| 761 | goto err; |
| 762 | } |
| 763 | return ret; |
| 764 | |
| 765 | err: |
| 766 | kfree(codec); |
| 767 | kfree(i2c); |
| 768 | return ret; |
| 769 | } |
| 770 | static int __exit tlv320aic23_i2c_remove(struct i2c_client *i2c) |
| 771 | { |
| 772 | put_device(&i2c->dev); |
| 773 | return 0; |
| 774 | } |
| 775 | |
| 776 | static const struct i2c_device_id tlv320aic23_id[] = { |
| 777 | {"tlv320aic23", 0}, |
| 778 | {} |
| 779 | }; |
| 780 | |
| 781 | MODULE_DEVICE_TABLE(i2c, tlv320aic23_id); |
| 782 | |
| 783 | static struct i2c_driver tlv320aic23_i2c_driver = { |
| 784 | .driver = { |
| 785 | .name = "tlv320aic23", |
| 786 | }, |
| 787 | .probe = tlv320aic23_codec_probe, |
| 788 | .remove = __exit_p(tlv320aic23_i2c_remove), |
| 789 | .id_table = tlv320aic23_id, |
| 790 | }; |
| 791 | |
| 792 | #endif |
| 793 | |
| 794 | static int tlv320aic23_probe(struct platform_device *pdev) |
| 795 | { |
| 796 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
| 797 | struct snd_soc_codec *codec; |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 798 | struct aic23 *aic23; |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 799 | int ret = 0; |
| 800 | |
| 801 | printk(KERN_INFO "AIC23 Audio Codec %s\n", AIC23_VERSION); |
| 802 | |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 803 | aic23 = kzalloc(sizeof(struct aic23), GFP_KERNEL); |
| 804 | if (aic23 == NULL) |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 805 | return -ENOMEM; |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 806 | codec = &aic23->codec; |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 807 | socdev->codec = codec; |
| 808 | mutex_init(&codec->mutex); |
| 809 | INIT_LIST_HEAD(&codec->dapm_widgets); |
| 810 | INIT_LIST_HEAD(&codec->dapm_paths); |
| 811 | |
| 812 | tlv320aic23_socdev = socdev; |
| 813 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
Arun KS | 4aa0239 | 2008-10-13 15:47:25 +0530 | [diff] [blame] | 814 | codec->hw_write = (hw_write_t) i2c_master_send; |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 815 | codec->hw_read = NULL; |
| 816 | ret = i2c_add_driver(&tlv320aic23_i2c_driver); |
| 817 | if (ret != 0) |
| 818 | printk(KERN_ERR "can't add i2c driver"); |
| 819 | #endif |
| 820 | return ret; |
| 821 | } |
| 822 | |
| 823 | static int tlv320aic23_remove(struct platform_device *pdev) |
| 824 | { |
| 825 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
| 826 | struct snd_soc_codec *codec = socdev->codec; |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 827 | struct aic23 *aic23 = container_of(codec, struct aic23, codec); |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 828 | |
| 829 | if (codec->control_data) |
| 830 | tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_OFF); |
| 831 | |
| 832 | snd_soc_free_pcms(socdev); |
| 833 | snd_soc_dapm_free(socdev); |
| 834 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
| 835 | i2c_del_driver(&tlv320aic23_i2c_driver); |
| 836 | #endif |
| 837 | kfree(codec->reg_cache); |
Troy Kisky | 26df91c | 2008-11-05 18:53:28 +0000 | [diff] [blame] | 838 | kfree(aic23); |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 839 | |
| 840 | return 0; |
| 841 | } |
| 842 | struct snd_soc_codec_device soc_codec_dev_tlv320aic23 = { |
| 843 | .probe = tlv320aic23_probe, |
| 844 | .remove = tlv320aic23_remove, |
| 845 | .suspend = tlv320aic23_suspend, |
| 846 | .resume = tlv320aic23_resume, |
| 847 | }; |
| 848 | EXPORT_SYMBOL_GPL(soc_codec_dev_tlv320aic23); |
| 849 | |
Mark Brown | 64089b8 | 2008-12-08 19:17:58 +0000 | [diff] [blame^] | 850 | static int __devinit tlv320aic23_modinit(void) |
| 851 | { |
| 852 | return snd_soc_register_dai(&tlv320aic23_dai); |
| 853 | } |
| 854 | module_init(tlv320aic23_modinit); |
| 855 | |
| 856 | static void __exit tlv320aic23_exit(void) |
| 857 | { |
| 858 | snd_soc_unregister_dai(&tlv320aic23_dai); |
| 859 | } |
| 860 | module_exit(tlv320aic23_exit); |
| 861 | |
Arun KS | c1f2719 | 2008-10-02 14:45:49 +0530 | [diff] [blame] | 862 | MODULE_DESCRIPTION("ASoC TLV320AIC23 codec driver"); |
| 863 | MODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>"); |
| 864 | MODULE_LICENSE("GPL"); |