]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ALSA: hda/realtek - Add default procedure for suspend and resume state
authorKailang Yang <kailang@realtek.com>
Wed, 21 Jun 2017 06:50:54 +0000 (14:50 +0800)
committerTakashi Iwai <tiwai@suse.de>
Wed, 21 Jun 2017 09:13:46 +0000 (11:13 +0200)
Except ALC269.
This will reduce pop noise from headset or headphone.
If codec enter to power save state, when plug headset or headphone....
It has a chance to cut off power by system.
Our new codec use this procedure will be more stable during suspend
and resume state.

Signed-off-by: Kailang Yang <kailang@realtek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/patch_realtek.c

index 082b2db9505668c1602d06bbb3a0b68cf579b004..c4a1b496d7bb101699e68e92c8fe25455df45b00 100644 (file)
@@ -3130,6 +3130,67 @@ static void alc256_shutup(struct hda_codec *codec)
        snd_hda_shutup_pins(codec);
 }
 
+static void alc_default_init(struct hda_codec *codec)
+{
+       struct alc_spec *spec = codec->spec;
+       hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+       bool hp_pin_sense;
+
+       if (!hp_pin)
+               return;
+
+       msleep(30);
+
+       hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
+
+       if (hp_pin_sense)
+               msleep(2);
+
+       snd_hda_codec_write(codec, hp_pin, 0,
+                           AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
+
+       if (hp_pin_sense)
+               msleep(85);
+
+       snd_hda_codec_write(codec, hp_pin, 0,
+                           AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
+
+       if (hp_pin_sense)
+               msleep(100);
+}
+
+static void alc_default_shutup(struct hda_codec *codec)
+{
+       struct alc_spec *spec = codec->spec;
+       hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+       bool hp_pin_sense;
+
+       if (!hp_pin) {
+               alc269_shutup(codec);
+               return;
+       }
+
+       hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
+
+       if (hp_pin_sense)
+               msleep(2);
+
+       snd_hda_codec_write(codec, hp_pin, 0,
+                           AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
+
+       if (hp_pin_sense)
+               msleep(85);
+
+       snd_hda_codec_write(codec, hp_pin, 0,
+                           AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
+
+       if (hp_pin_sense)
+               msleep(100);
+
+       alc_auto_setup_eapd(codec, false);
+       snd_hda_shutup_pins(codec);
+}
+
 static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
                             unsigned int val)
 {
@@ -6536,7 +6597,8 @@ static int patch_alc269(struct hda_codec *codec)
        codec->patch_ops.suspend = alc269_suspend;
        codec->patch_ops.resume = alc269_resume;
 #endif
-       spec->shutup = alc269_shutup;
+       spec->shutup = alc_default_shutup;
+       spec->init_hook = alc_default_init;
 
        snd_hda_pick_fixup(codec, alc269_fixup_models,
                       alc269_fixup_tbl, alc269_fixups);
@@ -6576,6 +6638,7 @@ static int patch_alc269(struct hda_codec *codec)
                }
                if (err < 0)
                        goto error;
+               spec->shutup = alc269_shutup;
                spec->init_hook = alc269_fill_coef;
                alc269_fill_coef(codec);
                break;