Skip to contentSkip to conversation

ASoC: codec: rt5640: Resolve failure to set DMIC clock after playback

PATCH In review Jarrah Gosbell 2 participants 2 messages Jan 14, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: codec: rt5640: Resolve failure to set DMIC clock after playback

From: Ondrej Jirman <[email protected]>

rt5640_set_dai_sysclk is called with freq == 0 when playback stops. This causes DMIC setup code to fail. I2S interface doesn't need to be active for codec to work, so don't clear rt5640->sysclk after rt5640_set_dai_sysclk is called with freq == 0.

---
 sound/soc/codecs/rt5640.c | 3 +++
 1 file changed, 3 insertions(+)
sound/soc/codecs/rt5640.c +3 -0
index 18e01949f20e..054de41ceccb 100644
@@ -1839,6 +1839,9 @@ static int rt5640_set_dai_sysclk(struct snd_soc_dai *dai,
 	unsigned int reg_val = 0;
 	unsigned int pll_bit = 0;
 
+	if (freq == 0)
+		return 0;
+
 	switch (clk_id) {
 	case RT5640_SCLK_S_MCLK:
 		reg_val |= RT5640_SCLK_SRC_MCLK;
Signature · 1 line
2.39.0
maintainer
#1 lore raw
Quoted 4 lines · Jarrah Gosbell

rt5640_set_dai_sysclk is called with freq == 0 when playback stops. This causes DMIC setup code to fail. I2S interface doesn't need to be active for codec to work, so don't clear rt5640->sysclk after rt5640_set_dai_sysclk is called with freq == 0.

The goal with set_sysclk() is to record the current clock frequency, if the clock is stopped it should be set to zero. If a machine driver is setting the input clock to zero when it's still being provided then it should be fixed. If the device doesn't need a clock for DMIC (which seems dubious) then whatever is checking for a clock should be fixed.