Merge tag 'powerpc-5.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[linux/fpc-iii.git] / sound / soc / fsl / imx-pcm-dma.c
blob04a9bc749016d40240cd868278cacf18488e58aa
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * imx-pcm-dma-mx2.c -- ALSA Soc Audio Layer
5 * Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de>
7 * This code is based on code copyrighted by Freescale,
8 * Liam Girdwood, Javier Martin and probably others.
9 */
10 #include <linux/platform_device.h>
11 #include <linux/dmaengine.h>
12 #include <linux/types.h>
13 #include <linux/module.h>
15 #include <sound/core.h>
16 #include <sound/pcm.h>
17 #include <sound/soc.h>
18 #include <sound/dmaengine_pcm.h>
20 #include "imx-pcm.h"
22 static bool filter(struct dma_chan *chan, void *param)
24 if (!imx_dma_is_general_purpose(chan))
25 return false;
27 chan->private = param;
29 return true;
32 static const struct snd_dmaengine_pcm_config imx_dmaengine_pcm_config = {
33 .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
34 .compat_filter_fn = filter,
37 int imx_pcm_dma_init(struct platform_device *pdev, size_t size)
39 struct snd_dmaengine_pcm_config *config;
41 config = devm_kzalloc(&pdev->dev,
42 sizeof(struct snd_dmaengine_pcm_config), GFP_KERNEL);
43 if (!config)
44 return -ENOMEM;
45 *config = imx_dmaengine_pcm_config;
47 return devm_snd_dmaengine_pcm_register(&pdev->dev,
48 config,
49 SND_DMAENGINE_PCM_FLAG_COMPAT);
51 EXPORT_SYMBOL_GPL(imx_pcm_dma_init);
53 MODULE_LICENSE("GPL");