Commit c9af753f authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda/realtek - Avoid superfluous COEF EAPD setups

Realtek codec driver applied the COEF setups to change the EAPD
control to the default mode (i.e. control by EPAD verbs) at the init
callback.  It works, but this is too excessive at the same time, since
it's called at each runtime PM resume.  That is, the initialization
should be done only once after the probe.  One may think that moving
this to the probe should be OK, but no -- there is a catch; when a
system resumes from S4 (hibernation), we need to re-initialize this
again manually, because it's out of regcache restoration.

This patch addresses the issue by introducing alc_pre_init() function
that performs such a task.  This is called from each codec probe
function, and it's called from the resume callback conditionally only
from S4 resume.
Reported-and-tested-by: default avatarKailang Yang <kailang@realtek.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent dad3197d
...@@ -535,7 +535,6 @@ static void alc_eapd_shutup(struct hda_codec *codec) ...@@ -535,7 +535,6 @@ static void alc_eapd_shutup(struct hda_codec *codec)
/* generic EAPD initialization */ /* generic EAPD initialization */
static void alc_auto_init_amp(struct hda_codec *codec, int type) static void alc_auto_init_amp(struct hda_codec *codec, int type)
{ {
alc_fill_eapd_coef(codec);
alc_auto_setup_eapd(codec, true); alc_auto_setup_eapd(codec, true);
alc_write_gpio(codec); alc_write_gpio(codec);
switch (type) { switch (type) {
...@@ -830,10 +829,22 @@ static int alc_build_controls(struct hda_codec *codec) ...@@ -830,10 +829,22 @@ static int alc_build_controls(struct hda_codec *codec)
* Common callbacks * Common callbacks
*/ */
static void alc_pre_init(struct hda_codec *codec)
{
alc_fill_eapd_coef(codec);
}
#define is_s4_resume(codec) \
((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE)
static int alc_init(struct hda_codec *codec) static int alc_init(struct hda_codec *codec)
{ {
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
/* hibernation resume needs the full chip initialization */
if (is_s4_resume(codec))
alc_pre_init(codec);
if (spec->init_hook) if (spec->init_hook)
spec->init_hook(codec); spec->init_hook(codec);
...@@ -1571,6 +1582,8 @@ static int patch_alc880(struct hda_codec *codec) ...@@ -1571,6 +1582,8 @@ static int patch_alc880(struct hda_codec *codec)
codec->patch_ops.unsol_event = alc880_unsol_event; codec->patch_ops.unsol_event = alc880_unsol_event;
alc_pre_init(codec);
snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
alc880_fixups); alc880_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
...@@ -1822,6 +1835,8 @@ static int patch_alc260(struct hda_codec *codec) ...@@ -1822,6 +1835,8 @@ static int patch_alc260(struct hda_codec *codec)
spec->shutup = alc_eapd_shutup; spec->shutup = alc_eapd_shutup;
alc_pre_init(codec);
snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl, snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
alc260_fixups); alc260_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
...@@ -2525,6 +2540,8 @@ static int patch_alc882(struct hda_codec *codec) ...@@ -2525,6 +2540,8 @@ static int patch_alc882(struct hda_codec *codec)
break; break;
} }
alc_pre_init(codec);
snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
alc882_fixups); alc882_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
...@@ -2699,6 +2716,8 @@ static int patch_alc262(struct hda_codec *codec) ...@@ -2699,6 +2716,8 @@ static int patch_alc262(struct hda_codec *codec)
#endif #endif
alc_fix_pll_init(codec, 0x20, 0x0a, 10); alc_fix_pll_init(codec, 0x20, 0x0a, 10);
alc_pre_init(codec);
snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl, snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
alc262_fixups); alc262_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
...@@ -2843,6 +2862,8 @@ static int patch_alc268(struct hda_codec *codec) ...@@ -2843,6 +2862,8 @@ static int patch_alc268(struct hda_codec *codec)
spec->shutup = alc_eapd_shutup; spec->shutup = alc_eapd_shutup;
alc_pre_init(codec);
snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
...@@ -7816,6 +7837,8 @@ static int patch_alc269(struct hda_codec *codec) ...@@ -7816,6 +7837,8 @@ static int patch_alc269(struct hda_codec *codec)
spec->init_hook = alc5505_dsp_init; spec->init_hook = alc5505_dsp_init;
} }
alc_pre_init(codec);
snd_hda_pick_fixup(codec, alc269_fixup_models, snd_hda_pick_fixup(codec, alc269_fixup_models,
alc269_fixup_tbl, alc269_fixups); alc269_fixup_tbl, alc269_fixups);
snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups); snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups);
...@@ -7958,6 +7981,8 @@ static int patch_alc861(struct hda_codec *codec) ...@@ -7958,6 +7981,8 @@ static int patch_alc861(struct hda_codec *codec)
spec->power_hook = alc_power_eapd; spec->power_hook = alc_power_eapd;
#endif #endif
alc_pre_init(codec);
snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
...@@ -8055,6 +8080,8 @@ static int patch_alc861vd(struct hda_codec *codec) ...@@ -8055,6 +8080,8 @@ static int patch_alc861vd(struct hda_codec *codec)
spec->shutup = alc_eapd_shutup; spec->shutup = alc_eapd_shutup;
alc_pre_init(codec);
snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
...@@ -8790,6 +8817,8 @@ static int patch_alc662(struct hda_codec *codec) ...@@ -8790,6 +8817,8 @@ static int patch_alc662(struct hda_codec *codec)
break; break;
} }
alc_pre_init(codec);
snd_hda_pick_fixup(codec, alc662_fixup_models, snd_hda_pick_fixup(codec, alc662_fixup_models,
alc662_fixup_tbl, alc662_fixups); alc662_fixup_tbl, alc662_fixups);
snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups); snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment