rockchip_pcm.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2018 Rockchip Electronics Co. Ltd.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/device.h>
  9. #include <linux/init.h>
  10. #include <linux/module.h>
  11. #include <sound/core.h>
  12. #include <sound/pcm.h>
  13. #include <sound/soc.h>
  14. #include <sound/dmaengine_pcm.h>
  15. #include "rockchip_pcm.h"
  16. static const struct snd_pcm_hardware snd_rockchip_hardware = {
  17. .info = SNDRV_PCM_INFO_MMAP |
  18. SNDRV_PCM_INFO_MMAP_VALID |
  19. SNDRV_PCM_INFO_PAUSE |
  20. SNDRV_PCM_INFO_RESUME |
  21. SNDRV_PCM_INFO_INTERLEAVED,
  22. .period_bytes_min = 32,
  23. .period_bytes_max = 8192,
  24. .periods_min = 1,
  25. .periods_max = 52,
  26. .buffer_bytes_max = 64 * 1024,
  27. .fifo_size = 32,
  28. };
  29. static const struct snd_dmaengine_pcm_config rk_dmaengine_pcm_config = {
  30. .pcm_hardware = &snd_rockchip_hardware,
  31. .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
  32. .prealloc_buffer_size = 32 * 1024,
  33. };
  34. int rockchip_pcm_platform_register(struct device *dev)
  35. {
  36. return devm_snd_dmaengine_pcm_register(dev, &rk_dmaengine_pcm_config,
  37. SND_DMAENGINE_PCM_FLAG_COMPAT);
  38. }
  39. EXPORT_SYMBOL_GPL(rockchip_pcm_platform_register);
  40. MODULE_LICENSE("GPL v2");