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

Commit c5177c86 authored by Kailang Yang's avatar Kailang Yang Committed by Takashi Iwai
Browse files

ALSA: hda - Fix the noise after suspend on ALC283 codec



When the power state of ALC283 codec goes to D3, it gives a noise via
headphone output.  This is because the driver tries to clear all pins
via snd_hda_shutup_pins().  Setting the mic pin to zero triggers such
a noise.

Define a new shutup call specific to this codec and control the pins
there more precisely.  Also, add the power-save enable/disable
sequences in the resume and the new shutup calls.

Signed-off-by: default avatarKailang Yang <kailang@realtek.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 9bfb2844
Loading
Loading
Loading
Loading
+36 −1
Original line number Original line Diff line number Diff line
@@ -2712,6 +2712,13 @@ static int alc269_resume(struct hda_codec *codec)
	hda_call_check_power_status(codec, 0x01);
	hda_call_check_power_status(codec, 0x01);
	if (spec->has_alc5505_dsp)
	if (spec->has_alc5505_dsp)
		alc5505_dsp_resume(codec);
		alc5505_dsp_resume(codec);

	/* clear the power-save mode for ALC283 */
	if (codec->vendor_id == 0x10ec0283) {
		alc_write_coef_idx(codec, 0x4, 0xaf01);
		alc_write_coef_idx(codec, 0x6, 0x2104);
	}

	return 0;
	return 0;
}
}
#endif /* CONFIG_PM */
#endif /* CONFIG_PM */
@@ -3775,6 +3782,30 @@ static void alc269_fill_coef(struct hda_codec *codec)
	alc_write_coef_idx(codec, 0x4, val | (1<<11));
	alc_write_coef_idx(codec, 0x4, val | (1<<11));
}
}


/* don't clear mic pin; otherwise it results in noise in D3 */
static void alc283_headset_shutup(struct hda_codec *codec)
{
	int i;

	if (codec->bus->shutdown)
		return;

	for (i = 0; i < codec->init_pins.used; i++) {
		struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
		/* use read here for syncing after issuing each verb */
		if (pin->nid != 0x19)
			snd_hda_codec_read(codec, pin->nid, 0,
					   AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
	}

	alc_write_coef_idx(codec, 0x4, 0x0f01); /* power save */
	alc_write_coef_idx(codec, 0x6, 0x2100); /* power save */
	snd_hda_codec_write(codec, 0x19, 0,
			AC_VERB_SET_PIN_WIDGET_CONTROL,
			PIN_VREFHIZ);
	codec->pins_shutup = 1;
}

/*
/*
 */
 */
static int patch_alc269(struct hda_codec *codec)
static int patch_alc269(struct hda_codec *codec)
@@ -3789,6 +3820,9 @@ static int patch_alc269(struct hda_codec *codec)
	spec = codec->spec;
	spec = codec->spec;
	spec->gen.shared_mic_vref_pin = 0x18;
	spec->gen.shared_mic_vref_pin = 0x18;


	if (codec->vendor_id == 0x10ec0283)
		spec->shutup = alc283_headset_shutup;

	snd_hda_pick_fixup(codec, alc269_fixup_models,
	snd_hda_pick_fixup(codec, alc269_fixup_models,
		       alc269_fixup_tbl, alc269_fixups);
		       alc269_fixup_tbl, alc269_fixups);
	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
@@ -3862,6 +3896,7 @@ static int patch_alc269(struct hda_codec *codec)
	codec->patch_ops.suspend = alc269_suspend;
	codec->patch_ops.suspend = alc269_suspend;
	codec->patch_ops.resume = alc269_resume;
	codec->patch_ops.resume = alc269_resume;
#endif
#endif
	if (!spec->shutup)
		spec->shutup = alc269_shutup;
		spec->shutup = alc269_shutup;


	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
	snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);