ep93xx-pcm.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * linux/sound/arm/ep93xx-pcm.c - EP93xx ALSA PCM interface
  3. *
  4. * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
  5. * Copyright (C) 2006 Applied Data Systems
  6. *
  7. * Rewritten for the SoC audio subsystem (Based on PXA2xx code):
  8. * Copyright (c) 2008 Ryan Mallon
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/module.h>
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/dmaengine.h>
  18. #include <sound/pcm.h>
  19. #include <sound/soc.h>
  20. #include <sound/dmaengine_pcm.h>
  21. #include <linux/platform_data/dma-ep93xx.h>
  22. static const struct snd_pcm_hardware ep93xx_pcm_hardware = {
  23. .info = (SNDRV_PCM_INFO_MMAP |
  24. SNDRV_PCM_INFO_MMAP_VALID |
  25. SNDRV_PCM_INFO_INTERLEAVED |
  26. SNDRV_PCM_INFO_BLOCK_TRANSFER),
  27. .rates = SNDRV_PCM_RATE_8000_192000,
  28. .rate_min = SNDRV_PCM_RATE_8000,
  29. .rate_max = SNDRV_PCM_RATE_192000,
  30. .formats = (SNDRV_PCM_FMTBIT_S16_LE |
  31. SNDRV_PCM_FMTBIT_S24_LE |
  32. SNDRV_PCM_FMTBIT_S32_LE),
  33. .buffer_bytes_max = 131072,
  34. .period_bytes_min = 32,
  35. .period_bytes_max = 32768,
  36. .periods_min = 1,
  37. .periods_max = 32,
  38. .fifo_size = 32,
  39. };
  40. static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param)
  41. {
  42. struct ep93xx_dma_data *data = filter_param;
  43. if (data->direction == ep93xx_dma_chan_direction(chan)) {
  44. chan->private = data;
  45. return true;
  46. }
  47. return false;
  48. }
  49. static struct dma_chan *ep93xx_compat_request_channel(
  50. struct snd_soc_pcm_runtime *rtd,
  51. struct snd_pcm_substream *substream)
  52. {
  53. struct snd_dmaengine_dai_dma_data *dma_data;
  54. dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
  55. return snd_dmaengine_pcm_request_channel(ep93xx_pcm_dma_filter,
  56. dma_data);
  57. }
  58. static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
  59. .pcm_hardware = &ep93xx_pcm_hardware,
  60. .compat_filter_fn = ep93xx_pcm_dma_filter,
  61. .compat_request_channel = ep93xx_compat_request_channel,
  62. .prealloc_buffer_size = 131072,
  63. };
  64. static int ep93xx_soc_platform_probe(struct platform_device *pdev)
  65. {
  66. return snd_dmaengine_pcm_register(&pdev->dev,
  67. &ep93xx_dmaengine_pcm_config,
  68. SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
  69. SND_DMAENGINE_PCM_FLAG_NO_DT |
  70. SND_DMAENGINE_PCM_FLAG_COMPAT);
  71. }
  72. static int ep93xx_soc_platform_remove(struct platform_device *pdev)
  73. {
  74. snd_dmaengine_pcm_unregister(&pdev->dev);
  75. return 0;
  76. }
  77. static struct platform_driver ep93xx_pcm_driver = {
  78. .driver = {
  79. .name = "ep93xx-pcm-audio",
  80. .owner = THIS_MODULE,
  81. },
  82. .probe = ep93xx_soc_platform_probe,
  83. .remove = ep93xx_soc_platform_remove,
  84. };
  85. module_platform_driver(ep93xx_pcm_driver);
  86. MODULE_AUTHOR("Ryan Mallon");
  87. MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
  88. MODULE_LICENSE("GPL");
  89. MODULE_ALIAS("platform:ep93xx-pcm-audio");