ALSA: hda/realtek – Check headset type by unplug and resume [Linux 5.2]

ALSA: hda/realtek – Check headset type by unplug and resume [Linux 5.2]

This Linux kernel change "ALSA: hda/realtek – Check headset type by unplug and resume" is included in the Linux 5.2 release. This change is authored by Kailang Yang <kailang [at] realtek.com> on Thu May 16 16:10:44 2019 +0800. The commit for this change in Linux stable tree is aeac1a0 (patch).

ALSA: hda/realtek - Check headset type by unplug and resume

When system enable HDA power save mode.
This issue will happen on new platform which DMIC connect to PCH.
In Dell headset mode, it will recheck during runtime resume when
headset was plugged.
This patch will move check headset type on unplug and system resume.

[ A few minor code cleanups by tiwai ]

Signed-off-by: Kailang Yang <kailang@realtek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

There are 11 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 sound/pci/hda/patch_realtek.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index f83f21d..b984bd1 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -834,6 +834,8 @@ static void alc_pre_init(struct hda_codec *codec)
    alc_fill_eapd_coef(codec);
 }

+#define is_s3_resume(codec) \
+   ((codec)->core.dev.power.power_state.event == PM_EVENT_RESUME)
 #define is_s4_resume(codec) \
    ((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE)

@@ -4901,6 +4903,8 @@ static void alc_update_headset_mode(struct hda_codec *codec)
    switch (new_headset_mode) {
    case ALC_HEADSET_MODE_UNPLUGGED:
        alc_headset_mode_unplugged(codec);
+       spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
+       spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
        spec->gen.hp_jack_present = false;
        break;
    case ALC_HEADSET_MODE_HEADSET:
@@ -4943,8 +4947,6 @@ static void alc_update_headset_mode_hook(struct hda_codec *codec,
 static void alc_update_headset_jack_cb(struct hda_codec *codec,
                       struct hda_jack_callback *jack)
 {
-   struct alc_spec *spec = codec->spec;
-   spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
    snd_hda_gen_hp_automute(codec, jack);
 }

@@ -4981,7 +4983,10 @@ static void alc_fixup_headset_mode(struct hda_codec *codec,
        alc_probe_headset_mode(codec);
        break;
    case HDA_FIXUP_ACT_INIT:
-       spec->current_headset_mode = 0;
+       if (is_s3_resume(codec) || is_s4_resume(codec)) {
+           spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
+           spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
+       }
        alc_update_headset_mode(codec);
        break;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *