spear_pcm.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * ALSA PCM interface for ST SPEAr Processors
  3. *
  4. * sound/soc/spear/spear_pcm.c
  5. *
  6. * Copyright (C) 2012 ST Microelectronics
  7. * Rajeev Kumar<rajeev-dlh.kumar@st.com>
  8. *
  9. * This file is licensed under the terms of the GNU General Public
  10. * License version 2. This program is licensed "as is" without any
  11. * warranty of any kind, whether express or implied.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/dmaengine.h>
  15. #include <linux/platform_device.h>
  16. #include <sound/dmaengine_pcm.h>
  17. #include <sound/pcm.h>
  18. #include <sound/soc.h>
  19. #include <sound/spear_dma.h>
  20. static const struct snd_pcm_hardware spear_pcm_hardware = {
  21. .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
  22. SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
  23. SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
  24. .buffer_bytes_max = 16 * 1024, /* max buffer size */
  25. .period_bytes_min = 2 * 1024, /* 1 msec data minimum period size */
  26. .period_bytes_max = 2 * 1024, /* maximum period size */
  27. .periods_min = 1, /* min # periods */
  28. .periods_max = 8, /* max # of periods */
  29. .fifo_size = 0, /* fifo size in bytes */
  30. };
  31. static struct dma_chan *spear_pcm_request_chan(struct snd_soc_pcm_runtime *rtd,
  32. struct snd_pcm_substream *substream)
  33. {
  34. struct spear_dma_data *dma_data;
  35. dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
  36. return snd_dmaengine_pcm_request_channel(dma_data->filter, dma_data);
  37. }
  38. static const struct snd_dmaengine_pcm_config spear_dmaengine_pcm_config = {
  39. .pcm_hardware = &spear_pcm_hardware,
  40. .compat_request_channel = spear_pcm_request_chan,
  41. .prealloc_buffer_size = 16 * 1024,
  42. };
  43. static int spear_soc_platform_probe(struct platform_device *pdev)
  44. {
  45. return snd_dmaengine_pcm_register(&pdev->dev,
  46. &spear_dmaengine_pcm_config,
  47. SND_DMAENGINE_PCM_FLAG_NO_DT |
  48. SND_DMAENGINE_PCM_FLAG_COMPAT);
  49. }
  50. static int spear_soc_platform_remove(struct platform_device *pdev)
  51. {
  52. snd_dmaengine_pcm_unregister(&pdev->dev);
  53. return 0;
  54. }
  55. static struct platform_driver spear_pcm_driver = {
  56. .driver = {
  57. .name = "spear-pcm-audio",
  58. .owner = THIS_MODULE,
  59. },
  60. .probe = spear_soc_platform_probe,
  61. .remove = spear_soc_platform_remove,
  62. };
  63. module_platform_driver(spear_pcm_driver);
  64. MODULE_AUTHOR("Rajeev Kumar <rajeev-dlh.kumar@st.com>");
  65. MODULE_DESCRIPTION("SPEAr PCM DMA module");
  66. MODULE_LICENSE("GPL");
  67. MODULE_ALIAS("platform:spear-pcm-audio");