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 */
56 ALC_HEADSET_MODE_UNKNOWN,
57 ALC_HEADSET_MODE_UNPLUGGED,
58 ALC_HEADSET_MODE_HEADSET,
60 ALC_HEADSET_MODE_HEADPHONE,
64 ALC_HEADSET_TYPE_UNKNOWN,
65 ALC_HEADSET_TYPE_CTIA,
66 ALC_HEADSET_TYPE_OMTP,
69 struct alc_customize_define {
71 unsigned char port_connectivity;
72 unsigned char check_sum;
73 unsigned char customization;
74 unsigned char external_amp;
75 unsigned int enable_pcbeep:1;
76 unsigned int platform_type:1;
78 unsigned int override:1;
79 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
83 struct hda_gen_spec gen; /* must be at head */
85 /* codec parameterization */
86 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
87 unsigned int num_mixers;
88 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
90 struct alc_customize_define cdefine;
91 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
93 /* inverted dmic fix */
94 unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */
95 unsigned int inv_dmic_muted:1; /* R-ch of inv d-mic is muted? */
96 hda_nid_t inv_dmic_pin;
98 /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
99 int mute_led_polarity;
100 hda_nid_t mute_led_nid;
102 unsigned int gpio_led; /* used for alc269_fixup_hp_gpio_led() */
104 hda_nid_t headset_mic_pin;
105 hda_nid_t headphone_mic_pin;
106 int current_headset_mode;
107 int current_headset_type;
110 void (*init_hook)(struct hda_codec *codec);
112 void (*power_hook)(struct hda_codec *codec);
114 void (*shutup)(struct hda_codec *codec);
117 int codec_variant; /* flag for other variants */
121 unsigned int pll_coef_idx, pll_coef_bit;
126 * Append the given mixer and verb elements for the later use
127 * The mixer array is referred in build_controls(), and init_verbs are
130 static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
132 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
134 spec->mixers[spec->num_mixers++] = mix;
138 * GPIO setup tables, used in initialization
140 /* Enable GPIO mask and set output */
141 static const struct hda_verb alc_gpio1_init_verbs[] = {
142 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
143 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
144 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
148 static const struct hda_verb alc_gpio2_init_verbs[] = {
149 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
150 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
151 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
155 static const struct hda_verb alc_gpio3_init_verbs[] = {
156 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
157 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
158 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
163 * Fix hardware PLL issue
164 * On some codecs, the analog PLL gating control must be off while
165 * the default value is 1.
167 static void alc_fix_pll(struct hda_codec *codec)
169 struct alc_spec *spec = codec->spec;
174 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
176 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
177 AC_VERB_GET_PROC_COEF, 0);
180 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
182 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
183 val & ~(1 << spec->pll_coef_bit));
186 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
187 unsigned int coef_idx, unsigned int coef_bit)
189 struct alc_spec *spec = codec->spec;
191 spec->pll_coef_idx = coef_idx;
192 spec->pll_coef_bit = coef_bit;
196 /* update the master volume per volume-knob's unsol event */
197 static void alc_update_knob_master(struct hda_codec *codec, struct hda_jack_tbl *jack)
200 struct snd_kcontrol *kctl;
201 struct snd_ctl_elem_value *uctl;
203 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
206 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
209 val = snd_hda_codec_read(codec, jack->nid, 0,
210 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
211 val &= HDA_AMP_VOLMASK;
212 uctl->value.integer.value[0] = val;
213 uctl->value.integer.value[1] = val;
214 kctl->put(kctl, uctl);
218 static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
220 /* For some reason, the res given from ALC880 is broken.
221 Here we adjust it properly. */
222 snd_hda_jack_unsol_event(codec, res >> 2);
225 /* additional initialization for ALC888 variants */
226 static void alc888_coef_init(struct hda_codec *codec)
230 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
231 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
232 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
233 if ((tmp & 0xf0) == 0x20)
235 snd_hda_codec_read(codec, 0x20, 0,
236 AC_VERB_SET_PROC_COEF, 0x830);
239 snd_hda_codec_read(codec, 0x20, 0,
240 AC_VERB_SET_PROC_COEF, 0x3030);
243 /* additional initialization for ALC889 variants */
244 static void alc889_coef_init(struct hda_codec *codec)
248 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
249 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
250 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
251 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
254 /* turn on/off EAPD control (only if available) */
255 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
257 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
259 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
260 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
264 /* turn on/off EAPD controls of the codec */
265 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
267 /* We currently only handle front, HP */
268 static hda_nid_t pins[] = {
269 0x0f, 0x10, 0x14, 0x15, 0x17, 0
272 for (p = pins; *p; p++)
273 set_eapd(codec, *p, on);
276 /* generic shutup callback;
277 * just turning off EPAD and a little pause for avoiding pop-noise
279 static void alc_eapd_shutup(struct hda_codec *codec)
281 alc_auto_setup_eapd(codec, false);
285 /* generic EAPD initialization */
286 static void alc_auto_init_amp(struct hda_codec *codec, int type)
290 alc_auto_setup_eapd(codec, true);
293 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
296 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
299 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
301 case ALC_INIT_DEFAULT:
302 switch (codec->vendor_id) {
304 snd_hda_codec_write(codec, 0x1a, 0,
305 AC_VERB_SET_COEF_INDEX, 7);
306 tmp = snd_hda_codec_read(codec, 0x1a, 0,
307 AC_VERB_GET_PROC_COEF, 0);
308 snd_hda_codec_write(codec, 0x1a, 0,
309 AC_VERB_SET_COEF_INDEX, 7);
310 snd_hda_codec_write(codec, 0x1a, 0,
311 AC_VERB_SET_PROC_COEF,
320 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
322 alc889_coef_init(codec);
325 alc888_coef_init(codec);
327 #if 0 /* XXX: This may cause the silent output on speaker on some machines */
330 snd_hda_codec_write(codec, 0x20, 0,
331 AC_VERB_SET_COEF_INDEX, 7);
332 tmp = snd_hda_codec_read(codec, 0x20, 0,
333 AC_VERB_GET_PROC_COEF, 0);
334 snd_hda_codec_write(codec, 0x20, 0,
335 AC_VERB_SET_COEF_INDEX, 7);
336 snd_hda_codec_write(codec, 0x20, 0,
337 AC_VERB_SET_PROC_COEF,
348 * Realtek SSID verification
351 /* Could be any non-zero and even value. When used as fixup, tells
352 * the driver to ignore any present sku defines.
354 #define ALC_FIXUP_SKU_IGNORE (2)
356 static void alc_fixup_sku_ignore(struct hda_codec *codec,
357 const struct hda_fixup *fix, int action)
359 struct alc_spec *spec = codec->spec;
360 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
361 spec->cdefine.fixup = 1;
362 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
366 static int alc_auto_parse_customize_define(struct hda_codec *codec)
368 unsigned int ass, tmp, i;
370 struct alc_spec *spec = codec->spec;
372 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
374 if (spec->cdefine.fixup) {
375 ass = spec->cdefine.sku_cfg;
376 if (ass == ALC_FIXUP_SKU_IGNORE)
381 ass = codec->subsystem_id & 0xffff;
382 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
386 if (codec->vendor_id == 0x10ec0260)
388 ass = snd_hda_codec_get_pincfg(codec, nid);
391 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
392 codec->chip_name, ass);
398 for (i = 1; i < 16; i++) {
402 if (((ass >> 16) & 0xf) != tmp)
405 spec->cdefine.port_connectivity = ass >> 30;
406 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
407 spec->cdefine.check_sum = (ass >> 16) & 0xf;
408 spec->cdefine.customization = ass >> 8;
410 spec->cdefine.sku_cfg = ass;
411 spec->cdefine.external_amp = (ass & 0x38) >> 3;
412 spec->cdefine.platform_type = (ass & 0x4) >> 2;
413 spec->cdefine.swap = (ass & 0x2) >> 1;
414 spec->cdefine.override = ass & 0x1;
416 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
417 nid, spec->cdefine.sku_cfg);
418 snd_printd("SKU: port_connectivity=0x%x\n",
419 spec->cdefine.port_connectivity);
420 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
421 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
422 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
423 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
424 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
425 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
426 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
431 /* return the position of NID in the list, or -1 if not found */
432 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
435 for (i = 0; i < nums; i++)
440 /* return true if the given NID is found in the list */
441 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
443 return find_idx_in_nid_list(nid, list, nums) >= 0;
446 /* check subsystem ID and set up device-specific initialization;
447 * return 1 if initialized, 0 if invalid SSID
449 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
450 * 31 ~ 16 : Manufacture ID
452 * 7 ~ 0 : Assembly ID
453 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
455 static int alc_subsystem_id(struct hda_codec *codec,
456 hda_nid_t porta, hda_nid_t porte,
457 hda_nid_t portd, hda_nid_t porti)
459 unsigned int ass, tmp, i;
461 struct alc_spec *spec = codec->spec;
463 if (spec->cdefine.fixup) {
464 ass = spec->cdefine.sku_cfg;
465 if (ass == ALC_FIXUP_SKU_IGNORE)
470 ass = codec->subsystem_id & 0xffff;
471 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
474 /* invalid SSID, check the special NID pin defcfg instead */
476 * 31~30 : port connectivity
479 * 19~16 : Check sum (15:1)
484 if (codec->vendor_id == 0x10ec0260)
486 ass = snd_hda_codec_get_pincfg(codec, nid);
487 snd_printd("realtek: No valid SSID, "
488 "checking pincfg 0x%08x for NID 0x%x\n",
492 if ((ass >> 30) != 1) /* no physical connection */
497 for (i = 1; i < 16; i++) {
501 if (((ass >> 16) & 0xf) != tmp)
504 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
505 ass & 0xffff, codec->vendor_id);
509 * 2 : 0 --> Desktop, 1 --> Laptop
510 * 3~5 : External Amplifier control
513 tmp = (ass & 0x38) >> 3; /* external Amp control */
516 spec->init_amp = ALC_INIT_GPIO1;
519 spec->init_amp = ALC_INIT_GPIO2;
522 spec->init_amp = ALC_INIT_GPIO3;
526 spec->init_amp = ALC_INIT_DEFAULT;
530 /* is laptop or Desktop and enable the function "Mute internal speaker
531 * when the external headphone out jack is plugged"
536 * 10~8 : Jack location
537 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
539 * 15 : 1 --> enable the function "Mute internal speaker
540 * when the external headphone out jack is plugged"
542 if (!spec->gen.autocfg.hp_pins[0] &&
543 !(spec->gen.autocfg.line_out_pins[0] &&
544 spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
546 tmp = (ass >> 11) & 0x3; /* HP to chassis */
557 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
558 spec->gen.autocfg.line_outs))
560 spec->gen.autocfg.hp_pins[0] = nid;
565 /* Check the validity of ALC subsystem-id
566 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
567 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
569 if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) {
570 struct alc_spec *spec = codec->spec;
571 snd_printd("realtek: "
572 "Enable default setup for auto mode as fallback\n");
573 spec->init_amp = ALC_INIT_DEFAULT;
578 * COEF access helper functions
580 static int alc_read_coef_idx(struct hda_codec *codec,
581 unsigned int coef_idx)
584 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
586 val = snd_hda_codec_read(codec, 0x20, 0,
587 AC_VERB_GET_PROC_COEF, 0);
591 static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
592 unsigned int coef_val)
594 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
596 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
600 /* a special bypass for COEF 0; read the cached value at the second time */
601 static unsigned int alc_get_coef0(struct hda_codec *codec)
603 struct alc_spec *spec = codec->spec;
605 spec->coef0 = alc_read_coef_idx(codec, 0);
612 static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx)
614 struct hda_gen_spec *spec = codec->spec;
615 if (spec->dyn_adc_switch)
616 adc_idx = spec->dyn_adc_idx[imux_idx];
617 return spec->adc_nids[adc_idx];
620 static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx)
622 struct alc_spec *spec = codec->spec;
623 struct hda_input_mux *imux = &spec->gen.input_mux;
624 struct nid_path *path;
629 for (i = 0; i < imux->num_items; i++) {
630 if (spec->gen.imux_pins[i] == spec->inv_dmic_pin)
633 if (i >= imux->num_items)
636 path = snd_hda_get_nid_path(codec, spec->inv_dmic_pin,
637 get_adc_nid(codec, adc_idx, i));
638 val = path->ctls[NID_PATH_MUTE_CTL];
641 nid = get_amp_nid_(val);
642 dir = get_amp_direction_(val);
643 parm = AC_AMP_SET_RIGHT |
644 (dir == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT);
646 /* flush all cached amps at first */
647 snd_hda_codec_flush_cache(codec);
649 /* we care only right channel */
650 val = snd_hda_codec_amp_read(codec, nid, 1, dir, 0);
651 if (val & 0x80) /* if already muted, we don't need to touch */
654 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
659 * Inverted digital-mic handling
661 * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch"
662 * gives the additional mute only to the right channel of the digital mic
663 * capture stream. This is a workaround for avoiding the almost silence
664 * by summing the stereo stream from some (known to be ForteMedia)
667 * The logic is to call alc_inv_dmic_sync() after each action (possibly)
668 * modifying ADC amp. When the mute flag is set, it mutes the R-channel
669 * without caching so that the cache can still keep the original value.
670 * The cached value is then restored when the flag is set off or any other
671 * than d-mic is used as the current input source.
673 static void alc_inv_dmic_sync(struct hda_codec *codec, bool force)
675 struct alc_spec *spec = codec->spec;
678 if (!spec->inv_dmic_fixup)
680 if (!spec->inv_dmic_muted && !force)
682 nums = spec->gen.dyn_adc_switch ? 1 : spec->gen.num_adc_nids;
683 for (src = 0; src < nums; src++) {
684 bool dmic_fixup = false;
686 if (spec->inv_dmic_muted &&
687 spec->gen.imux_pins[spec->gen.cur_mux[src]] == spec->inv_dmic_pin)
689 if (!dmic_fixup && !force)
691 alc_inv_dmic_sync_adc(codec, src);
695 static void alc_inv_dmic_hook(struct hda_codec *codec,
696 struct snd_ctl_elem_value *ucontrol)
698 alc_inv_dmic_sync(codec, false);
701 static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol,
702 struct snd_ctl_elem_value *ucontrol)
704 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
705 struct alc_spec *spec = codec->spec;
707 ucontrol->value.integer.value[0] = !spec->inv_dmic_muted;
711 static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol,
712 struct snd_ctl_elem_value *ucontrol)
714 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
715 struct alc_spec *spec = codec->spec;
716 unsigned int val = !ucontrol->value.integer.value[0];
718 if (val == spec->inv_dmic_muted)
720 spec->inv_dmic_muted = val;
721 alc_inv_dmic_sync(codec, true);
725 static const struct snd_kcontrol_new alc_inv_dmic_sw = {
726 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
727 .name = "Inverted Internal Mic Capture Switch",
728 .info = snd_ctl_boolean_mono_info,
729 .get = alc_inv_dmic_sw_get,
730 .put = alc_inv_dmic_sw_put,
733 static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid)
735 struct alc_spec *spec = codec->spec;
737 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &alc_inv_dmic_sw))
739 spec->inv_dmic_fixup = 1;
740 spec->inv_dmic_muted = 0;
741 spec->inv_dmic_pin = nid;
742 spec->gen.cap_sync_hook = alc_inv_dmic_hook;
746 /* typically the digital mic is put at node 0x12 */
747 static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec,
748 const struct hda_fixup *fix, int action)
750 if (action == HDA_FIXUP_ACT_PROBE)
751 alc_add_inv_dmic_mixer(codec, 0x12);
755 #ifdef CONFIG_SND_HDA_INPUT_BEEP
756 /* additional beep mixers; the actual parameters are overwritten at build */
757 static const struct snd_kcontrol_new alc_beep_mixer[] = {
758 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
759 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
764 static int alc_build_controls(struct hda_codec *codec)
766 struct alc_spec *spec = codec->spec;
769 err = snd_hda_gen_build_controls(codec);
773 for (i = 0; i < spec->num_mixers; i++) {
774 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
779 #ifdef CONFIG_SND_HDA_INPUT_BEEP
780 /* create beep controls if needed */
781 if (spec->beep_amp) {
782 const struct snd_kcontrol_new *knew;
783 for (knew = alc_beep_mixer; knew->name; knew++) {
784 struct snd_kcontrol *kctl;
785 kctl = snd_ctl_new1(knew, codec);
788 kctl->private_value = spec->beep_amp;
789 err = snd_hda_ctl_add(codec, 0, kctl);
796 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
805 static int alc_init(struct hda_codec *codec)
807 struct alc_spec *spec = codec->spec;
810 spec->init_hook(codec);
813 alc_auto_init_amp(codec, spec->init_amp);
815 snd_hda_gen_init(codec);
817 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
822 static inline void alc_shutup(struct hda_codec *codec)
824 struct alc_spec *spec = codec->spec;
826 if (spec && spec->shutup)
828 snd_hda_shutup_pins(codec);
831 #define alc_free snd_hda_gen_free
834 static void alc_power_eapd(struct hda_codec *codec)
836 alc_auto_setup_eapd(codec, false);
839 static int alc_suspend(struct hda_codec *codec)
841 struct alc_spec *spec = codec->spec;
843 if (spec && spec->power_hook)
844 spec->power_hook(codec);
850 static int alc_resume(struct hda_codec *codec)
852 msleep(150); /* to avoid pop noise */
853 codec->patch_ops.init(codec);
854 snd_hda_codec_resume_amp(codec);
855 snd_hda_codec_resume_cache(codec);
856 alc_inv_dmic_sync(codec, true);
857 hda_call_check_power_status(codec, 0x01);
864 static const struct hda_codec_ops alc_patch_ops = {
865 .build_controls = alc_build_controls,
866 .build_pcms = snd_hda_gen_build_pcms,
869 .unsol_event = snd_hda_jack_unsol_event,
871 .resume = alc_resume,
872 .suspend = alc_suspend,
873 .check_power_status = snd_hda_gen_check_power_status,
875 .reboot_notify = alc_shutup,
879 /* replace the codec chip_name with the given string */
880 static int alc_codec_rename(struct hda_codec *codec, const char *name)
882 kfree(codec->chip_name);
883 codec->chip_name = kstrdup(name, GFP_KERNEL);
884 if (!codec->chip_name) {
892 * Rename codecs appropriately from COEF value
894 struct alc_codec_rename_table {
895 unsigned int vendor_id;
896 unsigned short coef_mask;
897 unsigned short coef_bits;
901 static struct alc_codec_rename_table rename_tbl[] = {
902 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
903 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
904 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
905 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
906 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
907 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
908 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
909 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
910 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
911 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
912 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
913 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
914 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
915 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
916 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
920 static int alc_codec_rename_from_preset(struct hda_codec *codec)
922 const struct alc_codec_rename_table *p;
924 for (p = rename_tbl; p->vendor_id; p++) {
925 if (p->vendor_id != codec->vendor_id)
927 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
928 return alc_codec_rename(codec, p->name);
935 * Digital-beep handlers
937 #ifdef CONFIG_SND_HDA_INPUT_BEEP
938 #define set_beep_amp(spec, nid, idx, dir) \
939 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
941 static const struct snd_pci_quirk beep_white_list[] = {
942 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
943 SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
944 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
945 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
946 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
947 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
948 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
949 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
950 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
954 static inline int has_cdefine_beep(struct hda_codec *codec)
956 struct alc_spec *spec = codec->spec;
957 const struct snd_pci_quirk *q;
958 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
961 return spec->cdefine.enable_pcbeep;
964 #define set_beep_amp(spec, nid, idx, dir) /* NOP */
965 #define has_cdefine_beep(codec) 0
968 /* parse the BIOS configuration and set up the alc_spec */
969 /* return 1 if successful, 0 if the proper config is not found,
970 * or a negative error code
972 static int alc_parse_auto_config(struct hda_codec *codec,
973 const hda_nid_t *ignore_nids,
974 const hda_nid_t *ssid_nids)
976 struct alc_spec *spec = codec->spec;
977 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
980 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
986 alc_ssid_check(codec, ssid_nids);
988 err = snd_hda_gen_parse_auto_config(codec, cfg);
995 /* common preparation job for alc_spec */
996 static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
998 struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1004 snd_hda_gen_spec_init(&spec->gen);
1005 spec->gen.mixer_nid = mixer_nid;
1006 spec->gen.own_eapd_ctl = 1;
1007 codec->single_adc_amp = 1;
1008 /* FIXME: do we need this for all Realtek codec models? */
1009 codec->spdif_status_reset = 1;
1011 err = alc_codec_rename_from_preset(codec);
1019 static int alc880_parse_auto_config(struct hda_codec *codec)
1021 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
1022 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
1023 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1032 ALC880_FIXUP_MEDION_RIM,
1034 ALC880_FIXUP_LG_LW25,
1036 ALC880_FIXUP_EAPD_COEF,
1037 ALC880_FIXUP_TCL_S700,
1038 ALC880_FIXUP_VOL_KNOB,
1039 ALC880_FIXUP_FUJITSU,
1041 ALC880_FIXUP_UNIWILL,
1042 ALC880_FIXUP_UNIWILL_DIG,
1044 ALC880_FIXUP_ASUS_W5A,
1045 ALC880_FIXUP_3ST_BASE,
1047 ALC880_FIXUP_3ST_DIG,
1048 ALC880_FIXUP_5ST_BASE,
1050 ALC880_FIXUP_5ST_DIG,
1051 ALC880_FIXUP_6ST_BASE,
1053 ALC880_FIXUP_6ST_DIG,
1054 ALC880_FIXUP_6ST_AUTOMUTE,
1057 /* enable the volume-knob widget support on NID 0x21 */
1058 static void alc880_fixup_vol_knob(struct hda_codec *codec,
1059 const struct hda_fixup *fix, int action)
1061 if (action == HDA_FIXUP_ACT_PROBE)
1062 snd_hda_jack_detect_enable_callback(codec, 0x21, ALC_DCVOL_EVENT, alc_update_knob_master);
1065 static const struct hda_fixup alc880_fixups[] = {
1066 [ALC880_FIXUP_GPIO1] = {
1067 .type = HDA_FIXUP_VERBS,
1068 .v.verbs = alc_gpio1_init_verbs,
1070 [ALC880_FIXUP_GPIO2] = {
1071 .type = HDA_FIXUP_VERBS,
1072 .v.verbs = alc_gpio2_init_verbs,
1074 [ALC880_FIXUP_MEDION_RIM] = {
1075 .type = HDA_FIXUP_VERBS,
1076 .v.verbs = (const struct hda_verb[]) {
1077 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1078 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1082 .chain_id = ALC880_FIXUP_GPIO2,
1084 [ALC880_FIXUP_LG] = {
1085 .type = HDA_FIXUP_PINS,
1086 .v.pins = (const struct hda_pintbl[]) {
1087 /* disable bogus unused pins */
1088 { 0x16, 0x411111f0 },
1089 { 0x18, 0x411111f0 },
1090 { 0x1a, 0x411111f0 },
1094 [ALC880_FIXUP_LG_LW25] = {
1095 .type = HDA_FIXUP_PINS,
1096 .v.pins = (const struct hda_pintbl[]) {
1097 { 0x1a, 0x0181344f }, /* line-in */
1098 { 0x1b, 0x0321403f }, /* headphone */
1102 [ALC880_FIXUP_W810] = {
1103 .type = HDA_FIXUP_PINS,
1104 .v.pins = (const struct hda_pintbl[]) {
1105 /* disable bogus unused pins */
1106 { 0x17, 0x411111f0 },
1110 .chain_id = ALC880_FIXUP_GPIO2,
1112 [ALC880_FIXUP_EAPD_COEF] = {
1113 .type = HDA_FIXUP_VERBS,
1114 .v.verbs = (const struct hda_verb[]) {
1115 /* change to EAPD mode */
1116 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1117 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1121 [ALC880_FIXUP_TCL_S700] = {
1122 .type = HDA_FIXUP_VERBS,
1123 .v.verbs = (const struct hda_verb[]) {
1124 /* change to EAPD mode */
1125 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1126 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
1130 .chain_id = ALC880_FIXUP_GPIO2,
1132 [ALC880_FIXUP_VOL_KNOB] = {
1133 .type = HDA_FIXUP_FUNC,
1134 .v.func = alc880_fixup_vol_knob,
1136 [ALC880_FIXUP_FUJITSU] = {
1137 /* override all pins as BIOS on old Amilo is broken */
1138 .type = HDA_FIXUP_PINS,
1139 .v.pins = (const struct hda_pintbl[]) {
1140 { 0x14, 0x0121411f }, /* HP */
1141 { 0x15, 0x99030120 }, /* speaker */
1142 { 0x16, 0x99030130 }, /* bass speaker */
1143 { 0x17, 0x411111f0 }, /* N/A */
1144 { 0x18, 0x411111f0 }, /* N/A */
1145 { 0x19, 0x01a19950 }, /* mic-in */
1146 { 0x1a, 0x411111f0 }, /* N/A */
1147 { 0x1b, 0x411111f0 }, /* N/A */
1148 { 0x1c, 0x411111f0 }, /* N/A */
1149 { 0x1d, 0x411111f0 }, /* N/A */
1150 { 0x1e, 0x01454140 }, /* SPDIF out */
1154 .chain_id = ALC880_FIXUP_VOL_KNOB,
1156 [ALC880_FIXUP_F1734] = {
1157 /* almost compatible with FUJITSU, but no bass and SPDIF */
1158 .type = HDA_FIXUP_PINS,
1159 .v.pins = (const struct hda_pintbl[]) {
1160 { 0x14, 0x0121411f }, /* HP */
1161 { 0x15, 0x99030120 }, /* speaker */
1162 { 0x16, 0x411111f0 }, /* N/A */
1163 { 0x17, 0x411111f0 }, /* N/A */
1164 { 0x18, 0x411111f0 }, /* N/A */
1165 { 0x19, 0x01a19950 }, /* mic-in */
1166 { 0x1a, 0x411111f0 }, /* N/A */
1167 { 0x1b, 0x411111f0 }, /* N/A */
1168 { 0x1c, 0x411111f0 }, /* N/A */
1169 { 0x1d, 0x411111f0 }, /* N/A */
1170 { 0x1e, 0x411111f0 }, /* N/A */
1174 .chain_id = ALC880_FIXUP_VOL_KNOB,
1176 [ALC880_FIXUP_UNIWILL] = {
1177 /* need to fix HP and speaker pins to be parsed correctly */
1178 .type = HDA_FIXUP_PINS,
1179 .v.pins = (const struct hda_pintbl[]) {
1180 { 0x14, 0x0121411f }, /* HP */
1181 { 0x15, 0x99030120 }, /* speaker */
1182 { 0x16, 0x99030130 }, /* bass speaker */
1186 [ALC880_FIXUP_UNIWILL_DIG] = {
1187 .type = HDA_FIXUP_PINS,
1188 .v.pins = (const struct hda_pintbl[]) {
1189 /* disable bogus unused pins */
1190 { 0x17, 0x411111f0 },
1191 { 0x19, 0x411111f0 },
1192 { 0x1b, 0x411111f0 },
1193 { 0x1f, 0x411111f0 },
1197 [ALC880_FIXUP_Z71V] = {
1198 .type = HDA_FIXUP_PINS,
1199 .v.pins = (const struct hda_pintbl[]) {
1200 /* set up the whole pins as BIOS is utterly broken */
1201 { 0x14, 0x99030120 }, /* speaker */
1202 { 0x15, 0x0121411f }, /* HP */
1203 { 0x16, 0x411111f0 }, /* N/A */
1204 { 0x17, 0x411111f0 }, /* N/A */
1205 { 0x18, 0x01a19950 }, /* mic-in */
1206 { 0x19, 0x411111f0 }, /* N/A */
1207 { 0x1a, 0x01813031 }, /* line-in */
1208 { 0x1b, 0x411111f0 }, /* N/A */
1209 { 0x1c, 0x411111f0 }, /* N/A */
1210 { 0x1d, 0x411111f0 }, /* N/A */
1211 { 0x1e, 0x0144111e }, /* SPDIF */
1215 [ALC880_FIXUP_ASUS_W5A] = {
1216 .type = HDA_FIXUP_PINS,
1217 .v.pins = (const struct hda_pintbl[]) {
1218 /* set up the whole pins as BIOS is utterly broken */
1219 { 0x14, 0x0121411f }, /* HP */
1220 { 0x15, 0x411111f0 }, /* N/A */
1221 { 0x16, 0x411111f0 }, /* N/A */
1222 { 0x17, 0x411111f0 }, /* N/A */
1223 { 0x18, 0x90a60160 }, /* mic */
1224 { 0x19, 0x411111f0 }, /* N/A */
1225 { 0x1a, 0x411111f0 }, /* N/A */
1226 { 0x1b, 0x411111f0 }, /* N/A */
1227 { 0x1c, 0x411111f0 }, /* N/A */
1228 { 0x1d, 0x411111f0 }, /* N/A */
1229 { 0x1e, 0xb743111e }, /* SPDIF out */
1233 .chain_id = ALC880_FIXUP_GPIO1,
1235 [ALC880_FIXUP_3ST_BASE] = {
1236 .type = HDA_FIXUP_PINS,
1237 .v.pins = (const struct hda_pintbl[]) {
1238 { 0x14, 0x01014010 }, /* line-out */
1239 { 0x15, 0x411111f0 }, /* N/A */
1240 { 0x16, 0x411111f0 }, /* N/A */
1241 { 0x17, 0x411111f0 }, /* N/A */
1242 { 0x18, 0x01a19c30 }, /* mic-in */
1243 { 0x19, 0x0121411f }, /* HP */
1244 { 0x1a, 0x01813031 }, /* line-in */
1245 { 0x1b, 0x02a19c40 }, /* front-mic */
1246 { 0x1c, 0x411111f0 }, /* N/A */
1247 { 0x1d, 0x411111f0 }, /* N/A */
1248 /* 0x1e is filled in below */
1249 { 0x1f, 0x411111f0 }, /* N/A */
1253 [ALC880_FIXUP_3ST] = {
1254 .type = HDA_FIXUP_PINS,
1255 .v.pins = (const struct hda_pintbl[]) {
1256 { 0x1e, 0x411111f0 }, /* N/A */
1260 .chain_id = ALC880_FIXUP_3ST_BASE,
1262 [ALC880_FIXUP_3ST_DIG] = {
1263 .type = HDA_FIXUP_PINS,
1264 .v.pins = (const struct hda_pintbl[]) {
1265 { 0x1e, 0x0144111e }, /* SPDIF */
1269 .chain_id = ALC880_FIXUP_3ST_BASE,
1271 [ALC880_FIXUP_5ST_BASE] = {
1272 .type = HDA_FIXUP_PINS,
1273 .v.pins = (const struct hda_pintbl[]) {
1274 { 0x14, 0x01014010 }, /* front */
1275 { 0x15, 0x411111f0 }, /* N/A */
1276 { 0x16, 0x01011411 }, /* CLFE */
1277 { 0x17, 0x01016412 }, /* surr */
1278 { 0x18, 0x01a19c30 }, /* mic-in */
1279 { 0x19, 0x0121411f }, /* HP */
1280 { 0x1a, 0x01813031 }, /* line-in */
1281 { 0x1b, 0x02a19c40 }, /* front-mic */
1282 { 0x1c, 0x411111f0 }, /* N/A */
1283 { 0x1d, 0x411111f0 }, /* N/A */
1284 /* 0x1e is filled in below */
1285 { 0x1f, 0x411111f0 }, /* N/A */
1289 [ALC880_FIXUP_5ST] = {
1290 .type = HDA_FIXUP_PINS,
1291 .v.pins = (const struct hda_pintbl[]) {
1292 { 0x1e, 0x411111f0 }, /* N/A */
1296 .chain_id = ALC880_FIXUP_5ST_BASE,
1298 [ALC880_FIXUP_5ST_DIG] = {
1299 .type = HDA_FIXUP_PINS,
1300 .v.pins = (const struct hda_pintbl[]) {
1301 { 0x1e, 0x0144111e }, /* SPDIF */
1305 .chain_id = ALC880_FIXUP_5ST_BASE,
1307 [ALC880_FIXUP_6ST_BASE] = {
1308 .type = HDA_FIXUP_PINS,
1309 .v.pins = (const struct hda_pintbl[]) {
1310 { 0x14, 0x01014010 }, /* front */
1311 { 0x15, 0x01016412 }, /* surr */
1312 { 0x16, 0x01011411 }, /* CLFE */
1313 { 0x17, 0x01012414 }, /* side */
1314 { 0x18, 0x01a19c30 }, /* mic-in */
1315 { 0x19, 0x02a19c40 }, /* front-mic */
1316 { 0x1a, 0x01813031 }, /* line-in */
1317 { 0x1b, 0x0121411f }, /* HP */
1318 { 0x1c, 0x411111f0 }, /* N/A */
1319 { 0x1d, 0x411111f0 }, /* N/A */
1320 /* 0x1e is filled in below */
1321 { 0x1f, 0x411111f0 }, /* N/A */
1325 [ALC880_FIXUP_6ST] = {
1326 .type = HDA_FIXUP_PINS,
1327 .v.pins = (const struct hda_pintbl[]) {
1328 { 0x1e, 0x411111f0 }, /* N/A */
1332 .chain_id = ALC880_FIXUP_6ST_BASE,
1334 [ALC880_FIXUP_6ST_DIG] = {
1335 .type = HDA_FIXUP_PINS,
1336 .v.pins = (const struct hda_pintbl[]) {
1337 { 0x1e, 0x0144111e }, /* SPDIF */
1341 .chain_id = ALC880_FIXUP_6ST_BASE,
1343 [ALC880_FIXUP_6ST_AUTOMUTE] = {
1344 .type = HDA_FIXUP_PINS,
1345 .v.pins = (const struct hda_pintbl[]) {
1346 { 0x1b, 0x0121401f }, /* HP with jack detect */
1349 .chained_before = true,
1350 .chain_id = ALC880_FIXUP_6ST_BASE,
1354 static const struct snd_pci_quirk alc880_fixup_tbl[] = {
1355 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
1356 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
1357 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
1358 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
1359 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
1360 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
1361 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
1362 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
1363 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
1364 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
1365 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
1366 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
1367 SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
1368 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734),
1369 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
1370 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
1371 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
1372 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1373 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1374 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
1375 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
1376 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
1378 /* Below is the copied entries from alc880_quirks.c.
1379 * It's not quite sure whether BIOS sets the correct pin-config table
1380 * on these machines, thus they are kept to be compatible with
1381 * the old static quirks. Once when it's confirmed to work without
1382 * these overrides, it'd be better to remove.
1384 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1385 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1386 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1387 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1388 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1389 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1390 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1391 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1392 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1393 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1394 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1395 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1396 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1397 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1398 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1399 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1400 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1401 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1402 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1403 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1404 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1405 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1406 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1407 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1408 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1409 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1410 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1411 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1412 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1413 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1414 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1415 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1416 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1418 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1419 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1420 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1424 static const struct hda_model_fixup alc880_fixup_models[] = {
1425 {.id = ALC880_FIXUP_3ST, .name = "3stack"},
1426 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1427 {.id = ALC880_FIXUP_5ST, .name = "5stack"},
1428 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1429 {.id = ALC880_FIXUP_6ST, .name = "6stack"},
1430 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
1431 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
1437 * OK, here we have finally the patch for ALC880
1439 static int patch_alc880(struct hda_codec *codec)
1441 struct alc_spec *spec;
1444 err = alc_alloc_spec(codec, 0x0b);
1449 spec->gen.need_dac_fix = 1;
1450 spec->gen.beep_nid = 0x01;
1452 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
1454 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1456 /* automatic parse from the BIOS config */
1457 err = alc880_parse_auto_config(codec);
1461 if (!spec->gen.no_analog)
1462 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1464 codec->patch_ops = alc_patch_ops;
1465 codec->patch_ops.unsol_event = alc880_unsol_event;
1468 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1481 static int alc260_parse_auto_config(struct hda_codec *codec)
1483 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
1484 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1485 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
1492 ALC260_FIXUP_HP_DC5750,
1493 ALC260_FIXUP_HP_PIN_0F,
1496 ALC260_FIXUP_GPIO1_TOGGLE,
1497 ALC260_FIXUP_REPLACER,
1498 ALC260_FIXUP_HP_B1900,
1500 ALC260_FIXUP_FSC_S7020,
1501 ALC260_FIXUP_FSC_S7020_JWSE,
1502 ALC260_FIXUP_VAIO_PINS,
1505 static void alc260_gpio1_automute(struct hda_codec *codec)
1507 struct alc_spec *spec = codec->spec;
1508 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
1509 spec->gen.hp_jack_present);
1512 static void alc260_fixup_gpio1_toggle(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_PROBE) {
1517 /* although the machine has only one output pin, we need to
1518 * toggle GPIO1 according to the jack state
1520 spec->gen.automute_hook = alc260_gpio1_automute;
1521 spec->gen.detect_hp = 1;
1522 spec->gen.automute_speaker = 1;
1523 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1524 snd_hda_jack_detect_enable_callback(codec, 0x0f, HDA_GEN_HP_EVENT,
1525 snd_hda_gen_hp_automute);
1526 snd_hda_add_verbs(codec, alc_gpio1_init_verbs);
1530 static void alc260_fixup_kn1(struct hda_codec *codec,
1531 const struct hda_fixup *fix, int action)
1533 struct alc_spec *spec = codec->spec;
1534 static const struct hda_pintbl pincfgs[] = {
1535 { 0x0f, 0x02214000 }, /* HP/speaker */
1536 { 0x12, 0x90a60160 }, /* int mic */
1537 { 0x13, 0x02a19000 }, /* ext mic */
1538 { 0x18, 0x01446000 }, /* SPDIF out */
1539 /* disable bogus I/O pins */
1540 { 0x10, 0x411111f0 },
1541 { 0x11, 0x411111f0 },
1542 { 0x14, 0x411111f0 },
1543 { 0x15, 0x411111f0 },
1544 { 0x16, 0x411111f0 },
1545 { 0x17, 0x411111f0 },
1546 { 0x19, 0x411111f0 },
1551 case HDA_FIXUP_ACT_PRE_PROBE:
1552 snd_hda_apply_pincfgs(codec, pincfgs);
1554 case HDA_FIXUP_ACT_PROBE:
1555 spec->init_amp = ALC_INIT_NONE;
1560 static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1561 const struct hda_fixup *fix, int action)
1563 struct alc_spec *spec = codec->spec;
1564 if (action == HDA_FIXUP_ACT_PROBE)
1565 spec->init_amp = ALC_INIT_NONE;
1568 static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1569 const struct hda_fixup *fix, int action)
1571 struct alc_spec *spec = codec->spec;
1572 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1573 spec->gen.add_jack_modes = 1;
1574 spec->gen.hp_mic = 1;
1578 static const struct hda_fixup alc260_fixups[] = {
1579 [ALC260_FIXUP_HP_DC5750] = {
1580 .type = HDA_FIXUP_PINS,
1581 .v.pins = (const struct hda_pintbl[]) {
1582 { 0x11, 0x90130110 }, /* speaker */
1586 [ALC260_FIXUP_HP_PIN_0F] = {
1587 .type = HDA_FIXUP_PINS,
1588 .v.pins = (const struct hda_pintbl[]) {
1589 { 0x0f, 0x01214000 }, /* HP */
1593 [ALC260_FIXUP_COEF] = {
1594 .type = HDA_FIXUP_VERBS,
1595 .v.verbs = (const struct hda_verb[]) {
1596 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1597 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3040 },
1601 [ALC260_FIXUP_GPIO1] = {
1602 .type = HDA_FIXUP_VERBS,
1603 .v.verbs = alc_gpio1_init_verbs,
1605 [ALC260_FIXUP_GPIO1_TOGGLE] = {
1606 .type = HDA_FIXUP_FUNC,
1607 .v.func = alc260_fixup_gpio1_toggle,
1609 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1611 [ALC260_FIXUP_REPLACER] = {
1612 .type = HDA_FIXUP_VERBS,
1613 .v.verbs = (const struct hda_verb[]) {
1614 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1615 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3050 },
1619 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1621 [ALC260_FIXUP_HP_B1900] = {
1622 .type = HDA_FIXUP_FUNC,
1623 .v.func = alc260_fixup_gpio1_toggle,
1625 .chain_id = ALC260_FIXUP_COEF,
1627 [ALC260_FIXUP_KN1] = {
1628 .type = HDA_FIXUP_FUNC,
1629 .v.func = alc260_fixup_kn1,
1631 [ALC260_FIXUP_FSC_S7020] = {
1632 .type = HDA_FIXUP_FUNC,
1633 .v.func = alc260_fixup_fsc_s7020,
1635 [ALC260_FIXUP_FSC_S7020_JWSE] = {
1636 .type = HDA_FIXUP_FUNC,
1637 .v.func = alc260_fixup_fsc_s7020_jwse,
1639 .chain_id = ALC260_FIXUP_FSC_S7020,
1641 [ALC260_FIXUP_VAIO_PINS] = {
1642 .type = HDA_FIXUP_PINS,
1643 .v.pins = (const struct hda_pintbl[]) {
1644 /* Pin configs are missing completely on some VAIOs */
1645 { 0x0f, 0x01211020 },
1646 { 0x10, 0x0001003f },
1647 { 0x11, 0x411111f0 },
1648 { 0x12, 0x01a15930 },
1649 { 0x13, 0x411111f0 },
1650 { 0x14, 0x411111f0 },
1651 { 0x15, 0x411111f0 },
1652 { 0x16, 0x411111f0 },
1653 { 0x17, 0x411111f0 },
1654 { 0x18, 0x411111f0 },
1655 { 0x19, 0x411111f0 },
1661 static const struct snd_pci_quirk alc260_fixup_tbl[] = {
1662 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
1663 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
1664 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
1665 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
1666 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
1667 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
1668 SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
1669 SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
1670 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
1671 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
1672 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
1673 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
1677 static const struct hda_model_fixup alc260_fixup_models[] = {
1678 {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1679 {.id = ALC260_FIXUP_COEF, .name = "coef"},
1680 {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1681 {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1687 static int patch_alc260(struct hda_codec *codec)
1689 struct alc_spec *spec;
1692 err = alc_alloc_spec(codec, 0x07);
1697 /* as quite a few machines require HP amp for speaker outputs,
1698 * it's easier to enable it unconditionally; even if it's unneeded,
1699 * it's almost harmless.
1701 spec->gen.prefer_hp_amp = 1;
1702 spec->gen.beep_nid = 0x01;
1704 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1706 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1708 /* automatic parse from the BIOS config */
1709 err = alc260_parse_auto_config(codec);
1713 if (!spec->gen.no_analog)
1714 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
1716 codec->patch_ops = alc_patch_ops;
1717 spec->shutup = alc_eapd_shutup;
1719 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1730 * ALC882/883/885/888/889 support
1732 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1733 * configuration. Each pin widget can choose any input DACs and a mixer.
1734 * Each ADC is connected from a mixer of all inputs. This makes possible
1735 * 6-channel independent captures.
1737 * In addition, an independent DAC for the multi-playback (not used in this
1745 ALC882_FIXUP_ABIT_AW9D_MAX,
1746 ALC882_FIXUP_LENOVO_Y530,
1747 ALC882_FIXUP_PB_M5210,
1748 ALC882_FIXUP_ACER_ASPIRE_7736,
1749 ALC882_FIXUP_ASUS_W90V,
1751 ALC889_FIXUP_VAIO_TT,
1752 ALC888_FIXUP_EEE1601,
1755 ALC883_FIXUP_ACER_EAPD,
1760 ALC882_FIXUP_ASUS_W2JC,
1761 ALC882_FIXUP_ACER_ASPIRE_4930G,
1762 ALC882_FIXUP_ACER_ASPIRE_8930G,
1763 ALC882_FIXUP_ASPIRE_8930G_VERBS,
1764 ALC885_FIXUP_MACPRO_GPIO,
1765 ALC889_FIXUP_DAC_ROUTE,
1766 ALC889_FIXUP_MBP_VREF,
1767 ALC889_FIXUP_IMAC91_VREF,
1768 ALC889_FIXUP_MBA11_VREF,
1769 ALC889_FIXUP_MBA21_VREF,
1770 ALC889_FIXUP_MP11_VREF,
1771 ALC882_FIXUP_INV_DMIC,
1772 ALC882_FIXUP_NO_PRIMARY_HP,
1773 ALC887_FIXUP_ASUS_BASS,
1776 static void alc889_fixup_coef(struct hda_codec *codec,
1777 const struct hda_fixup *fix, int action)
1779 if (action != HDA_FIXUP_ACT_INIT)
1781 alc889_coef_init(codec);
1784 /* toggle speaker-output according to the hp-jack state */
1785 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
1787 unsigned int gpiostate, gpiomask, gpiodir;
1789 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1790 AC_VERB_GET_GPIO_DATA, 0);
1793 gpiostate |= (1 << pin);
1795 gpiostate &= ~(1 << pin);
1797 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1798 AC_VERB_GET_GPIO_MASK, 0);
1799 gpiomask |= (1 << pin);
1801 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1802 AC_VERB_GET_GPIO_DIRECTION, 0);
1803 gpiodir |= (1 << pin);
1806 snd_hda_codec_write(codec, codec->afg, 0,
1807 AC_VERB_SET_GPIO_MASK, gpiomask);
1808 snd_hda_codec_write(codec, codec->afg, 0,
1809 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1813 snd_hda_codec_write(codec, codec->afg, 0,
1814 AC_VERB_SET_GPIO_DATA, gpiostate);
1817 /* set up GPIO at initialization */
1818 static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1819 const struct hda_fixup *fix, int action)
1821 if (action != HDA_FIXUP_ACT_INIT)
1823 alc882_gpio_mute(codec, 0, 0);
1824 alc882_gpio_mute(codec, 1, 0);
1827 /* Fix the connection of some pins for ALC889:
1828 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1829 * work correctly (bko#42740)
1831 static void alc889_fixup_dac_route(struct hda_codec *codec,
1832 const struct hda_fixup *fix, int action)
1834 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1835 /* fake the connections during parsing the tree */
1836 hda_nid_t conn1[2] = { 0x0c, 0x0d };
1837 hda_nid_t conn2[2] = { 0x0e, 0x0f };
1838 snd_hda_override_conn_list(codec, 0x14, 2, conn1);
1839 snd_hda_override_conn_list(codec, 0x15, 2, conn1);
1840 snd_hda_override_conn_list(codec, 0x18, 2, conn2);
1841 snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
1842 } else if (action == HDA_FIXUP_ACT_PROBE) {
1843 /* restore the connections */
1844 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1845 snd_hda_override_conn_list(codec, 0x14, 5, conn);
1846 snd_hda_override_conn_list(codec, 0x15, 5, conn);
1847 snd_hda_override_conn_list(codec, 0x18, 5, conn);
1848 snd_hda_override_conn_list(codec, 0x1a, 5, conn);
1852 /* Set VREF on HP pin */
1853 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
1854 const struct hda_fixup *fix, int action)
1856 struct alc_spec *spec = codec->spec;
1857 static hda_nid_t nids[2] = { 0x14, 0x15 };
1860 if (action != HDA_FIXUP_ACT_INIT)
1862 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1863 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1864 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1866 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1867 val |= AC_PINCTL_VREF_80;
1868 snd_hda_set_pin_ctl(codec, nids[i], val);
1869 spec->gen.keep_vref_in_automute = 1;
1874 static void alc889_fixup_mac_pins(struct hda_codec *codec,
1875 const hda_nid_t *nids, int num_nids)
1877 struct alc_spec *spec = codec->spec;
1880 for (i = 0; i < num_nids; i++) {
1882 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1883 val |= AC_PINCTL_VREF_50;
1884 snd_hda_set_pin_ctl(codec, nids[i], val);
1886 spec->gen.keep_vref_in_automute = 1;
1889 /* Set VREF on speaker pins on imac91 */
1890 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
1891 const struct hda_fixup *fix, int action)
1893 static hda_nid_t nids[2] = { 0x18, 0x1a };
1895 if (action == HDA_FIXUP_ACT_INIT)
1896 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1899 /* Set VREF on speaker pins on mba11 */
1900 static void alc889_fixup_mba11_vref(struct hda_codec *codec,
1901 const struct hda_fixup *fix, int action)
1903 static hda_nid_t nids[1] = { 0x18 };
1905 if (action == HDA_FIXUP_ACT_INIT)
1906 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1909 /* Set VREF on speaker pins on mba21 */
1910 static void alc889_fixup_mba21_vref(struct hda_codec *codec,
1911 const struct hda_fixup *fix, int action)
1913 static hda_nid_t nids[2] = { 0x18, 0x19 };
1915 if (action == HDA_FIXUP_ACT_INIT)
1916 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1919 /* Don't take HP output as primary
1920 * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
1921 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
1923 static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
1924 const struct hda_fixup *fix, int action)
1926 struct alc_spec *spec = codec->spec;
1927 if (action == HDA_FIXUP_ACT_PRE_PROBE)
1928 spec->gen.no_primary_hp = 1;
1931 static const struct hda_fixup alc882_fixups[] = {
1932 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
1933 .type = HDA_FIXUP_PINS,
1934 .v.pins = (const struct hda_pintbl[]) {
1935 { 0x15, 0x01080104 }, /* side */
1936 { 0x16, 0x01011012 }, /* rear */
1937 { 0x17, 0x01016011 }, /* clfe */
1941 [ALC882_FIXUP_LENOVO_Y530] = {
1942 .type = HDA_FIXUP_PINS,
1943 .v.pins = (const struct hda_pintbl[]) {
1944 { 0x15, 0x99130112 }, /* rear int speakers */
1945 { 0x16, 0x99130111 }, /* subwoofer */
1949 [ALC882_FIXUP_PB_M5210] = {
1950 .type = HDA_FIXUP_PINCTLS,
1951 .v.pins = (const struct hda_pintbl[]) {
1952 { 0x19, PIN_VREF50 },
1956 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
1957 .type = HDA_FIXUP_FUNC,
1958 .v.func = alc_fixup_sku_ignore,
1960 [ALC882_FIXUP_ASUS_W90V] = {
1961 .type = HDA_FIXUP_PINS,
1962 .v.pins = (const struct hda_pintbl[]) {
1963 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
1967 [ALC889_FIXUP_CD] = {
1968 .type = HDA_FIXUP_PINS,
1969 .v.pins = (const struct hda_pintbl[]) {
1970 { 0x1c, 0x993301f0 }, /* CD */
1974 [ALC889_FIXUP_VAIO_TT] = {
1975 .type = HDA_FIXUP_PINS,
1976 .v.pins = (const struct hda_pintbl[]) {
1977 { 0x17, 0x90170111 }, /* hidden surround speaker */
1981 [ALC888_FIXUP_EEE1601] = {
1982 .type = HDA_FIXUP_VERBS,
1983 .v.verbs = (const struct hda_verb[]) {
1984 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
1985 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
1989 [ALC882_FIXUP_EAPD] = {
1990 .type = HDA_FIXUP_VERBS,
1991 .v.verbs = (const struct hda_verb[]) {
1992 /* change to EAPD mode */
1993 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1994 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1998 [ALC883_FIXUP_EAPD] = {
1999 .type = HDA_FIXUP_VERBS,
2000 .v.verbs = (const struct hda_verb[]) {
2001 /* change to EAPD mode */
2002 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2003 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2007 [ALC883_FIXUP_ACER_EAPD] = {
2008 .type = HDA_FIXUP_VERBS,
2009 .v.verbs = (const struct hda_verb[]) {
2010 /* eanable EAPD on Acer laptops */
2011 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2012 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2016 [ALC882_FIXUP_GPIO1] = {
2017 .type = HDA_FIXUP_VERBS,
2018 .v.verbs = alc_gpio1_init_verbs,
2020 [ALC882_FIXUP_GPIO2] = {
2021 .type = HDA_FIXUP_VERBS,
2022 .v.verbs = alc_gpio2_init_verbs,
2024 [ALC882_FIXUP_GPIO3] = {
2025 .type = HDA_FIXUP_VERBS,
2026 .v.verbs = alc_gpio3_init_verbs,
2028 [ALC882_FIXUP_ASUS_W2JC] = {
2029 .type = HDA_FIXUP_VERBS,
2030 .v.verbs = alc_gpio1_init_verbs,
2032 .chain_id = ALC882_FIXUP_EAPD,
2034 [ALC889_FIXUP_COEF] = {
2035 .type = HDA_FIXUP_FUNC,
2036 .v.func = alc889_fixup_coef,
2038 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
2039 .type = HDA_FIXUP_PINS,
2040 .v.pins = (const struct hda_pintbl[]) {
2041 { 0x16, 0x99130111 }, /* CLFE speaker */
2042 { 0x17, 0x99130112 }, /* surround speaker */
2046 .chain_id = ALC882_FIXUP_GPIO1,
2048 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
2049 .type = HDA_FIXUP_PINS,
2050 .v.pins = (const struct hda_pintbl[]) {
2051 { 0x16, 0x99130111 }, /* CLFE speaker */
2052 { 0x1b, 0x99130112 }, /* surround speaker */
2056 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2058 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2059 /* additional init verbs for Acer Aspire 8930G */
2060 .type = HDA_FIXUP_VERBS,
2061 .v.verbs = (const struct hda_verb[]) {
2062 /* Enable all DACs */
2063 /* DAC DISABLE/MUTE 1? */
2064 /* setting bits 1-5 disables DAC nids 0x02-0x06
2065 * apparently. Init=0x38 */
2066 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2067 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2068 /* DAC DISABLE/MUTE 2? */
2069 /* some bit here disables the other DACs.
2071 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2072 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2074 * This laptop has a stereo digital microphone.
2075 * The mics are only 1cm apart which makes the stereo
2076 * useless. However, either the mic or the ALC889
2077 * makes the signal become a difference/sum signal
2078 * instead of standard stereo, which is annoying.
2079 * So instead we flip this bit which makes the
2080 * codec replicate the sum signal to both channels,
2081 * turning it into a normal mono mic.
2083 /* DMIC_CONTROL? Init value = 0x0001 */
2084 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2085 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2086 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2087 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2091 .chain_id = ALC882_FIXUP_GPIO1,
2093 [ALC885_FIXUP_MACPRO_GPIO] = {
2094 .type = HDA_FIXUP_FUNC,
2095 .v.func = alc885_fixup_macpro_gpio,
2097 [ALC889_FIXUP_DAC_ROUTE] = {
2098 .type = HDA_FIXUP_FUNC,
2099 .v.func = alc889_fixup_dac_route,
2101 [ALC889_FIXUP_MBP_VREF] = {
2102 .type = HDA_FIXUP_FUNC,
2103 .v.func = alc889_fixup_mbp_vref,
2105 .chain_id = ALC882_FIXUP_GPIO1,
2107 [ALC889_FIXUP_IMAC91_VREF] = {
2108 .type = HDA_FIXUP_FUNC,
2109 .v.func = alc889_fixup_imac91_vref,
2111 .chain_id = ALC882_FIXUP_GPIO1,
2113 [ALC889_FIXUP_MBA11_VREF] = {
2114 .type = HDA_FIXUP_FUNC,
2115 .v.func = alc889_fixup_mba11_vref,
2117 .chain_id = ALC889_FIXUP_MBP_VREF,
2119 [ALC889_FIXUP_MBA21_VREF] = {
2120 .type = HDA_FIXUP_FUNC,
2121 .v.func = alc889_fixup_mba21_vref,
2123 .chain_id = ALC889_FIXUP_MBP_VREF,
2125 [ALC889_FIXUP_MP11_VREF] = {
2126 .type = HDA_FIXUP_FUNC,
2127 .v.func = alc889_fixup_mba11_vref,
2129 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2131 [ALC882_FIXUP_INV_DMIC] = {
2132 .type = HDA_FIXUP_FUNC,
2133 .v.func = alc_fixup_inv_dmic_0x12,
2135 [ALC882_FIXUP_NO_PRIMARY_HP] = {
2136 .type = HDA_FIXUP_FUNC,
2137 .v.func = alc882_fixup_no_primary_hp,
2139 [ALC887_FIXUP_ASUS_BASS] = {
2140 .type = HDA_FIXUP_PINS,
2141 .v.pins = (const struct hda_pintbl[]) {
2142 {0x16, 0x99130130}, /* bass speaker */
2148 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2149 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2150 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2151 SND_PCI_QUIRK(0x1025, 0x0107, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2152 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2153 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2154 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2155 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
2156 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2157 ALC882_FIXUP_ACER_ASPIRE_4930G),
2158 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2159 ALC882_FIXUP_ACER_ASPIRE_4930G),
2160 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2161 ALC882_FIXUP_ACER_ASPIRE_8930G),
2162 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2163 ALC882_FIXUP_ACER_ASPIRE_8930G),
2164 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2165 ALC882_FIXUP_ACER_ASPIRE_4930G),
2166 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2167 ALC882_FIXUP_ACER_ASPIRE_4930G),
2168 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2169 ALC882_FIXUP_ACER_ASPIRE_4930G),
2170 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
2171 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2172 ALC882_FIXUP_ACER_ASPIRE_4930G),
2173 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
2174 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
2175 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
2176 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
2177 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
2178 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
2179 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
2180 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
2181 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
2182 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
2183 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
2185 /* All Apple entries are in codec SSIDs */
2186 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2187 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2188 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2189 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
2190 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2191 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
2192 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2193 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
2194 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
2195 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
2196 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
2197 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2198 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2199 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
2200 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2201 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2202 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
2203 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO),
2204 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
2205 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2206 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2207 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF),
2209 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
2210 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
2211 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
2212 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD),
2213 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
2214 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2215 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
2216 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
2217 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
2221 static const struct hda_model_fixup alc882_fixup_models[] = {
2222 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2223 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2224 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
2225 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
2226 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
2231 * BIOS auto configuration
2233 /* almost identical with ALC880 parser... */
2234 static int alc882_parse_auto_config(struct hda_codec *codec)
2236 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
2237 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2238 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
2243 static int patch_alc882(struct hda_codec *codec)
2245 struct alc_spec *spec;
2248 err = alc_alloc_spec(codec, 0x0b);
2254 switch (codec->vendor_id) {
2260 /* ALC883 and variants */
2261 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2265 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2267 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2269 alc_auto_parse_customize_define(codec);
2271 if (has_cdefine_beep(codec))
2272 spec->gen.beep_nid = 0x01;
2274 /* automatic parse from the BIOS config */
2275 err = alc882_parse_auto_config(codec);
2279 if (!spec->gen.no_analog && spec->gen.beep_nid)
2280 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2282 codec->patch_ops = alc_patch_ops;
2284 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2297 static int alc262_parse_auto_config(struct hda_codec *codec)
2299 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
2300 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2301 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
2308 ALC262_FIXUP_FSC_H270,
2309 ALC262_FIXUP_FSC_S7110,
2310 ALC262_FIXUP_HP_Z200,
2312 ALC262_FIXUP_LENOVO_3000,
2314 ALC262_FIXUP_BENQ_T31,
2315 ALC262_FIXUP_INV_DMIC,
2318 static const struct hda_fixup alc262_fixups[] = {
2319 [ALC262_FIXUP_FSC_H270] = {
2320 .type = HDA_FIXUP_PINS,
2321 .v.pins = (const struct hda_pintbl[]) {
2322 { 0x14, 0x99130110 }, /* speaker */
2323 { 0x15, 0x0221142f }, /* front HP */
2324 { 0x1b, 0x0121141f }, /* rear HP */
2328 [ALC262_FIXUP_FSC_S7110] = {
2329 .type = HDA_FIXUP_PINS,
2330 .v.pins = (const struct hda_pintbl[]) {
2331 { 0x15, 0x90170110 }, /* speaker */
2335 .chain_id = ALC262_FIXUP_BENQ,
2337 [ALC262_FIXUP_HP_Z200] = {
2338 .type = HDA_FIXUP_PINS,
2339 .v.pins = (const struct hda_pintbl[]) {
2340 { 0x16, 0x99130120 }, /* internal speaker */
2344 [ALC262_FIXUP_TYAN] = {
2345 .type = HDA_FIXUP_PINS,
2346 .v.pins = (const struct hda_pintbl[]) {
2347 { 0x14, 0x1993e1f0 }, /* int AUX */
2351 [ALC262_FIXUP_LENOVO_3000] = {
2352 .type = HDA_FIXUP_PINCTLS,
2353 .v.pins = (const struct hda_pintbl[]) {
2354 { 0x19, PIN_VREF50 },
2358 .chain_id = ALC262_FIXUP_BENQ,
2360 [ALC262_FIXUP_BENQ] = {
2361 .type = HDA_FIXUP_VERBS,
2362 .v.verbs = (const struct hda_verb[]) {
2363 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2364 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2368 [ALC262_FIXUP_BENQ_T31] = {
2369 .type = HDA_FIXUP_VERBS,
2370 .v.verbs = (const struct hda_verb[]) {
2371 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2372 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2376 [ALC262_FIXUP_INV_DMIC] = {
2377 .type = HDA_FIXUP_FUNC,
2378 .v.func = alc_fixup_inv_dmic_0x12,
2382 static const struct snd_pci_quirk alc262_fixup_tbl[] = {
2383 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
2384 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
2385 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
2386 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2387 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
2388 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
2389 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2390 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
2394 static const struct hda_model_fixup alc262_fixup_models[] = {
2395 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2401 static int patch_alc262(struct hda_codec *codec)
2403 struct alc_spec *spec;
2406 err = alc_alloc_spec(codec, 0x0b);
2411 spec->gen.shared_mic_vref_pin = 0x18;
2414 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
2419 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
2420 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
2421 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
2422 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
2425 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2427 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2429 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2431 alc_auto_parse_customize_define(codec);
2433 if (has_cdefine_beep(codec))
2434 spec->gen.beep_nid = 0x01;
2436 /* automatic parse from the BIOS config */
2437 err = alc262_parse_auto_config(codec);
2441 if (!spec->gen.no_analog && spec->gen.beep_nid)
2442 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2444 codec->patch_ops = alc_patch_ops;
2445 spec->shutup = alc_eapd_shutup;
2447 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2459 /* bind Beep switches of both NID 0x0f and 0x10 */
2460 static const struct hda_bind_ctls alc268_bind_beep_sw = {
2461 .ops = &snd_hda_bind_sw,
2463 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
2464 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
2469 static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2470 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2471 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
2475 /* set PCBEEP vol = 0, mute connections */
2476 static const struct hda_verb alc268_beep_init_verbs[] = {
2477 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2478 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2479 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2484 ALC268_FIXUP_INV_DMIC,
2485 ALC268_FIXUP_HP_EAPD,
2489 static const struct hda_fixup alc268_fixups[] = {
2490 [ALC268_FIXUP_INV_DMIC] = {
2491 .type = HDA_FIXUP_FUNC,
2492 .v.func = alc_fixup_inv_dmic_0x12,
2494 [ALC268_FIXUP_HP_EAPD] = {
2495 .type = HDA_FIXUP_VERBS,
2496 .v.verbs = (const struct hda_verb[]) {
2497 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2501 [ALC268_FIXUP_SPDIF] = {
2502 .type = HDA_FIXUP_PINS,
2503 .v.pins = (const struct hda_pintbl[]) {
2504 { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2510 static const struct hda_model_fixup alc268_fixup_models[] = {
2511 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
2512 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2516 static const struct snd_pci_quirk alc268_fixup_tbl[] = {
2517 SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
2518 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
2519 /* below is codec SSID since multiple Toshiba laptops have the
2520 * same PCI SSID 1179:ff00
2522 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
2527 * BIOS auto configuration
2529 static int alc268_parse_auto_config(struct hda_codec *codec)
2531 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2532 return alc_parse_auto_config(codec, NULL, alc268_ssids);
2537 static int patch_alc268(struct hda_codec *codec)
2539 struct alc_spec *spec;
2542 /* ALC268 has no aa-loopback mixer */
2543 err = alc_alloc_spec(codec, 0);
2548 spec->gen.beep_nid = 0x01;
2550 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2551 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2553 /* automatic parse from the BIOS config */
2554 err = alc268_parse_auto_config(codec);
2558 if (err > 0 && !spec->gen.no_analog &&
2559 spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2560 add_mixer(spec, alc268_beep_mixer);
2561 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
2562 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2563 /* override the amp caps for beep generator */
2564 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2565 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2566 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2567 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2568 (0 << AC_AMPCAP_MUTE_SHIFT));
2571 codec->patch_ops = alc_patch_ops;
2572 spec->shutup = alc_eapd_shutup;
2574 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2587 static int playback_pcm_open(struct hda_pcm_stream *hinfo,
2588 struct hda_codec *codec,
2589 struct snd_pcm_substream *substream)
2591 struct hda_gen_spec *spec = codec->spec;
2592 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2596 static int playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2597 struct hda_codec *codec,
2598 unsigned int stream_tag,
2599 unsigned int format,
2600 struct snd_pcm_substream *substream)
2602 struct hda_gen_spec *spec = codec->spec;
2603 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2604 stream_tag, format, substream);
2607 static int playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2608 struct hda_codec *codec,
2609 struct snd_pcm_substream *substream)
2611 struct hda_gen_spec *spec = codec->spec;
2612 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2615 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
2619 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2620 /* NID is set in alc_build_pcms */
2622 .open = playback_pcm_open,
2623 .prepare = playback_pcm_prepare,
2624 .cleanup = playback_pcm_cleanup
2628 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
2632 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
2633 /* NID is set in alc_build_pcms */
2636 /* different alc269-variants */
2638 ALC269_TYPE_ALC269VA,
2639 ALC269_TYPE_ALC269VB,
2640 ALC269_TYPE_ALC269VC,
2641 ALC269_TYPE_ALC269VD,
2650 * BIOS auto configuration
2652 static int alc269_parse_auto_config(struct hda_codec *codec)
2654 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
2655 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
2656 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2657 struct alc_spec *spec = codec->spec;
2658 const hda_nid_t *ssids;
2660 switch (spec->codec_variant) {
2661 case ALC269_TYPE_ALC269VA:
2662 case ALC269_TYPE_ALC269VC:
2663 case ALC269_TYPE_ALC280:
2664 case ALC269_TYPE_ALC284:
2665 ssids = alc269va_ssids;
2667 case ALC269_TYPE_ALC269VB:
2668 case ALC269_TYPE_ALC269VD:
2669 case ALC269_TYPE_ALC282:
2670 case ALC269_TYPE_ALC286:
2671 case ALC269_TYPE_ALC255:
2672 ssids = alc269_ssids;
2675 ssids = alc269_ssids;
2679 return alc_parse_auto_config(codec, alc269_ignore, ssids);
2682 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
2684 int val = alc_read_coef_idx(codec, 0x04);
2691 alc_write_coef_idx(codec, 0x04, val);
2694 static void alc269_shutup(struct hda_codec *codec)
2696 struct alc_spec *spec = codec->spec;
2698 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
2701 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2702 alc269vb_toggle_power_output(codec, 0);
2703 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2704 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
2710 static int alc269_resume(struct hda_codec *codec)
2712 struct alc_spec *spec = codec->spec;
2714 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2715 alc269vb_toggle_power_output(codec, 0);
2716 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2717 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
2721 codec->patch_ops.init(codec);
2723 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2724 alc269vb_toggle_power_output(codec, 1);
2725 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2726 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
2730 snd_hda_codec_resume_amp(codec);
2731 snd_hda_codec_resume_cache(codec);
2732 hda_call_check_power_status(codec, 0x01);
2735 #endif /* CONFIG_PM */
2737 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
2738 const struct hda_fixup *fix, int action)
2740 struct alc_spec *spec = codec->spec;
2742 if (action == HDA_FIXUP_ACT_PRE_PROBE)
2743 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
2746 static void alc269_fixup_hweq(struct hda_codec *codec,
2747 const struct hda_fixup *fix, int action)
2751 if (action != HDA_FIXUP_ACT_INIT)
2753 coef = alc_read_coef_idx(codec, 0x1e);
2754 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
2757 static void alc271_fixup_dmic(struct hda_codec *codec,
2758 const struct hda_fixup *fix, int action)
2760 static const struct hda_verb verbs[] = {
2761 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
2762 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
2767 if (strcmp(codec->chip_name, "ALC271X") &&
2768 strcmp(codec->chip_name, "ALC269VB"))
2770 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
2771 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
2772 snd_hda_sequence_write(codec, verbs);
2775 static void alc269_fixup_pcm_44k(struct hda_codec *codec,
2776 const struct hda_fixup *fix, int action)
2778 struct alc_spec *spec = codec->spec;
2780 if (action != HDA_FIXUP_ACT_PROBE)
2783 /* Due to a hardware problem on Lenovo Ideadpad, we need to
2784 * fix the sample rate of analog I/O to 44.1kHz
2786 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
2787 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
2790 static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
2791 const struct hda_fixup *fix, int action)
2795 if (action != HDA_FIXUP_ACT_INIT)
2797 /* The digital-mic unit sends PDM (differential signal) instead of
2798 * the standard PCM, thus you can't record a valid mono stream as is.
2799 * Below is a workaround specific to ALC269 to control the dmic
2800 * signal source as mono.
2802 coef = alc_read_coef_idx(codec, 0x07);
2803 alc_write_coef_idx(codec, 0x07, coef | 0x80);
2806 static void alc269_quanta_automute(struct hda_codec *codec)
2808 snd_hda_gen_update_outputs(codec);
2810 snd_hda_codec_write(codec, 0x20, 0,
2811 AC_VERB_SET_COEF_INDEX, 0x0c);
2812 snd_hda_codec_write(codec, 0x20, 0,
2813 AC_VERB_SET_PROC_COEF, 0x680);
2815 snd_hda_codec_write(codec, 0x20, 0,
2816 AC_VERB_SET_COEF_INDEX, 0x0c);
2817 snd_hda_codec_write(codec, 0x20, 0,
2818 AC_VERB_SET_PROC_COEF, 0x480);
2821 static void alc269_fixup_quanta_mute(struct hda_codec *codec,
2822 const struct hda_fixup *fix, int action)
2824 struct alc_spec *spec = codec->spec;
2825 if (action != HDA_FIXUP_ACT_PROBE)
2827 spec->gen.automute_hook = alc269_quanta_automute;
2830 static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
2831 struct hda_jack_tbl *jack)
2833 struct alc_spec *spec = codec->spec;
2836 snd_hda_gen_hp_automute(codec, jack);
2838 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
2840 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2843 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2847 static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
2848 const struct hda_fixup *fix, int action)
2850 struct alc_spec *spec = codec->spec;
2851 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2852 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
2853 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
2858 /* update mute-LED according to the speaker mute state via mic VREF pin */
2859 static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
2861 struct hda_codec *codec = private_data;
2862 struct alc_spec *spec = codec->spec;
2863 unsigned int pinval;
2865 if (spec->mute_led_polarity)
2867 pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
2868 pinval &= ~AC_PINCTL_VREFEN;
2869 pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
2870 if (spec->mute_led_nid)
2871 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
2874 /* Make sure the led works even in runtime suspend */
2875 static unsigned int led_power_filter(struct hda_codec *codec,
2877 unsigned int power_state)
2879 struct alc_spec *spec = codec->spec;
2881 if (power_state != AC_PWRST_D3 || nid != spec->mute_led_nid)
2884 /* Set pin ctl again, it might have just been set to 0 */
2885 snd_hda_set_pin_ctl(codec, nid,
2886 snd_hda_codec_get_pin_target(codec, nid));
2891 static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
2892 const struct hda_fixup *fix, int action)
2894 struct alc_spec *spec = codec->spec;
2895 const struct dmi_device *dev = NULL;
2897 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2900 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
2902 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
2904 if (pin < 0x0a || pin >= 0x10)
2906 spec->mute_led_polarity = pol;
2907 spec->mute_led_nid = pin - 0x0a + 0x18;
2908 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
2909 spec->gen.vmaster_mute_enum = 1;
2910 codec->power_filter = led_power_filter;
2911 snd_printd("Detected mute LED for %x:%d\n", spec->mute_led_nid,
2912 spec->mute_led_polarity);
2917 static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
2918 const struct hda_fixup *fix, int action)
2920 struct alc_spec *spec = codec->spec;
2921 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2922 spec->mute_led_polarity = 0;
2923 spec->mute_led_nid = 0x18;
2924 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
2925 spec->gen.vmaster_mute_enum = 1;
2926 codec->power_filter = led_power_filter;
2930 static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
2931 const struct hda_fixup *fix, int action)
2933 struct alc_spec *spec = codec->spec;
2934 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2935 spec->mute_led_polarity = 0;
2936 spec->mute_led_nid = 0x19;
2937 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
2938 spec->gen.vmaster_mute_enum = 1;
2939 codec->power_filter = led_power_filter;
2943 /* turn on/off mute LED per vmaster hook */
2944 static void alc269_fixup_hp_gpio_mute_hook(void *private_data, int enabled)
2946 struct hda_codec *codec = private_data;
2947 struct alc_spec *spec = codec->spec;
2948 unsigned int oldval = spec->gpio_led;
2951 spec->gpio_led &= ~0x08;
2953 spec->gpio_led |= 0x08;
2954 if (spec->gpio_led != oldval)
2955 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
2959 /* turn on/off mic-mute LED per capture hook */
2960 static void alc269_fixup_hp_gpio_mic_mute_hook(struct hda_codec *codec,
2961 struct snd_ctl_elem_value *ucontrol)
2963 struct alc_spec *spec = codec->spec;
2964 unsigned int oldval = spec->gpio_led;
2969 if (ucontrol->value.integer.value[0] ||
2970 ucontrol->value.integer.value[1])
2971 spec->gpio_led &= ~0x10;
2973 spec->gpio_led |= 0x10;
2974 if (spec->gpio_led != oldval)
2975 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
2979 static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
2980 const struct hda_fixup *fix, int action)
2982 struct alc_spec *spec = codec->spec;
2983 static const struct hda_verb gpio_init[] = {
2984 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
2985 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
2989 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2990 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
2991 spec->gen.cap_sync_hook = alc269_fixup_hp_gpio_mic_mute_hook;
2993 snd_hda_add_verbs(codec, gpio_init);
2997 static void alc_headset_mode_unplugged(struct hda_codec *codec)
3001 switch (codec->vendor_id) {
3003 alc_write_coef_idx(codec, 0x1b, 0x0c0b);
3004 alc_write_coef_idx(codec, 0x45, 0xc429);
3005 val = alc_read_coef_idx(codec, 0x35);
3006 alc_write_coef_idx(codec, 0x35, val & 0xbfff);
3007 alc_write_coef_idx(codec, 0x06, 0x2104);
3008 alc_write_coef_idx(codec, 0x1a, 0x0001);
3009 alc_write_coef_idx(codec, 0x26, 0x0004);
3010 alc_write_coef_idx(codec, 0x32, 0x42a3);
3013 alc_write_coef_idx(codec, 0x76, 0x000e);
3014 alc_write_coef_idx(codec, 0x6c, 0x2400);
3015 alc_write_coef_idx(codec, 0x18, 0x7308);
3016 alc_write_coef_idx(codec, 0x6b, 0xc429);
3019 alc_write_coef_idx(codec, 0x15, 0x0d40);
3020 alc_write_coef_idx(codec, 0xb7, 0x802b);
3023 snd_printdd("Headset jack set to unplugged mode.\n");
3027 static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
3032 switch (codec->vendor_id) {
3034 alc_write_coef_idx(codec, 0x45, 0xc429);
3035 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3036 val = alc_read_coef_idx(codec, 0x35);
3037 alc_write_coef_idx(codec, 0x35, val | 1<<14);
3038 alc_write_coef_idx(codec, 0x06, 0x2100);
3039 alc_write_coef_idx(codec, 0x1a, 0x0021);
3040 alc_write_coef_idx(codec, 0x26, 0x008c);
3041 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3044 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3045 alc_write_coef_idx(codec, 0x19, 0xa208);
3046 alc_write_coef_idx(codec, 0x2e, 0xacf0);
3049 alc_write_coef_idx(codec, 0x11, 0x0001);
3050 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3051 alc_write_coef_idx(codec, 0xb7, 0x802b);
3052 alc_write_coef_idx(codec, 0xb5, 0x1040);
3053 val = alc_read_coef_idx(codec, 0xc3);
3054 alc_write_coef_idx(codec, 0xc3, val | 1<<12);
3055 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3058 snd_printdd("Headset jack set to mic-in mode.\n");
3061 static void alc_headset_mode_default(struct hda_codec *codec)
3063 switch (codec->vendor_id) {
3065 alc_write_coef_idx(codec, 0x06, 0x2100);
3066 alc_write_coef_idx(codec, 0x32, 0x4ea3);
3069 alc_write_coef_idx(codec, 0x76, 0x000e);
3070 alc_write_coef_idx(codec, 0x6c, 0x2400);
3071 alc_write_coef_idx(codec, 0x6b, 0xc429);
3072 alc_write_coef_idx(codec, 0x18, 0x7308);
3075 alc_write_coef_idx(codec, 0x11, 0x0041);
3076 alc_write_coef_idx(codec, 0x15, 0x0d40);
3077 alc_write_coef_idx(codec, 0xb7, 0x802b);
3080 snd_printdd("Headset jack set to headphone (default) mode.\n");
3084 static void alc_headset_mode_ctia(struct hda_codec *codec)
3086 switch (codec->vendor_id) {
3088 alc_write_coef_idx(codec, 0x45, 0xd429);
3089 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3090 alc_write_coef_idx(codec, 0x32, 0x4ea3);
3093 alc_write_coef_idx(codec, 0x6b, 0xd429);
3094 alc_write_coef_idx(codec, 0x76, 0x0008);
3095 alc_write_coef_idx(codec, 0x18, 0x7388);
3098 alc_write_coef_idx(codec, 0x11, 0x0001);
3099 alc_write_coef_idx(codec, 0x15, 0x0d60);
3100 alc_write_coef_idx(codec, 0xc3, 0x0000);
3103 snd_printdd("Headset jack set to iPhone-style headset mode.\n");
3107 static void alc_headset_mode_omtp(struct hda_codec *codec)
3109 switch (codec->vendor_id) {
3111 alc_write_coef_idx(codec, 0x45, 0xe429);
3112 alc_write_coef_idx(codec, 0x1b, 0x0c2b);
3113 alc_write_coef_idx(codec, 0x32, 0x4ea3);
3116 alc_write_coef_idx(codec, 0x6b, 0xe429);
3117 alc_write_coef_idx(codec, 0x76, 0x0008);
3118 alc_write_coef_idx(codec, 0x18, 0x7388);
3121 alc_write_coef_idx(codec, 0x11, 0x0001);
3122 alc_write_coef_idx(codec, 0x15, 0x0d50);
3123 alc_write_coef_idx(codec, 0xc3, 0x0000);
3126 snd_printdd("Headset jack set to Nokia-style headset mode.\n");
3129 static void alc_determine_headset_type(struct hda_codec *codec)
3132 bool is_ctia = false;
3133 struct alc_spec *spec = codec->spec;
3135 switch (codec->vendor_id) {
3137 alc_write_coef_idx(codec, 0x45, 0xd029);
3139 val = alc_read_coef_idx(codec, 0x46);
3140 is_ctia = (val & 0x0070) == 0x0070;
3143 alc_write_coef_idx(codec, 0x6b, 0xd429);
3145 val = alc_read_coef_idx(codec, 0x6c);
3146 is_ctia = (val & 0x001c) == 0x001c;
3149 alc_write_coef_idx(codec, 0x11, 0x0001);
3150 alc_write_coef_idx(codec, 0xb7, 0x802b);
3151 alc_write_coef_idx(codec, 0x15, 0x0d60);
3152 alc_write_coef_idx(codec, 0xc3, 0x0c00);
3154 val = alc_read_coef_idx(codec, 0xbe);
3155 is_ctia = (val & 0x1c02) == 0x1c02;
3159 snd_printdd("Headset jack detected iPhone-style headset: %s\n",
3160 is_ctia ? "yes" : "no");
3161 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
3164 static void alc_update_headset_mode(struct hda_codec *codec)
3166 struct alc_spec *spec = codec->spec;
3168 hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
3169 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3171 int new_headset_mode;
3173 if (!snd_hda_jack_detect(codec, hp_pin))
3174 new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
3175 else if (mux_pin == spec->headset_mic_pin)
3176 new_headset_mode = ALC_HEADSET_MODE_HEADSET;
3177 else if (mux_pin == spec->headphone_mic_pin)
3178 new_headset_mode = ALC_HEADSET_MODE_MIC;
3180 new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
3182 if (new_headset_mode == spec->current_headset_mode) {
3183 snd_hda_gen_update_outputs(codec);
3187 switch (new_headset_mode) {
3188 case ALC_HEADSET_MODE_UNPLUGGED:
3189 alc_headset_mode_unplugged(codec);
3190 spec->gen.hp_jack_present = false;
3192 case ALC_HEADSET_MODE_HEADSET:
3193 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
3194 alc_determine_headset_type(codec);
3195 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
3196 alc_headset_mode_ctia(codec);
3197 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
3198 alc_headset_mode_omtp(codec);
3199 spec->gen.hp_jack_present = true;
3201 case ALC_HEADSET_MODE_MIC:
3202 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
3203 spec->gen.hp_jack_present = false;
3205 case ALC_HEADSET_MODE_HEADPHONE:
3206 alc_headset_mode_default(codec);
3207 spec->gen.hp_jack_present = true;
3210 if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
3211 snd_hda_set_pin_ctl_cache(codec, hp_pin,
3212 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3213 if (spec->headphone_mic_pin)
3214 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
3217 spec->current_headset_mode = new_headset_mode;
3219 snd_hda_gen_update_outputs(codec);
3222 static void alc_update_headset_mode_hook(struct hda_codec *codec,
3223 struct snd_ctl_elem_value *ucontrol)
3225 alc_update_headset_mode(codec);
3228 static void alc_update_headset_jack_cb(struct hda_codec *codec, struct hda_jack_tbl *jack)
3230 struct alc_spec *spec = codec->spec;
3231 spec->current_headset_type = ALC_HEADSET_MODE_UNKNOWN;
3232 snd_hda_gen_hp_automute(codec, jack);
3235 static void alc_probe_headset_mode(struct hda_codec *codec)
3238 struct alc_spec *spec = codec->spec;
3239 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
3242 for (i = 0; i < cfg->num_inputs; i++) {
3243 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
3244 spec->headset_mic_pin = cfg->inputs[i].pin;
3245 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
3246 spec->headphone_mic_pin = cfg->inputs[i].pin;
3249 spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
3250 spec->gen.automute_hook = alc_update_headset_mode;
3251 spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
3254 static void alc_fixup_headset_mode(struct hda_codec *codec,
3255 const struct hda_fixup *fix, int action)
3257 struct alc_spec *spec = codec->spec;
3260 case HDA_FIXUP_ACT_PRE_PROBE:
3261 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
3263 case HDA_FIXUP_ACT_PROBE:
3264 alc_probe_headset_mode(codec);
3266 case HDA_FIXUP_ACT_INIT:
3267 spec->current_headset_mode = 0;
3268 alc_update_headset_mode(codec);
3273 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
3274 const struct hda_fixup *fix, int action)
3276 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3277 struct alc_spec *spec = codec->spec;
3278 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3281 alc_fixup_headset_mode(codec, fix, action);
3284 static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
3285 const struct hda_fixup *fix, int action)
3287 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3289 alc_write_coef_idx(codec, 0xc4, 0x8000);
3290 val = alc_read_coef_idx(codec, 0xc2);
3291 alc_write_coef_idx(codec, 0xc2, val & 0xfe);
3292 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
3294 alc_fixup_headset_mode(codec, fix, action);
3297 static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
3298 const struct hda_fixup *fix,
3301 struct alc_spec *spec = codec->spec;
3303 if (action == HDA_FIXUP_ACT_PROBE) {
3304 if (snd_BUG_ON(!spec->gen.am_entry[1].pin ||
3305 !spec->gen.autocfg.hp_pins[0]))
3307 snd_hda_jack_set_gating_jack(codec, spec->gen.am_entry[1].pin,
3308 spec->gen.autocfg.hp_pins[0]);
3312 static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
3313 const struct hda_fixup *fix,
3316 struct alc_spec *spec = codec->spec;
3317 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
3320 /* The mic boosts on level 2 and 3 are too noisy
3321 on the internal mic input.
3322 Therefore limit the boost to 0 or 1. */
3324 if (action != HDA_FIXUP_ACT_PROBE)
3327 for (i = 0; i < cfg->num_inputs; i++) {
3328 hda_nid_t nid = cfg->inputs[i].pin;
3329 unsigned int defcfg;
3330 if (cfg->inputs[i].type != AUTO_PIN_MIC)
3332 defcfg = snd_hda_codec_get_pincfg(codec, nid);
3333 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
3336 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
3337 (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
3338 (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3339 (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
3340 (0 << AC_AMPCAP_MUTE_SHIFT));
3344 static void alc290_fixup_mono_speakers(struct hda_codec *codec,
3345 const struct hda_fixup *fix, int action)
3347 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3348 /* Remove DAC node 0x03, as it seems to be
3349 giving mono output */
3350 snd_hda_override_wcaps(codec, 0x03, 0);
3354 ALC269_FIXUP_SONY_VAIO,
3355 ALC275_FIXUP_SONY_VAIO_GPIO2,
3356 ALC269_FIXUP_DELL_M101Z,
3357 ALC269_FIXUP_SKU_IGNORE,
3358 ALC269_FIXUP_ASUS_G73JW,
3359 ALC269_FIXUP_LENOVO_EAPD,
3360 ALC275_FIXUP_SONY_HWEQ,
3362 ALC269_FIXUP_PCM_44K,
3363 ALC269_FIXUP_STEREO_DMIC,
3364 ALC269_FIXUP_QUANTA_MUTE,
3365 ALC269_FIXUP_LIFEBOOK,
3366 ALC269_FIXUP_LIFEBOOK_EXTMIC,
3367 ALC269_FIXUP_LIFEBOOK_HP_PIN,
3368 ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT,
3371 ALC269VB_FIXUP_AMIC,
3372 ALC269VB_FIXUP_DMIC,
3373 ALC269_FIXUP_HP_MUTE_LED,
3374 ALC269_FIXUP_HP_MUTE_LED_MIC1,
3375 ALC269_FIXUP_HP_MUTE_LED_MIC2,
3376 ALC269_FIXUP_HP_GPIO_LED,
3377 ALC269_FIXUP_INV_DMIC,
3378 ALC269_FIXUP_LENOVO_DOCK,
3379 ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
3380 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
3381 ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
3382 ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
3383 ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
3384 ALC290_FIXUP_MONO_SPEAKERS,
3385 ALC269_FIXUP_HEADSET_MODE,
3386 ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
3387 ALC269_FIXUP_ASPIRE_HEADSET_MIC,
3388 ALC269_FIXUP_ASUS_X101_FUNC,
3389 ALC269_FIXUP_ASUS_X101_VERB,
3390 ALC269_FIXUP_ASUS_X101,
3391 ALC271_FIXUP_AMIC_MIC2,
3392 ALC271_FIXUP_HP_GATE_MIC_JACK,
3393 ALC269_FIXUP_ACER_AC700,
3394 ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
3397 static const struct hda_fixup alc269_fixups[] = {
3398 [ALC269_FIXUP_SONY_VAIO] = {
3399 .type = HDA_FIXUP_PINCTLS,
3400 .v.pins = (const struct hda_pintbl[]) {
3401 {0x19, PIN_VREFGRD},
3405 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
3406 .type = HDA_FIXUP_VERBS,
3407 .v.verbs = (const struct hda_verb[]) {
3408 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
3409 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
3410 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3414 .chain_id = ALC269_FIXUP_SONY_VAIO
3416 [ALC269_FIXUP_DELL_M101Z] = {
3417 .type = HDA_FIXUP_VERBS,
3418 .v.verbs = (const struct hda_verb[]) {
3419 /* Enables internal speaker */
3420 {0x20, AC_VERB_SET_COEF_INDEX, 13},
3421 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
3425 [ALC269_FIXUP_SKU_IGNORE] = {
3426 .type = HDA_FIXUP_FUNC,
3427 .v.func = alc_fixup_sku_ignore,
3429 [ALC269_FIXUP_ASUS_G73JW] = {
3430 .type = HDA_FIXUP_PINS,
3431 .v.pins = (const struct hda_pintbl[]) {
3432 { 0x17, 0x99130111 }, /* subwoofer */
3436 [ALC269_FIXUP_LENOVO_EAPD] = {
3437 .type = HDA_FIXUP_VERBS,
3438 .v.verbs = (const struct hda_verb[]) {
3439 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
3443 [ALC275_FIXUP_SONY_HWEQ] = {
3444 .type = HDA_FIXUP_FUNC,
3445 .v.func = alc269_fixup_hweq,
3447 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
3449 [ALC271_FIXUP_DMIC] = {
3450 .type = HDA_FIXUP_FUNC,
3451 .v.func = alc271_fixup_dmic,
3453 [ALC269_FIXUP_PCM_44K] = {
3454 .type = HDA_FIXUP_FUNC,
3455 .v.func = alc269_fixup_pcm_44k,
3457 .chain_id = ALC269_FIXUP_QUANTA_MUTE
3459 [ALC269_FIXUP_STEREO_DMIC] = {
3460 .type = HDA_FIXUP_FUNC,
3461 .v.func = alc269_fixup_stereo_dmic,
3463 [ALC269_FIXUP_QUANTA_MUTE] = {
3464 .type = HDA_FIXUP_FUNC,
3465 .v.func = alc269_fixup_quanta_mute,
3467 [ALC269_FIXUP_LIFEBOOK] = {
3468 .type = HDA_FIXUP_PINS,
3469 .v.pins = (const struct hda_pintbl[]) {
3470 { 0x1a, 0x2101103f }, /* dock line-out */
3471 { 0x1b, 0x23a11040 }, /* dock mic-in */
3475 .chain_id = ALC269_FIXUP_QUANTA_MUTE
3477 [ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
3478 .type = HDA_FIXUP_PINS,
3479 .v.pins = (const struct hda_pintbl[]) {
3480 { 0x19, 0x01a1903c }, /* headset mic, with jack detect */
3484 [ALC269_FIXUP_LIFEBOOK_HP_PIN] = {
3485 .type = HDA_FIXUP_PINS,
3486 .v.pins = (const struct hda_pintbl[]) {
3487 { 0x21, 0x0221102f }, /* HP out */
3491 [ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT] = {
3492 .type = HDA_FIXUP_FUNC,
3493 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
3495 [ALC269_FIXUP_AMIC] = {
3496 .type = HDA_FIXUP_PINS,
3497 .v.pins = (const struct hda_pintbl[]) {
3498 { 0x14, 0x99130110 }, /* speaker */
3499 { 0x15, 0x0121401f }, /* HP out */
3500 { 0x18, 0x01a19c20 }, /* mic */
3501 { 0x19, 0x99a3092f }, /* int-mic */
3505 [ALC269_FIXUP_DMIC] = {
3506 .type = HDA_FIXUP_PINS,
3507 .v.pins = (const struct hda_pintbl[]) {
3508 { 0x12, 0x99a3092f }, /* int-mic */
3509 { 0x14, 0x99130110 }, /* speaker */
3510 { 0x15, 0x0121401f }, /* HP out */
3511 { 0x18, 0x01a19c20 }, /* mic */
3515 [ALC269VB_FIXUP_AMIC] = {
3516 .type = HDA_FIXUP_PINS,
3517 .v.pins = (const struct hda_pintbl[]) {
3518 { 0x14, 0x99130110 }, /* speaker */
3519 { 0x18, 0x01a19c20 }, /* mic */
3520 { 0x19, 0x99a3092f }, /* int-mic */
3521 { 0x21, 0x0121401f }, /* HP out */
3525 [ALC269VB_FIXUP_DMIC] = {
3526 .type = HDA_FIXUP_PINS,
3527 .v.pins = (const struct hda_pintbl[]) {
3528 { 0x12, 0x99a3092f }, /* int-mic */
3529 { 0x14, 0x99130110 }, /* speaker */
3530 { 0x18, 0x01a19c20 }, /* mic */
3531 { 0x21, 0x0121401f }, /* HP out */
3535 [ALC269_FIXUP_HP_MUTE_LED] = {
3536 .type = HDA_FIXUP_FUNC,
3537 .v.func = alc269_fixup_hp_mute_led,
3539 [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
3540 .type = HDA_FIXUP_FUNC,
3541 .v.func = alc269_fixup_hp_mute_led_mic1,
3543 [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
3544 .type = HDA_FIXUP_FUNC,
3545 .v.func = alc269_fixup_hp_mute_led_mic2,
3547 [ALC269_FIXUP_HP_GPIO_LED] = {
3548 .type = HDA_FIXUP_FUNC,
3549 .v.func = alc269_fixup_hp_gpio_led,
3551 [ALC269_FIXUP_INV_DMIC] = {
3552 .type = HDA_FIXUP_FUNC,
3553 .v.func = alc_fixup_inv_dmic_0x12,
3555 [ALC269_FIXUP_LENOVO_DOCK] = {
3556 .type = HDA_FIXUP_PINS,
3557 .v.pins = (const struct hda_pintbl[]) {
3558 { 0x19, 0x23a11040 }, /* dock mic */
3559 { 0x1b, 0x2121103f }, /* dock headphone */
3563 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
3565 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
3566 .type = HDA_FIXUP_FUNC,
3567 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
3569 [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
3570 .type = HDA_FIXUP_PINS,
3571 .v.pins = (const struct hda_pintbl[]) {
3572 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
3573 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
3577 .chain_id = ALC269_FIXUP_HEADSET_MODE
3579 [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
3580 .type = HDA_FIXUP_PINS,
3581 .v.pins = (const struct hda_pintbl[]) {
3582 { 0x16, 0x21014020 }, /* dock line out */
3583 { 0x19, 0x21a19030 }, /* dock mic */
3584 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
3588 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
3590 [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
3591 .type = HDA_FIXUP_PINS,
3592 .v.pins = (const struct hda_pintbl[]) {
3593 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
3597 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
3599 [ALC269_FIXUP_HEADSET_MODE] = {
3600 .type = HDA_FIXUP_FUNC,
3601 .v.func = alc_fixup_headset_mode,
3603 [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
3604 .type = HDA_FIXUP_FUNC,
3605 .v.func = alc_fixup_headset_mode_no_hp_mic,
3607 [ALC269_FIXUP_ASPIRE_HEADSET_MIC] = {
3608 .type = HDA_FIXUP_PINS,
3609 .v.pins = (const struct hda_pintbl[]) {
3610 { 0x19, 0x01a1913c }, /* headset mic w/o jack detect */
3614 .chain_id = ALC269_FIXUP_HEADSET_MODE,
3616 [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
3617 .type = HDA_FIXUP_PINS,
3618 .v.pins = (const struct hda_pintbl[]) {
3619 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
3623 [ALC269_FIXUP_ASUS_X101_FUNC] = {
3624 .type = HDA_FIXUP_FUNC,
3625 .v.func = alc269_fixup_x101_headset_mic,
3627 [ALC269_FIXUP_ASUS_X101_VERB] = {
3628 .type = HDA_FIXUP_VERBS,
3629 .v.verbs = (const struct hda_verb[]) {
3630 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3631 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
3632 {0x20, AC_VERB_SET_PROC_COEF, 0x0310},
3636 .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
3638 [ALC269_FIXUP_ASUS_X101] = {
3639 .type = HDA_FIXUP_PINS,
3640 .v.pins = (const struct hda_pintbl[]) {
3641 { 0x18, 0x04a1182c }, /* Headset mic */
3645 .chain_id = ALC269_FIXUP_ASUS_X101_VERB
3647 [ALC271_FIXUP_AMIC_MIC2] = {
3648 .type = HDA_FIXUP_PINS,
3649 .v.pins = (const struct hda_pintbl[]) {
3650 { 0x14, 0x99130110 }, /* speaker */
3651 { 0x19, 0x01a19c20 }, /* mic */
3652 { 0x1b, 0x99a7012f }, /* int-mic */
3653 { 0x21, 0x0121401f }, /* HP out */
3657 [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
3658 .type = HDA_FIXUP_FUNC,
3659 .v.func = alc271_hp_gate_mic_jack,
3661 .chain_id = ALC271_FIXUP_AMIC_MIC2,
3663 [ALC269_FIXUP_ACER_AC700] = {
3664 .type = HDA_FIXUP_PINS,
3665 .v.pins = (const struct hda_pintbl[]) {
3666 { 0x12, 0x99a3092f }, /* int-mic */
3667 { 0x14, 0x99130110 }, /* speaker */
3668 { 0x18, 0x03a11c20 }, /* mic */
3669 { 0x1e, 0x0346101e }, /* SPDIF1 */
3670 { 0x21, 0x0321101f }, /* HP out */
3674 .chain_id = ALC271_FIXUP_DMIC,
3676 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
3677 .type = HDA_FIXUP_FUNC,
3678 .v.func = alc269_fixup_limit_int_mic_boost,
3680 [ALC290_FIXUP_MONO_SPEAKERS] = {
3681 .type = HDA_FIXUP_FUNC,
3682 .v.func = alc290_fixup_mono_speakers,
3684 .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
3688 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
3689 SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
3690 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
3691 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
3692 SND_PCI_QUIRK(0x1028, 0x05bd, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
3693 SND_PCI_QUIRK(0x1028, 0x05be, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
3694 SND_PCI_QUIRK(0x1028, 0x05c4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3695 SND_PCI_QUIRK(0x1028, 0x05c5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3696 SND_PCI_QUIRK(0x1028, 0x05c6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3697 SND_PCI_QUIRK(0x1028, 0x05c7, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3698 SND_PCI_QUIRK(0x1028, 0x05c8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3699 SND_PCI_QUIRK(0x1028, 0x05c9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3700 SND_PCI_QUIRK(0x1028, 0x05ca, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
3701 SND_PCI_QUIRK(0x1028, 0x05cb, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
3702 SND_PCI_QUIRK(0x1028, 0x05de, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
3703 SND_PCI_QUIRK(0x1028, 0x05e0, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
3704 SND_PCI_QUIRK(0x1028, 0x05e9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3705 SND_PCI_QUIRK(0x1028, 0x05ea, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3706 SND_PCI_QUIRK(0x1028, 0x05eb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3707 SND_PCI_QUIRK(0x1028, 0x05ec, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3708 SND_PCI_QUIRK(0x1028, 0x05ed, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3709 SND_PCI_QUIRK(0x1028, 0x05ee, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3710 SND_PCI_QUIRK(0x1028, 0x05f3, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3711 SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3712 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3713 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3714 SND_PCI_QUIRK(0x1028, 0x05f8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3715 SND_PCI_QUIRK(0x1028, 0x05f9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3716 SND_PCI_QUIRK(0x1028, 0x05fb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3717 SND_PCI_QUIRK(0x1028, 0x0606, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3718 SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3719 SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3720 SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3721 SND_PCI_QUIRK(0x1028, 0x0614, "Dell Inspiron 3135", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
3722 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_MONO_SPEAKERS),
3723 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS),
3724 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
3725 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
3726 SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
3727 SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
3728 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
3729 SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
3730 SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
3731 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC),
3732 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC),
3733 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
3734 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
3735 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
3736 SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
3737 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
3738 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
3739 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
3740 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
3741 SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
3742 SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
3743 SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
3744 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
3745 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
3746 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
3747 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
3748 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
3749 SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
3750 SND_PCI_QUIRK(0x1025, 0x072d, "Acer Aspire V5-571G", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
3751 SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
3752 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
3753 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
3754 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
3755 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
3756 SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT),
3757 SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
3758 SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
3759 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
3760 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
3761 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
3762 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
3763 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
3764 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
3765 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
3766 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
3767 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
3768 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
3769 SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
3770 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
3771 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
3772 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
3775 /* Below is a quirk table taken from the old code.
3776 * Basically the device should work as is without the fixup table.
3777 * If BIOS doesn't give a proper info, enable the corresponding
3780 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
3782 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
3783 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
3784 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
3785 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
3786 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
3787 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
3788 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
3789 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
3790 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
3791 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
3792 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
3793 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
3794 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
3795 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
3796 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
3797 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
3798 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
3799 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
3800 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
3801 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
3802 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
3803 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
3804 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
3805 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
3806 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
3807 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
3808 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
3809 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
3810 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
3811 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
3812 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
3813 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
3814 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
3815 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
3816 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
3817 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
3818 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
3819 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
3820 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
3825 static const struct hda_model_fixup alc269_fixup_models[] = {
3826 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
3827 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
3828 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
3829 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
3830 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
3831 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
3832 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
3833 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
3834 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
3839 static void alc269_fill_coef(struct hda_codec *codec)
3841 struct alc_spec *spec = codec->spec;
3844 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
3847 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
3848 alc_write_coef_idx(codec, 0xf, 0x960b);
3849 alc_write_coef_idx(codec, 0xe, 0x8817);
3852 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
3853 alc_write_coef_idx(codec, 0xf, 0x960b);
3854 alc_write_coef_idx(codec, 0xe, 0x8814);
3857 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
3858 val = alc_read_coef_idx(codec, 0x04);
3859 /* Power up output pin */
3861 alc_write_coef_idx(codec, 0x04, val | (1<<11));
3864 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
3865 val = alc_read_coef_idx(codec, 0xd);
3866 if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
3867 /* Capless ramp up clock control */
3868 alc_write_coef_idx(codec, 0xd, val | (1<<10));
3870 val = alc_read_coef_idx(codec, 0x17);
3871 if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
3872 /* Class D power on reset */
3873 alc_write_coef_idx(codec, 0x17, val | (1<<7));
3877 val = alc_read_coef_idx(codec, 0xd); /* Class D */
3879 alc_write_coef_idx(codec, 0xd, val | (1<<14));
3881 val = alc_read_coef_idx(codec, 0x4); /* HP */
3883 alc_write_coef_idx(codec, 0x4, val | (1<<11));
3888 static int patch_alc269(struct hda_codec *codec)
3890 struct alc_spec *spec;
3893 err = alc_alloc_spec(codec, 0x0b);
3898 spec->gen.shared_mic_vref_pin = 0x18;
3900 snd_hda_pick_fixup(codec, alc269_fixup_models,
3901 alc269_fixup_tbl, alc269_fixups);
3902 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3904 alc_auto_parse_customize_define(codec);
3906 if (has_cdefine_beep(codec))
3907 spec->gen.beep_nid = 0x01;
3909 switch (codec->vendor_id) {
3911 spec->codec_variant = ALC269_TYPE_ALC269VA;
3912 switch (alc_get_coef0(codec) & 0x00f0) {
3914 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
3915 spec->cdefine.platform_type == 1)
3916 err = alc_codec_rename(codec, "ALC271X");
3917 spec->codec_variant = ALC269_TYPE_ALC269VB;
3920 if (codec->bus->pci->subsystem_vendor == 0x17aa &&
3921 codec->bus->pci->subsystem_device == 0x21f3)
3922 err = alc_codec_rename(codec, "ALC3202");
3923 spec->codec_variant = ALC269_TYPE_ALC269VC;
3926 spec->codec_variant = ALC269_TYPE_ALC269VD;
3929 alc_fix_pll_init(codec, 0x20, 0x04, 15);
3933 spec->init_hook = alc269_fill_coef;
3934 alc269_fill_coef(codec);
3939 spec->codec_variant = ALC269_TYPE_ALC280;
3944 spec->codec_variant = ALC269_TYPE_ALC282;
3948 spec->codec_variant = ALC269_TYPE_ALC284;
3952 spec->codec_variant = ALC269_TYPE_ALC286;
3955 spec->codec_variant = ALC269_TYPE_ALC255;
3959 /* automatic parse from the BIOS config */
3960 err = alc269_parse_auto_config(codec);
3964 if (!spec->gen.no_analog && spec->gen.beep_nid)
3965 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
3967 codec->patch_ops = alc_patch_ops;
3969 codec->patch_ops.resume = alc269_resume;
3971 spec->shutup = alc269_shutup;
3973 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3986 static int alc861_parse_auto_config(struct hda_codec *codec)
3988 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
3989 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
3990 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
3993 /* Pin config fixes */
3995 ALC861_FIXUP_FSC_AMILO_PI1505,
3996 ALC861_FIXUP_AMP_VREF_0F,
3997 ALC861_FIXUP_NO_JACK_DETECT,
3998 ALC861_FIXUP_ASUS_A6RP,
3999 ALC660_FIXUP_ASUS_W7J,
4002 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
4003 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
4004 const struct hda_fixup *fix, int action)
4006 struct alc_spec *spec = codec->spec;
4009 if (action != HDA_FIXUP_ACT_INIT)
4011 val = snd_hda_codec_get_pin_target(codec, 0x0f);
4012 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
4013 val |= AC_PINCTL_IN_EN;
4014 val |= AC_PINCTL_VREF_50;
4015 snd_hda_set_pin_ctl(codec, 0x0f, val);
4016 spec->gen.keep_vref_in_automute = 1;
4019 /* suppress the jack-detection */
4020 static void alc_fixup_no_jack_detect(struct hda_codec *codec,
4021 const struct hda_fixup *fix, int action)
4023 if (action == HDA_FIXUP_ACT_PRE_PROBE)
4024 codec->no_jack_detect = 1;
4027 static const struct hda_fixup alc861_fixups[] = {
4028 [ALC861_FIXUP_FSC_AMILO_PI1505] = {
4029 .type = HDA_FIXUP_PINS,
4030 .v.pins = (const struct hda_pintbl[]) {
4031 { 0x0b, 0x0221101f }, /* HP */
4032 { 0x0f, 0x90170310 }, /* speaker */
4036 [ALC861_FIXUP_AMP_VREF_0F] = {
4037 .type = HDA_FIXUP_FUNC,
4038 .v.func = alc861_fixup_asus_amp_vref_0f,
4040 [ALC861_FIXUP_NO_JACK_DETECT] = {
4041 .type = HDA_FIXUP_FUNC,
4042 .v.func = alc_fixup_no_jack_detect,
4044 [ALC861_FIXUP_ASUS_A6RP] = {
4045 .type = HDA_FIXUP_FUNC,
4046 .v.func = alc861_fixup_asus_amp_vref_0f,
4048 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
4050 [ALC660_FIXUP_ASUS_W7J] = {
4051 .type = HDA_FIXUP_VERBS,
4052 .v.verbs = (const struct hda_verb[]) {
4053 /* ASUS W7J needs a magic pin setup on unused NID 0x10
4054 * for enabling outputs
4056 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4062 static const struct snd_pci_quirk alc861_fixup_tbl[] = {
4063 SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
4064 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
4065 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
4066 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
4067 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
4068 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
4069 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
4070 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
4076 static int patch_alc861(struct hda_codec *codec)
4078 struct alc_spec *spec;
4081 err = alc_alloc_spec(codec, 0x15);
4086 spec->gen.beep_nid = 0x23;
4088 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
4089 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4091 /* automatic parse from the BIOS config */
4092 err = alc861_parse_auto_config(codec);
4096 if (!spec->gen.no_analog)
4097 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
4099 codec->patch_ops = alc_patch_ops;
4101 spec->power_hook = alc_power_eapd;
4104 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4118 * In addition, an independent DAC
4120 static int alc861vd_parse_auto_config(struct hda_codec *codec)
4122 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
4123 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4124 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
4128 ALC660VD_FIX_ASUS_GPIO1,
4129 ALC861VD_FIX_DALLAS,
4132 /* exclude VREF80 */
4133 static void alc861vd_fixup_dallas(struct hda_codec *codec,
4134 const struct hda_fixup *fix, int action)
4136 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4137 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
4138 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
4142 static const struct hda_fixup alc861vd_fixups[] = {
4143 [ALC660VD_FIX_ASUS_GPIO1] = {
4144 .type = HDA_FIXUP_VERBS,
4145 .v.verbs = (const struct hda_verb[]) {
4147 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
4148 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4149 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4153 [ALC861VD_FIX_DALLAS] = {
4154 .type = HDA_FIXUP_FUNC,
4155 .v.func = alc861vd_fixup_dallas,
4159 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
4160 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
4161 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
4162 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
4168 static int patch_alc861vd(struct hda_codec *codec)
4170 struct alc_spec *spec;
4173 err = alc_alloc_spec(codec, 0x0b);
4178 spec->gen.beep_nid = 0x23;
4180 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
4181 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4183 /* automatic parse from the BIOS config */
4184 err = alc861vd_parse_auto_config(codec);
4188 if (!spec->gen.no_analog)
4189 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4191 codec->patch_ops = alc_patch_ops;
4193 spec->shutup = alc_eapd_shutup;
4195 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4207 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
4208 * configuration. Each pin widget can choose any input DACs and a mixer.
4209 * Each ADC is connected from a mixer of all inputs. This makes possible
4210 * 6-channel independent captures.
4212 * In addition, an independent DAC for the multi-playback (not used in this
4217 * BIOS auto configuration
4220 static int alc662_parse_auto_config(struct hda_codec *codec)
4222 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
4223 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
4224 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
4225 const hda_nid_t *ssids;
4227 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
4228 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670 ||
4229 codec->vendor_id == 0x10ec0671)
4230 ssids = alc663_ssids;
4232 ssids = alc662_ssids;
4233 return alc_parse_auto_config(codec, alc662_ignore, ssids);
4236 static void alc272_fixup_mario(struct hda_codec *codec,
4237 const struct hda_fixup *fix, int action)
4239 if (action != HDA_FIXUP_ACT_PRE_PROBE)
4241 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
4242 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
4243 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
4244 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4245 (0 << AC_AMPCAP_MUTE_SHIFT)))
4247 "hda_codec: failed to override amp caps for NID 0x2\n");
4251 ALC662_FIXUP_ASPIRE,
4252 ALC662_FIXUP_IDEAPAD,
4254 ALC662_FIXUP_CZC_P10T,
4255 ALC662_FIXUP_SKU_IGNORE,
4256 ALC662_FIXUP_HP_RP5800,
4257 ALC662_FIXUP_ASUS_MODE1,
4258 ALC662_FIXUP_ASUS_MODE2,
4259 ALC662_FIXUP_ASUS_MODE3,
4260 ALC662_FIXUP_ASUS_MODE4,
4261 ALC662_FIXUP_ASUS_MODE5,
4262 ALC662_FIXUP_ASUS_MODE6,
4263 ALC662_FIXUP_ASUS_MODE7,
4264 ALC662_FIXUP_ASUS_MODE8,
4265 ALC662_FIXUP_NO_JACK_DETECT,
4266 ALC662_FIXUP_ZOTAC_Z68,
4267 ALC662_FIXUP_INV_DMIC,
4268 ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
4269 ALC668_FIXUP_HEADSET_MODE,
4272 static const struct hda_fixup alc662_fixups[] = {
4273 [ALC662_FIXUP_ASPIRE] = {
4274 .type = HDA_FIXUP_PINS,
4275 .v.pins = (const struct hda_pintbl[]) {
4276 { 0x15, 0x99130112 }, /* subwoofer */
4280 [ALC662_FIXUP_IDEAPAD] = {
4281 .type = HDA_FIXUP_PINS,
4282 .v.pins = (const struct hda_pintbl[]) {
4283 { 0x17, 0x99130112 }, /* subwoofer */
4287 [ALC272_FIXUP_MARIO] = {
4288 .type = HDA_FIXUP_FUNC,
4289 .v.func = alc272_fixup_mario,
4291 [ALC662_FIXUP_CZC_P10T] = {
4292 .type = HDA_FIXUP_VERBS,
4293 .v.verbs = (const struct hda_verb[]) {
4294 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
4298 [ALC662_FIXUP_SKU_IGNORE] = {
4299 .type = HDA_FIXUP_FUNC,
4300 .v.func = alc_fixup_sku_ignore,
4302 [ALC662_FIXUP_HP_RP5800] = {
4303 .type = HDA_FIXUP_PINS,
4304 .v.pins = (const struct hda_pintbl[]) {
4305 { 0x14, 0x0221201f }, /* HP out */
4309 .chain_id = ALC662_FIXUP_SKU_IGNORE
4311 [ALC662_FIXUP_ASUS_MODE1] = {
4312 .type = HDA_FIXUP_PINS,
4313 .v.pins = (const struct hda_pintbl[]) {
4314 { 0x14, 0x99130110 }, /* speaker */
4315 { 0x18, 0x01a19c20 }, /* mic */
4316 { 0x19, 0x99a3092f }, /* int-mic */
4317 { 0x21, 0x0121401f }, /* HP out */
4321 .chain_id = ALC662_FIXUP_SKU_IGNORE
4323 [ALC662_FIXUP_ASUS_MODE2] = {
4324 .type = HDA_FIXUP_PINS,
4325 .v.pins = (const struct hda_pintbl[]) {
4326 { 0x14, 0x99130110 }, /* speaker */
4327 { 0x18, 0x01a19820 }, /* mic */
4328 { 0x19, 0x99a3092f }, /* int-mic */
4329 { 0x1b, 0x0121401f }, /* HP out */
4333 .chain_id = ALC662_FIXUP_SKU_IGNORE
4335 [ALC662_FIXUP_ASUS_MODE3] = {
4336 .type = HDA_FIXUP_PINS,
4337 .v.pins = (const struct hda_pintbl[]) {
4338 { 0x14, 0x99130110 }, /* speaker */
4339 { 0x15, 0x0121441f }, /* HP */
4340 { 0x18, 0x01a19840 }, /* mic */
4341 { 0x19, 0x99a3094f }, /* int-mic */
4342 { 0x21, 0x01211420 }, /* HP2 */
4346 .chain_id = ALC662_FIXUP_SKU_IGNORE
4348 [ALC662_FIXUP_ASUS_MODE4] = {
4349 .type = HDA_FIXUP_PINS,
4350 .v.pins = (const struct hda_pintbl[]) {
4351 { 0x14, 0x99130110 }, /* speaker */
4352 { 0x16, 0x99130111 }, /* speaker */
4353 { 0x18, 0x01a19840 }, /* mic */
4354 { 0x19, 0x99a3094f }, /* int-mic */
4355 { 0x21, 0x0121441f }, /* HP */
4359 .chain_id = ALC662_FIXUP_SKU_IGNORE
4361 [ALC662_FIXUP_ASUS_MODE5] = {
4362 .type = HDA_FIXUP_PINS,
4363 .v.pins = (const struct hda_pintbl[]) {
4364 { 0x14, 0x99130110 }, /* speaker */
4365 { 0x15, 0x0121441f }, /* HP */
4366 { 0x16, 0x99130111 }, /* speaker */
4367 { 0x18, 0x01a19840 }, /* mic */
4368 { 0x19, 0x99a3094f }, /* int-mic */
4372 .chain_id = ALC662_FIXUP_SKU_IGNORE
4374 [ALC662_FIXUP_ASUS_MODE6] = {
4375 .type = HDA_FIXUP_PINS,
4376 .v.pins = (const struct hda_pintbl[]) {
4377 { 0x14, 0x99130110 }, /* speaker */
4378 { 0x15, 0x01211420 }, /* HP2 */
4379 { 0x18, 0x01a19840 }, /* mic */
4380 { 0x19, 0x99a3094f }, /* int-mic */
4381 { 0x1b, 0x0121441f }, /* HP */
4385 .chain_id = ALC662_FIXUP_SKU_IGNORE
4387 [ALC662_FIXUP_ASUS_MODE7] = {
4388 .type = HDA_FIXUP_PINS,
4389 .v.pins = (const struct hda_pintbl[]) {
4390 { 0x14, 0x99130110 }, /* speaker */
4391 { 0x17, 0x99130111 }, /* speaker */
4392 { 0x18, 0x01a19840 }, /* mic */
4393 { 0x19, 0x99a3094f }, /* int-mic */
4394 { 0x1b, 0x01214020 }, /* HP */
4395 { 0x21, 0x0121401f }, /* HP */
4399 .chain_id = ALC662_FIXUP_SKU_IGNORE
4401 [ALC662_FIXUP_ASUS_MODE8] = {
4402 .type = HDA_FIXUP_PINS,
4403 .v.pins = (const struct hda_pintbl[]) {
4404 { 0x14, 0x99130110 }, /* speaker */
4405 { 0x12, 0x99a30970 }, /* int-mic */
4406 { 0x15, 0x01214020 }, /* HP */
4407 { 0x17, 0x99130111 }, /* speaker */
4408 { 0x18, 0x01a19840 }, /* mic */
4409 { 0x21, 0x0121401f }, /* HP */
4413 .chain_id = ALC662_FIXUP_SKU_IGNORE
4415 [ALC662_FIXUP_NO_JACK_DETECT] = {
4416 .type = HDA_FIXUP_FUNC,
4417 .v.func = alc_fixup_no_jack_detect,
4419 [ALC662_FIXUP_ZOTAC_Z68] = {
4420 .type = HDA_FIXUP_PINS,
4421 .v.pins = (const struct hda_pintbl[]) {
4422 { 0x1b, 0x02214020 }, /* Front HP */
4426 [ALC662_FIXUP_INV_DMIC] = {
4427 .type = HDA_FIXUP_FUNC,
4428 .v.func = alc_fixup_inv_dmic_0x12,
4430 [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
4431 .type = HDA_FIXUP_PINS,
4432 .v.pins = (const struct hda_pintbl[]) {
4433 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
4434 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
4438 .chain_id = ALC668_FIXUP_HEADSET_MODE
4440 [ALC668_FIXUP_HEADSET_MODE] = {
4441 .type = HDA_FIXUP_FUNC,
4442 .v.func = alc_fixup_headset_mode_alc668,
4446 static const struct snd_pci_quirk alc662_fixup_tbl[] = {
4447 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
4448 SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
4449 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
4450 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
4451 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
4452 SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
4453 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
4454 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
4455 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
4456 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
4457 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_ASUS_MODE4),
4458 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_ASUS_MODE4),
4459 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
4460 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
4461 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
4462 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
4463 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
4464 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
4465 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
4468 /* Below is a quirk table taken from the old code.
4469 * Basically the device should work as is without the fixup table.
4470 * If BIOS doesn't give a proper info, enable the corresponding
4473 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
4474 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
4475 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
4476 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
4477 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
4478 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
4479 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
4480 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
4481 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
4482 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
4483 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
4484 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
4485 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
4486 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
4487 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
4488 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
4489 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
4490 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
4491 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
4492 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
4493 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
4494 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
4495 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
4496 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
4497 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
4498 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
4499 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
4500 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
4501 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
4502 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
4503 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
4504 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
4505 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
4506 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
4507 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
4508 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
4509 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
4510 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
4511 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
4512 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
4513 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
4514 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
4515 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
4516 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
4517 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
4518 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
4519 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
4520 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
4521 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
4522 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
4527 static const struct hda_model_fixup alc662_fixup_models[] = {
4528 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
4529 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
4530 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
4531 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
4532 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
4533 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
4534 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
4535 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
4536 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
4537 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
4538 {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
4542 static void alc662_fill_coef(struct hda_codec *codec)
4546 coef = alc_get_coef0(codec);
4548 switch (codec->vendor_id) {
4550 if ((coef & 0x00f0) == 0x0030) {
4551 val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */
4552 alc_write_coef_idx(codec, 0x4, val & ~(1<<10));
4562 val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */
4563 alc_write_coef_idx(codec, 0xd, val | (1<<14));
4570 static int patch_alc662(struct hda_codec *codec)
4572 struct alc_spec *spec;
4575 err = alc_alloc_spec(codec, 0x0b);
4581 /* handle multiple HPs as is */
4582 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
4584 alc_fix_pll_init(codec, 0x20, 0x04, 15);
4586 spec->init_hook = alc662_fill_coef;
4587 alc662_fill_coef(codec);
4589 snd_hda_pick_fixup(codec, alc662_fixup_models,
4590 alc662_fixup_tbl, alc662_fixups);
4591 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4593 alc_auto_parse_customize_define(codec);
4595 if (has_cdefine_beep(codec))
4596 spec->gen.beep_nid = 0x01;
4598 if ((alc_get_coef0(codec) & (1 << 14)) &&
4599 codec->bus->pci->subsystem_vendor == 0x1025 &&
4600 spec->cdefine.platform_type == 1) {
4601 err = alc_codec_rename(codec, "ALC272X");
4606 /* automatic parse from the BIOS config */
4607 err = alc662_parse_auto_config(codec);
4611 if (!spec->gen.no_analog && spec->gen.beep_nid) {
4612 switch (codec->vendor_id) {
4614 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4620 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
4623 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
4628 codec->patch_ops = alc_patch_ops;
4629 spec->shutup = alc_eapd_shutup;
4631 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4644 static int alc680_parse_auto_config(struct hda_codec *codec)
4646 return alc_parse_auto_config(codec, NULL, NULL);
4651 static int patch_alc680(struct hda_codec *codec)
4655 /* ALC680 has no aa-loopback mixer */
4656 err = alc_alloc_spec(codec, 0);
4660 /* automatic parse from the BIOS config */
4661 err = alc680_parse_auto_config(codec);
4667 codec->patch_ops = alc_patch_ops;
4675 static const struct hda_codec_preset snd_hda_preset_realtek[] = {
4676 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
4677 { .id = 0x10ec0231, .name = "ALC231", .patch = patch_alc269 },
4678 { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
4679 { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 },
4680 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
4681 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
4682 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
4683 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
4684 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
4685 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
4686 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
4687 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
4688 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
4689 { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 },
4690 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
4691 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
4692 { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
4693 { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 },
4694 { .id = 0x10ec0288, .name = "ALC288", .patch = patch_alc269 },
4695 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
4696 { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
4697 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
4698 .patch = patch_alc861 },
4699 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
4700 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
4701 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
4702 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
4703 .patch = patch_alc882 },
4704 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
4705 .patch = patch_alc662 },
4706 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
4707 .patch = patch_alc662 },
4708 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
4709 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
4710 { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 },
4711 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
4712 { .id = 0x10ec0671, .name = "ALC671", .patch = patch_alc662 },
4713 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
4714 { .id = 0x10ec0867, .name = "ALC891", .patch = patch_alc882 },
4715 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
4716 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
4717 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
4718 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
4719 .patch = patch_alc882 },
4720 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
4721 .patch = patch_alc882 },
4722 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
4723 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
4724 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
4725 .patch = patch_alc882 },
4726 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
4727 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
4728 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
4729 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
4730 { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 },
4734 MODULE_ALIAS("snd-hda-codec-id:10ec*");
4736 MODULE_LICENSE("GPL");
4737 MODULE_DESCRIPTION("Realtek HD-audio codec");
4739 static struct hda_codec_preset_list realtek_list = {
4740 .preset = snd_hda_preset_realtek,
4741 .owner = THIS_MODULE,
4744 static int __init patch_realtek_init(void)
4746 return snd_hda_add_codec_preset(&realtek_list);
4749 static void __exit patch_realtek_exit(void)
4751 snd_hda_delete_codec_preset(&realtek_list);
4754 module_init(patch_realtek_init)
4755 module_exit(patch_realtek_exit)