From 15ec253f3c19688187cae16e58cffba38826a32c Mon Sep 17 00:00:00 2001 From: Sugar Zhang Date: Fri, 29 Mar 2024 21:46:15 +0800 Subject: [PATCH] ASoC: rockchip: i2s-tdm: Init Valid Width for TDM from DT e.g. simple-audio-card,cpu { sound-dai = <&i2s0_8ch>; dai-tdm-slot-num = <8>; dai-tdm-slot-width = <32>; }; Signed-off-by: Sugar Zhang Change-Id: I55c3849d87e17145db6b4ce4af202303b5563080 --- sound/soc/rockchip/rockchip_i2s_tdm.c | 33 +++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/sound/soc/rockchip/rockchip_i2s_tdm.c b/sound/soc/rockchip/rockchip_i2s_tdm.c index aed50dd9751a..3ee692c9853c 100644 --- a/sound/soc/rockchip/rockchip_i2s_tdm.c +++ b/sound/soc/rockchip/rockchip_i2s_tdm.c @@ -2229,10 +2229,35 @@ static int rockchip_dai_tdm_slot(struct snd_soc_dai *dai, if (ret < 0 && ret != -EACCES) return ret; - regmap_update_bits(i2s_tdm->regmap, I2S_TDM_TXCR, - mask, val); - regmap_update_bits(i2s_tdm->regmap, I2S_TDM_RXCR, - mask, val); + regmap_update_bits(i2s_tdm->regmap, I2S_TDM_TXCR, mask, val); + regmap_update_bits(i2s_tdm->regmap, I2S_TDM_RXCR, mask, val); + + mask = I2S_TXCR_VDW_MASK | I2S_TXCR_CSR_MASK; + val = I2S_TXCR_VDW(slot_width); + + if (!i2s_tdm->tdm_fsync_half_frame) { + switch (slots) { + case 16: + val |= I2S_CHN_8; + break; + case 12: + val |= I2S_CHN_6; + break; + case 8: + val |= I2S_CHN_4; + break; + case 4: + val |= I2S_CHN_2; + break; + default: + val |= I2S_CHN_2; + break; + } + } + + regmap_update_bits(i2s_tdm->regmap, I2S_TXCR, mask, val); + regmap_update_bits(i2s_tdm->regmap, I2S_RXCR, mask, val); + pm_runtime_put(dai->dev); return 0;