From: Phil Elwell Date: Wed, 3 Jan 2024 14:43:43 +0000 (+0000) Subject: ASoC: dwc: Defer bclk_ratio handling to hw_params X-Git-Tag: accepted/tizen/unified/20240422.153132~171 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd3ab4d68398c858275c7273baa5bf5e0e6137c7;p=platform%2Fkernel%2Flinux-rpi.git ASoC: dwc: Defer bclk_ratio handling to hw_params bclk_ratio is only a factor in clock producer mode, and needs to override the default value of num_channels * sample_size. Move the bclk_ratio handling into the hw_params method, only latching the value in set_bclk_ratio, to address both of those matters. See: https://github.com/raspberrypi/linux/issues/5817 Signed-off-by: Phil Elwell --- diff --git a/sound/soc/dwc/dwc-i2s.c b/sound/soc/dwc/dwc-i2s.c index 11cd83b..fcb1ccc 100644 --- a/sound/soc/dwc/dwc-i2s.c +++ b/sound/soc/dwc/dwc-i2s.c @@ -314,6 +314,25 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream, if (dev->tdm_slots) config->data_width = 32; + if ((dev->capability & DW_I2S_MASTER) && dev->bclk_ratio) { + switch (dev->bclk_ratio) { + case 32: + dev->ccr = 0x00; + break; + + case 48: + dev->ccr = 0x08; + break; + + case 64: + dev->ccr = 0x10; + break; + + default: + return -EINVAL; + } + } + config->chan_nr = params_channels(params); switch (config->chan_nr) { @@ -537,23 +556,7 @@ static int dw_i2s_set_bclk_ratio(struct snd_soc_dai *cpu_dai, dev_dbg(dev->dev, "%s(%d)\n", __func__, ratio); - switch (ratio) { - case 32: - dev->ccr = 0x00; - break; - - case 48: - dev->ccr = 0x08; - break; - - case 64: - dev->ccr = 0x10; - break; - default: - return -EINVAL; - } - - i2s_write_reg(dev->i2s_base, CCR, dev->ccr); + dev->bclk_ratio = ratio; return 0; } @@ -1068,6 +1071,7 @@ static int dw_i2s_probe(struct platform_device *pdev) } } + dev->bclk_ratio = 0; dev->i2s_reg_comp1 = I2S_COMP_PARAM_1; dev->i2s_reg_comp2 = I2S_COMP_PARAM_2; if (pdata) { diff --git a/sound/soc/dwc/local.h b/sound/soc/dwc/local.h index 6b08979..9f21eb6 100644 --- a/sound/soc/dwc/local.h +++ b/sound/soc/dwc/local.h @@ -128,6 +128,7 @@ struct dw_i2s_dev { unsigned int quirks; unsigned int i2s_reg_comp1; unsigned int i2s_reg_comp2; + unsigned int bclk_ratio; struct device *dev; u32 ccr; u32 xfer_resolution;