Commit ebf629d5 authored by Olivier Moysan's avatar Olivier Moysan Committed by Mark Brown

ASoC: stm32: i2s: fix stream count management

Move counter handling to trigger start section
to manage multiple start/stop events.
Signed-off-by: default avatarOlivier Moysan <olivier.moysan@st.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 0c4c68d6
...@@ -554,10 +554,6 @@ static int stm32_i2s_startup(struct snd_pcm_substream *substream, ...@@ -554,10 +554,6 @@ static int stm32_i2s_startup(struct snd_pcm_substream *substream,
return ret; return ret;
} }
spin_lock(&i2s->lock_fd);
i2s->refcount++;
spin_unlock(&i2s->lock_fd);
return regmap_write_bits(i2s->regmap, STM32_I2S_IFCR_REG, return regmap_write_bits(i2s->regmap, STM32_I2S_IFCR_REG,
I2S_IFCR_MASK, I2S_IFCR_MASK); I2S_IFCR_MASK, I2S_IFCR_MASK);
} }
...@@ -613,18 +609,19 @@ static int stm32_i2s_trigger(struct snd_pcm_substream *substream, int cmd, ...@@ -613,18 +609,19 @@ static int stm32_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
regmap_write_bits(i2s->regmap, STM32_I2S_IFCR_REG, regmap_write_bits(i2s->regmap, STM32_I2S_IFCR_REG,
I2S_IFCR_MASK, I2S_IFCR_MASK); I2S_IFCR_MASK, I2S_IFCR_MASK);
spin_lock(&i2s->lock_fd);
i2s->refcount++;
if (playback_flg) { if (playback_flg) {
ier = I2S_IER_UDRIE; ier = I2S_IER_UDRIE;
} else { } else {
ier = I2S_IER_OVRIE; ier = I2S_IER_OVRIE;
spin_lock(&i2s->lock_fd);
if (i2s->refcount == 1) if (i2s->refcount == 1)
/* dummy write to trigger capture */ /* dummy write to trigger capture */
regmap_write(i2s->regmap, regmap_write(i2s->regmap,
STM32_I2S_TXDR_REG, 0); STM32_I2S_TXDR_REG, 0);
spin_unlock(&i2s->lock_fd);
} }
spin_unlock(&i2s->lock_fd);
if (STM32_I2S_IS_SLAVE(i2s)) if (STM32_I2S_IS_SLAVE(i2s))
ier |= I2S_IER_TIFREIE; ier |= I2S_IER_TIFREIE;
...@@ -649,7 +646,6 @@ static int stm32_i2s_trigger(struct snd_pcm_substream *substream, int cmd, ...@@ -649,7 +646,6 @@ static int stm32_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
spin_unlock(&i2s->lock_fd); spin_unlock(&i2s->lock_fd);
break; break;
} }
spin_unlock(&i2s->lock_fd);
dev_dbg(cpu_dai->dev, "stop I2S\n"); dev_dbg(cpu_dai->dev, "stop I2S\n");
...@@ -657,8 +653,10 @@ static int stm32_i2s_trigger(struct snd_pcm_substream *substream, int cmd, ...@@ -657,8 +653,10 @@ static int stm32_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
I2S_CR1_SPE, 0); I2S_CR1_SPE, 0);
if (ret < 0) { if (ret < 0) {
dev_err(cpu_dai->dev, "Error %d disabling I2S\n", ret); dev_err(cpu_dai->dev, "Error %d disabling I2S\n", ret);
spin_unlock(&i2s->lock_fd);
return ret; return ret;
} }
spin_unlock(&i2s->lock_fd);
cfg1_mask = I2S_CFG1_RXDMAEN | I2S_CFG1_TXDMAEN; cfg1_mask = I2S_CFG1_RXDMAEN | I2S_CFG1_TXDMAEN;
regmap_update_bits(i2s->regmap, STM32_I2S_CFG1_REG, regmap_update_bits(i2s->regmap, STM32_I2S_CFG1_REG,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment