Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 1 | /* |
| 2 | * sn95031.c - TI sn95031 Codec driver |
| 3 | * |
| 4 | * Copyright (C) 2010 Intel Corp |
| 5 | * Author: Vinod Koul <vinod.koul@intel.com> |
| 6 | * Author: Harsha Priya <priya.harsha@intel.com> |
| 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 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 as published by |
| 11 | * the Free Software Foundation; version 2 of the License. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
| 21 | * |
| 22 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 23 | * |
| 24 | * |
| 25 | */ |
| 26 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 27 | |
| 28 | #include <linux/platform_device.h> |
| 29 | #include <linux/slab.h> |
| 30 | #include <asm/intel_scu_ipc.h> |
| 31 | #include <sound/pcm.h> |
| 32 | #include <sound/pcm_params.h> |
| 33 | #include <sound/soc.h> |
| 34 | #include <sound/soc-dapm.h> |
| 35 | #include <sound/initval.h> |
Harsha Priya | fd94eee | 2011-01-28 22:26:53 +0530 | [diff] [blame] | 36 | #include <sound/tlv.h> |
Vinod Koul | 1e2f593 | 2011-02-09 21:44:32 +0530 | [diff] [blame^] | 37 | #include <sound/jack.h> |
Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 38 | #include "sn95031.h" |
| 39 | |
| 40 | #define SN95031_RATES (SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100) |
| 41 | #define SN95031_FORMATS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE) |
| 42 | |
| 43 | /* |
| 44 | * todo: |
| 45 | * capture paths |
| 46 | * jack detection |
| 47 | * PM functions |
| 48 | */ |
| 49 | |
| 50 | static inline unsigned int sn95031_read(struct snd_soc_codec *codec, |
| 51 | unsigned int reg) |
| 52 | { |
| 53 | u8 value = 0; |
| 54 | int ret; |
| 55 | |
| 56 | ret = intel_scu_ipc_ioread8(reg, &value); |
| 57 | if (ret) |
| 58 | pr_err("read of %x failed, err %d\n", reg, ret); |
| 59 | return value; |
| 60 | |
| 61 | } |
| 62 | |
| 63 | static inline int sn95031_write(struct snd_soc_codec *codec, |
| 64 | unsigned int reg, unsigned int value) |
| 65 | { |
| 66 | int ret; |
| 67 | |
| 68 | ret = intel_scu_ipc_iowrite8(reg, value); |
| 69 | if (ret) |
| 70 | pr_err("write of %x failed, err %d\n", reg, ret); |
| 71 | return ret; |
| 72 | } |
| 73 | |
| 74 | static int sn95031_set_vaud_bias(struct snd_soc_codec *codec, |
| 75 | enum snd_soc_bias_level level) |
| 76 | { |
| 77 | switch (level) { |
| 78 | case SND_SOC_BIAS_ON: |
| 79 | break; |
| 80 | |
| 81 | case SND_SOC_BIAS_PREPARE: |
| 82 | if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY) { |
| 83 | pr_debug("vaud_bias powering up pll\n"); |
| 84 | /* power up the pll */ |
| 85 | snd_soc_write(codec, SN95031_AUDPLLCTRL, BIT(5)); |
| 86 | /* enable pcm 2 */ |
| 87 | snd_soc_update_bits(codec, SN95031_PCM2C2, |
| 88 | BIT(0), BIT(0)); |
| 89 | } |
| 90 | break; |
| 91 | |
| 92 | case SND_SOC_BIAS_STANDBY: |
| 93 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { |
| 94 | pr_debug("vaud_bias power up rail\n"); |
| 95 | /* power up the rail */ |
| 96 | snd_soc_write(codec, SN95031_VAUD, |
| 97 | BIT(2)|BIT(1)|BIT(0)); |
| 98 | msleep(1); |
| 99 | } else if (codec->dapm.bias_level == SND_SOC_BIAS_PREPARE) { |
| 100 | /* turn off pcm */ |
| 101 | pr_debug("vaud_bias power dn pcm\n"); |
| 102 | snd_soc_update_bits(codec, SN95031_PCM2C2, BIT(0), 0); |
| 103 | snd_soc_write(codec, SN95031_AUDPLLCTRL, 0); |
| 104 | } |
| 105 | break; |
| 106 | |
| 107 | |
| 108 | case SND_SOC_BIAS_OFF: |
| 109 | pr_debug("vaud_bias _OFF doing rail shutdown\n"); |
| 110 | snd_soc_write(codec, SN95031_VAUD, BIT(3)); |
| 111 | break; |
| 112 | } |
| 113 | |
| 114 | codec->dapm.bias_level = level; |
| 115 | return 0; |
| 116 | } |
| 117 | |
| 118 | static int sn95031_vhs_event(struct snd_soc_dapm_widget *w, |
| 119 | struct snd_kcontrol *kcontrol, int event) |
| 120 | { |
| 121 | if (SND_SOC_DAPM_EVENT_ON(event)) { |
| 122 | pr_debug("VHS SND_SOC_DAPM_EVENT_ON doing rail startup now\n"); |
| 123 | /* power up the rail */ |
| 124 | snd_soc_write(w->codec, SN95031_VHSP, 0x3D); |
| 125 | snd_soc_write(w->codec, SN95031_VHSN, 0x3F); |
| 126 | msleep(1); |
| 127 | } else if (SND_SOC_DAPM_EVENT_OFF(event)) { |
| 128 | pr_debug("VHS SND_SOC_DAPM_EVENT_OFF doing rail shutdown\n"); |
| 129 | snd_soc_write(w->codec, SN95031_VHSP, 0xC4); |
| 130 | snd_soc_write(w->codec, SN95031_VHSN, 0x04); |
| 131 | } |
| 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | static int sn95031_vihf_event(struct snd_soc_dapm_widget *w, |
| 136 | struct snd_kcontrol *kcontrol, int event) |
| 137 | { |
| 138 | if (SND_SOC_DAPM_EVENT_ON(event)) { |
| 139 | pr_debug("VIHF SND_SOC_DAPM_EVENT_ON doing rail startup now\n"); |
| 140 | /* power up the rail */ |
| 141 | snd_soc_write(w->codec, SN95031_VIHF, 0x27); |
| 142 | msleep(1); |
| 143 | } else if (SND_SOC_DAPM_EVENT_OFF(event)) { |
| 144 | pr_debug("VIHF SND_SOC_DAPM_EVENT_OFF doing rail shutdown\n"); |
| 145 | snd_soc_write(w->codec, SN95031_VIHF, 0x24); |
| 146 | } |
| 147 | return 0; |
| 148 | } |
| 149 | |
Harsha Priya | fd94eee | 2011-01-28 22:26:53 +0530 | [diff] [blame] | 150 | static int sn95031_dmic12_event(struct snd_soc_dapm_widget *w, |
| 151 | struct snd_kcontrol *k, int event) |
| 152 | { |
| 153 | unsigned int ldo = 0, clk_dir = 0, data_dir = 0; |
| 154 | |
| 155 | if (SND_SOC_DAPM_EVENT_ON(event)) { |
| 156 | ldo = BIT(5)|BIT(4); |
| 157 | clk_dir = BIT(0); |
| 158 | data_dir = BIT(7); |
| 159 | } |
| 160 | /* program DMIC LDO, clock and set clock */ |
| 161 | snd_soc_update_bits(w->codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo); |
| 162 | snd_soc_update_bits(w->codec, SN95031_DMICBUF0123, BIT(0), clk_dir); |
| 163 | snd_soc_update_bits(w->codec, SN95031_DMICBUF0123, BIT(7), data_dir); |
| 164 | return 0; |
| 165 | } |
| 166 | |
| 167 | static int sn95031_dmic34_event(struct snd_soc_dapm_widget *w, |
| 168 | struct snd_kcontrol *k, int event) |
| 169 | { |
| 170 | unsigned int ldo = 0, clk_dir = 0, data_dir = 0; |
| 171 | |
| 172 | if (SND_SOC_DAPM_EVENT_ON(event)) { |
| 173 | ldo = BIT(5)|BIT(4); |
| 174 | clk_dir = BIT(2); |
| 175 | data_dir = BIT(1); |
| 176 | } |
| 177 | /* program DMIC LDO, clock and set clock */ |
| 178 | snd_soc_update_bits(w->codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo); |
| 179 | snd_soc_update_bits(w->codec, SN95031_DMICBUF0123, BIT(2), clk_dir); |
| 180 | snd_soc_update_bits(w->codec, SN95031_DMICBUF45, BIT(1), data_dir); |
| 181 | return 0; |
| 182 | } |
| 183 | |
| 184 | static int sn95031_dmic56_event(struct snd_soc_dapm_widget *w, |
| 185 | struct snd_kcontrol *k, int event) |
| 186 | { |
| 187 | unsigned int ldo = 0; |
| 188 | |
| 189 | if (SND_SOC_DAPM_EVENT_ON(event)) |
| 190 | ldo = BIT(7)|BIT(6); |
| 191 | |
| 192 | /* program DMIC LDO */ |
| 193 | snd_soc_update_bits(w->codec, SN95031_MICBIAS, BIT(7)|BIT(6), ldo); |
| 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | /* mux controls */ |
| 198 | static const char *sn95031_mic_texts[] = { "AMIC", "LineIn" }; |
| 199 | |
| 200 | static const struct soc_enum sn95031_micl_enum = |
| 201 | SOC_ENUM_SINGLE(SN95031_ADCCONFIG, 1, 2, sn95031_mic_texts); |
| 202 | |
| 203 | static const struct snd_kcontrol_new sn95031_micl_mux_control = |
| 204 | SOC_DAPM_ENUM("Route", sn95031_micl_enum); |
| 205 | |
| 206 | static const struct soc_enum sn95031_micr_enum = |
| 207 | SOC_ENUM_SINGLE(SN95031_ADCCONFIG, 3, 2, sn95031_mic_texts); |
| 208 | |
| 209 | static const struct snd_kcontrol_new sn95031_micr_mux_control = |
| 210 | SOC_DAPM_ENUM("Route", sn95031_micr_enum); |
| 211 | |
| 212 | static const char *sn95031_input_texts[] = { "DMIC1", "DMIC2", "DMIC3", |
| 213 | "DMIC4", "DMIC5", "DMIC6", |
| 214 | "ADC Left", "ADC Right" }; |
| 215 | |
| 216 | static const struct soc_enum sn95031_input1_enum = |
| 217 | SOC_ENUM_SINGLE(SN95031_AUDIOMUX12, 0, 8, sn95031_input_texts); |
| 218 | |
| 219 | static const struct snd_kcontrol_new sn95031_input1_mux_control = |
| 220 | SOC_DAPM_ENUM("Route", sn95031_input1_enum); |
| 221 | |
| 222 | static const struct soc_enum sn95031_input2_enum = |
| 223 | SOC_ENUM_SINGLE(SN95031_AUDIOMUX12, 4, 8, sn95031_input_texts); |
| 224 | |
| 225 | static const struct snd_kcontrol_new sn95031_input2_mux_control = |
| 226 | SOC_DAPM_ENUM("Route", sn95031_input2_enum); |
| 227 | |
| 228 | static const struct soc_enum sn95031_input3_enum = |
| 229 | SOC_ENUM_SINGLE(SN95031_AUDIOMUX34, 0, 8, sn95031_input_texts); |
| 230 | |
| 231 | static const struct snd_kcontrol_new sn95031_input3_mux_control = |
| 232 | SOC_DAPM_ENUM("Route", sn95031_input3_enum); |
| 233 | |
| 234 | static const struct soc_enum sn95031_input4_enum = |
| 235 | SOC_ENUM_SINGLE(SN95031_AUDIOMUX34, 4, 8, sn95031_input_texts); |
| 236 | |
| 237 | static const struct snd_kcontrol_new sn95031_input4_mux_control = |
| 238 | SOC_DAPM_ENUM("Route", sn95031_input4_enum); |
| 239 | |
| 240 | /* capture path controls */ |
| 241 | |
| 242 | static const char *sn95031_micmode_text[] = {"Single Ended", "Differential"}; |
| 243 | |
| 244 | /* 0dB to 30dB in 10dB steps */ |
| 245 | static const DECLARE_TLV_DB_SCALE(mic_tlv, 0, 10, 30); |
| 246 | |
| 247 | static const struct soc_enum sn95031_micmode1_enum = |
| 248 | SOC_ENUM_SINGLE(SN95031_MICAMP1, 1, 2, sn95031_micmode_text); |
| 249 | static const struct soc_enum sn95031_micmode2_enum = |
| 250 | SOC_ENUM_SINGLE(SN95031_MICAMP2, 1, 2, sn95031_micmode_text); |
| 251 | |
| 252 | static const char *sn95031_dmic_cfg_text[] = {"GPO", "DMIC"}; |
| 253 | |
| 254 | static const struct soc_enum sn95031_dmic12_cfg_enum = |
| 255 | SOC_ENUM_SINGLE(SN95031_DMICMUX, 0, 2, sn95031_dmic_cfg_text); |
| 256 | static const struct soc_enum sn95031_dmic34_cfg_enum = |
| 257 | SOC_ENUM_SINGLE(SN95031_DMICMUX, 1, 2, sn95031_dmic_cfg_text); |
| 258 | static const struct soc_enum sn95031_dmic56_cfg_enum = |
| 259 | SOC_ENUM_SINGLE(SN95031_DMICMUX, 2, 2, sn95031_dmic_cfg_text); |
| 260 | |
| 261 | static const struct snd_kcontrol_new sn95031_snd_controls[] = { |
| 262 | SOC_ENUM("Mic1Mode Capture Route", sn95031_micmode1_enum), |
| 263 | SOC_ENUM("Mic2Mode Capture Route", sn95031_micmode2_enum), |
| 264 | SOC_ENUM("DMIC12 Capture Route", sn95031_dmic12_cfg_enum), |
| 265 | SOC_ENUM("DMIC34 Capture Route", sn95031_dmic34_cfg_enum), |
| 266 | SOC_ENUM("DMIC56 Capture Route", sn95031_dmic56_cfg_enum), |
| 267 | SOC_SINGLE_TLV("Mic1 Capture Volume", SN95031_MICAMP1, |
| 268 | 2, 4, 0, mic_tlv), |
| 269 | SOC_SINGLE_TLV("Mic2 Capture Volume", SN95031_MICAMP2, |
| 270 | 2, 4, 0, mic_tlv), |
| 271 | }; |
| 272 | |
Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 273 | /* DAPM widgets */ |
| 274 | static const struct snd_soc_dapm_widget sn95031_dapm_widgets[] = { |
| 275 | |
| 276 | /* all end points mic, hs etc */ |
| 277 | SND_SOC_DAPM_OUTPUT("HPOUTL"), |
| 278 | SND_SOC_DAPM_OUTPUT("HPOUTR"), |
| 279 | SND_SOC_DAPM_OUTPUT("EPOUT"), |
| 280 | SND_SOC_DAPM_OUTPUT("IHFOUTL"), |
| 281 | SND_SOC_DAPM_OUTPUT("IHFOUTR"), |
| 282 | SND_SOC_DAPM_OUTPUT("LINEOUTL"), |
| 283 | SND_SOC_DAPM_OUTPUT("LINEOUTR"), |
| 284 | SND_SOC_DAPM_OUTPUT("VIB1OUT"), |
| 285 | SND_SOC_DAPM_OUTPUT("VIB2OUT"), |
| 286 | |
Harsha Priya | fd94eee | 2011-01-28 22:26:53 +0530 | [diff] [blame] | 287 | SND_SOC_DAPM_INPUT("AMIC1"), /* headset mic */ |
| 288 | SND_SOC_DAPM_INPUT("AMIC2"), |
| 289 | SND_SOC_DAPM_INPUT("DMIC1"), |
| 290 | SND_SOC_DAPM_INPUT("DMIC2"), |
| 291 | SND_SOC_DAPM_INPUT("DMIC3"), |
| 292 | SND_SOC_DAPM_INPUT("DMIC4"), |
| 293 | SND_SOC_DAPM_INPUT("DMIC5"), |
| 294 | SND_SOC_DAPM_INPUT("DMIC6"), |
| 295 | SND_SOC_DAPM_INPUT("LINEINL"), |
| 296 | SND_SOC_DAPM_INPUT("LINEINR"), |
| 297 | |
| 298 | SND_SOC_DAPM_MICBIAS("AMIC1Bias", SN95031_MICBIAS, 2, 0), |
| 299 | SND_SOC_DAPM_MICBIAS("AMIC2Bias", SN95031_MICBIAS, 3, 0), |
| 300 | SND_SOC_DAPM_MICBIAS("DMIC12Bias", SN95031_DMICMUX, 3, 0), |
| 301 | SND_SOC_DAPM_MICBIAS("DMIC34Bias", SN95031_DMICMUX, 4, 0), |
| 302 | SND_SOC_DAPM_MICBIAS("DMIC56Bias", SN95031_DMICMUX, 5, 0), |
| 303 | |
| 304 | SND_SOC_DAPM_SUPPLY("DMIC12supply", SN95031_DMICLK, 0, 0, |
| 305 | sn95031_dmic12_event, |
| 306 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 307 | SND_SOC_DAPM_SUPPLY("DMIC34supply", SN95031_DMICLK, 1, 0, |
| 308 | sn95031_dmic34_event, |
| 309 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 310 | SND_SOC_DAPM_SUPPLY("DMIC56supply", SN95031_DMICLK, 2, 0, |
| 311 | sn95031_dmic56_event, |
| 312 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 313 | |
| 314 | SND_SOC_DAPM_AIF_OUT("PCM_Out", "Capture", 0, |
| 315 | SND_SOC_NOPM, 0, 0), |
| 316 | |
Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 317 | SND_SOC_DAPM_SUPPLY("Headset Rail", SND_SOC_NOPM, 0, 0, |
| 318 | sn95031_vhs_event, |
| 319 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 320 | SND_SOC_DAPM_SUPPLY("Speaker Rail", SND_SOC_NOPM, 0, 0, |
| 321 | sn95031_vihf_event, |
| 322 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), |
| 323 | |
| 324 | /* playback path driver enables */ |
| 325 | SND_SOC_DAPM_PGA("Headset Left Playback", |
| 326 | SN95031_DRIVEREN, 0, 0, NULL, 0), |
| 327 | SND_SOC_DAPM_PGA("Headset Right Playback", |
| 328 | SN95031_DRIVEREN, 1, 0, NULL, 0), |
| 329 | SND_SOC_DAPM_PGA("Speaker Left Playback", |
| 330 | SN95031_DRIVEREN, 2, 0, NULL, 0), |
| 331 | SND_SOC_DAPM_PGA("Speaker Right Playback", |
| 332 | SN95031_DRIVEREN, 3, 0, NULL, 0), |
| 333 | SND_SOC_DAPM_PGA("Vibra1 Playback", |
| 334 | SN95031_DRIVEREN, 4, 0, NULL, 0), |
| 335 | SND_SOC_DAPM_PGA("Vibra2 Playback", |
| 336 | SN95031_DRIVEREN, 5, 0, NULL, 0), |
| 337 | SND_SOC_DAPM_PGA("Earpiece Playback", |
| 338 | SN95031_DRIVEREN, 6, 0, NULL, 0), |
| 339 | SND_SOC_DAPM_PGA("Lineout Left Playback", |
| 340 | SN95031_LOCTL, 0, 0, NULL, 0), |
| 341 | SND_SOC_DAPM_PGA("Lineout Right Playback", |
| 342 | SN95031_LOCTL, 4, 0, NULL, 0), |
| 343 | |
| 344 | /* playback path filter enable */ |
| 345 | SND_SOC_DAPM_PGA("Headset Left Filter", |
| 346 | SN95031_HSEPRXCTRL, 4, 0, NULL, 0), |
| 347 | SND_SOC_DAPM_PGA("Headset Right Filter", |
| 348 | SN95031_HSEPRXCTRL, 5, 0, NULL, 0), |
| 349 | SND_SOC_DAPM_PGA("Speaker Left Filter", |
| 350 | SN95031_IHFRXCTRL, 0, 0, NULL, 0), |
| 351 | SND_SOC_DAPM_PGA("Speaker Right Filter", |
| 352 | SN95031_IHFRXCTRL, 1, 0, NULL, 0), |
| 353 | |
| 354 | /* DACs */ |
| 355 | SND_SOC_DAPM_DAC("HSDAC Left", "Headset", |
| 356 | SN95031_DACCONFIG, 0, 0), |
| 357 | SND_SOC_DAPM_DAC("HSDAC Right", "Headset", |
| 358 | SN95031_DACCONFIG, 1, 0), |
| 359 | SND_SOC_DAPM_DAC("IHFDAC Left", "Speaker", |
| 360 | SN95031_DACCONFIG, 2, 0), |
| 361 | SND_SOC_DAPM_DAC("IHFDAC Right", "Speaker", |
| 362 | SN95031_DACCONFIG, 3, 0), |
| 363 | SND_SOC_DAPM_DAC("Vibra1 DAC", "Vibra1", |
| 364 | SN95031_VIB1C5, 1, 0), |
| 365 | SND_SOC_DAPM_DAC("Vibra2 DAC", "Vibra2", |
| 366 | SN95031_VIB2C5, 1, 0), |
Harsha Priya | fd94eee | 2011-01-28 22:26:53 +0530 | [diff] [blame] | 367 | |
| 368 | /* capture widgets */ |
| 369 | SND_SOC_DAPM_PGA("LineIn Enable Left", SN95031_MICAMP1, |
| 370 | 7, 0, NULL, 0), |
| 371 | SND_SOC_DAPM_PGA("LineIn Enable Right", SN95031_MICAMP2, |
| 372 | 7, 0, NULL, 0), |
| 373 | |
| 374 | SND_SOC_DAPM_PGA("MIC1 Enable", SN95031_MICAMP1, 0, 0, NULL, 0), |
| 375 | SND_SOC_DAPM_PGA("MIC2 Enable", SN95031_MICAMP2, 0, 0, NULL, 0), |
| 376 | SND_SOC_DAPM_PGA("TX1 Enable", SN95031_AUDIOTXEN, 2, 0, NULL, 0), |
| 377 | SND_SOC_DAPM_PGA("TX2 Enable", SN95031_AUDIOTXEN, 3, 0, NULL, 0), |
| 378 | SND_SOC_DAPM_PGA("TX3 Enable", SN95031_AUDIOTXEN, 4, 0, NULL, 0), |
| 379 | SND_SOC_DAPM_PGA("TX4 Enable", SN95031_AUDIOTXEN, 5, 0, NULL, 0), |
| 380 | |
| 381 | /* ADC have null stream as they will be turned ON by TX path */ |
| 382 | SND_SOC_DAPM_ADC("ADC Left", NULL, |
| 383 | SN95031_ADCCONFIG, 0, 0), |
| 384 | SND_SOC_DAPM_ADC("ADC Right", NULL, |
| 385 | SN95031_ADCCONFIG, 2, 0), |
| 386 | |
| 387 | SND_SOC_DAPM_MUX("Mic_InputL Capture Route", |
| 388 | SND_SOC_NOPM, 0, 0, &sn95031_micl_mux_control), |
| 389 | SND_SOC_DAPM_MUX("Mic_InputR Capture Route", |
| 390 | SND_SOC_NOPM, 0, 0, &sn95031_micr_mux_control), |
| 391 | |
| 392 | SND_SOC_DAPM_MUX("Txpath1 Capture Route", |
| 393 | SND_SOC_NOPM, 0, 0, &sn95031_input1_mux_control), |
| 394 | SND_SOC_DAPM_MUX("Txpath2 Capture Route", |
| 395 | SND_SOC_NOPM, 0, 0, &sn95031_input2_mux_control), |
| 396 | SND_SOC_DAPM_MUX("Txpath3 Capture Route", |
| 397 | SND_SOC_NOPM, 0, 0, &sn95031_input3_mux_control), |
| 398 | SND_SOC_DAPM_MUX("Txpath4 Capture Route", |
| 399 | SND_SOC_NOPM, 0, 0, &sn95031_input4_mux_control), |
| 400 | |
Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 401 | }; |
| 402 | |
| 403 | static const struct snd_soc_dapm_route sn95031_audio_map[] = { |
| 404 | /* headset and earpiece map */ |
| 405 | { "HPOUTL", NULL, "Headset Left Playback" }, |
| 406 | { "HPOUTR", NULL, "Headset Right Playback" }, |
| 407 | { "EPOUT", NULL, "Earpiece Playback" }, |
| 408 | { "Headset Left Playback", NULL, "Headset Left Filter"}, |
| 409 | { "Headset Right Playback", NULL, "Headset Right Filter"}, |
| 410 | { "Earpiece Playback", NULL, "Headset Left Filter"}, |
| 411 | { "Headset Left Filter", NULL, "HSDAC Left"}, |
| 412 | { "Headset Right Filter", NULL, "HSDAC Right"}, |
| 413 | { "HSDAC Left", NULL, "Headset Rail"}, |
| 414 | { "HSDAC Right", NULL, "Headset Rail"}, |
| 415 | |
| 416 | /* speaker map */ |
| 417 | { "IHFOUTL", "NULL", "Speaker Left Playback"}, |
| 418 | { "IHFOUTR", "NULL", "Speaker Right Playback"}, |
| 419 | { "Speaker Left Playback", NULL, "Speaker Left Filter"}, |
| 420 | { "Speaker Right Playback", NULL, "Speaker Right Filter"}, |
| 421 | { "Speaker Left Filter", NULL, "IHFDAC Left"}, |
| 422 | { "Speaker Right Filter", NULL, "IHFDAC Right"}, |
| 423 | { "IHFDAC Left", NULL, "Speaker Rail"}, |
| 424 | { "IHFDAC Right", NULL, "Speaker Rail"}, |
| 425 | |
| 426 | /* vibra map */ |
Vinod Koul | b22dab8 | 2011-01-07 16:20:28 +0530 | [diff] [blame] | 427 | { "VIB1OUT", NULL, "Vibra1 Playback"}, |
| 428 | { "Vibra1 Playback", NULL, "Vibra1 DAC"}, |
Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 429 | |
Vinod Koul | b22dab8 | 2011-01-07 16:20:28 +0530 | [diff] [blame] | 430 | { "VIB2OUT", NULL, "Vibra2 Playback"}, |
| 431 | { "Vibra2 Playback", NULL, "Vibra2 DAC"}, |
Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 432 | |
| 433 | /* lineout */ |
Vinod Koul | b22dab8 | 2011-01-07 16:20:28 +0530 | [diff] [blame] | 434 | { "LINEOUTL", NULL, "Lineout Left Playback"}, |
| 435 | { "LINEOUTR", NULL, "Lineout Right Playback"}, |
| 436 | { "Lineout Left Playback", NULL, "Headset Left Filter"}, |
| 437 | { "Lineout Left Playback", NULL, "Speaker Left Filter"}, |
| 438 | { "Lineout Left Playback", NULL, "Vibra1 DAC"}, |
| 439 | { "Lineout Right Playback", NULL, "Headset Right Filter"}, |
| 440 | { "Lineout Right Playback", NULL, "Speaker Right Filter"}, |
| 441 | { "Lineout Right Playback", NULL, "Vibra2 DAC"}, |
Harsha Priya | fd94eee | 2011-01-28 22:26:53 +0530 | [diff] [blame] | 442 | |
| 443 | /* Headset (AMIC1) mic */ |
| 444 | { "AMIC1Bias", NULL, "AMIC1"}, |
| 445 | { "MIC1 Enable", NULL, "AMIC1Bias"}, |
| 446 | { "Mic_InputL Capture Route", "AMIC", "MIC1 Enable"}, |
| 447 | |
| 448 | /* AMIC2 */ |
| 449 | { "AMIC2Bias", NULL, "AMIC2"}, |
| 450 | { "MIC2 Enable", NULL, "AMIC2Bias"}, |
| 451 | { "Mic_InputR Capture Route", "AMIC", "MIC2 Enable"}, |
| 452 | |
| 453 | |
| 454 | /* Linein */ |
| 455 | { "LineIn Enable Left", NULL, "LINEINL"}, |
| 456 | { "LineIn Enable Right", NULL, "LINEINR"}, |
| 457 | { "Mic_InputL Capture Route", "LineIn", "LineIn Enable Left"}, |
| 458 | { "Mic_InputR Capture Route", "LineIn", "LineIn Enable Right"}, |
| 459 | |
| 460 | /* ADC connection */ |
| 461 | { "ADC Left", NULL, "Mic_InputL Capture Route"}, |
| 462 | { "ADC Right", NULL, "Mic_InputR Capture Route"}, |
| 463 | |
| 464 | /*DMIC connections */ |
| 465 | { "DMIC1", NULL, "DMIC12supply"}, |
| 466 | { "DMIC2", NULL, "DMIC12supply"}, |
| 467 | { "DMIC3", NULL, "DMIC34supply"}, |
| 468 | { "DMIC4", NULL, "DMIC34supply"}, |
| 469 | { "DMIC5", NULL, "DMIC56supply"}, |
| 470 | { "DMIC6", NULL, "DMIC56supply"}, |
| 471 | |
| 472 | { "DMIC12Bias", NULL, "DMIC1"}, |
| 473 | { "DMIC12Bias", NULL, "DMIC2"}, |
| 474 | { "DMIC34Bias", NULL, "DMIC3"}, |
| 475 | { "DMIC34Bias", NULL, "DMIC4"}, |
| 476 | { "DMIC56Bias", NULL, "DMIC5"}, |
| 477 | { "DMIC56Bias", NULL, "DMIC6"}, |
| 478 | |
| 479 | /*TX path inputs*/ |
| 480 | { "Txpath1 Capture Route", "ADC Left", "ADC Left"}, |
| 481 | { "Txpath2 Capture Route", "ADC Left", "ADC Left"}, |
| 482 | { "Txpath3 Capture Route", "ADC Left", "ADC Left"}, |
| 483 | { "Txpath4 Capture Route", "ADC Left", "ADC Left"}, |
| 484 | { "Txpath1 Capture Route", "ADC Right", "ADC Right"}, |
| 485 | { "Txpath2 Capture Route", "ADC Right", "ADC Right"}, |
| 486 | { "Txpath3 Capture Route", "ADC Right", "ADC Right"}, |
| 487 | { "Txpath4 Capture Route", "ADC Right", "ADC Right"}, |
| 488 | { "Txpath1 Capture Route", NULL, "DMIC1"}, |
| 489 | { "Txpath2 Capture Route", NULL, "DMIC1"}, |
| 490 | { "Txpath3 Capture Route", NULL, "DMIC1"}, |
| 491 | { "Txpath4 Capture Route", NULL, "DMIC1"}, |
| 492 | { "Txpath1 Capture Route", NULL, "DMIC2"}, |
| 493 | { "Txpath2 Capture Route", NULL, "DMIC2"}, |
| 494 | { "Txpath3 Capture Route", NULL, "DMIC2"}, |
| 495 | { "Txpath4 Capture Route", NULL, "DMIC2"}, |
| 496 | { "Txpath1 Capture Route", NULL, "DMIC3"}, |
| 497 | { "Txpath2 Capture Route", NULL, "DMIC3"}, |
| 498 | { "Txpath3 Capture Route", NULL, "DMIC3"}, |
| 499 | { "Txpath4 Capture Route", NULL, "DMIC3"}, |
| 500 | { "Txpath1 Capture Route", NULL, "DMIC4"}, |
| 501 | { "Txpath2 Capture Route", NULL, "DMIC4"}, |
| 502 | { "Txpath3 Capture Route", NULL, "DMIC4"}, |
| 503 | { "Txpath4 Capture Route", NULL, "DMIC4"}, |
| 504 | { "Txpath1 Capture Route", NULL, "DMIC5"}, |
| 505 | { "Txpath2 Capture Route", NULL, "DMIC5"}, |
| 506 | { "Txpath3 Capture Route", NULL, "DMIC5"}, |
| 507 | { "Txpath4 Capture Route", NULL, "DMIC5"}, |
| 508 | { "Txpath1 Capture Route", NULL, "DMIC6"}, |
| 509 | { "Txpath2 Capture Route", NULL, "DMIC6"}, |
| 510 | { "Txpath3 Capture Route", NULL, "DMIC6"}, |
| 511 | { "Txpath4 Capture Route", NULL, "DMIC6"}, |
| 512 | |
| 513 | /* tx path */ |
| 514 | { "TX1 Enable", NULL, "Txpath1 Capture Route"}, |
| 515 | { "TX2 Enable", NULL, "Txpath2 Capture Route"}, |
| 516 | { "TX3 Enable", NULL, "Txpath3 Capture Route"}, |
| 517 | { "TX4 Enable", NULL, "Txpath4 Capture Route"}, |
| 518 | { "PCM_Out", NULL, "TX1 Enable"}, |
| 519 | { "PCM_Out", NULL, "TX2 Enable"}, |
| 520 | { "PCM_Out", NULL, "TX3 Enable"}, |
| 521 | { "PCM_Out", NULL, "TX4 Enable"}, |
| 522 | |
Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 523 | }; |
| 524 | |
| 525 | /* speaker and headset mutes, for audio pops and clicks */ |
| 526 | static int sn95031_pcm_hs_mute(struct snd_soc_dai *dai, int mute) |
| 527 | { |
| 528 | snd_soc_update_bits(dai->codec, |
| 529 | SN95031_HSLVOLCTRL, BIT(7), (!mute << 7)); |
| 530 | snd_soc_update_bits(dai->codec, |
| 531 | SN95031_HSRVOLCTRL, BIT(7), (!mute << 7)); |
| 532 | return 0; |
| 533 | } |
| 534 | |
| 535 | static int sn95031_pcm_spkr_mute(struct snd_soc_dai *dai, int mute) |
| 536 | { |
| 537 | snd_soc_update_bits(dai->codec, |
| 538 | SN95031_IHFLVOLCTRL, BIT(7), (!mute << 7)); |
| 539 | snd_soc_update_bits(dai->codec, |
| 540 | SN95031_IHFRVOLCTRL, BIT(7), (!mute << 7)); |
| 541 | return 0; |
| 542 | } |
| 543 | |
| 544 | int sn95031_pcm_hw_params(struct snd_pcm_substream *substream, |
| 545 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) |
| 546 | { |
| 547 | unsigned int format, rate; |
| 548 | |
| 549 | switch (params_format(params)) { |
| 550 | case SNDRV_PCM_FORMAT_S16_LE: |
| 551 | format = BIT(4)|BIT(5); |
| 552 | break; |
| 553 | |
| 554 | case SNDRV_PCM_FORMAT_S24_LE: |
| 555 | format = 0; |
| 556 | break; |
| 557 | default: |
| 558 | return -EINVAL; |
| 559 | } |
| 560 | snd_soc_update_bits(dai->codec, SN95031_PCM2C2, |
| 561 | BIT(4)|BIT(5), format); |
| 562 | |
| 563 | switch (params_rate(params)) { |
| 564 | case 48000: |
| 565 | pr_debug("RATE_48000\n"); |
| 566 | rate = 0; |
| 567 | break; |
| 568 | |
| 569 | case 44100: |
| 570 | pr_debug("RATE_44100\n"); |
| 571 | rate = BIT(7); |
| 572 | break; |
| 573 | |
| 574 | default: |
| 575 | pr_err("ERR rate %d\n", params_rate(params)); |
| 576 | return -EINVAL; |
| 577 | } |
| 578 | snd_soc_update_bits(dai->codec, SN95031_PCM1C1, BIT(7), rate); |
| 579 | |
| 580 | return 0; |
| 581 | } |
| 582 | |
| 583 | /* Codec DAI section */ |
| 584 | static struct snd_soc_dai_ops sn95031_headset_dai_ops = { |
| 585 | .digital_mute = sn95031_pcm_hs_mute, |
| 586 | .hw_params = sn95031_pcm_hw_params, |
| 587 | }; |
| 588 | |
| 589 | static struct snd_soc_dai_ops sn95031_speaker_dai_ops = { |
| 590 | .digital_mute = sn95031_pcm_spkr_mute, |
| 591 | .hw_params = sn95031_pcm_hw_params, |
| 592 | }; |
| 593 | |
| 594 | static struct snd_soc_dai_ops sn95031_vib1_dai_ops = { |
| 595 | .hw_params = sn95031_pcm_hw_params, |
| 596 | }; |
| 597 | |
| 598 | static struct snd_soc_dai_ops sn95031_vib2_dai_ops = { |
| 599 | .hw_params = sn95031_pcm_hw_params, |
| 600 | }; |
| 601 | |
| 602 | struct snd_soc_dai_driver sn95031_dais[] = { |
| 603 | { |
| 604 | .name = "SN95031 Headset", |
| 605 | .playback = { |
| 606 | .stream_name = "Headset", |
| 607 | .channels_min = 2, |
| 608 | .channels_max = 2, |
| 609 | .rates = SN95031_RATES, |
| 610 | .formats = SN95031_FORMATS, |
| 611 | }, |
Harsha Priya | fd94eee | 2011-01-28 22:26:53 +0530 | [diff] [blame] | 612 | .capture = { |
| 613 | .stream_name = "Capture", |
| 614 | .channels_min = 1, |
| 615 | .channels_max = 5, |
| 616 | .rates = SN95031_RATES, |
| 617 | .formats = SN95031_FORMATS, |
| 618 | }, |
Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 619 | .ops = &sn95031_headset_dai_ops, |
| 620 | }, |
| 621 | { .name = "SN95031 Speaker", |
| 622 | .playback = { |
| 623 | .stream_name = "Speaker", |
| 624 | .channels_min = 2, |
| 625 | .channels_max = 2, |
| 626 | .rates = SN95031_RATES, |
| 627 | .formats = SN95031_FORMATS, |
| 628 | }, |
| 629 | .ops = &sn95031_speaker_dai_ops, |
| 630 | }, |
| 631 | { .name = "SN95031 Vibra1", |
| 632 | .playback = { |
| 633 | .stream_name = "Vibra1", |
| 634 | .channels_min = 1, |
| 635 | .channels_max = 1, |
| 636 | .rates = SN95031_RATES, |
| 637 | .formats = SN95031_FORMATS, |
| 638 | }, |
| 639 | .ops = &sn95031_vib1_dai_ops, |
| 640 | }, |
| 641 | { .name = "SN95031 Vibra2", |
| 642 | .playback = { |
| 643 | .stream_name = "Vibra2", |
| 644 | .channels_min = 1, |
| 645 | .channels_max = 1, |
| 646 | .rates = SN95031_RATES, |
| 647 | .formats = SN95031_FORMATS, |
| 648 | }, |
| 649 | .ops = &sn95031_vib2_dai_ops, |
| 650 | }, |
| 651 | }; |
| 652 | |
Vinod Koul | 1e2f593 | 2011-02-09 21:44:32 +0530 | [diff] [blame^] | 653 | static inline void sn95031_disable_jack_btn(struct snd_soc_codec *codec) |
| 654 | { |
| 655 | snd_soc_write(codec, SN95031_BTNCTRL2, 0x00); |
| 656 | } |
| 657 | |
| 658 | static inline void sn95031_enable_jack_btn(struct snd_soc_codec *codec) |
| 659 | { |
| 660 | snd_soc_write(codec, SN95031_BTNCTRL1, 0x77); |
| 661 | snd_soc_write(codec, SN95031_BTNCTRL2, 0x01); |
| 662 | } |
| 663 | |
| 664 | static int sn95031_get_headset_state(struct snd_soc_jack *mfld_jack) |
| 665 | { |
| 666 | /* Defaulting to HEADSET for now. |
| 667 | * will change after adding soc-jack detection apis */ |
| 668 | int jack_type = SND_JACK_HEADSET; |
| 669 | |
| 670 | pr_debug("jack type detected = %d\n", jack_type); |
| 671 | if (jack_type == SND_JACK_HEADSET) |
| 672 | sn95031_enable_jack_btn(mfld_jack->codec); |
| 673 | return jack_type; |
| 674 | } |
| 675 | |
| 676 | void sn95031_jack_detection(struct mfld_jack_data *jack_data) |
| 677 | { |
| 678 | unsigned int status; |
| 679 | unsigned int mask = SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_HEADSET; |
| 680 | |
| 681 | pr_debug("interrupt id read in sram = 0x%x\n", jack_data->intr_id); |
| 682 | if (jack_data->intr_id & 0x1) { |
| 683 | pr_debug("short_push detected\n"); |
| 684 | status = SND_JACK_HEADSET | SND_JACK_BTN_0; |
| 685 | } else if (jack_data->intr_id & 0x2) { |
| 686 | pr_debug("long_push detected\n"); |
| 687 | status = SND_JACK_HEADSET | SND_JACK_BTN_1; |
| 688 | } else if (jack_data->intr_id & 0x4) { |
| 689 | pr_debug("headset or headphones inserted\n"); |
| 690 | status = sn95031_get_headset_state(jack_data->mfld_jack); |
| 691 | } else if (jack_data->intr_id & 0x8) { |
| 692 | pr_debug("headset or headphones removed\n"); |
| 693 | status = 0; |
| 694 | sn95031_disable_jack_btn(jack_data->mfld_jack->codec); |
| 695 | } else { |
| 696 | pr_err("unidentified interrupt\n"); |
| 697 | return; |
| 698 | } |
| 699 | |
| 700 | snd_soc_jack_report(jack_data->mfld_jack, status, mask); |
| 701 | /*button pressed and released so we send explicit button release */ |
| 702 | if ((status & SND_JACK_BTN_0) | (status & SND_JACK_BTN_1)) |
| 703 | snd_soc_jack_report(jack_data->mfld_jack, |
| 704 | SND_JACK_HEADSET, mask); |
| 705 | } |
| 706 | EXPORT_SYMBOL_GPL(sn95031_jack_detection); |
| 707 | |
Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 708 | /* codec registration */ |
| 709 | static int sn95031_codec_probe(struct snd_soc_codec *codec) |
| 710 | { |
| 711 | int ret; |
| 712 | |
| 713 | pr_debug("codec_probe called\n"); |
| 714 | |
| 715 | codec->dapm.bias_level = SND_SOC_BIAS_OFF; |
| 716 | codec->dapm.idle_bias_off = 1; |
| 717 | |
| 718 | /* PCM interface config |
| 719 | * This sets the pcm rx slot conguration to max 6 slots |
| 720 | * for max 4 dais (2 stereo and 2 mono) |
| 721 | */ |
| 722 | snd_soc_write(codec, SN95031_PCM2RXSLOT01, 0x10); |
| 723 | snd_soc_write(codec, SN95031_PCM2RXSLOT23, 0x32); |
| 724 | snd_soc_write(codec, SN95031_PCM2RXSLOT45, 0x54); |
Harsha Priya | fd94eee | 2011-01-28 22:26:53 +0530 | [diff] [blame] | 725 | snd_soc_write(codec, SN95031_PCM2TXSLOT01, 0x10); |
| 726 | snd_soc_write(codec, SN95031_PCM2TXSLOT23, 0x32); |
Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 727 | /* pcm port setting |
| 728 | * This sets the pcm port to slave and clock at 19.2Mhz which |
| 729 | * can support 6slots, sampling rate set per stream in hw-params |
| 730 | */ |
| 731 | snd_soc_write(codec, SN95031_PCM1C1, 0x00); |
| 732 | snd_soc_write(codec, SN95031_PCM2C1, 0x01); |
| 733 | snd_soc_write(codec, SN95031_PCM2C2, 0x0A); |
| 734 | snd_soc_write(codec, SN95031_HSMIXER, BIT(0)|BIT(4)); |
| 735 | /* vendor vibra workround, the vibras are muted by |
| 736 | * custom register so unmute them |
| 737 | */ |
| 738 | snd_soc_write(codec, SN95031_SSR5, 0x80); |
| 739 | snd_soc_write(codec, SN95031_SSR6, 0x80); |
| 740 | snd_soc_write(codec, SN95031_VIB1C5, 0x00); |
| 741 | snd_soc_write(codec, SN95031_VIB2C5, 0x00); |
| 742 | /* configure vibras for pcm port */ |
| 743 | snd_soc_write(codec, SN95031_VIB1C3, 0x00); |
| 744 | snd_soc_write(codec, SN95031_VIB2C3, 0x00); |
| 745 | |
| 746 | /* soft mute ramp time */ |
| 747 | snd_soc_write(codec, SN95031_SOFTMUTE, 0x3); |
| 748 | /* fix the initial volume at 1dB, |
| 749 | * default in +9dB, |
| 750 | * 1dB give optimal swing on DAC, amps |
| 751 | */ |
| 752 | snd_soc_write(codec, SN95031_HSLVOLCTRL, 0x08); |
| 753 | snd_soc_write(codec, SN95031_HSRVOLCTRL, 0x08); |
| 754 | snd_soc_write(codec, SN95031_IHFLVOLCTRL, 0x08); |
| 755 | snd_soc_write(codec, SN95031_IHFRVOLCTRL, 0x08); |
| 756 | /* dac mode and lineout workaround */ |
| 757 | snd_soc_write(codec, SN95031_SSR2, 0x10); |
| 758 | snd_soc_write(codec, SN95031_SSR3, 0x40); |
| 759 | |
Harsha Priya | fd94eee | 2011-01-28 22:26:53 +0530 | [diff] [blame] | 760 | snd_soc_add_controls(codec, sn95031_snd_controls, |
| 761 | ARRAY_SIZE(sn95031_snd_controls)); |
| 762 | |
Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 763 | ret = snd_soc_dapm_new_controls(&codec->dapm, sn95031_dapm_widgets, |
| 764 | ARRAY_SIZE(sn95031_dapm_widgets)); |
| 765 | if (ret) |
| 766 | pr_err("soc_dapm_new_control failed %d", ret); |
| 767 | ret = snd_soc_dapm_add_routes(&codec->dapm, sn95031_audio_map, |
| 768 | ARRAY_SIZE(sn95031_audio_map)); |
| 769 | if (ret) |
| 770 | pr_err("soc_dapm_add_routes failed %d", ret); |
| 771 | |
| 772 | return ret; |
| 773 | } |
| 774 | |
| 775 | static int sn95031_codec_remove(struct snd_soc_codec *codec) |
| 776 | { |
| 777 | pr_debug("codec_remove called\n"); |
| 778 | sn95031_set_vaud_bias(codec, SND_SOC_BIAS_OFF); |
| 779 | |
| 780 | return 0; |
| 781 | } |
| 782 | |
| 783 | struct snd_soc_codec_driver sn95031_codec = { |
Vinod Koul | b22dab8 | 2011-01-07 16:20:28 +0530 | [diff] [blame] | 784 | .probe = sn95031_codec_probe, |
| 785 | .remove = sn95031_codec_remove, |
Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 786 | .read = sn95031_read, |
| 787 | .write = sn95031_write, |
| 788 | .set_bias_level = sn95031_set_vaud_bias, |
| 789 | }; |
| 790 | |
| 791 | static int __devinit sn95031_device_probe(struct platform_device *pdev) |
| 792 | { |
| 793 | pr_debug("codec device probe called for %s\n", dev_name(&pdev->dev)); |
| 794 | return snd_soc_register_codec(&pdev->dev, &sn95031_codec, |
| 795 | sn95031_dais, ARRAY_SIZE(sn95031_dais)); |
| 796 | } |
| 797 | |
| 798 | static int __devexit sn95031_device_remove(struct platform_device *pdev) |
| 799 | { |
| 800 | pr_debug("codec device remove called\n"); |
| 801 | snd_soc_unregister_codec(&pdev->dev); |
| 802 | return 0; |
| 803 | } |
| 804 | |
| 805 | static struct platform_driver sn95031_codec_driver = { |
| 806 | .driver = { |
| 807 | .name = "sn95031", |
| 808 | .owner = THIS_MODULE, |
| 809 | }, |
| 810 | .probe = sn95031_device_probe, |
| 811 | .remove = sn95031_device_remove, |
| 812 | }; |
| 813 | |
| 814 | static int __init sn95031_init(void) |
| 815 | { |
| 816 | pr_debug("driver init called\n"); |
| 817 | return platform_driver_register(&sn95031_codec_driver); |
| 818 | } |
| 819 | module_init(sn95031_init); |
| 820 | |
| 821 | static void __exit sn95031_exit(void) |
| 822 | { |
| 823 | pr_debug("driver exit called\n"); |
| 824 | platform_driver_unregister(&sn95031_codec_driver); |
| 825 | } |
| 826 | module_exit(sn95031_exit); |
| 827 | |
Vinod Koul | b22dab8 | 2011-01-07 16:20:28 +0530 | [diff] [blame] | 828 | MODULE_DESCRIPTION("ASoC TI SN95031 codec driver"); |
Vinod Koul | 4dc69be | 2011-01-04 20:16:07 +0530 | [diff] [blame] | 829 | MODULE_AUTHOR("Vinod Koul <vinod.koul@intel.com>"); |
| 830 | MODULE_AUTHOR("Harsha Priya <priya.harsha@intel.com>"); |
| 831 | MODULE_LICENSE("GPL v2"); |
| 832 | MODULE_ALIAS("platform:sn95031"); |