1 From cbc65d9c95088d1437a5a84c7d6628b8d27a86f1 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Tue, 28 Nov 2023 12:14:03 +0000
4 Subject: [PATCH] ASoC: dwc: Fix full-duplex mode
6 Configuration of the DMA register was carelessly zeroing bits that may
7 used by a stream in the other direction. Preserve them instead.
9 See: https://github.com/raspberrypi/linux/issues/5741
11 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
13 sound/soc/dwc/dwc-i2s.c | 20 +++++++++++++-------
14 1 file changed, 13 insertions(+), 7 deletions(-)
16 --- a/sound/soc/dwc/dwc-i2s.c
17 +++ b/sound/soc/dwc/dwc-i2s.c
18 @@ -189,10 +189,17 @@ static void dw_i2s_config(struct dw_i2s_
20 struct i2s_clk_config_data *config = &dev->config;
25 i2s_disable_channels(dev, stream);
27 + dmacr = i2s_read_reg(dev->i2s_base, DMACR);
29 + if (stream == SNDRV_PCM_STREAM_PLAYBACK)
30 + dmacr &= ~(DMACR_DMAEN_TXCH0 * 0xf);
32 + dmacr &= ~(DMACR_DMAEN_RXCH0 * 0xf);
34 for (ch_reg = 0; ch_reg < (config->chan_nr / 2); ch_reg++) {
35 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
36 i2s_write_reg(dev->i2s_base, TCR(ch_reg),
37 @@ -210,10 +217,6 @@ static void dw_i2s_config(struct dw_i2s_
38 dmacr |= (DMACR_DMAEN_RXCH0 << ch_reg);
41 - if (stream == SNDRV_PCM_STREAM_PLAYBACK)
42 - dmacr |= DMACR_DMAEN_TX;
43 - else if (stream == SNDRV_PCM_STREAM_CAPTURE)
44 - dmacr |= DMACR_DMAEN_RX;
46 i2s_write_reg(dev->i2s_base, DMACR, dmacr);
48 @@ -319,10 +322,13 @@ static int dw_i2s_startup(struct snd_pcm
50 dw_i2s_config(dev, substream->stream);
51 dmacr = i2s_read_reg(dev->i2s_base, DMACR);
52 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
53 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
54 dma_data = &dev->play_dma_data;
55 - else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
56 + dmacr |= DMACR_DMAEN_TX;
57 + } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
58 dma_data = &dev->capture_dma_data;
59 + dmacr |= DMACR_DMAEN_RX;
62 snd_soc_dai_set_dma_data(cpu_dai, substream, (void *)dma_data);
63 i2s_write_reg(dev->i2s_base, DMACR, dmacr);