Skip to content

Commit 4884057

Browse files
marcanjannau
authored andcommitted
ASoC: tas2770: Power cycle amp on ISENSE/VSENSE change
The ISENSE/VSENSE blocks are only powered up when the amplifier transitions from shutdown to active. This means that if those controls are flipped on while the amplifier is already playing back audio, they will have no effect. Fix this by forcing a power cycle around transitions in those controls. Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent ce20c1a commit 4884057

1 file changed

Lines changed: 32 additions & 2 deletions

File tree

sound/soc/codecs/tas2770.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,41 @@ static const struct snd_kcontrol_new isense_switch =
163163
static const struct snd_kcontrol_new vsense_switch =
164164
SOC_DAPM_SINGLE("Switch", TAS2770_PWR_CTRL, 2, 1, 1);
165165

166+
static int sense_event(struct snd_soc_dapm_widget *w,
167+
struct snd_kcontrol *kcontrol, int event)
168+
{
169+
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
170+
struct tas2770_priv *tas2770 = snd_soc_component_get_drvdata(component);
171+
int ret = 0;
172+
173+
/*
174+
* Powering up ISENSE/VSENSE requires a trip through the shutdown state.
175+
* Do that here to ensure that our changes are applied properly, otherwise
176+
* we might end up with non-functional IVSENSE if playback started earlier,
177+
* which would break software speaker protection.
178+
*/
179+
180+
switch (event) {
181+
case SND_SOC_DAPM_PRE_REG:
182+
ret = snd_soc_component_update_bits(component, TAS2770_PWR_CTRL,
183+
TAS2770_PWR_CTRL_MASK,
184+
TAS2770_PWR_CTRL_SHUTDOWN);
185+
break;
186+
case SND_SOC_DAPM_POST_REG:
187+
ret = tas2770_update_pwr_ctrl(tas2770);
188+
break;
189+
}
190+
191+
return ret;
192+
}
193+
166194
static const struct snd_soc_dapm_widget tas2770_dapm_widgets[] = {
167195
SND_SOC_DAPM_AIF_IN("ASI1", "ASI1 Playback", 0, SND_SOC_NOPM, 0, 0),
168196
SND_SOC_DAPM_MUX("ASI1 Sel", SND_SOC_NOPM, 0, 0, &tas2770_asi1_mux),
169-
SND_SOC_DAPM_SWITCH("ISENSE", TAS2770_PWR_CTRL, 3, 1, &isense_switch),
170-
SND_SOC_DAPM_SWITCH("VSENSE", TAS2770_PWR_CTRL, 2, 1, &vsense_switch),
197+
SND_SOC_DAPM_SWITCH_E("ISENSE", TAS2770_PWR_CTRL, 3, 1, &isense_switch,
198+
sense_event, SND_SOC_DAPM_PRE_REG | SND_SOC_DAPM_POST_REG),
199+
SND_SOC_DAPM_SWITCH_E("VSENSE", TAS2770_PWR_CTRL, 2, 1, &vsense_switch,
200+
sense_event, SND_SOC_DAPM_PRE_REG | SND_SOC_DAPM_POST_REG),
171201
SND_SOC_DAPM_DAC_E("DAC", NULL, SND_SOC_NOPM, 0, 0, tas2770_dac_event,
172202
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
173203
SND_SOC_DAPM_OUTPUT("OUT"),

0 commit comments

Comments
 (0)