aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/fsl
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-03-22 09:12:12 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-03-26 10:17:31 -0400
commit312bb4f626328fdc246c8d13082ab00e26e7d048 (patch)
treeb0252427b7dcc44643f228980610cd13ccaca58a /sound/soc/fsl
parentac581e60dfb4cc55ac20cca18202c7689d324aa7 (diff)
ASoC: imx-pcm: Embed the imx_dma_data struct in the dma_params struct
Currently the imx_dma_data struct, which gets passed to the dmaengine driver, is allocated and constructed in the pcm driver from the data stored in the dma_params struct. The dma_params struct gets passed to the pcm driver from the dai driver. Instead of going this route of indirection embed the dma_data struct directly into the dma_params struct and let the dai driver fill it in. This allows us to simplify the imx-pcm-dma driver quite a bit, since it doesn't have care about memory managing the imx_dma_data struct anymore. 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>
Diffstat (limited to 'sound/soc/fsl')
-rw-r--r--sound/soc/fsl/fsl_ssi.c17
-rw-r--r--sound/soc/fsl/imx-pcm-dma.c35
-rw-r--r--sound/soc/fsl/imx-pcm.h17
-rw-r--r--sound/soc/fsl/imx-ssi.c12
4 files changed, 34 insertions, 47 deletions
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 7decbd9b2340..2cce1ce1b7dd 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -649,6 +649,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
649 const uint32_t *iprop; 649 const uint32_t *iprop;
650 struct resource res; 650 struct resource res;
651 char name[64]; 651 char name[64];
652 bool shared;
652 653
653 /* SSIs that are not connected on the board should have a 654 /* SSIs that are not connected on the board should have a
654 * status = "disabled" 655 * status = "disabled"
@@ -755,14 +756,14 @@ static int fsl_ssi_probe(struct platform_device *pdev)
755 dev_err(&pdev->dev, "could not get dma events\n"); 756 dev_err(&pdev->dev, "could not get dma events\n");
756 goto error_clk; 757 goto error_clk;
757 } 758 }
758 ssi_private->dma_params_tx.dma = dma_events[0]; 759
759 ssi_private->dma_params_rx.dma = dma_events[1]; 760 shared = of_device_is_compatible(of_get_parent(np),
760 761 "fsl,spba-bus");
761 ssi_private->dma_params_tx.shared_peripheral = 762
762 of_device_is_compatible(of_get_parent(np), 763 imx_pcm_dma_params_init_data(&ssi_private->dma_params_tx,
763 "fsl,spba-bus"); 764 dma_events[0], shared);
764 ssi_private->dma_params_rx.shared_peripheral = 765 imx_pcm_dma_params_init_data(&ssi_private->dma_params_rx,
765 ssi_private->dma_params_tx.shared_peripheral; 766 dma_events[1], shared);
766 } 767 }
767 768
768 /* Initialize the the device_attribute structure */ 769 /* Initialize the the device_attribute structure */
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c
index 500f8ce55d78..6832c498457a 100644
--- a/sound/soc/fsl/imx-pcm-dma.c
+++ b/sound/soc/fsl/imx-pcm-dma.c
@@ -30,8 +30,6 @@
30#include <sound/soc.h> 30#include <sound/soc.h>
31#include <sound/dmaengine_pcm.h> 31#include <sound/dmaengine_pcm.h>
32 32
33#include <linux/platform_data/dma-imx.h>
34
35#include "imx-pcm.h" 33#include "imx-pcm.h"
36 34
37static bool filter(struct dma_chan *chan, void *param) 35static bool filter(struct dma_chan *chan, void *param)
@@ -101,46 +99,17 @@ static int snd_imx_open(struct snd_pcm_substream *substream)
101{ 99{
102 struct snd_soc_pcm_runtime *rtd = substream->private_data; 100 struct snd_soc_pcm_runtime *rtd = substream->private_data;
103 struct imx_pcm_dma_params *dma_params; 101 struct imx_pcm_dma_params *dma_params;
104 struct imx_dma_data *dma_data;
105 int ret;
106 102
107 snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware); 103 snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware);
108 104
109 dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); 105 dma_params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
110 106
111 dma_data = kzalloc(sizeof(*dma_data), GFP_KERNEL); 107 return snd_dmaengine_pcm_open(substream, filter, &dma_params->dma_data);
112 if (!dma_data)
113 return -ENOMEM;
114
115 dma_data->peripheral_type = dma_params->shared_peripheral ?
116 IMX_DMATYPE_SSI_SP : IMX_DMATYPE_SSI;
117 dma_data->priority = DMA_PRIO_HIGH;
118 dma_data->dma_request = dma_params->dma;
119
120 ret = snd_dmaengine_pcm_open(substream, filter, dma_data);
121 if (ret) {
122 kfree(dma_data);
123 return ret;
124 }
125
126 snd_dmaengine_pcm_set_data(substream, dma_data);
127
128 return 0;
129}
130
131static int snd_imx_close(struct snd_pcm_substream *substream)
132{
133 struct imx_dma_data *dma_data = snd_dmaengine_pcm_get_data(substream);
134
135 snd_dmaengine_pcm_close(substream);
136 kfree(dma_data);
137
138 return 0;
139} 108}
140 109
141static struct snd_pcm_ops imx_pcm_ops = { 110static struct snd_pcm_ops imx_pcm_ops = {
142 .open = snd_imx_open, 111 .open = snd_imx_open,
143 .close = snd_imx_close, 112 .close = snd_dmaengine_pcm_close,
144 .ioctl = snd_pcm_lib_ioctl, 113 .ioctl = snd_pcm_lib_ioctl,
145 .hw_params = snd_imx_pcm_hw_params, 114 .hw_params = snd_imx_pcm_hw_params,
146 .trigger = snd_dmaengine_pcm_trigger, 115 .trigger = snd_dmaengine_pcm_trigger,
diff --git a/sound/soc/fsl/imx-pcm.h b/sound/soc/fsl/imx-pcm.h
index 5ae13a13a353..16eaf5a09f53 100644
--- a/sound/soc/fsl/imx-pcm.h
+++ b/sound/soc/fsl/imx-pcm.h
@@ -13,18 +13,31 @@
13#ifndef _IMX_PCM_H 13#ifndef _IMX_PCM_H
14#define _IMX_PCM_H 14#define _IMX_PCM_H
15 15
16#include <linux/platform_data/dma-imx.h>
17
16/* 18/*
17 * Do not change this as the FIQ handler depends on this size 19 * Do not change this as the FIQ handler depends on this size
18 */ 20 */
19#define IMX_SSI_DMABUF_SIZE (64 * 1024) 21#define IMX_SSI_DMABUF_SIZE (64 * 1024)
20 22
21struct imx_pcm_dma_params { 23struct imx_pcm_dma_params {
22 int dma;
23 unsigned long dma_addr; 24 unsigned long dma_addr;
24 int burstsize; 25 int burstsize;
25 bool shared_peripheral; /* The peripheral is on SPBA bus */ 26 struct imx_dma_data dma_data;
26}; 27};
27 28
29static inline void
30imx_pcm_dma_params_init_data(struct imx_pcm_dma_params *params,
31 int dma, bool shared)
32{
33 params->dma_data.dma_request = dma;
34 params->dma_data.priority = DMA_PRIO_HIGH;
35 if (shared)
36 params->dma_data.peripheral_type = IMX_DMATYPE_SSI_SP;
37 else
38 params->dma_data.peripheral_type = IMX_DMATYPE_SSI;
39}
40
28int snd_imx_pcm_mmap(struct snd_pcm_substream *substream, 41int snd_imx_pcm_mmap(struct snd_pcm_substream *substream,
29 struct vm_area_struct *vma); 42 struct vm_area_struct *vma);
30int imx_pcm_new(struct snd_soc_pcm_runtime *rtd); 43int imx_pcm_new(struct snd_soc_pcm_runtime *rtd);
diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c
index 55464a5b0706..14018c4628ec 100644
--- a/sound/soc/fsl/imx-ssi.c
+++ b/sound/soc/fsl/imx-ssi.c
@@ -577,12 +577,16 @@ static int imx_ssi_probe(struct platform_device *pdev)
577 ssi->dma_params_rx.burstsize = 4; 577 ssi->dma_params_rx.burstsize = 4;
578 578
579 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx0"); 579 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx0");
580 if (res) 580 if (res) {
581 ssi->dma_params_tx.dma = res->start; 581 imx_pcm_dma_params_init_data(&ssi->dma_params_tx, res->start,
582 false);
583 }
582 584
583 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx0"); 585 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx0");
584 if (res) 586 if (res) {
585 ssi->dma_params_rx.dma = res->start; 587 imx_pcm_dma_params_init_data(&ssi->dma_params_rx, res->start,
588 false);
589 }
586 590
587 platform_set_drvdata(pdev, ssi); 591 platform_set_drvdata(pdev, ssi);
588 592