diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2012-03-05 09:30:55 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-03-05 19:03:08 -0500 |
commit | 4762fbab0b1cf1d4f3e02b78351dc6fa59ca564e (patch) | |
tree | 08c59b48b0b3f7e24f84820683f9961e5664da90 /sound | |
parent | af4872fb39301bbe196d0778f80d22ec51d8884b (diff) |
ASoC: imx: separate imx-pcm bits from imx-ssi driver
Currently the imx-ssi.c[h] accommodates the imx-pcm common bits which
are shared between imx-pcm-dma-mx2 and imx-pcm-fiq drivers. It assumes
that imx-pcm-dma-mx2 and imx-pcm-fiq will always be used together with
imx-ssi driver. However this becomes untrue when we see that driver
sound/soc/fsl/fsl_ssi could possibly work with imx-pcm-dma-mx2 too.
The patch moves the imx-pcm common bits from imx-ssi.c[h] into new
files imx-pcm.c[h], and let imx-pcm-dma-mx2 and imx-pcm-fiq drivers
build it in, so that imx-pcm-dma-mx2 can work with no dependency on
imx-ssi driver.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/imx/Kconfig | 7 | ||||
-rw-r--r-- | sound/soc/imx/Makefile | 9 | ||||
-rw-r--r-- | sound/soc/imx/imx-pcm-dma-mx2.c | 2 | ||||
-rw-r--r-- | sound/soc/imx/imx-pcm.c | 105 | ||||
-rw-r--r-- | sound/soc/imx/imx-pcm.h | 32 | ||||
-rw-r--r-- | sound/soc/imx/imx-ssi.c | 88 | ||||
-rw-r--r-- | sound/soc/imx/imx-ssi.h | 16 |
7 files changed, 150 insertions, 109 deletions
diff --git a/sound/soc/imx/Kconfig b/sound/soc/imx/Kconfig index d3b716663d1d..2566032a4901 100644 --- a/sound/soc/imx/Kconfig +++ b/sound/soc/imx/Kconfig | |||
@@ -8,13 +8,18 @@ menuconfig SND_IMX_SOC | |||
8 | 8 | ||
9 | if SND_IMX_SOC | 9 | if SND_IMX_SOC |
10 | 10 | ||
11 | config SND_SOC_IMX_PCM | ||
12 | tristate | ||
13 | |||
11 | config SND_MXC_SOC_FIQ | 14 | config SND_MXC_SOC_FIQ |
12 | select FIQ | ||
13 | tristate | 15 | tristate |
16 | select FIQ | ||
17 | select SND_SOC_IMX_PCM | ||
14 | 18 | ||
15 | config SND_MXC_SOC_MX2 | 19 | config SND_MXC_SOC_MX2 |
16 | select SND_SOC_DMAENGINE_PCM | 20 | select SND_SOC_DMAENGINE_PCM |
17 | tristate | 21 | tristate |
22 | select SND_SOC_IMX_PCM | ||
18 | 23 | ||
19 | config SND_SOC_IMX_AUDMUX | 24 | config SND_SOC_IMX_AUDMUX |
20 | tristate | 25 | tristate |
diff --git a/sound/soc/imx/Makefile b/sound/soc/imx/Makefile index 5c40541b8315..e9ed362636e8 100644 --- a/sound/soc/imx/Makefile +++ b/sound/soc/imx/Makefile | |||
@@ -1,14 +1,15 @@ | |||
1 | # i.MX Platform Support | 1 | # i.MX Platform Support |
2 | snd-soc-imx-objs := imx-ssi.o | 2 | snd-soc-imx-objs := imx-ssi.o |
3 | snd-soc-imx-fiq-objs := imx-pcm-fiq.o | ||
4 | snd-soc-imx-mx2-objs := imx-pcm-dma-mx2.o | ||
5 | snd-soc-imx-audmux-objs := imx-audmux.o | 3 | snd-soc-imx-audmux-objs := imx-audmux.o |
6 | 4 | ||
7 | obj-$(CONFIG_SND_IMX_SOC) += snd-soc-imx.o | 5 | obj-$(CONFIG_SND_IMX_SOC) += snd-soc-imx.o |
8 | obj-$(CONFIG_SND_MXC_SOC_FIQ) += snd-soc-imx-fiq.o | ||
9 | obj-$(CONFIG_SND_MXC_SOC_MX2) += snd-soc-imx-mx2.o | ||
10 | obj-$(CONFIG_SND_SOC_IMX_AUDMUX) += snd-soc-imx-audmux.o | 6 | obj-$(CONFIG_SND_SOC_IMX_AUDMUX) += snd-soc-imx-audmux.o |
11 | 7 | ||
8 | obj-$(CONFIG_SND_SOC_IMX_PCM) += snd-soc-imx-pcm.o | ||
9 | snd-soc-imx-pcm-y := imx-pcm.o | ||
10 | snd-soc-imx-pcm-$(CONFIG_SND_MXC_SOC_FIQ) += imx-pcm-fiq.o | ||
11 | snd-soc-imx-pcm-$(CONFIG_SND_MXC_SOC_MX2) += imx-pcm-dma-mx2.o | ||
12 | |||
12 | # i.MX Machine Support | 13 | # i.MX Machine Support |
13 | snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o | 14 | snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o |
14 | snd-soc-phycore-ac97-objs := phycore-ac97.o | 15 | snd-soc-phycore-ac97-objs := phycore-ac97.o |
diff --git a/sound/soc/imx/imx-pcm-dma-mx2.c b/sound/soc/imx/imx-pcm-dma-mx2.c index 471e2218c971..e43c8fa2788b 100644 --- a/sound/soc/imx/imx-pcm-dma-mx2.c +++ b/sound/soc/imx/imx-pcm-dma-mx2.c | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | #include <mach/dma.h> | 32 | #include <mach/dma.h> |
33 | 33 | ||
34 | #include "imx-ssi.h" | 34 | #include "imx-pcm.h" |
35 | 35 | ||
36 | static bool filter(struct dma_chan *chan, void *param) | 36 | static bool filter(struct dma_chan *chan, void *param) |
37 | { | 37 | { |
diff --git a/sound/soc/imx/imx-pcm.c b/sound/soc/imx/imx-pcm.c new file mode 100644 index 000000000000..93dc360b1777 --- /dev/null +++ b/sound/soc/imx/imx-pcm.c | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de> | ||
3 | * | ||
4 | * This code is based on code copyrighted by Freescale, | ||
5 | * Liam Girdwood, Javier Martin and probably others. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/dma-mapping.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <sound/pcm.h> | ||
16 | #include <sound/soc.h> | ||
17 | #include "imx-pcm.h" | ||
18 | |||
19 | int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, | ||
20 | struct vm_area_struct *vma) | ||
21 | { | ||
22 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
23 | int ret; | ||
24 | |||
25 | ret = dma_mmap_writecombine(substream->pcm->card->dev, vma, | ||
26 | runtime->dma_area, runtime->dma_addr, runtime->dma_bytes); | ||
27 | |||
28 | pr_debug("%s: ret: %d %p 0x%08x 0x%08x\n", __func__, ret, | ||
29 | runtime->dma_area, | ||
30 | runtime->dma_addr, | ||
31 | runtime->dma_bytes); | ||
32 | return ret; | ||
33 | } | ||
34 | EXPORT_SYMBOL_GPL(snd_imx_pcm_mmap); | ||
35 | |||
36 | static int imx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) | ||
37 | { | ||
38 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; | ||
39 | struct snd_dma_buffer *buf = &substream->dma_buffer; | ||
40 | size_t size = IMX_SSI_DMABUF_SIZE; | ||
41 | |||
42 | buf->dev.type = SNDRV_DMA_TYPE_DEV; | ||
43 | buf->dev.dev = pcm->card->dev; | ||
44 | buf->private_data = NULL; | ||
45 | buf->area = dma_alloc_writecombine(pcm->card->dev, size, | ||
46 | &buf->addr, GFP_KERNEL); | ||
47 | if (!buf->area) | ||
48 | return -ENOMEM; | ||
49 | buf->bytes = size; | ||
50 | |||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | static u64 imx_pcm_dmamask = DMA_BIT_MASK(32); | ||
55 | |||
56 | int imx_pcm_new(struct snd_soc_pcm_runtime *rtd) | ||
57 | { | ||
58 | struct snd_card *card = rtd->card->snd_card; | ||
59 | struct snd_pcm *pcm = rtd->pcm; | ||
60 | int ret = 0; | ||
61 | |||
62 | if (!card->dev->dma_mask) | ||
63 | card->dev->dma_mask = &imx_pcm_dmamask; | ||
64 | if (!card->dev->coherent_dma_mask) | ||
65 | card->dev->coherent_dma_mask = DMA_BIT_MASK(32); | ||
66 | if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { | ||
67 | ret = imx_pcm_preallocate_dma_buffer(pcm, | ||
68 | SNDRV_PCM_STREAM_PLAYBACK); | ||
69 | if (ret) | ||
70 | goto out; | ||
71 | } | ||
72 | |||
73 | if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { | ||
74 | ret = imx_pcm_preallocate_dma_buffer(pcm, | ||
75 | SNDRV_PCM_STREAM_CAPTURE); | ||
76 | if (ret) | ||
77 | goto out; | ||
78 | } | ||
79 | |||
80 | out: | ||
81 | return ret; | ||
82 | } | ||
83 | EXPORT_SYMBOL_GPL(imx_pcm_new); | ||
84 | |||
85 | void imx_pcm_free(struct snd_pcm *pcm) | ||
86 | { | ||
87 | struct snd_pcm_substream *substream; | ||
88 | struct snd_dma_buffer *buf; | ||
89 | int stream; | ||
90 | |||
91 | for (stream = 0; stream < 2; stream++) { | ||
92 | substream = pcm->streams[stream].substream; | ||
93 | if (!substream) | ||
94 | continue; | ||
95 | |||
96 | buf = &substream->dma_buffer; | ||
97 | if (!buf->area) | ||
98 | continue; | ||
99 | |||
100 | dma_free_writecombine(pcm->card->dev, buf->bytes, | ||
101 | buf->area, buf->addr); | ||
102 | buf->area = NULL; | ||
103 | } | ||
104 | } | ||
105 | EXPORT_SYMBOL_GPL(imx_pcm_free); | ||
diff --git a/sound/soc/imx/imx-pcm.h b/sound/soc/imx/imx-pcm.h new file mode 100644 index 000000000000..b5f5c3acf34d --- /dev/null +++ b/sound/soc/imx/imx-pcm.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | * Copyright 2009 Sascha Hauer <s.hauer@pengutronix.de> | ||
3 | * | ||
4 | * This code is based on code copyrighted by Freescale, | ||
5 | * Liam Girdwood, Javier Martin and probably others. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | */ | ||
12 | |||
13 | #ifndef _IMX_PCM_H | ||
14 | #define _IMX_PCM_H | ||
15 | |||
16 | /* | ||
17 | * Do not change this as the FIQ handler depends on this size | ||
18 | */ | ||
19 | #define IMX_SSI_DMABUF_SIZE (64 * 1024) | ||
20 | |||
21 | struct imx_pcm_dma_params { | ||
22 | int dma; | ||
23 | unsigned long dma_addr; | ||
24 | int burstsize; | ||
25 | }; | ||
26 | |||
27 | int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, | ||
28 | struct vm_area_struct *vma); | ||
29 | int imx_pcm_new(struct snd_soc_pcm_runtime *rtd); | ||
30 | void imx_pcm_free(struct snd_pcm *pcm); | ||
31 | |||
32 | #endif /* _IMX_PCM_H */ | ||
diff --git a/sound/soc/imx/imx-ssi.c b/sound/soc/imx/imx-ssi.c index 25c623115a9f..9203cdd0a154 100644 --- a/sound/soc/imx/imx-ssi.c +++ b/sound/soc/imx/imx-ssi.c | |||
@@ -363,94 +363,6 @@ static const struct snd_soc_dai_ops imx_ssi_pcm_dai_ops = { | |||
363 | .trigger = imx_ssi_trigger, | 363 | .trigger = imx_ssi_trigger, |
364 | }; | 364 | }; |
365 | 365 | ||
366 | int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, | ||
367 | struct vm_area_struct *vma) | ||
368 | { | ||
369 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
370 | int ret; | ||
371 | |||
372 | ret = dma_mmap_writecombine(substream->pcm->card->dev, vma, | ||
373 | runtime->dma_area, runtime->dma_addr, runtime->dma_bytes); | ||
374 | |||
375 | pr_debug("%s: ret: %d %p 0x%08x 0x%08x\n", __func__, ret, | ||
376 | runtime->dma_area, | ||
377 | runtime->dma_addr, | ||
378 | runtime->dma_bytes); | ||
379 | return ret; | ||
380 | } | ||
381 | EXPORT_SYMBOL_GPL(snd_imx_pcm_mmap); | ||
382 | |||
383 | static int imx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) | ||
384 | { | ||
385 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; | ||
386 | struct snd_dma_buffer *buf = &substream->dma_buffer; | ||
387 | size_t size = IMX_SSI_DMABUF_SIZE; | ||
388 | |||
389 | buf->dev.type = SNDRV_DMA_TYPE_DEV; | ||
390 | buf->dev.dev = pcm->card->dev; | ||
391 | buf->private_data = NULL; | ||
392 | buf->area = dma_alloc_writecombine(pcm->card->dev, size, | ||
393 | &buf->addr, GFP_KERNEL); | ||
394 | if (!buf->area) | ||
395 | return -ENOMEM; | ||
396 | buf->bytes = size; | ||
397 | |||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | static u64 imx_pcm_dmamask = DMA_BIT_MASK(32); | ||
402 | |||
403 | int imx_pcm_new(struct snd_soc_pcm_runtime *rtd) | ||
404 | { | ||
405 | struct snd_card *card = rtd->card->snd_card; | ||
406 | struct snd_pcm *pcm = rtd->pcm; | ||
407 | int ret = 0; | ||
408 | |||
409 | if (!card->dev->dma_mask) | ||
410 | card->dev->dma_mask = &imx_pcm_dmamask; | ||
411 | if (!card->dev->coherent_dma_mask) | ||
412 | card->dev->coherent_dma_mask = DMA_BIT_MASK(32); | ||
413 | if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { | ||
414 | ret = imx_pcm_preallocate_dma_buffer(pcm, | ||
415 | SNDRV_PCM_STREAM_PLAYBACK); | ||
416 | if (ret) | ||
417 | goto out; | ||
418 | } | ||
419 | |||
420 | if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { | ||
421 | ret = imx_pcm_preallocate_dma_buffer(pcm, | ||
422 | SNDRV_PCM_STREAM_CAPTURE); | ||
423 | if (ret) | ||
424 | goto out; | ||
425 | } | ||
426 | |||
427 | out: | ||
428 | return ret; | ||
429 | } | ||
430 | EXPORT_SYMBOL_GPL(imx_pcm_new); | ||
431 | |||
432 | void imx_pcm_free(struct snd_pcm *pcm) | ||
433 | { | ||
434 | struct snd_pcm_substream *substream; | ||
435 | struct snd_dma_buffer *buf; | ||
436 | int stream; | ||
437 | |||
438 | for (stream = 0; stream < 2; stream++) { | ||
439 | substream = pcm->streams[stream].substream; | ||
440 | if (!substream) | ||
441 | continue; | ||
442 | |||
443 | buf = &substream->dma_buffer; | ||
444 | if (!buf->area) | ||
445 | continue; | ||
446 | |||
447 | dma_free_writecombine(pcm->card->dev, buf->bytes, | ||
448 | buf->area, buf->addr); | ||
449 | buf->area = NULL; | ||
450 | } | ||
451 | } | ||
452 | EXPORT_SYMBOL_GPL(imx_pcm_free); | ||
453 | |||
454 | static int imx_ssi_dai_probe(struct snd_soc_dai *dai) | 366 | static int imx_ssi_dai_probe(struct snd_soc_dai *dai) |
455 | { | 367 | { |
456 | struct imx_ssi *ssi = dev_get_drvdata(dai->dev); | 368 | struct imx_ssi *ssi = dev_get_drvdata(dai->dev); |
diff --git a/sound/soc/imx/imx-ssi.h b/sound/soc/imx/imx-ssi.h index 1072dfb53e47..5744e86ca878 100644 --- a/sound/soc/imx/imx-ssi.h +++ b/sound/soc/imx/imx-ssi.h | |||
@@ -187,12 +187,7 @@ | |||
187 | 187 | ||
188 | #include <linux/dmaengine.h> | 188 | #include <linux/dmaengine.h> |
189 | #include <mach/dma.h> | 189 | #include <mach/dma.h> |
190 | 190 | #include "imx-pcm.h" | |
191 | struct imx_pcm_dma_params { | ||
192 | int dma; | ||
193 | unsigned long dma_addr; | ||
194 | int burstsize; | ||
195 | }; | ||
196 | 191 | ||
197 | struct imx_ssi { | 192 | struct imx_ssi { |
198 | struct platform_device *ac97_dev; | 193 | struct platform_device *ac97_dev; |
@@ -218,13 +213,4 @@ struct imx_ssi { | |||
218 | struct platform_device *soc_platform_pdev_fiq; | 213 | struct platform_device *soc_platform_pdev_fiq; |
219 | }; | 214 | }; |
220 | 215 | ||
221 | int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *vma); | ||
222 | int imx_pcm_new(struct snd_soc_pcm_runtime *rtd); | ||
223 | void imx_pcm_free(struct snd_pcm *pcm); | ||
224 | |||
225 | /* | ||
226 | * Do not change this as the FIQ handler depends on this size | ||
227 | */ | ||
228 | #define IMX_SSI_DMABUF_SIZE (64 * 1024) | ||
229 | |||
230 | #endif /* _IMX_SSI_H */ | 216 | #endif /* _IMX_SSI_H */ |