aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKailang Yang <kailang@realtek.com>2017-06-21 02:50:54 -0400
committerTakashi Iwai <tiwai@suse.de>2017-06-21 05:13:46 -0400
commitc2d6af53a43fd8bb528eac8f31ffb666e9c74cf7 (patch)
treec140d32d3d186f59f520db70650f27a7c3f17748
parent71683c32dee66cdb244a25490823731db1401dce (diff)
ALSA: hda/realtek - Add default procedure for suspend and resume state
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>
-rw-r--r--sound/pci/hda/patch_realtek.c65
1 files changed, 64 insertions, 1 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 082b2db95056..c4a1b496d7bb 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -3130,6 +3130,67 @@ static void alc256_shutup(struct hda_codec *codec)
3130 snd_hda_shutup_pins(codec); 3130 snd_hda_shutup_pins(codec);
3131} 3131}
3132 3132
3133static void alc_default_init(struct hda_codec *codec)
3134{
3135 struct alc_spec *spec = codec->spec;
3136 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3137 bool hp_pin_sense;
3138
3139 if (!hp_pin)
3140 return;
3141
3142 msleep(30);
3143
3144 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3145
3146 if (hp_pin_sense)
3147 msleep(2);
3148
3149 snd_hda_codec_write(codec, hp_pin, 0,
3150 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3151
3152 if (hp_pin_sense)
3153 msleep(85);
3154
3155 snd_hda_codec_write(codec, hp_pin, 0,
3156 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3157
3158 if (hp_pin_sense)
3159 msleep(100);
3160}
3161
3162static void alc_default_shutup(struct hda_codec *codec)
3163{
3164 struct alc_spec *spec = codec->spec;
3165 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3166 bool hp_pin_sense;
3167
3168 if (!hp_pin) {
3169 alc269_shutup(codec);
3170 return;
3171 }
3172
3173 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3174
3175 if (hp_pin_sense)
3176 msleep(2);
3177
3178 snd_hda_codec_write(codec, hp_pin, 0,
3179 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3180
3181 if (hp_pin_sense)
3182 msleep(85);
3183
3184 snd_hda_codec_write(codec, hp_pin, 0,
3185 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3186
3187 if (hp_pin_sense)
3188 msleep(100);
3189
3190 alc_auto_setup_eapd(codec, false);
3191 snd_hda_shutup_pins(codec);
3192}
3193
3133static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg, 3194static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3134 unsigned int val) 3195 unsigned int val)
3135{ 3196{
@@ -6536,7 +6597,8 @@ static int patch_alc269(struct hda_codec *codec)
6536 codec->patch_ops.suspend = alc269_suspend; 6597 codec->patch_ops.suspend = alc269_suspend;
6537 codec->patch_ops.resume = alc269_resume; 6598 codec->patch_ops.resume = alc269_resume;
6538#endif 6599#endif
6539 spec->shutup = alc269_shutup; 6600 spec->shutup = alc_default_shutup;
6601 spec->init_hook = alc_default_init;
6540 6602
6541 snd_hda_pick_fixup(codec, alc269_fixup_models, 6603 snd_hda_pick_fixup(codec, alc269_fixup_models,
6542 alc269_fixup_tbl, alc269_fixups); 6604 alc269_fixup_tbl, alc269_fixups);
@@ -6576,6 +6638,7 @@ static int patch_alc269(struct hda_codec *codec)
6576 } 6638 }
6577 if (err < 0) 6639 if (err < 0)
6578 goto error; 6640 goto error;
6641 spec->shutup = alc269_shutup;
6579 spec->init_hook = alc269_fill_coef; 6642 spec->init_hook = alc269_fill_coef;
6580 alc269_fill_coef(codec); 6643 alc269_fill_coef(codec);
6581 break; 6644 break;