]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: tas2764: Power up/down amp on mute ops
authorHector Martin <marcan@marcan.st>
Sat, 8 Feb 2025 01:03:24 +0000 (01:03 +0000)
committerMark Brown <broonie@kernel.org>
Sun, 16 Feb 2025 23:51:26 +0000 (23:51 +0000)
The ASoC convention is that clocks are removed after codec mute, and
power up/down is more about top level power management. For these chips,
the "mute" state still expects a TDM clock, and yanking the clock in
this state will trigger clock errors. So, do the full
shutdown<->mute<->active transition on the mute operation, so the amp is
in software shutdown by the time the clocks are removed.

This fixes TDM clock errors when streams are stopped.

Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://patch.msgid.link/20250208-asoc-tas2764-v1-1-dbab892a69b5@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/tas2764.c

index d482cd194c08c5c443b82c665de7a6d96531ef2e..60d660a88fab19a700a7fd1ca524cfaf0fb52165 100644 (file)
@@ -180,33 +180,6 @@ static SOC_ENUM_SINGLE_DECL(
 static const struct snd_kcontrol_new tas2764_asi1_mux =
        SOC_DAPM_ENUM("ASI1 Source", tas2764_ASI1_src_enum);
 
-static int tas2764_dac_event(struct snd_soc_dapm_widget *w,
-                            struct snd_kcontrol *kcontrol, int event)
-{
-       struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
-       struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
-       int ret;
-
-       switch (event) {
-       case SND_SOC_DAPM_POST_PMU:
-               tas2764->dac_powered = true;
-               ret = tas2764_update_pwr_ctrl(tas2764);
-               break;
-       case SND_SOC_DAPM_PRE_PMD:
-               tas2764->dac_powered = false;
-               ret = tas2764_update_pwr_ctrl(tas2764);
-               break;
-       default:
-               dev_err(tas2764->dev, "Unsupported event\n");
-               return -EINVAL;
-       }
-
-       if (ret < 0)
-               return ret;
-
-       return 0;
-}
-
 static const struct snd_kcontrol_new isense_switch =
        SOC_DAPM_SINGLE("Switch", TAS2764_PWR_CTRL, TAS2764_ISENSE_POWER_EN, 1, 1);
 static const struct snd_kcontrol_new vsense_switch =
@@ -219,8 +192,7 @@ static const struct snd_soc_dapm_widget tas2764_dapm_widgets[] = {
                            1, &isense_switch),
        SND_SOC_DAPM_SWITCH("VSENSE", TAS2764_PWR_CTRL, TAS2764_VSENSE_POWER_EN,
                            1, &vsense_switch),
-       SND_SOC_DAPM_DAC_E("DAC", NULL, SND_SOC_NOPM, 0, 0, tas2764_dac_event,
-                          SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
+       SND_SOC_DAPM_DAC("DAC", NULL, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_OUTPUT("OUT"),
        SND_SOC_DAPM_SIGGEN("VMON"),
        SND_SOC_DAPM_SIGGEN("IMON")
@@ -241,9 +213,28 @@ static int tas2764_mute(struct snd_soc_dai *dai, int mute, int direction)
 {
        struct tas2764_priv *tas2764 =
                        snd_soc_component_get_drvdata(dai->component);
+       int ret;
+
+       if (!mute) {
+               tas2764->dac_powered = true;
+               ret = tas2764_update_pwr_ctrl(tas2764);
+               if (ret)
+                       return ret;
+       }
 
        tas2764->unmuted = !mute;
-       return tas2764_update_pwr_ctrl(tas2764);
+       ret = tas2764_update_pwr_ctrl(tas2764);
+       if (ret)
+               return ret;
+
+       if (mute) {
+               tas2764->dac_powered = false;
+               ret = tas2764_update_pwr_ctrl(tas2764);
+               if (ret)
+                       return ret;
+       }
+
+       return 0;
 }
 
 static int tas2764_set_bitwidth(struct tas2764_priv *tas2764, int bitwidth)