mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda/realtek: Restore headset mic COEF and restart HP JD on init
@ 2026-11-29 16:21 Nguyen Thanh Nhat
  0 siblings, 0 replies; only message in thread
From: Nguyen Thanh Nhat @ 2026-11-29 16:21 UTC (permalink / raw)
  To: Takashi Iwai, Jaroslav Kysela
  Cc: linux-sound, linux-kernel, Kailang Yang, SungHwan Jung,
	Breno Baptista, Nguyen Thanh Nhat

alc2xx_fixup_headset_mic() configures vendor COEF 0x45 for CTIA
combo-jack headset mic routing only during HDA_FIXUP_ACT_PRE_PROBE.
Because COEF 0x45 is not preserved across S3 suspend/resume, the
headset microphone stops working after waking from sleep.

Commit 655a830a248d ("ALSA: hda/realtek: Fix distorted headphone audio
on Acer Predator PHN16-71") pulses Reset HP JD (COEF 0x4a BIT(15)) on
HDA_FIXUP_ACT_INIT for Acer Predator PHN16-71 (Realtek ALC245,
1025:170f). However, restoring COEF 0x45 alone (0xc689 -> 0x5289) or
pulsing COEF 0x4a BIT(15) before restoring COEF 0x45 still leaves
headphone audio distorted and the headset mic non-working until the
headset is unplugged and replugged. Restoring COEF 0x45 first and then
pulsing COEF 0x4a BIT(15) restores both cleanly.

Add 0x10ec0245 to alc_combo_jack_hp_jd_restart() and invoke both the
COEF 0x45 update and alc_combo_jack_hp_jd_restart() during
HDA_FIXUP_ACT_INIT in alc2xx_fixup_headset_mic(). This makes the
PHN16-71-specific ALC245_FIXUP_ACER_HP_JD_RESET wrapper redundant, so
remove it and point 1025:170f back to ALC245_FIXUP_ACER_MICMUTE_LED
(which chains to ALC2XX_FIXUP_HEADSET_MIC).

Verified on Acer Predator PHN16-71 with a custom build of this tree
across cold boot, S3 suspend/resume, and unplug/replug.

An AI coding assistant was used to analyze the codec driver behavior
and interpret COEF register values.

Fixes: c8c0a03ec1be ("ALSA: hda/realtek - Fixed ASUS platform headset Mic issue")
Signed-off-by: Nguyen Thanh Nhat <nguyenthanhnhat397@gmail.com>
---
 sound/hda/codecs/realtek/alc269.c | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/sound/hda/codecs/realtek/alc269.c b/sound/hda/codecs/realtek/alc269.c
index 4ccbb10ee7e0..bb88ab43bce6 100644
--- a/sound/hda/codecs/realtek/alc269.c
+++ b/sound/hda/codecs/realtek/alc269.c
@@ -1477,17 +1477,6 @@ static void alc245_fixup_minisforum_jack_detect(struct hda_codec *codec,
 		alc_update_coef_idx(codec, 0x4a, BIT(15), 0);
 }
 
-static void alc245_fixup_acer_hp_jd_reset(struct hda_codec *codec,
-					  const struct hda_fixup *fix,
-					  int action)
-{
-	if (action == HDA_FIXUP_ACT_INIT) {
-		/* Pulse Reset HP JD */
-		alc_update_coef_idx(codec, 0x4a, BIT(15), BIT(15));
-		alc_update_coef_idx(codec, 0x4a, BIT(15), 0);
-	}
-}
-
 /* turn on/off mic-mute LED per capture hook via VREF change */
 static int vref_micmute_led_set(struct led_classdev *led_cdev,
 				enum led_brightness brightness)
@@ -3060,6 +3049,7 @@ static void alc285_fixup_invalidate_dacs(struct hda_codec *codec,
 static void alc_combo_jack_hp_jd_restart(struct hda_codec *codec)
 {
 	switch (codec->core.vendor_id) {
+	case 0x10ec0245:
 	case 0x10ec0274:
 	case 0x10ec0294:
 	case 0x10ec0225:
@@ -3990,6 +3980,10 @@ static void alc2xx_fixup_headset_mic(struct hda_codec *codec,
 		alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
 		spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
 		break;
+	case HDA_FIXUP_ACT_INIT:
+		alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
+		alc_combo_jack_hp_jd_restart(codec);
+		break;
 	}
 }
 
@@ -4644,7 +4638,6 @@ enum {
 	ALC233_FIXUP_LENOVO_GPIO2_MIC_HOTKEY,
 	ALC245_FIXUP_BASS_HP_DAC,
 	ALC245_FIXUP_ACER_MICMUTE_LED,
-	ALC245_FIXUP_ACER_HP_JD_RESET,
 	ALC245_FIXUP_CS35L41_I2C_2_MUTE_LED,
 	ALC245_FIXUP_CS35L41_I2C_2_MUTE_MICMUTE_LED,
 	ALC256_FIXUP_HONOR_MRB_XXX_M1020_AUDIO,
@@ -7483,12 +7476,6 @@ static const struct hda_fixup alc269_fixups[] = {
 		.chained = true,
 		.chain_id = ALC2XX_FIXUP_HEADSET_MIC,
 	},
-	[ALC245_FIXUP_ACER_HP_JD_RESET] = {
-		.type = HDA_FIXUP_FUNC,
-		.v.func = alc245_fixup_acer_hp_jd_reset,
-		.chained = true,
-		.chain_id = ALC245_FIXUP_ACER_MICMUTE_LED,
-	},
 	[ALC245_FIXUP_CS35L41_I2C_2_MUTE_LED] = {
 		.type = HDA_FIXUP_FUNC,
 		.v.func = alc245_fixup_hp_mute_led_coefbit,
@@ -7679,7 +7666,7 @@ static const struct hda_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x1025, 0x166c, "Acer Predator PH16-71", ALC2XX_FIXUP_HEADSET_MIC),
 	SND_PCI_QUIRK(0x1025, 0x1679, "Acer Nitro 16 AN16-41", ALC2XX_FIXUP_HEADSET_MIC),
 	SND_PCI_QUIRK(0x1025, 0x169a, "Acer Swift SFG16", ALC256_FIXUP_ACER_SFG16_MICMUTE_LED),
-	SND_PCI_QUIRK(0x1025, 0x170f, "Acer Predator PHN16-71", ALC245_FIXUP_ACER_HP_JD_RESET),
+	SND_PCI_QUIRK(0x1025, 0x170f, "Acer Predator PHN16-71", ALC245_FIXUP_ACER_MICMUTE_LED),
 	SND_PCI_QUIRK(0x1025, 0x171e, "Acer Nitro ANV15-51", ALC245_FIXUP_ACER_MICMUTE_LED),
 	SND_PCI_QUIRK(0x1025, 0x172c, "Acer Nitro ANV16-41", ALC2XX_FIXUP_HEADSET_MIC),
 	SND_PCI_QUIRK(0x1025, 0x1731, "Acer Predator PHN16-72", ALC245_FIXUP_ACER_MICMUTE_LED),

base-commit: 0910688e9191b9cd32cd49bb459a9d2d797c8f77
-- 
2.56.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-29 16:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-29 16:21 [PATCH] ALSA: hda/realtek: Restore headset mic COEF and restart HP JD on init Nguyen Thanh Nhat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®