1f19493a3SShawn Guo /* 2f19493a3SShawn Guo * imx-pcm-dma-mx2.c -- ALSA Soc Audio Layer 3f19493a3SShawn Guo * 4f19493a3SShawn Guo * Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de> 5f19493a3SShawn Guo * 6f19493a3SShawn Guo * This code is based on code copyrighted by Freescale, 7f19493a3SShawn Guo * Liam Girdwood, Javier Martin and probably others. 8f19493a3SShawn Guo * 9f19493a3SShawn Guo * This program is free software; you can redistribute it and/or modify it 10f19493a3SShawn Guo * under the terms of the GNU General Public License as published by the 11f19493a3SShawn Guo * Free Software Foundation; either version 2 of the License, or (at your 12f19493a3SShawn Guo * option) any later version. 13f19493a3SShawn Guo */ 14f19493a3SShawn Guo #include <linux/platform_device.h> 15f19493a3SShawn Guo #include <linux/dmaengine.h> 16f19493a3SShawn Guo #include <linux/types.h> 173c1c32d3SMark Brown #include <linux/module.h> 18f19493a3SShawn Guo 19f19493a3SShawn Guo #include <sound/core.h> 20f19493a3SShawn Guo #include <sound/pcm.h> 21f19493a3SShawn Guo #include <sound/soc.h> 22f19493a3SShawn Guo #include <sound/dmaengine_pcm.h> 23f19493a3SShawn Guo 24f19493a3SShawn Guo #include "imx-pcm.h" 25f19493a3SShawn Guo 26f19493a3SShawn Guo static bool filter(struct dma_chan *chan, void *param) 27f19493a3SShawn Guo { 28f19493a3SShawn Guo if (!imx_dma_is_general_purpose(chan)) 29f19493a3SShawn Guo return false; 30f19493a3SShawn Guo 3190130d2eSMark Brown chan->private = param; 32f19493a3SShawn Guo 33f19493a3SShawn Guo return true; 34f19493a3SShawn Guo } 35f19493a3SShawn Guo 36adaa3229SLars-Peter Clausen static const struct snd_pcm_hardware imx_pcm_hardware = { 37f19493a3SShawn Guo .info = SNDRV_PCM_INFO_INTERLEAVED | 38f19493a3SShawn Guo SNDRV_PCM_INFO_BLOCK_TRANSFER | 39f19493a3SShawn Guo SNDRV_PCM_INFO_MMAP | 40f19493a3SShawn Guo SNDRV_PCM_INFO_MMAP_VALID | 41f19493a3SShawn Guo SNDRV_PCM_INFO_PAUSE | 42f19493a3SShawn Guo SNDRV_PCM_INFO_RESUME, 43f19493a3SShawn Guo .formats = SNDRV_PCM_FMTBIT_S16_LE, 44f19493a3SShawn Guo .rate_min = 8000, 45f19493a3SShawn Guo .channels_min = 2, 46f19493a3SShawn Guo .channels_max = 2, 47f19493a3SShawn Guo .buffer_bytes_max = IMX_SSI_DMABUF_SIZE, 48f19493a3SShawn Guo .period_bytes_min = 128, 49f19493a3SShawn Guo .period_bytes_max = 65535, /* Limited by SDMA engine */ 50f19493a3SShawn Guo .periods_min = 2, 51f19493a3SShawn Guo .periods_max = 255, 52f19493a3SShawn Guo .fifo_size = 0, 53f19493a3SShawn Guo }; 54f19493a3SShawn Guo 55adaa3229SLars-Peter Clausen static const struct snd_dmaengine_pcm_config imx_dmaengine_pcm_config = { 56adaa3229SLars-Peter Clausen .pcm_hardware = &imx_pcm_hardware, 57adaa3229SLars-Peter Clausen .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, 58adaa3229SLars-Peter Clausen .compat_filter_fn = filter, 59adaa3229SLars-Peter Clausen .prealloc_buffer_size = IMX_SSI_DMABUF_SIZE, 60f19493a3SShawn Guo }; 61f19493a3SShawn Guo 621927661bSShawn Guo int imx_pcm_dma_init(struct platform_device *pdev) 63f19493a3SShawn Guo { 64*7e6d18acSLars-Peter Clausen return devm_snd_dmaengine_pcm_register(&pdev->dev, 65*7e6d18acSLars-Peter Clausen &imx_dmaengine_pcm_config, 66adaa3229SLars-Peter Clausen SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | 67adaa3229SLars-Peter Clausen SND_DMAENGINE_PCM_FLAG_COMPAT); 68adaa3229SLars-Peter Clausen } 69dbdf6b54SShawn Guo EXPORT_SYMBOL_GPL(imx_pcm_dma_init); 70adaa3229SLars-Peter Clausen 713c1c32d3SMark Brown MODULE_LICENSE("GPL"); 72