1 From dad3197da7a3817f27bb24f7fd3c135ffa707202 Mon Sep 17 00:00:00 2001
2 From: Kailang Yang <kailang@realtek.com>
3 Date: Fri, 10 May 2019 16:28:57 +0800
4 Subject: ALSA: hda/realtek - Fixup headphone noise via runtime suspend
6 From: Kailang Yang <kailang@realtek.com>
8 commit dad3197da7a3817f27bb24f7fd3c135ffa707202 upstream.
10 Dell platform with ALC298.
11 system enter to runtime suspend. Headphone had noise.
12 Let Headset Mic not shutup will solve this issue.
14 [ Fixed minor coding style issues by tiwai ]
16 Signed-off-by: Kailang Yang <kailang@realtek.com>
17 Cc: <stable@vger.kernel.org>
18 Signed-off-by: Takashi Iwai <tiwai@suse.de>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 sound/pci/hda/patch_realtek.c | 59 ++++++++++++++++++++++++------------------
23 1 file changed, 35 insertions(+), 24 deletions(-)
25 --- a/sound/pci/hda/patch_realtek.c
26 +++ b/sound/pci/hda/patch_realtek.c
27 @@ -477,12 +477,45 @@ static void alc_auto_setup_eapd(struct h
28 set_eapd(codec, *p, on);
31 +static int find_ext_mic_pin(struct hda_codec *codec);
33 +static void alc_headset_mic_no_shutup(struct hda_codec *codec)
35 + const struct hda_pincfg *pin;
36 + int mic_pin = find_ext_mic_pin(codec);
39 + /* don't shut up pins when unloading the driver; otherwise it breaks
40 + * the default pin setup at the next load of the driver
42 + if (codec->bus->shutdown)
45 + snd_array_for_each(&codec->init_pins, i, pin) {
46 + /* use read here for syncing after issuing each verb */
47 + if (pin->nid != mic_pin)
48 + snd_hda_codec_read(codec, pin->nid, 0,
49 + AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
52 + codec->pins_shutup = 1;
55 static void alc_shutup_pins(struct hda_codec *codec)
57 struct alc_spec *spec = codec->spec;
59 - if (!spec->no_shutup_pins)
60 - snd_hda_shutup_pins(codec);
61 + switch (codec->core.vendor_id) {
65 + alc_headset_mic_no_shutup(codec);
68 + if (!spec->no_shutup_pins)
69 + snd_hda_shutup_pins(codec);
74 /* generic shutup callback;
75 @@ -2923,27 +2956,6 @@ static int alc269_parse_auto_config(stru
76 return alc_parse_auto_config(codec, alc269_ignore, ssids);
79 -static int find_ext_mic_pin(struct hda_codec *codec);
81 -static void alc286_shutup(struct hda_codec *codec)
83 - const struct hda_pincfg *pin;
85 - int mic_pin = find_ext_mic_pin(codec);
86 - /* don't shut up pins when unloading the driver; otherwise it breaks
87 - * the default pin setup at the next load of the driver
89 - if (codec->bus->shutdown)
91 - snd_array_for_each(&codec->init_pins, i, pin) {
92 - /* use read here for syncing after issuing each verb */
93 - if (pin->nid != mic_pin)
94 - snd_hda_codec_read(codec, pin->nid, 0,
95 - AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
97 - codec->pins_shutup = 1;
100 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
102 alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
103 @@ -7611,7 +7623,6 @@ static int patch_alc269(struct hda_codec
106 spec->codec_variant = ALC269_TYPE_ALC286;
107 - spec->shutup = alc286_shutup;
110 spec->codec_variant = ALC269_TYPE_ALC298;