Skip to content

Commit 805b53c

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 08cf729 commit 805b53c

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
@@ -199,33 +199,6 @@ static SOC_ENUM_SINGLE_DECL(
199199
static const struct snd_kcontrol_new tas2764_asi1_mux =
200200
SOC_DAPM_ENUM("ASI1 Source", tas2764_ASI1_src_enum);
201201

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

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

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

0 commit comments

Comments
 (0)