2019-05-27 09:55:01 +03:00
// SPDX-License-Identifier: GPL-2.0-or-later
2009-11-25 18:41:04 +03:00
/*
* imx - pcm - dma - mx2 . c - - ALSA Soc Audio Layer
*
* Copyright 2009 Sascha Hauer < s . hauer @ pengutronix . de >
*
* This code is based on code copyrighted by Freescale ,
* Liam Girdwood , Javier Martin and probably others .
*/
# include <linux/platform_device.h>
2010-11-04 19:05:43 +03:00
# include <linux/dmaengine.h>
2012-02-01 14:42:19 +04:00
# include <linux/types.h>
2013-08-16 15:07:19 +04:00
# include <linux/module.h>
2009-11-25 18:41:04 +03:00
# include <sound/core.h>
# include <sound/pcm.h>
# include <sound/soc.h>
2012-02-22 13:49:09 +04:00
# include <sound/dmaengine_pcm.h>
2009-11-25 18:41:04 +03:00
2012-03-05 18:30:55 +04:00
# include "imx-pcm.h"
2009-11-25 18:41:04 +03:00
2010-11-04 19:05:43 +03:00
static bool filter ( struct dma_chan * chan , void * param )
2009-11-25 18:41:04 +03:00
{
2010-11-04 19:05:43 +03:00
if ( ! imx_dma_is_general_purpose ( chan ) )
return false ;
2009-11-25 18:41:04 +03:00
2013-10-20 00:38:26 +04:00
chan - > private = param ;
2010-04-08 13:31:25 +04:00
2012-02-22 13:49:09 +04:00
return true ;
2012-02-22 13:49:06 +04:00
}
2013-04-15 21:19:59 +04:00
static const struct snd_dmaengine_pcm_config imx_dmaengine_pcm_config = {
. prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config ,
. compat_filter_fn = filter ,
2009-11-25 18:41:04 +03:00
} ;
2015-06-23 13:23:53 +03:00
int imx_pcm_dma_init ( struct platform_device * pdev , size_t size )
2009-11-25 18:41:04 +03:00
{
2015-06-23 13:23:53 +03:00
struct snd_dmaengine_pcm_config * config ;
config = devm_kzalloc ( & pdev - > dev ,
sizeof ( struct snd_dmaengine_pcm_config ) , GFP_KERNEL ) ;
2015-12-20 14:15:50 +03:00
if ( ! config )
return - ENOMEM ;
2015-06-23 13:23:53 +03:00
* config = imx_dmaengine_pcm_config ;
2013-11-28 11:50:35 +04:00
return devm_snd_dmaengine_pcm_register ( & pdev - > dev ,
2015-06-23 13:23:53 +03:00
config ,
2013-04-15 21:19:59 +04:00
SND_DMAENGINE_PCM_FLAG_COMPAT ) ;
}
2013-04-25 07:18:50 +04:00
EXPORT_SYMBOL_GPL ( imx_pcm_dma_init ) ;
2013-04-15 21:19:59 +04:00
2013-08-16 15:07:19 +04:00
MODULE_LICENSE ( " GPL " ) ;