Skip to content

Commit a6c4e1a

Browse files
Dharageswari Rplbossart
authored andcommitted
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 suggests 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. Signed-off-by: Dharageswari R <dharageswari.r@intel.com>
1 parent e979200 commit a6c4e1a

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

sound/soc/intel/boards/sof_maxim_common.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <uapi/sound/asound.h>
1010
#include "sof_maxim_common.h"
1111

12+
#define MAX_98373_PIN_NAME 16
13+
1214
static const struct snd_soc_dapm_route max_98373_dapm_routes[] = {
1315
/* speaker */
1416
{ "Left Spk", NULL, "Left BE_OUT" },
@@ -57,8 +59,51 @@ static int max98373_hw_params(struct snd_pcm_substream *substream,
5759
return 0;
5860
}
5961

62+
static int max98373_trigger(struct snd_pcm_substream *substream, int cmd)
63+
{
64+
struct snd_soc_pcm_runtime *rtd = substream->private_data;
65+
struct snd_soc_dai *codec_dai;
66+
int j;
67+
int ret = 0;
68+
69+
for_each_rtd_codec_dais(rtd, j, codec_dai) {
70+
struct snd_soc_component *component = codec_dai->component;
71+
struct snd_soc_dapm_context *dapm =
72+
snd_soc_component_get_dapm(component);
73+
char pin_name[MAX_98373_PIN_NAME];
74+
75+
snprintf(pin_name, ARRAY_SIZE(pin_name), "%s Spk",
76+
codec_dai->component->name_prefix);
77+
78+
switch (cmd) {
79+
case SNDRV_PCM_TRIGGER_START:
80+
case SNDRV_PCM_TRIGGER_RESUME:
81+
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
82+
ret = snd_soc_dapm_enable_pin(dapm, pin_name);
83+
if (!ret)
84+
snd_soc_dapm_sync(dapm);
85+
break;
86+
case SNDRV_PCM_TRIGGER_STOP:
87+
case SNDRV_PCM_TRIGGER_SUSPEND:
88+
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
89+
/* Make sure no streams are active before disable pin */
90+
if (snd_soc_dai_active(codec_dai) != 1)
91+
break;
92+
ret = snd_soc_dapm_disable_pin(dapm, pin_name);
93+
if (!ret)
94+
snd_soc_dapm_sync(dapm);
95+
break;
96+
default:
97+
break;
98+
}
99+
}
100+
101+
return ret;
102+
}
103+
60104
struct snd_soc_ops max_98373_ops = {
61105
.hw_params = max98373_hw_params,
106+
.trigger = max98373_trigger,
62107
};
63108

64109
int max98373_spk_codec_init(struct snd_soc_pcm_runtime *rtd)

sound/soc/intel/boards/sof_rt5682.c

Lines changed: 9 additions & 0 deletions
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,6 +350,14 @@ static int sof_card_late_probe(struct snd_soc_card *card)
349350
i++;
350351
}
351352

353+
if (sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) {
354+
/* Disable Left and Right Spk pin after boot */
355+
snd_soc_dapm_disable_pin(dapm, "Left Spk");
356+
snd_soc_dapm_disable_pin(dapm, "Right Spk");
357+
err = snd_soc_dapm_sync(dapm);
358+
if (err < 0)
359+
return err;
360+
}
352361
return hdac_hdmi_jack_port_init(component, &card->dapm);
353362
}
354363

0 commit comments

Comments
 (0)