[PATCH v4] ALSA: hda/realtek: Sequence GPIO2 on Star Labs StarFighter

Sean Rhodes posted 1 patch 3 weeks, 1 day ago
sound/hda/codecs/realtek/alc269.c | 38 ++++++++++++++++++++++++++-----
1 file changed, 32 insertions(+), 6 deletions(-)
[PATCH v4] ALSA: hda/realtek: Sequence GPIO2 on Star Labs StarFighter
Posted by Sean Rhodes 3 weeks, 1 day ago
The initial StarFighter quirk fixed the runtime suspend pop by muting
speakers in the shutup callback before power-down. Further hardware
validation showed that the speaker path is controlled directly by LINE2
EAPD on NID 0x1b together with GPIO2 for the external amplifier.

Replace the shutup-delay workaround with explicit sequencing of those
controls at playback start and stop:
- assert LINE2 EAPD and drive GPIO2 high on PREPARE
- deassert LINE2 EAPD and drive GPIO2 low on CLEANUP

This avoids the runtime suspend pop without a sleep, and also fixes pops
around G3 entry and display-manager start that the original workaround
did not cover.

Fixes: 1cb3c20688fc ("ALSA: hda/realtek: Fix speaker pop on Star Labs StarFighter")
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Stefan Binding <sbinding@opensource.cirrus.com>
Cc: Kailang Yang <kailang@realtek.com>
Cc: Chris Chiu <chris.chiu@canonical.com>
Cc: Edip Hazuri <edip@medip.dev>
Cc: linux-sound@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Tested-by: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
---
 sound/hda/codecs/realtek/alc269.c | 38 ++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 6 deletions(-)

diff --git a/sound/hda/codecs/realtek/alc269.c b/sound/hda/codecs/realtek/alc269.c
index 4c49f1195e1b..b1a52fb4bb8a 100644
--- a/sound/hda/codecs/realtek/alc269.c
+++ b/sound/hda/codecs/realtek/alc269.c
@@ -1017,12 +1017,30 @@ static int alc269_resume(struct hda_codec *codec)
 	return 0;
 }
 
-#define STARLABS_STARFIGHTER_SHUTUP_DELAY_MS	30
+#define ALC233_STARFIGHTER_SPK_PIN	0x1b
+#define ALC233_STARFIGHTER_GPIO2	0x04
 
-static void starlabs_starfighter_shutup(struct hda_codec *codec)
+static void alc233_starfighter_update_amp(struct hda_codec *codec, bool on)
 {
-	if (snd_hda_gen_shutup_speakers(codec))
-		msleep(STARLABS_STARFIGHTER_SHUTUP_DELAY_MS);
+	snd_hda_codec_write(codec, ALC233_STARFIGHTER_SPK_PIN, 0,
+			    AC_VERB_SET_EAPD_BTLENABLE,
+			    on ? AC_EAPDBTL_EAPD : 0);
+	alc_update_gpio_data(codec, ALC233_STARFIGHTER_GPIO2, on);
+}
+
+static void alc233_starfighter_pcm_hook(struct hda_pcm_stream *hinfo,
+					struct hda_codec *codec,
+					struct snd_pcm_substream *substream,
+					int action)
+{
+	switch (action) {
+	case HDA_GEN_PCM_ACT_PREPARE:
+		alc233_starfighter_update_amp(codec, true);
+		break;
+	case HDA_GEN_PCM_ACT_CLEANUP:
+		alc233_starfighter_update_amp(codec, false);
+		break;
+	}
 }
 
 static void alc233_fixup_starlabs_starfighter(struct hda_codec *codec,
@@ -1031,8 +1049,16 @@ static void alc233_fixup_starlabs_starfighter(struct hda_codec *codec,
 {
 	struct alc_spec *spec = codec->spec;
 
-	if (action == HDA_FIXUP_ACT_PRE_PROBE)
-		spec->shutup = starlabs_starfighter_shutup;
+	switch (action) {
+	case HDA_FIXUP_ACT_PRE_PROBE:
+		spec->gpio_mask |= ALC233_STARFIGHTER_GPIO2;
+		spec->gpio_dir |= ALC233_STARFIGHTER_GPIO2;
+		spec->gpio_data &= ~ALC233_STARFIGHTER_GPIO2;
+		break;
+	case HDA_FIXUP_ACT_PROBE:
+		spec->gen.pcm_playback_hook = alc233_starfighter_pcm_hook;
+		break;
+	}
 }
 
 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
-- 
2.51.0
Re: [PATCH v4] ALSA: hda/realtek: Sequence GPIO2 on Star Labs StarFighter
Posted by Takashi Iwai 3 weeks ago
On Sun, 15 Mar 2026 21:11:27 +0100,
Sean Rhodes wrote:
> 
> The initial StarFighter quirk fixed the runtime suspend pop by muting
> speakers in the shutup callback before power-down. Further hardware
> validation showed that the speaker path is controlled directly by LINE2
> EAPD on NID 0x1b together with GPIO2 for the external amplifier.
> 
> Replace the shutup-delay workaround with explicit sequencing of those
> controls at playback start and stop:
> - assert LINE2 EAPD and drive GPIO2 high on PREPARE
> - deassert LINE2 EAPD and drive GPIO2 low on CLEANUP
> 
> This avoids the runtime suspend pop without a sleep, and also fixes pops
> around G3 entry and display-manager start that the original workaround
> did not cover.
> 
> Fixes: 1cb3c20688fc ("ALSA: hda/realtek: Fix speaker pop on Star Labs StarFighter")
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: Stefan Binding <sbinding@opensource.cirrus.com>
> Cc: Kailang Yang <kailang@realtek.com>
> Cc: Chris Chiu <chris.chiu@canonical.com>
> Cc: Edip Hazuri <edip@medip.dev>
> Cc: linux-sound@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Tested-by: Sean Rhodes <sean@starlabs.systems>
> Signed-off-by: Sean Rhodes <sean@starlabs.systems>

Applied now.  Thanks.


Takashi
Re: [PATCH v4] ALSA: hda/realtek: Sequence GPIO2 on Star Labs StarFighter
Posted by Sean Rhodes 3 weeks ago
Thank you :)

> On 16 Mar 2026, at 17:05, Takashi Iwai <tiwai@suse.de> wrote:
> 
> On Sun, 15 Mar 2026 21:11:27 +0100,
> Sean Rhodes wrote:
>> 
>> The initial StarFighter quirk fixed the runtime suspend pop by muting
>> speakers in the shutup callback before power-down. Further hardware
>> validation showed that the speaker path is controlled directly by LINE2
>> EAPD on NID 0x1b together with GPIO2 for the external amplifier.
>> 
>> Replace the shutup-delay workaround with explicit sequencing of those
>> controls at playback start and stop:
>> - assert LINE2 EAPD and drive GPIO2 high on PREPARE
>> - deassert LINE2 EAPD and drive GPIO2 low on CLEANUP
>> 
>> This avoids the runtime suspend pop without a sleep, and also fixes pops
>> around G3 entry and display-manager start that the original workaround
>> did not cover.
>> 
>> Fixes: 1cb3c20688fc ("ALSA: hda/realtek: Fix speaker pop on Star Labs StarFighter")
>> Cc: Jaroslav Kysela <perex@perex.cz>
>> Cc: Takashi Iwai <tiwai@suse.com>
>> Cc: Stefan Binding <sbinding@opensource.cirrus.com>
>> Cc: Kailang Yang <kailang@realtek.com>
>> Cc: Chris Chiu <chris.chiu@canonical.com>
>> Cc: Edip Hazuri <edip@medip.dev>
>> Cc: linux-sound@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>> Tested-by: Sean Rhodes <sean@starlabs.systems>
>> Signed-off-by: Sean Rhodes <sean@starlabs.systems>
> 
> Applied now.  Thanks.
> 
> 
> Takashi