Skip to content

Commit b3f6e7f

Browse files
marcanjannau
authored andcommitted
ASoC: tas2764: Power up/down amp on mute ops
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>
1 parent cc69347 commit b3f6e7f

1 file changed

Lines changed: 21 additions & 30 deletions

File tree

sound/soc/codecs/tas2764.c

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -198,33 +198,6 @@ static SOC_ENUM_SINGLE_DECL(
198198
static const struct snd_kcontrol_new tas2764_asi1_mux =
199199
SOC_DAPM_ENUM("ASI1 Source", tas2764_ASI1_src_enum);
200200

201-
static int tas2764_dac_event(struct snd_soc_dapm_widget *w,
202-
struct snd_kcontrol *kcontrol, int event)
203-
{
204-
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
205-
struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component);
206-
int ret;
207-
208-
switch (event) {
209-
case SND_SOC_DAPM_POST_PMU:
210-
tas2764->dac_powered = true;
211-
ret = tas2764_update_pwr_ctrl(tas2764);
212-
break;
213-
case SND_SOC_DAPM_PRE_PMD:
214-
tas2764->dac_powered = false;
215-
ret = tas2764_update_pwr_ctrl(tas2764);
216-
break;
217-
default:
218-
dev_err(tas2764->dev, "Unsupported event\n");
219-
return -EINVAL;
220-
}
221-
222-
if (ret < 0)
223-
return ret;
224-
225-
return 0;
226-
}
227-
228201
static const struct snd_kcontrol_new isense_switch =
229202
SOC_DAPM_SINGLE("Switch", TAS2764_PWR_CTRL, TAS2764_ISENSE_POWER_EN, 1, 1);
230203
static const struct snd_kcontrol_new vsense_switch =
@@ -237,8 +210,7 @@ static const struct snd_soc_dapm_widget tas2764_dapm_widgets[] = {
237210
1, &isense_switch),
238211
SND_SOC_DAPM_SWITCH("VSENSE", TAS2764_PWR_CTRL, TAS2764_VSENSE_POWER_EN,
239212
1, &vsense_switch),
240-
SND_SOC_DAPM_DAC_E("DAC", NULL, SND_SOC_NOPM, 0, 0, tas2764_dac_event,
241-
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
213+
SND_SOC_DAPM_DAC("DAC", NULL, SND_SOC_NOPM, 0, 0),
242214
SND_SOC_DAPM_OUTPUT("OUT"),
243215
SND_SOC_DAPM_SIGGEN("VMON"),
244216
SND_SOC_DAPM_SIGGEN("IMON")
@@ -259,9 +231,28 @@ static int tas2764_mute(struct snd_soc_dai *dai, int mute, int direction)
259231
{
260232
struct tas2764_priv *tas2764 =
261233
snd_soc_component_get_drvdata(dai->component);
234+
int ret;
235+
236+
if (!mute) {
237+
tas2764->dac_powered = true;
238+
ret = tas2764_update_pwr_ctrl(tas2764);
239+
if (ret)
240+
return ret;
241+
}
262242

263243
tas2764->unmuted = !mute;
264-
return tas2764_update_pwr_ctrl(tas2764);
244+
ret = tas2764_update_pwr_ctrl(tas2764);
245+
if (ret)
246+
return ret;
247+
248+
if (mute) {
249+
tas2764->dac_powered = false;
250+
ret = tas2764_update_pwr_ctrl(tas2764);
251+
if (ret)
252+
return ret;
253+
}
254+
255+
return 0;
265256
}
266257

267258
static int tas2764_set_bitwidth(struct tas2764_priv *tas2764, int bitwidth)

0 commit comments

Comments
 (0)