Skip to contentSkip to conversation

ASoC: qcom: sdm845: Disable the quaternary MI2S bit clock on shutdown

PATCH In review yoxcu 2 participants 2 messages Oct 13 – Oct 16

Subsystems (4)
lore
Share & tools
lore

yoxcu

author
#0 lore raw

PATCH 1/1 ASoC: qcom: sdm845: Disable the quaternary MI2S bit clock on shutdown

From: Michael Auer <[email protected]>

sdm845_snd_startup() enables the quaternary MI2S bit clock in the ADSP, but sdm845_snd_shutdown() never disables it. After the first stream on this port the clock stays on.

On the OnePlus 6 the speaker amplifier is on this port. After the first playback the ADSP no longer power collapses: it slept under 9 s in 5 hours. With this change it sleeps again when audio is idle (about 40 s of 45 s).

Refcount the clock like the other MI2S and TDM ports and disable it when the last user is gone.

Fixes 5caf64c633a3 ("ASoC: qcom: sdm845: add support to DB845c and Lenovo Yoga")
Assisted-by LLM

---
Tested on a OnePlus 6 with an sdm845-mainline 7.1-rc1 based kernel:
the bit clock is set at stream start and set to 0 when the stream is closed, and the ADSP power collapses again. On sound/for-next it was only build tested (W=1). Not tested on the other boards that use QUAT MI2S (DB845c HDMI, Xiaomi beryllium and polaris).

 sound/soc/qcom/sdm845.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
sound/soc/qcom/sdm845.c +15 -4
index f0fbec9c8df2..85951397cb2b 100644
@@ -43,6 +43,7 @@ struct sdm845_snd_data {
 	bool stream_prepared[AFE_PORT_MAX];
 	uint32_t pri_mi2s_clk_count;
 	uint32_t sec_mi2s_clk_count;
+	uint32_t quat_mi2s_clk_count;
 	uint32_t quat_tdm_clk_count;
 };
 
@@ -372,9 +373,11 @@ static int sdm845_snd_startup(struct snd_pcm_substream *substream)
 		break;
 	case QUATERNARY_MI2S_RX:
 		codec_dai_fmt |= SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S;
-		snd_soc_dai_set_sysclk(cpu_dai,
-			Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
-			MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
+		if (++(data->quat_mi2s_clk_count) == 1) {
+			snd_soc_dai_set_sysclk(cpu_dai,
+				Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
+				MI2S_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK);
+		}
 		snd_soc_dai_set_fmt(cpu_dai, fmt);
 		snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt);
 		break;
@@ -483,8 +486,16 @@ static void  sdm845_snd_shutdown(struct snd_pcm_substream *substream)
 				0, SNDRV_PCM_STREAM_PLAYBACK);
 		}
 		break;
-	case SLIMBUS_0_RX...SLIMBUS_6_TX:
+
 	case QUATERNARY_MI2S_RX:
+		if (--(data->quat_mi2s_clk_count) == 0) {
+			snd_soc_dai_set_sysclk(cpu_dai,
+				Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT,
+				0, SNDRV_PCM_STREAM_PLAYBACK);
+		}
+		break;
+
+	case SLIMBUS_0_RX...SLIMBUS_6_TX:
 		break;
 
 	default:

base-commit: 631a161db2c5168dd836242571724baba3561a1f

Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 1 line · yoxcu

ASoC: qcom: sdm845: Disable the quaternary MI2S bit clock on shutdown

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4

Thanks!

[1/1] ASoC: qcom: sdm845: Disable the quaternary MI2S bit clock on shutdown

      https://git.kernel.org/broonie/sound/c/cef5d087d681

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark