aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/blackfin/bf5xx-ac97-pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/blackfin/bf5xx-ac97-pcm.c')
-rw-r--r--sound/soc/blackfin/bf5xx-ac97-pcm.c54
1 files changed, 40 insertions, 14 deletions
diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c
index 5e7aacf3bb5a..98b44b316e78 100644
--- a/sound/soc/blackfin/bf5xx-ac97-pcm.c
+++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c
@@ -243,6 +243,9 @@ static snd_pcm_uframes_t bf5xx_pcm_pointer(struct snd_pcm_substream *substream)
243 243
244static int bf5xx_pcm_open(struct snd_pcm_substream *substream) 244static int bf5xx_pcm_open(struct snd_pcm_substream *substream)
245{ 245{
246 struct snd_soc_pcm_runtime *rtd = substream->private_data;
247 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
248 struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai);
246 struct snd_pcm_runtime *runtime = substream->runtime; 249 struct snd_pcm_runtime *runtime = substream->runtime;
247 int ret; 250 int ret;
248 251
@@ -314,6 +317,9 @@ static struct snd_pcm_ops bf5xx_pcm_ac97_ops = {
314 317
315static int bf5xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) 318static int bf5xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
316{ 319{
320 struct snd_soc_pcm_runtime *rtd = pcm->private_data;
321 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
322 struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai);
317 struct snd_pcm_substream *substream = pcm->streams[stream].substream; 323 struct snd_pcm_substream *substream = pcm->streams[stream].substream;
318 struct snd_dma_buffer *buf = &substream->dma_buffer; 324 struct snd_dma_buffer *buf = &substream->dma_buffer;
319 size_t size = bf5xx_pcm_hardware.buffer_bytes_max 325 size_t size = bf5xx_pcm_hardware.buffer_bytes_max
@@ -377,6 +383,9 @@ static void bf5xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
377 struct snd_dma_buffer *buf; 383 struct snd_dma_buffer *buf;
378 int stream; 384 int stream;
379#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) 385#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT)
386 struct snd_soc_pcm_runtime *rtd = pcm->private_data;
387 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
388 struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai);
380 size_t size = bf5xx_pcm_hardware.buffer_bytes_max * 389 size_t size = bf5xx_pcm_hardware.buffer_bytes_max *
381 sizeof(struct ac97_frame) / 4; 390 sizeof(struct ac97_frame) / 4;
382#endif 391#endif
@@ -405,8 +414,6 @@ static void bf5xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
405 } 414 }
406#endif 415#endif
407 } 416 }
408 if (sport_handle)
409 sport_done(sport_handle);
410} 417}
411 418
412static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32); 419static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32);
@@ -422,14 +429,14 @@ int bf5xx_pcm_ac97_new(struct snd_card *card, struct snd_soc_dai *dai,
422 if (!card->dev->coherent_dma_mask) 429 if (!card->dev->coherent_dma_mask)
423 card->dev->coherent_dma_mask = DMA_BIT_MASK(32); 430 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
424 431
425 if (dai->playback.channels_min) { 432 if (dai->driver->playback.channels_min) {
426 ret = bf5xx_pcm_preallocate_dma_buffer(pcm, 433 ret = bf5xx_pcm_preallocate_dma_buffer(pcm,
427 SNDRV_PCM_STREAM_PLAYBACK); 434 SNDRV_PCM_STREAM_PLAYBACK);
428 if (ret) 435 if (ret)
429 goto out; 436 goto out;
430 } 437 }
431 438
432 if (dai->capture.channels_min) { 439 if (dai->driver->capture.channels_min) {
433 ret = bf5xx_pcm_preallocate_dma_buffer(pcm, 440 ret = bf5xx_pcm_preallocate_dma_buffer(pcm,
434 SNDRV_PCM_STREAM_CAPTURE); 441 SNDRV_PCM_STREAM_CAPTURE);
435 if (ret) 442 if (ret)
@@ -439,25 +446,44 @@ int bf5xx_pcm_ac97_new(struct snd_card *card, struct snd_soc_dai *dai,
439 return ret; 446 return ret;
440} 447}
441 448
442struct snd_soc_platform bf5xx_ac97_soc_platform = { 449static struct snd_soc_platform_driver bf5xx_ac97_soc_platform = {
443 .name = "bf5xx-audio", 450 .ops = &bf5xx_pcm_ac97_ops,
444 .pcm_ops = &bf5xx_pcm_ac97_ops,
445 .pcm_new = bf5xx_pcm_ac97_new, 451 .pcm_new = bf5xx_pcm_ac97_new,
446 .pcm_free = bf5xx_pcm_free_dma_buffers, 452 .pcm_free = bf5xx_pcm_free_dma_buffers,
447}; 453};
448EXPORT_SYMBOL_GPL(bf5xx_ac97_soc_platform);
449 454
450static int __init bfin_ac97_init(void) 455static int __devinit bf5xx_soc_platform_probe(struct platform_device *pdev)
451{ 456{
452 return snd_soc_register_platform(&bf5xx_ac97_soc_platform); 457 return snd_soc_register_platform(&pdev->dev, &bf5xx_ac97_soc_platform);
453} 458}
454module_init(bfin_ac97_init);
455 459
456static void __exit bfin_ac97_exit(void) 460static int __devexit bf5xx_soc_platform_remove(struct platform_device *pdev)
457{ 461{
458 snd_soc_unregister_platform(&bf5xx_ac97_soc_platform); 462 snd_soc_unregister_platform(&pdev->dev);
463 return 0;
464}
465
466static struct platform_driver bf5xx_pcm_driver = {
467 .driver = {
468 .name = "bfin-ac97-pcm-audio",
469 .owner = THIS_MODULE,
470 },
471
472 .probe = bf5xx_soc_platform_probe,
473 .remove = __devexit_p(bf5xx_soc_platform_remove),
474};
475
476static int __init snd_bf5xx_pcm_init(void)
477{
478 return platform_driver_register(&bf5xx_pcm_driver);
479}
480module_init(snd_bf5xx_pcm_init);
481
482static void __exit snd_bf5xx_pcm_exit(void)
483{
484 platform_driver_unregister(&bf5xx_pcm_driver);
459} 485}
460module_exit(bfin_ac97_exit); 486module_exit(snd_bf5xx_pcm_exit);
461 487
462MODULE_AUTHOR("Cliff Cai"); 488MODULE_AUTHOR("Cliff Cai");
463MODULE_DESCRIPTION("ADI Blackfin AC97 PCM DMA module"); 489MODULE_DESCRIPTION("ADI Blackfin AC97 PCM DMA module");