spear_pcm.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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<rajeevkumar.linux@gmail.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. #include "spear_pcm.h"
  21. static const struct snd_pcm_hardware spear_pcm_hardware = {
  22. .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
  23. SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
  24. SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME),
  25. .buffer_bytes_max = 16 * 1024, /* max buffer size */
  26. .period_bytes_min = 2 * 1024, /* 1 msec data minimum period size */
  27. .period_bytes_max = 2 * 1024, /* maximum period size */
  28. .periods_min = 1, /* min # periods */
  29. .periods_max = 8, /* max # of periods */
  30. .fifo_size = 0, /* fifo size in bytes */
  31. };
  32. static const struct snd_dmaengine_pcm_config spear_dmaengine_pcm_config = {
  33. .pcm_hardware = &spear_pcm_hardware,
  34. .prealloc_buffer_size = 16 * 1024,
  35. };
  36. int devm_spear_pcm_platform_register(struct device *dev,
  37. struct snd_dmaengine_pcm_config *config,
  38. bool (*filter)(struct dma_chan *chan, void *slave))
  39. {
  40. *config = spear_dmaengine_pcm_config;
  41. config->compat_filter_fn = filter;
  42. return devm_snd_dmaengine_pcm_register(dev, config,
  43. SND_DMAENGINE_PCM_FLAG_NO_DT |
  44. SND_DMAENGINE_PCM_FLAG_COMPAT);
  45. }
  46. EXPORT_SYMBOL_GPL(devm_spear_pcm_platform_register);
  47. MODULE_AUTHOR("Rajeev Kumar <rajeevkumar.linux@gmail.com>");
  48. MODULE_DESCRIPTION("SPEAr PCM DMA module");
  49. MODULE_LICENSE("GPL");