diff options
Diffstat (limited to 'sound/soc/blackfin/bf5xx-tdm-pcm.c')
-rw-r--r-- | sound/soc/blackfin/bf5xx-tdm-pcm.c | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/sound/soc/blackfin/bf5xx-tdm-pcm.c b/sound/soc/blackfin/bf5xx-tdm-pcm.c index 6bac1ac1a315..07cfc7a9e49a 100644 --- a/sound/soc/blackfin/bf5xx-tdm-pcm.c +++ b/sound/soc/blackfin/bf5xx-tdm-pcm.c | |||
@@ -154,7 +154,12 @@ static snd_pcm_uframes_t bf5xx_pcm_pointer(struct snd_pcm_substream *substream) | |||
154 | 154 | ||
155 | static int bf5xx_pcm_open(struct snd_pcm_substream *substream) | 155 | static int bf5xx_pcm_open(struct snd_pcm_substream *substream) |
156 | { | 156 | { |
157 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
158 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | ||
159 | struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai); | ||
157 | struct snd_pcm_runtime *runtime = substream->runtime; | 160 | struct snd_pcm_runtime *runtime = substream->runtime; |
161 | struct snd_dma_buffer *buf = &substream->dma_buffer; | ||
162 | |||
158 | int ret = 0; | 163 | int ret = 0; |
159 | 164 | ||
160 | snd_soc_set_runtime_hwparams(substream, &bf5xx_pcm_hardware); | 165 | snd_soc_set_runtime_hwparams(substream, &bf5xx_pcm_hardware); |
@@ -164,9 +169,14 @@ static int bf5xx_pcm_open(struct snd_pcm_substream *substream) | |||
164 | if (ret < 0) | 169 | if (ret < 0) |
165 | goto out; | 170 | goto out; |
166 | 171 | ||
167 | if (sport_handle != NULL) | 172 | if (sport_handle != NULL) { |
173 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
174 | sport_handle->tx_buf = buf->area; | ||
175 | else | ||
176 | sport_handle->rx_buf = buf->area; | ||
177 | |||
168 | runtime->private_data = sport_handle; | 178 | runtime->private_data = sport_handle; |
169 | else { | 179 | } else { |
170 | pr_err("sport_handle is NULL\n"); | 180 | pr_err("sport_handle is NULL\n"); |
171 | ret = -ENODEV; | 181 | ret = -ENODEV; |
172 | } | 182 | } |
@@ -249,11 +259,6 @@ static int bf5xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) | |||
249 | } | 259 | } |
250 | buf->bytes = size; | 260 | buf->bytes = size; |
251 | 261 | ||
252 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
253 | sport_handle->tx_buf = buf->area; | ||
254 | else | ||
255 | sport_handle->rx_buf = buf->area; | ||
256 | |||
257 | return 0; | 262 | return 0; |
258 | } | 263 | } |
259 | 264 | ||
@@ -274,8 +279,6 @@ static void bf5xx_pcm_free_dma_buffers(struct snd_pcm *pcm) | |||
274 | dma_free_coherent(NULL, buf->bytes, buf->area, 0); | 279 | dma_free_coherent(NULL, buf->bytes, buf->area, 0); |
275 | buf->area = NULL; | 280 | buf->area = NULL; |
276 | } | 281 | } |
277 | if (sport_handle) | ||
278 | sport_done(sport_handle); | ||
279 | } | 282 | } |
280 | 283 | ||
281 | static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32); | 284 | static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32); |
@@ -290,14 +293,14 @@ static int bf5xx_pcm_tdm_new(struct snd_card *card, struct snd_soc_dai *dai, | |||
290 | if (!card->dev->coherent_dma_mask) | 293 | if (!card->dev->coherent_dma_mask) |
291 | card->dev->coherent_dma_mask = DMA_BIT_MASK(32); | 294 | card->dev->coherent_dma_mask = DMA_BIT_MASK(32); |
292 | 295 | ||
293 | if (dai->playback.channels_min) { | 296 | if (dai->driver->playback.channels_min) { |
294 | ret = bf5xx_pcm_preallocate_dma_buffer(pcm, | 297 | ret = bf5xx_pcm_preallocate_dma_buffer(pcm, |
295 | SNDRV_PCM_STREAM_PLAYBACK); | 298 | SNDRV_PCM_STREAM_PLAYBACK); |
296 | if (ret) | 299 | if (ret) |
297 | goto out; | 300 | goto out; |
298 | } | 301 | } |
299 | 302 | ||
300 | if (dai->capture.channels_min) { | 303 | if (dai->driver->capture.channels_min) { |
301 | ret = bf5xx_pcm_preallocate_dma_buffer(pcm, | 304 | ret = bf5xx_pcm_preallocate_dma_buffer(pcm, |
302 | SNDRV_PCM_STREAM_CAPTURE); | 305 | SNDRV_PCM_STREAM_CAPTURE); |
303 | if (ret) | 306 | if (ret) |
@@ -307,25 +310,44 @@ out: | |||
307 | return ret; | 310 | return ret; |
308 | } | 311 | } |
309 | 312 | ||
310 | struct snd_soc_platform bf5xx_tdm_soc_platform = { | 313 | static struct snd_soc_platform_driver bf5xx_tdm_soc_platform = { |
311 | .name = "bf5xx-audio", | 314 | .ops = &bf5xx_pcm_tdm_ops, |
312 | .pcm_ops = &bf5xx_pcm_tdm_ops, | ||
313 | .pcm_new = bf5xx_pcm_tdm_new, | 315 | .pcm_new = bf5xx_pcm_tdm_new, |
314 | .pcm_free = bf5xx_pcm_free_dma_buffers, | 316 | .pcm_free = bf5xx_pcm_free_dma_buffers, |
315 | }; | 317 | }; |
316 | EXPORT_SYMBOL_GPL(bf5xx_tdm_soc_platform); | ||
317 | 318 | ||
318 | static int __init bfin_pcm_tdm_init(void) | 319 | static int __devinit bf5xx_soc_platform_probe(struct platform_device *pdev) |
320 | { | ||
321 | return snd_soc_register_platform(&pdev->dev, &bf5xx_tdm_soc_platform); | ||
322 | } | ||
323 | |||
324 | static int __devexit bf5xx_soc_platform_remove(struct platform_device *pdev) | ||
325 | { | ||
326 | snd_soc_unregister_platform(&pdev->dev); | ||
327 | return 0; | ||
328 | } | ||
329 | |||
330 | static struct platform_driver bfin_tdm_driver = { | ||
331 | .driver = { | ||
332 | .name = "bfin-tdm-pcm-audio", | ||
333 | .owner = THIS_MODULE, | ||
334 | }, | ||
335 | |||
336 | .probe = bf5xx_soc_platform_probe, | ||
337 | .remove = __devexit_p(bf5xx_soc_platform_remove), | ||
338 | }; | ||
339 | |||
340 | static int __init snd_bfin_tdm_init(void) | ||
319 | { | 341 | { |
320 | return snd_soc_register_platform(&bf5xx_tdm_soc_platform); | 342 | return platform_driver_register(&bfin_tdm_driver); |
321 | } | 343 | } |
322 | module_init(bfin_pcm_tdm_init); | 344 | module_init(snd_bfin_tdm_init); |
323 | 345 | ||
324 | static void __exit bfin_pcm_tdm_exit(void) | 346 | static void __exit snd_bfin_tdm_exit(void) |
325 | { | 347 | { |
326 | snd_soc_unregister_platform(&bf5xx_tdm_soc_platform); | 348 | platform_driver_unregister(&bfin_tdm_driver); |
327 | } | 349 | } |
328 | module_exit(bfin_pcm_tdm_exit); | 350 | module_exit(snd_bfin_tdm_exit); |
329 | 351 | ||
330 | MODULE_AUTHOR("Barry Song"); | 352 | MODULE_AUTHOR("Barry Song"); |
331 | MODULE_DESCRIPTION("ADI Blackfin TDM PCM DMA module"); | 353 | MODULE_DESCRIPTION("ADI Blackfin TDM PCM DMA module"); |