diff options
author | Takashi Iwai <tiwai@suse.de> | 2010-05-20 06:00:43 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-05-20 06:00:43 -0400 |
commit | d71f4cece4bd97d05592836202fc04ff2e7817e3 (patch) | |
tree | 6c877c7a938758b1323d9c97d46b9c536e618c69 /sound/soc/davinci | |
parent | 19008bdacb9f7841166ebafe0aef361ee582ffbf (diff) | |
parent | ad8332c1302bcb4f80d593fd3eb477be9d7f5604 (diff) |
Merge branch 'topic/asoc' into for-linus
Conflicts:
sound/soc/codecs/ad1938.c
Diffstat (limited to 'sound/soc/davinci')
-rw-r--r-- | sound/soc/davinci/Kconfig | 27 | ||||
-rw-r--r-- | sound/soc/davinci/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/davinci/davinci-evm.c | 61 | ||||
-rw-r--r-- | sound/soc/davinci/davinci-vcif.c | 274 | ||||
-rw-r--r-- | sound/soc/davinci/davinci-vcif.h | 28 |
5 files changed, 387 insertions, 5 deletions
diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig index 047ee39418c0..6bbf001f6591 100644 --- a/sound/soc/davinci/Kconfig +++ b/sound/soc/davinci/Kconfig | |||
@@ -12,15 +12,38 @@ config SND_DAVINCI_SOC_I2S | |||
12 | config SND_DAVINCI_SOC_MCASP | 12 | config SND_DAVINCI_SOC_MCASP |
13 | tristate | 13 | tristate |
14 | 14 | ||
15 | config SND_DAVINCI_SOC_VCIF | ||
16 | tristate | ||
17 | |||
15 | config SND_DAVINCI_SOC_EVM | 18 | config SND_DAVINCI_SOC_EVM |
16 | tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM" | 19 | tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM" |
17 | depends on SND_DAVINCI_SOC | 20 | depends on SND_DAVINCI_SOC |
18 | depends on MACH_DAVINCI_EVM || MACH_DAVINCI_DM355_EVM || MACH_DAVINCI_DM365_EVM | 21 | depends on MACH_DAVINCI_EVM || MACH_DAVINCI_DM355_EVM || MACH_DAVINCI_DM365_EVM |
19 | select SND_DAVINCI_SOC_I2S | 22 | select SND_DAVINCI_SOC_I2S |
20 | select SND_SOC_TLV320AIC3X | 23 | select SND_SOC_TLV320AIC3X |
21 | help | 24 | help |
22 | Say Y if you want to add support for SoC audio on TI | 25 | Say Y if you want to add support for SoC audio on TI |
23 | DaVinci DM6446 or DM355 EVM platforms. | 26 | DaVinci DM6446, DM355 or DM365 EVM platforms. |
27 | |||
28 | choice | ||
29 | prompt "DM365 codec select" | ||
30 | depends on SND_DAVINCI_SOC_EVM | ||
31 | depends on MACH_DAVINCI_DM365_EVM | ||
32 | default SND_DM365_EXTERNAL_CODEC | ||
33 | |||
34 | config SND_DM365_AIC3X_CODEC | ||
35 | bool "Audio Codec - AIC3101" | ||
36 | help | ||
37 | Say Y if you want to add support for AIC3101 audio codec | ||
38 | |||
39 | config SND_DM365_VOICE_CODEC | ||
40 | bool "Voice Codec - CQ93VC" | ||
41 | select MFD_DAVINCI_VOICECODEC | ||
42 | select SND_DAVINCI_SOC_VCIF | ||
43 | select SND_SOC_CQ0093VC | ||
44 | help | ||
45 | Say Y if you want to add support for SoC On-chip voice codec | ||
46 | endchoice | ||
24 | 47 | ||
25 | config SND_DM6467_SOC_EVM | 48 | config SND_DM6467_SOC_EVM |
26 | tristate "SoC Audio support for DaVinci DM6467 EVM" | 49 | tristate "SoC Audio support for DaVinci DM6467 EVM" |
diff --git a/sound/soc/davinci/Makefile b/sound/soc/davinci/Makefile index a6939d71b988..a93679d618cd 100644 --- a/sound/soc/davinci/Makefile +++ b/sound/soc/davinci/Makefile | |||
@@ -2,10 +2,12 @@ | |||
2 | snd-soc-davinci-objs := davinci-pcm.o | 2 | snd-soc-davinci-objs := davinci-pcm.o |
3 | snd-soc-davinci-i2s-objs := davinci-i2s.o | 3 | snd-soc-davinci-i2s-objs := davinci-i2s.o |
4 | snd-soc-davinci-mcasp-objs:= davinci-mcasp.o | 4 | snd-soc-davinci-mcasp-objs:= davinci-mcasp.o |
5 | snd-soc-davinci-vcif-objs:= davinci-vcif.o | ||
5 | 6 | ||
6 | obj-$(CONFIG_SND_DAVINCI_SOC) += snd-soc-davinci.o | 7 | obj-$(CONFIG_SND_DAVINCI_SOC) += snd-soc-davinci.o |
7 | obj-$(CONFIG_SND_DAVINCI_SOC_I2S) += snd-soc-davinci-i2s.o | 8 | obj-$(CONFIG_SND_DAVINCI_SOC_I2S) += snd-soc-davinci-i2s.o |
8 | obj-$(CONFIG_SND_DAVINCI_SOC_MCASP) += snd-soc-davinci-mcasp.o | 9 | obj-$(CONFIG_SND_DAVINCI_SOC_MCASP) += snd-soc-davinci-mcasp.o |
10 | obj-$(CONFIG_SND_DAVINCI_SOC_VCIF) += snd-soc-davinci-vcif.o | ||
9 | 11 | ||
10 | # DAVINCI Machine Support | 12 | # DAVINCI Machine Support |
11 | snd-soc-evm-objs := davinci-evm.o | 13 | snd-soc-evm-objs := davinci-evm.o |
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index 7ccbe6684fc2..97f74d6a33e6 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c | |||
@@ -28,10 +28,12 @@ | |||
28 | #include <mach/mux.h> | 28 | #include <mach/mux.h> |
29 | 29 | ||
30 | #include "../codecs/tlv320aic3x.h" | 30 | #include "../codecs/tlv320aic3x.h" |
31 | #include "../codecs/cq93vc.h" | ||
31 | #include "../codecs/spdif_transciever.h" | 32 | #include "../codecs/spdif_transciever.h" |
32 | #include "davinci-pcm.h" | 33 | #include "davinci-pcm.h" |
33 | #include "davinci-i2s.h" | 34 | #include "davinci-i2s.h" |
34 | #include "davinci-mcasp.h" | 35 | #include "davinci-mcasp.h" |
36 | #include "davinci-vcif.h" | ||
35 | 37 | ||
36 | #define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \ | 38 | #define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \ |
37 | SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF) | 39 | SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF) |
@@ -81,10 +83,24 @@ static int evm_hw_params(struct snd_pcm_substream *substream, | |||
81 | return 0; | 83 | return 0; |
82 | } | 84 | } |
83 | 85 | ||
86 | static int evm_spdif_hw_params(struct snd_pcm_substream *substream, | ||
87 | struct snd_pcm_hw_params *params) | ||
88 | { | ||
89 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
90 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
91 | |||
92 | /* set cpu DAI configuration */ | ||
93 | return snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT); | ||
94 | } | ||
95 | |||
84 | static struct snd_soc_ops evm_ops = { | 96 | static struct snd_soc_ops evm_ops = { |
85 | .hw_params = evm_hw_params, | 97 | .hw_params = evm_hw_params, |
86 | }; | 98 | }; |
87 | 99 | ||
100 | static struct snd_soc_ops evm_spdif_ops = { | ||
101 | .hw_params = evm_spdif_hw_params, | ||
102 | }; | ||
103 | |||
88 | /* davinci-evm machine dapm widgets */ | 104 | /* davinci-evm machine dapm widgets */ |
89 | static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { | 105 | static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { |
90 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | 106 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
@@ -151,6 +167,22 @@ static struct snd_soc_dai_link evm_dai = { | |||
151 | .ops = &evm_ops, | 167 | .ops = &evm_ops, |
152 | }; | 168 | }; |
153 | 169 | ||
170 | static struct snd_soc_dai_link dm365_evm_dai = { | ||
171 | #ifdef CONFIG_SND_DM365_AIC3X_CODEC | ||
172 | .name = "TLV320AIC3X", | ||
173 | .stream_name = "AIC3X", | ||
174 | .cpu_dai = &davinci_i2s_dai, | ||
175 | .codec_dai = &aic3x_dai, | ||
176 | .init = evm_aic3x_init, | ||
177 | .ops = &evm_ops, | ||
178 | #elif defined(CONFIG_SND_DM365_VOICE_CODEC) | ||
179 | .name = "Voice Codec - CQ93VC", | ||
180 | .stream_name = "CQ93", | ||
181 | .cpu_dai = &davinci_vcif_dai, | ||
182 | .codec_dai = &cq93vc_dai, | ||
183 | #endif | ||
184 | }; | ||
185 | |||
154 | static struct snd_soc_dai_link dm6467_evm_dai[] = { | 186 | static struct snd_soc_dai_link dm6467_evm_dai[] = { |
155 | { | 187 | { |
156 | .name = "TLV320AIC3X", | 188 | .name = "TLV320AIC3X", |
@@ -165,7 +197,7 @@ static struct snd_soc_dai_link dm6467_evm_dai[] = { | |||
165 | .stream_name = "spdif", | 197 | .stream_name = "spdif", |
166 | .cpu_dai = &davinci_mcasp_dai[DAVINCI_MCASP_DIT_DAI], | 198 | .cpu_dai = &davinci_mcasp_dai[DAVINCI_MCASP_DIT_DAI], |
167 | .codec_dai = &dit_stub_dai, | 199 | .codec_dai = &dit_stub_dai, |
168 | .ops = &evm_ops, | 200 | .ops = &evm_spdif_ops, |
169 | }, | 201 | }, |
170 | }; | 202 | }; |
171 | static struct snd_soc_dai_link da8xx_evm_dai = { | 203 | static struct snd_soc_dai_link da8xx_evm_dai = { |
@@ -177,7 +209,7 @@ static struct snd_soc_dai_link da8xx_evm_dai = { | |||
177 | .ops = &evm_ops, | 209 | .ops = &evm_ops, |
178 | }; | 210 | }; |
179 | 211 | ||
180 | /* davinci dm6446, dm355 or dm365 evm audio machine driver */ | 212 | /* davinci dm6446, dm355 evm audio machine driver */ |
181 | static struct snd_soc_card snd_soc_card_evm = { | 213 | static struct snd_soc_card snd_soc_card_evm = { |
182 | .name = "DaVinci EVM", | 214 | .name = "DaVinci EVM", |
183 | .platform = &davinci_soc_platform, | 215 | .platform = &davinci_soc_platform, |
@@ -185,6 +217,15 @@ static struct snd_soc_card snd_soc_card_evm = { | |||
185 | .num_links = 1, | 217 | .num_links = 1, |
186 | }; | 218 | }; |
187 | 219 | ||
220 | /* davinci dm365 evm audio machine driver */ | ||
221 | static struct snd_soc_card dm365_snd_soc_card_evm = { | ||
222 | .name = "DaVinci DM365 EVM", | ||
223 | .platform = &davinci_soc_platform, | ||
224 | .dai_link = &dm365_evm_dai, | ||
225 | .num_links = 1, | ||
226 | }; | ||
227 | |||
228 | |||
188 | /* davinci dm6467 evm audio machine driver */ | 229 | /* davinci dm6467 evm audio machine driver */ |
189 | static struct snd_soc_card dm6467_snd_soc_card_evm = { | 230 | static struct snd_soc_card dm6467_snd_soc_card_evm = { |
190 | .name = "DaVinci DM6467 EVM", | 231 | .name = "DaVinci DM6467 EVM", |
@@ -217,6 +258,17 @@ static struct snd_soc_device evm_snd_devdata = { | |||
217 | }; | 258 | }; |
218 | 259 | ||
219 | /* evm audio subsystem */ | 260 | /* evm audio subsystem */ |
261 | static struct snd_soc_device dm365_evm_snd_devdata = { | ||
262 | .card = &dm365_snd_soc_card_evm, | ||
263 | #ifdef CONFIG_SND_DM365_AIC3X_CODEC | ||
264 | .codec_dev = &soc_codec_dev_aic3x, | ||
265 | .codec_data = &aic3x_setup, | ||
266 | #elif defined(CONFIG_SND_DM365_VOICE_CODEC) | ||
267 | .codec_dev = &soc_codec_dev_cq93vc, | ||
268 | #endif | ||
269 | }; | ||
270 | |||
271 | /* evm audio subsystem */ | ||
220 | static struct snd_soc_device dm6467_evm_snd_devdata = { | 272 | static struct snd_soc_device dm6467_evm_snd_devdata = { |
221 | .card = &dm6467_snd_soc_card_evm, | 273 | .card = &dm6467_snd_soc_card_evm, |
222 | .codec_dev = &soc_codec_dev_aic3x, | 274 | .codec_dev = &soc_codec_dev_aic3x, |
@@ -244,12 +296,15 @@ static int __init evm_init(void) | |||
244 | int index; | 296 | int index; |
245 | int ret; | 297 | int ret; |
246 | 298 | ||
247 | if (machine_is_davinci_evm() || machine_is_davinci_dm365_evm()) { | 299 | if (machine_is_davinci_evm()) { |
248 | evm_snd_dev_data = &evm_snd_devdata; | 300 | evm_snd_dev_data = &evm_snd_devdata; |
249 | index = 0; | 301 | index = 0; |
250 | } else if (machine_is_davinci_dm355_evm()) { | 302 | } else if (machine_is_davinci_dm355_evm()) { |
251 | evm_snd_dev_data = &evm_snd_devdata; | 303 | evm_snd_dev_data = &evm_snd_devdata; |
252 | index = 1; | 304 | index = 1; |
305 | } else if (machine_is_davinci_dm365_evm()) { | ||
306 | evm_snd_dev_data = &dm365_evm_snd_devdata; | ||
307 | index = 0; | ||
253 | } else if (machine_is_davinci_dm6467_evm()) { | 308 | } else if (machine_is_davinci_dm6467_evm()) { |
254 | evm_snd_dev_data = &dm6467_evm_snd_devdata; | 309 | evm_snd_dev_data = &dm6467_evm_snd_devdata; |
255 | index = 0; | 310 | index = 0; |
diff --git a/sound/soc/davinci/davinci-vcif.c b/sound/soc/davinci/davinci-vcif.c new file mode 100644 index 000000000000..9aa980d38231 --- /dev/null +++ b/sound/soc/davinci/davinci-vcif.c | |||
@@ -0,0 +1,274 @@ | |||
1 | /* | ||
2 | * ALSA SoC Voice Codec Interface for TI DAVINCI processor | ||
3 | * | ||
4 | * Copyright (C) 2010 Texas Instruments. | ||
5 | * | ||
6 | * Author: Miguel Aguilar <miguel.aguilar@ridgerun.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #include <linux/init.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/device.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/io.h> | ||
29 | #include <linux/mfd/davinci_voicecodec.h> | ||
30 | |||
31 | #include <sound/core.h> | ||
32 | #include <sound/pcm.h> | ||
33 | #include <sound/pcm_params.h> | ||
34 | #include <sound/initval.h> | ||
35 | #include <sound/soc.h> | ||
36 | |||
37 | #include "davinci-pcm.h" | ||
38 | #include "davinci-i2s.h" | ||
39 | #include "davinci-vcif.h" | ||
40 | |||
41 | #define MOD_REG_BIT(val, mask, set) do { \ | ||
42 | if (set) { \ | ||
43 | val |= mask; \ | ||
44 | } else { \ | ||
45 | val &= ~mask; \ | ||
46 | } \ | ||
47 | } while (0) | ||
48 | |||
49 | struct davinci_vcif_dev { | ||
50 | struct davinci_vc *davinci_vc; | ||
51 | struct davinci_pcm_dma_params dma_params[2]; | ||
52 | }; | ||
53 | |||
54 | static void davinci_vcif_start(struct snd_pcm_substream *substream) | ||
55 | { | ||
56 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
57 | struct davinci_vcif_dev *davinci_vcif_dev = | ||
58 | rtd->dai->cpu_dai->private_data; | ||
59 | struct davinci_vc *davinci_vc = davinci_vcif_dev->davinci_vc; | ||
60 | u32 w; | ||
61 | |||
62 | /* Start the sample generator and enable transmitter/receiver */ | ||
63 | w = readl(davinci_vc->base + DAVINCI_VC_CTRL); | ||
64 | |||
65 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
66 | MOD_REG_BIT(w, DAVINCI_VC_CTRL_RSTDAC, 1); | ||
67 | else | ||
68 | MOD_REG_BIT(w, DAVINCI_VC_CTRL_RSTADC, 1); | ||
69 | |||
70 | writel(w, davinci_vc->base + DAVINCI_VC_CTRL); | ||
71 | } | ||
72 | |||
73 | static void davinci_vcif_stop(struct snd_pcm_substream *substream) | ||
74 | { | ||
75 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
76 | struct davinci_vcif_dev *davinci_vcif_dev = | ||
77 | rtd->dai->cpu_dai->private_data; | ||
78 | struct davinci_vc *davinci_vc = davinci_vcif_dev->davinci_vc; | ||
79 | u32 w; | ||
80 | |||
81 | /* Reset transmitter/receiver and sample rate/frame sync generators */ | ||
82 | w = readl(davinci_vc->base + DAVINCI_VC_CTRL); | ||
83 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
84 | MOD_REG_BIT(w, DAVINCI_VC_CTRL_RSTDAC, 0); | ||
85 | else | ||
86 | MOD_REG_BIT(w, DAVINCI_VC_CTRL_RSTADC, 0); | ||
87 | |||
88 | writel(w, davinci_vc->base + DAVINCI_VC_CTRL); | ||
89 | } | ||
90 | |||
91 | static int davinci_vcif_hw_params(struct snd_pcm_substream *substream, | ||
92 | struct snd_pcm_hw_params *params, | ||
93 | struct snd_soc_dai *dai) | ||
94 | { | ||
95 | struct davinci_vcif_dev *davinci_vcif_dev = dai->private_data; | ||
96 | struct davinci_vc *davinci_vc = davinci_vcif_dev->davinci_vc; | ||
97 | struct davinci_pcm_dma_params *dma_params = | ||
98 | &davinci_vcif_dev->dma_params[substream->stream]; | ||
99 | u32 w; | ||
100 | |||
101 | /* Restart the codec before setup */ | ||
102 | davinci_vcif_stop(substream); | ||
103 | davinci_vcif_start(substream); | ||
104 | |||
105 | /* General line settings */ | ||
106 | writel(DAVINCI_VC_CTRL_MASK, davinci_vc->base + DAVINCI_VC_CTRL); | ||
107 | |||
108 | writel(DAVINCI_VC_INT_MASK, davinci_vc->base + DAVINCI_VC_INTCLR); | ||
109 | |||
110 | writel(DAVINCI_VC_INT_MASK, davinci_vc->base + DAVINCI_VC_INTEN); | ||
111 | |||
112 | w = readl(davinci_vc->base + DAVINCI_VC_CTRL); | ||
113 | |||
114 | /* Determine xfer data type */ | ||
115 | switch (params_format(params)) { | ||
116 | case SNDRV_PCM_FORMAT_U8: | ||
117 | dma_params->data_type = 0; | ||
118 | |||
119 | MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 | | ||
120 | DAVINCI_VC_CTRL_RD_UNSIGNED | | ||
121 | DAVINCI_VC_CTRL_WD_BITS_8 | | ||
122 | DAVINCI_VC_CTRL_WD_UNSIGNED, 1); | ||
123 | break; | ||
124 | case SNDRV_PCM_FORMAT_S8: | ||
125 | dma_params->data_type = 1; | ||
126 | |||
127 | MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 | | ||
128 | DAVINCI_VC_CTRL_WD_BITS_8, 1); | ||
129 | |||
130 | MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_UNSIGNED | | ||
131 | DAVINCI_VC_CTRL_WD_UNSIGNED, 0); | ||
132 | break; | ||
133 | case SNDRV_PCM_FORMAT_S16_LE: | ||
134 | dma_params->data_type = 2; | ||
135 | |||
136 | MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 | | ||
137 | DAVINCI_VC_CTRL_RD_UNSIGNED | | ||
138 | DAVINCI_VC_CTRL_WD_BITS_8 | | ||
139 | DAVINCI_VC_CTRL_WD_UNSIGNED, 0); | ||
140 | break; | ||
141 | default: | ||
142 | printk(KERN_WARNING "davinci-vcif: unsupported PCM format"); | ||
143 | return -EINVAL; | ||
144 | } | ||
145 | |||
146 | dma_params->acnt = dma_params->data_type; | ||
147 | |||
148 | writel(w, davinci_vc->base + DAVINCI_VC_CTRL); | ||
149 | |||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | static int davinci_vcif_trigger(struct snd_pcm_substream *substream, int cmd, | ||
154 | struct snd_soc_dai *dai) | ||
155 | { | ||
156 | int ret = 0; | ||
157 | |||
158 | switch (cmd) { | ||
159 | case SNDRV_PCM_TRIGGER_START: | ||
160 | case SNDRV_PCM_TRIGGER_RESUME: | ||
161 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
162 | davinci_vcif_start(substream); | ||
163 | case SNDRV_PCM_TRIGGER_STOP: | ||
164 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
165 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
166 | davinci_vcif_stop(substream); | ||
167 | break; | ||
168 | default: | ||
169 | ret = -EINVAL; | ||
170 | } | ||
171 | |||
172 | return ret; | ||
173 | } | ||
174 | |||
175 | #define DAVINCI_VCIF_RATES SNDRV_PCM_RATE_8000_48000 | ||
176 | |||
177 | static struct snd_soc_dai_ops davinci_vcif_dai_ops = { | ||
178 | .trigger = davinci_vcif_trigger, | ||
179 | .hw_params = davinci_vcif_hw_params, | ||
180 | }; | ||
181 | |||
182 | struct snd_soc_dai davinci_vcif_dai = { | ||
183 | .name = "davinci-vcif", | ||
184 | .playback = { | ||
185 | .channels_min = 1, | ||
186 | .channels_max = 2, | ||
187 | .rates = DAVINCI_VCIF_RATES, | ||
188 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | ||
189 | .capture = { | ||
190 | .channels_min = 1, | ||
191 | .channels_max = 2, | ||
192 | .rates = DAVINCI_VCIF_RATES, | ||
193 | .formats = SNDRV_PCM_FMTBIT_S16_LE,}, | ||
194 | .ops = &davinci_vcif_dai_ops, | ||
195 | |||
196 | }; | ||
197 | EXPORT_SYMBOL_GPL(davinci_vcif_dai); | ||
198 | |||
199 | static int davinci_vcif_probe(struct platform_device *pdev) | ||
200 | { | ||
201 | struct davinci_vc *davinci_vc = platform_get_drvdata(pdev); | ||
202 | struct davinci_vcif_dev *davinci_vcif_dev; | ||
203 | int ret; | ||
204 | |||
205 | davinci_vcif_dev = kzalloc(sizeof(struct davinci_vcif_dev), GFP_KERNEL); | ||
206 | if (!davinci_vc) { | ||
207 | dev_dbg(&pdev->dev, | ||
208 | "could not allocate memory for private data\n"); | ||
209 | return -ENOMEM; | ||
210 | } | ||
211 | |||
212 | /* DMA tx params */ | ||
213 | davinci_vcif_dev->davinci_vc = davinci_vc; | ||
214 | davinci_vcif_dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].channel = | ||
215 | davinci_vc->davinci_vcif.dma_tx_channel; | ||
216 | davinci_vcif_dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].dma_addr = | ||
217 | davinci_vc->davinci_vcif.dma_tx_addr; | ||
218 | |||
219 | /* DMA rx params */ | ||
220 | davinci_vcif_dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].channel = | ||
221 | davinci_vc->davinci_vcif.dma_rx_channel; | ||
222 | davinci_vcif_dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].dma_addr = | ||
223 | davinci_vc->davinci_vcif.dma_rx_addr; | ||
224 | |||
225 | davinci_vcif_dai.dev = &pdev->dev; | ||
226 | davinci_vcif_dai.capture.dma_data = davinci_vcif_dev->dma_params; | ||
227 | davinci_vcif_dai.playback.dma_data = davinci_vcif_dev->dma_params; | ||
228 | davinci_vcif_dai.private_data = davinci_vcif_dev; | ||
229 | |||
230 | ret = snd_soc_register_dai(&davinci_vcif_dai); | ||
231 | if (ret != 0) { | ||
232 | dev_err(&pdev->dev, "could not register dai\n"); | ||
233 | goto fail; | ||
234 | } | ||
235 | |||
236 | return 0; | ||
237 | |||
238 | fail: | ||
239 | kfree(davinci_vcif_dev); | ||
240 | |||
241 | return ret; | ||
242 | } | ||
243 | |||
244 | static int davinci_vcif_remove(struct platform_device *pdev) | ||
245 | { | ||
246 | snd_soc_unregister_dai(&davinci_vcif_dai); | ||
247 | |||
248 | return 0; | ||
249 | } | ||
250 | |||
251 | static struct platform_driver davinci_vcif_driver = { | ||
252 | .probe = davinci_vcif_probe, | ||
253 | .remove = davinci_vcif_remove, | ||
254 | .driver = { | ||
255 | .name = "davinci_vcif", | ||
256 | .owner = THIS_MODULE, | ||
257 | }, | ||
258 | }; | ||
259 | |||
260 | static int __init davinci_vcif_init(void) | ||
261 | { | ||
262 | return platform_driver_probe(&davinci_vcif_driver, davinci_vcif_probe); | ||
263 | } | ||
264 | module_init(davinci_vcif_init); | ||
265 | |||
266 | static void __exit davinci_vcif_exit(void) | ||
267 | { | ||
268 | platform_driver_unregister(&davinci_vcif_driver); | ||
269 | } | ||
270 | module_exit(davinci_vcif_exit); | ||
271 | |||
272 | MODULE_AUTHOR("Miguel Aguilar"); | ||
273 | MODULE_DESCRIPTION("Texas Instruments DaVinci ASoC Voice Codec Interface"); | ||
274 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/davinci/davinci-vcif.h b/sound/soc/davinci/davinci-vcif.h new file mode 100644 index 000000000000..571c9948724f --- /dev/null +++ b/sound/soc/davinci/davinci-vcif.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | * ALSA SoC Voice Codec Interface for TI DAVINCI processor | ||
3 | * | ||
4 | * Copyright (C) 2010 Texas Instruments. | ||
5 | * | ||
6 | * Author: Miguel Aguilar <miguel.aguilar@ridgerun.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #ifndef _DAVINCI_VCIF_H | ||
24 | #define _DAVINCI_VCIF_H | ||
25 | |||
26 | extern struct snd_soc_dai davinci_vcif_dai; | ||
27 | |||
28 | #endif | ||