[alsa-devel] [PATCH 0/2] ASoC: rockchip: i2s: fix TDL and RDL to 16 bits
To make Bus DMA works more efficiency, DMA may work in burst mode, we set the watermark of transmit and receive reach to 16 bits.
Jianqun Xu (2): ASoC: rockchip: i2s: fix error defination of transmit data level ASoC: rockchip: i2s: set TDL and RDL to 16 bits
sound/soc/rockchip/rockchip_i2s.c | 4 ++++ sound/soc/rockchip/rockchip_i2s.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
According to description about "Transmit Data Level",
This bit field controls the level at which a DMA request is made by the transmit logic.
It is equal to the watermark level.
That is, the dma_tx_req signal is generated when the number of valid data entries in the TXFIFO (TXFIFO0 if CSR=00 TXFIFO1 if CSR=01 TXFIFO2 if CSR=10 TXFIFO3 if CSR=11) is equal to or below this field value.
Different to receive data level, transmit data level does not need to "-1".
Signed-off-by: Jianqun Xu jay.xu@rock-chips.com --- sound/soc/rockchip/rockchip_i2s.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/rockchip/rockchip_i2s.h b/sound/soc/rockchip/rockchip_i2s.h index 89a5d8b..93f456f 100644 --- a/sound/soc/rockchip/rockchip_i2s.h +++ b/sound/soc/rockchip/rockchip_i2s.h @@ -127,7 +127,7 @@ #define I2S_DMACR_TDE_DISABLE (0 << I2S_DMACR_TDE_SHIFT) #define I2S_DMACR_TDE_ENABLE (1 << I2S_DMACR_TDE_SHIFT) #define I2S_DMACR_TDL_SHIFT 0 -#define I2S_DMACR_TDL(x) ((x - 1) << I2S_DMACR_TDL_SHIFT) +#define I2S_DMACR_TDL(x) ((x) << I2S_DMACR_TDL_SHIFT) #define I2S_DMACR_TDL_MASK (0x1f << I2S_DMACR_TDL_SHIFT)
/*
Set Transmit Data Level(TDL) and Receive Data Level(RDL) to 16 bits. Without this setting, the TDL is default to be 0x00 (means 1 bit), and the RDL is default to be 0x1f (means 16 bits).
This patch is helpful to fix pop sound, tested on rk3288 board.
Signed-off-by: Jianqun Xu jay.xu@rock-chips.com --- sound/soc/rockchip/rockchip_i2s.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index c74ba37..1cd7efc 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -247,6 +247,10 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
regmap_update_bits(i2s->regmap, I2S_TXCR, I2S_TXCR_VDW_MASK, val); regmap_update_bits(i2s->regmap, I2S_RXCR, I2S_RXCR_VDW_MASK, val); + regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_TDL_MASK, + I2S_DMACR_TDL(16)); + regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_RDL_MASK, + I2S_DMACR_RDL(16));
return 0; }
On Tue, Dec 23, 2014 at 1:08 AM, Jianqun Xu jay.xu@rock-chips.com wrote:
Set Transmit Data Level(TDL) and Receive Data Level(RDL) to 16 bits. Without this setting, the TDL is default to be 0x00 (means 1 bit), and the RDL is default to be 0x1f (means 16 bits).
My impression from the TRM was that TDL and RDL were measured in samples. Are you sure it's 'bits'?
This patch is helpful to fix pop sound, tested on rk3288 board.
Signed-off-by: Jianqun Xu jay.xu@rock-chips.com
sound/soc/rockchip/rockchip_i2s.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index c74ba37..1cd7efc 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -247,6 +247,10 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
regmap_update_bits(i2s->regmap, I2S_TXCR, I2S_TXCR_VDW_MASK, val); regmap_update_bits(i2s->regmap, I2S_RXCR, I2S_RXCR_VDW_MASK, val);
regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_TDL_MASK,
I2S_DMACR_TDL(16));
regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_RDL_MASK,
I2S_DMACR_RDL(16)); return 0;
}
1.9.1
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
在 12/24/2014 07:06 AM, Dylan Reid 写道:
On Tue, Dec 23, 2014 at 1:08 AM, Jianqun Xu jay.xu@rock-chips.com wrote:
Set Transmit Data Level(TDL) and Receive Data Level(RDL) to 16 bits. Without this setting, the TDL is default to be 0x00 (means 1 bit), and the RDL is default to be 0x1f (means 16 bits).
My impression from the TRM was that TDL and RDL were measured in samples. Are you sure it's 'bits'?
You are right, I'll modify the commit message next version, thank you
This patch is helpful to fix pop sound, tested on rk3288 board.
Signed-off-by: Jianqun Xu jay.xu@rock-chips.com
sound/soc/rockchip/rockchip_i2s.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index c74ba37..1cd7efc 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -247,6 +247,10 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
regmap_update_bits(i2s->regmap, I2S_TXCR, I2S_TXCR_VDW_MASK, val); regmap_update_bits(i2s->regmap, I2S_RXCR, I2S_RXCR_VDW_MASK, val);
regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_TDL_MASK,
I2S_DMACR_TDL(16));
regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_RDL_MASK,
I2S_DMACR_RDL(16)); return 0;
}
1.9.1
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
To make Bus DMA works more efficiency, DMA may work in burst mode, we set the watermark of transmit and receive reach to 16 bits.
Jianqun Xu (3): ASoC: rockchip: i2s: fix error defination of transmit data level ASoC: rockchip: i2s: set TDL and RDL to 16 samples ASoC: rockchip: i2s: fix maxburst of dma data to 4
sound/soc/rockchip/rockchip_i2s.c | 8 ++++++-- sound/soc/rockchip/rockchip_i2s.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-)
According to description about "Transmit Data Level",
This bit field controls the level at which a DMA request is made by the transmit logic.
It is equal to the watermark level.
That is, the dma_tx_req signal is generated when the number of valid data entries in the TXFIFO (TXFIFO0 if CSR=00 TXFIFO1 if CSR=01 TXFIFO2 if CSR=10 TXFIFO3 if CSR=11) is equal to or below this field value.
Different to receive data level, transmit data level does not need to "-1".
Signed-off-by: Jianqun Xu jay.xu@rock-chips.com --- changes since v1: - none
sound/soc/rockchip/rockchip_i2s.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/rockchip/rockchip_i2s.h b/sound/soc/rockchip/rockchip_i2s.h index 89a5d8b..93f456f 100644 --- a/sound/soc/rockchip/rockchip_i2s.h +++ b/sound/soc/rockchip/rockchip_i2s.h @@ -127,7 +127,7 @@ #define I2S_DMACR_TDE_DISABLE (0 << I2S_DMACR_TDE_SHIFT) #define I2S_DMACR_TDE_ENABLE (1 << I2S_DMACR_TDE_SHIFT) #define I2S_DMACR_TDL_SHIFT 0 -#define I2S_DMACR_TDL(x) ((x - 1) << I2S_DMACR_TDL_SHIFT) +#define I2S_DMACR_TDL(x) ((x) << I2S_DMACR_TDL_SHIFT) #define I2S_DMACR_TDL_MASK (0x1f << I2S_DMACR_TDL_SHIFT)
/*
Set Transmit Data Level(TDL) and Receive Data Level(RDL) to 16 samples. Without this setting, the TDL is default to be 0x00 (means 0 sample), and the RDL is default to be 0x1f (means 32 samples).
Signed-off-by: Jianqun Xu jay.xu@rock-chips.com --- changes since v1: - modify commit message "bit" to "sample", suggested by dgreid
sound/soc/rockchip/rockchip_i2s.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index c74ba37..1cd7efc 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -247,6 +247,10 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
regmap_update_bits(i2s->regmap, I2S_TXCR, I2S_TXCR_VDW_MASK, val); regmap_update_bits(i2s->regmap, I2S_RXCR, I2S_RXCR_VDW_MASK, val); + regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_TDL_MASK, + I2S_DMACR_TDL(16)); + regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_RDL_MASK, + I2S_DMACR_RDL(16));
return 0; }
Since RK3288 DMAC's burst length only support max to 4, here set maxburst of playback and capture dma data to 4.
Signed-off-by: Jianqun Xu jay.xu@rock-chips.com --- changes since v1: - new patch since v1
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 1cd7efc..59aeec4 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -458,11 +458,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 = 16; + i2s->playback_dma_data.maxburst = 4;
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 = 16; + i2s->capture_dma_data.maxburst = 4;
i2s->dev = &pdev->dev; dev_set_drvdata(&pdev->dev, i2s);
On Wed, Dec 24, 2014 at 05:36:59PM +0800, Jianqun Xu wrote:
To make Bus DMA works more efficiency, DMA may work in burst mode, we set the watermark of transmit and receive reach to 16 bits.
Applied all, thanks.
participants (4)
-
Dylan Reid
-
Jianqun
-
Jianqun Xu
-
Mark Brown