]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ALSA: hda - Fix the noise after suspend on ALC283 codec
authorKailang Yang <kailang@realtek.com>
Wed, 24 Jul 2013 12:39:49 +0000 (14:39 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 24 Jul 2013 12:44:40 +0000 (14:44 +0200)
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: Kailang Yang <kailang@realtek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/patch_realtek.c

index dbd59dfc746eaa6b5ec6b7a67e320373f491c644..04a69e3fca479e282495c7254010d93a26c5cac2 100644 (file)
@@ -2712,6 +2712,13 @@ static int alc269_resume(struct hda_codec *codec)
        hda_call_check_power_status(codec, 0x01);
        if (spec->has_alc5505_dsp)
                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;
 }
 #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));
 }
 
+/* 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)
@@ -3789,6 +3820,9 @@ static int patch_alc269(struct hda_codec *codec)
        spec = codec->spec;
        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,
                       alc269_fixup_tbl, alc269_fixups);
        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
@@ -3862,7 +3896,8 @@ static int patch_alc269(struct hda_codec *codec)
        codec->patch_ops.suspend = alc269_suspend;
        codec->patch_ops.resume = alc269_resume;
 #endif
-       spec->shutup = alc269_shutup;
+       if (!spec->shutup)
+               spec->shutup = alc269_shutup;
 
        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);