edma-pcm.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * edma-pcm.c - eDMA PCM driver using dmaengine for AM3xxx, AM4xxx
  4. *
  5. * Copyright (C) 2014 Texas Instruments, Inc.
  6. *
  7. * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
  8. *
  9. * Based on: sound/soc/tegra/tegra_pcm.c
  10. */
  11. #include <linux/module.h>
  12. #include <sound/core.h>
  13. #include <sound/pcm.h>
  14. #include <sound/pcm_params.h>
  15. #include <sound/soc.h>
  16. #include <sound/dmaengine_pcm.h>
  17. #include "edma-pcm.h"
  18. static const struct snd_pcm_hardware edma_pcm_hardware = {
  19. .info = SNDRV_PCM_INFO_MMAP |
  20. SNDRV_PCM_INFO_MMAP_VALID |
  21. SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME |
  22. SNDRV_PCM_INFO_NO_PERIOD_WAKEUP |
  23. SNDRV_PCM_INFO_INTERLEAVED,
  24. .buffer_bytes_max = 128 * 1024,
  25. .period_bytes_min = 32,
  26. .period_bytes_max = 64 * 1024,
  27. .periods_min = 2,
  28. .periods_max = 19, /* Limit by edma dmaengine driver */
  29. };
  30. static const struct snd_dmaengine_pcm_config edma_dmaengine_pcm_config = {
  31. .pcm_hardware = &edma_pcm_hardware,
  32. .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
  33. .prealloc_buffer_size = 128 * 1024,
  34. };
  35. int edma_pcm_platform_register(struct device *dev)
  36. {
  37. struct snd_dmaengine_pcm_config *config;
  38. if (dev->of_node)
  39. return devm_snd_dmaengine_pcm_register(dev,
  40. &edma_dmaengine_pcm_config, 0);
  41. config = devm_kzalloc(dev, sizeof(*config), GFP_KERNEL);
  42. if (!config)
  43. return -ENOMEM;
  44. *config = edma_dmaengine_pcm_config;
  45. config->chan_names[0] = "tx";
  46. config->chan_names[1] = "rx";
  47. return devm_snd_dmaengine_pcm_register(dev, config, 0);
  48. }
  49. EXPORT_SYMBOL_GPL(edma_pcm_platform_register);
  50. MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>");
  51. MODULE_DESCRIPTION("eDMA PCM ASoC platform driver");
  52. MODULE_LICENSE("GPL");