2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for Realtek ALC codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@just42.net>
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <linux/dmi.h>
31 #include <linux/module.h>
32 #include <sound/core.h>
33 #include <sound/jack.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
36 #include "hda_auto_parser.h"
38 #include "hda_generic.h"
40 /* unsol event tags */
41 #define ALC_DCVOL_EVENT 0x08
44 #define GPIO_MASK 0x03
46 /* extra amp-initialization sequence types */
55 struct alc_customize_define {
57 unsigned char port_connectivity;
58 unsigned char check_sum;
59 unsigned char customization;
60 unsigned char external_amp;
61 unsigned int enable_pcbeep:1;
62 unsigned int platform_type:1;
64 unsigned int override:1;
65 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
69 struct hda_gen_spec gen; /* must be at head */
71 /* codec parameterization */
72 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
73 unsigned int num_mixers;
74 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
76 struct alc_customize_define cdefine;
77 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
79 /* inverted dmic fix */
80 unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */
81 unsigned int inv_dmic_muted:1; /* R-ch of inv d-mic is muted? */
82 hda_nid_t inv_dmic_pin;
84 /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
85 int mute_led_polarity;
86 hda_nid_t mute_led_nid;
88 unsigned int gpio_led; /* used for alc269_fixup_hp_gpio_led() */
91 void (*init_hook)(struct hda_codec *codec);
93 void (*power_hook)(struct hda_codec *codec);
95 void (*shutup)(struct hda_codec *codec);
98 int codec_variant; /* flag for other variants */
102 unsigned int pll_coef_idx, pll_coef_bit;
107 * Append the given mixer and verb elements for the later use
108 * The mixer array is referred in build_controls(), and init_verbs are
111 static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
113 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
115 spec->mixers[spec->num_mixers++] = mix;
119 * GPIO setup tables, used in initialization
121 /* Enable GPIO mask and set output */
122 static const struct hda_verb alc_gpio1_init_verbs[] = {
123 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
124 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
125 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
129 static const struct hda_verb alc_gpio2_init_verbs[] = {
130 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
131 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
132 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
136 static const struct hda_verb alc_gpio3_init_verbs[] = {
137 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
138 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
139 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
144 * Fix hardware PLL issue
145 * On some codecs, the analog PLL gating control must be off while
146 * the default value is 1.
148 static void alc_fix_pll(struct hda_codec *codec)
150 struct alc_spec *spec = codec->spec;
155 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
157 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
158 AC_VERB_GET_PROC_COEF, 0);
159 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
161 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
162 val & ~(1 << spec->pll_coef_bit));
165 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
166 unsigned int coef_idx, unsigned int coef_bit)
168 struct alc_spec *spec = codec->spec;
170 spec->pll_coef_idx = coef_idx;
171 spec->pll_coef_bit = coef_bit;
175 /* update the master volume per volume-knob's unsol event */
176 static void alc_update_knob_master(struct hda_codec *codec, struct hda_jack_tbl *jack)
179 struct snd_kcontrol *kctl;
180 struct snd_ctl_elem_value *uctl;
182 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
185 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
188 val = snd_hda_codec_read(codec, jack->nid, 0,
189 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
190 val &= HDA_AMP_VOLMASK;
191 uctl->value.integer.value[0] = val;
192 uctl->value.integer.value[1] = val;
193 kctl->put(kctl, uctl);
197 static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
199 /* For some reason, the res given from ALC880 is broken.
200 Here we adjust it properly. */
201 snd_hda_jack_unsol_event(codec, res >> 2);
204 /* additional initialization for ALC888 variants */
205 static void alc888_coef_init(struct hda_codec *codec)
209 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
210 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
211 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
212 if ((tmp & 0xf0) == 0x20)
214 snd_hda_codec_read(codec, 0x20, 0,
215 AC_VERB_SET_PROC_COEF, 0x830);
218 snd_hda_codec_read(codec, 0x20, 0,
219 AC_VERB_SET_PROC_COEF, 0x3030);
222 /* additional initialization for ALC889 variants */
223 static void alc889_coef_init(struct hda_codec *codec)
227 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
228 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
229 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
230 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
233 /* turn on/off EAPD control (only if available) */
234 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
236 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
238 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
239 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
243 /* turn on/off EAPD controls of the codec */
244 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
246 /* We currently only handle front, HP */
247 static hda_nid_t pins[] = {
248 0x0f, 0x10, 0x14, 0x15, 0
251 for (p = pins; *p; p++)
252 set_eapd(codec, *p, on);
255 /* generic shutup callback;
256 * just turning off EPAD and a little pause for avoiding pop-noise
258 static void alc_eapd_shutup(struct hda_codec *codec)
260 alc_auto_setup_eapd(codec, false);
264 /* generic EAPD initialization */
265 static void alc_auto_init_amp(struct hda_codec *codec, int type)
269 alc_auto_setup_eapd(codec, true);
272 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
275 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
278 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
280 case ALC_INIT_DEFAULT:
281 switch (codec->vendor_id) {
283 snd_hda_codec_write(codec, 0x1a, 0,
284 AC_VERB_SET_COEF_INDEX, 7);
285 tmp = snd_hda_codec_read(codec, 0x1a, 0,
286 AC_VERB_GET_PROC_COEF, 0);
287 snd_hda_codec_write(codec, 0x1a, 0,
288 AC_VERB_SET_COEF_INDEX, 7);
289 snd_hda_codec_write(codec, 0x1a, 0,
290 AC_VERB_SET_PROC_COEF,
299 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
300 alc889_coef_init(codec);
303 alc888_coef_init(codec);
305 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
308 snd_hda_codec_write(codec, 0x20, 0,
309 AC_VERB_SET_COEF_INDEX, 7);
310 tmp = snd_hda_codec_read(codec, 0x20, 0,
311 AC_VERB_GET_PROC_COEF, 0);
312 snd_hda_codec_write(codec, 0x20, 0,
313 AC_VERB_SET_COEF_INDEX, 7);
314 snd_hda_codec_write(codec, 0x20, 0,
315 AC_VERB_SET_PROC_COEF,
326 * Realtek SSID verification
329 /* Could be any non-zero and even value. When used as fixup, tells
330 * the driver to ignore any present sku defines.
332 #define ALC_FIXUP_SKU_IGNORE (2)
334 static void alc_fixup_sku_ignore(struct hda_codec *codec,
335 const struct hda_fixup *fix, int action)
337 struct alc_spec *spec = codec->spec;
338 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
339 spec->cdefine.fixup = 1;
340 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
344 static int alc_auto_parse_customize_define(struct hda_codec *codec)
346 unsigned int ass, tmp, i;
348 struct alc_spec *spec = codec->spec;
350 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
352 if (spec->cdefine.fixup) {
353 ass = spec->cdefine.sku_cfg;
354 if (ass == ALC_FIXUP_SKU_IGNORE)
359 ass = codec->subsystem_id & 0xffff;
360 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
364 if (codec->vendor_id == 0x10ec0260)
366 ass = snd_hda_codec_get_pincfg(codec, nid);
369 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
370 codec->chip_name, ass);
376 for (i = 1; i < 16; i++) {
380 if (((ass >> 16) & 0xf) != tmp)
383 spec->cdefine.port_connectivity = ass >> 30;
384 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
385 spec->cdefine.check_sum = (ass >> 16) & 0xf;
386 spec->cdefine.customization = ass >> 8;
388 spec->cdefine.sku_cfg = ass;
389 spec->cdefine.external_amp = (ass & 0x38) >> 3;
390 spec->cdefine.platform_type = (ass & 0x4) >> 2;
391 spec->cdefine.swap = (ass & 0x2) >> 1;
392 spec->cdefine.override = ass & 0x1;
394 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
395 nid, spec->cdefine.sku_cfg);
396 snd_printd("SKU: port_connectivity=0x%x\n",
397 spec->cdefine.port_connectivity);
398 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
399 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
400 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
401 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
402 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
403 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
404 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
409 /* return the position of NID in the list, or -1 if not found */
410 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
413 for (i = 0; i < nums; i++)
418 /* return true if the given NID is found in the list */
419 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
421 return find_idx_in_nid_list(nid, list, nums) >= 0;
424 /* check subsystem ID and set up device-specific initialization;
425 * return 1 if initialized, 0 if invalid SSID
427 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
428 * 31 ~ 16 : Manufacture ID
430 * 7 ~ 0 : Assembly ID
431 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
433 static int alc_subsystem_id(struct hda_codec *codec,
434 hda_nid_t porta, hda_nid_t porte,
435 hda_nid_t portd, hda_nid_t porti)
437 unsigned int ass, tmp, i;
439 struct alc_spec *spec = codec->spec;
441 if (spec->cdefine.fixup) {
442 ass = spec->cdefine.sku_cfg;
443 if (ass == ALC_FIXUP_SKU_IGNORE)
448 ass = codec->subsystem_id & 0xffff;
449 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
452 /* invalid SSID, check the special NID pin defcfg instead */
454 * 31~30 : port connectivity
457 * 19~16 : Check sum (15:1)
462 if (codec->vendor_id == 0x10ec0260)
464 ass = snd_hda_codec_get_pincfg(codec, nid);
465 snd_printd("realtek: No valid SSID, "
466 "checking pincfg 0x%08x for NID 0x%x\n",
470 if ((ass >> 30) != 1) /* no physical connection */
475 for (i = 1; i < 16; i++) {
479 if (((ass >> 16) & 0xf) != tmp)
482 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
483 ass & 0xffff, codec->vendor_id);
487 * 2 : 0 --> Desktop, 1 --> Laptop
488 * 3~5 : External Amplifier control
491 tmp = (ass & 0x38) >> 3; /* external Amp control */
494 spec->init_amp = ALC_INIT_GPIO1;
497 spec->init_amp = ALC_INIT_GPIO2;
500 spec->init_amp = ALC_INIT_GPIO3;
504 spec->init_amp = ALC_INIT_DEFAULT;
508 /* is laptop or Desktop and enable the function "Mute internal speaker
509 * when the external headphone out jack is plugged"
514 * 10~8 : Jack location
515 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
517 * 15 : 1 --> enable the function "Mute internal speaker
518 * when the external headphone out jack is plugged"
520 if (!spec->gen.autocfg.hp_pins[0] &&
521 !(spec->gen.autocfg.line_out_pins[0] &&
522 spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
524 tmp = (ass >> 11) & 0x3; /* HP to chassis */
535 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
536 spec->gen.autocfg.line_outs))
538 spec->gen.autocfg.hp_pins[0] = nid;
543 /* Check the validity of ALC subsystem-id
544 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
545 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
547 if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) {
548 struct alc_spec *spec = codec->spec;
549 snd_printd("realtek: "
550 "Enable default setup for auto mode as fallback\n");
551 spec->init_amp = ALC_INIT_DEFAULT;
556 * COEF access helper functions
558 static int alc_read_coef_idx(struct hda_codec *codec,
559 unsigned int coef_idx)
562 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
564 val = snd_hda_codec_read(codec, 0x20, 0,
565 AC_VERB_GET_PROC_COEF, 0);
569 static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
570 unsigned int coef_val)
572 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
574 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
578 /* a special bypass for COEF 0; read the cached value at the second time */
579 static unsigned int alc_get_coef0(struct hda_codec *codec)
581 struct alc_spec *spec = codec->spec;
583 spec->coef0 = alc_read_coef_idx(codec, 0);
590 static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx)
592 struct hda_gen_spec *spec = codec->spec;
593 if (spec->dyn_adc_switch)
594 adc_idx = spec->dyn_adc_idx[imux_idx];
595 return spec->adc_nids[adc_idx];
598 static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx)
600 struct alc_spec *spec = codec->spec;
601 struct hda_input_mux *imux = &spec->gen.input_mux;
602 struct nid_path *path;
607 for (i = 0; i < imux->num_items; i++) {
608 if (spec->gen.imux_pins[i] == spec->inv_dmic_pin)
611 if (i >= imux->num_items)
614 path = snd_hda_get_nid_path(codec, spec->inv_dmic_pin,
615 get_adc_nid(codec, adc_idx, i));
616 val = path->ctls[NID_PATH_MUTE_CTL];
619 nid = get_amp_nid_(val);
620 dir = get_amp_direction_(val);
621 parm = AC_AMP_SET_RIGHT |
622 (dir == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT);
624 /* flush all cached amps at first */
625 snd_hda_codec_flush_cache(codec);
627 /* we care only right channel */
628 val = snd_hda_codec_amp_read(codec, nid, 1, dir, 0);
629 if (val & 0x80) /* if already muted, we don't need to touch */
632 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
637 * Inverted digital-mic handling
639 * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch"
640 * gives the additional mute only to the right channel of the digital mic
641 * capture stream. This is a workaround for avoiding the almost silence
642 * by summing the stereo stream from some (known to be ForteMedia)
645 * The logic is to call alc_inv_dmic_sync() after each action (possibly)
646 * modifying ADC amp. When the mute flag is set, it mutes the R-channel
647 * without caching so that the cache can still keep the original value.
648 * The cached value is then restored when the flag is set off or any other
649 * than d-mic is used as the current input source.
651 static void alc_inv_dmic_sync(struct hda_codec *codec, bool force)
653 struct alc_spec *spec = codec->spec;
656 if (!spec->inv_dmic_fixup)
658 if (!spec->inv_dmic_muted && !force)
660 nums = spec->gen.dyn_adc_switch ? 1 : spec->gen.num_adc_nids;
661 for (src = 0; src < nums; src++) {
662 bool dmic_fixup = false;
664 if (spec->inv_dmic_muted &&
665 spec->gen.imux_pins[spec->gen.cur_mux[src]] == spec->inv_dmic_pin)
667 if (!dmic_fixup && !force)
669 alc_inv_dmic_sync_adc(codec, src);
673 static void alc_inv_dmic_hook(struct hda_codec *codec,
674 struct snd_ctl_elem_value *ucontrol)
676 alc_inv_dmic_sync(codec, false);
679 static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol,
680 struct snd_ctl_elem_value *ucontrol)
682 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
683 struct alc_spec *spec = codec->spec;
685 ucontrol->value.integer.value[0] = !spec->inv_dmic_muted;
689 static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol,
690 struct snd_ctl_elem_value *ucontrol)
692 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
693 struct alc_spec *spec = codec->spec;
694 unsigned int val = !ucontrol->value.integer.value[0];
696 if (val == spec->inv_dmic_muted)
698 spec->inv_dmic_muted = val;
699 alc_inv_dmic_sync(codec, true);
703 static const struct snd_kcontrol_new alc_inv_dmic_sw = {
704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
705 .name = "Inverted Internal Mic Capture Switch",
706 .info = snd_ctl_boolean_mono_info,
707 .get = alc_inv_dmic_sw_get,
708 .put = alc_inv_dmic_sw_put,
711 static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid)
713 struct alc_spec *spec = codec->spec;
715 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &alc_inv_dmic_sw))
717 spec->inv_dmic_fixup = 1;
718 spec->inv_dmic_muted = 0;
719 spec->inv_dmic_pin = nid;
720 spec->gen.cap_sync_hook = alc_inv_dmic_hook;
724 /* typically the digital mic is put at node 0x12 */
725 static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec,
726 const struct hda_fixup *fix, int action)
728 if (action == HDA_FIXUP_ACT_PROBE)
729 alc_add_inv_dmic_mixer(codec, 0x12);
733 #ifdef CONFIG_SND_HDA_INPUT_BEEP
734 /* additional beep mixers; the actual parameters are overwritten at build */
735 static const struct snd_kcontrol_new alc_beep_mixer[] = {
736 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
737 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
742 static int alc_build_controls(struct hda_codec *codec)
744 struct alc_spec *spec = codec->spec;
747 err = snd_hda_gen_build_controls(codec);
751 for (i = 0; i < spec->num_mixers; i++) {
752 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
757 #ifdef CONFIG_SND_HDA_INPUT_BEEP
758 /* create beep controls if needed */
759 if (spec->beep_amp) {
760 const struct snd_kcontrol_new *knew;
761 for (knew = alc_beep_mixer; knew->name; knew++) {
762 struct snd_kcontrol *kctl;
763 kctl = snd_ctl_new1(knew, codec);
766 kctl->private_value = spec->beep_amp;
767 err = snd_hda_ctl_add(codec, 0, kctl);
774 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
783 static int alc_init(struct hda_codec *codec)
785 struct alc_spec *spec = codec->spec;
788 spec->init_hook(codec);
791 alc_auto_init_amp(codec, spec->init_amp);
793 snd_hda_gen_init(codec);
795 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
800 static inline void alc_shutup(struct hda_codec *codec)
802 struct alc_spec *spec = codec->spec;
804 if (spec && spec->shutup)
806 snd_hda_shutup_pins(codec);
809 #define alc_free snd_hda_gen_free
812 static void alc_power_eapd(struct hda_codec *codec)
814 alc_auto_setup_eapd(codec, false);
817 static int alc_suspend(struct hda_codec *codec)
819 struct alc_spec *spec = codec->spec;
821 if (spec && spec->power_hook)
822 spec->power_hook(codec);
828 static int alc_resume(struct hda_codec *codec)
830 msleep(150); /* to avoid pop noise */
831 codec->patch_ops.init(codec);
832 snd_hda_codec_resume_amp(codec);
833 snd_hda_codec_resume_cache(codec);
834 alc_inv_dmic_sync(codec, true);
835 hda_call_check_power_status(codec, 0x01);
842 static const struct hda_codec_ops alc_patch_ops = {
843 .build_controls = alc_build_controls,
844 .build_pcms = snd_hda_gen_build_pcms,
847 .unsol_event = snd_hda_jack_unsol_event,
849 .resume = alc_resume,
850 .suspend = alc_suspend,
851 .check_power_status = snd_hda_gen_check_power_status,
853 .reboot_notify = alc_shutup,
857 /* replace the codec chip_name with the given string */
858 static int alc_codec_rename(struct hda_codec *codec, const char *name)
860 kfree(codec->chip_name);
861 codec->chip_name = kstrdup(name, GFP_KERNEL);
862 if (!codec->chip_name) {
870 * Rename codecs appropriately from COEF value
872 struct alc_codec_rename_table {
873 unsigned int vendor_id;
874 unsigned short coef_mask;
875 unsigned short coef_bits;
879 static struct alc_codec_rename_table rename_tbl[] = {
880 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
881 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
882 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
883 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
884 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
885 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
886 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
887 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
888 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
889 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
890 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
891 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
892 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
893 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
894 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
898 static int alc_codec_rename_from_preset(struct hda_codec *codec)
900 const struct alc_codec_rename_table *p;
902 for (p = rename_tbl; p->vendor_id; p++) {
903 if (p->vendor_id != codec->vendor_id)
905 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
906 return alc_codec_rename(codec, p->name);
913 * Digital-beep handlers
915 #ifdef CONFIG_SND_HDA_INPUT_BEEP
916 #define set_beep_amp(spec, nid, idx, dir) \
917 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
919 static const struct snd_pci_quirk beep_white_list[] = {
920 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
921 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
922 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
923 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
924 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
925 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
926 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
927 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
931 static inline int has_cdefine_beep(struct hda_codec *codec)
933 struct alc_spec *spec = codec->spec;
934 const struct snd_pci_quirk *q;
935 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
938 return spec->cdefine.enable_pcbeep;
941 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
942 #define has_cdefine_beep(codec) 0
945 /* parse the BIOS configuration and set up the alc_spec */
946 /* return 1 if successful, 0 if the proper config is not found,
947 * or a negative error code
949 static int alc_parse_auto_config(struct hda_codec *codec,
950 const hda_nid_t *ignore_nids,
951 const hda_nid_t *ssid_nids)
953 struct alc_spec *spec = codec->spec;
954 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
957 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
963 alc_ssid_check(codec, ssid_nids);
965 err = snd_hda_gen_parse_auto_config(codec, cfg);
972 /* common preparation job for alc_spec */
973 static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
975 struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
981 snd_hda_gen_spec_init(&spec->gen);
982 spec->gen.mixer_nid = mixer_nid;
983 spec->gen.own_eapd_ctl = 1;
984 codec->single_adc_amp = 1;
985 /* FIXME: do we need this for all Realtek codec models? */
986 codec->spdif_status_reset = 1;
988 err = alc_codec_rename_from_preset(codec);
996 static int alc880_parse_auto_config(struct hda_codec *codec)
998 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
999 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
1000 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1009 ALC880_FIXUP_MEDION_RIM,
1012 ALC880_FIXUP_EAPD_COEF,
1013 ALC880_FIXUP_TCL_S700,
1014 ALC880_FIXUP_VOL_KNOB,
1015 ALC880_FIXUP_FUJITSU,
1017 ALC880_FIXUP_UNIWILL,
1018 ALC880_FIXUP_UNIWILL_DIG,
1020 ALC880_FIXUP_3ST_BASE,
1022 ALC880_FIXUP_3ST_DIG,
1023 ALC880_FIXUP_5ST_BASE,
1025 ALC880_FIXUP_5ST_DIG,
1026 ALC880_FIXUP_6ST_BASE,
1028 ALC880_FIXUP_6ST_DIG,
1029 ALC880_FIXUP_6ST_AUTOMUTE,
1032 /* enable the volume-knob widget support on NID 0x21 */
1033 static void alc880_fixup_vol_knob(struct hda_codec *codec,
1034 const struct hda_fixup *fix, int action)
1036 if (action == HDA_FIXUP_ACT_PROBE)
1037 snd_hda_jack_detect_enable_callback(codec, 0x21, ALC_DCVOL_EVENT, alc_update_knob_master);
1040 static const struct hda_fixup alc880_fixups[] = {
1041 [ALC880_FIXUP_GPIO1] = {
1042 .type = HDA_FIXUP_VERBS,
1043 .v.verbs = alc_gpio1_init_verbs,
1045 [ALC880_FIXUP_GPIO2] = {
1046 .type = HDA_FIXUP_VERBS,
1047 .v.verbs = alc_gpio2_init_verbs,
1049 [ALC880_FIXUP_MEDION_RIM] = {
1050 .type = HDA_FIXUP_VERBS,
1051 .v.verbs = (const struct hda_verb[]) {
1052 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1053 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1057 .chain_id = ALC880_FIXUP_GPIO2,
1059 [ALC880_FIXUP_LG] = {
1060 .type = HDA_FIXUP_PINS,
1061 .v.pins = (const struct hda_pintbl[]) {
1062 /* disable bogus unused pins */
1063 { 0x16, 0x411111f0 },
1064 { 0x18, 0x411111f0 },
1065 { 0x1a, 0x411111f0 },
1069 [ALC880_FIXUP_W810] = {
1070 .type = HDA_FIXUP_PINS,
1071 .v.pins = (const struct hda_pintbl[]) {
1072 /* disable bogus unused pins */
1073 { 0x17, 0x411111f0 },
1077 .chain_id = ALC880_FIXUP_GPIO2,
1079 [ALC880_FIXUP_EAPD_COEF] = {
1080 .type = HDA_FIXUP_VERBS,
1081 .v.verbs = (const struct hda_verb[]) {
1082 /* change to EAPD mode */
1083 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1084 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1088 [ALC880_FIXUP_TCL_S700] = {
1089 .type = HDA_FIXUP_VERBS,
1090 .v.verbs = (const struct hda_verb[]) {
1091 /* change to EAPD mode */
1092 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1093 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
1097 .chain_id = ALC880_FIXUP_GPIO2,
1099 [ALC880_FIXUP_VOL_KNOB] = {
1100 .type = HDA_FIXUP_FUNC,
1101 .v.func = alc880_fixup_vol_knob,
1103 [ALC880_FIXUP_FUJITSU] = {
1104 /* override all pins as BIOS on old Amilo is broken */
1105 .type = HDA_FIXUP_PINS,
1106 .v.pins = (const struct hda_pintbl[]) {
1107 { 0x14, 0x0121411f }, /* HP */
1108 { 0x15, 0x99030120 }, /* speaker */
1109 { 0x16, 0x99030130 }, /* bass speaker */
1110 { 0x17, 0x411111f0 }, /* N/A */
1111 { 0x18, 0x411111f0 }, /* N/A */
1112 { 0x19, 0x01a19950 }, /* mic-in */
1113 { 0x1a, 0x411111f0 }, /* N/A */
1114 { 0x1b, 0x411111f0 }, /* N/A */
1115 { 0x1c, 0x411111f0 }, /* N/A */
1116 { 0x1d, 0x411111f0 }, /* N/A */
1117 { 0x1e, 0x01454140 }, /* SPDIF out */
1121 .chain_id = ALC880_FIXUP_VOL_KNOB,
1123 [ALC880_FIXUP_F1734] = {
1124 /* almost compatible with FUJITSU, but no bass and SPDIF */
1125 .type = HDA_FIXUP_PINS,
1126 .v.pins = (const struct hda_pintbl[]) {
1127 { 0x14, 0x0121411f }, /* HP */
1128 { 0x15, 0x99030120 }, /* speaker */
1129 { 0x16, 0x411111f0 }, /* N/A */
1130 { 0x17, 0x411111f0 }, /* N/A */
1131 { 0x18, 0x411111f0 }, /* N/A */
1132 { 0x19, 0x01a19950 }, /* mic-in */
1133 { 0x1a, 0x411111f0 }, /* N/A */
1134 { 0x1b, 0x411111f0 }, /* N/A */
1135 { 0x1c, 0x411111f0 }, /* N/A */
1136 { 0x1d, 0x411111f0 }, /* N/A */
1137 { 0x1e, 0x411111f0 }, /* N/A */
1141 .chain_id = ALC880_FIXUP_VOL_KNOB,
1143 [ALC880_FIXUP_UNIWILL] = {
1144 /* need to fix HP and speaker pins to be parsed correctly */
1145 .type = HDA_FIXUP_PINS,
1146 .v.pins = (const struct hda_pintbl[]) {
1147 { 0x14, 0x0121411f }, /* HP */
1148 { 0x15, 0x99030120 }, /* speaker */
1149 { 0x16, 0x99030130 }, /* bass speaker */
1153 [ALC880_FIXUP_UNIWILL_DIG] = {
1154 .type = HDA_FIXUP_PINS,
1155 .v.pins = (const struct hda_pintbl[]) {
1156 /* disable bogus unused pins */
1157 { 0x17, 0x411111f0 },
1158 { 0x19, 0x411111f0 },
1159 { 0x1b, 0x411111f0 },
1160 { 0x1f, 0x411111f0 },
1164 [ALC880_FIXUP_Z71V] = {
1165 .type = HDA_FIXUP_PINS,
1166 .v.pins = (const struct hda_pintbl[]) {
1167 /* set up the whole pins as BIOS is utterly broken */
1168 { 0x14, 0x99030120 }, /* speaker */
1169 { 0x15, 0x0121411f }, /* HP */
1170 { 0x16, 0x411111f0 }, /* N/A */
1171 { 0x17, 0x411111f0 }, /* N/A */
1172 { 0x18, 0x01a19950 }, /* mic-in */
1173 { 0x19, 0x411111f0 }, /* N/A */
1174 { 0x1a, 0x01813031 }, /* line-in */
1175 { 0x1b, 0x411111f0 }, /* N/A */
1176 { 0x1c, 0x411111f0 }, /* N/A */
1177 { 0x1d, 0x411111f0 }, /* N/A */
1178 { 0x1e, 0x0144111e }, /* SPDIF */
1182 [ALC880_FIXUP_3ST_BASE] = {
1183 .type = HDA_FIXUP_PINS,
1184 .v.pins = (const struct hda_pintbl[]) {
1185 { 0x14, 0x01014010 }, /* line-out */
1186 { 0x15, 0x411111f0 }, /* N/A */
1187 { 0x16, 0x411111f0 }, /* N/A */
1188 { 0x17, 0x411111f0 }, /* N/A */
1189 { 0x18, 0x01a19c30 }, /* mic-in */
1190 { 0x19, 0x0121411f }, /* HP */
1191 { 0x1a, 0x01813031 }, /* line-in */
1192 { 0x1b, 0x02a19c40 }, /* front-mic */
1193 { 0x1c, 0x411111f0 }, /* N/A */
1194 { 0x1d, 0x411111f0 }, /* N/A */
1195 /* 0x1e is filled in below */
1196 { 0x1f, 0x411111f0 }, /* N/A */
1200 [ALC880_FIXUP_3ST] = {
1201 .type = HDA_FIXUP_PINS,
1202 .v.pins = (const struct hda_pintbl[]) {
1203 { 0x1e, 0x411111f0 }, /* N/A */
1207 .chain_id = ALC880_FIXUP_3ST_BASE,
1209 [ALC880_FIXUP_3ST_DIG] = {
1210 .type = HDA_FIXUP_PINS,
1211 .v.pins = (const struct hda_pintbl[]) {
1212 { 0x1e, 0x0144111e }, /* SPDIF */
1216 .chain_id = ALC880_FIXUP_3ST_BASE,
1218 [ALC880_FIXUP_5ST_BASE] = {
1219 .type = HDA_FIXUP_PINS,
1220 .v.pins = (const struct hda_pintbl[]) {
1221 { 0x14, 0x01014010 }, /* front */
1222 { 0x15, 0x411111f0 }, /* N/A */
1223 { 0x16, 0x01011411 }, /* CLFE */
1224 { 0x17, 0x01016412 }, /* surr */
1225 { 0x18, 0x01a19c30 }, /* mic-in */
1226 { 0x19, 0x0121411f }, /* HP */
1227 { 0x1a, 0x01813031 }, /* line-in */
1228 { 0x1b, 0x02a19c40 }, /* front-mic */
1229 { 0x1c, 0x411111f0 }, /* N/A */
1230 { 0x1d, 0x411111f0 }, /* N/A */
1231 /* 0x1e is filled in below */
1232 { 0x1f, 0x411111f0 }, /* N/A */
1236 [ALC880_FIXUP_5ST] = {
1237 .type = HDA_FIXUP_PINS,
1238 .v.pins = (const struct hda_pintbl[]) {
1239 { 0x1e, 0x411111f0 }, /* N/A */
1243 .chain_id = ALC880_FIXUP_5ST_BASE,
1245 [ALC880_FIXUP_5ST_DIG] = {
1246 .type = HDA_FIXUP_PINS,
1247 .v.pins = (const struct hda_pintbl[]) {
1248 { 0x1e, 0x0144111e }, /* SPDIF */
1252 .chain_id = ALC880_FIXUP_5ST_BASE,
1254 [ALC880_FIXUP_6ST_BASE] = {
1255 .type = HDA_FIXUP_PINS,
1256 .v.pins = (const struct hda_pintbl[]) {
1257 { 0x14, 0x01014010 }, /* front */
1258 { 0x15, 0x01016412 }, /* surr */
1259 { 0x16, 0x01011411 }, /* CLFE */
1260 { 0x17, 0x01012414 }, /* side */
1261 { 0x18, 0x01a19c30 }, /* mic-in */
1262 { 0x19, 0x02a19c40 }, /* front-mic */
1263 { 0x1a, 0x01813031 }, /* line-in */
1264 { 0x1b, 0x0121411f }, /* HP */
1265 { 0x1c, 0x411111f0 }, /* N/A */
1266 { 0x1d, 0x411111f0 }, /* N/A */
1267 /* 0x1e is filled in below */
1268 { 0x1f, 0x411111f0 }, /* N/A */
1272 [ALC880_FIXUP_6ST] = {
1273 .type = HDA_FIXUP_PINS,
1274 .v.pins = (const struct hda_pintbl[]) {
1275 { 0x1e, 0x411111f0 }, /* N/A */
1279 .chain_id = ALC880_FIXUP_6ST_BASE,
1281 [ALC880_FIXUP_6ST_DIG] = {
1282 .type = HDA_FIXUP_PINS,
1283 .v.pins = (const struct hda_pintbl[]) {
1284 { 0x1e, 0x0144111e }, /* SPDIF */
1288 .chain_id = ALC880_FIXUP_6ST_BASE,
1290 [ALC880_FIXUP_6ST_AUTOMUTE] = {
1291 .type = HDA_FIXUP_PINS,
1292 .v.pins = (const struct hda_pintbl[]) {
1293 { 0x1b, 0x0121401f }, /* HP with jack detect */
1296 .chained_before = true,
1297 .chain_id = ALC880_FIXUP_6ST_BASE,
1301 static const struct snd_pci_quirk alc880_fixup_tbl[] = {
1302 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
1303 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
1304 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
1305 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
1306 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
1307 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
1308 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
1309 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
1310 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
1311 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
1312 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
1313 SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
1314 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734),
1315 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
1316 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
1317 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
1318 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1319 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1320 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
1321 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
1323 /* Below is the copied entries from alc880_quirks.c.
1324 * It's not quite sure whether BIOS sets the correct pin-config table
1325 * on these machines, thus they are kept to be compatible with
1326 * the old static quirks. Once when it's confirmed to work without
1327 * these overrides, it'd be better to remove.
1329 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1330 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1331 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1332 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1333 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1334 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1335 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1336 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1337 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1338 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1339 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1340 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1341 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1342 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1343 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1344 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1345 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1346 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1347 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1348 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1349 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1350 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1351 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1352 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1353 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1354 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1355 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1356 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1357 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1358 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1359 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1360 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1361 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1363 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1364 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1365 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1369 static const struct hda_model_fixup alc880_fixup_models[] = {
1370 {.id = ALC880_FIXUP_3ST, .name = "3stack"},
1371 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1372 {.id = ALC880_FIXUP_5ST, .name = "5stack"},
1373 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1374 {.id = ALC880_FIXUP_6ST, .name = "6stack"},
1375 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
1376 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
1382 * OK, here we have finally the patch for ALC880
1384 static int patch_alc880(struct hda_codec *codec)
1386 struct alc_spec *spec;
1389 err = alc_alloc_spec(codec, 0x0b);
1394 spec->gen.need_dac_fix = 1;
1395 spec->gen.beep_nid = 0x01;
1397 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
1399 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1401 /* automatic parse from the BIOS config */
1402 err = alc880_parse_auto_config(codec);
1406 if (!spec->gen.no_analog)
1407 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1409 codec->patch_ops = alc_patch_ops;
1410 codec->patch_ops.unsol_event = alc880_unsol_event;
1413 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1426 static int alc260_parse_auto_config(struct hda_codec *codec)
1428 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
1429 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1430 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
1437 ALC260_FIXUP_HP_DC5750,
1438 ALC260_FIXUP_HP_PIN_0F,
1441 ALC260_FIXUP_GPIO1_TOGGLE,
1442 ALC260_FIXUP_REPLACER,
1443 ALC260_FIXUP_HP_B1900,
1445 ALC260_FIXUP_FSC_S7020,
1446 ALC260_FIXUP_FSC_S7020_JWSE,
1449 static void alc260_gpio1_automute(struct hda_codec *codec)
1451 struct alc_spec *spec = codec->spec;
1452 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
1453 spec->gen.hp_jack_present);
1456 static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1457 const struct hda_fixup *fix, int action)
1459 struct alc_spec *spec = codec->spec;
1460 if (action == HDA_FIXUP_ACT_PROBE) {
1461 /* although the machine has only one output pin, we need to
1462 * toggle GPIO1 according to the jack state
1464 spec->gen.automute_hook = alc260_gpio1_automute;
1465 spec->gen.detect_hp = 1;
1466 spec->gen.automute_speaker = 1;
1467 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1468 snd_hda_jack_detect_enable_callback(codec, 0x0f, HDA_GEN_HP_EVENT,
1469 snd_hda_gen_hp_automute);
1470 snd_hda_add_verbs(codec, alc_gpio1_init_verbs);
1474 static void alc260_fixup_kn1(struct hda_codec *codec,
1475 const struct hda_fixup *fix, int action)
1477 struct alc_spec *spec = codec->spec;
1478 static const struct hda_pintbl pincfgs[] = {
1479 { 0x0f, 0x02214000 }, /* HP/speaker */
1480 { 0x12, 0x90a60160 }, /* int mic */
1481 { 0x13, 0x02a19000 }, /* ext mic */
1482 { 0x18, 0x01446000 }, /* SPDIF out */
1483 /* disable bogus I/O pins */
1484 { 0x10, 0x411111f0 },
1485 { 0x11, 0x411111f0 },
1486 { 0x14, 0x411111f0 },
1487 { 0x15, 0x411111f0 },
1488 { 0x16, 0x411111f0 },
1489 { 0x17, 0x411111f0 },
1490 { 0x19, 0x411111f0 },
1495 case HDA_FIXUP_ACT_PRE_PROBE:
1496 snd_hda_apply_pincfgs(codec, pincfgs);
1498 case HDA_FIXUP_ACT_PROBE:
1499 spec->init_amp = ALC_INIT_NONE;
1504 static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1505 const struct hda_fixup *fix, int action)
1507 struct alc_spec *spec = codec->spec;
1508 if (action == HDA_FIXUP_ACT_PROBE)
1509 spec->init_amp = ALC_INIT_NONE;
1512 static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1513 const struct hda_fixup *fix, int action)
1515 struct alc_spec *spec = codec->spec;
1516 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1517 spec->gen.add_jack_modes = 1;
1518 spec->gen.hp_mic = 1;
1522 static const struct hda_fixup alc260_fixups[] = {
1523 [ALC260_FIXUP_HP_DC5750] = {
1524 .type = HDA_FIXUP_PINS,
1525 .v.pins = (const struct hda_pintbl[]) {
1526 { 0x11, 0x90130110 }, /* speaker */
1530 [ALC260_FIXUP_HP_PIN_0F] = {
1531 .type = HDA_FIXUP_PINS,
1532 .v.pins = (const struct hda_pintbl[]) {
1533 { 0x0f, 0x01214000 }, /* HP */
1537 [ALC260_FIXUP_COEF] = {
1538 .type = HDA_FIXUP_VERBS,
1539 .v.verbs = (const struct hda_verb[]) {
1540 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1541 { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 },
1545 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1547 [ALC260_FIXUP_GPIO1] = {
1548 .type = HDA_FIXUP_VERBS,
1549 .v.verbs = alc_gpio1_init_verbs,
1551 [ALC260_FIXUP_GPIO1_TOGGLE] = {
1552 .type = HDA_FIXUP_FUNC,
1553 .v.func = alc260_fixup_gpio1_toggle,
1555 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1557 [ALC260_FIXUP_REPLACER] = {
1558 .type = HDA_FIXUP_VERBS,
1559 .v.verbs = (const struct hda_verb[]) {
1560 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1561 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
1565 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1567 [ALC260_FIXUP_HP_B1900] = {
1568 .type = HDA_FIXUP_FUNC,
1569 .v.func = alc260_fixup_gpio1_toggle,
1571 .chain_id = ALC260_FIXUP_COEF,
1573 [ALC260_FIXUP_KN1] = {
1574 .type = HDA_FIXUP_FUNC,
1575 .v.func = alc260_fixup_kn1,
1577 [ALC260_FIXUP_FSC_S7020] = {
1578 .type = HDA_FIXUP_FUNC,
1579 .v.func = alc260_fixup_fsc_s7020,
1581 [ALC260_FIXUP_FSC_S7020_JWSE] = {
1582 .type = HDA_FIXUP_FUNC,
1583 .v.func = alc260_fixup_fsc_s7020_jwse,
1585 .chain_id = ALC260_FIXUP_FSC_S7020,
1589 static const struct snd_pci_quirk alc260_fixup_tbl[] = {
1590 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
1591 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
1592 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
1593 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
1594 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
1595 SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
1596 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
1597 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
1598 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
1599 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
1603 static const struct hda_model_fixup alc260_fixup_models[] = {
1604 {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1605 {.id = ALC260_FIXUP_COEF, .name = "coef"},
1606 {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1607 {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1613 static int patch_alc260(struct hda_codec *codec)
1615 struct alc_spec *spec;
1618 err = alc_alloc_spec(codec, 0x07);
1623 /* as quite a few machines require HP amp for speaker outputs,
1624 * it's easier to enable it unconditionally; even if it's unneeded,
1625 * it's almost harmless.
1627 spec->gen.prefer_hp_amp = 1;
1628 spec->gen.beep_nid = 0x01;
1630 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1632 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1634 /* automatic parse from the BIOS config */
1635 err = alc260_parse_auto_config(codec);
1639 if (!spec->gen.no_analog)
1640 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
1642 codec->patch_ops = alc_patch_ops;
1643 spec->shutup = alc_eapd_shutup;
1645 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1656 * ALC882/883/885/888/889 support
1658 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1659 * configuration. Each pin widget can choose any input DACs and a mixer.
1660 * Each ADC is connected from a mixer of all inputs. This makes possible
1661 * 6-channel independent captures.
1663 * In addition, an independent DAC for the multi-playback (not used in this
1671 ALC882_FIXUP_ABIT_AW9D_MAX,
1672 ALC882_FIXUP_LENOVO_Y530,
1673 ALC882_FIXUP_PB_M5210,
1674 ALC882_FIXUP_ACER_ASPIRE_7736,
1675 ALC882_FIXUP_ASUS_W90V,
1677 ALC889_FIXUP_VAIO_TT,
1678 ALC888_FIXUP_EEE1601,
1681 ALC883_FIXUP_ACER_EAPD,
1686 ALC882_FIXUP_ASUS_W2JC,
1687 ALC882_FIXUP_ACER_ASPIRE_4930G,
1688 ALC882_FIXUP_ACER_ASPIRE_8930G,
1689 ALC882_FIXUP_ASPIRE_8930G_VERBS,
1690 ALC885_FIXUP_MACPRO_GPIO,
1691 ALC889_FIXUP_DAC_ROUTE,
1692 ALC889_FIXUP_MBP_VREF,
1693 ALC889_FIXUP_IMAC91_VREF,
1694 ALC882_FIXUP_INV_DMIC,
1695 ALC882_FIXUP_NO_PRIMARY_HP,
1698 static void alc889_fixup_coef(struct hda_codec *codec,
1699 const struct hda_fixup *fix, int action)
1701 if (action != HDA_FIXUP_ACT_INIT)
1703 alc889_coef_init(codec);
1706 /* toggle speaker-output according to the hp-jack state */
1707 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
1709 unsigned int gpiostate, gpiomask, gpiodir;
1711 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1712 AC_VERB_GET_GPIO_DATA, 0);
1715 gpiostate |= (1 << pin);
1717 gpiostate &= ~(1 << pin);
1719 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1720 AC_VERB_GET_GPIO_MASK, 0);
1721 gpiomask |= (1 << pin);
1723 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1724 AC_VERB_GET_GPIO_DIRECTION, 0);
1725 gpiodir |= (1 << pin);
1728 snd_hda_codec_write(codec, codec->afg, 0,
1729 AC_VERB_SET_GPIO_MASK, gpiomask);
1730 snd_hda_codec_write(codec, codec->afg, 0,
1731 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1735 snd_hda_codec_write(codec, codec->afg, 0,
1736 AC_VERB_SET_GPIO_DATA, gpiostate);
1739 /* set up GPIO at initialization */
1740 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1741 const struct hda_fixup *fix, int action)
1743 if (action != HDA_FIXUP_ACT_INIT)
1745 alc882_gpio_mute(codec, 0, 0);
1746 alc882_gpio_mute(codec, 1, 0);
1749 /* Fix the connection of some pins for ALC889:
1750 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1751 * work correctly (bko#42740)
1753 static void alc889_fixup_dac_route(struct hda_codec *codec,
1754 const struct hda_fixup *fix, int action)
1756 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1757 /* fake the connections during parsing the tree */
1758 hda_nid_t conn1[2] = { 0x0c, 0x0d };
1759 hda_nid_t conn2[2] = { 0x0e, 0x0f };
1760 snd_hda_override_conn_list(codec, 0x14, 2, conn1);
1761 snd_hda_override_conn_list(codec, 0x15, 2, conn1);
1762 snd_hda_override_conn_list(codec, 0x18, 2, conn2);
1763 snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
1764 } else if (action == HDA_FIXUP_ACT_PROBE) {
1765 /* restore the connections */
1766 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1767 snd_hda_override_conn_list(codec, 0x14, 5, conn);
1768 snd_hda_override_conn_list(codec, 0x15, 5, conn);
1769 snd_hda_override_conn_list(codec, 0x18, 5, conn);
1770 snd_hda_override_conn_list(codec, 0x1a, 5, conn);
1774 /* Set VREF on HP pin */
1775 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
1776 const struct hda_fixup *fix, int action)
1778 struct alc_spec *spec = codec->spec;
1779 static hda_nid_t nids[2] = { 0x14, 0x15 };
1782 if (action != HDA_FIXUP_ACT_INIT)
1784 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1785 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1786 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1788 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1789 val |= AC_PINCTL_VREF_80;
1790 snd_hda_set_pin_ctl(codec, nids[i], val);
1791 spec->gen.keep_vref_in_automute = 1;
1796 /* Set VREF on speaker pins on imac91 */
1797 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
1798 const struct hda_fixup *fix, int action)
1800 struct alc_spec *spec = codec->spec;
1801 static hda_nid_t nids[2] = { 0x18, 0x1a };
1804 if (action != HDA_FIXUP_ACT_INIT)
1806 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1808 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1809 val |= AC_PINCTL_VREF_50;
1810 snd_hda_set_pin_ctl(codec, nids[i], val);
1812 spec->gen.keep_vref_in_automute = 1;
1815 /* Don't take HP output as primary
1816 * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
1817 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
1819 static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
1820 const struct hda_fixup *fix, int action)
1822 struct alc_spec *spec = codec->spec;
1823 if (action == HDA_FIXUP_ACT_PRE_PROBE)
1824 spec->gen.no_primary_hp = 1;
1827 static const struct hda_fixup alc882_fixups[] = {
1828 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
1829 .type = HDA_FIXUP_PINS,
1830 .v.pins = (const struct hda_pintbl[]) {
1831 { 0x15, 0x01080104 }, /* side */
1832 { 0x16, 0x01011012 }, /* rear */
1833 { 0x17, 0x01016011 }, /* clfe */
1837 [ALC882_FIXUP_LENOVO_Y530] = {
1838 .type = HDA_FIXUP_PINS,
1839 .v.pins = (const struct hda_pintbl[]) {
1840 { 0x15, 0x99130112 }, /* rear int speakers */
1841 { 0x16, 0x99130111 }, /* subwoofer */
1845 [ALC882_FIXUP_PB_M5210] = {
1846 .type = HDA_FIXUP_PINCTLS,
1847 .v.pins = (const struct hda_pintbl[]) {
1848 { 0x19, PIN_VREF50 },
1852 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
1853 .type = HDA_FIXUP_FUNC,
1854 .v.func = alc_fixup_sku_ignore,
1856 [ALC882_FIXUP_ASUS_W90V] = {
1857 .type = HDA_FIXUP_PINS,
1858 .v.pins = (const struct hda_pintbl[]) {
1859 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
1863 [ALC889_FIXUP_CD] = {
1864 .type = HDA_FIXUP_PINS,
1865 .v.pins = (const struct hda_pintbl[]) {
1866 { 0x1c, 0x993301f0 }, /* CD */
1870 [ALC889_FIXUP_VAIO_TT] = {
1871 .type = HDA_FIXUP_PINS,
1872 .v.pins = (const struct hda_pintbl[]) {
1873 { 0x17, 0x90170111 }, /* hidden surround speaker */
1877 [ALC888_FIXUP_EEE1601] = {
1878 .type = HDA_FIXUP_VERBS,
1879 .v.verbs = (const struct hda_verb[]) {
1880 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
1881 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
1885 [ALC882_FIXUP_EAPD] = {
1886 .type = HDA_FIXUP_VERBS,
1887 .v.verbs = (const struct hda_verb[]) {
1888 /* change to EAPD mode */
1889 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1890 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1894 [ALC883_FIXUP_EAPD] = {
1895 .type = HDA_FIXUP_VERBS,
1896 .v.verbs = (const struct hda_verb[]) {
1897 /* change to EAPD mode */
1898 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1899 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
1903 [ALC883_FIXUP_ACER_EAPD] = {
1904 .type = HDA_FIXUP_VERBS,
1905 .v.verbs = (const struct hda_verb[]) {
1906 /* eanable EAPD on Acer laptops */
1907 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1908 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
1912 [ALC882_FIXUP_GPIO1] = {
1913 .type = HDA_FIXUP_VERBS,
1914 .v.verbs = alc_gpio1_init_verbs,
1916 [ALC882_FIXUP_GPIO2] = {
1917 .type = HDA_FIXUP_VERBS,
1918 .v.verbs = alc_gpio2_init_verbs,
1920 [ALC882_FIXUP_GPIO3] = {
1921 .type = HDA_FIXUP_VERBS,
1922 .v.verbs = alc_gpio3_init_verbs,
1924 [ALC882_FIXUP_ASUS_W2JC] = {
1925 .type = HDA_FIXUP_VERBS,
1926 .v.verbs = alc_gpio1_init_verbs,
1928 .chain_id = ALC882_FIXUP_EAPD,
1930 [ALC889_FIXUP_COEF] = {
1931 .type = HDA_FIXUP_FUNC,
1932 .v.func = alc889_fixup_coef,
1934 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
1935 .type = HDA_FIXUP_PINS,
1936 .v.pins = (const struct hda_pintbl[]) {
1937 { 0x16, 0x99130111 }, /* CLFE speaker */
1938 { 0x17, 0x99130112 }, /* surround speaker */
1942 .chain_id = ALC882_FIXUP_GPIO1,
1944 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
1945 .type = HDA_FIXUP_PINS,
1946 .v.pins = (const struct hda_pintbl[]) {
1947 { 0x16, 0x99130111 }, /* CLFE speaker */
1948 { 0x1b, 0x99130112 }, /* surround speaker */
1952 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
1954 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
1955 /* additional init verbs for Acer Aspire 8930G */
1956 .type = HDA_FIXUP_VERBS,
1957 .v.verbs = (const struct hda_verb[]) {
1958 /* Enable all DACs */
1959 /* DAC DISABLE/MUTE 1? */
1960 /* setting bits 1-5 disables DAC nids 0x02-0x06
1961 * apparently. Init=0x38 */
1962 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
1963 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
1964 /* DAC DISABLE/MUTE 2? */
1965 /* some bit here disables the other DACs.
1967 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
1968 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
1970 * This laptop has a stereo digital microphone.
1971 * The mics are only 1cm apart which makes the stereo
1972 * useless. However, either the mic or the ALC889
1973 * makes the signal become a difference/sum signal
1974 * instead of standard stereo, which is annoying.
1975 * So instead we flip this bit which makes the
1976 * codec replicate the sum signal to both channels,
1977 * turning it into a normal mono mic.
1979 /* DMIC_CONTROL? Init value = 0x0001 */
1980 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
1981 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
1982 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1983 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
1987 .chain_id = ALC882_FIXUP_GPIO1,
1989 [ALC885_FIXUP_MACPRO_GPIO] = {
1990 .type = HDA_FIXUP_FUNC,
1991 .v.func = alc885_fixup_macpro_gpio,
1993 [ALC889_FIXUP_DAC_ROUTE] = {
1994 .type = HDA_FIXUP_FUNC,
1995 .v.func = alc889_fixup_dac_route,
1997 [ALC889_FIXUP_MBP_VREF] = {
1998 .type = HDA_FIXUP_FUNC,
1999 .v.func = alc889_fixup_mbp_vref,
2001 .chain_id = ALC882_FIXUP_GPIO1,
2003 [ALC889_FIXUP_IMAC91_VREF] = {
2004 .type = HDA_FIXUP_FUNC,
2005 .v.func = alc889_fixup_imac91_vref,
2007 .chain_id = ALC882_FIXUP_GPIO1,
2009 [ALC882_FIXUP_INV_DMIC] = {
2010 .type = HDA_FIXUP_FUNC,
2011 .v.func = alc_fixup_inv_dmic_0x12,
2013 [ALC882_FIXUP_NO_PRIMARY_HP] = {
2014 .type = HDA_FIXUP_FUNC,
2015 .v.func = alc882_fixup_no_primary_hp,
2019 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2020 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2021 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2022 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2023 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2024 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2025 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
2026 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2027 ALC882_FIXUP_ACER_ASPIRE_4930G),
2028 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2029 ALC882_FIXUP_ACER_ASPIRE_4930G),
2030 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2031 ALC882_FIXUP_ACER_ASPIRE_8930G),
2032 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2033 ALC882_FIXUP_ACER_ASPIRE_8930G),
2034 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2035 ALC882_FIXUP_ACER_ASPIRE_4930G),
2036 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2037 ALC882_FIXUP_ACER_ASPIRE_4930G),
2038 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2039 ALC882_FIXUP_ACER_ASPIRE_4930G),
2040 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
2041 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2042 ALC882_FIXUP_ACER_ASPIRE_4930G),
2043 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
2044 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
2045 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
2046 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
2047 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
2048 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
2049 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
2050 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
2051 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
2052 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
2054 /* All Apple entries are in codec SSIDs */
2055 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2056 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2057 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2058 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO),
2059 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2060 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
2061 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2062 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
2063 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
2064 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF),
2065 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF),
2066 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2067 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2068 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
2069 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2070 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2071 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
2072 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO),
2073 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
2074 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2075 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2076 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF),
2078 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
2079 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
2080 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
2081 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD),
2082 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
2083 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2084 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
2085 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
2086 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
2090 static const struct hda_model_fixup alc882_fixup_models[] = {
2091 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2092 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2093 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
2094 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
2095 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
2100 * BIOS auto configuration
2102 /* almost identical with ALC880 parser... */
2103 static int alc882_parse_auto_config(struct hda_codec *codec)
2105 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
2106 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2107 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
2112 static int patch_alc882(struct hda_codec *codec)
2114 struct alc_spec *spec;
2117 err = alc_alloc_spec(codec, 0x0b);
2123 switch (codec->vendor_id) {
2128 /* ALC883 and variants */
2129 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2133 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2135 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2137 alc_auto_parse_customize_define(codec);
2139 if (has_cdefine_beep(codec))
2140 spec->gen.beep_nid = 0x01;
2142 /* automatic parse from the BIOS config */
2143 err = alc882_parse_auto_config(codec);
2147 if (!spec->gen.no_analog && spec->gen.beep_nid)
2148 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2150 codec->patch_ops = alc_patch_ops;
2152 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2165 static int alc262_parse_auto_config(struct hda_codec *codec)
2167 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
2168 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2169 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
2176 ALC262_FIXUP_FSC_H270,
2177 ALC262_FIXUP_FSC_S7110,
2178 ALC262_FIXUP_HP_Z200,
2180 ALC262_FIXUP_LENOVO_3000,
2182 ALC262_FIXUP_BENQ_T31,
2183 ALC262_FIXUP_INV_DMIC,
2186 static const struct hda_fixup alc262_fixups[] = {
2187 [ALC262_FIXUP_FSC_H270] = {
2188 .type = HDA_FIXUP_PINS,
2189 .v.pins = (const struct hda_pintbl[]) {
2190 { 0x14, 0x99130110 }, /* speaker */
2191 { 0x15, 0x0221142f }, /* front HP */
2192 { 0x1b, 0x0121141f }, /* rear HP */
2196 [ALC262_FIXUP_FSC_S7110] = {
2197 .type = HDA_FIXUP_PINS,
2198 .v.pins = (const struct hda_pintbl[]) {
2199 { 0x15, 0x90170110 }, /* speaker */
2203 .chain_id = ALC262_FIXUP_BENQ,
2205 [ALC262_FIXUP_HP_Z200] = {
2206 .type = HDA_FIXUP_PINS,
2207 .v.pins = (const struct hda_pintbl[]) {
2208 { 0x16, 0x99130120 }, /* internal speaker */
2212 [ALC262_FIXUP_TYAN] = {
2213 .type = HDA_FIXUP_PINS,
2214 .v.pins = (const struct hda_pintbl[]) {
2215 { 0x14, 0x1993e1f0 }, /* int AUX */
2219 [ALC262_FIXUP_LENOVO_3000] = {
2220 .type = HDA_FIXUP_PINCTLS,
2221 .v.pins = (const struct hda_pintbl[]) {
2222 { 0x19, PIN_VREF50 },
2226 .chain_id = ALC262_FIXUP_BENQ,
2228 [ALC262_FIXUP_BENQ] = {
2229 .type = HDA_FIXUP_VERBS,
2230 .v.verbs = (const struct hda_verb[]) {
2231 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2232 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2236 [ALC262_FIXUP_BENQ_T31] = {
2237 .type = HDA_FIXUP_VERBS,
2238 .v.verbs = (const struct hda_verb[]) {
2239 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2240 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2244 [ALC262_FIXUP_INV_DMIC] = {
2245 .type = HDA_FIXUP_FUNC,
2246 .v.func = alc_fixup_inv_dmic_0x12,
2250 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
2251 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
2252 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
2253 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
2254 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2255 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
2256 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
2257 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2258 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
2262 static const struct hda_model_fixup alc262_fixup_models[] = {
2263 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2269 static int patch_alc262(struct hda_codec *codec)
2271 struct alc_spec *spec;
2274 err = alc_alloc_spec(codec, 0x0b);
2279 spec->gen.shared_mic_vref_pin = 0x18;
2282 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
2287 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
2288 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
2289 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
2290 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
2293 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2295 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2297 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2299 alc_auto_parse_customize_define(codec);
2301 if (has_cdefine_beep(codec))
2302 spec->gen.beep_nid = 0x01;
2304 /* automatic parse from the BIOS config */
2305 err = alc262_parse_auto_config(codec);
2309 if (!spec->gen.no_analog && spec->gen.beep_nid)
2310 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2312 codec->patch_ops = alc_patch_ops;
2313 spec->shutup = alc_eapd_shutup;
2315 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2327 /* bind Beep switches of both NID 0x0f and 0x10 */
2328 static const struct hda_bind_ctls alc268_bind_beep_sw = {
2329 .ops = &snd_hda_bind_sw,
2331 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
2332 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
2337 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2338 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2339 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
2343 /* set PCBEEP vol = 0, mute connections */
2344 static const struct hda_verb alc268_beep_init_verbs[] = {
2345 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2346 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2347 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2352 ALC268_FIXUP_INV_DMIC,
2353 ALC268_FIXUP_HP_EAPD,
2356 static const struct hda_fixup alc268_fixups[] = {
2357 [ALC268_FIXUP_INV_DMIC] = {
2358 .type = HDA_FIXUP_FUNC,
2359 .v.func = alc_fixup_inv_dmic_0x12,
2361 [ALC268_FIXUP_HP_EAPD] = {
2362 .type = HDA_FIXUP_VERBS,
2363 .v.verbs = (const struct hda_verb[]) {
2364 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2370 static const struct hda_model_fixup alc268_fixup_models[] = {
2371 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
2372 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2376 static const struct snd_pci_quirk alc268_fixup_tbl[] = {
2377 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
2378 /* below is codec SSID since multiple Toshiba laptops have the
2379 * same PCI SSID 1179:ff00
2381 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
2386 * BIOS auto configuration
2388 static int alc268_parse_auto_config(struct hda_codec *codec)
2390 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2391 return alc_parse_auto_config(codec, NULL, alc268_ssids);
2396 static int patch_alc268(struct hda_codec *codec)
2398 struct alc_spec *spec;
2401 /* ALC268 has no aa-loopback mixer */
2402 err = alc_alloc_spec(codec, 0);
2407 spec->gen.beep_nid = 0x01;
2409 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2410 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2412 /* automatic parse from the BIOS config */
2413 err = alc268_parse_auto_config(codec);
2417 if (err > 0 && !spec->gen.no_analog &&
2418 spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2419 add_mixer(spec, alc268_beep_mixer);
2420 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
2421 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2422 /* override the amp caps for beep generator */
2423 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2424 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2425 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2426 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2427 (0 << AC_AMPCAP_MUTE_SHIFT));
2430 codec->patch_ops = alc_patch_ops;
2431 spec->shutup = alc_eapd_shutup;
2433 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2446 static int playback_pcm_open(struct hda_pcm_stream *hinfo,
2447 struct hda_codec *codec,
2448 struct snd_pcm_substream *substream)
2450 struct hda_gen_spec *spec = codec->spec;
2451 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2455 static int playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2456 struct hda_codec *codec,
2457 unsigned int stream_tag,
2458 unsigned int format,
2459 struct snd_pcm_substream *substream)
2461 struct hda_gen_spec *spec = codec->spec;
2462 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2463 stream_tag, format, substream);
2466 static int playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2467 struct hda_codec *codec,
2468 struct snd_pcm_substream *substream)
2470 struct hda_gen_spec *spec = codec->spec;
2471 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2474 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
2478 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2479 /* NID is set in alc_build_pcms */
2481 .open = playback_pcm_open,
2482 .prepare = playback_pcm_prepare,
2483 .cleanup = playback_pcm_cleanup
2487 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
2491 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2492 /* NID is set in alc_build_pcms */
2495 /* different alc269-variants */
2497 ALC269_TYPE_ALC269VA,
2498 ALC269_TYPE_ALC269VB,
2499 ALC269_TYPE_ALC269VC,
2500 ALC269_TYPE_ALC269VD,
2507 * BIOS auto configuration
2509 static int alc269_parse_auto_config(struct hda_codec *codec)
2511 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
2512 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
2513 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2514 struct alc_spec *spec = codec->spec;
2515 const hda_nid_t *ssids;
2517 switch (spec->codec_variant) {
2518 case ALC269_TYPE_ALC269VA:
2519 case ALC269_TYPE_ALC269VC:
2520 case ALC269_TYPE_ALC280:
2521 case ALC269_TYPE_ALC284:
2522 ssids = alc269va_ssids;
2524 case ALC269_TYPE_ALC269VB:
2525 case ALC269_TYPE_ALC269VD:
2526 case ALC269_TYPE_ALC282:
2527 ssids = alc269_ssids;
2530 ssids = alc269_ssids;
2534 return alc_parse_auto_config(codec, alc269_ignore, ssids);
2537 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
2539 int val = alc_read_coef_idx(codec, 0x04);
2544 alc_write_coef_idx(codec, 0x04, val);
2547 static void alc269_shutup(struct hda_codec *codec)
2549 struct alc_spec *spec = codec->spec;
2551 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
2554 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2555 alc269vb_toggle_power_output(codec, 0);
2556 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2557 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
2563 static int alc269_resume(struct hda_codec *codec)
2565 struct alc_spec *spec = codec->spec;
2567 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2568 alc269vb_toggle_power_output(codec, 0);
2569 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2570 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
2574 codec->patch_ops.init(codec);
2576 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2577 alc269vb_toggle_power_output(codec, 1);
2578 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2579 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
2583 snd_hda_codec_resume_amp(codec);
2584 snd_hda_codec_resume_cache(codec);
2585 hda_call_check_power_status(codec, 0x01);
2588 #endif /* CONFIG_PM */
2590 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
2591 const struct hda_fixup *fix, int action)
2593 struct alc_spec *spec = codec->spec;
2595 if (action == HDA_FIXUP_ACT_PRE_PROBE)
2596 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
2599 static void alc269_fixup_hweq(struct hda_codec *codec,
2600 const struct hda_fixup *fix, int action)
2604 if (action != HDA_FIXUP_ACT_INIT)
2606 coef = alc_read_coef_idx(codec, 0x1e);
2607 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
2610 static void alc271_fixup_dmic(struct hda_codec *codec,
2611 const struct hda_fixup *fix, int action)
2613 static const struct hda_verb verbs[] = {
2614 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
2615 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
2620 if (strcmp(codec->chip_name, "ALC271X"))
2622 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
2623 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
2624 snd_hda_sequence_write(codec, verbs);
2627 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
2628 const struct hda_fixup *fix, int action)
2630 struct alc_spec *spec = codec->spec;
2632 if (action != HDA_FIXUP_ACT_PROBE)
2635 /* Due to a hardware problem on Lenovo Ideadpad, we need to
2636 * fix the sample rate of analog I/O to 44.1kHz
2638 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
2639 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
2642 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
2643 const struct hda_fixup *fix, int action)
2647 if (action != HDA_FIXUP_ACT_INIT)
2649 /* The digital-mic unit sends PDM (differential signal) instead of
2650 * the standard PCM, thus you can't record a valid mono stream as is.
2651 * Below is a workaround specific to ALC269 to control the dmic
2652 * signal source as mono.
2654 coef = alc_read_coef_idx(codec, 0x07);
2655 alc_write_coef_idx(codec, 0x07, coef | 0x80);
2658 static void alc269_quanta_automute(struct hda_codec *codec)
2660 snd_hda_gen_update_outputs(codec);
2662 snd_hda_codec_write(codec, 0x20, 0,
2663 AC_VERB_SET_COEF_INDEX, 0x0c);
2664 snd_hda_codec_write(codec, 0x20, 0,
2665 AC_VERB_SET_PROC_COEF, 0x680);
2667 snd_hda_codec_write(codec, 0x20, 0,
2668 AC_VERB_SET_COEF_INDEX, 0x0c);
2669 snd_hda_codec_write(codec, 0x20, 0,
2670 AC_VERB_SET_PROC_COEF, 0x480);
2673 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
2674 const struct hda_fixup *fix, int action)
2676 struct alc_spec *spec = codec->spec;
2677 if (action != HDA_FIXUP_ACT_PROBE)
2679 spec->gen.automute_hook = alc269_quanta_automute;
2682 /* update mute-LED according to the speaker mute state via mic VREF pin */
2683 static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
2685 struct hda_codec *codec = private_data;
2686 struct alc_spec *spec = codec->spec;
2687 unsigned int pinval;
2689 if (spec->mute_led_polarity)
2691 pinval = AC_PINCTL_IN_EN |
2692 (enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80);
2693 if (spec->mute_led_nid)
2694 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
2697 static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
2698 const struct hda_fixup *fix, int action)
2700 struct alc_spec *spec = codec->spec;
2701 const struct dmi_device *dev = NULL;
2703 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2706 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
2708 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
2710 if (pin < 0x0a || pin >= 0x10)
2712 spec->mute_led_polarity = pol;
2713 spec->mute_led_nid = pin - 0x0a + 0x18;
2714 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
2715 spec->gen.vmaster_mute_enum = 1;
2716 snd_printd("Detected mute LED for %x:%d\n", spec->mute_led_nid,
2717 spec->mute_led_polarity);
2722 static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
2723 const struct hda_fixup *fix, int action)
2725 struct alc_spec *spec = codec->spec;
2726 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2727 spec->mute_led_polarity = 0;
2728 spec->mute_led_nid = 0x18;
2729 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
2730 spec->gen.vmaster_mute_enum = 1;
2734 static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
2735 const struct hda_fixup *fix, int action)
2737 struct alc_spec *spec = codec->spec;
2738 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2739 spec->mute_led_polarity = 0;
2740 spec->mute_led_nid = 0x19;
2741 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
2742 spec->gen.vmaster_mute_enum = 1;
2746 /* turn on/off mute LED per vmaster hook */
2747 static void alc269_fixup_hp_gpio_mute_hook(void *private_data, int enabled)
2749 struct hda_codec *codec = private_data;
2750 struct alc_spec *spec = codec->spec;
2751 unsigned int oldval = spec->gpio_led;
2754 spec->gpio_led &= ~0x08;
2756 spec->gpio_led |= 0x08;
2757 if (spec->gpio_led != oldval)
2758 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
2762 /* turn on/off mic-mute LED per capture hook */
2763 static void alc269_fixup_hp_gpio_mic_mute_hook(struct hda_codec *codec,
2764 struct snd_ctl_elem_value *ucontrol)
2766 struct alc_spec *spec = codec->spec;
2767 unsigned int oldval = spec->gpio_led;
2772 if (ucontrol->value.integer.value[0] ||
2773 ucontrol->value.integer.value[1])
2774 spec->gpio_led &= ~0x10;
2776 spec->gpio_led |= 0x10;
2777 if (spec->gpio_led != oldval)
2778 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
2782 static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
2783 const struct hda_fixup *fix, int action)
2785 struct alc_spec *spec = codec->spec;
2786 static const struct hda_verb gpio_init[] = {
2787 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
2788 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
2792 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2793 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
2794 spec->gen.cap_sync_hook = alc269_fixup_hp_gpio_mic_mute_hook;
2796 snd_hda_add_verbs(codec, gpio_init);
2800 static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
2801 const struct hda_fixup *fix,
2804 struct alc_spec *spec = codec->spec;
2806 if (action == HDA_FIXUP_ACT_PROBE) {
2807 if (snd_BUG_ON(!spec->gen.am_entry[1].pin ||
2808 !spec->gen.autocfg.hp_pins[0]))
2810 snd_hda_jack_set_gating_jack(codec, spec->gen.am_entry[1].pin,
2811 spec->gen.autocfg.hp_pins[0]);
2816 ALC269_FIXUP_SONY_VAIO,
2817 ALC275_FIXUP_SONY_VAIO_GPIO2,
2818 ALC269_FIXUP_DELL_M101Z,
2819 ALC269_FIXUP_SKU_IGNORE,
2820 ALC269_FIXUP_ASUS_G73JW,
2821 ALC269_FIXUP_LENOVO_EAPD,
2822 ALC275_FIXUP_SONY_HWEQ,
2824 ALC269_FIXUP_PCM_44K,
2825 ALC269_FIXUP_STEREO_DMIC,
2826 ALC269_FIXUP_QUANTA_MUTE,
2827 ALC269_FIXUP_LIFEBOOK,
2830 ALC269VB_FIXUP_AMIC,
2831 ALC269VB_FIXUP_DMIC,
2832 ALC269_FIXUP_HP_MUTE_LED,
2833 ALC269_FIXUP_HP_MUTE_LED_MIC1,
2834 ALC269_FIXUP_HP_MUTE_LED_MIC2,
2835 ALC269_FIXUP_HP_GPIO_LED,
2836 ALC269_FIXUP_INV_DMIC,
2837 ALC269_FIXUP_LENOVO_DOCK,
2838 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
2839 ALC271_FIXUP_AMIC_MIC2,
2840 ALC271_FIXUP_HP_GATE_MIC_JACK,
2843 static const struct hda_fixup alc269_fixups[] = {
2844 [ALC269_FIXUP_SONY_VAIO] = {
2845 .type = HDA_FIXUP_PINCTLS,
2846 .v.pins = (const struct hda_pintbl[]) {
2847 {0x19, PIN_VREFGRD},
2851 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
2852 .type = HDA_FIXUP_VERBS,
2853 .v.verbs = (const struct hda_verb[]) {
2854 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
2855 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
2856 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
2860 .chain_id = ALC269_FIXUP_SONY_VAIO
2862 [ALC269_FIXUP_DELL_M101Z] = {
2863 .type = HDA_FIXUP_VERBS,
2864 .v.verbs = (const struct hda_verb[]) {
2865 /* Enables internal speaker */
2866 {0x20, AC_VERB_SET_COEF_INDEX, 13},
2867 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
2871 [ALC269_FIXUP_SKU_IGNORE] = {
2872 .type = HDA_FIXUP_FUNC,
2873 .v.func = alc_fixup_sku_ignore,
2875 [ALC269_FIXUP_ASUS_G73JW] = {
2876 .type = HDA_FIXUP_PINS,
2877 .v.pins = (const struct hda_pintbl[]) {
2878 { 0x17, 0x99130111 }, /* subwoofer */
2882 [ALC269_FIXUP_LENOVO_EAPD] = {
2883 .type = HDA_FIXUP_VERBS,
2884 .v.verbs = (const struct hda_verb[]) {
2885 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
2889 [ALC275_FIXUP_SONY_HWEQ] = {
2890 .type = HDA_FIXUP_FUNC,
2891 .v.func = alc269_fixup_hweq,
2893 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
2895 [ALC271_FIXUP_DMIC] = {
2896 .type = HDA_FIXUP_FUNC,
2897 .v.func = alc271_fixup_dmic,
2899 [ALC269_FIXUP_PCM_44K] = {
2900 .type = HDA_FIXUP_FUNC,
2901 .v.func = alc269_fixup_pcm_44k,
2903 .chain_id = ALC269_FIXUP_QUANTA_MUTE
2905 [ALC269_FIXUP_STEREO_DMIC] = {
2906 .type = HDA_FIXUP_FUNC,
2907 .v.func = alc269_fixup_stereo_dmic,
2909 [ALC269_FIXUP_QUANTA_MUTE] = {
2910 .type = HDA_FIXUP_FUNC,
2911 .v.func = alc269_fixup_quanta_mute,
2913 [ALC269_FIXUP_LIFEBOOK] = {
2914 .type = HDA_FIXUP_PINS,
2915 .v.pins = (const struct hda_pintbl[]) {
2916 { 0x1a, 0x2101103f }, /* dock line-out */
2917 { 0x1b, 0x23a11040 }, /* dock mic-in */
2921 .chain_id = ALC269_FIXUP_QUANTA_MUTE
2923 [ALC269_FIXUP_AMIC] = {
2924 .type = HDA_FIXUP_PINS,
2925 .v.pins = (const struct hda_pintbl[]) {
2926 { 0x14, 0x99130110 }, /* speaker */
2927 { 0x15, 0x0121401f }, /* HP out */
2928 { 0x18, 0x01a19c20 }, /* mic */
2929 { 0x19, 0x99a3092f }, /* int-mic */
2933 [ALC269_FIXUP_DMIC] = {
2934 .type = HDA_FIXUP_PINS,
2935 .v.pins = (const struct hda_pintbl[]) {
2936 { 0x12, 0x99a3092f }, /* int-mic */
2937 { 0x14, 0x99130110 }, /* speaker */
2938 { 0x15, 0x0121401f }, /* HP out */
2939 { 0x18, 0x01a19c20 }, /* mic */
2943 [ALC269VB_FIXUP_AMIC] = {
2944 .type = HDA_FIXUP_PINS,
2945 .v.pins = (const struct hda_pintbl[]) {
2946 { 0x14, 0x99130110 }, /* speaker */
2947 { 0x18, 0x01a19c20 }, /* mic */
2948 { 0x19, 0x99a3092f }, /* int-mic */
2949 { 0x21, 0x0121401f }, /* HP out */
2953 [ALC269VB_FIXUP_DMIC] = {
2954 .type = HDA_FIXUP_PINS,
2955 .v.pins = (const struct hda_pintbl[]) {
2956 { 0x12, 0x99a3092f }, /* int-mic */
2957 { 0x14, 0x99130110 }, /* speaker */
2958 { 0x18, 0x01a19c20 }, /* mic */
2959 { 0x21, 0x0121401f }, /* HP out */
2963 [ALC269_FIXUP_HP_MUTE_LED] = {
2964 .type = HDA_FIXUP_FUNC,
2965 .v.func = alc269_fixup_hp_mute_led,
2967 [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
2968 .type = HDA_FIXUP_FUNC,
2969 .v.func = alc269_fixup_hp_mute_led_mic1,
2971 [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
2972 .type = HDA_FIXUP_FUNC,
2973 .v.func = alc269_fixup_hp_mute_led_mic2,
2975 [ALC269_FIXUP_HP_GPIO_LED] = {
2976 .type = HDA_FIXUP_FUNC,
2977 .v.func = alc269_fixup_hp_gpio_led,
2979 [ALC269_FIXUP_INV_DMIC] = {
2980 .type = HDA_FIXUP_FUNC,
2981 .v.func = alc_fixup_inv_dmic_0x12,
2983 [ALC269_FIXUP_LENOVO_DOCK] = {
2984 .type = HDA_FIXUP_PINS,
2985 .v.pins = (const struct hda_pintbl[]) {
2986 { 0x19, 0x23a11040 }, /* dock mic */
2987 { 0x1b, 0x2121103f }, /* dock headphone */
2991 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
2993 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
2994 .type = HDA_FIXUP_FUNC,
2995 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
2997 [ALC271_FIXUP_AMIC_MIC2] = {
2998 .type = HDA_FIXUP_PINS,
2999 .v.pins = (const struct hda_pintbl[]) {
3000 { 0x14, 0x99130110 }, /* speaker */
3001 { 0x19, 0x01a19c20 }, /* mic */
3002 { 0x1b, 0x99a7012f }, /* int-mic */
3003 { 0x21, 0x0121401f }, /* HP out */
3007 [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
3008 .type = HDA_FIXUP_FUNC,
3009 .v.func = alc271_hp_gate_mic_jack,
3011 .chain_id = ALC271_FIXUP_AMIC_MIC2,
3015 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
3016 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
3017 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
3018 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
3019 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
3020 SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
3021 SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
3022 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
3023 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC),
3024 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC),
3025 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
3026 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
3027 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
3028 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
3029 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
3030 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
3031 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
3032 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
3033 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
3034 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
3035 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
3036 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
3037 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
3038 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
3039 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
3040 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
3041 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
3042 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
3043 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
3044 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
3045 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
3046 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
3047 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
3048 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
3049 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
3050 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
3051 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
3052 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
3055 /* Below is a quirk table taken from the old code.
3056 * Basically the device should work as is without the fixup table.
3057 * If BIOS doesn't give a proper info, enable the corresponding
3060 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
3062 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
3063 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
3064 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
3065 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
3066 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
3067 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
3068 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
3069 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
3070 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
3071 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
3072 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
3073 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
3074 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
3075 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
3076 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
3077 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
3078 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
3079 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
3080 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
3081 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
3082 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
3083 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
3084 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
3085 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
3086 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
3087 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
3088 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
3089 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
3090 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
3091 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
3092 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
3093 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
3094 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
3095 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
3096 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
3097 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
3098 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
3099 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
3100 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
3105 static const struct hda_model_fixup alc269_fixup_models[] = {
3106 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
3107 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
3108 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
3109 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
3110 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
3111 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
3112 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
3117 static void alc269_fill_coef(struct hda_codec *codec)
3119 struct alc_spec *spec = codec->spec;
3122 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
3125 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
3126 alc_write_coef_idx(codec, 0xf, 0x960b);
3127 alc_write_coef_idx(codec, 0xe, 0x8817);
3130 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
3131 alc_write_coef_idx(codec, 0xf, 0x960b);
3132 alc_write_coef_idx(codec, 0xe, 0x8814);
3135 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
3136 val = alc_read_coef_idx(codec, 0x04);
3137 /* Power up output pin */
3138 alc_write_coef_idx(codec, 0x04, val | (1<<11));
3141 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
3142 val = alc_read_coef_idx(codec, 0xd);
3143 if ((val & 0x0c00) >> 10 != 0x1) {
3144 /* Capless ramp up clock control */
3145 alc_write_coef_idx(codec, 0xd, val | (1<<10));
3147 val = alc_read_coef_idx(codec, 0x17);
3148 if ((val & 0x01c0) >> 6 != 0x4) {
3149 /* Class D power on reset */
3150 alc_write_coef_idx(codec, 0x17, val | (1<<7));
3154 val = alc_read_coef_idx(codec, 0xd); /* Class D */
3155 alc_write_coef_idx(codec, 0xd, val | (1<<14));
3157 val = alc_read_coef_idx(codec, 0x4); /* HP */
3158 alc_write_coef_idx(codec, 0x4, val | (1<<11));
3163 static int patch_alc269(struct hda_codec *codec)
3165 struct alc_spec *spec;
3168 err = alc_alloc_spec(codec, 0x0b);
3173 spec->gen.shared_mic_vref_pin = 0x18;
3175 snd_hda_pick_fixup(codec, alc269_fixup_models,
3176 alc269_fixup_tbl, alc269_fixups);
3177 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3179 alc_auto_parse_customize_define(codec);
3181 if (has_cdefine_beep(codec))
3182 spec->gen.beep_nid = 0x01;
3184 switch (codec->vendor_id) {
3186 spec->codec_variant = ALC269_TYPE_ALC269VA;
3187 switch (alc_get_coef0(codec) & 0x00f0) {
3189 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
3190 spec->cdefine.platform_type == 1)
3191 err = alc_codec_rename(codec, "ALC271X");
3192 spec->codec_variant = ALC269_TYPE_ALC269VB;
3195 if (codec->bus->pci->subsystem_vendor == 0x17aa &&
3196 codec->bus->pci->subsystem_device == 0x21f3)
3197 err = alc_codec_rename(codec, "ALC3202");
3198 spec->codec_variant = ALC269_TYPE_ALC269VC;
3201 spec->codec_variant = ALC269_TYPE_ALC269VD;
3204 alc_fix_pll_init(codec, 0x20, 0x04, 15);
3208 spec->init_hook = alc269_fill_coef;
3209 alc269_fill_coef(codec);
3214 spec->codec_variant = ALC269_TYPE_ALC280;
3219 spec->codec_variant = ALC269_TYPE_ALC282;
3223 spec->codec_variant = ALC269_TYPE_ALC284;
3227 /* automatic parse from the BIOS config */
3228 err = alc269_parse_auto_config(codec);
3232 if (!spec->gen.no_analog && spec->gen.beep_nid)
3233 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
3235 codec->patch_ops = alc_patch_ops;
3237 codec->patch_ops.resume = alc269_resume;
3239 spec->shutup = alc269_shutup;
3241 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3254 static int alc861_parse_auto_config(struct hda_codec *codec)
3256 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
3257 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
3258 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
3261 /* Pin config fixes */
3263 ALC861_FIXUP_FSC_AMILO_PI1505,
3264 ALC861_FIXUP_AMP_VREF_0F,
3265 ALC861_FIXUP_NO_JACK_DETECT,
3266 ALC861_FIXUP_ASUS_A6RP,
3269 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
3270 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
3271 const struct hda_fixup *fix, int action)
3273 struct alc_spec *spec = codec->spec;
3276 if (action != HDA_FIXUP_ACT_INIT)
3278 val = snd_hda_codec_get_pin_target(codec, 0x0f);
3279 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
3280 val |= AC_PINCTL_IN_EN;
3281 val |= AC_PINCTL_VREF_50;
3282 snd_hda_set_pin_ctl(codec, 0x0f, val);
3283 spec->gen.keep_vref_in_automute = 1;
3286 /* suppress the jack-detection */
3287 static void alc_fixup_no_jack_detect(struct hda_codec *codec,
3288 const struct hda_fixup *fix, int action)
3290 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3291 codec->no_jack_detect = 1;
3294 static const struct hda_fixup alc861_fixups[] = {
3295 [ALC861_FIXUP_FSC_AMILO_PI1505] = {
3296 .type = HDA_FIXUP_PINS,
3297 .v.pins = (const struct hda_pintbl[]) {
3298 { 0x0b, 0x0221101f }, /* HP */
3299 { 0x0f, 0x90170310 }, /* speaker */
3303 [ALC861_FIXUP_AMP_VREF_0F] = {
3304 .type = HDA_FIXUP_FUNC,
3305 .v.func = alc861_fixup_asus_amp_vref_0f,
3307 [ALC861_FIXUP_NO_JACK_DETECT] = {
3308 .type = HDA_FIXUP_FUNC,
3309 .v.func = alc_fixup_no_jack_detect,
3311 [ALC861_FIXUP_ASUS_A6RP] = {
3312 .type = HDA_FIXUP_FUNC,
3313 .v.func = alc861_fixup_asus_amp_vref_0f,
3315 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
3319 static const struct snd_pci_quirk alc861_fixup_tbl[] = {
3320 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
3321 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
3322 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
3323 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
3324 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
3325 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
3331 static int patch_alc861(struct hda_codec *codec)
3333 struct alc_spec *spec;
3336 err = alc_alloc_spec(codec, 0x15);
3341 spec->gen.beep_nid = 0x23;
3343 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
3344 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3346 /* automatic parse from the BIOS config */
3347 err = alc861_parse_auto_config(codec);
3351 if (!spec->gen.no_analog)
3352 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
3354 codec->patch_ops = alc_patch_ops;
3356 spec->power_hook = alc_power_eapd;
3359 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3373 * In addition, an independent DAC
3375 static int alc861vd_parse_auto_config(struct hda_codec *codec)
3377 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
3378 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3379 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
3383 ALC660VD_FIX_ASUS_GPIO1,
3384 ALC861VD_FIX_DALLAS,
3387 /* exclude VREF80 */
3388 static void alc861vd_fixup_dallas(struct hda_codec *codec,
3389 const struct hda_fixup *fix, int action)
3391 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3392 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
3393 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
3397 static const struct hda_fixup alc861vd_fixups[] = {
3398 [ALC660VD_FIX_ASUS_GPIO1] = {
3399 .type = HDA_FIXUP_VERBS,
3400 .v.verbs = (const struct hda_verb[]) {
3402 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
3403 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3404 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3408 [ALC861VD_FIX_DALLAS] = {
3409 .type = HDA_FIXUP_FUNC,
3410 .v.func = alc861vd_fixup_dallas,
3414 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
3415 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
3416 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
3417 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
3423 static int patch_alc861vd(struct hda_codec *codec)
3425 struct alc_spec *spec;
3428 err = alc_alloc_spec(codec, 0x0b);
3433 spec->gen.beep_nid = 0x23;
3435 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
3436 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3438 /* automatic parse from the BIOS config */
3439 err = alc861vd_parse_auto_config(codec);
3443 if (!spec->gen.no_analog)
3444 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
3446 codec->patch_ops = alc_patch_ops;
3448 spec->shutup = alc_eapd_shutup;
3450 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3462 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
3463 * configuration. Each pin widget can choose any input DACs and a mixer.
3464 * Each ADC is connected from a mixer of all inputs. This makes possible
3465 * 6-channel independent captures.
3467 * In addition, an independent DAC for the multi-playback (not used in this
3472 * BIOS auto configuration
3475 static int alc662_parse_auto_config(struct hda_codec *codec)
3477 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
3478 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
3479 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3480 const hda_nid_t *ssids;
3482 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
3483 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
3484 ssids = alc663_ssids;
3486 ssids = alc662_ssids;
3487 return alc_parse_auto_config(codec, alc662_ignore, ssids);
3490 static void alc272_fixup_mario(struct hda_codec *codec,
3491 const struct hda_fixup *fix, int action)
3493 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3495 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
3496 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
3497 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
3498 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3499 (0 << AC_AMPCAP_MUTE_SHIFT)))
3501 "hda_codec: failed to override amp caps for NID 0x2\n");
3505 ALC662_FIXUP_ASPIRE,
3506 ALC662_FIXUP_IDEAPAD,
3508 ALC662_FIXUP_CZC_P10T,
3509 ALC662_FIXUP_SKU_IGNORE,
3510 ALC662_FIXUP_HP_RP5800,
3511 ALC662_FIXUP_ASUS_MODE1,
3512 ALC662_FIXUP_ASUS_MODE2,
3513 ALC662_FIXUP_ASUS_MODE3,
3514 ALC662_FIXUP_ASUS_MODE4,
3515 ALC662_FIXUP_ASUS_MODE5,
3516 ALC662_FIXUP_ASUS_MODE6,
3517 ALC662_FIXUP_ASUS_MODE7,
3518 ALC662_FIXUP_ASUS_MODE8,
3519 ALC662_FIXUP_NO_JACK_DETECT,
3520 ALC662_FIXUP_ZOTAC_Z68,
3521 ALC662_FIXUP_INV_DMIC,
3524 static const struct hda_fixup alc662_fixups[] = {
3525 [ALC662_FIXUP_ASPIRE] = {
3526 .type = HDA_FIXUP_PINS,
3527 .v.pins = (const struct hda_pintbl[]) {
3528 { 0x15, 0x99130112 }, /* subwoofer */
3532 [ALC662_FIXUP_IDEAPAD] = {
3533 .type = HDA_FIXUP_PINS,
3534 .v.pins = (const struct hda_pintbl[]) {
3535 { 0x17, 0x99130112 }, /* subwoofer */
3539 [ALC272_FIXUP_MARIO] = {
3540 .type = HDA_FIXUP_FUNC,
3541 .v.func = alc272_fixup_mario,
3543 [ALC662_FIXUP_CZC_P10T] = {
3544 .type = HDA_FIXUP_VERBS,
3545 .v.verbs = (const struct hda_verb[]) {
3546 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
3550 [ALC662_FIXUP_SKU_IGNORE] = {
3551 .type = HDA_FIXUP_FUNC,
3552 .v.func = alc_fixup_sku_ignore,
3554 [ALC662_FIXUP_HP_RP5800] = {
3555 .type = HDA_FIXUP_PINS,
3556 .v.pins = (const struct hda_pintbl[]) {
3557 { 0x14, 0x0221201f }, /* HP out */
3561 .chain_id = ALC662_FIXUP_SKU_IGNORE
3563 [ALC662_FIXUP_ASUS_MODE1] = {
3564 .type = HDA_FIXUP_PINS,
3565 .v.pins = (const struct hda_pintbl[]) {
3566 { 0x14, 0x99130110 }, /* speaker */
3567 { 0x18, 0x01a19c20 }, /* mic */
3568 { 0x19, 0x99a3092f }, /* int-mic */
3569 { 0x21, 0x0121401f }, /* HP out */
3573 .chain_id = ALC662_FIXUP_SKU_IGNORE
3575 [ALC662_FIXUP_ASUS_MODE2] = {
3576 .type = HDA_FIXUP_PINS,
3577 .v.pins = (const struct hda_pintbl[]) {
3578 { 0x14, 0x99130110 }, /* speaker */
3579 { 0x18, 0x01a19820 }, /* mic */
3580 { 0x19, 0x99a3092f }, /* int-mic */
3581 { 0x1b, 0x0121401f }, /* HP out */
3585 .chain_id = ALC662_FIXUP_SKU_IGNORE
3587 [ALC662_FIXUP_ASUS_MODE3] = {
3588 .type = HDA_FIXUP_PINS,
3589 .v.pins = (const struct hda_pintbl[]) {
3590 { 0x14, 0x99130110 }, /* speaker */
3591 { 0x15, 0x0121441f }, /* HP */
3592 { 0x18, 0x01a19840 }, /* mic */
3593 { 0x19, 0x99a3094f }, /* int-mic */
3594 { 0x21, 0x01211420 }, /* HP2 */
3598 .chain_id = ALC662_FIXUP_SKU_IGNORE
3600 [ALC662_FIXUP_ASUS_MODE4] = {
3601 .type = HDA_FIXUP_PINS,
3602 .v.pins = (const struct hda_pintbl[]) {
3603 { 0x14, 0x99130110 }, /* speaker */
3604 { 0x16, 0x99130111 }, /* speaker */
3605 { 0x18, 0x01a19840 }, /* mic */
3606 { 0x19, 0x99a3094f }, /* int-mic */
3607 { 0x21, 0x0121441f }, /* HP */
3611 .chain_id = ALC662_FIXUP_SKU_IGNORE
3613 [ALC662_FIXUP_ASUS_MODE5] = {
3614 .type = HDA_FIXUP_PINS,
3615 .v.pins = (const struct hda_pintbl[]) {
3616 { 0x14, 0x99130110 }, /* speaker */
3617 { 0x15, 0x0121441f }, /* HP */
3618 { 0x16, 0x99130111 }, /* speaker */
3619 { 0x18, 0x01a19840 }, /* mic */
3620 { 0x19, 0x99a3094f }, /* int-mic */
3624 .chain_id = ALC662_FIXUP_SKU_IGNORE
3626 [ALC662_FIXUP_ASUS_MODE6] = {
3627 .type = HDA_FIXUP_PINS,
3628 .v.pins = (const struct hda_pintbl[]) {
3629 { 0x14, 0x99130110 }, /* speaker */
3630 { 0x15, 0x01211420 }, /* HP2 */
3631 { 0x18, 0x01a19840 }, /* mic */
3632 { 0x19, 0x99a3094f }, /* int-mic */
3633 { 0x1b, 0x0121441f }, /* HP */
3637 .chain_id = ALC662_FIXUP_SKU_IGNORE
3639 [ALC662_FIXUP_ASUS_MODE7] = {
3640 .type = HDA_FIXUP_PINS,
3641 .v.pins = (const struct hda_pintbl[]) {
3642 { 0x14, 0x99130110 }, /* speaker */
3643 { 0x17, 0x99130111 }, /* speaker */
3644 { 0x18, 0x01a19840 }, /* mic */
3645 { 0x19, 0x99a3094f }, /* int-mic */
3646 { 0x1b, 0x01214020 }, /* HP */
3647 { 0x21, 0x0121401f }, /* HP */
3651 .chain_id = ALC662_FIXUP_SKU_IGNORE
3653 [ALC662_FIXUP_ASUS_MODE8] = {
3654 .type = HDA_FIXUP_PINS,
3655 .v.pins = (const struct hda_pintbl[]) {
3656 { 0x14, 0x99130110 }, /* speaker */
3657 { 0x12, 0x99a30970 }, /* int-mic */
3658 { 0x15, 0x01214020 }, /* HP */
3659 { 0x17, 0x99130111 }, /* speaker */
3660 { 0x18, 0x01a19840 }, /* mic */
3661 { 0x21, 0x0121401f }, /* HP */
3665 .chain_id = ALC662_FIXUP_SKU_IGNORE
3667 [ALC662_FIXUP_NO_JACK_DETECT] = {
3668 .type = HDA_FIXUP_FUNC,
3669 .v.func = alc_fixup_no_jack_detect,
3671 [ALC662_FIXUP_ZOTAC_Z68] = {
3672 .type = HDA_FIXUP_PINS,
3673 .v.pins = (const struct hda_pintbl[]) {
3674 { 0x1b, 0x02214020 }, /* Front HP */
3678 [ALC662_FIXUP_INV_DMIC] = {
3679 .type = HDA_FIXUP_FUNC,
3680 .v.func = alc_fixup_inv_dmic_0x12,
3684 static const struct snd_pci_quirk alc662_fixup_tbl[] = {
3685 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
3686 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
3687 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
3688 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
3689 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
3690 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
3691 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
3692 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
3693 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
3694 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
3695 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
3696 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
3697 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
3700 /* Below is a quirk table taken from the old code.
3701 * Basically the device should work as is without the fixup table.
3702 * If BIOS doesn't give a proper info, enable the corresponding
3705 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
3706 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
3707 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
3708 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
3709 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
3710 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3711 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
3712 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
3713 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
3714 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3715 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
3716 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
3717 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
3718 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
3719 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
3720 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3721 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
3722 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
3723 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3724 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
3725 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
3726 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3727 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
3728 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
3729 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
3730 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3731 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
3732 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
3733 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3734 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
3735 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3736 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3737 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
3738 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
3739 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
3740 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
3741 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
3742 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
3743 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
3744 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
3745 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
3746 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
3747 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
3748 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
3749 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
3750 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
3751 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
3752 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
3753 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
3754 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
3759 static const struct hda_model_fixup alc662_fixup_models[] = {
3760 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
3761 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
3762 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
3763 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
3764 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
3765 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
3766 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
3767 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
3768 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
3769 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
3773 static void alc662_fill_coef(struct hda_codec *codec)
3777 coef = alc_get_coef0(codec);
3779 switch (codec->vendor_id) {
3781 if ((coef & 0x00f0) == 0x0030) {
3782 val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */
3783 alc_write_coef_idx(codec, 0x4, val & ~(1<<10));
3793 val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */
3794 alc_write_coef_idx(codec, 0xd, val | (1<<14));
3801 static int patch_alc662(struct hda_codec *codec)
3803 struct alc_spec *spec;
3806 err = alc_alloc_spec(codec, 0x0b);
3812 /* handle multiple HPs as is */
3813 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3815 alc_fix_pll_init(codec, 0x20, 0x04, 15);
3817 spec->init_hook = alc662_fill_coef;
3818 alc662_fill_coef(codec);
3820 snd_hda_pick_fixup(codec, alc662_fixup_models,
3821 alc662_fixup_tbl, alc662_fixups);
3822 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3824 alc_auto_parse_customize_define(codec);
3826 if (has_cdefine_beep(codec))
3827 spec->gen.beep_nid = 0x01;
3829 if ((alc_get_coef0(codec) & (1 << 14)) &&
3830 codec->bus->pci->subsystem_vendor == 0x1025 &&
3831 spec->cdefine.platform_type == 1) {
3832 if (alc_codec_rename(codec, "ALC272X") < 0)
3836 /* automatic parse from the BIOS config */
3837 err = alc662_parse_auto_config(codec);
3841 if (!spec->gen.no_analog && spec->gen.beep_nid) {
3842 switch (codec->vendor_id) {
3844 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
3849 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
3852 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
3857 codec->patch_ops = alc_patch_ops;
3858 spec->shutup = alc_eapd_shutup;
3860 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3873 static int alc680_parse_auto_config(struct hda_codec *codec)
3875 return alc_parse_auto_config(codec, NULL, NULL);
3880 static int patch_alc680(struct hda_codec *codec)
3884 /* ALC680 has no aa-loopback mixer */
3885 err = alc_alloc_spec(codec, 0);
3889 /* automatic parse from the BIOS config */
3890 err = alc680_parse_auto_config(codec);
3896 codec->patch_ops = alc_patch_ops;
3904 static const struct hda_codec_preset snd_hda_preset_realtek[] = {
3905 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
3906 { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
3907 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
3908 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
3909 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
3910 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
3911 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
3912 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
3913 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
3914 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
3915 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
3916 { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 },
3917 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
3918 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
3919 { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
3920 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
3921 { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
3922 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
3923 .patch = patch_alc861 },
3924 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
3925 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
3926 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
3927 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
3928 .patch = patch_alc882 },
3929 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
3930 .patch = patch_alc662 },
3931 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
3932 .patch = patch_alc662 },
3933 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
3934 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
3935 { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 },
3936 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
3937 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
3938 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
3939 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
3940 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
3941 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
3942 .patch = patch_alc882 },
3943 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
3944 .patch = patch_alc882 },
3945 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
3946 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
3947 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
3948 .patch = patch_alc882 },
3949 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
3950 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
3951 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
3952 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
3953 { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 },
3957 MODULE_ALIAS("snd-hda-codec-id:10ec*");
3959 MODULE_LICENSE("GPL");
3960 MODULE_DESCRIPTION("Realtek HD-audio codec");
3962 static struct hda_codec_preset_list realtek_list = {
3963 .preset = snd_hda_preset_realtek,
3964 .owner = THIS_MODULE,
3967 static int __init patch_realtek_init(void)
3969 return snd_hda_add_codec_preset(&realtek_list);
3972 static void __exit patch_realtek_exit(void)
3974 snd_hda_delete_codec_preset(&realtek_list);
3977 module_init(patch_realtek_init)
3978 module_exit(patch_realtek_exit)