diff options
author | Daniel Mack <daniel@caiaq.de> | 2010-03-19 10:52:55 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-03-19 15:37:29 -0400 |
commit | fd23b7dee5e4d369f620979cb120f53629389355 (patch) | |
tree | bbfa4637b0b97662b8ee63922eccb01913baaf1d /sound/soc/s3c24xx | |
parent | 093208f5d03980d7216b706e3c54432d0f299e26 (diff) |
ASoC: move dma_data from snd_soc_dai to snd_soc_pcm_stream
This fixes a memory corruption when ASoC devices are used in
full-duplex mode. Specifically for pxa-ssp code, where this pointer
is dynamically allocated for each direction and destroyed upon each
stream start.
All other platforms are fixed blindly, I couldn't even compile-test
them. Sorry for any breakage I may have caused.
Reported-by: Sven Neumann <s.neumann@raumfeld.com>
Reported-by: Michael Hirsch <m.hirsch@raumfeld.com>
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Acked-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/s3c24xx')
-rw-r--r-- | sound/soc/s3c24xx/s3c-ac97.c | 21 | ||||
-rw-r--r-- | sound/soc/s3c24xx/s3c-dma.c | 4 | ||||
-rw-r--r-- | sound/soc/s3c24xx/s3c-i2s-v2.c | 13 | ||||
-rw-r--r-- | sound/soc/s3c24xx/s3c-pcm.c | 7 | ||||
-rw-r--r-- | sound/soc/s3c24xx/s3c2412-i2s.c | 7 | ||||
-rw-r--r-- | sound/soc/s3c24xx/s3c24xx-i2s.c | 19 |
6 files changed, 43 insertions, 28 deletions
diff --git a/sound/soc/s3c24xx/s3c-ac97.c b/sound/soc/s3c24xx/s3c-ac97.c index ee8ed9d7e703..ecf4fd04ae96 100644 --- a/sound/soc/s3c24xx/s3c-ac97.c +++ b/sound/soc/s3c24xx/s3c-ac97.c | |||
@@ -224,11 +224,14 @@ static int s3c_ac97_hw_params(struct snd_pcm_substream *substream, | |||
224 | { | 224 | { |
225 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 225 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
226 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | 226 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; |
227 | struct s3c_dma_params *dma_data; | ||
227 | 228 | ||
228 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 229 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
229 | cpu_dai->dma_data = &s3c_ac97_pcm_out; | 230 | dma_data = &s3c_ac97_pcm_out; |
230 | else | 231 | else |
231 | cpu_dai->dma_data = &s3c_ac97_pcm_in; | 232 | dma_data = &s3c_ac97_pcm_in; |
233 | |||
234 | snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data); | ||
232 | 235 | ||
233 | return 0; | 236 | return 0; |
234 | } | 237 | } |
@@ -238,8 +241,8 @@ static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd, | |||
238 | { | 241 | { |
239 | u32 ac_glbctrl; | 242 | u32 ac_glbctrl; |
240 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 243 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
241 | int channel = ((struct s3c_dma_params *) | 244 | struct s3c_dma_params *dma_data = |
242 | rtd->dai->cpu_dai->dma_data)->channel; | 245 | snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream); |
243 | 246 | ||
244 | ac_glbctrl = readl(s3c_ac97.regs + S3C_AC97_GLBCTRL); | 247 | ac_glbctrl = readl(s3c_ac97.regs + S3C_AC97_GLBCTRL); |
245 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | 248 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) |
@@ -265,7 +268,7 @@ static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd, | |||
265 | 268 | ||
266 | writel(ac_glbctrl, s3c_ac97.regs + S3C_AC97_GLBCTRL); | 269 | writel(ac_glbctrl, s3c_ac97.regs + S3C_AC97_GLBCTRL); |
267 | 270 | ||
268 | s3c2410_dma_ctrl(channel, S3C2410_DMAOP_STARTED); | 271 | s3c2410_dma_ctrl(dma_data->channel, S3C2410_DMAOP_STARTED); |
269 | 272 | ||
270 | return 0; | 273 | return 0; |
271 | } | 274 | } |
@@ -280,7 +283,7 @@ static int s3c_ac97_hw_mic_params(struct snd_pcm_substream *substream, | |||
280 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 283 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
281 | return -ENODEV; | 284 | return -ENODEV; |
282 | else | 285 | else |
283 | cpu_dai->dma_data = &s3c_ac97_mic_in; | 286 | snd_soc_dai_set_dma_data(cpu_dai, substream, &s3c_ac97_mic_in); |
284 | 287 | ||
285 | return 0; | 288 | return 0; |
286 | } | 289 | } |
@@ -290,8 +293,8 @@ static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream, | |||
290 | { | 293 | { |
291 | u32 ac_glbctrl; | 294 | u32 ac_glbctrl; |
292 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 295 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
293 | int channel = ((struct s3c_dma_params *) | 296 | struct s3c_dma_params *dma_data = |
294 | rtd->dai->cpu_dai->dma_data)->channel; | 297 | snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream); |
295 | 298 | ||
296 | ac_glbctrl = readl(s3c_ac97.regs + S3C_AC97_GLBCTRL); | 299 | ac_glbctrl = readl(s3c_ac97.regs + S3C_AC97_GLBCTRL); |
297 | ac_glbctrl &= ~S3C_AC97_GLBCTRL_MICINTM_MASK; | 300 | ac_glbctrl &= ~S3C_AC97_GLBCTRL_MICINTM_MASK; |
@@ -311,7 +314,7 @@ static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream, | |||
311 | 314 | ||
312 | writel(ac_glbctrl, s3c_ac97.regs + S3C_AC97_GLBCTRL); | 315 | writel(ac_glbctrl, s3c_ac97.regs + S3C_AC97_GLBCTRL); |
313 | 316 | ||
314 | s3c2410_dma_ctrl(channel, S3C2410_DMAOP_STARTED); | 317 | s3c2410_dma_ctrl(dma_data->channel, S3C2410_DMAOP_STARTED); |
315 | 318 | ||
316 | return 0; | 319 | return 0; |
317 | } | 320 | } |
diff --git a/sound/soc/s3c24xx/s3c-dma.c b/sound/soc/s3c24xx/s3c-dma.c index 7725e26d6c91..1b61c23ff300 100644 --- a/sound/soc/s3c24xx/s3c-dma.c +++ b/sound/soc/s3c24xx/s3c-dma.c | |||
@@ -145,10 +145,12 @@ static int s3c_dma_hw_params(struct snd_pcm_substream *substream, | |||
145 | struct snd_pcm_runtime *runtime = substream->runtime; | 145 | struct snd_pcm_runtime *runtime = substream->runtime; |
146 | struct s3c24xx_runtime_data *prtd = runtime->private_data; | 146 | struct s3c24xx_runtime_data *prtd = runtime->private_data; |
147 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 147 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
148 | struct s3c_dma_params *dma = rtd->dai->cpu_dai->dma_data; | ||
149 | unsigned long totbytes = params_buffer_bytes(params); | 148 | unsigned long totbytes = params_buffer_bytes(params); |
149 | struct s3c_dma_params *dma = | ||
150 | snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream); | ||
150 | int ret = 0; | 151 | int ret = 0; |
151 | 152 | ||
153 | |||
152 | pr_debug("Entered %s\n", __func__); | 154 | pr_debug("Entered %s\n", __func__); |
153 | 155 | ||
154 | /* return if this is a bufferless transfer e.g. | 156 | /* return if this is a bufferless transfer e.g. |
diff --git a/sound/soc/s3c24xx/s3c-i2s-v2.c b/sound/soc/s3c24xx/s3c-i2s-v2.c index c3fcb63cbf25..865f93143bf1 100644 --- a/sound/soc/s3c24xx/s3c-i2s-v2.c +++ b/sound/soc/s3c24xx/s3c-i2s-v2.c | |||
@@ -333,14 +333,17 @@ static int s3c_i2sv2_hw_params(struct snd_pcm_substream *substream, | |||
333 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 333 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
334 | struct snd_soc_dai_link *dai = rtd->dai; | 334 | struct snd_soc_dai_link *dai = rtd->dai; |
335 | struct s3c_i2sv2_info *i2s = to_info(dai->cpu_dai); | 335 | struct s3c_i2sv2_info *i2s = to_info(dai->cpu_dai); |
336 | struct s3c_dma_params *dma_data; | ||
336 | u32 iismod; | 337 | u32 iismod; |
337 | 338 | ||
338 | pr_debug("Entered %s\n", __func__); | 339 | pr_debug("Entered %s\n", __func__); |
339 | 340 | ||
340 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 341 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
341 | dai->cpu_dai->dma_data = i2s->dma_playback; | 342 | dma_data = i2s->dma_playback; |
342 | else | 343 | else |
343 | dai->cpu_dai->dma_data = i2s->dma_capture; | 344 | dma_data = i2s->dma_capture; |
345 | |||
346 | snd_soc_dai_set_dma_data(dai->cpu_dai, substream, dma_data); | ||
344 | 347 | ||
345 | /* Working copies of register */ | 348 | /* Working copies of register */ |
346 | iismod = readl(i2s->regs + S3C2412_IISMOD); | 349 | iismod = readl(i2s->regs + S3C2412_IISMOD); |
@@ -372,8 +375,8 @@ static int s3c2412_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | |||
372 | int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); | 375 | int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); |
373 | unsigned long irqs; | 376 | unsigned long irqs; |
374 | int ret = 0; | 377 | int ret = 0; |
375 | int channel = ((struct s3c_dma_params *) | 378 | struct s3c_dma_params *dma_data = |
376 | rtd->dai->cpu_dai->dma_data)->channel; | 379 | snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream); |
377 | 380 | ||
378 | pr_debug("Entered %s\n", __func__); | 381 | pr_debug("Entered %s\n", __func__); |
379 | 382 | ||
@@ -409,7 +412,7 @@ static int s3c2412_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | |||
409 | * of the auto reload mechanism of S3C24XX. | 412 | * of the auto reload mechanism of S3C24XX. |
410 | * This call won't bother S3C64XX. | 413 | * This call won't bother S3C64XX. |
411 | */ | 414 | */ |
412 | s3c2410_dma_ctrl(channel, S3C2410_DMAOP_STARTED); | 415 | s3c2410_dma_ctrl(dma_data->channel, S3C2410_DMAOP_STARTED); |
413 | 416 | ||
414 | break; | 417 | break; |
415 | 418 | ||
diff --git a/sound/soc/s3c24xx/s3c-pcm.c b/sound/soc/s3c24xx/s3c-pcm.c index a98f40c3cd29..326f0a9e7e30 100644 --- a/sound/soc/s3c24xx/s3c-pcm.c +++ b/sound/soc/s3c24xx/s3c-pcm.c | |||
@@ -178,6 +178,7 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream, | |||
178 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 178 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
179 | struct snd_soc_dai_link *dai = rtd->dai; | 179 | struct snd_soc_dai_link *dai = rtd->dai; |
180 | struct s3c_pcm_info *pcm = to_info(dai->cpu_dai); | 180 | struct s3c_pcm_info *pcm = to_info(dai->cpu_dai); |
181 | struct s3c_dma_params *dma_data; | ||
181 | void __iomem *regs = pcm->regs; | 182 | void __iomem *regs = pcm->regs; |
182 | struct clk *clk; | 183 | struct clk *clk; |
183 | int sclk_div, sync_div; | 184 | int sclk_div, sync_div; |
@@ -187,9 +188,11 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream, | |||
187 | dev_dbg(pcm->dev, "Entered %s\n", __func__); | 188 | dev_dbg(pcm->dev, "Entered %s\n", __func__); |
188 | 189 | ||
189 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 190 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
190 | dai->cpu_dai->dma_data = pcm->dma_playback; | 191 | dma_data = pcm->dma_playback; |
191 | else | 192 | else |
192 | dai->cpu_dai->dma_data = pcm->dma_capture; | 193 | dma_data = pcm->dma_capture; |
194 | |||
195 | snd_soc_dai_set_dma_data(dai->cpu_dai, substream, dma_data); | ||
193 | 196 | ||
194 | /* Strictly check for sample size */ | 197 | /* Strictly check for sample size */ |
195 | switch (params_format(params)) { | 198 | switch (params_format(params)) { |
diff --git a/sound/soc/s3c24xx/s3c2412-i2s.c b/sound/soc/s3c24xx/s3c2412-i2s.c index a5b21f63261f..f3148f98b419 100644 --- a/sound/soc/s3c24xx/s3c2412-i2s.c +++ b/sound/soc/s3c24xx/s3c2412-i2s.c | |||
@@ -151,14 +151,17 @@ static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream, | |||
151 | struct snd_soc_dai *cpu_dai) | 151 | struct snd_soc_dai *cpu_dai) |
152 | { | 152 | { |
153 | struct s3c_i2sv2_info *i2s = to_info(cpu_dai); | 153 | struct s3c_i2sv2_info *i2s = to_info(cpu_dai); |
154 | struct s3c_dma_params *dma_data; | ||
154 | u32 iismod; | 155 | u32 iismod; |
155 | 156 | ||
156 | pr_debug("Entered %s\n", __func__); | 157 | pr_debug("Entered %s\n", __func__); |
157 | 158 | ||
158 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 159 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
159 | cpu_dai->dma_data = i2s->dma_playback; | 160 | dma_data = i2s->dma_playback; |
160 | else | 161 | else |
161 | cpu_dai->dma_data = i2s->dma_capture; | 162 | dma_data = i2s->dma_capture; |
163 | |||
164 | snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data); | ||
162 | 165 | ||
163 | iismod = readl(i2s->regs + S3C2412_IISMOD); | 166 | iismod = readl(i2s->regs + S3C2412_IISMOD); |
164 | pr_debug("%s: r: IISMOD: %x\n", __func__, iismod); | 167 | pr_debug("%s: r: IISMOD: %x\n", __func__, iismod); |
diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c index 0bc5950b9f02..c3ac890a3986 100644 --- a/sound/soc/s3c24xx/s3c24xx-i2s.c +++ b/sound/soc/s3c24xx/s3c24xx-i2s.c | |||
@@ -242,14 +242,17 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream, | |||
242 | struct snd_soc_dai *dai) | 242 | struct snd_soc_dai *dai) |
243 | { | 243 | { |
244 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 244 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
245 | struct s3c_dma_params *dma_data; | ||
245 | u32 iismod; | 246 | u32 iismod; |
246 | 247 | ||
247 | pr_debug("Entered %s\n", __func__); | 248 | pr_debug("Entered %s\n", __func__); |
248 | 249 | ||
249 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 250 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
250 | rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_out; | 251 | dma_data = &s3c24xx_i2s_pcm_stereo_out; |
251 | else | 252 | else |
252 | rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_in; | 253 | dma_data = &s3c24xx_i2s_pcm_stereo_in; |
254 | |||
255 | snd_soc_dai_set_dma_data(rtd->dai->cpu_dai, substream, dma_data); | ||
253 | 256 | ||
254 | /* Working copies of register */ | 257 | /* Working copies of register */ |
255 | iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); | 258 | iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); |
@@ -258,13 +261,11 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream, | |||
258 | switch (params_format(params)) { | 261 | switch (params_format(params)) { |
259 | case SNDRV_PCM_FORMAT_S8: | 262 | case SNDRV_PCM_FORMAT_S8: |
260 | iismod &= ~S3C2410_IISMOD_16BIT; | 263 | iismod &= ~S3C2410_IISMOD_16BIT; |
261 | ((struct s3c_dma_params *) | 264 | dma_data->dma_size = 1; |
262 | rtd->dai->cpu_dai->dma_data)->dma_size = 1; | ||
263 | break; | 265 | break; |
264 | case SNDRV_PCM_FORMAT_S16_LE: | 266 | case SNDRV_PCM_FORMAT_S16_LE: |
265 | iismod |= S3C2410_IISMOD_16BIT; | 267 | iismod |= S3C2410_IISMOD_16BIT; |
266 | ((struct s3c_dma_params *) | 268 | dma_data->dma_size = 2; |
267 | rtd->dai->cpu_dai->dma_data)->dma_size = 2; | ||
268 | break; | 269 | break; |
269 | default: | 270 | default: |
270 | return -EINVAL; | 271 | return -EINVAL; |
@@ -280,8 +281,8 @@ static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | |||
280 | { | 281 | { |
281 | int ret = 0; | 282 | int ret = 0; |
282 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 283 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
283 | int channel = ((struct s3c_dma_params *) | 284 | struct s3c_dma_params *dma_data = |
284 | rtd->dai->cpu_dai->dma_data)->channel; | 285 | snd_soc_dai_get_dma_data(rtd->dai->cpu_dai, substream); |
285 | 286 | ||
286 | pr_debug("Entered %s\n", __func__); | 287 | pr_debug("Entered %s\n", __func__); |
287 | 288 | ||
@@ -300,7 +301,7 @@ static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | |||
300 | else | 301 | else |
301 | s3c24xx_snd_txctrl(1); | 302 | s3c24xx_snd_txctrl(1); |
302 | 303 | ||
303 | s3c2410_dma_ctrl(channel, S3C2410_DMAOP_STARTED); | 304 | s3c2410_dma_ctrl(dma_data->channel, S3C2410_DMAOP_STARTED); |
304 | break; | 305 | break; |
305 | case SNDRV_PCM_TRIGGER_STOP: | 306 | case SNDRV_PCM_TRIGGER_STOP: |
306 | case SNDRV_PCM_TRIGGER_SUSPEND: | 307 | case SNDRV_PCM_TRIGGER_SUSPEND: |