aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-04-15 13:19:59 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-04-17 09:26:33 -0400
commitadaa3229fbb88532e0d460afad779efbfb92ffeb (patch)
tree1ea22aba1d3ee1abcc27ab8f10365dddb4ad487f
parentfc8ba7f94d84e1ccd351e41c778e36710834334e (diff)
ASoC: imx: Use generic dmaengine PCM
Use the generic dmaengine PCM driver instead of a custom implementation. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/fsl/Kconfig2
-rw-r--r--sound/soc/fsl/imx-pcm-dma.c76
-rw-r--r--sound/soc/fsl/imx-pcm.c6
-rw-r--r--sound/soc/fsl/imx-pcm.h5
4 files changed, 26 insertions, 63 deletions
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 3b98159d9645..3843a18d4e56 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -118,7 +118,7 @@ config SND_SOC_IMX_PCM_FIQ
118 118
119config SND_SOC_IMX_PCM_DMA 119config SND_SOC_IMX_PCM_DMA
120 bool 120 bool
121 select SND_SOC_DMAENGINE_PCM 121 select SND_SOC_GENERIC_DMAENGINE_PCM
122 select SND_SOC_IMX_PCM 122 select SND_SOC_IMX_PCM
123 123
124config SND_SOC_IMX_AUDMUX 124config SND_SOC_IMX_AUDMUX
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c
index c6647825bdd5..c246fb514930 100644
--- a/sound/soc/fsl/imx-pcm-dma.c
+++ b/sound/soc/fsl/imx-pcm-dma.c
@@ -11,22 +11,12 @@
11 * Free Software Foundation; either version 2 of the License, or (at your 11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version. 12 * option) any later version.
13 */ 13 */
14#include <linux/clk.h>
15#include <linux/delay.h>
16#include <linux/device.h>
17#include <linux/dma-mapping.h>
18#include <linux/init.h>
19#include <linux/interrupt.h>
20#include <linux/module.h>
21#include <linux/platform_device.h> 14#include <linux/platform_device.h>
22#include <linux/slab.h>
23#include <linux/dmaengine.h> 15#include <linux/dmaengine.h>
24#include <linux/types.h> 16#include <linux/types.h>
25 17
26#include <sound/core.h> 18#include <sound/core.h>
27#include <sound/initval.h>
28#include <sound/pcm.h> 19#include <sound/pcm.h>
29#include <sound/pcm_params.h>
30#include <sound/soc.h> 20#include <sound/soc.h>
31#include <sound/dmaengine_pcm.h> 21#include <sound/dmaengine_pcm.h>
32 22
@@ -44,32 +34,7 @@ static bool filter(struct dma_chan *chan, void *param)
44 return true; 34 return true;
45} 35}
46 36
47static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream, 37static const struct snd_pcm_hardware imx_pcm_hardware = {
48 struct snd_pcm_hw_params *params)
49{
50 struct snd_soc_pcm_runtime *rtd = substream->private_data;
51 struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream);
52 struct dma_slave_config slave_config;
53 int ret;
54
55 ret = snd_hwparams_to_dma_slave_config(substream, params, &slave_config);
56 if (ret)
57 return ret;
58
59 snd_dmaengine_pcm_set_config_from_dai_data(substream,
60 snd_soc_dai_get_dma_data(rtd->cpu_dai, substream),
61 &slave_config);
62
63 ret = dmaengine_slave_config(chan, &slave_config);
64 if (ret)
65 return ret;
66
67 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
68
69 return 0;
70}
71
72static struct snd_pcm_hardware snd_imx_hardware = {
73 .info = SNDRV_PCM_INFO_INTERLEAVED | 38 .info = SNDRV_PCM_INFO_INTERLEAVED |
74 SNDRV_PCM_INFO_BLOCK_TRANSFER | 39 SNDRV_PCM_INFO_BLOCK_TRANSFER |
75 SNDRV_PCM_INFO_MMAP | 40 SNDRV_PCM_INFO_MMAP |
@@ -88,33 +53,22 @@ static struct snd_pcm_hardware snd_imx_hardware = {
88 .fifo_size = 0, 53 .fifo_size = 0,
89}; 54};
90 55
91static int snd_imx_open(struct snd_pcm_substream *substream) 56static const struct snd_dmaengine_pcm_config imx_dmaengine_pcm_config = {
92{ 57 .pcm_hardware = &imx_pcm_hardware,
93 struct snd_soc_pcm_runtime *rtd = substream->private_data; 58 .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
94 59 .compat_filter_fn = filter,
95 snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware); 60 .prealloc_buffer_size = IMX_SSI_DMABUF_SIZE,
96
97 return snd_dmaengine_pcm_open(substream, filter,
98 snd_soc_dai_get_dma_data(rtd->cpu_dai, substream));
99}
100
101static struct snd_pcm_ops imx_pcm_ops = {
102 .open = snd_imx_open,
103 .close = snd_dmaengine_pcm_close_release_chan,
104 .ioctl = snd_pcm_lib_ioctl,
105 .hw_params = snd_imx_pcm_hw_params,
106 .trigger = snd_dmaengine_pcm_trigger,
107 .pointer = snd_dmaengine_pcm_pointer_no_residue,
108 .mmap = snd_imx_pcm_mmap,
109};
110
111static struct snd_soc_platform_driver imx_soc_platform_mx2 = {
112 .ops = &imx_pcm_ops,
113 .pcm_new = imx_pcm_new,
114 .pcm_free = imx_pcm_free,
115}; 61};
116 62
117int imx_pcm_dma_init(struct platform_device *pdev) 63int imx_pcm_dma_init(struct platform_device *pdev)
118{ 64{
119 return snd_soc_register_platform(&pdev->dev, &imx_soc_platform_mx2); 65 return snd_dmaengine_pcm_register(&pdev->dev, &imx_dmaengine_pcm_config,
66 SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
67 SND_DMAENGINE_PCM_FLAG_NO_DT |
68 SND_DMAENGINE_PCM_FLAG_COMPAT);
69}
70
71void imx_pcm_dma_exit(struct platform_device *pdev)
72{
73 snd_dmaengine_pcm_unregister(&pdev->dev);
120} 74}
diff --git a/sound/soc/fsl/imx-pcm.c b/sound/soc/fsl/imx-pcm.c
index 0d0625bfcb65..c49896442d8e 100644
--- a/sound/soc/fsl/imx-pcm.c
+++ b/sound/soc/fsl/imx-pcm.c
@@ -114,7 +114,11 @@ static int imx_pcm_probe(struct platform_device *pdev)
114 114
115static int imx_pcm_remove(struct platform_device *pdev) 115static int imx_pcm_remove(struct platform_device *pdev)
116{ 116{
117 snd_soc_unregister_platform(&pdev->dev); 117 if (strcmp(pdev->id_entry->name, "imx-fiq-pcm-audio") == 0)
118 snd_soc_unregister_platform(&pdev->dev);
119 else
120 imx_pcm_dma_exit(pdev);
121
118 return 0; 122 return 0;
119} 123}
120 124
diff --git a/sound/soc/fsl/imx-pcm.h b/sound/soc/fsl/imx-pcm.h
index be9cc64a208b..b7fa0d75c687 100644
--- a/sound/soc/fsl/imx-pcm.h
+++ b/sound/soc/fsl/imx-pcm.h
@@ -39,11 +39,16 @@ void imx_pcm_free(struct snd_pcm *pcm);
39 39
40#ifdef CONFIG_SND_SOC_IMX_PCM_DMA 40#ifdef CONFIG_SND_SOC_IMX_PCM_DMA
41int imx_pcm_dma_init(struct platform_device *pdev); 41int imx_pcm_dma_init(struct platform_device *pdev);
42void imx_pcm_dma_exit(struct platform_device *pdev);
42#else 43#else
43static inline int imx_pcm_dma_init(struct platform_device *pdev) 44static inline int imx_pcm_dma_init(struct platform_device *pdev)
44{ 45{
45 return -ENODEV; 46 return -ENODEV;
46} 47}
48
49static inline void imx_pcm_dma_exit(struct platform_device *pdev)
50{
51}
47#endif 52#endif
48 53
49#ifdef CONFIG_SND_SOC_IMX_PCM_FIQ 54#ifdef CONFIG_SND_SOC_IMX_PCM_FIQ