Skip to contentSkip to conversation

ASoc: tas2781: fixed the issue that the chip do not shutdown immediatly after aplay stopped

PATCH In review Shenghao Ding 2 participants 4 messages Aug 19, 2024 – Aug 20, 2024

Subsystems (3)
lore
Share & tools
lore

Shenghao Ding

author maintainer
#0 lore raw

PATCH 1/1 ASoc: tas2781: fixed the issue that the chip do not shutdown immediatly after aplay stopped

Issue reported from customer that the chip do not shutdown after aplay stopped until 6 mins later. Drop tasdevice_dapm_event and implement .stream_mute in the tasdevice_dai_ops.

---
v1:
- Drop tasdevice_dapm_event and implement .stream_mute in the tasdevice_dai_ops
- Remove unnecessary line feed for tasdevice_codec_remove

---
 sound/soc/codecs/tas2781-i2c.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)
sound/soc/codecs/tas2781-i2c.c +8 -15
index 9a32e0504857..145c45349399 100644
@@ -557,30 +557,22 @@ static void tasdevice_fw_ready(const struct firmware *fmw,
 		release_firmware(fmw);
 }
 
-static int tasdevice_dapm_event(struct snd_soc_dapm_widget *w,
-			struct snd_kcontrol *kcontrol, int event)
+static int tasdevice_mute(struct snd_soc_dai *dai, int mute, int stream)
 {
-	struct snd_soc_component *codec = snd_soc_dapm_to_component(w->dapm);
+	struct snd_soc_component *codec = dai->component;
 	struct tasdevice_priv *tas_priv = snd_soc_component_get_drvdata(codec);
-	int state = 0;
 
-	/* Codec Lock Hold */
-	mutex_lock(&tas_priv->codec_lock);
-	if (event == SND_SOC_DAPM_PRE_PMD)
-		state = 1;
-	tasdevice_tuning_switch(tas_priv, state);
-	/* Codec Lock Release*/
-	mutex_unlock(&tas_priv->codec_lock);
+	/* Codec Lock/UnLock */
+	guard(mutex)(&tas_priv->codec_lock);
+	tasdevice_tuning_switch(tas_priv, mute);
 
 	return 0;
 }
 
 static const struct snd_soc_dapm_widget tasdevice_dapm_widgets[] = {
 	SND_SOC_DAPM_AIF_IN("ASI", "ASI Playback", 0, SND_SOC_NOPM, 0, 0),
-	SND_SOC_DAPM_AIF_OUT_E("ASI OUT", "ASI Capture", 0, SND_SOC_NOPM,
-		0, 0, tasdevice_dapm_event,
-		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
-	SND_SOC_DAPM_SPK("SPK", tasdevice_dapm_event),
+	SND_SOC_DAPM_AIF_OUT("ASI OUT", "ASI Capture", 0, SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_SPK("SPK", NULL),
 	SND_SOC_DAPM_OUTPUT("OUT"),
 	SND_SOC_DAPM_INPUT("DMIC")
 };
@@ -667,6 +659,7 @@ static const struct snd_soc_dai_ops tasdevice_dai_ops = {
 	.startup = tasdevice_startup,
 	.hw_params = tasdevice_hw_params,
 	.set_sysclk = tasdevice_set_dai_sysclk,
+	.mute_stream = tasdevice_mute,
 };
 
 static struct snd_soc_dai_driver tasdevice_dai_driver[] = {
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 3 lines · Shenghao Ding

Issue reported from customer that the chip do not shutdown after aplay stopped until 6 mins later. Drop tasdevice_dapm_event and implement .stream_mute in the tasdevice_dai_ops.

Six minutes sounds like a usersrpace issue with userspace sitting playing silence for a long time rather than a driver issue. By default DAPM does defer powerdown, but only by seconds not minutes.

sound/soc/codecs/tas2781-i2c.c static void tasdevice_fw_ready(const struct firmware *fmw, · line 567

Quoted 5 lines
sound/soc/codecs/tas2781-i2c.c +3 -2
-	/* Codec Lock Release*/
-	mutex_unlock(&tas_priv->codec_lock);
+	/* Codec Lock/UnLock */
+	guard(mutex)(&tas_priv->codec_lock);
+	tasdevice_tuning_switch(tas_priv, mute);

This is a much heavier weight operation than we're expecting for a mute, it should usually just be literally muting - one or two register writes, not a power up/down sequence

author maintainer
#2 lore raw

Hi Broonie

Quoted 29 lines

-----Original Message-----
From: Mark Brown <[email protected]>
Sent: Tuesday, August 20, 2024 12:07 AM
To: Ding, Shenghao <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Salazar, Ivan <[email protected]>; [email protected]; Yue, Jaden <[email protected]>; [email protected]; Rao, Dipa <[email protected]>; [email protected]; Lo, Henry <[email protected]>; [email protected]; Xu, Baojun <[email protected]>; [email protected]; Chadha, Jasjot Singh <[email protected]>; [email protected]; Navada Kanyana, Mukund <[email protected]>; [email protected]; Kutty, Aanya <[email protected]>; Mahmud, Nayeem <[email protected]>; [email protected]; [email protected]; Ji, Jesse <jesse- [email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [EXTERNAL] Re: [PATCH v1] ASoc: tas2781: fixed the issue that the chip do not shutdown immediatly after aplay stopped

Quoted 3 lines · Shenghao Ding

Issue reported from customer that the chip do not shutdown after aplay stopped until 6 mins later. Drop tasdevice_dapm_event and implement .stream_mute in the tasdevice_dai_ops.

Six minutes sounds like a usersrpace issue with userspace sitting playing silence for a long time rather than a driver issue. By default DAPM does defer powerdown, but only by seconds not minutes.

Quoted 9 lines

sound/soc/codecs/tas2781-i2c.c static void tasdevice_fw_ready(const struct firmware *fmw, · line 567

Quoted 5 lines
sound/soc/codecs/tas2781-i2c.c +3 -2
-	/* Codec Lock Release*/
-	mutex_unlock(&tas_priv->codec_lock);
+	/* Codec Lock/UnLock */
+	guard(mutex)(&tas_priv->codec_lock);
+	tasdevice_tuning_switch(tas_priv, mute);

This is a much heavier weight operation than we're expecting for a mute, it should usually just be literally muting - one or two register writes, not a power up/down sequence

Can the power on is still kept in DAMP, and move the power off(Only set the register 0x2 to 0xe) into the .mute_stream?

maintainer
#3 lore raw
Quoted 6 lines · Shenghao
Quoted 3 lines

This is a much heavier weight operation than we're expecting for a mute, it should usually just be literally muting - one or two register writes, not a power up/down sequence

Can the power on is still kept in DAMP, and move the power off(Only set the register 0x2 to 0xe) into the .mute_stream?

Wouldn't that break when a second stream is played, unless whatever is holding the output open is fixed DAPM will still have the device active and therefore not redo the power up sequence?