Skip to content

Commit c4698f4

Browse files
marcanjannau
authored andcommitted
macaudio: Skip speaker sense PCM if no sense or no speakers
This PCM triggers speakersafetyd, so hide it if it can't work. Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 55b5dcd commit c4698f4

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

sound/soc/apple/macaudio.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ struct macaudio_snd_data {
105105

106106
const struct macaudio_platform_cfg *cfg;
107107
bool has_speakers;
108+
bool has_sense;
108109
bool has_safety;
109110
unsigned int max_channels;
110111

@@ -569,6 +570,8 @@ static int macaudio_parse_of(struct macaudio_snd_data *ma)
569570
continue;
570571
}
571572
ma->has_speakers = 1;
573+
if (ma->cfg->amp != AMP_SSM3515 && ma->cfg->safe_vol != 0)
574+
ma->has_sense = 1;
572575
}
573576

574577
cpu = of_get_child_by_name(np, "cpu");
@@ -670,6 +673,18 @@ static int macaudio_parse_of(struct macaudio_snd_data *ma)
670673
for (i = 0; i < ARRAY_SIZE(macaudio_fe_links); i++)
671674
card->dai_link[i].platforms->of_node = platform;
672675

676+
/* Skip the speaker sense PCM link if this amp has no sense (or no speakers) */
677+
if (!ma->has_sense) {
678+
for (i = 0; i < ARRAY_SIZE(macaudio_fe_links); i++) {
679+
if (ma->link_props[i].is_sense) {
680+
memmove(&card->dai_link[i], &card->dai_link[i + 1],
681+
(num_links - i - 1) * sizeof (struct snd_soc_dai_link));
682+
num_links--;
683+
break;
684+
}
685+
}
686+
}
687+
673688
card->num_links = num_links;
674689

675690
return 0;

0 commit comments

Comments
 (0)