diff options
author | Misael Lopez Cruz <x0052729@ti.com> | 2010-02-22 16:09:22 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-02-23 05:41:05 -0500 |
commit | db72c2f89790f919d65d0adbee390958005c40fc (patch) | |
tree | 89d16b9604fe188a54f4ba07d67cf52b9428001e /sound/soc | |
parent | b3b0b4580bcb771d1d53b3d5acf689cba9907392 (diff) |
ASoC: OMAP4: Add McPDM platform driver
McPDM platform driver is configured to use sDMA in order to transfer
to/from memory. Support for interfacing with ABE will be added later.
McPDM dai currently supports up to 4 downlink channels and 2 uplink
channels simultaneously, as well as 88.2 and 96 KHz, and a sample
size of 32 bits.
Signed-off-by: Misael Lopez Cruz <x0052729@ti.com>
Signed-off-by: Margarita Olaya <x0080101@ti.com>
Signed-off-by: Jorge Eduardo Candelaria <jorge.candelaria@ti.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/omap/Kconfig | 3 | ||||
-rw-r--r-- | sound/soc/omap/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/omap/omap-mcpdm.c | 251 | ||||
-rw-r--r-- | sound/soc/omap/omap-mcpdm.h | 29 |
4 files changed, 285 insertions, 0 deletions
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index 18ebdc7d0a51..f11963c21873 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig | |||
@@ -6,6 +6,9 @@ config SND_OMAP_SOC_MCBSP | |||
6 | tristate | 6 | tristate |
7 | select OMAP_MCBSP | 7 | select OMAP_MCBSP |
8 | 8 | ||
9 | config SND_OMAP_SOC_MCPDM | ||
10 | tristate | ||
11 | |||
9 | config SND_OMAP_SOC_N810 | 12 | config SND_OMAP_SOC_N810 |
10 | tristate "SoC Audio support for Nokia N810" | 13 | tristate "SoC Audio support for Nokia N810" |
11 | depends on SND_OMAP_SOC && MACH_NOKIA_N810 && I2C | 14 | depends on SND_OMAP_SOC && MACH_NOKIA_N810 && I2C |
diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile index 19283e5edfbf..0bc00ca14b37 100644 --- a/sound/soc/omap/Makefile +++ b/sound/soc/omap/Makefile | |||
@@ -1,9 +1,11 @@ | |||
1 | # OMAP Platform Support | 1 | # OMAP Platform Support |
2 | snd-soc-omap-objs := omap-pcm.o | 2 | snd-soc-omap-objs := omap-pcm.o |
3 | snd-soc-omap-mcbsp-objs := omap-mcbsp.o | 3 | snd-soc-omap-mcbsp-objs := omap-mcbsp.o |
4 | snd-soc-omap-mcpdm-objs := omap-mcpdm.o mcpdm.o | ||
4 | 5 | ||
5 | obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.o | 6 | obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.o |
6 | obj-$(CONFIG_SND_OMAP_SOC_MCBSP) += snd-soc-omap-mcbsp.o | 7 | obj-$(CONFIG_SND_OMAP_SOC_MCBSP) += snd-soc-omap-mcbsp.o |
8 | obj-$(CONFIG_SND_OMAP_SOC_MCPDM) += snd-soc-omap-mcpdm.o | ||
7 | 9 | ||
8 | # OMAP Machine Support | 10 | # OMAP Machine Support |
9 | snd-soc-n810-objs := n810.o | 11 | snd-soc-n810-objs := n810.o |
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c new file mode 100644 index 000000000000..25f19e4728bf --- /dev/null +++ b/sound/soc/omap/omap-mcpdm.c | |||
@@ -0,0 +1,251 @@ | |||
1 | /* | ||
2 | * omap-mcpdm.c -- OMAP ALSA SoC DAI driver using McPDM port | ||
3 | * | ||
4 | * Copyright (C) 2009 Texas Instruments | ||
5 | * | ||
6 | * Author: Misael Lopez Cruz <x0052729@ti.com> | ||
7 | * Contact: Jorge Eduardo Candelaria <x0107209@ti.com> | ||
8 | * Margarita Olaya <magi.olaya@ti.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * version 2 as published by the Free Software Foundation. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
22 | * 02110-1301 USA | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #include <linux/init.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/device.h> | ||
29 | #include <sound/core.h> | ||
30 | #include <sound/pcm.h> | ||
31 | #include <sound/pcm_params.h> | ||
32 | #include <sound/initval.h> | ||
33 | #include <sound/soc.h> | ||
34 | |||
35 | #include <plat/control.h> | ||
36 | #include <plat/dma.h> | ||
37 | #include <plat/mcbsp.h> | ||
38 | #include "mcpdm.h" | ||
39 | #include "omap-mcpdm.h" | ||
40 | #include "omap-pcm.h" | ||
41 | |||
42 | struct omap_mcpdm_data { | ||
43 | struct omap_mcpdm_link *links; | ||
44 | int active; | ||
45 | }; | ||
46 | |||
47 | static struct omap_mcpdm_link omap_mcpdm_links[] = { | ||
48 | /* downlink */ | ||
49 | { | ||
50 | .irq_mask = MCPDM_DN_IRQ_EMPTY | MCPDM_DN_IRQ_FULL, | ||
51 | .threshold = 1, | ||
52 | .format = PDMOUTFORMAT_LJUST, | ||
53 | }, | ||
54 | /* uplink */ | ||
55 | { | ||
56 | .irq_mask = MCPDM_UP_IRQ_EMPTY | MCPDM_UP_IRQ_FULL, | ||
57 | .threshold = 1, | ||
58 | .format = PDMOUTFORMAT_LJUST, | ||
59 | }, | ||
60 | }; | ||
61 | |||
62 | static struct omap_mcpdm_data mcpdm_data = { | ||
63 | .links = omap_mcpdm_links, | ||
64 | .active = 0, | ||
65 | }; | ||
66 | |||
67 | /* | ||
68 | * Stream DMA parameters | ||
69 | */ | ||
70 | static struct omap_pcm_dma_data omap_mcpdm_dai_dma_params[] = { | ||
71 | { | ||
72 | .name = "Audio playback", | ||
73 | .dma_req = OMAP44XX_DMA_MCPDM_DL, | ||
74 | .data_type = OMAP_DMA_DATA_TYPE_S32, | ||
75 | .sync_mode = OMAP_DMA_SYNC_PACKET, | ||
76 | .packet_size = 16, | ||
77 | .port_addr = OMAP44XX_MCPDM_L3_BASE + MCPDM_DN_DATA, | ||
78 | }, | ||
79 | { | ||
80 | .name = "Audio capture", | ||
81 | .dma_req = OMAP44XX_DMA_MCPDM_UP, | ||
82 | .data_type = OMAP_DMA_DATA_TYPE_S32, | ||
83 | .sync_mode = OMAP_DMA_SYNC_PACKET, | ||
84 | .packet_size = 16, | ||
85 | .port_addr = OMAP44XX_MCPDM_L3_BASE + MCPDM_UP_DATA, | ||
86 | }, | ||
87 | }; | ||
88 | |||
89 | static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream, | ||
90 | struct snd_soc_dai *dai) | ||
91 | { | ||
92 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
93 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
94 | int err = 0; | ||
95 | |||
96 | if (!cpu_dai->active) | ||
97 | err = omap_mcpdm_request(); | ||
98 | |||
99 | return err; | ||
100 | } | ||
101 | |||
102 | static void omap_mcpdm_dai_shutdown(struct snd_pcm_substream *substream, | ||
103 | struct snd_soc_dai *dai) | ||
104 | { | ||
105 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
106 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
107 | |||
108 | if (!cpu_dai->active) | ||
109 | omap_mcpdm_free(); | ||
110 | } | ||
111 | |||
112 | static int omap_mcpdm_dai_trigger(struct snd_pcm_substream *substream, int cmd, | ||
113 | struct snd_soc_dai *dai) | ||
114 | { | ||
115 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
116 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
117 | struct omap_mcpdm_data *mcpdm_priv = cpu_dai->private_data; | ||
118 | int stream = substream->stream; | ||
119 | int err = 0; | ||
120 | |||
121 | switch (cmd) { | ||
122 | case SNDRV_PCM_TRIGGER_START: | ||
123 | case SNDRV_PCM_TRIGGER_RESUME: | ||
124 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
125 | if (!mcpdm_priv->active++) | ||
126 | omap_mcpdm_start(stream); | ||
127 | break; | ||
128 | |||
129 | case SNDRV_PCM_TRIGGER_STOP: | ||
130 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
131 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
132 | if (!--mcpdm_priv->active) | ||
133 | omap_mcpdm_stop(stream); | ||
134 | break; | ||
135 | default: | ||
136 | err = -EINVAL; | ||
137 | } | ||
138 | |||
139 | return err; | ||
140 | } | ||
141 | |||
142 | static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream, | ||
143 | struct snd_pcm_hw_params *params, | ||
144 | struct snd_soc_dai *dai) | ||
145 | { | ||
146 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
147 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
148 | struct omap_mcpdm_data *mcpdm_priv = cpu_dai->private_data; | ||
149 | struct omap_mcpdm_link *mcpdm_links = mcpdm_priv->links; | ||
150 | int stream = substream->stream; | ||
151 | int channels, err, link_mask = 0; | ||
152 | |||
153 | cpu_dai->dma_data = &omap_mcpdm_dai_dma_params[stream]; | ||
154 | |||
155 | channels = params_channels(params); | ||
156 | switch (channels) { | ||
157 | case 4: | ||
158 | if (stream == SNDRV_PCM_STREAM_CAPTURE) | ||
159 | /* up to 2 channels for capture */ | ||
160 | return -EINVAL; | ||
161 | link_mask |= 1 << 3; | ||
162 | case 3: | ||
163 | if (stream == SNDRV_PCM_STREAM_CAPTURE) | ||
164 | /* up to 2 channels for capture */ | ||
165 | return -EINVAL; | ||
166 | link_mask |= 1 << 2; | ||
167 | case 2: | ||
168 | link_mask |= 1 << 1; | ||
169 | case 1: | ||
170 | link_mask |= 1 << 0; | ||
171 | break; | ||
172 | default: | ||
173 | /* unsupported number of channels */ | ||
174 | return -EINVAL; | ||
175 | } | ||
176 | |||
177 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
178 | mcpdm_links[stream].channels = link_mask << 3; | ||
179 | err = omap_mcpdm_playback_open(&mcpdm_links[stream]); | ||
180 | } else { | ||
181 | mcpdm_links[stream].channels = link_mask << 0; | ||
182 | err = omap_mcpdm_capture_open(&mcpdm_links[stream]); | ||
183 | } | ||
184 | |||
185 | return err; | ||
186 | } | ||
187 | |||
188 | static int omap_mcpdm_dai_hw_free(struct snd_pcm_substream *substream, | ||
189 | struct snd_soc_dai *dai) | ||
190 | { | ||
191 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
192 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
193 | struct omap_mcpdm_data *mcpdm_priv = cpu_dai->private_data; | ||
194 | struct omap_mcpdm_link *mcpdm_links = mcpdm_priv->links; | ||
195 | int stream = substream->stream; | ||
196 | int err; | ||
197 | |||
198 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
199 | err = omap_mcpdm_playback_close(&mcpdm_links[stream]); | ||
200 | else | ||
201 | err = omap_mcpdm_capture_close(&mcpdm_links[stream]); | ||
202 | |||
203 | return err; | ||
204 | } | ||
205 | |||
206 | static struct snd_soc_dai_ops omap_mcpdm_dai_ops = { | ||
207 | .startup = omap_mcpdm_dai_startup, | ||
208 | .shutdown = omap_mcpdm_dai_shutdown, | ||
209 | .trigger = omap_mcpdm_dai_trigger, | ||
210 | .hw_params = omap_mcpdm_dai_hw_params, | ||
211 | .hw_free = omap_mcpdm_dai_hw_free, | ||
212 | }; | ||
213 | |||
214 | #define OMAP_MCPDM_RATES (SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) | ||
215 | #define OMAP_MCPDM_FORMATS (SNDRV_PCM_FMTBIT_S32_LE) | ||
216 | |||
217 | struct snd_soc_dai omap_mcpdm_dai = { | ||
218 | .name = "omap-mcpdm", | ||
219 | .id = -1, | ||
220 | .playback = { | ||
221 | .channels_min = 1, | ||
222 | .channels_max = 4, | ||
223 | .rates = OMAP_MCPDM_RATES, | ||
224 | .formats = OMAP_MCPDM_FORMATS, | ||
225 | }, | ||
226 | .capture = { | ||
227 | .channels_min = 1, | ||
228 | .channels_max = 2, | ||
229 | .rates = OMAP_MCPDM_RATES, | ||
230 | .formats = OMAP_MCPDM_FORMATS, | ||
231 | }, | ||
232 | .ops = &omap_mcpdm_dai_ops, | ||
233 | .private_data = &mcpdm_data, | ||
234 | }; | ||
235 | EXPORT_SYMBOL_GPL(omap_mcpdm_dai); | ||
236 | |||
237 | static int __init snd_omap_mcpdm_init(void) | ||
238 | { | ||
239 | return snd_soc_register_dai(&omap_mcpdm_dai); | ||
240 | } | ||
241 | module_init(snd_omap_mcpdm_init); | ||
242 | |||
243 | static void __exit snd_omap_mcpdm_exit(void) | ||
244 | { | ||
245 | snd_soc_unregister_dai(&omap_mcpdm_dai); | ||
246 | } | ||
247 | module_exit(snd_omap_mcpdm_exit); | ||
248 | |||
249 | MODULE_AUTHOR("Misael Lopez Cruz <x0052729@ti.com>"); | ||
250 | MODULE_DESCRIPTION("OMAP PDM SoC Interface"); | ||
251 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/omap/omap-mcpdm.h b/sound/soc/omap/omap-mcpdm.h new file mode 100644 index 000000000000..73b80d559345 --- /dev/null +++ b/sound/soc/omap/omap-mcpdm.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * omap-mcpdm.h | ||
3 | * | ||
4 | * Copyright (C) 2009 Texas Instruments | ||
5 | * | ||
6 | * Contact: Misael Lopez Cruz <x0052729@ti.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * version 2 as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
20 | * 02110-1301 USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __OMAP_MCPDM_H__ | ||
25 | #define __OMAP_MCPDM_H__ | ||
26 | |||
27 | extern struct snd_soc_dai omap_mcpdm_dai; | ||
28 | |||
29 | #endif /* End of __OMAP_MCPDM_H__ */ | ||