aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/atmel/atmel-pcm-dma.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/atmel/atmel-pcm-dma.c')
-rw-r--r--sound/soc/atmel/atmel-pcm-dma.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c
index 30184a4a147a..1d38fd0bc4e2 100644
--- a/sound/soc/atmel/atmel-pcm-dma.c
+++ b/sound/soc/atmel/atmel-pcm-dma.c
@@ -67,9 +67,10 @@ static const struct snd_pcm_hardware atmel_pcm_dma_hardware = {
67static void atmel_pcm_dma_irq(u32 ssc_sr, 67static void atmel_pcm_dma_irq(u32 ssc_sr,
68 struct snd_pcm_substream *substream) 68 struct snd_pcm_substream *substream)
69{ 69{
70 struct snd_soc_pcm_runtime *rtd = substream->private_data;
70 struct atmel_pcm_dma_params *prtd; 71 struct atmel_pcm_dma_params *prtd;
71 72
72 prtd = snd_dmaengine_pcm_get_data(substream); 73 prtd = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
73 74
74 if (ssc_sr & prtd->mask->ssc_error) { 75 if (ssc_sr & prtd->mask->ssc_error) {
75 if (snd_pcm_running(substream)) 76 if (snd_pcm_running(substream))
@@ -104,15 +105,13 @@ static bool filter(struct dma_chan *chan, void *slave)
104} 105}
105 106
106static int atmel_pcm_configure_dma(struct snd_pcm_substream *substream, 107static int atmel_pcm_configure_dma(struct snd_pcm_substream *substream,
107 struct snd_pcm_hw_params *params) 108 struct snd_pcm_hw_params *params, struct atmel_pcm_dma_params *prtd)
108{ 109{
109 struct atmel_pcm_dma_params *prtd;
110 struct ssc_device *ssc; 110 struct ssc_device *ssc;
111 struct dma_chan *dma_chan; 111 struct dma_chan *dma_chan;
112 struct dma_slave_config slave_config; 112 struct dma_slave_config slave_config;
113 int ret; 113 int ret;
114 114
115 prtd = snd_dmaengine_pcm_get_data(substream);
116 ssc = prtd->ssc; 115 ssc = prtd->ssc;
117 116
118 ret = snd_hwparams_to_dma_slave_config(substream, params, 117 ret = snd_hwparams_to_dma_slave_config(substream, params,
@@ -130,8 +129,6 @@ static int atmel_pcm_configure_dma(struct snd_pcm_substream *substream,
130 slave_config.src_maxburst = 1; 129 slave_config.src_maxburst = 1;
131 } 130 }
132 131
133 slave_config.device_fc = false;
134
135 dma_chan = snd_dmaengine_pcm_get_chan(substream); 132 dma_chan = snd_dmaengine_pcm_get_chan(substream);
136 if (dmaengine_slave_config(dma_chan, &slave_config)) { 133 if (dmaengine_slave_config(dma_chan, &slave_config)) {
137 pr_err("atmel-pcm: failed to configure dma channel\n"); 134 pr_err("atmel-pcm: failed to configure dma channel\n");
@@ -158,15 +155,13 @@ static int atmel_pcm_hw_params(struct snd_pcm_substream *substream,
158 if (ssc->pdev) 155 if (ssc->pdev)
159 sdata = ssc->pdev->dev.platform_data; 156 sdata = ssc->pdev->dev.platform_data;
160 157
161 ret = snd_dmaengine_pcm_open(substream, filter, sdata); 158 ret = snd_dmaengine_pcm_open_request_chan(substream, filter, sdata);
162 if (ret) { 159 if (ret) {
163 pr_err("atmel-pcm: dmaengine pcm open failed\n"); 160 pr_err("atmel-pcm: dmaengine pcm open failed\n");
164 return -EINVAL; 161 return -EINVAL;
165 } 162 }
166 163
167 snd_dmaengine_pcm_set_data(substream, prtd); 164 ret = atmel_pcm_configure_dma(substream, params, prtd);
168
169 ret = atmel_pcm_configure_dma(substream, params);
170 if (ret) { 165 if (ret) {
171 pr_err("atmel-pcm: failed to configure dmai\n"); 166 pr_err("atmel-pcm: failed to configure dmai\n");
172 goto err; 167 goto err;
@@ -176,15 +171,16 @@ static int atmel_pcm_hw_params(struct snd_pcm_substream *substream,
176 171
177 return 0; 172 return 0;
178err: 173err:
179 snd_dmaengine_pcm_close(substream); 174 snd_dmaengine_pcm_close_release_chan(substream);
180 return ret; 175 return ret;
181} 176}
182 177
183static int atmel_pcm_dma_prepare(struct snd_pcm_substream *substream) 178static int atmel_pcm_dma_prepare(struct snd_pcm_substream *substream)
184{ 179{
180 struct snd_soc_pcm_runtime *rtd = substream->private_data;
185 struct atmel_pcm_dma_params *prtd; 181 struct atmel_pcm_dma_params *prtd;
186 182
187 prtd = snd_dmaengine_pcm_get_data(substream); 183 prtd = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
188 184
189 ssc_writex(prtd->ssc->regs, SSC_IER, prtd->mask->ssc_error); 185 ssc_writex(prtd->ssc->regs, SSC_IER, prtd->mask->ssc_error);
190 ssc_writex(prtd->ssc->regs, SSC_CR, prtd->mask->ssc_enable); 186 ssc_writex(prtd->ssc->regs, SSC_CR, prtd->mask->ssc_enable);
@@ -199,16 +195,9 @@ static int atmel_pcm_open(struct snd_pcm_substream *substream)
199 return 0; 195 return 0;
200} 196}
201 197
202static int atmel_pcm_close(struct snd_pcm_substream *substream)
203{
204 snd_dmaengine_pcm_close(substream);
205
206 return 0;
207}
208
209static struct snd_pcm_ops atmel_pcm_ops = { 198static struct snd_pcm_ops atmel_pcm_ops = {
210 .open = atmel_pcm_open, 199 .open = atmel_pcm_open,
211 .close = atmel_pcm_close, 200 .close = snd_dmaengine_pcm_close_release_chan,
212 .ioctl = snd_pcm_lib_ioctl, 201 .ioctl = snd_pcm_lib_ioctl,
213 .hw_params = atmel_pcm_hw_params, 202 .hw_params = atmel_pcm_hw_params,
214 .prepare = atmel_pcm_dma_prepare, 203 .prepare = atmel_pcm_dma_prepare,