Skip to content

Commit 04db5f6

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 f379e07 commit 04db5f6

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

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

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

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

0 commit comments

Comments
 (0)