Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05ff7e11 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: hda - Reduce click noise at power-saving



Add some tricks to reduce the click noise at powering down to D3
in the power saving mode on STAC/IDT codecs.
The key seems to be to reset PINs before the power-down, and some
delay before entering D3.  The needed delay is significantly long,
but I don't know why.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 05e870d2
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -2367,9 +2367,14 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
	hda_nid_t nid;
	hda_nid_t nid;
	int i;
	int i;


	snd_hda_codec_write(codec, fg, 0, AC_VERB_SET_POWER_STATE,
	/* this delay seems necessary to avoid click noise at power-down */
	if (power_state == AC_PWRST_D3)
		msleep(100);
	snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
			    power_state);
			    power_state);
	msleep(10); /* partial workaround for "azx_get_response timeout" */
	/* partial workaround for "azx_get_response timeout" */
	if (power_state == AC_PWRST_D0)
		msleep(10);


	nid = codec->start_nid;
	nid = codec->start_nid;
	for (i = 0; i < codec->num_nodes; i++, nid++) {
	for (i = 0; i < codec->num_nodes; i++, nid++) {
+14 −0
Original line number Original line Diff line number Diff line
@@ -4745,6 +4745,20 @@ static int stac92xx_hp_check_power_status(struct hda_codec *codec,
static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
{
{
	struct sigmatel_spec *spec = codec->spec;
	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 = (wcaps & AC_WCAP_TYPE) >>
			AC_WCAP_TYPE_SHIFT;
		if (wid_type == AC_WID_PIN)
			snd_hda_codec_read(codec, nid, 0,
				AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
	}

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