Skip to content

Commit

Permalink
ALSA: hda - Reset pins of IDT/STAC codecs at free
Browse files Browse the repository at this point in the history
Some laptops cause annoying clicks or noises at shutdown/reboot since
the speaker pin is set still high.  Apply the same procedure used for
the suspend to avoid such clicks/noises for freeing the codec, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Nov 6, 2009
1 parent 9ad6a46 commit 167eae5
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions sound/pci/hda/patch_sigmatel.c
Original file line number Diff line number Diff line change
Expand Up @@ -4327,13 +4327,36 @@ static void stac92xx_free_kctls(struct hda_codec *codec)
snd_array_free(&spec->kctls);
}

static void stac92xx_shutup(struct hda_codec *codec)
{
struct sigmatel_spec *spec = codec->spec;
int i;
hda_nid_t nid;

/* reset each pin before powering down DAC/ADC to avoid click noise */
nid = codec->start_nid;
for (i = 0; i < codec->num_nodes; i++, nid++) {
unsigned int wcaps = get_wcaps(codec, nid);
unsigned int wid_type = get_wcaps_type(wcaps);
if (wid_type == AC_WID_PIN)
snd_hda_codec_read(codec, nid, 0,
AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
}

if (spec->eapd_mask)
stac_gpio_set(codec, spec->gpio_mask,
spec->gpio_dir, spec->gpio_data &
~spec->eapd_mask);
}

static void stac92xx_free(struct hda_codec *codec)
{
struct sigmatel_spec *spec = codec->spec;

if (! spec)
return;

stac92xx_shutup(codec);
stac92xx_free_jacks(codec);
snd_array_free(&spec->events);

Expand Down Expand Up @@ -4793,24 +4816,7 @@ static int stac92xx_hp_check_power_status(struct hda_codec *codec,

static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
{
struct sigmatel_spec *spec = codec->spec;
int i;
hda_nid_t nid;

/* reset each pin before powering down DAC/ADC to avoid click noise */
nid = codec->start_nid;
for (i = 0; i < codec->num_nodes; i++, nid++) {
unsigned int wcaps = get_wcaps(codec, nid);
unsigned int wid_type = get_wcaps_type(wcaps);
if (wid_type == AC_WID_PIN)
snd_hda_codec_read(codec, nid, 0,
AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
}

if (spec->eapd_mask)
stac_gpio_set(codec, spec->gpio_mask,
spec->gpio_dir, spec->gpio_data &
~spec->eapd_mask);
stac92xx_shutup(codec);
return 0;
}
#endif
Expand Down

0 comments on commit 167eae5

Please sign in to comment.