diff options
-rw-r--r-- | sound/soc/codecs/Kconfig | 4 | ||||
-rw-r--r-- | sound/soc/codecs/Makefile | 4 | ||||
-rw-r--r-- | sound/soc/codecs/ad1938.c | 521 | ||||
-rw-r--r-- | sound/soc/codecs/ad1938.h | 100 | ||||
-rw-r--r-- | sound/soc/codecs/ad193x.c | 560 | ||||
-rw-r--r-- | sound/soc/codecs/ad193x.h | 83 |
6 files changed, 647 insertions, 625 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 398cbb0e79fd..bc0ab47e156b 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
@@ -13,7 +13,7 @@ config SND_SOC_ALL_CODECS | |||
13 | select SND_SOC_L3 | 13 | select SND_SOC_L3 |
14 | select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS | 14 | select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS |
15 | select SND_SOC_AD1836 if SPI_MASTER | 15 | select SND_SOC_AD1836 if SPI_MASTER |
16 | select SND_SOC_AD1938 if SPI_MASTER | 16 | select SND_SOC_AD193X if SND_SOC_I2C_AND_SPI |
17 | select SND_SOC_AD1980 if SND_SOC_AC97_BUS | 17 | select SND_SOC_AD1980 if SND_SOC_AC97_BUS |
18 | select SND_SOC_ADS117X | 18 | select SND_SOC_ADS117X |
19 | select SND_SOC_AD73311 if I2C | 19 | select SND_SOC_AD73311 if I2C |
@@ -92,7 +92,7 @@ config SND_SOC_AC97_CODEC | |||
92 | config SND_SOC_AD1836 | 92 | config SND_SOC_AD1836 |
93 | tristate | 93 | tristate |
94 | 94 | ||
95 | config SND_SOC_AD1938 | 95 | config SND_SOC_AD193X |
96 | tristate | 96 | tristate |
97 | 97 | ||
98 | config SND_SOC_AD1980 | 98 | config SND_SOC_AD1980 |
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 98bd10c8fd3a..337904167358 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile | |||
@@ -1,6 +1,6 @@ | |||
1 | snd-soc-ac97-objs := ac97.o | 1 | snd-soc-ac97-objs := ac97.o |
2 | snd-soc-ad1836-objs := ad1836.o | 2 | snd-soc-ad1836-objs := ad1836.o |
3 | snd-soc-ad1938-objs := ad1938.o | 3 | snd-soc-ad193x-objs := ad193x.o |
4 | snd-soc-ad1980-objs := ad1980.o | 4 | snd-soc-ad1980-objs := ad1980.o |
5 | snd-soc-ad73311-objs := ad73311.o | 5 | snd-soc-ad73311-objs := ad73311.o |
6 | snd-soc-ads117x-objs := ads117x.o | 6 | snd-soc-ads117x-objs := ads117x.o |
@@ -64,7 +64,7 @@ snd-soc-wm2000-objs := wm2000.o | |||
64 | 64 | ||
65 | obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o | 65 | obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o |
66 | obj-$(CONFIG_SND_SOC_AD1836) += snd-soc-ad1836.o | 66 | obj-$(CONFIG_SND_SOC_AD1836) += snd-soc-ad1836.o |
67 | obj-$(CONFIG_SND_SOC_AD1938) += snd-soc-ad1938.o | 67 | obj-$(CONFIG_SND_SOC_AD193X) += snd-soc-ad193x.o |
68 | obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o | 68 | obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o |
69 | obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o | 69 | obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o |
70 | obj-$(CONFIG_SND_SOC_ADS117X) += snd-soc-ads117x.o | 70 | obj-$(CONFIG_SND_SOC_ADS117X) += snd-soc-ads117x.o |
diff --git a/sound/soc/codecs/ad1938.c b/sound/soc/codecs/ad1938.c deleted file mode 100644 index c233810d463d..000000000000 --- a/sound/soc/codecs/ad1938.c +++ /dev/null | |||
@@ -1,521 +0,0 @@ | |||
1 | /* | ||
2 | * File: sound/soc/codecs/ad1938.c | ||
3 | * Author: Barry Song <Barry.Song@analog.com> | ||
4 | * | ||
5 | * Created: June 04 2009 | ||
6 | * Description: Driver for AD1938 sound chip | ||
7 | * | ||
8 | * Modified: | ||
9 | * Copyright 2009 Analog Devices Inc. | ||
10 | * | ||
11 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License as published by | ||
15 | * the Free Software Foundation; either version 2 of the License, or | ||
16 | * (at your option) any later version. | ||
17 | * | ||
18 | * This program is distributed in the hope that it will be useful, | ||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | * GNU General Public License for more details. | ||
22 | * | ||
23 | * You should have received a copy of the GNU General Public License | ||
24 | * along with this program; if not, see the file COPYING, or write | ||
25 | * to the Free Software Foundation, Inc., | ||
26 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
27 | */ | ||
28 | |||
29 | #include <linux/init.h> | ||
30 | #include <linux/module.h> | ||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/device.h> | ||
33 | #include <sound/core.h> | ||
34 | #include <sound/pcm.h> | ||
35 | #include <sound/pcm_params.h> | ||
36 | #include <sound/initval.h> | ||
37 | #include <sound/soc.h> | ||
38 | #include <sound/tlv.h> | ||
39 | #include <sound/soc-dapm.h> | ||
40 | #include <linux/spi/spi.h> | ||
41 | #include "ad1938.h" | ||
42 | |||
43 | /* codec private data */ | ||
44 | struct ad1938_priv { | ||
45 | struct snd_soc_codec codec; | ||
46 | u8 reg_cache[AD1938_NUM_REGS]; | ||
47 | }; | ||
48 | |||
49 | /* ad1938 register cache & default register settings */ | ||
50 | static const u8 ad1938_reg[AD1938_NUM_REGS] = { | ||
51 | 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0, | ||
52 | }; | ||
53 | |||
54 | static struct snd_soc_codec *ad1938_codec; | ||
55 | struct snd_soc_codec_device soc_codec_dev_ad1938; | ||
56 | static int ad1938_register(struct ad1938_priv *ad1938); | ||
57 | static void ad1938_unregister(struct ad1938_priv *ad1938); | ||
58 | |||
59 | /* | ||
60 | * AD1938 volume/mute/de-emphasis etc. controls | ||
61 | */ | ||
62 | static const char *ad1938_deemp[] = {"None", "48kHz", "44.1kHz", "32kHz"}; | ||
63 | |||
64 | static const struct soc_enum ad1938_deemp_enum = | ||
65 | SOC_ENUM_SINGLE(AD1938_DAC_CTRL2, 1, 4, ad1938_deemp); | ||
66 | |||
67 | static const struct snd_kcontrol_new ad1938_snd_controls[] = { | ||
68 | /* DAC volume control */ | ||
69 | SOC_DOUBLE_R("DAC1 Volume", AD1938_DAC_L1_VOL, | ||
70 | AD1938_DAC_R1_VOL, 0, 0xFF, 1), | ||
71 | SOC_DOUBLE_R("DAC2 Volume", AD1938_DAC_L2_VOL, | ||
72 | AD1938_DAC_R2_VOL, 0, 0xFF, 1), | ||
73 | SOC_DOUBLE_R("DAC3 Volume", AD1938_DAC_L3_VOL, | ||
74 | AD1938_DAC_R3_VOL, 0, 0xFF, 1), | ||
75 | SOC_DOUBLE_R("DAC4 Volume", AD1938_DAC_L4_VOL, | ||
76 | AD1938_DAC_R4_VOL, 0, 0xFF, 1), | ||
77 | |||
78 | /* ADC switch control */ | ||
79 | SOC_DOUBLE("ADC1 Switch", AD1938_ADC_CTRL0, AD1938_ADCL1_MUTE, | ||
80 | AD1938_ADCR1_MUTE, 1, 1), | ||
81 | SOC_DOUBLE("ADC2 Switch", AD1938_ADC_CTRL0, AD1938_ADCL2_MUTE, | ||
82 | AD1938_ADCR2_MUTE, 1, 1), | ||
83 | |||
84 | /* DAC switch control */ | ||
85 | SOC_DOUBLE("DAC1 Switch", AD1938_DAC_CHNL_MUTE, AD1938_DACL1_MUTE, | ||
86 | AD1938_DACR1_MUTE, 1, 1), | ||
87 | SOC_DOUBLE("DAC2 Switch", AD1938_DAC_CHNL_MUTE, AD1938_DACL2_MUTE, | ||
88 | AD1938_DACR2_MUTE, 1, 1), | ||
89 | SOC_DOUBLE("DAC3 Switch", AD1938_DAC_CHNL_MUTE, AD1938_DACL3_MUTE, | ||
90 | AD1938_DACR3_MUTE, 1, 1), | ||
91 | SOC_DOUBLE("DAC4 Switch", AD1938_DAC_CHNL_MUTE, AD1938_DACL4_MUTE, | ||
92 | AD1938_DACR4_MUTE, 1, 1), | ||
93 | |||
94 | /* ADC high-pass filter */ | ||
95 | SOC_SINGLE("ADC High Pass Filter Switch", AD1938_ADC_CTRL0, | ||
96 | AD1938_ADC_HIGHPASS_FILTER, 1, 0), | ||
97 | |||
98 | /* DAC de-emphasis */ | ||
99 | SOC_ENUM("Playback Deemphasis", ad1938_deemp_enum), | ||
100 | }; | ||
101 | |||
102 | static const struct snd_soc_dapm_widget ad1938_dapm_widgets[] = { | ||
103 | SND_SOC_DAPM_DAC("DAC", "Playback", AD1938_DAC_CTRL0, 0, 1), | ||
104 | SND_SOC_DAPM_ADC("ADC", "Capture", SND_SOC_NOPM, 0, 0), | ||
105 | SND_SOC_DAPM_SUPPLY("PLL_PWR", AD1938_PLL_CLK_CTRL0, 0, 1, NULL, 0), | ||
106 | SND_SOC_DAPM_SUPPLY("ADC_PWR", AD1938_ADC_CTRL0, 0, 1, NULL, 0), | ||
107 | SND_SOC_DAPM_OUTPUT("DAC1OUT"), | ||
108 | SND_SOC_DAPM_OUTPUT("DAC2OUT"), | ||
109 | SND_SOC_DAPM_OUTPUT("DAC3OUT"), | ||
110 | SND_SOC_DAPM_OUTPUT("DAC4OUT"), | ||
111 | SND_SOC_DAPM_INPUT("ADC1IN"), | ||
112 | SND_SOC_DAPM_INPUT("ADC2IN"), | ||
113 | }; | ||
114 | |||
115 | static const struct snd_soc_dapm_route audio_paths[] = { | ||
116 | { "DAC", NULL, "PLL_PWR" }, | ||
117 | { "ADC", NULL, "PLL_PWR" }, | ||
118 | { "DAC", NULL, "ADC_PWR" }, | ||
119 | { "ADC", NULL, "ADC_PWR" }, | ||
120 | { "DAC1OUT", "DAC1 Switch", "DAC" }, | ||
121 | { "DAC2OUT", "DAC2 Switch", "DAC" }, | ||
122 | { "DAC3OUT", "DAC3 Switch", "DAC" }, | ||
123 | { "DAC4OUT", "DAC4 Switch", "DAC" }, | ||
124 | { "ADC", "ADC1 Switch", "ADC1IN" }, | ||
125 | { "ADC", "ADC2 Switch", "ADC2IN" }, | ||
126 | }; | ||
127 | |||
128 | /* | ||
129 | * DAI ops entries | ||
130 | */ | ||
131 | |||
132 | static int ad1938_mute(struct snd_soc_dai *dai, int mute) | ||
133 | { | ||
134 | struct snd_soc_codec *codec = dai->codec; | ||
135 | int reg; | ||
136 | |||
137 | reg = snd_soc_read(codec, AD1938_DAC_CTRL2); | ||
138 | reg = (mute > 0) ? reg | AD1938_DAC_MASTER_MUTE : reg & | ||
139 | (~AD1938_DAC_MASTER_MUTE); | ||
140 | snd_soc_write(codec, AD1938_DAC_CTRL2, reg); | ||
141 | |||
142 | return 0; | ||
143 | } | ||
144 | |||
145 | static int ad1938_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, | ||
146 | unsigned int rx_mask, int slots, int width) | ||
147 | { | ||
148 | struct snd_soc_codec *codec = dai->codec; | ||
149 | int dac_reg = snd_soc_read(codec, AD1938_DAC_CTRL1); | ||
150 | int adc_reg = snd_soc_read(codec, AD1938_ADC_CTRL2); | ||
151 | |||
152 | dac_reg &= ~AD1938_DAC_CHAN_MASK; | ||
153 | adc_reg &= ~AD1938_ADC_CHAN_MASK; | ||
154 | |||
155 | switch (slots) { | ||
156 | case 2: | ||
157 | dac_reg |= AD1938_DAC_2_CHANNELS << AD1938_DAC_CHAN_SHFT; | ||
158 | adc_reg |= AD1938_ADC_2_CHANNELS << AD1938_ADC_CHAN_SHFT; | ||
159 | break; | ||
160 | case 4: | ||
161 | dac_reg |= AD1938_DAC_4_CHANNELS << AD1938_DAC_CHAN_SHFT; | ||
162 | adc_reg |= AD1938_ADC_4_CHANNELS << AD1938_ADC_CHAN_SHFT; | ||
163 | break; | ||
164 | case 8: | ||
165 | dac_reg |= AD1938_DAC_8_CHANNELS << AD1938_DAC_CHAN_SHFT; | ||
166 | adc_reg |= AD1938_ADC_8_CHANNELS << AD1938_ADC_CHAN_SHFT; | ||
167 | break; | ||
168 | case 16: | ||
169 | dac_reg |= AD1938_DAC_16_CHANNELS << AD1938_DAC_CHAN_SHFT; | ||
170 | adc_reg |= AD1938_ADC_16_CHANNELS << AD1938_ADC_CHAN_SHFT; | ||
171 | break; | ||
172 | default: | ||
173 | return -EINVAL; | ||
174 | } | ||
175 | |||
176 | snd_soc_write(codec, AD1938_DAC_CTRL1, dac_reg); | ||
177 | snd_soc_write(codec, AD1938_ADC_CTRL2, adc_reg); | ||
178 | |||
179 | return 0; | ||
180 | } | ||
181 | |||
182 | static int ad1938_set_dai_fmt(struct snd_soc_dai *codec_dai, | ||
183 | unsigned int fmt) | ||
184 | { | ||
185 | struct snd_soc_codec *codec = codec_dai->codec; | ||
186 | int adc_reg, dac_reg; | ||
187 | |||
188 | adc_reg = snd_soc_read(codec, AD1938_ADC_CTRL2); | ||
189 | dac_reg = snd_soc_read(codec, AD1938_DAC_CTRL1); | ||
190 | |||
191 | /* At present, the driver only support AUX ADC mode(SND_SOC_DAIFMT_I2S | ||
192 | * with TDM) and ADC&DAC TDM mode(SND_SOC_DAIFMT_DSP_A) | ||
193 | */ | ||
194 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
195 | case SND_SOC_DAIFMT_I2S: | ||
196 | adc_reg &= ~AD1938_ADC_SERFMT_MASK; | ||
197 | adc_reg |= AD1938_ADC_SERFMT_TDM; | ||
198 | break; | ||
199 | case SND_SOC_DAIFMT_DSP_A: | ||
200 | adc_reg &= ~AD1938_ADC_SERFMT_MASK; | ||
201 | adc_reg |= AD1938_ADC_SERFMT_AUX; | ||
202 | break; | ||
203 | default: | ||
204 | return -EINVAL; | ||
205 | } | ||
206 | |||
207 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
208 | case SND_SOC_DAIFMT_NB_NF: /* normal bit clock + frame */ | ||
209 | adc_reg &= ~AD1938_ADC_LEFT_HIGH; | ||
210 | adc_reg &= ~AD1938_ADC_BCLK_INV; | ||
211 | dac_reg &= ~AD1938_DAC_LEFT_HIGH; | ||
212 | dac_reg &= ~AD1938_DAC_BCLK_INV; | ||
213 | break; | ||
214 | case SND_SOC_DAIFMT_NB_IF: /* normal bclk + invert frm */ | ||
215 | adc_reg |= AD1938_ADC_LEFT_HIGH; | ||
216 | adc_reg &= ~AD1938_ADC_BCLK_INV; | ||
217 | dac_reg |= AD1938_DAC_LEFT_HIGH; | ||
218 | dac_reg &= ~AD1938_DAC_BCLK_INV; | ||
219 | break; | ||
220 | case SND_SOC_DAIFMT_IB_NF: /* invert bclk + normal frm */ | ||
221 | adc_reg &= ~AD1938_ADC_LEFT_HIGH; | ||
222 | adc_reg |= AD1938_ADC_BCLK_INV; | ||
223 | dac_reg &= ~AD1938_DAC_LEFT_HIGH; | ||
224 | dac_reg |= AD1938_DAC_BCLK_INV; | ||
225 | break; | ||
226 | |||
227 | case SND_SOC_DAIFMT_IB_IF: /* invert bclk + frm */ | ||
228 | adc_reg |= AD1938_ADC_LEFT_HIGH; | ||
229 | adc_reg |= AD1938_ADC_BCLK_INV; | ||
230 | dac_reg |= AD1938_DAC_LEFT_HIGH; | ||
231 | dac_reg |= AD1938_DAC_BCLK_INV; | ||
232 | break; | ||
233 | default: | ||
234 | return -EINVAL; | ||
235 | } | ||
236 | |||
237 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
238 | case SND_SOC_DAIFMT_CBM_CFM: /* codec clk & frm master */ | ||
239 | adc_reg |= AD1938_ADC_LCR_MASTER; | ||
240 | adc_reg |= AD1938_ADC_BCLK_MASTER; | ||
241 | dac_reg |= AD1938_DAC_LCR_MASTER; | ||
242 | dac_reg |= AD1938_DAC_BCLK_MASTER; | ||
243 | break; | ||
244 | case SND_SOC_DAIFMT_CBS_CFM: /* codec clk slave & frm master */ | ||
245 | adc_reg |= AD1938_ADC_LCR_MASTER; | ||
246 | adc_reg &= ~AD1938_ADC_BCLK_MASTER; | ||
247 | dac_reg |= AD1938_DAC_LCR_MASTER; | ||
248 | dac_reg &= ~AD1938_DAC_BCLK_MASTER; | ||
249 | break; | ||
250 | case SND_SOC_DAIFMT_CBM_CFS: /* codec clk master & frame slave */ | ||
251 | adc_reg &= ~AD1938_ADC_LCR_MASTER; | ||
252 | adc_reg |= AD1938_ADC_BCLK_MASTER; | ||
253 | dac_reg &= ~AD1938_DAC_LCR_MASTER; | ||
254 | dac_reg |= AD1938_DAC_BCLK_MASTER; | ||
255 | break; | ||
256 | case SND_SOC_DAIFMT_CBS_CFS: /* codec clk & frm slave */ | ||
257 | adc_reg &= ~AD1938_ADC_LCR_MASTER; | ||
258 | adc_reg &= ~AD1938_ADC_BCLK_MASTER; | ||
259 | dac_reg &= ~AD1938_DAC_LCR_MASTER; | ||
260 | dac_reg &= ~AD1938_DAC_BCLK_MASTER; | ||
261 | break; | ||
262 | default: | ||
263 | return -EINVAL; | ||
264 | } | ||
265 | |||
266 | snd_soc_write(codec, AD1938_ADC_CTRL2, adc_reg); | ||
267 | snd_soc_write(codec, AD1938_DAC_CTRL1, dac_reg); | ||
268 | |||
269 | return 0; | ||
270 | } | ||
271 | |||
272 | static int ad1938_hw_params(struct snd_pcm_substream *substream, | ||
273 | struct snd_pcm_hw_params *params, | ||
274 | struct snd_soc_dai *dai) | ||
275 | { | ||
276 | int word_len = 0, reg = 0; | ||
277 | |||
278 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
279 | struct snd_soc_device *socdev = rtd->socdev; | ||
280 | struct snd_soc_codec *codec = socdev->card->codec; | ||
281 | |||
282 | /* bit size */ | ||
283 | switch (params_format(params)) { | ||
284 | case SNDRV_PCM_FORMAT_S16_LE: | ||
285 | word_len = 3; | ||
286 | break; | ||
287 | case SNDRV_PCM_FORMAT_S20_3LE: | ||
288 | word_len = 1; | ||
289 | break; | ||
290 | case SNDRV_PCM_FORMAT_S24_LE: | ||
291 | case SNDRV_PCM_FORMAT_S32_LE: | ||
292 | word_len = 0; | ||
293 | break; | ||
294 | } | ||
295 | |||
296 | reg = snd_soc_read(codec, AD1938_DAC_CTRL2); | ||
297 | reg = (reg & (~AD1938_DAC_WORD_LEN_MASK)) | word_len; | ||
298 | snd_soc_write(codec, AD1938_DAC_CTRL2, reg); | ||
299 | |||
300 | reg = snd_soc_read(codec, AD1938_ADC_CTRL1); | ||
301 | reg = (reg & (~AD1938_ADC_WORD_LEN_MASK)) | word_len; | ||
302 | snd_soc_write(codec, AD1938_ADC_CTRL1, reg); | ||
303 | |||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | static int __devinit ad1938_spi_probe(struct spi_device *spi) | ||
308 | { | ||
309 | struct snd_soc_codec *codec; | ||
310 | struct ad1938_priv *ad1938; | ||
311 | |||
312 | ad1938 = kzalloc(sizeof(struct ad1938_priv), GFP_KERNEL); | ||
313 | if (ad1938 == NULL) | ||
314 | return -ENOMEM; | ||
315 | |||
316 | codec = &ad1938->codec; | ||
317 | codec->control_data = spi; | ||
318 | codec->dev = &spi->dev; | ||
319 | |||
320 | dev_set_drvdata(&spi->dev, ad1938); | ||
321 | |||
322 | return ad1938_register(ad1938); | ||
323 | } | ||
324 | |||
325 | static int __devexit ad1938_spi_remove(struct spi_device *spi) | ||
326 | { | ||
327 | struct ad1938_priv *ad1938 = dev_get_drvdata(&spi->dev); | ||
328 | |||
329 | ad1938_unregister(ad1938); | ||
330 | return 0; | ||
331 | } | ||
332 | |||
333 | static struct spi_driver ad1938_spi_driver = { | ||
334 | .driver = { | ||
335 | .name = "ad1938", | ||
336 | .owner = THIS_MODULE, | ||
337 | }, | ||
338 | .probe = ad1938_spi_probe, | ||
339 | .remove = __devexit_p(ad1938_spi_remove), | ||
340 | }; | ||
341 | |||
342 | static struct snd_soc_dai_ops ad1938_dai_ops = { | ||
343 | .hw_params = ad1938_hw_params, | ||
344 | .digital_mute = ad1938_mute, | ||
345 | .set_tdm_slot = ad1938_set_tdm_slot, | ||
346 | .set_fmt = ad1938_set_dai_fmt, | ||
347 | }; | ||
348 | |||
349 | /* codec DAI instance */ | ||
350 | struct snd_soc_dai ad1938_dai = { | ||
351 | .name = "AD1938", | ||
352 | .playback = { | ||
353 | .stream_name = "Playback", | ||
354 | .channels_min = 2, | ||
355 | .channels_max = 8, | ||
356 | .rates = SNDRV_PCM_RATE_48000, | ||
357 | .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE | | ||
358 | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE, | ||
359 | }, | ||
360 | .capture = { | ||
361 | .stream_name = "Capture", | ||
362 | .channels_min = 2, | ||
363 | .channels_max = 4, | ||
364 | .rates = SNDRV_PCM_RATE_48000, | ||
365 | .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE | | ||
366 | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE, | ||
367 | }, | ||
368 | .ops = &ad1938_dai_ops, | ||
369 | }; | ||
370 | EXPORT_SYMBOL_GPL(ad1938_dai); | ||
371 | |||
372 | static int ad1938_register(struct ad1938_priv *ad1938) | ||
373 | { | ||
374 | int ret; | ||
375 | struct snd_soc_codec *codec = &ad1938->codec; | ||
376 | |||
377 | if (ad1938_codec) { | ||
378 | dev_err(codec->dev, "Another ad1938 is registered\n"); | ||
379 | return -EINVAL; | ||
380 | } | ||
381 | |||
382 | mutex_init(&codec->mutex); | ||
383 | INIT_LIST_HEAD(&codec->dapm_widgets); | ||
384 | INIT_LIST_HEAD(&codec->dapm_paths); | ||
385 | codec->private_data = ad1938; | ||
386 | codec->reg_cache = ad1938->reg_cache; | ||
387 | codec->reg_cache_size = AD1938_NUM_REGS; | ||
388 | codec->name = "AD1938"; | ||
389 | codec->owner = THIS_MODULE; | ||
390 | codec->dai = &ad1938_dai; | ||
391 | codec->num_dai = 1; | ||
392 | INIT_LIST_HEAD(&codec->dapm_widgets); | ||
393 | INIT_LIST_HEAD(&codec->dapm_paths); | ||
394 | |||
395 | ad1938_dai.dev = codec->dev; | ||
396 | ad1938_codec = codec; | ||
397 | |||
398 | memcpy(codec->reg_cache, ad1938_reg, AD1938_NUM_REGS); | ||
399 | |||
400 | ret = snd_soc_codec_set_cache_io(codec, 16, 8, SND_SOC_SPI); | ||
401 | if (ret < 0) { | ||
402 | dev_err(codec->dev, "failed to set cache I/O: %d\n", | ||
403 | ret); | ||
404 | kfree(ad1938); | ||
405 | return ret; | ||
406 | } | ||
407 | |||
408 | /* default setting for ad1938 */ | ||
409 | |||
410 | /* unmute dac channels */ | ||
411 | snd_soc_write(codec, AD1938_DAC_CHNL_MUTE, 0x0); | ||
412 | /* de-emphasis: 48kHz, powedown dac */ | ||
413 | snd_soc_write(codec, AD1938_DAC_CTRL2, 0x1A); | ||
414 | /* powerdown dac, dac in tdm mode */ | ||
415 | snd_soc_write(codec, AD1938_DAC_CTRL0, 0x41); | ||
416 | /* high-pass filter enable */ | ||
417 | snd_soc_write(codec, AD1938_ADC_CTRL0, 0x3); | ||
418 | /* sata delay=1, adc aux mode */ | ||
419 | snd_soc_write(codec, AD1938_ADC_CTRL1, 0x43); | ||
420 | /* pll input: mclki/xi */ | ||
421 | snd_soc_write(codec, AD1938_PLL_CLK_CTRL0, 0x9D); | ||
422 | snd_soc_write(codec, AD1938_PLL_CLK_CTRL1, 0x04); | ||
423 | |||
424 | ret = snd_soc_register_codec(codec); | ||
425 | if (ret != 0) { | ||
426 | dev_err(codec->dev, "Failed to register codec: %d\n", ret); | ||
427 | kfree(ad1938); | ||
428 | return ret; | ||
429 | } | ||
430 | |||
431 | ret = snd_soc_register_dai(&ad1938_dai); | ||
432 | if (ret != 0) { | ||
433 | dev_err(codec->dev, "Failed to register DAI: %d\n", ret); | ||
434 | snd_soc_unregister_codec(codec); | ||
435 | kfree(ad1938); | ||
436 | return ret; | ||
437 | } | ||
438 | |||
439 | return 0; | ||
440 | } | ||
441 | |||
442 | static void ad1938_unregister(struct ad1938_priv *ad1938) | ||
443 | { | ||
444 | snd_soc_unregister_dai(&ad1938_dai); | ||
445 | snd_soc_unregister_codec(&ad1938->codec); | ||
446 | kfree(ad1938); | ||
447 | ad1938_codec = NULL; | ||
448 | } | ||
449 | |||
450 | static int ad1938_probe(struct platform_device *pdev) | ||
451 | { | ||
452 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
453 | struct snd_soc_codec *codec; | ||
454 | int ret = 0; | ||
455 | |||
456 | if (ad1938_codec == NULL) { | ||
457 | dev_err(&pdev->dev, "Codec device not registered\n"); | ||
458 | return -ENODEV; | ||
459 | } | ||
460 | |||
461 | socdev->card->codec = ad1938_codec; | ||
462 | codec = ad1938_codec; | ||
463 | |||
464 | /* register pcms */ | ||
465 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | ||
466 | if (ret < 0) { | ||
467 | dev_err(codec->dev, "failed to create pcms: %d\n", ret); | ||
468 | goto pcm_err; | ||
469 | } | ||
470 | |||
471 | snd_soc_add_controls(codec, ad1938_snd_controls, | ||
472 | ARRAY_SIZE(ad1938_snd_controls)); | ||
473 | snd_soc_dapm_new_controls(codec, ad1938_dapm_widgets, | ||
474 | ARRAY_SIZE(ad1938_dapm_widgets)); | ||
475 | snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths)); | ||
476 | |||
477 | |||
478 | pcm_err: | ||
479 | return ret; | ||
480 | } | ||
481 | |||
482 | /* power down chip */ | ||
483 | static int ad1938_remove(struct platform_device *pdev) | ||
484 | { | ||
485 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
486 | |||
487 | snd_soc_free_pcms(socdev); | ||
488 | snd_soc_dapm_free(socdev); | ||
489 | |||
490 | return 0; | ||
491 | } | ||
492 | |||
493 | struct snd_soc_codec_device soc_codec_dev_ad1938 = { | ||
494 | .probe = ad1938_probe, | ||
495 | .remove = ad1938_remove, | ||
496 | }; | ||
497 | EXPORT_SYMBOL_GPL(soc_codec_dev_ad1938); | ||
498 | |||
499 | static int __init ad1938_init(void) | ||
500 | { | ||
501 | int ret; | ||
502 | |||
503 | ret = spi_register_driver(&ad1938_spi_driver); | ||
504 | if (ret != 0) { | ||
505 | printk(KERN_ERR "Failed to register ad1938 SPI driver: %d\n", | ||
506 | ret); | ||
507 | } | ||
508 | |||
509 | return ret; | ||
510 | } | ||
511 | module_init(ad1938_init); | ||
512 | |||
513 | static void __exit ad1938_exit(void) | ||
514 | { | ||
515 | spi_unregister_driver(&ad1938_spi_driver); | ||
516 | } | ||
517 | module_exit(ad1938_exit); | ||
518 | |||
519 | MODULE_DESCRIPTION("ASoC ad1938 driver"); | ||
520 | MODULE_AUTHOR("Barry Song "); | ||
521 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/ad1938.h b/sound/soc/codecs/ad1938.h deleted file mode 100644 index fe3c48cd2d5b..000000000000 --- a/sound/soc/codecs/ad1938.h +++ /dev/null | |||
@@ -1,100 +0,0 @@ | |||
1 | /* | ||
2 | * File: sound/soc/codecs/ad1836.h | ||
3 | * Based on: | ||
4 | * Author: Barry Song <Barry.Song@analog.com> | ||
5 | * | ||
6 | * Created: May 25, 2009 | ||
7 | * Description: definitions for AD1938 registers | ||
8 | * | ||
9 | * Modified: | ||
10 | * | ||
11 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License as published by | ||
15 | * the Free Software Foundation; either version 2 of the License, or | ||
16 | * (at your option) any later version. | ||
17 | * | ||
18 | * This program is distributed in the hope that it will be useful, | ||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | * GNU General Public License for more details. | ||
22 | * | ||
23 | * You should have received a copy of the GNU General Public License | ||
24 | * along with this program; if not, see the file COPYING, or write | ||
25 | * to the Free Software Foundation, Inc., | ||
26 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
27 | */ | ||
28 | |||
29 | #ifndef __AD1938_H__ | ||
30 | #define __AD1938_H__ | ||
31 | |||
32 | #define AD1938_PLL_CLK_CTRL0 0 | ||
33 | #define AD1938_PLL_POWERDOWN 0x01 | ||
34 | #define AD1938_PLL_CLK_CTRL1 1 | ||
35 | #define AD1938_DAC_CTRL0 2 | ||
36 | #define AD1938_DAC_POWERDOWN 0x01 | ||
37 | #define AD1938_DAC_SERFMT_MASK 0xC0 | ||
38 | #define AD1938_DAC_SERFMT_STEREO (0 << 6) | ||
39 | #define AD1938_DAC_SERFMT_TDM (1 << 6) | ||
40 | #define AD1938_DAC_CTRL1 3 | ||
41 | #define AD1938_DAC_2_CHANNELS 0 | ||
42 | #define AD1938_DAC_4_CHANNELS 1 | ||
43 | #define AD1938_DAC_8_CHANNELS 2 | ||
44 | #define AD1938_DAC_16_CHANNELS 3 | ||
45 | #define AD1938_DAC_CHAN_SHFT 1 | ||
46 | #define AD1938_DAC_CHAN_MASK (3 << AD1938_DAC_CHAN_SHFT) | ||
47 | #define AD1938_DAC_LCR_MASTER (1 << 4) | ||
48 | #define AD1938_DAC_BCLK_MASTER (1 << 5) | ||
49 | #define AD1938_DAC_LEFT_HIGH (1 << 3) | ||
50 | #define AD1938_DAC_BCLK_INV (1 << 7) | ||
51 | #define AD1938_DAC_CTRL2 4 | ||
52 | #define AD1938_DAC_WORD_LEN_MASK 0xC | ||
53 | #define AD1938_DAC_MASTER_MUTE 1 | ||
54 | #define AD1938_DAC_CHNL_MUTE 5 | ||
55 | #define AD1938_DACL1_MUTE 0 | ||
56 | #define AD1938_DACR1_MUTE 1 | ||
57 | #define AD1938_DACL2_MUTE 2 | ||
58 | #define AD1938_DACR2_MUTE 3 | ||
59 | #define AD1938_DACL3_MUTE 4 | ||
60 | #define AD1938_DACR3_MUTE 5 | ||
61 | #define AD1938_DACL4_MUTE 6 | ||
62 | #define AD1938_DACR4_MUTE 7 | ||
63 | #define AD1938_DAC_L1_VOL 6 | ||
64 | #define AD1938_DAC_R1_VOL 7 | ||
65 | #define AD1938_DAC_L2_VOL 8 | ||
66 | #define AD1938_DAC_R2_VOL 9 | ||
67 | #define AD1938_DAC_L3_VOL 10 | ||
68 | #define AD1938_DAC_R3_VOL 11 | ||
69 | #define AD1938_DAC_L4_VOL 12 | ||
70 | #define AD1938_DAC_R4_VOL 13 | ||
71 | #define AD1938_ADC_CTRL0 14 | ||
72 | #define AD1938_ADC_POWERDOWN 0x01 | ||
73 | #define AD1938_ADC_HIGHPASS_FILTER 1 | ||
74 | #define AD1938_ADCL1_MUTE 2 | ||
75 | #define AD1938_ADCR1_MUTE 3 | ||
76 | #define AD1938_ADCL2_MUTE 4 | ||
77 | #define AD1938_ADCR2_MUTE 5 | ||
78 | #define AD1938_ADC_CTRL1 15 | ||
79 | #define AD1938_ADC_SERFMT_MASK 0x60 | ||
80 | #define AD1938_ADC_SERFMT_STEREO (0 << 5) | ||
81 | #define AD1938_ADC_SERFMT_TDM (1 << 2) | ||
82 | #define AD1938_ADC_SERFMT_AUX (2 << 5) | ||
83 | #define AD1938_ADC_WORD_LEN_MASK 0x3 | ||
84 | #define AD1938_ADC_CTRL2 16 | ||
85 | #define AD1938_ADC_2_CHANNELS 0 | ||
86 | #define AD1938_ADC_4_CHANNELS 1 | ||
87 | #define AD1938_ADC_8_CHANNELS 2 | ||
88 | #define AD1938_ADC_16_CHANNELS 3 | ||
89 | #define AD1938_ADC_CHAN_SHFT 4 | ||
90 | #define AD1938_ADC_CHAN_MASK (3 << AD1938_ADC_CHAN_SHFT) | ||
91 | #define AD1938_ADC_LCR_MASTER (1 << 3) | ||
92 | #define AD1938_ADC_BCLK_MASTER (1 << 6) | ||
93 | #define AD1938_ADC_LEFT_HIGH (1 << 2) | ||
94 | #define AD1938_ADC_BCLK_INV (1 << 1) | ||
95 | |||
96 | #define AD1938_NUM_REGS 17 | ||
97 | |||
98 | extern struct snd_soc_dai ad1938_dai; | ||
99 | extern struct snd_soc_codec_device soc_codec_dev_ad1938; | ||
100 | #endif | ||
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c new file mode 100644 index 000000000000..d7426990b66e --- /dev/null +++ b/sound/soc/codecs/ad193x.c | |||
@@ -0,0 +1,560 @@ | |||
1 | /* | ||
2 | * AD193X Audio Codec driver supporting AD1936/7/8/9 | ||
3 | * | ||
4 | * Copyright 2010 Analog Devices Inc. | ||
5 | * | ||
6 | * Licensed under the GPL-2 or later. | ||
7 | */ | ||
8 | |||
9 | #include <linux/init.h> | ||
10 | #include <linux/module.h> | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/device.h> | ||
13 | #include <linux/i2c.h> | ||
14 | #include <linux/spi/spi.h> | ||
15 | #include <sound/core.h> | ||
16 | #include <sound/pcm.h> | ||
17 | #include <sound/pcm_params.h> | ||
18 | #include <sound/initval.h> | ||
19 | #include <sound/soc.h> | ||
20 | #include <sound/tlv.h> | ||
21 | #include <sound/soc-dapm.h> | ||
22 | #include "ad193x.h" | ||
23 | |||
24 | /* codec private data */ | ||
25 | struct ad193x_priv { | ||
26 | struct snd_soc_codec codec; | ||
27 | u8 reg_cache[AD193X_NUM_REGS]; | ||
28 | }; | ||
29 | |||
30 | /* ad193x register cache & default register settings */ | ||
31 | static const u8 ad193x_reg[AD193X_NUM_REGS] = { | ||
32 | 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0, | ||
33 | }; | ||
34 | |||
35 | static struct snd_soc_codec *ad193x_codec; | ||
36 | struct snd_soc_codec_device soc_codec_dev_ad193x; | ||
37 | static int ad193x_register(struct ad193x_priv *ad193x, int bus_type); | ||
38 | static void ad193x_unregister(struct ad193x_priv *ad193x); | ||
39 | |||
40 | /* | ||
41 | * AD193X volume/mute/de-emphasis etc. controls | ||
42 | */ | ||
43 | static const char *ad193x_deemp[] = {"None", "48kHz", "44.1kHz", "32kHz"}; | ||
44 | |||
45 | static const struct soc_enum ad193x_deemp_enum = | ||
46 | SOC_ENUM_SINGLE(AD193X_DAC_CTRL2, 1, 4, ad193x_deemp); | ||
47 | |||
48 | static const struct snd_kcontrol_new ad193x_snd_controls[] = { | ||
49 | /* DAC volume control */ | ||
50 | SOC_DOUBLE_R("DAC1 Volume", AD193X_DAC_L1_VOL, | ||
51 | AD193X_DAC_R1_VOL, 0, 0xFF, 1), | ||
52 | SOC_DOUBLE_R("DAC2 Volume", AD193X_DAC_L2_VOL, | ||
53 | AD193X_DAC_R2_VOL, 0, 0xFF, 1), | ||
54 | SOC_DOUBLE_R("DAC3 Volume", AD193X_DAC_L3_VOL, | ||
55 | AD193X_DAC_R3_VOL, 0, 0xFF, 1), | ||
56 | SOC_DOUBLE_R("DAC4 Volume", AD193X_DAC_L4_VOL, | ||
57 | AD193X_DAC_R4_VOL, 0, 0xFF, 1), | ||
58 | |||
59 | /* ADC switch control */ | ||
60 | SOC_DOUBLE("ADC1 Switch", AD193X_ADC_CTRL0, AD193X_ADCL1_MUTE, | ||
61 | AD193X_ADCR1_MUTE, 1, 1), | ||
62 | SOC_DOUBLE("ADC2 Switch", AD193X_ADC_CTRL0, AD193X_ADCL2_MUTE, | ||
63 | AD193X_ADCR2_MUTE, 1, 1), | ||
64 | |||
65 | /* DAC switch control */ | ||
66 | SOC_DOUBLE("DAC1 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL1_MUTE, | ||
67 | AD193X_DACR1_MUTE, 1, 1), | ||
68 | SOC_DOUBLE("DAC2 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL2_MUTE, | ||
69 | AD193X_DACR2_MUTE, 1, 1), | ||
70 | SOC_DOUBLE("DAC3 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL3_MUTE, | ||
71 | AD193X_DACR3_MUTE, 1, 1), | ||
72 | SOC_DOUBLE("DAC4 Switch", AD193X_DAC_CHNL_MUTE, AD193X_DACL4_MUTE, | ||
73 | AD193X_DACR4_MUTE, 1, 1), | ||
74 | |||
75 | /* ADC high-pass filter */ | ||
76 | SOC_SINGLE("ADC High Pass Filter Switch", AD193X_ADC_CTRL0, | ||
77 | AD193X_ADC_HIGHPASS_FILTER, 1, 0), | ||
78 | |||
79 | /* DAC de-emphasis */ | ||
80 | SOC_ENUM("Playback Deemphasis", ad193x_deemp_enum), | ||
81 | }; | ||
82 | |||
83 | static const struct snd_soc_dapm_widget ad193x_dapm_widgets[] = { | ||
84 | SND_SOC_DAPM_DAC("DAC", "Playback", AD193X_DAC_CTRL0, 0, 1), | ||
85 | SND_SOC_DAPM_ADC("ADC", "Capture", SND_SOC_NOPM, 0, 0), | ||
86 | SND_SOC_DAPM_SUPPLY("PLL_PWR", AD193X_PLL_CLK_CTRL0, 0, 1, NULL, 0), | ||
87 | SND_SOC_DAPM_SUPPLY("ADC_PWR", AD193X_ADC_CTRL0, 0, 1, NULL, 0), | ||
88 | SND_SOC_DAPM_OUTPUT("DAC1OUT"), | ||
89 | SND_SOC_DAPM_OUTPUT("DAC2OUT"), | ||
90 | SND_SOC_DAPM_OUTPUT("DAC3OUT"), | ||
91 | SND_SOC_DAPM_OUTPUT("DAC4OUT"), | ||
92 | SND_SOC_DAPM_INPUT("ADC1IN"), | ||
93 | SND_SOC_DAPM_INPUT("ADC2IN"), | ||
94 | }; | ||
95 | |||
96 | static const struct snd_soc_dapm_route audio_paths[] = { | ||
97 | { "DAC", NULL, "PLL_PWR" }, | ||
98 | { "ADC", NULL, "PLL_PWR" }, | ||
99 | { "DAC", NULL, "ADC_PWR" }, | ||
100 | { "ADC", NULL, "ADC_PWR" }, | ||
101 | { "DAC1OUT", "DAC1 Switch", "DAC" }, | ||
102 | { "DAC2OUT", "DAC2 Switch", "DAC" }, | ||
103 | { "DAC3OUT", "DAC3 Switch", "DAC" }, | ||
104 | { "DAC4OUT", "DAC4 Switch", "DAC" }, | ||
105 | { "ADC", "ADC1 Switch", "ADC1IN" }, | ||
106 | { "ADC", "ADC2 Switch", "ADC2IN" }, | ||
107 | }; | ||
108 | |||
109 | /* | ||
110 | * DAI ops entries | ||
111 | */ | ||
112 | |||
113 | static int ad193x_mute(struct snd_soc_dai *dai, int mute) | ||
114 | { | ||
115 | struct snd_soc_codec *codec = dai->codec; | ||
116 | int reg; | ||
117 | |||
118 | reg = snd_soc_read(codec, AD193X_DAC_CTRL2); | ||
119 | reg = (mute > 0) ? reg | AD193X_DAC_MASTER_MUTE : reg & | ||
120 | (~AD193X_DAC_MASTER_MUTE); | ||
121 | snd_soc_write(codec, AD193X_DAC_CTRL2, reg); | ||
122 | |||
123 | return 0; | ||
124 | } | ||
125 | |||
126 | static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, | ||
127 | unsigned int rx_mask, int slots, int width) | ||
128 | { | ||
129 | struct snd_soc_codec *codec = dai->codec; | ||
130 | int dac_reg = snd_soc_read(codec, AD193X_DAC_CTRL1); | ||
131 | int adc_reg = snd_soc_read(codec, AD193X_ADC_CTRL2); | ||
132 | |||
133 | dac_reg &= ~AD193X_DAC_CHAN_MASK; | ||
134 | adc_reg &= ~AD193X_ADC_CHAN_MASK; | ||
135 | |||
136 | switch (slots) { | ||
137 | case 2: | ||
138 | dac_reg |= AD193X_DAC_2_CHANNELS << AD193X_DAC_CHAN_SHFT; | ||
139 | adc_reg |= AD193X_ADC_2_CHANNELS << AD193X_ADC_CHAN_SHFT; | ||
140 | break; | ||
141 | case 4: | ||
142 | dac_reg |= AD193X_DAC_4_CHANNELS << AD193X_DAC_CHAN_SHFT; | ||
143 | adc_reg |= AD193X_ADC_4_CHANNELS << AD193X_ADC_CHAN_SHFT; | ||
144 | break; | ||
145 | case 8: | ||
146 | dac_reg |= AD193X_DAC_8_CHANNELS << AD193X_DAC_CHAN_SHFT; | ||
147 | adc_reg |= AD193X_ADC_8_CHANNELS << AD193X_ADC_CHAN_SHFT; | ||
148 | break; | ||
149 | case 16: | ||
150 | dac_reg |= AD193X_DAC_16_CHANNELS << AD193X_DAC_CHAN_SHFT; | ||
151 | adc_reg |= AD193X_ADC_16_CHANNELS << AD193X_ADC_CHAN_SHFT; | ||
152 | break; | ||
153 | default: | ||
154 | return -EINVAL; | ||
155 | } | ||
156 | |||
157 | snd_soc_write(codec, AD193X_DAC_CTRL1, dac_reg); | ||
158 | snd_soc_write(codec, AD193X_ADC_CTRL2, adc_reg); | ||
159 | |||
160 | return 0; | ||
161 | } | ||
162 | |||
163 | static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai, | ||
164 | unsigned int fmt) | ||
165 | { | ||
166 | struct snd_soc_codec *codec = codec_dai->codec; | ||
167 | int adc_reg, dac_reg; | ||
168 | |||
169 | adc_reg = snd_soc_read(codec, AD193X_ADC_CTRL2); | ||
170 | dac_reg = snd_soc_read(codec, AD193X_DAC_CTRL1); | ||
171 | |||
172 | /* At present, the driver only support AUX ADC mode(SND_SOC_DAIFMT_I2S | ||
173 | * with TDM) and ADC&DAC TDM mode(SND_SOC_DAIFMT_DSP_A) | ||
174 | */ | ||
175 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
176 | case SND_SOC_DAIFMT_I2S: | ||
177 | adc_reg &= ~AD193X_ADC_SERFMT_MASK; | ||
178 | adc_reg |= AD193X_ADC_SERFMT_TDM; | ||
179 | break; | ||
180 | case SND_SOC_DAIFMT_DSP_A: | ||
181 | adc_reg &= ~AD193X_ADC_SERFMT_MASK; | ||
182 | adc_reg |= AD193X_ADC_SERFMT_AUX; | ||
183 | break; | ||
184 | default: | ||
185 | return -EINVAL; | ||
186 | } | ||
187 | |||
188 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
189 | case SND_SOC_DAIFMT_NB_NF: /* normal bit clock + frame */ | ||
190 | adc_reg &= ~AD193X_ADC_LEFT_HIGH; | ||
191 | adc_reg &= ~AD193X_ADC_BCLK_INV; | ||
192 | dac_reg &= ~AD193X_DAC_LEFT_HIGH; | ||
193 | dac_reg &= ~AD193X_DAC_BCLK_INV; | ||
194 | break; | ||
195 | case SND_SOC_DAIFMT_NB_IF: /* normal bclk + invert frm */ | ||
196 | adc_reg |= AD193X_ADC_LEFT_HIGH; | ||
197 | adc_reg &= ~AD193X_ADC_BCLK_INV; | ||
198 | dac_reg |= AD193X_DAC_LEFT_HIGH; | ||
199 | dac_reg &= ~AD193X_DAC_BCLK_INV; | ||
200 | break; | ||
201 | case SND_SOC_DAIFMT_IB_NF: /* invert bclk + normal frm */ | ||
202 | adc_reg &= ~AD193X_ADC_LEFT_HIGH; | ||
203 | adc_reg |= AD193X_ADC_BCLK_INV; | ||
204 | dac_reg &= ~AD193X_DAC_LEFT_HIGH; | ||
205 | dac_reg |= AD193X_DAC_BCLK_INV; | ||
206 | break; | ||
207 | |||
208 | case SND_SOC_DAIFMT_IB_IF: /* invert bclk + frm */ | ||
209 | adc_reg |= AD193X_ADC_LEFT_HIGH; | ||
210 | adc_reg |= AD193X_ADC_BCLK_INV; | ||
211 | dac_reg |= AD193X_DAC_LEFT_HIGH; | ||
212 | dac_reg |= AD193X_DAC_BCLK_INV; | ||
213 | break; | ||
214 | default: | ||
215 | return -EINVAL; | ||
216 | } | ||
217 | |||
218 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
219 | case SND_SOC_DAIFMT_CBM_CFM: /* codec clk & frm master */ | ||
220 | adc_reg |= AD193X_ADC_LCR_MASTER; | ||
221 | adc_reg |= AD193X_ADC_BCLK_MASTER; | ||
222 | dac_reg |= AD193X_DAC_LCR_MASTER; | ||
223 | dac_reg |= AD193X_DAC_BCLK_MASTER; | ||
224 | break; | ||
225 | case SND_SOC_DAIFMT_CBS_CFM: /* codec clk slave & frm master */ | ||
226 | adc_reg |= AD193X_ADC_LCR_MASTER; | ||
227 | adc_reg &= ~AD193X_ADC_BCLK_MASTER; | ||
228 | dac_reg |= AD193X_DAC_LCR_MASTER; | ||
229 | dac_reg &= ~AD193X_DAC_BCLK_MASTER; | ||
230 | break; | ||
231 | case SND_SOC_DAIFMT_CBM_CFS: /* codec clk master & frame slave */ | ||
232 | adc_reg &= ~AD193X_ADC_LCR_MASTER; | ||
233 | adc_reg |= AD193X_ADC_BCLK_MASTER; | ||
234 | dac_reg &= ~AD193X_DAC_LCR_MASTER; | ||
235 | dac_reg |= AD193X_DAC_BCLK_MASTER; | ||
236 | break; | ||
237 | case SND_SOC_DAIFMT_CBS_CFS: /* codec clk & frm slave */ | ||
238 | adc_reg &= ~AD193X_ADC_LCR_MASTER; | ||
239 | adc_reg &= ~AD193X_ADC_BCLK_MASTER; | ||
240 | dac_reg &= ~AD193X_DAC_LCR_MASTER; | ||
241 | dac_reg &= ~AD193X_DAC_BCLK_MASTER; | ||
242 | break; | ||
243 | default: | ||
244 | return -EINVAL; | ||
245 | } | ||
246 | |||
247 | snd_soc_write(codec, AD193X_ADC_CTRL2, adc_reg); | ||
248 | snd_soc_write(codec, AD193X_DAC_CTRL1, dac_reg); | ||
249 | |||
250 | return 0; | ||
251 | } | ||
252 | |||
253 | static int ad193x_hw_params(struct snd_pcm_substream *substream, | ||
254 | struct snd_pcm_hw_params *params, | ||
255 | struct snd_soc_dai *dai) | ||
256 | { | ||
257 | int word_len = 0, reg = 0; | ||
258 | |||
259 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
260 | struct snd_soc_device *socdev = rtd->socdev; | ||
261 | struct snd_soc_codec *codec = socdev->card->codec; | ||
262 | |||
263 | /* bit size */ | ||
264 | switch (params_format(params)) { | ||
265 | case SNDRV_PCM_FORMAT_S16_LE: | ||
266 | word_len = 3; | ||
267 | break; | ||
268 | case SNDRV_PCM_FORMAT_S20_3LE: | ||
269 | word_len = 1; | ||
270 | break; | ||
271 | case SNDRV_PCM_FORMAT_S24_LE: | ||
272 | case SNDRV_PCM_FORMAT_S32_LE: | ||
273 | word_len = 0; | ||
274 | break; | ||
275 | } | ||
276 | |||
277 | reg = snd_soc_read(codec, AD193X_DAC_CTRL2); | ||
278 | reg = (reg & (~AD193X_DAC_WORD_LEN_MASK)) | word_len; | ||
279 | snd_soc_write(codec, AD193X_DAC_CTRL2, reg); | ||
280 | |||
281 | reg = snd_soc_read(codec, AD193X_ADC_CTRL1); | ||
282 | reg = (reg & (~AD193X_ADC_WORD_LEN_MASK)) | word_len; | ||
283 | snd_soc_write(codec, AD193X_ADC_CTRL1, reg); | ||
284 | |||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | int ad193x_bus_probe(struct device *dev, void *ctrl_data, int bus_type) | ||
289 | { | ||
290 | struct snd_soc_codec *codec; | ||
291 | struct ad193x_priv *ad193x; | ||
292 | |||
293 | ad193x = kzalloc(sizeof(struct ad193x_priv), GFP_KERNEL); | ||
294 | if (ad193x == NULL) | ||
295 | return -ENOMEM; | ||
296 | |||
297 | codec = &ad193x->codec; | ||
298 | codec->control_data = ctrl_data; | ||
299 | codec->dev = dev; | ||
300 | |||
301 | dev_set_drvdata(dev, ad193x); | ||
302 | |||
303 | return ad193x_register(ad193x, bus_type); | ||
304 | } | ||
305 | EXPORT_SYMBOL_GPL(ad193x_bus_probe); | ||
306 | |||
307 | int ad193x_bus_remove(struct device *dev) | ||
308 | { | ||
309 | struct ad193x_priv *ad193x = dev_get_drvdata(dev); | ||
310 | |||
311 | ad193x_unregister(ad193x); | ||
312 | return 0; | ||
313 | } | ||
314 | EXPORT_SYMBOL_GPL(ad193x_bus_remove); | ||
315 | |||
316 | static struct snd_soc_dai_ops ad193x_dai_ops = { | ||
317 | .hw_params = ad193x_hw_params, | ||
318 | .digital_mute = ad193x_mute, | ||
319 | .set_tdm_slot = ad193x_set_tdm_slot, | ||
320 | .set_fmt = ad193x_set_dai_fmt, | ||
321 | }; | ||
322 | |||
323 | /* codec DAI instance */ | ||
324 | struct snd_soc_dai ad193x_dai = { | ||
325 | .name = "AD193X", | ||
326 | .playback = { | ||
327 | .stream_name = "Playback", | ||
328 | .channels_min = 2, | ||
329 | .channels_max = 8, | ||
330 | .rates = SNDRV_PCM_RATE_48000, | ||
331 | .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE | | ||
332 | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE, | ||
333 | }, | ||
334 | .capture = { | ||
335 | .stream_name = "Capture", | ||
336 | .channels_min = 2, | ||
337 | .channels_max = 4, | ||
338 | .rates = SNDRV_PCM_RATE_48000, | ||
339 | .formats = SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S16_LE | | ||
340 | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE, | ||
341 | }, | ||
342 | .ops = &ad193x_dai_ops, | ||
343 | }; | ||
344 | EXPORT_SYMBOL_GPL(ad193x_dai); | ||
345 | |||
346 | static int ad193x_register(struct ad193x_priv *ad193x, int bus_type) | ||
347 | { | ||
348 | int ret; | ||
349 | struct snd_soc_codec *codec = &ad193x->codec; | ||
350 | |||
351 | if (ad193x_codec) { | ||
352 | dev_err(codec->dev, "Another ad193x is registered\n"); | ||
353 | return -EINVAL; | ||
354 | } | ||
355 | |||
356 | mutex_init(&codec->mutex); | ||
357 | codec->private_data = ad193x; | ||
358 | codec->reg_cache = ad193x->reg_cache; | ||
359 | codec->reg_cache_size = AD193X_NUM_REGS; | ||
360 | codec->name = "AD193X"; | ||
361 | codec->owner = THIS_MODULE; | ||
362 | codec->dai = &ad193x_dai; | ||
363 | codec->num_dai = 1; | ||
364 | INIT_LIST_HEAD(&codec->dapm_widgets); | ||
365 | INIT_LIST_HEAD(&codec->dapm_paths); | ||
366 | |||
367 | ad193x_dai.dev = codec->dev; | ||
368 | ad193x_codec = codec; | ||
369 | |||
370 | memcpy(codec->reg_cache, ad193x_reg, AD193X_NUM_REGS); | ||
371 | |||
372 | if (bus_type == SND_SOC_I2C) | ||
373 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, bus_type); | ||
374 | else | ||
375 | ret = snd_soc_codec_set_cache_io(codec, 16, 8, bus_type); | ||
376 | if (ret < 0) { | ||
377 | dev_err(codec->dev, "failed to set cache I/O: %d\n", | ||
378 | ret); | ||
379 | kfree(ad193x); | ||
380 | return ret; | ||
381 | } | ||
382 | |||
383 | /* default setting for ad193x */ | ||
384 | |||
385 | /* unmute dac channels */ | ||
386 | snd_soc_write(codec, AD193X_DAC_CHNL_MUTE, 0x0); | ||
387 | /* de-emphasis: 48kHz, powedown dac */ | ||
388 | snd_soc_write(codec, AD193X_DAC_CTRL2, 0x1A); | ||
389 | /* powerdown dac, dac in tdm mode */ | ||
390 | snd_soc_write(codec, AD193X_DAC_CTRL0, 0x41); | ||
391 | /* high-pass filter enable */ | ||
392 | snd_soc_write(codec, AD193X_ADC_CTRL0, 0x3); | ||
393 | /* sata delay=1, adc aux mode */ | ||
394 | snd_soc_write(codec, AD193X_ADC_CTRL1, 0x43); | ||
395 | /* pll input: mclki/xi */ | ||
396 | snd_soc_write(codec, AD193X_PLL_CLK_CTRL0, 0x99); /* mclk=24.576Mhz: 0x9D; mclk=12.288Mhz: 0x99 */ | ||
397 | snd_soc_write(codec, AD193X_PLL_CLK_CTRL1, 0x04); | ||
398 | |||
399 | ret = snd_soc_register_codec(codec); | ||
400 | if (ret != 0) { | ||
401 | dev_err(codec->dev, "Failed to register codec: %d\n", ret); | ||
402 | kfree(ad193x); | ||
403 | return ret; | ||
404 | } | ||
405 | |||
406 | ret = snd_soc_register_dai(&ad193x_dai); | ||
407 | if (ret != 0) { | ||
408 | dev_err(codec->dev, "Failed to register DAI: %d\n", ret); | ||
409 | snd_soc_unregister_codec(codec); | ||
410 | kfree(ad193x); | ||
411 | return ret; | ||
412 | } | ||
413 | |||
414 | return 0; | ||
415 | } | ||
416 | |||
417 | static void ad193x_unregister(struct ad193x_priv *ad193x) | ||
418 | { | ||
419 | snd_soc_unregister_dai(&ad193x_dai); | ||
420 | snd_soc_unregister_codec(&ad193x->codec); | ||
421 | kfree(ad193x); | ||
422 | ad193x_codec = NULL; | ||
423 | } | ||
424 | |||
425 | static int ad193x_probe(struct platform_device *pdev) | ||
426 | { | ||
427 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
428 | struct snd_soc_codec *codec; | ||
429 | int ret = 0; | ||
430 | |||
431 | if (ad193x_codec == NULL) { | ||
432 | dev_err(&pdev->dev, "Codec device not registered\n"); | ||
433 | return -ENODEV; | ||
434 | } | ||
435 | |||
436 | socdev->card->codec = ad193x_codec; | ||
437 | codec = ad193x_codec; | ||
438 | |||
439 | /* register pcms */ | ||
440 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | ||
441 | if (ret < 0) { | ||
442 | dev_err(codec->dev, "failed to create pcms: %d\n", ret); | ||
443 | goto pcm_err; | ||
444 | } | ||
445 | |||
446 | snd_soc_add_controls(codec, ad193x_snd_controls, | ||
447 | ARRAY_SIZE(ad193x_snd_controls)); | ||
448 | snd_soc_dapm_new_controls(codec, ad193x_dapm_widgets, | ||
449 | ARRAY_SIZE(ad193x_dapm_widgets)); | ||
450 | snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths)); | ||
451 | |||
452 | pcm_err: | ||
453 | return ret; | ||
454 | } | ||
455 | |||
456 | /* power down chip */ | ||
457 | static int ad193x_remove(struct platform_device *pdev) | ||
458 | { | ||
459 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
460 | |||
461 | snd_soc_free_pcms(socdev); | ||
462 | snd_soc_dapm_free(socdev); | ||
463 | |||
464 | return 0; | ||
465 | } | ||
466 | |||
467 | struct snd_soc_codec_device soc_codec_dev_ad193x = { | ||
468 | .probe = ad193x_probe, | ||
469 | .remove = ad193x_remove, | ||
470 | }; | ||
471 | EXPORT_SYMBOL_GPL(soc_codec_dev_ad193x); | ||
472 | |||
473 | #if defined(CONFIG_SPI_MASTER) | ||
474 | static int __devinit ad193x_spi_probe(struct spi_device *spi) | ||
475 | { | ||
476 | return ad193x_bus_probe(&spi->dev, spi, SND_SOC_SPI); | ||
477 | } | ||
478 | |||
479 | static int __devexit ad193x_spi_remove(struct spi_device *spi) | ||
480 | { | ||
481 | return ad193x_bus_remove(&spi->dev); | ||
482 | } | ||
483 | |||
484 | static struct spi_driver ad193x_spi_driver = { | ||
485 | .driver = { | ||
486 | .name = "ad193x", | ||
487 | .owner = THIS_MODULE, | ||
488 | }, | ||
489 | .probe = ad193x_spi_probe, | ||
490 | .remove = __devexit_p(ad193x_spi_remove), | ||
491 | }; | ||
492 | #endif | ||
493 | |||
494 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
495 | static const struct i2c_device_id ad193x_id[] = { | ||
496 | { "ad1936", 0 }, | ||
497 | { "ad1937", 0 }, | ||
498 | { } | ||
499 | }; | ||
500 | MODULE_DEVICE_TABLE(i2c, ad193x_id); | ||
501 | |||
502 | static int __devinit ad193x_i2c_probe(struct i2c_client *client, | ||
503 | const struct i2c_device_id *id) | ||
504 | { | ||
505 | return ad193x_bus_probe(&client->dev, client, SND_SOC_I2C); | ||
506 | } | ||
507 | |||
508 | static int __devexit ad193x_i2c_remove(struct i2c_client *client) | ||
509 | { | ||
510 | return ad193x_bus_remove(&client->dev); | ||
511 | } | ||
512 | |||
513 | static struct i2c_driver ad193x_i2c_driver = { | ||
514 | .driver = { | ||
515 | .name = "ad193x", | ||
516 | }, | ||
517 | .probe = ad193x_i2c_probe, | ||
518 | .remove = __devexit_p(ad193x_i2c_remove), | ||
519 | .id_table = ad193x_id, | ||
520 | }; | ||
521 | #endif | ||
522 | |||
523 | static int __init ad193x_modinit(void) | ||
524 | { | ||
525 | int ret; | ||
526 | |||
527 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
528 | ret = i2c_add_driver(&ad193x_i2c_driver); | ||
529 | if (ret != 0) { | ||
530 | printk(KERN_ERR "Failed to register AD193X I2C driver: %d\n", | ||
531 | ret); | ||
532 | } | ||
533 | #endif | ||
534 | |||
535 | #if defined(CONFIG_SPI_MASTER) | ||
536 | ret = spi_register_driver(&ad193x_spi_driver); | ||
537 | if (ret != 0) { | ||
538 | printk(KERN_ERR "Failed to register AD193X SPI driver: %d\n", | ||
539 | ret); | ||
540 | } | ||
541 | #endif | ||
542 | return ret; | ||
543 | } | ||
544 | module_init(ad193x_modinit); | ||
545 | |||
546 | static void __exit ad193x_modexit(void) | ||
547 | { | ||
548 | #if defined(CONFIG_SPI_MASTER) | ||
549 | spi_unregister_driver(&ad193x_spi_driver); | ||
550 | #endif | ||
551 | |||
552 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
553 | i2c_del_driver(&ad193x_i2c_driver); | ||
554 | #endif | ||
555 | } | ||
556 | module_exit(ad193x_modexit); | ||
557 | |||
558 | MODULE_DESCRIPTION("ASoC ad193x driver"); | ||
559 | MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); | ||
560 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/ad193x.h b/sound/soc/codecs/ad193x.h new file mode 100644 index 000000000000..b240d1d67c22 --- /dev/null +++ b/sound/soc/codecs/ad193x.h | |||
@@ -0,0 +1,83 @@ | |||
1 | /* | ||
2 | * AD193X Audio Codec driver | ||
3 | * | ||
4 | * Copyright 2010 Analog Devices Inc. | ||
5 | * | ||
6 | * Licensed under the GPL-2 or later. | ||
7 | */ | ||
8 | |||
9 | #ifndef __AD193X_H__ | ||
10 | #define __AD193X_H__ | ||
11 | |||
12 | #define AD193X_PLL_CLK_CTRL0 0x800 | ||
13 | #define AD193X_PLL_POWERDOWN 0x01 | ||
14 | #define AD193X_PLL_CLK_CTRL1 0x801 | ||
15 | #define AD193X_DAC_CTRL0 0x802 | ||
16 | #define AD193X_DAC_POWERDOWN 0x01 | ||
17 | #define AD193X_DAC_SERFMT_MASK 0xC0 | ||
18 | #define AD193X_DAC_SERFMT_STEREO (0 << 6) | ||
19 | #define AD193X_DAC_SERFMT_TDM (1 << 6) | ||
20 | #define AD193X_DAC_CTRL1 0x803 | ||
21 | #define AD193X_DAC_2_CHANNELS 0 | ||
22 | #define AD193X_DAC_4_CHANNELS 1 | ||
23 | #define AD193X_DAC_8_CHANNELS 2 | ||
24 | #define AD193X_DAC_16_CHANNELS 3 | ||
25 | #define AD193X_DAC_CHAN_SHFT 1 | ||
26 | #define AD193X_DAC_CHAN_MASK (3 << AD193X_DAC_CHAN_SHFT) | ||
27 | #define AD193X_DAC_LCR_MASTER (1 << 4) | ||
28 | #define AD193X_DAC_BCLK_MASTER (1 << 5) | ||
29 | #define AD193X_DAC_LEFT_HIGH (1 << 3) | ||
30 | #define AD193X_DAC_BCLK_INV (1 << 7) | ||
31 | #define AD193X_DAC_CTRL2 0x804 | ||
32 | #define AD193X_DAC_WORD_LEN_MASK 0xC | ||
33 | #define AD193X_DAC_MASTER_MUTE 1 | ||
34 | #define AD193X_DAC_CHNL_MUTE 0x805 | ||
35 | #define AD193X_DACL1_MUTE 0 | ||
36 | #define AD193X_DACR1_MUTE 1 | ||
37 | #define AD193X_DACL2_MUTE 2 | ||
38 | #define AD193X_DACR2_MUTE 3 | ||
39 | #define AD193X_DACL3_MUTE 4 | ||
40 | #define AD193X_DACR3_MUTE 5 | ||
41 | #define AD193X_DACL4_MUTE 6 | ||
42 | #define AD193X_DACR4_MUTE 7 | ||
43 | #define AD193X_DAC_L1_VOL 0x806 | ||
44 | #define AD193X_DAC_R1_VOL 0x807 | ||
45 | #define AD193X_DAC_L2_VOL 0x808 | ||
46 | #define AD193X_DAC_R2_VOL 0x809 | ||
47 | #define AD193X_DAC_L3_VOL 0x80a | ||
48 | #define AD193X_DAC_R3_VOL 0x80b | ||
49 | #define AD193X_DAC_L4_VOL 0x80c | ||
50 | #define AD193X_DAC_R4_VOL 0x80d | ||
51 | #define AD193X_ADC_CTRL0 0x80e | ||
52 | #define AD193X_ADC_POWERDOWN 0x01 | ||
53 | #define AD193X_ADC_HIGHPASS_FILTER 1 | ||
54 | #define AD193X_ADCL1_MUTE 2 | ||
55 | #define AD193X_ADCR1_MUTE 3 | ||
56 | #define AD193X_ADCL2_MUTE 4 | ||
57 | #define AD193X_ADCR2_MUTE 5 | ||
58 | #define AD193X_ADC_CTRL1 0x80f | ||
59 | #define AD193X_ADC_SERFMT_MASK 0x60 | ||
60 | #define AD193X_ADC_SERFMT_STEREO (0 << 5) | ||
61 | #define AD193X_ADC_SERFMT_TDM (1 << 2) | ||
62 | #define AD193X_ADC_SERFMT_AUX (2 << 5) | ||
63 | #define AD193X_ADC_WORD_LEN_MASK 0x3 | ||
64 | #define AD193X_ADC_CTRL2 0x810 | ||
65 | #define AD193X_ADC_2_CHANNELS 0 | ||
66 | #define AD193X_ADC_4_CHANNELS 1 | ||
67 | #define AD193X_ADC_8_CHANNELS 2 | ||
68 | #define AD193X_ADC_16_CHANNELS 3 | ||
69 | #define AD193X_ADC_CHAN_SHFT 4 | ||
70 | #define AD193X_ADC_CHAN_MASK (3 << AD193X_ADC_CHAN_SHFT) | ||
71 | #define AD193X_ADC_LCR_MASTER (1 << 3) | ||
72 | #define AD193X_ADC_BCLK_MASTER (1 << 6) | ||
73 | #define AD193X_ADC_LEFT_HIGH (1 << 2) | ||
74 | #define AD193X_ADC_BCLK_INV (1 << 1) | ||
75 | |||
76 | #define AD193X_NUM_REGS 17 | ||
77 | |||
78 | extern struct snd_soc_dai ad193x_dai; | ||
79 | extern struct snd_soc_codec_device soc_codec_dev_ad193x; | ||
80 | extern int ad193x_bus_probe(struct device *dev, void *ctrl_data, int bus_type); | ||
81 | extern int ad193x_bus_remove(struct device *dev); | ||
82 | |||
83 | #endif | ||