* [PATCH v1 0/15] Patches to update for rockchip i2s
@ 2021-08-23 10:48 Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 01/15] ASoC: rockchip: i2s: Add support for set bclk ratio Sugar Zhang
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Sugar Zhang @ 2021-08-23 10:48 UTC (permalink / raw)
To: broonie, heiko
Cc: linux-rockchip, Sugar Zhang, Jaroslav Kysela, devicetree,
alsa-devel, Philipp Zabel, linux-kernel, Takashi Iwai,
Liam Girdwood, Rob Herring, linux-arm-kernel
These patches fixup or update for rockchip i2s.
Sugar Zhang (13):
ASoC: rockchip: i2s: Add support for set bclk ratio
ASoC: rockchip: i2s: Fixup clk div error
ASoC: rockchip: i2s: Improve dma data transfer efficiency
ASoC: rockchip: i2s: Fix regmap_ops hang
ASoC: rockchip: i2s: Fix concurrency between tx/rx
ASoC: rockchip: i2s: Reset the controller if soft reset failed
ASoC: dt-bindings: rockchip: Document reset property for i2s
ASoC: rockchip: i2s: Add property to specify play/cap capability
ASoC: dt-bindings: rockchip: i2s: Document property for
playback/capture
ASoC: rockchip: i2s: Add compatible for more SoCs
ASoC: dt-bindings: rockchip: Add compatible strings for more SoCs
ASoC: rockchip: i2s: Add support for frame inversion
ASoC: dt-bindings: rockchip: i2s: Document property 'clk-trcm'
Xiaotan Luo (1):
ASoC: rockchip: i2s: Fixup config for DAIFMT_DSP_A/B
Xing Zheng (1):
ASoC: rockchip: i2s: Add support for 'rockchip,clk-trcm' property
.../devicetree/bindings/sound/rockchip-i2s.yaml | 30 ++++
sound/soc/rockchip/rockchip_i2s.c | 153 ++++++++++++++++-----
sound/soc/rockchip/rockchip_i2s.h | 10 +-
3 files changed, 157 insertions(+), 36 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 01/15] ASoC: rockchip: i2s: Add support for set bclk ratio
2021-08-23 10:48 [PATCH v1 0/15] Patches to update for rockchip i2s Sugar Zhang
@ 2021-08-23 10:48 ` Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 02/15] ASoC: rockchip: i2s: Fixup clk div error Sugar Zhang
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Sugar Zhang @ 2021-08-23 10:48 UTC (permalink / raw)
To: broonie, heiko
Cc: linux-rockchip, Sugar Zhang, Liam Girdwood, Jaroslav Kysela,
Takashi Iwai, alsa-devel, linux-arm-kernel, linux-kernel
This patch adds support for set bclk ratio from machine driver.
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
---
sound/soc/rockchip/rockchip_i2s.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index c7dc350..c9d5c52 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -49,6 +49,7 @@ struct rk_i2s_dev {
bool rx_start;
bool is_master_mode;
const struct rk_i2s_pins *pins;
+ unsigned int bclk_ratio;
};
static int i2s_runtime_suspend(struct device *dev)
@@ -278,7 +279,7 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
if (i2s->is_master_mode) {
mclk_rate = clk_get_rate(i2s->mclk);
- bclk_rate = 2 * 32 * params_rate(params);
+ bclk_rate = i2s->bclk_ratio * params_rate(params);
if (bclk_rate == 0 || mclk_rate % bclk_rate)
return -EINVAL;
@@ -413,6 +414,16 @@ static int rockchip_i2s_trigger(struct snd_pcm_substream *substream,
return ret;
}
+static int rockchip_i2s_set_bclk_ratio(struct snd_soc_dai *dai,
+ unsigned int ratio)
+{
+ struct rk_i2s_dev *i2s = to_info(dai);
+
+ i2s->bclk_ratio = ratio;
+
+ return 0;
+}
+
static int rockchip_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, int clk_id,
unsigned int freq, int dir)
{
@@ -441,6 +452,7 @@ static int rockchip_i2s_dai_probe(struct snd_soc_dai *dai)
static const struct snd_soc_dai_ops rockchip_i2s_dai_ops = {
.hw_params = rockchip_i2s_hw_params,
+ .set_bclk_ratio = rockchip_i2s_set_bclk_ratio,
.set_sysclk = rockchip_i2s_set_sysclk,
.set_fmt = rockchip_i2s_set_fmt,
.trigger = rockchip_i2s_trigger,
@@ -638,6 +650,8 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
i2s->capture_dma_data.maxburst = 4;
+ i2s->bclk_ratio = 64;
+
dev_set_drvdata(&pdev->dev, i2s);
pm_runtime_enable(&pdev->dev);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 02/15] ASoC: rockchip: i2s: Fixup clk div error
2021-08-23 10:48 [PATCH v1 0/15] Patches to update for rockchip i2s Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 01/15] ASoC: rockchip: i2s: Add support for set bclk ratio Sugar Zhang
@ 2021-08-23 10:48 ` Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 03/15] ASoC: rockchip: i2s: Improve dma data transfer efficiency Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 04/15] ASoC: rockchip: i2s: Fix regmap_ops hang Sugar Zhang
3 siblings, 0 replies; 5+ messages in thread
From: Sugar Zhang @ 2021-08-23 10:48 UTC (permalink / raw)
To: broonie, heiko
Cc: linux-rockchip, Sugar Zhang, Liam Girdwood, Jaroslav Kysela,
Takashi Iwai, alsa-devel, linux-arm-kernel, linux-kernel
MCLK maybe not precise as required because of PLL,
but which still can be used and no side effect. so,
using DIV_ROUND_CLOSEST instead div.
e.g.
set mclk to 11289600 Hz, but get 11289598 Hz.
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
---
sound/soc/rockchip/rockchip_i2s.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index c9d5c52..05fce2c 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -280,10 +280,10 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
if (i2s->is_master_mode) {
mclk_rate = clk_get_rate(i2s->mclk);
bclk_rate = i2s->bclk_ratio * params_rate(params);
- if (bclk_rate == 0 || mclk_rate % bclk_rate)
+ if (!bclk_rate)
return -EINVAL;
- div_bclk = mclk_rate / bclk_rate;
+ div_bclk = DIV_ROUND_CLOSEST(mclk_rate, bclk_rate);
div_lrck = bclk_rate / params_rate(params);
regmap_update_bits(i2s->regmap, I2S_CKR,
I2S_CKR_MDIV_MASK,
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 03/15] ASoC: rockchip: i2s: Improve dma data transfer efficiency
2021-08-23 10:48 [PATCH v1 0/15] Patches to update for rockchip i2s Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 01/15] ASoC: rockchip: i2s: Add support for set bclk ratio Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 02/15] ASoC: rockchip: i2s: Fixup clk div error Sugar Zhang
@ 2021-08-23 10:48 ` Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 04/15] ASoC: rockchip: i2s: Fix regmap_ops hang Sugar Zhang
3 siblings, 0 replies; 5+ messages in thread
From: Sugar Zhang @ 2021-08-23 10:48 UTC (permalink / raw)
To: broonie, heiko
Cc: linux-rockchip, Sugar Zhang, Liam Girdwood, Jaroslav Kysela,
Takashi Iwai, alsa-devel, linux-arm-kernel, linux-kernel
This patch changes dma data burst from 4 to 8 to improve
data transfer efficiency.
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
---
sound/soc/rockchip/rockchip_i2s.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index 05fce2c..2e0047d 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -644,11 +644,11 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
i2s->playback_dma_data.addr = res->start + I2S_TXDR;
i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
- i2s->playback_dma_data.maxburst = 4;
+ i2s->playback_dma_data.maxburst = 8;
i2s->capture_dma_data.addr = res->start + I2S_RXDR;
i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
- i2s->capture_dma_data.maxburst = 4;
+ i2s->capture_dma_data.maxburst = 8;
i2s->bclk_ratio = 64;
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 04/15] ASoC: rockchip: i2s: Fix regmap_ops hang
2021-08-23 10:48 [PATCH v1 0/15] Patches to update for rockchip i2s Sugar Zhang
` (2 preceding siblings ...)
2021-08-23 10:48 ` [PATCH v1 03/15] ASoC: rockchip: i2s: Improve dma data transfer efficiency Sugar Zhang
@ 2021-08-23 10:48 ` Sugar Zhang
3 siblings, 0 replies; 5+ messages in thread
From: Sugar Zhang @ 2021-08-23 10:48 UTC (permalink / raw)
To: broonie, heiko
Cc: linux-rockchip, Sugar Zhang, Liam Girdwood, Jaroslav Kysela,
Takashi Iwai, alsa-devel, linux-arm-kernel, linux-kernel
API 'set_fmt' maybe called when PD is off, in the situation,
any register access will hang the system. so, enable PD
before r/w register.
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
---
sound/soc/rockchip/rockchip_i2s.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index 2e0047d..90877e8 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -187,7 +187,9 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
{
struct rk_i2s_dev *i2s = to_info(cpu_dai);
unsigned int mask = 0, val = 0;
+ int ret = 0;
+ pm_runtime_get_sync(cpu_dai->dev);
mask = I2S_CKR_MSS_MASK;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBS_CFS:
@@ -200,7 +202,8 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
i2s->is_master_mode = false;
break;
default:
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_pm_put;
}
regmap_update_bits(i2s->regmap, I2S_CKR, mask, val);
@@ -214,7 +217,8 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
val = I2S_CKR_CKP_POS;
break;
default:
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_pm_put;
}
regmap_update_bits(i2s->regmap, I2S_CKR, mask, val);
@@ -237,7 +241,8 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
val = I2S_TXCR_TFS_PCM | I2S_TXCR_PBM_MODE(1);
break;
default:
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_pm_put;
}
regmap_update_bits(i2s->regmap, I2S_TXCR, mask, val);
@@ -260,12 +265,16 @@ static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
val = I2S_RXCR_TFS_PCM | I2S_RXCR_PBM_MODE(1);
break;
default:
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_pm_put;
}
regmap_update_bits(i2s->regmap, I2S_RXCR, mask, val);
- return 0;
+err_pm_put:
+ pm_runtime_put(cpu_dai->dev);
+
+ return ret;
}
static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-23 10:49 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23 10:48 [PATCH v1 0/15] Patches to update for rockchip i2s Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 01/15] ASoC: rockchip: i2s: Add support for set bclk ratio Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 02/15] ASoC: rockchip: i2s: Fixup clk div error Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 03/15] ASoC: rockchip: i2s: Improve dma data transfer efficiency Sugar Zhang
2021-08-23 10:48 ` [PATCH v1 04/15] ASoC: rockchip: i2s: Fix regmap_ops hang Sugar Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).