ASoC: rockchip: i2s: protect I2S_XFER_TXS/I2S_XFER_RXS with spin lock

fix bug error log: "rockchip-i2s ff070000.i2s: fail to clear".
When the TX/RX have started, can not do 'clear operation'.

Change-Id: Ia156144490a61f4fa9823b1313588e44688f4bce
Signed-off-by: Binyuan Lan <lby@rock-chips.com>
This commit is contained in:
Binyuan Lan
2018-03-23 22:57:33 +08:00
committed by Tao Huang
parent 7c4f5712a0
commit 7482a49a2d

View File

@@ -18,6 +18,7 @@
#include <linux/clk.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/spinlock.h>
#include <sound/pcm_params.h>
#include <sound/dmaengine_pcm.h>
@@ -54,6 +55,9 @@ struct rk_i2s_dev {
unsigned int bclk_fs;
};
/* txctrl/rxctrl lock */
static DEFINE_SPINLOCK(lock);
static int i2s_runtime_suspend(struct device *dev)
{
struct rk_i2s_dev *i2s = dev_get_drvdata(dev);
@@ -95,6 +99,7 @@ static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
unsigned int val = 0;
int retry = 10;
spin_lock(&lock);
if (on) {
regmap_update_bits(i2s->regmap, I2S_DMACR,
I2S_DMACR_TDE_ENABLE, I2S_DMACR_TDE_ENABLE);
@@ -135,6 +140,7 @@ static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on)
}
}
}
spin_unlock(&lock);
}
static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
@@ -142,6 +148,7 @@ static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
unsigned int val = 0;
int retry = 10;
spin_lock(&lock);
if (on) {
regmap_update_bits(i2s->regmap, I2S_DMACR,
I2S_DMACR_RDE_ENABLE, I2S_DMACR_RDE_ENABLE);
@@ -182,6 +189,7 @@ static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
}
}
}
spin_unlock(&lock);
}
static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,