Skip to content

Commit fbccb2b

Browse files
author
Dharageswari R
committed
ASoC: Intel: Boards: tgl_max98373: add dai_trigger function
Speaker amplifier feedback is not modeled as being dependent on any active output. Even when there is no playback happening, parts of the graph, specifically the IV sense->speaker protection->output remains active and this prevents the DSP from entering low-power states. This patch suggest a machine driver level approach where the speaker pins are enabled/disabled dynamically depending on stream start/stop events. DPAM graph representations show the feedback loop is indeed disabled and low-power states can be reached. Change-Id: I3c34487ec18fc20efe0da678402946b93313d391 Signed-off-by: Dharageswari R <dharageswari.r@inetl.com>
1 parent 1697493 commit fbccb2b

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

sound/soc/intel/boards/sof_maxim_common.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,60 @@ static int max98373_hw_params(struct snd_pcm_substream *substream,
5757
return 0;
5858
}
5959

60+
static int max98373_trigger(struct snd_pcm_substream *substream, int cmd)
61+
{
62+
struct snd_soc_pcm_runtime *rtd = substream->private_data;
63+
struct snd_soc_dai *codec_dai;
64+
int j, ret;
65+
66+
for_each_rtd_codec_dais(rtd, j, codec_dai) {
67+
const char *name = codec_dai->component->name;
68+
struct snd_soc_component *component = codec_dai->component;
69+
struct snd_soc_dapm_context *dapm =
70+
snd_soc_component_get_dapm(component);
71+
char pin_name[20];
72+
73+
if (strcmp(name, MAX_98373_DEV0_NAME) &&
74+
strcmp(name, MAX_98373_DEV1_NAME))
75+
continue;
76+
77+
snprintf(pin_name, ARRAY_SIZE(pin_name), "%s Spk",
78+
codec_dai->component->name_prefix);
79+
80+
switch (cmd) {
81+
case SNDRV_PCM_TRIGGER_START:
82+
case SNDRV_PCM_TRIGGER_RESUME:
83+
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
84+
ret = snd_soc_dapm_enable_pin(dapm, pin_name);
85+
if (ret) {
86+
dev_err(rtd->dev, "failed to enable %s: %d\n",
87+
pin_name, ret);
88+
return ret;
89+
}
90+
snd_soc_dapm_sync(dapm);
91+
break;
92+
case SNDRV_PCM_TRIGGER_STOP:
93+
case SNDRV_PCM_TRIGGER_SUSPEND:
94+
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
95+
if (codec_dai->active != 1)
96+
break;
97+
ret = snd_soc_dapm_disable_pin(dapm, pin_name);
98+
if (ret) {
99+
dev_err(rtd->dev, "failed to disable %s: %d\n",
100+
pin_name, ret);
101+
return ret;
102+
}
103+
snd_soc_dapm_sync(dapm);
104+
break;
105+
}
106+
}
107+
108+
return 0;
109+
}
110+
60111
struct snd_soc_ops max_98373_ops = {
61112
.hw_params = max98373_hw_params,
113+
.trigger = max98373_trigger,
62114
};
63115

64116
int max98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd)

sound/soc/intel/boards/sof_rt5682.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ static int sof_card_late_probe(struct snd_soc_card *card)
311311
{
312312
struct sof_card_private *ctx = snd_soc_card_get_drvdata(card);
313313
struct snd_soc_component *component = NULL;
314+
struct snd_soc_dapm_context *dapm = &card->dapm;
314315
char jack_name[NAME_SIZE];
315316
struct sof_hdmi_pcm *pcm;
316317
int err;
@@ -349,7 +350,17 @@ static int sof_card_late_probe(struct snd_soc_card *card)
349350
i++;
350351
}
351352

352-
return hdac_hdmi_jack_port_init(component, &card->dapm);
353+
354+
err = hdac_hdmi_jack_port_init(component, &card->dapm);
355+
if (err < 0)
356+
return err;
357+
358+
if (sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) {
359+
snd_soc_dapm_disable_pin(dapm, "Left Spk");
360+
snd_soc_dapm_disable_pin(dapm, "Right Spk");
361+
return snd_soc_dapm_sync(dapm);
362+
}
363+
return ret;
353364
}
354365

355366
static const struct snd_kcontrol_new sof_controls[] = {

0 commit comments

Comments
 (0)