[SRU,D] ALSA: hda/realtek - Fixed headphone issue for ALC700
diff mbox series

Message ID 20190108062813.3266-3-hui.wang@canonical.com
State New
Headers show
Series
  • [SRU,D] ALSA: hda/realtek - Fixed headphone issue for ALC700
Related show

Commit Message

Hui Wang Jan. 8, 2019, 6:28 a.m. UTC
From: Kailang Yang <kailang@realtek.com>

BugLink: https://bugs.launchpad.net/bugs/1810891

If it plugged headphone or headset into the jack, then
do the reboot, it will have a chance to cause headphone no sound.
It just need to run the headphone mode procedure after boot time.
The issue will be fixed.
It also suitable for ALC234 ALC274 and ALC294.

Signed-off-by: Kailang Yang <kailang@realtek.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
(cherry picked from commit bde1a7459623a66c2abec4d0a841e4b06cc88d9a)
Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 sound/pci/hda/patch_realtek.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

Comments

Seth Forshee Jan. 9, 2019, 5:11 p.m. UTC | #1
On Tue, Jan 08, 2019 at 02:28:13PM +0800, Hui Wang wrote:
> From: Kailang Yang <kailang@realtek.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1810891
> 
> If it plugged headphone or headset into the jack, then
> do the reboot, it will have a chance to cause headphone no sound.
> It just need to run the headphone mode procedure after boot time.
> The issue will be fixed.
> It also suitable for ALC234 ALC274 and ALC294.
> 
> Signed-off-by: Kailang Yang <kailang@realtek.com>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> (cherry picked from commit bde1a7459623a66c2abec4d0a841e4b06cc88d9a)
> Signed-off-by: Hui Wang <hui.wang@canonical.com>

Disco already got this patch from upstream stable. Thanks!

Patch
diff mbox series

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index cf5d26642bcd..78a090eda61c 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -7200,6 +7200,37 @@  static void alc269_fill_coef(struct hda_codec *codec)
 	alc_update_coef_idx(codec, 0x4, 0, 1<<11);
 }
 
+static void alc294_hp_init(struct hda_codec *codec)
+{
+	struct alc_spec *spec = codec->spec;
+	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+	int i, val;
+
+	if (!hp_pin)
+		return;
+
+	snd_hda_codec_write(codec, hp_pin, 0,
+			    AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
+
+	msleep(100);
+
+	snd_hda_codec_write(codec, hp_pin, 0,
+			    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
+
+	alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
+	alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
+
+	/* Wait for depop procedure finish  */
+	val = alc_read_coefex_idx(codec, 0x58, 0x01);
+	for (i = 0; i < 20 && val & 0x0080; i++) {
+		msleep(50);
+		val = alc_read_coefex_idx(codec, 0x58, 0x01);
+	}
+	/* Set HP depop to auto mode */
+	alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
+	msleep(50);
+}
+
 /*
  */
 static int patch_alc269(struct hda_codec *codec)
@@ -7325,6 +7356,7 @@  static int patch_alc269(struct hda_codec *codec)
 		spec->codec_variant = ALC269_TYPE_ALC294;
 		spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
 		alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
+		alc294_hp_init(codec);
 		break;
 	case 0x10ec0300:
 		spec->codec_variant = ALC269_TYPE_ALC300;
@@ -7336,6 +7368,7 @@  static int patch_alc269(struct hda_codec *codec)
 		spec->codec_variant = ALC269_TYPE_ALC700;
 		spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
 		alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
+		alc294_hp_init(codec);
 		break;
 
 	}