dmaengine.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * dmaengine.c - Samsung dmaengine wrapper
  3. *
  4. * Author: Mark Brown <broonie@linaro.org>
  5. * Copyright 2013 Linaro
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * version 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. */
  17. #include <linux/module.h>
  18. #include <linux/amba/pl08x.h>
  19. #include <linux/platform_data/dma-s3c24xx.h>
  20. #include <sound/core.h>
  21. #include <sound/pcm.h>
  22. #include <sound/pcm_params.h>
  23. #include <sound/dmaengine_pcm.h>
  24. #include <sound/soc.h>
  25. #include <sound/soc-dai.h>
  26. #include "dma.h"
  27. #ifdef CONFIG_ARCH_S3C64XX
  28. #define filter_fn pl08x_filter_id
  29. #elif defined(CONFIG_ARCH_S3C24XX)
  30. #define filter_fn s3c24xx_dma_filter
  31. #else
  32. #define filter_fn NULL
  33. #endif
  34. static const struct snd_dmaengine_pcm_config samsung_dmaengine_pcm_config = {
  35. .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
  36. .compat_filter_fn = filter_fn,
  37. };
  38. void samsung_asoc_init_dma_data(struct snd_soc_dai *dai,
  39. struct s3c_dma_params *playback,
  40. struct s3c_dma_params *capture)
  41. {
  42. struct snd_dmaengine_dai_dma_data *playback_data = NULL;
  43. struct snd_dmaengine_dai_dma_data *capture_data = NULL;
  44. if (playback) {
  45. playback_data = &playback->dma_data;
  46. playback_data->filter_data = (void *)playback->channel;
  47. playback_data->chan_name = playback->ch_name;
  48. playback_data->addr = playback->dma_addr;
  49. playback_data->addr_width = playback->dma_size;
  50. }
  51. if (capture) {
  52. capture_data = &capture->dma_data;
  53. capture_data->filter_data = (void *)capture->channel;
  54. capture_data->chan_name = capture->ch_name;
  55. capture_data->addr = capture->dma_addr;
  56. capture_data->addr_width = capture->dma_size;
  57. }
  58. snd_soc_dai_init_dma_data(dai, playback_data, capture_data);
  59. }
  60. EXPORT_SYMBOL_GPL(samsung_asoc_init_dma_data);
  61. int samsung_asoc_dma_platform_register(struct device *dev)
  62. {
  63. return devm_snd_dmaengine_pcm_register(dev,
  64. &samsung_dmaengine_pcm_config,
  65. SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME |
  66. SND_DMAENGINE_PCM_FLAG_COMPAT);
  67. }
  68. EXPORT_SYMBOL_GPL(samsung_asoc_dma_platform_register);
  69. MODULE_AUTHOR("Mark Brown <broonie@linaro.org>");
  70. MODULE_DESCRIPTION("Samsung dmaengine ASoC driver");
  71. MODULE_LICENSE("GPL");