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 Sugar Zhang
parent 9107b1d583
commit e249d0522e

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>
@@ -55,6 +56,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);
@@ -96,6 +100,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);
@@ -136,6 +141,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)
@@ -143,6 +149,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);
@@ -183,6 +190,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,