Skip to content

Commit ccd8d75

Browse files
a1batrossbroonie
authored andcommitted
ASoC: rockchip: i2s-tdm: Fix trcm mode by setting clock on right mclk
When TRCM mode is enabled, I2S RX and TX clocks are synchronized through selected clock source. Without this fix BCLK and LRCK might get parented to an uninitialized MCLK and the DAI will receive data at wrong pace. However, unlike in original i2s-tdm driver, there is no need to manually synchronize mclk_rx and mclk_tx, as only one gets used anyway. Tested on a board with RK3568 SoC and Silergy SY24145S codec with enabled and disabled TRCM mode. Fixes: 9e2ab4b ("ASoC: rockchip: i2s-tdm: Fix inaccurate sampling rates") Signed-off-by: Alibek Omarov <[email protected]> Reviewed-by: Luca Ceresoli <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 4d46b69 commit ccd8d75

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sound/soc/rockchip/rockchip_i2s_tdm.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,17 @@ static int rockchip_i2s_tdm_hw_params(struct snd_pcm_substream *substream,
655655
int err;
656656

657657
if (i2s_tdm->is_master_mode) {
658-
struct clk *mclk = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
659-
i2s_tdm->mclk_tx : i2s_tdm->mclk_rx;
658+
struct clk *mclk;
659+
660+
if (i2s_tdm->clk_trcm == TRCM_TX) {
661+
mclk = i2s_tdm->mclk_tx;
662+
} else if (i2s_tdm->clk_trcm == TRCM_RX) {
663+
mclk = i2s_tdm->mclk_rx;
664+
} else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
665+
mclk = i2s_tdm->mclk_tx;
666+
} else {
667+
mclk = i2s_tdm->mclk_rx;
668+
}
660669

661670
err = clk_set_rate(mclk, DEFAULT_MCLK_FS * params_rate(params));
662671
if (err)

0 commit comments

Comments
 (0)