Skip to content

Commit

Permalink
ALSA: hda - Set codec to D3 at reboot/shutdown on Thinkpads
Browse files Browse the repository at this point in the history
Lenovo Thinkpads with Realtek codecs may still have some loud
crackling noises at reboot/shutdown even though a few previous fixes
have been applied.  It's because the previous fix (disabling the
default shutup callback) takes effect only at transition of the codec
power state.  Meanwhile, at reboot or shutdown, we don't take down the
codec power as default, thus it triggers the same problem unless the
codec is powered down casually by runtime PM.

This patch tries to address the issue.  It gives two things:
- implement the separate reboot_notify hook to struct alc_spec, and
  call it optionally if defined.
- turn off the codec to D3 for Thinkpad models via this new callback

Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=958439
Reported-and-tested-by: Benjamin Poirier <[email protected]>
Cc: <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Dec 15, 2015
1 parent 157f0b7 commit 70a0976
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion sound/pci/hda/patch_realtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ struct alc_spec {
void (*power_hook)(struct hda_codec *codec);
#endif
void (*shutup)(struct hda_codec *codec);
void (*reboot_notify)(struct hda_codec *codec);

int init_amp;
int codec_variant; /* flag for other variants */
Expand Down Expand Up @@ -773,6 +774,25 @@ static inline void alc_shutup(struct hda_codec *codec)
snd_hda_shutup_pins(codec);
}

static void alc_reboot_notify(struct hda_codec *codec)
{
struct alc_spec *spec = codec->spec;

if (spec && spec->reboot_notify)
spec->reboot_notify(codec);
else
alc_shutup(codec);
}

/* power down codec to D3 at reboot/shutdown; set as reboot_notify ops */
static void alc_d3_at_reboot(struct hda_codec *codec)
{
snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3);
snd_hda_codec_write(codec, codec->core.afg, 0,
AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
msleep(10);
}

#define alc_free snd_hda_gen_free

#ifdef CONFIG_PM
Expand Down Expand Up @@ -818,7 +838,7 @@ static const struct hda_codec_ops alc_patch_ops = {
.suspend = alc_suspend,
.check_power_status = snd_hda_gen_check_power_status,
#endif
.reboot_notify = alc_shutup,
.reboot_notify = alc_reboot_notify,
};


Expand Down Expand Up @@ -4199,6 +4219,7 @@ static void alc_fixup_tpt440_dock(struct hda_codec *codec,

if (action == HDA_FIXUP_ACT_PRE_PROBE) {
spec->shutup = alc_no_shutup; /* reduce click noise */
spec->reboot_notify = alc_d3_at_reboot; /* reduce noise */
spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
codec->power_save_node = 0; /* avoid click noises */
snd_hda_apply_pincfgs(codec, pincfgs);
Expand Down

0 comments on commit 70a0976

Please sign in to comment.