diff options
author | Troy Kisky <troy.kisky@boundarydevices.com> | 2009-09-11 17:29:02 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-09-23 13:08:56 -0400 |
commit | 81ac55aa14c863821248d9e82694c79bb556694d (patch) | |
tree | 6484713a22832c2557cbdf79901481b80abf3191 /sound/soc | |
parent | df0fd5e5e117329436fdea568455545ca18a71f0 (diff) |
ASoC: DaVinci: Fix divide by zero error during 1st execution
When both playback and capture stream were open
davinci_i2s_hw_params was setting parameters for
the wrong stream. The fix for davinci_i2s_hw_params
is sufficient, but it looks like a race still happens
in davici_pcm_open. This patch also makes the race smaller
but the next patch provides a better fix.
Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/davinci/davinci-i2s.c | 3 | ||||
-rw-r--r-- | sound/soc/davinci/davinci-pcm.c | 12 |
2 files changed, 7 insertions, 8 deletions
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index 12a6c549ee6e..d32e1974fdf2 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c | |||
@@ -353,8 +353,9 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream, | |||
353 | struct snd_pcm_hw_params *params, | 353 | struct snd_pcm_hw_params *params, |
354 | struct snd_soc_dai *dai) | 354 | struct snd_soc_dai *dai) |
355 | { | 355 | { |
356 | struct davinci_pcm_dma_params *dma_params = dai->dma_data; | ||
357 | struct davinci_mcbsp_dev *dev = dai->private_data; | 356 | struct davinci_mcbsp_dev *dev = dai->private_data; |
357 | struct davinci_pcm_dma_params *dma_params = | ||
358 | dev->dma_params[substream->stream]; | ||
358 | struct snd_interval *i = NULL; | 359 | struct snd_interval *i = NULL; |
359 | int mcbsp_word_length; | 360 | int mcbsp_word_length; |
360 | unsigned int rcr, xcr, srgr; | 361 | unsigned int rcr, xcr, srgr; |
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c index 091dacb78b4d..002808b27f49 100644 --- a/sound/soc/davinci/davinci-pcm.c +++ b/sound/soc/davinci/davinci-pcm.c | |||
@@ -126,16 +126,9 @@ static void davinci_pcm_dma_irq(unsigned lch, u16 ch_status, void *data) | |||
126 | static int davinci_pcm_dma_request(struct snd_pcm_substream *substream) | 126 | static int davinci_pcm_dma_request(struct snd_pcm_substream *substream) |
127 | { | 127 | { |
128 | struct davinci_runtime_data *prtd = substream->runtime->private_data; | 128 | struct davinci_runtime_data *prtd = substream->runtime->private_data; |
129 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
130 | struct davinci_pcm_dma_params *dma_data = rtd->dai->cpu_dai->dma_data; | ||
131 | struct edmacc_param p_ram; | 129 | struct edmacc_param p_ram; |
132 | int ret; | 130 | int ret; |
133 | 131 | ||
134 | if (!dma_data) | ||
135 | return -ENODEV; | ||
136 | |||
137 | prtd->params = dma_data; | ||
138 | |||
139 | /* Request master DMA channel */ | 132 | /* Request master DMA channel */ |
140 | ret = edma_alloc_channel(prtd->params->channel, | 133 | ret = edma_alloc_channel(prtd->params->channel, |
141 | davinci_pcm_dma_irq, substream, | 134 | davinci_pcm_dma_irq, substream, |
@@ -244,6 +237,10 @@ static int davinci_pcm_open(struct snd_pcm_substream *substream) | |||
244 | struct snd_pcm_runtime *runtime = substream->runtime; | 237 | struct snd_pcm_runtime *runtime = substream->runtime; |
245 | struct davinci_runtime_data *prtd; | 238 | struct davinci_runtime_data *prtd; |
246 | int ret = 0; | 239 | int ret = 0; |
240 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
241 | struct davinci_pcm_dma_params *params = rtd->dai->cpu_dai->dma_data; | ||
242 | if (!params) | ||
243 | return -ENODEV; | ||
247 | 244 | ||
248 | snd_soc_set_runtime_hwparams(substream, &davinci_pcm_hardware); | 245 | snd_soc_set_runtime_hwparams(substream, &davinci_pcm_hardware); |
249 | /* ensure that buffer size is a multiple of period size */ | 246 | /* ensure that buffer size is a multiple of period size */ |
@@ -257,6 +254,7 @@ static int davinci_pcm_open(struct snd_pcm_substream *substream) | |||
257 | return -ENOMEM; | 254 | return -ENOMEM; |
258 | 255 | ||
259 | spin_lock_init(&prtd->lock); | 256 | spin_lock_init(&prtd->lock); |
257 | prtd->params = params; | ||
260 | 258 | ||
261 | runtime->private_data = prtd; | 259 | runtime->private_data = prtd; |
262 | 260 | ||