ep93xx-pcm.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = {
  50. .pcm_hardware = &ep93xx_pcm_hardware,
  51. .compat_filter_fn = ep93xx_pcm_dma_filter,
  52. .prealloc_buffer_size = 131072,
  53. };
  54. static int ep93xx_soc_platform_probe(struct platform_device *pdev)
  55. {
  56. return snd_dmaengine_pcm_register(&pdev->dev,
  57. &ep93xx_dmaengine_pcm_config,
  58. SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
  59. SND_DMAENGINE_PCM_FLAG_NO_DT |
  60. SND_DMAENGINE_PCM_FLAG_COMPAT);
  61. }
  62. static int ep93xx_soc_platform_remove(struct platform_device *pdev)
  63. {
  64. snd_dmaengine_pcm_unregister(&pdev->dev);
  65. return 0;
  66. }
  67. static struct platform_driver ep93xx_pcm_driver = {
  68. .driver = {
  69. .name = "ep93xx-pcm-audio",
  70. .owner = THIS_MODULE,
  71. },
  72. .probe = ep93xx_soc_platform_probe,
  73. .remove = ep93xx_soc_platform_remove,
  74. };
  75. module_platform_driver(ep93xx_pcm_driver);
  76. MODULE_AUTHOR("Ryan Mallon");
  77. MODULE_DESCRIPTION("EP93xx ALSA PCM interface");
  78. MODULE_LICENSE("GPL");
  79. MODULE_ALIAS("platform:ep93xx-pcm-audio");