Skip to content

Commit

Permalink
ASoC: rockchip: i2s-tdm: Fix trcm mode by setting clock on right mclk
Browse files Browse the repository at this point in the history
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 <a1ba.omarov@gmail.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Link: https://msgid.link/r/20240604184752.697313-1-a1ba.omarov@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
a1batross authored and broonie committed Jun 5, 2024
1 parent 4d46b69 commit ccd8d75
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sound/soc/rockchip/rockchip_i2s_tdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,17 @@ static int rockchip_i2s_tdm_hw_params(struct snd_pcm_substream *substream,
int err;

if (i2s_tdm->is_master_mode) {
struct clk *mclk = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
i2s_tdm->mclk_tx : i2s_tdm->mclk_rx;
struct clk *mclk;

if (i2s_tdm->clk_trcm == TRCM_TX) {
mclk = i2s_tdm->mclk_tx;
} else if (i2s_tdm->clk_trcm == TRCM_RX) {
mclk = i2s_tdm->mclk_rx;
} else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
mclk = i2s_tdm->mclk_tx;
} else {
mclk = i2s_tdm->mclk_rx;
}

err = clk_set_rate(mclk, DEFAULT_MCLK_FS * params_rate(params));
if (err)
Expand Down

0 comments on commit ccd8d75

Please sign in to comment.