1 From 6f2a136f210d0e4178fbb5dc3fb5f765ef4c431d Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Thu, 29 Feb 2024 11:53:44 +0000
4 Subject: [PATCH 0931/1085] fixup! ASoC: dwc: Defer bclk_ratio handling to
7 See: https://github.com/raspberrypi/linux/issues/5743#issuecomment-1962740328
9 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
11 sound/soc/dwc/dwc-i2s.c | 51 ++++++++++++++++++++---------------------
12 1 file changed, 25 insertions(+), 26 deletions(-)
14 --- a/sound/soc/dwc/dwc-i2s.c
15 +++ b/sound/soc/dwc/dwc-i2s.c
16 @@ -287,21 +287,18 @@ static int dw_i2s_hw_params(struct snd_p
17 case SNDRV_PCM_FORMAT_S16_LE:
18 config->data_width = 16;
19 dma_data->dt.addr_width = 2;
21 dev->xfer_resolution = 0x02;
24 case SNDRV_PCM_FORMAT_S24_LE:
25 config->data_width = 24;
26 dma_data->dt.addr_width = 4;
28 dev->xfer_resolution = 0x04;
31 case SNDRV_PCM_FORMAT_S32_LE:
32 config->data_width = 32;
33 dma_data->dt.addr_width = 4;
35 dev->xfer_resolution = 0x05;
38 @@ -313,25 +310,6 @@ static int dw_i2s_hw_params(struct snd_p
40 config->data_width = 32;
42 - if ((dev->capability & DW_I2S_MASTER) && dev->bclk_ratio) {
43 - switch (dev->bclk_ratio) {
61 config->chan_nr = params_channels(params);
63 switch (config->chan_nr) {
64 @@ -347,11 +325,31 @@ static int dw_i2s_hw_params(struct snd_p
66 dw_i2s_config(dev, substream->stream);
68 - i2s_write_reg(dev->i2s_base, CCR, dev->ccr);
70 config->sample_rate = params_rate(params);
72 if (dev->capability & DW_I2S_MASTER) {
73 + u32 frame_length = config->data_width * 2;
75 + if (dev->bclk_ratio)
76 + frame_length = dev->bclk_ratio;
78 + switch (frame_length) {
95 if (dev->i2s_clk_cfg) {
96 ret = dev->i2s_clk_cfg(config);
98 @@ -359,8 +357,7 @@ static int dw_i2s_hw_params(struct snd_p
102 - u32 bitclk = config->sample_rate *
103 - config->data_width * 2;
104 + u32 bitclk = config->sample_rate * frame_length;
106 ret = clk_set_rate(dev->clk, bitclk);
108 @@ -369,6 +366,8 @@ static int dw_i2s_hw_params(struct snd_p
113 + i2s_write_reg(dev->i2s_base, CCR, dev->ccr);