imx-pcm-dma.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * imx-pcm-dma-mx2.c -- ALSA Soc Audio Layer
  3. *
  4. * Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de>
  5. *
  6. * This code is based on code copyrighted by Freescale,
  7. * Liam Girdwood, Javier Martin and probably others.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. */
  14. #include <linux/platform_device.h>
  15. #include <linux/dmaengine.h>
  16. #include <linux/types.h>
  17. #include <linux/module.h>
  18. #include <sound/core.h>
  19. #include <sound/pcm.h>
  20. #include <sound/soc.h>
  21. #include <sound/dmaengine_pcm.h>
  22. #include "imx-pcm.h"
  23. static bool filter(struct dma_chan *chan, void *param)
  24. {
  25. if (!imx_dma_is_general_purpose(chan))
  26. return false;
  27. chan->private = param;
  28. return true;
  29. }
  30. static const struct snd_dmaengine_pcm_config imx_dmaengine_pcm_config = {
  31. .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
  32. .compat_filter_fn = filter,
  33. };
  34. int imx_pcm_dma_init(struct platform_device *pdev, size_t size)
  35. {
  36. struct snd_dmaengine_pcm_config *config;
  37. config = devm_kzalloc(&pdev->dev,
  38. sizeof(struct snd_dmaengine_pcm_config), GFP_KERNEL);
  39. if (!config)
  40. return -ENOMEM;
  41. *config = imx_dmaengine_pcm_config;
  42. return devm_snd_dmaengine_pcm_register(&pdev->dev,
  43. config,
  44. SND_DMAENGINE_PCM_FLAG_COMPAT);
  45. }
  46. EXPORT_SYMBOL_GPL(imx_pcm_dma_init);
  47. MODULE_LICENSE("GPL");