Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * imx-pcm-dma-mx2.c  --  ALSA Soc Audio Layer
0004  *
0005  * Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de>
0006  *
0007  * This code is based on code copyrighted by Freescale,
0008  * Liam Girdwood, Javier Martin and probably others.
0009  */
0010 #include <linux/platform_device.h>
0011 #include <linux/dmaengine.h>
0012 #include <linux/types.h>
0013 #include <linux/module.h>
0014 
0015 #include <sound/core.h>
0016 #include <sound/pcm.h>
0017 #include <sound/soc.h>
0018 #include <sound/dmaengine_pcm.h>
0019 
0020 #include "imx-pcm.h"
0021 
0022 static bool filter(struct dma_chan *chan, void *param)
0023 {
0024     if (!imx_dma_is_general_purpose(chan))
0025         return false;
0026 
0027     chan->private = param;
0028 
0029     return true;
0030 }
0031 
0032 static const struct snd_dmaengine_pcm_config imx_dmaengine_pcm_config = {
0033     .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
0034     .compat_filter_fn = filter,
0035 };
0036 
0037 int imx_pcm_dma_init(struct platform_device *pdev)
0038 {
0039     struct snd_dmaengine_pcm_config *config;
0040 
0041     config = devm_kzalloc(&pdev->dev,
0042             sizeof(struct snd_dmaengine_pcm_config), GFP_KERNEL);
0043     if (!config)
0044         return -ENOMEM;
0045     *config = imx_dmaengine_pcm_config;
0046 
0047     return devm_snd_dmaengine_pcm_register(&pdev->dev,
0048         config,
0049         SND_DMAENGINE_PCM_FLAG_COMPAT);
0050 }
0051 EXPORT_SYMBOL_GPL(imx_pcm_dma_init);
0052 
0053 MODULE_LICENSE("GPL");