diff options
Diffstat (limited to 'sound/soc/omap/omap-mcpdm.c')
-rw-r--r-- | sound/soc/omap/omap-mcpdm.c | 72 |
1 files changed, 46 insertions, 26 deletions
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index b7f4f7e015f3..bed09c27e44c 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c | |||
@@ -32,11 +32,9 @@ | |||
32 | #include <sound/initval.h> | 32 | #include <sound/initval.h> |
33 | #include <sound/soc.h> | 33 | #include <sound/soc.h> |
34 | 34 | ||
35 | #include <plat/control.h> | ||
36 | #include <plat/dma.h> | 35 | #include <plat/dma.h> |
37 | #include <plat/mcbsp.h> | 36 | #include <plat/mcbsp.h> |
38 | #include "mcpdm.h" | 37 | #include "mcpdm.h" |
39 | #include "omap-mcpdm.h" | ||
40 | #include "omap-pcm.h" | 38 | #include "omap-pcm.h" |
41 | 39 | ||
42 | struct omap_mcpdm_data { | 40 | struct omap_mcpdm_data { |
@@ -89,11 +87,9 @@ static struct omap_pcm_dma_data omap_mcpdm_dai_dma_params[] = { | |||
89 | static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream, | 87 | static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream, |
90 | struct snd_soc_dai *dai) | 88 | struct snd_soc_dai *dai) |
91 | { | 89 | { |
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; | 90 | int err = 0; |
95 | 91 | ||
96 | if (!cpu_dai->active) | 92 | if (!dai->active) |
97 | err = omap_mcpdm_request(); | 93 | err = omap_mcpdm_request(); |
98 | 94 | ||
99 | return err; | 95 | return err; |
@@ -102,19 +98,14 @@ static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream, | |||
102 | static void omap_mcpdm_dai_shutdown(struct snd_pcm_substream *substream, | 98 | static void omap_mcpdm_dai_shutdown(struct snd_pcm_substream *substream, |
103 | struct snd_soc_dai *dai) | 99 | struct snd_soc_dai *dai) |
104 | { | 100 | { |
105 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 101 | if (!dai->active) |
106 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
107 | |||
108 | if (!cpu_dai->active) | ||
109 | omap_mcpdm_free(); | 102 | omap_mcpdm_free(); |
110 | } | 103 | } |
111 | 104 | ||
112 | static int omap_mcpdm_dai_trigger(struct snd_pcm_substream *substream, int cmd, | 105 | static int omap_mcpdm_dai_trigger(struct snd_pcm_substream *substream, int cmd, |
113 | struct snd_soc_dai *dai) | 106 | struct snd_soc_dai *dai) |
114 | { | 107 | { |
115 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 108 | struct omap_mcpdm_data *mcpdm_priv = snd_soc_dai_get_drvdata(dai); |
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; | 109 | int stream = substream->stream; |
119 | int err = 0; | 110 | int err = 0; |
120 | 111 | ||
@@ -143,14 +134,12 @@ static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream, | |||
143 | struct snd_pcm_hw_params *params, | 134 | struct snd_pcm_hw_params *params, |
144 | struct snd_soc_dai *dai) | 135 | struct snd_soc_dai *dai) |
145 | { | 136 | { |
146 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 137 | struct omap_mcpdm_data *mcpdm_priv = snd_soc_dai_get_drvdata(dai); |
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; | 138 | struct omap_mcpdm_link *mcpdm_links = mcpdm_priv->links; |
150 | int stream = substream->stream; | 139 | int stream = substream->stream; |
151 | int channels, err, link_mask = 0; | 140 | int channels, err, link_mask = 0; |
152 | 141 | ||
153 | snd_soc_dai_set_dma_data(cpu_dai, substream, | 142 | snd_soc_dai_set_dma_data(dai, substream, |
154 | &omap_mcpdm_dai_dma_params[stream]); | 143 | &omap_mcpdm_dai_dma_params[stream]); |
155 | 144 | ||
156 | channels = params_channels(params); | 145 | channels = params_channels(params); |
@@ -189,9 +178,7 @@ static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream, | |||
189 | static int omap_mcpdm_dai_hw_free(struct snd_pcm_substream *substream, | 178 | static int omap_mcpdm_dai_hw_free(struct snd_pcm_substream *substream, |
190 | struct snd_soc_dai *dai) | 179 | struct snd_soc_dai *dai) |
191 | { | 180 | { |
192 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 181 | struct omap_mcpdm_data *mcpdm_priv = snd_soc_dai_get_drvdata(dai); |
193 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | ||
194 | struct omap_mcpdm_data *mcpdm_priv = cpu_dai->private_data; | ||
195 | struct omap_mcpdm_link *mcpdm_links = mcpdm_priv->links; | 182 | struct omap_mcpdm_link *mcpdm_links = mcpdm_priv->links; |
196 | int stream = substream->stream; | 183 | int stream = substream->stream; |
197 | int err; | 184 | int err; |
@@ -215,9 +202,14 @@ static struct snd_soc_dai_ops omap_mcpdm_dai_ops = { | |||
215 | #define OMAP_MCPDM_RATES (SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) | 202 | #define OMAP_MCPDM_RATES (SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) |
216 | #define OMAP_MCPDM_FORMATS (SNDRV_PCM_FMTBIT_S32_LE) | 203 | #define OMAP_MCPDM_FORMATS (SNDRV_PCM_FMTBIT_S32_LE) |
217 | 204 | ||
218 | struct snd_soc_dai omap_mcpdm_dai = { | 205 | static int omap_mcpdm_dai_probe(struct snd_soc_dai *dai) |
219 | .name = "omap-mcpdm", | 206 | { |
220 | .id = -1, | 207 | snd_soc_dai_set_drvdata(dai, &mcpdm_data); |
208 | return 0; | ||
209 | } | ||
210 | |||
211 | static struct snd_soc_dai_driver omap_mcpdm_dai = { | ||
212 | .probe = omap_mcpdm_dai_probe, | ||
221 | .playback = { | 213 | .playback = { |
222 | .channels_min = 1, | 214 | .channels_min = 1, |
223 | .channels_max = 4, | 215 | .channels_max = 4, |
@@ -231,19 +223,47 @@ struct snd_soc_dai omap_mcpdm_dai = { | |||
231 | .formats = OMAP_MCPDM_FORMATS, | 223 | .formats = OMAP_MCPDM_FORMATS, |
232 | }, | 224 | }, |
233 | .ops = &omap_mcpdm_dai_ops, | 225 | .ops = &omap_mcpdm_dai_ops, |
234 | .private_data = &mcpdm_data, | ||
235 | }; | 226 | }; |
236 | EXPORT_SYMBOL_GPL(omap_mcpdm_dai); | 227 | |
228 | static __devinit int asoc_mcpdm_probe(struct platform_device *pdev) | ||
229 | { | ||
230 | int ret; | ||
231 | |||
232 | ret = omap_mcpdm_probe(pdev); | ||
233 | if (ret < 0) | ||
234 | return ret; | ||
235 | ret = snd_soc_register_dai(&pdev->dev, &omap_mcpdm_dai); | ||
236 | if (ret < 0) | ||
237 | omap_mcpdm_remove(pdev); | ||
238 | return ret; | ||
239 | } | ||
240 | |||
241 | static int __devexit asoc_mcpdm_remove(struct platform_device *pdev) | ||
242 | { | ||
243 | snd_soc_unregister_dai(&pdev->dev); | ||
244 | omap_mcpdm_remove(pdev); | ||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | static struct platform_driver asoc_mcpdm_driver = { | ||
249 | .driver = { | ||
250 | .name = "omap-mcpdm-dai", | ||
251 | .owner = THIS_MODULE, | ||
252 | }, | ||
253 | |||
254 | .probe = asoc_mcpdm_probe, | ||
255 | .remove = __devexit_p(asoc_mcpdm_remove), | ||
256 | }; | ||
237 | 257 | ||
238 | static int __init snd_omap_mcpdm_init(void) | 258 | static int __init snd_omap_mcpdm_init(void) |
239 | { | 259 | { |
240 | return snd_soc_register_dai(&omap_mcpdm_dai); | 260 | return platform_driver_register(&asoc_mcpdm_driver); |
241 | } | 261 | } |
242 | module_init(snd_omap_mcpdm_init); | 262 | module_init(snd_omap_mcpdm_init); |
243 | 263 | ||
244 | static void __exit snd_omap_mcpdm_exit(void) | 264 | static void __exit snd_omap_mcpdm_exit(void) |
245 | { | 265 | { |
246 | snd_soc_unregister_dai(&omap_mcpdm_dai); | 266 | platform_driver_unregister(&asoc_mcpdm_driver); |
247 | } | 267 | } |
248 | module_exit(snd_omap_mcpdm_exit); | 268 | module_exit(snd_omap_mcpdm_exit); |
249 | 269 | ||