1 From: Takashi Iwai <tiwai@suse.de>
2 Subject: ALSA: hda - Reset pins of IDT/STAC codecs at free
6 Some laptops cause annoying clicks or noises at shutdown/reboot since
7 the speaker pin is set still high. Apply the same procedure used for
8 the suspend to avoid such clicks/noises for freeing the codec, too.
10 Signed-off-by: Takashi Iwai <tiwai@suse.de>
13 sound/pci/hda/patch_sigmatel.c | 42 +++++++++++++++++++++++------------------
14 1 file changed, 24 insertions(+), 18 deletions(-)
16 --- a/sound/pci/hda/patch_sigmatel.c
17 +++ b/sound/pci/hda/patch_sigmatel.c
18 @@ -4058,6 +4058,28 @@
19 snd_array_free(&spec->kctls);
22 +static void stac92xx_shutup(struct hda_codec *codec)
24 + struct sigmatel_spec *spec = codec->spec;
28 + /* reset each pin before powering down DAC/ADC to avoid click noise */
29 + nid = codec->start_nid;
30 + for (i = 0; i < codec->num_nodes; i++, nid++) {
31 + unsigned int wcaps = get_wcaps(codec, nid);
32 + unsigned int wid_type = get_wcaps_type(wcaps);
33 + if (wid_type == AC_WID_PIN)
34 + snd_hda_codec_read(codec, nid, 0,
35 + AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
38 + if (spec->eapd_mask)
39 + stac_gpio_set(codec, spec->gpio_mask,
40 + spec->gpio_dir, spec->gpio_data &
44 static void stac92xx_free(struct hda_codec *codec)
46 struct sigmatel_spec *spec = codec->spec;
51 + stac92xx_shutup(codec);
52 snd_array_free(&spec->events);
55 @@ -4424,24 +4447,7 @@
57 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
59 - struct sigmatel_spec *spec = codec->spec;
63 - /* reset each pin before powering down DAC/ADC to avoid click noise */
64 - nid = codec->start_nid;
65 - for (i = 0; i < codec->num_nodes; i++, nid++) {
66 - unsigned int wcaps = get_wcaps(codec, nid);
67 - unsigned int wid_type = get_wcaps_type(wcaps);
68 - if (wid_type == AC_WID_PIN)
69 - snd_hda_codec_read(codec, nid, 0,
70 - AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
73 - if (spec->eapd_mask)
74 - stac_gpio_set(codec, spec->gpio_mask,
75 - spec->gpio_dir, spec->gpio_data &
77 + stac92xx_shutup(codec);