aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-05-10 05:01:43 -0400
committerTakashi Iwai <tiwai@suse.de>2019-05-10 05:01:43 -0400
commitc9af753f26bdf80291eb2c2279b9de1989fbc591 (patch)
tree71aa2bf5608c2b30c3623064707c6df61a17888a
parentdad3197da7a3817f27bb24f7fd3c135ffa707202 (diff)
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: Kailang Yang <kailang@realtek.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/hda/patch_realtek.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index c39f48e02ee9..2a50e580aa56 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -535,7 +535,6 @@ static void alc_eapd_shutup(struct hda_codec *codec)
535/* generic EAPD initialization */ 535/* generic EAPD initialization */
536static void alc_auto_init_amp(struct hda_codec *codec, int type) 536static void alc_auto_init_amp(struct hda_codec *codec, int type)
537{ 537{
538 alc_fill_eapd_coef(codec);
539 alc_auto_setup_eapd(codec, true); 538 alc_auto_setup_eapd(codec, true);
540 alc_write_gpio(codec); 539 alc_write_gpio(codec);
541 switch (type) { 540 switch (type) {
@@ -830,10 +829,22 @@ static int alc_build_controls(struct hda_codec *codec)
830 * Common callbacks 829 * Common callbacks
831 */ 830 */
832 831
832static void alc_pre_init(struct hda_codec *codec)
833{
834 alc_fill_eapd_coef(codec);
835}
836
837#define is_s4_resume(codec) \
838 ((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE)
839
833static int alc_init(struct hda_codec *codec) 840static int alc_init(struct hda_codec *codec)
834{ 841{
835 struct alc_spec *spec = codec->spec; 842 struct alc_spec *spec = codec->spec;
836 843
844 /* hibernation resume needs the full chip initialization */
845 if (is_s4_resume(codec))
846 alc_pre_init(codec);
847
837 if (spec->init_hook) 848 if (spec->init_hook)
838 spec->init_hook(codec); 849 spec->init_hook(codec);
839 850
@@ -1571,6 +1582,8 @@ static int patch_alc880(struct hda_codec *codec)
1571 1582
1572 codec->patch_ops.unsol_event = alc880_unsol_event; 1583 codec->patch_ops.unsol_event = alc880_unsol_event;
1573 1584
1585 alc_pre_init(codec);
1586
1574 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, 1587 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
1575 alc880_fixups); 1588 alc880_fixups);
1576 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 1589 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
@@ -1822,6 +1835,8 @@ static int patch_alc260(struct hda_codec *codec)
1822 1835
1823 spec->shutup = alc_eapd_shutup; 1836 spec->shutup = alc_eapd_shutup;
1824 1837
1838 alc_pre_init(codec);
1839
1825 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl, 1840 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1826 alc260_fixups); 1841 alc260_fixups);
1827 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 1842 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
@@ -2525,6 +2540,8 @@ static int patch_alc882(struct hda_codec *codec)
2525 break; 2540 break;
2526 } 2541 }
2527 2542
2543 alc_pre_init(codec);
2544
2528 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, 2545 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2529 alc882_fixups); 2546 alc882_fixups);
2530 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 2547 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
@@ -2699,6 +2716,8 @@ static int patch_alc262(struct hda_codec *codec)
2699#endif 2716#endif
2700 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 2717 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2701 2718
2719 alc_pre_init(codec);
2720
2702 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl, 2721 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2703 alc262_fixups); 2722 alc262_fixups);
2704 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 2723 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
@@ -2843,6 +2862,8 @@ static int patch_alc268(struct hda_codec *codec)
2843 2862
2844 spec->shutup = alc_eapd_shutup; 2863 spec->shutup = alc_eapd_shutup;
2845 2864
2865 alc_pre_init(codec);
2866
2846 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); 2867 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2847 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 2868 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2848 2869
@@ -7816,6 +7837,8 @@ static int patch_alc269(struct hda_codec *codec)
7816 spec->init_hook = alc5505_dsp_init; 7837 spec->init_hook = alc5505_dsp_init;
7817 } 7838 }
7818 7839
7840 alc_pre_init(codec);
7841
7819 snd_hda_pick_fixup(codec, alc269_fixup_models, 7842 snd_hda_pick_fixup(codec, alc269_fixup_models,
7820 alc269_fixup_tbl, alc269_fixups); 7843 alc269_fixup_tbl, alc269_fixups);
7821 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups); 7844 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 spec->power_hook = alc_power_eapd; 7981 spec->power_hook = alc_power_eapd;
7959#endif 7982#endif
7960 7983
7984 alc_pre_init(codec);
7985
7961 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); 7986 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
7962 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 7987 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
7963 7988
@@ -8055,6 +8080,8 @@ static int patch_alc861vd(struct hda_codec *codec)
8055 8080
8056 spec->shutup = alc_eapd_shutup; 8081 spec->shutup = alc_eapd_shutup;
8057 8082
8083 alc_pre_init(codec);
8084
8058 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); 8085 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
8059 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 8086 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
8060 8087
@@ -8790,6 +8817,8 @@ static int patch_alc662(struct hda_codec *codec)
8790 break; 8817 break;
8791 } 8818 }
8792 8819
8820 alc_pre_init(codec);
8821
8793 snd_hda_pick_fixup(codec, alc662_fixup_models, 8822 snd_hda_pick_fixup(codec, alc662_fixup_models,
8794 alc662_fixup_tbl, alc662_fixups); 8823 alc662_fixup_tbl, alc662_fixups);
8795 snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups); 8824 snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups);