edma-pcm.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * edma-pcm.c - eDMA PCM driver using dmaengine for AM3xxx, AM4xxx
  3. *
  4. * Copyright (C) 2014 Texas Instruments, Inc.
  5. *
  6. * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
  7. *
  8. * Based on: sound/soc/tegra/tegra_pcm.c
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * version 2 as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. */
  19. #include <linux/module.h>
  20. #include <sound/core.h>
  21. #include <sound/pcm.h>
  22. #include <sound/pcm_params.h>
  23. #include <sound/soc.h>
  24. #include <sound/dmaengine_pcm.h>
  25. #include <linux/edma.h>
  26. #include "edma-pcm.h"
  27. static const struct snd_pcm_hardware edma_pcm_hardware = {
  28. .info = SNDRV_PCM_INFO_MMAP |
  29. SNDRV_PCM_INFO_MMAP_VALID |
  30. SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME |
  31. SNDRV_PCM_INFO_NO_PERIOD_WAKEUP |
  32. SNDRV_PCM_INFO_INTERLEAVED,
  33. .buffer_bytes_max = 128 * 1024,
  34. .period_bytes_min = 32,
  35. .period_bytes_max = 64 * 1024,
  36. .periods_min = 2,
  37. .periods_max = 19, /* Limit by edma dmaengine driver */
  38. };
  39. static const struct snd_dmaengine_pcm_config edma_dmaengine_pcm_config = {
  40. .pcm_hardware = &edma_pcm_hardware,
  41. .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
  42. .compat_filter_fn = edma_filter_fn,
  43. .prealloc_buffer_size = 128 * 1024,
  44. };
  45. int edma_pcm_platform_register(struct device *dev)
  46. {
  47. return devm_snd_dmaengine_pcm_register(dev, &edma_dmaengine_pcm_config,
  48. SND_DMAENGINE_PCM_FLAG_COMPAT);
  49. }
  50. EXPORT_SYMBOL_GPL(edma_pcm_platform_register);
  51. MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>");
  52. MODULE_DESCRIPTION("eDMA PCM ASoC platform driver");
  53. MODULE_LICENSE("GPL");