]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - sound/pci/hda/patch_realtek.c
Merge tag 'asoc-fix-v4.14-intel-kconfig' of https://git.kernel.org/pub/scm/linux...
[mirror_ubuntu-bionic-kernel.git] / sound / pci / hda / patch_realtek.c
CommitLineData
1da177e4
LT
1/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
1d045db9 4 * HD audio interface patch for Realtek ALC codecs
1da177e4 5 *
df694daa
KY
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
1da177e4 8 * Takashi Iwai <tiwai@suse.de>
409a3e98 9 * Jonathan Woithe <jwoithe@just42.net>
1da177e4
LT
10 *
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.
15 *
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.
20 *
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
24 */
25
1da177e4
LT
26#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
08fb0d0e 30#include <linux/dmi.h>
da155d5b 31#include <linux/module.h>
33f4acd3 32#include <linux/input.h>
1da177e4 33#include <sound/core.h>
9ad0e496 34#include <sound/jack.h>
1da177e4
LT
35#include "hda_codec.h"
36#include "hda_local.h"
23d30f28 37#include "hda_auto_parser.h"
1835a0f9 38#include "hda_jack.h"
08c189f2 39#include "hda_generic.h"
1da177e4 40
cd63a5ff
TI
41/* keep halting ALC5505 DSP, for power saving */
42#define HALT_REALTEK_ALC5505
43
4a79ba34
TI
44/* extra amp-initialization sequence types */
45enum {
46 ALC_INIT_NONE,
47 ALC_INIT_DEFAULT,
48 ALC_INIT_GPIO1,
49 ALC_INIT_GPIO2,
50 ALC_INIT_GPIO3,
51};
52
73bdd597
DH
53enum {
54 ALC_HEADSET_MODE_UNKNOWN,
55 ALC_HEADSET_MODE_UNPLUGGED,
56 ALC_HEADSET_MODE_HEADSET,
57 ALC_HEADSET_MODE_MIC,
58 ALC_HEADSET_MODE_HEADPHONE,
59};
60
61enum {
62 ALC_HEADSET_TYPE_UNKNOWN,
63 ALC_HEADSET_TYPE_CTIA,
64 ALC_HEADSET_TYPE_OMTP,
65};
66
c7b60a89
HW
67enum {
68 ALC_KEY_MICMUTE_INDEX,
69};
70
da00c244
KY
71struct alc_customize_define {
72 unsigned int sku_cfg;
73 unsigned char port_connectivity;
74 unsigned char check_sum;
75 unsigned char customization;
76 unsigned char external_amp;
77 unsigned int enable_pcbeep:1;
78 unsigned int platform_type:1;
79 unsigned int swap:1;
80 unsigned int override:1;
90622917 81 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
da00c244
KY
82};
83
1da177e4 84struct alc_spec {
08c189f2 85 struct hda_gen_spec gen; /* must be at head */
23d30f28 86
1da177e4 87 /* codec parameterization */
a9111321 88 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
1da177e4 89 unsigned int num_mixers;
45bdd1c1 90 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
1da177e4 91
da00c244 92 struct alc_customize_define cdefine;
08c189f2 93 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
834be88d 94
08fb0d0e
TI
95 /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
96 int mute_led_polarity;
97 hda_nid_t mute_led_nid;
9c5dc3bf 98 hda_nid_t cap_mute_led_nid;
08fb0d0e 99
9f5c6faf 100 unsigned int gpio_led; /* used for alc269_fixup_hp_gpio_led() */
0f32fd19
TI
101 unsigned int gpio_mute_led_mask;
102 unsigned int gpio_mic_led_mask;
9f5c6faf 103
73bdd597
DH
104 hda_nid_t headset_mic_pin;
105 hda_nid_t headphone_mic_pin;
106 int current_headset_mode;
107 int current_headset_type;
108
ae6b813a
TI
109 /* hooks */
110 void (*init_hook)(struct hda_codec *codec);
83012a7c 111#ifdef CONFIG_PM
c97259df 112 void (*power_hook)(struct hda_codec *codec);
f5de24b0 113#endif
1c716153 114 void (*shutup)(struct hda_codec *codec);
70a0976b 115 void (*reboot_notify)(struct hda_codec *codec);
d922b51d 116
4a79ba34 117 int init_amp;
d433a678 118 int codec_variant; /* flag for other variants */
97a26570
KY
119 unsigned int has_alc5505_dsp:1;
120 unsigned int no_depop_delay:1;
e64f14f4 121
2c3bf9ab
TI
122 /* for PLL fix */
123 hda_nid_t pll_nid;
124 unsigned int pll_coef_idx, pll_coef_bit;
1bb7e43e 125 unsigned int coef0;
33f4acd3 126 struct input_dev *kb_dev;
c7b60a89 127 u8 alc_mute_keycode_map[1];
df694daa
KY
128};
129
f2a227cd
TI
130/*
131 * COEF access helper functions
132 */
133
134static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
135 unsigned int coef_idx)
136{
137 unsigned int val;
138
139 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
140 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
141 return val;
142}
143
144#define alc_read_coef_idx(codec, coef_idx) \
145 alc_read_coefex_idx(codec, 0x20, coef_idx)
146
147static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
148 unsigned int coef_idx, unsigned int coef_val)
149{
150 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
151 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
152}
153
154#define alc_write_coef_idx(codec, coef_idx, coef_val) \
155 alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
156
98b24883
TI
157static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
158 unsigned int coef_idx, unsigned int mask,
159 unsigned int bits_set)
160{
161 unsigned int val = alc_read_coefex_idx(codec, nid, coef_idx);
162
163 if (val != -1)
164 alc_write_coefex_idx(codec, nid, coef_idx,
165 (val & ~mask) | bits_set);
166}
167
168#define alc_update_coef_idx(codec, coef_idx, mask, bits_set) \
169 alc_update_coefex_idx(codec, 0x20, coef_idx, mask, bits_set)
170
f2a227cd
TI
171/* a special bypass for COEF 0; read the cached value at the second time */
172static unsigned int alc_get_coef0(struct hda_codec *codec)
173{
174 struct alc_spec *spec = codec->spec;
175
176 if (!spec->coef0)
177 spec->coef0 = alc_read_coef_idx(codec, 0);
178 return spec->coef0;
179}
180
54db6c39
TI
181/* coef writes/updates batch */
182struct coef_fw {
183 unsigned char nid;
184 unsigned char idx;
185 unsigned short mask;
186 unsigned short val;
187};
188
189#define UPDATE_COEFEX(_nid, _idx, _mask, _val) \
190 { .nid = (_nid), .idx = (_idx), .mask = (_mask), .val = (_val) }
191#define WRITE_COEFEX(_nid, _idx, _val) UPDATE_COEFEX(_nid, _idx, -1, _val)
192#define WRITE_COEF(_idx, _val) WRITE_COEFEX(0x20, _idx, _val)
193#define UPDATE_COEF(_idx, _mask, _val) UPDATE_COEFEX(0x20, _idx, _mask, _val)
194
195static void alc_process_coef_fw(struct hda_codec *codec,
196 const struct coef_fw *fw)
197{
198 for (; fw->nid; fw++) {
199 if (fw->mask == (unsigned short)-1)
200 alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
201 else
202 alc_update_coefex_idx(codec, fw->nid, fw->idx,
203 fw->mask, fw->val);
204 }
205}
206
d88897ea 207/*
1d045db9
TI
208 * Append the given mixer and verb elements for the later use
209 * The mixer array is referred in build_controls(), and init_verbs are
210 * called in init().
d88897ea 211 */
a9111321 212static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
d88897ea
TI
213{
214 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
215 return;
216 spec->mixers[spec->num_mixers++] = mix;
217}
218
df694daa 219/*
1d045db9 220 * GPIO setup tables, used in initialization
df694daa 221 */
bc9f98a9 222/* Enable GPIO mask and set output */
a9111321 223static const struct hda_verb alc_gpio1_init_verbs[] = {
bc9f98a9
KY
224 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
225 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
226 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
227 { }
228};
229
a9111321 230static const struct hda_verb alc_gpio2_init_verbs[] = {
bc9f98a9
KY
231 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
232 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
233 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
234 { }
235};
236
a9111321 237static const struct hda_verb alc_gpio3_init_verbs[] = {
bdd148a3
KY
238 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
239 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
240 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
241 { }
242};
243
2c3bf9ab
TI
244/*
245 * Fix hardware PLL issue
246 * On some codecs, the analog PLL gating control must be off while
247 * the default value is 1.
248 */
249static void alc_fix_pll(struct hda_codec *codec)
250{
251 struct alc_spec *spec = codec->spec;
2c3bf9ab 252
98b24883
TI
253 if (spec->pll_nid)
254 alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
255 1 << spec->pll_coef_bit, 0);
2c3bf9ab
TI
256}
257
258static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
259 unsigned int coef_idx, unsigned int coef_bit)
260{
261 struct alc_spec *spec = codec->spec;
262 spec->pll_nid = nid;
263 spec->pll_coef_idx = coef_idx;
264 spec->pll_coef_bit = coef_bit;
265 alc_fix_pll(codec);
266}
267
cf5a2279 268/* update the master volume per volume-knob's unsol event */
1a4f69d5
TI
269static void alc_update_knob_master(struct hda_codec *codec,
270 struct hda_jack_callback *jack)
cf5a2279
TI
271{
272 unsigned int val;
273 struct snd_kcontrol *kctl;
274 struct snd_ctl_elem_value *uctl;
275
276 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
277 if (!kctl)
278 return;
279 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
280 if (!uctl)
281 return;
2ebab40e 282 val = snd_hda_codec_read(codec, jack->nid, 0,
cf5a2279
TI
283 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
284 val &= HDA_AMP_VOLMASK;
285 uctl->value.integer.value[0] = val;
286 uctl->value.integer.value[1] = val;
287 kctl->put(kctl, uctl);
288 kfree(uctl);
289}
290
29adc4b9 291static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
f21d78e2 292{
29adc4b9
DH
293 /* For some reason, the res given from ALC880 is broken.
294 Here we adjust it properly. */
295 snd_hda_jack_unsol_event(codec, res >> 2);
f21d78e2
TI
296}
297
394c97f8
KY
298/* Change EAPD to verb control */
299static void alc_fill_eapd_coef(struct hda_codec *codec)
300{
301 int coef;
302
303 coef = alc_get_coef0(codec);
304
7639a06c 305 switch (codec->core.vendor_id) {
394c97f8
KY
306 case 0x10ec0262:
307 alc_update_coef_idx(codec, 0x7, 0, 1<<5);
308 break;
309 case 0x10ec0267:
310 case 0x10ec0268:
311 alc_update_coef_idx(codec, 0x7, 0, 1<<13);
312 break;
313 case 0x10ec0269:
314 if ((coef & 0x00f0) == 0x0010)
315 alc_update_coef_idx(codec, 0xd, 0, 1<<14);
316 if ((coef & 0x00f0) == 0x0020)
317 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
318 if ((coef & 0x00f0) == 0x0030)
319 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
320 break;
321 case 0x10ec0280:
322 case 0x10ec0284:
323 case 0x10ec0290:
324 case 0x10ec0292:
325 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
326 break;
0a6f0600 327 case 0x10ec0215:
4231430d 328 case 0x10ec0225:
394c97f8 329 case 0x10ec0233:
736f20a7 330 case 0x10ec0236:
394c97f8 331 case 0x10ec0255:
4344aec8 332 case 0x10ec0256:
394c97f8
KY
333 case 0x10ec0282:
334 case 0x10ec0283:
335 case 0x10ec0286:
336 case 0x10ec0288:
0a6f0600 337 case 0x10ec0285:
7d727869 338 case 0x10ec0295:
506b62c3 339 case 0x10ec0298:
0a6f0600 340 case 0x10ec0289:
28f1f9b2 341 case 0x10ec0299:
394c97f8
KY
342 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
343 break;
394c97f8
KY
344 case 0x10ec0293:
345 alc_update_coef_idx(codec, 0xa, 1<<13, 0);
346 break;
dcd4f0db
KY
347 case 0x10ec0234:
348 case 0x10ec0274:
349 case 0x10ec0294:
6fbae35a
KY
350 case 0x10ec0700:
351 case 0x10ec0701:
352 case 0x10ec0703:
dcd4f0db
KY
353 alc_update_coef_idx(codec, 0x10, 1<<15, 0);
354 break;
394c97f8
KY
355 case 0x10ec0662:
356 if ((coef & 0x00f0) == 0x0030)
357 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
358 break;
359 case 0x10ec0272:
360 case 0x10ec0273:
361 case 0x10ec0663:
362 case 0x10ec0665:
363 case 0x10ec0670:
364 case 0x10ec0671:
365 case 0x10ec0672:
366 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
367 break;
368 case 0x10ec0668:
369 alc_update_coef_idx(codec, 0x7, 3<<13, 0);
370 break;
371 case 0x10ec0867:
372 alc_update_coef_idx(codec, 0x4, 1<<10, 0);
373 break;
374 case 0x10ec0888:
375 if ((coef & 0x00f0) == 0x0020 || (coef & 0x00f0) == 0x0030)
376 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
377 break;
378 case 0x10ec0892:
379 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
380 break;
381 case 0x10ec0899:
382 case 0x10ec0900:
65553b12 383 case 0x10ec1168:
a535ad57 384 case 0x10ec1220:
394c97f8
KY
385 alc_update_coef_idx(codec, 0x7, 1<<1, 0);
386 break;
387 }
388}
389
f9423e7a
KY
390/* additional initialization for ALC888 variants */
391static void alc888_coef_init(struct hda_codec *codec)
392{
1df8874b
KY
393 switch (alc_get_coef0(codec) & 0x00f0) {
394 /* alc888-VA */
395 case 0x00:
396 /* alc888-VB */
397 case 0x10:
398 alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */
399 break;
400 }
87a8c370
JK
401}
402
3fb4a508
TI
403/* turn on/off EAPD control (only if available) */
404static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
405{
406 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
407 return;
408 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
409 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
410 on ? 2 : 0);
411}
412
691f1fcc
TI
413/* turn on/off EAPD controls of the codec */
414static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
415{
416 /* We currently only handle front, HP */
39fa84e9 417 static hda_nid_t pins[] = {
af95b414 418 0x0f, 0x10, 0x14, 0x15, 0x17, 0
39fa84e9
TI
419 };
420 hda_nid_t *p;
421 for (p = pins; *p; p++)
422 set_eapd(codec, *p, on);
691f1fcc
TI
423}
424
1c716153 425/* generic shutup callback;
4ce8e6a5 426 * just turning off EAPD and a little pause for avoiding pop-noise
1c716153
TI
427 */
428static void alc_eapd_shutup(struct hda_codec *codec)
429{
97a26570
KY
430 struct alc_spec *spec = codec->spec;
431
1c716153 432 alc_auto_setup_eapd(codec, false);
97a26570
KY
433 if (!spec->no_depop_delay)
434 msleep(200);
9bfb2844 435 snd_hda_shutup_pins(codec);
1c716153
TI
436}
437
1d045db9 438/* generic EAPD initialization */
4a79ba34 439static void alc_auto_init_amp(struct hda_codec *codec, int type)
bc9f98a9 440{
394c97f8 441 alc_fill_eapd_coef(codec);
39fa84e9 442 alc_auto_setup_eapd(codec, true);
4a79ba34
TI
443 switch (type) {
444 case ALC_INIT_GPIO1:
bc9f98a9
KY
445 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
446 break;
4a79ba34 447 case ALC_INIT_GPIO2:
bc9f98a9
KY
448 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
449 break;
4a79ba34 450 case ALC_INIT_GPIO3:
bdd148a3
KY
451 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
452 break;
4a79ba34 453 case ALC_INIT_DEFAULT:
7639a06c 454 switch (codec->core.vendor_id) {
c9b58006 455 case 0x10ec0260:
98b24883 456 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
c9b58006 457 break;
c9b58006
KY
458 case 0x10ec0880:
459 case 0x10ec0882:
460 case 0x10ec0883:
461 case 0x10ec0885:
1df8874b 462 alc_update_coef_idx(codec, 7, 0, 0x2030);
c9b58006 463 break;
f9423e7a 464 case 0x10ec0888:
4a79ba34 465 alc888_coef_init(codec);
f9423e7a 466 break;
bc9f98a9 467 }
4a79ba34
TI
468 break;
469 }
470}
471
08c189f2 472
1d045db9 473/*
08c189f2 474 * Realtek SSID verification
1d045db9 475 */
42cf0d01 476
08c189f2
TI
477/* Could be any non-zero and even value. When used as fixup, tells
478 * the driver to ignore any present sku defines.
479 */
480#define ALC_FIXUP_SKU_IGNORE (2)
1a1455de 481
08c189f2
TI
482static void alc_fixup_sku_ignore(struct hda_codec *codec,
483 const struct hda_fixup *fix, int action)
1a1455de 484{
1a1455de 485 struct alc_spec *spec = codec->spec;
08c189f2
TI
486 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
487 spec->cdefine.fixup = 1;
488 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
1a1455de 489 }
1a1455de
TI
490}
491
b5c6611f
ML
492static void alc_fixup_no_depop_delay(struct hda_codec *codec,
493 const struct hda_fixup *fix, int action)
494{
495 struct alc_spec *spec = codec->spec;
496
84d2dc3e 497 if (action == HDA_FIXUP_ACT_PROBE) {
b5c6611f 498 spec->no_depop_delay = 1;
84d2dc3e
ML
499 codec->depop_delay = 0;
500 }
b5c6611f
ML
501}
502
08c189f2 503static int alc_auto_parse_customize_define(struct hda_codec *codec)
4a79ba34 504{
08c189f2
TI
505 unsigned int ass, tmp, i;
506 unsigned nid = 0;
4a79ba34
TI
507 struct alc_spec *spec = codec->spec;
508
08c189f2 509 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
4a79ba34 510
08c189f2
TI
511 if (spec->cdefine.fixup) {
512 ass = spec->cdefine.sku_cfg;
513 if (ass == ALC_FIXUP_SKU_IGNORE)
514 return -1;
515 goto do_sku;
bb35febd
TI
516 }
517
5100cd07
TI
518 if (!codec->bus->pci)
519 return -1;
7639a06c 520 ass = codec->core.subsystem_id & 0xffff;
08c189f2
TI
521 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
522 goto do_sku;
4a79ba34 523
08c189f2 524 nid = 0x1d;
7639a06c 525 if (codec->core.vendor_id == 0x10ec0260)
08c189f2
TI
526 nid = 0x17;
527 ass = snd_hda_codec_get_pincfg(codec, nid);
42cf0d01 528
08c189f2 529 if (!(ass & 1)) {
4e76a883 530 codec_info(codec, "%s: SKU not ready 0x%08x\n",
7639a06c 531 codec->core.chip_name, ass);
08c189f2 532 return -1;
42cf0d01
DH
533 }
534
08c189f2
TI
535 /* check sum */
536 tmp = 0;
537 for (i = 1; i < 16; i++) {
538 if ((ass >> i) & 1)
539 tmp++;
ae8a60a5 540 }
08c189f2
TI
541 if (((ass >> 16) & 0xf) != tmp)
542 return -1;
ae8a60a5 543
da00c244
KY
544 spec->cdefine.port_connectivity = ass >> 30;
545 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
546 spec->cdefine.check_sum = (ass >> 16) & 0xf;
547 spec->cdefine.customization = ass >> 8;
548do_sku:
549 spec->cdefine.sku_cfg = ass;
550 spec->cdefine.external_amp = (ass & 0x38) >> 3;
551 spec->cdefine.platform_type = (ass & 0x4) >> 2;
552 spec->cdefine.swap = (ass & 0x2) >> 1;
553 spec->cdefine.override = ass & 0x1;
554
4e76a883 555 codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
da00c244 556 nid, spec->cdefine.sku_cfg);
4e76a883 557 codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
da00c244 558 spec->cdefine.port_connectivity);
4e76a883
TI
559 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
560 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
561 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
562 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
563 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
564 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
565 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
da00c244
KY
566
567 return 0;
568}
569
08c189f2
TI
570/* return the position of NID in the list, or -1 if not found */
571static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
572{
573 int i;
574 for (i = 0; i < nums; i++)
575 if (list[i] == nid)
576 return i;
577 return -1;
578}
1d045db9 579/* return true if the given NID is found in the list */
3af9ee6b
TI
580static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
581{
21268961 582 return find_idx_in_nid_list(nid, list, nums) >= 0;
3af9ee6b
TI
583}
584
4a79ba34
TI
585/* check subsystem ID and set up device-specific initialization;
586 * return 1 if initialized, 0 if invalid SSID
587 */
588/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
589 * 31 ~ 16 : Manufacture ID
590 * 15 ~ 8 : SKU ID
591 * 7 ~ 0 : Assembly ID
592 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
593 */
58c57cfa 594static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
4a79ba34
TI
595{
596 unsigned int ass, tmp, i;
597 unsigned nid;
598 struct alc_spec *spec = codec->spec;
599
90622917
DH
600 if (spec->cdefine.fixup) {
601 ass = spec->cdefine.sku_cfg;
602 if (ass == ALC_FIXUP_SKU_IGNORE)
603 return 0;
604 goto do_sku;
605 }
606
7639a06c 607 ass = codec->core.subsystem_id & 0xffff;
5100cd07
TI
608 if (codec->bus->pci &&
609 ass != codec->bus->pci->subsystem_device && (ass & 1))
4a79ba34
TI
610 goto do_sku;
611
612 /* invalid SSID, check the special NID pin defcfg instead */
613 /*
def319f9 614 * 31~30 : port connectivity
4a79ba34
TI
615 * 29~21 : reserve
616 * 20 : PCBEEP input
617 * 19~16 : Check sum (15:1)
618 * 15~1 : Custom
619 * 0 : override
620 */
621 nid = 0x1d;
7639a06c 622 if (codec->core.vendor_id == 0x10ec0260)
4a79ba34
TI
623 nid = 0x17;
624 ass = snd_hda_codec_get_pincfg(codec, nid);
4e76a883
TI
625 codec_dbg(codec,
626 "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
cb6605c1 627 ass, nid);
6227cdce 628 if (!(ass & 1))
4a79ba34
TI
629 return 0;
630 if ((ass >> 30) != 1) /* no physical connection */
631 return 0;
632
633 /* check sum */
634 tmp = 0;
635 for (i = 1; i < 16; i++) {
636 if ((ass >> i) & 1)
637 tmp++;
638 }
639 if (((ass >> 16) & 0xf) != tmp)
640 return 0;
641do_sku:
4e76a883 642 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
7639a06c 643 ass & 0xffff, codec->core.vendor_id);
4a79ba34
TI
644 /*
645 * 0 : override
646 * 1 : Swap Jack
647 * 2 : 0 --> Desktop, 1 --> Laptop
648 * 3~5 : External Amplifier control
649 * 7~6 : Reserved
650 */
651 tmp = (ass & 0x38) >> 3; /* external Amp control */
652 switch (tmp) {
653 case 1:
654 spec->init_amp = ALC_INIT_GPIO1;
655 break;
656 case 3:
657 spec->init_amp = ALC_INIT_GPIO2;
658 break;
659 case 7:
660 spec->init_amp = ALC_INIT_GPIO3;
661 break;
662 case 5:
5a8cfb4e 663 default:
4a79ba34 664 spec->init_amp = ALC_INIT_DEFAULT;
bc9f98a9
KY
665 break;
666 }
ea1fb29a 667
8c427226 668 /* is laptop or Desktop and enable the function "Mute internal speaker
c9b58006
KY
669 * when the external headphone out jack is plugged"
670 */
8c427226 671 if (!(ass & 0x8000))
4a79ba34 672 return 1;
c9b58006
KY
673 /*
674 * 10~8 : Jack location
675 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
676 * 14~13: Resvered
677 * 15 : 1 --> enable the function "Mute internal speaker
678 * when the external headphone out jack is plugged"
679 */
08c189f2
TI
680 if (!spec->gen.autocfg.hp_pins[0] &&
681 !(spec->gen.autocfg.line_out_pins[0] &&
682 spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
01d4825d 683 hda_nid_t nid;
c9b58006 684 tmp = (ass >> 11) & 0x3; /* HP to chassis */
58c57cfa 685 nid = ports[tmp];
08c189f2
TI
686 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
687 spec->gen.autocfg.line_outs))
3af9ee6b 688 return 1;
08c189f2 689 spec->gen.autocfg.hp_pins[0] = nid;
c9b58006 690 }
4a79ba34
TI
691 return 1;
692}
ea1fb29a 693
3e6179b8
TI
694/* Check the validity of ALC subsystem-id
695 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
696static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
4a79ba34 697{
58c57cfa 698 if (!alc_subsystem_id(codec, ports)) {
4a79ba34 699 struct alc_spec *spec = codec->spec;
4e76a883
TI
700 codec_dbg(codec,
701 "realtek: Enable default setup for auto mode as fallback\n");
4a79ba34 702 spec->init_amp = ALC_INIT_DEFAULT;
4a79ba34 703 }
21268961 704}
1a1455de 705
1d045db9 706/*
ef8ef5fb 707 */
f9e336f6 708
9d36a7dc
DH
709static void alc_fixup_inv_dmic(struct hda_codec *codec,
710 const struct hda_fixup *fix, int action)
125821ae
TI
711{
712 struct alc_spec *spec = codec->spec;
668d1e96 713
9d36a7dc 714 spec->gen.inv_dmic_split = 1;
6e72aa5f
TI
715}
716
e9edcee0 717
1d045db9
TI
718#ifdef CONFIG_SND_HDA_INPUT_BEEP
719/* additional beep mixers; the actual parameters are overwritten at build */
720static const struct snd_kcontrol_new alc_beep_mixer[] = {
721 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
722 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
16ded525
TI
723 { } /* end */
724};
1d045db9 725#endif
16ded525 726
08c189f2 727static int alc_build_controls(struct hda_codec *codec)
1d045db9
TI
728{
729 struct alc_spec *spec = codec->spec;
08c189f2 730 int i, err;
e9427969 731
08c189f2
TI
732 err = snd_hda_gen_build_controls(codec);
733 if (err < 0)
734 return err;
1da177e4
LT
735
736 for (i = 0; i < spec->num_mixers; i++) {
737 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
738 if (err < 0)
739 return err;
740 }
2134ea4f 741
67d634c0 742#ifdef CONFIG_SND_HDA_INPUT_BEEP
45bdd1c1
TI
743 /* create beep controls if needed */
744 if (spec->beep_amp) {
a9111321 745 const struct snd_kcontrol_new *knew;
45bdd1c1
TI
746 for (knew = alc_beep_mixer; knew->name; knew++) {
747 struct snd_kcontrol *kctl;
748 kctl = snd_ctl_new1(knew, codec);
749 if (!kctl)
08c189f2
TI
750 return -ENOMEM;
751 kctl->private_value = spec->beep_amp;
752 err = snd_hda_ctl_add(codec, 0, kctl);
753 if (err < 0)
754 return err;
1d045db9 755 }
863b4518 756 }
08c189f2 757#endif
1c4a54b4 758
1727a771 759 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
1c4a54b4 760 return 0;
a361d84b
KY
761}
762
a361d84b 763
df694daa 764/*
08c189f2 765 * Common callbacks
df694daa 766 */
a361d84b 767
08c189f2 768static int alc_init(struct hda_codec *codec)
1d045db9
TI
769{
770 struct alc_spec *spec = codec->spec;
a361d84b 771
08c189f2
TI
772 if (spec->init_hook)
773 spec->init_hook(codec);
a361d84b 774
08c189f2
TI
775 alc_fix_pll(codec);
776 alc_auto_init_amp(codec, spec->init_amp);
3abf2f36 777
08c189f2 778 snd_hda_gen_init(codec);
a361d84b 779
1727a771 780 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
a361d84b 781
1d045db9
TI
782 return 0;
783}
a361d84b 784
08c189f2 785static inline void alc_shutup(struct hda_codec *codec)
1d045db9
TI
786{
787 struct alc_spec *spec = codec->spec;
a361d84b 788
08c189f2
TI
789 if (spec && spec->shutup)
790 spec->shutup(codec);
9bfb2844
TI
791 else
792 snd_hda_shutup_pins(codec);
1d045db9
TI
793}
794
70a0976b
TI
795static void alc_reboot_notify(struct hda_codec *codec)
796{
797 struct alc_spec *spec = codec->spec;
798
799 if (spec && spec->reboot_notify)
800 spec->reboot_notify(codec);
801 else
802 alc_shutup(codec);
803}
804
805/* power down codec to D3 at reboot/shutdown; set as reboot_notify ops */
806static void alc_d3_at_reboot(struct hda_codec *codec)
807{
808 snd_hda_codec_set_power_to_all(codec, codec->core.afg, AC_PWRST_D3);
809 snd_hda_codec_write(codec, codec->core.afg, 0,
810 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
811 msleep(10);
812}
813
8a02c0cc 814#define alc_free snd_hda_gen_free
2134ea4f 815
08c189f2
TI
816#ifdef CONFIG_PM
817static void alc_power_eapd(struct hda_codec *codec)
1d045db9 818{
08c189f2 819 alc_auto_setup_eapd(codec, false);
1d045db9 820}
2134ea4f 821
08c189f2 822static int alc_suspend(struct hda_codec *codec)
1d045db9
TI
823{
824 struct alc_spec *spec = codec->spec;
08c189f2
TI
825 alc_shutup(codec);
826 if (spec && spec->power_hook)
827 spec->power_hook(codec);
a361d84b
KY
828 return 0;
829}
08c189f2 830#endif
a361d84b 831
08c189f2
TI
832#ifdef CONFIG_PM
833static int alc_resume(struct hda_codec *codec)
1d045db9 834{
97a26570
KY
835 struct alc_spec *spec = codec->spec;
836
837 if (!spec->no_depop_delay)
838 msleep(150); /* to avoid pop noise */
08c189f2 839 codec->patch_ops.init(codec);
eeecd9d1 840 regcache_sync(codec->core.regmap);
08c189f2
TI
841 hda_call_check_power_status(codec, 0x01);
842 return 0;
1d045db9 843}
08c189f2 844#endif
f6a92248 845
1d045db9 846/*
1d045db9 847 */
08c189f2
TI
848static const struct hda_codec_ops alc_patch_ops = {
849 .build_controls = alc_build_controls,
850 .build_pcms = snd_hda_gen_build_pcms,
851 .init = alc_init,
852 .free = alc_free,
853 .unsol_event = snd_hda_jack_unsol_event,
854#ifdef CONFIG_PM
855 .resume = alc_resume,
08c189f2 856 .suspend = alc_suspend,
fce52a3b 857 .check_power_status = snd_hda_gen_check_power_status,
08c189f2 858#endif
70a0976b 859 .reboot_notify = alc_reboot_notify,
08c189f2 860};
f6a92248 861
f53281e6 862
ded255be 863#define alc_codec_rename(codec, name) snd_hda_codec_set_name(codec, name)
e01bf509 864
e4770629 865/*
4b016931 866 * Rename codecs appropriately from COEF value or subvendor id
e4770629 867 */
08c189f2
TI
868struct alc_codec_rename_table {
869 unsigned int vendor_id;
870 unsigned short coef_mask;
871 unsigned short coef_bits;
872 const char *name;
873};
84898e87 874
4b016931
KY
875struct alc_codec_rename_pci_table {
876 unsigned int codec_vendor_id;
877 unsigned short pci_subvendor;
878 unsigned short pci_subdevice;
879 const char *name;
880};
881
08c189f2 882static struct alc_codec_rename_table rename_tbl[] = {
e6e5f7ad 883 { 0x10ec0221, 0xf00f, 0x1003, "ALC231" },
08c189f2
TI
884 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
885 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
886 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
887 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
888 { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
889 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
890 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
891 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
e6e5f7ad 892 { 0x10ec0662, 0xffff, 0x4020, "ALC656" },
08c189f2
TI
893 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
894 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
895 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
896 { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
897 { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
898 { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
899 { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
900 { } /* terminator */
901};
84898e87 902
4b016931
KY
903static struct alc_codec_rename_pci_table rename_pci_tbl[] = {
904 { 0x10ec0280, 0x1028, 0, "ALC3220" },
905 { 0x10ec0282, 0x1028, 0, "ALC3221" },
906 { 0x10ec0283, 0x1028, 0, "ALC3223" },
193177de 907 { 0x10ec0288, 0x1028, 0, "ALC3263" },
4b016931 908 { 0x10ec0292, 0x1028, 0, "ALC3226" },
193177de 909 { 0x10ec0293, 0x1028, 0, "ALC3235" },
4b016931
KY
910 { 0x10ec0255, 0x1028, 0, "ALC3234" },
911 { 0x10ec0668, 0x1028, 0, "ALC3661" },
e6e5f7ad
KY
912 { 0x10ec0275, 0x1028, 0, "ALC3260" },
913 { 0x10ec0899, 0x1028, 0, "ALC3861" },
2c674fac 914 { 0x10ec0298, 0x1028, 0, "ALC3266" },
736f20a7 915 { 0x10ec0236, 0x1028, 0, "ALC3204" },
82324502 916 { 0x10ec0256, 0x1028, 0, "ALC3246" },
4231430d 917 { 0x10ec0225, 0x1028, 0, "ALC3253" },
7d727869 918 { 0x10ec0295, 0x1028, 0, "ALC3254" },
28f1f9b2 919 { 0x10ec0299, 0x1028, 0, "ALC3271" },
e6e5f7ad
KY
920 { 0x10ec0670, 0x1025, 0, "ALC669X" },
921 { 0x10ec0676, 0x1025, 0, "ALC679X" },
922 { 0x10ec0282, 0x1043, 0, "ALC3229" },
923 { 0x10ec0233, 0x1043, 0, "ALC3236" },
924 { 0x10ec0280, 0x103c, 0, "ALC3228" },
925 { 0x10ec0282, 0x103c, 0, "ALC3227" },
926 { 0x10ec0286, 0x103c, 0, "ALC3242" },
927 { 0x10ec0290, 0x103c, 0, "ALC3241" },
928 { 0x10ec0668, 0x103c, 0, "ALC3662" },
929 { 0x10ec0283, 0x17aa, 0, "ALC3239" },
930 { 0x10ec0292, 0x17aa, 0, "ALC3232" },
4b016931
KY
931 { } /* terminator */
932};
933
08c189f2 934static int alc_codec_rename_from_preset(struct hda_codec *codec)
1d045db9 935{
08c189f2 936 const struct alc_codec_rename_table *p;
4b016931 937 const struct alc_codec_rename_pci_table *q;
60db6b53 938
08c189f2 939 for (p = rename_tbl; p->vendor_id; p++) {
7639a06c 940 if (p->vendor_id != codec->core.vendor_id)
08c189f2
TI
941 continue;
942 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
943 return alc_codec_rename(codec, p->name);
1d045db9 944 }
4b016931 945
5100cd07
TI
946 if (!codec->bus->pci)
947 return 0;
4b016931 948 for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
7639a06c 949 if (q->codec_vendor_id != codec->core.vendor_id)
4b016931
KY
950 continue;
951 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
952 continue;
953 if (!q->pci_subdevice ||
954 q->pci_subdevice == codec->bus->pci->subsystem_device)
955 return alc_codec_rename(codec, q->name);
956 }
957
08c189f2 958 return 0;
1d045db9 959}
f53281e6 960
e4770629 961
1d045db9
TI
962/*
963 * Digital-beep handlers
964 */
965#ifdef CONFIG_SND_HDA_INPUT_BEEP
966#define set_beep_amp(spec, nid, idx, dir) \
967 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
84898e87 968
1d045db9 969static const struct snd_pci_quirk beep_white_list[] = {
7110005e 970 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
a4b7f21d 971 SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
1d045db9 972 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
8554ee40 973 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
1d045db9
TI
974 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
975 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
976 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
78f8baf1 977 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
1d045db9
TI
978 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
979 {}
fe3eb0a7
KY
980};
981
1d045db9
TI
982static inline int has_cdefine_beep(struct hda_codec *codec)
983{
984 struct alc_spec *spec = codec->spec;
985 const struct snd_pci_quirk *q;
986 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
987 if (q)
988 return q->value;
989 return spec->cdefine.enable_pcbeep;
990}
991#else
992#define set_beep_amp(spec, nid, idx, dir) /* NOP */
993#define has_cdefine_beep(codec) 0
994#endif
84898e87 995
1d045db9
TI
996/* parse the BIOS configuration and set up the alc_spec */
997/* return 1 if successful, 0 if the proper config is not found,
998 * or a negative error code
999 */
3e6179b8
TI
1000static int alc_parse_auto_config(struct hda_codec *codec,
1001 const hda_nid_t *ignore_nids,
1002 const hda_nid_t *ssid_nids)
1d045db9
TI
1003{
1004 struct alc_spec *spec = codec->spec;
08c189f2 1005 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
1d045db9 1006 int err;
26f5df26 1007
53c334ad
TI
1008 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1009 spec->parse_flags);
1d045db9
TI
1010 if (err < 0)
1011 return err;
3e6179b8
TI
1012
1013 if (ssid_nids)
1014 alc_ssid_check(codec, ssid_nids);
64154835 1015
08c189f2
TI
1016 err = snd_hda_gen_parse_auto_config(codec, cfg);
1017 if (err < 0)
1018 return err;
070cff4c 1019
1d045db9 1020 return 1;
60db6b53 1021}
f6a92248 1022
3de95173
TI
1023/* common preparation job for alc_spec */
1024static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1025{
1026 struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1027 int err;
1028
1029 if (!spec)
1030 return -ENOMEM;
1031 codec->spec = spec;
08c189f2
TI
1032 snd_hda_gen_spec_init(&spec->gen);
1033 spec->gen.mixer_nid = mixer_nid;
1034 spec->gen.own_eapd_ctl = 1;
1098b7c2 1035 codec->single_adc_amp = 1;
08c189f2
TI
1036 /* FIXME: do we need this for all Realtek codec models? */
1037 codec->spdif_status_reset = 1;
225068ab 1038 codec->patch_ops = alc_patch_ops;
3de95173
TI
1039
1040 err = alc_codec_rename_from_preset(codec);
1041 if (err < 0) {
1042 kfree(spec);
1043 return err;
1044 }
1045 return 0;
1046}
1047
3e6179b8
TI
1048static int alc880_parse_auto_config(struct hda_codec *codec)
1049{
1050 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
7d7eb9ea 1051 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3e6179b8
TI
1052 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1053}
1054
ee3b2969
TI
1055/*
1056 * ALC880 fix-ups
1057 */
1058enum {
411225a0 1059 ALC880_FIXUP_GPIO1,
ee3b2969
TI
1060 ALC880_FIXUP_GPIO2,
1061 ALC880_FIXUP_MEDION_RIM,
dc6af52d 1062 ALC880_FIXUP_LG,
db8a38e5 1063 ALC880_FIXUP_LG_LW25,
f02aab5d 1064 ALC880_FIXUP_W810,
27e917f8 1065 ALC880_FIXUP_EAPD_COEF,
b9368f5c 1066 ALC880_FIXUP_TCL_S700,
cf5a2279
TI
1067 ALC880_FIXUP_VOL_KNOB,
1068 ALC880_FIXUP_FUJITSU,
ba533818 1069 ALC880_FIXUP_F1734,
817de92f 1070 ALC880_FIXUP_UNIWILL,
967b88c4 1071 ALC880_FIXUP_UNIWILL_DIG,
96e225f6 1072 ALC880_FIXUP_Z71V,
487a588d 1073 ALC880_FIXUP_ASUS_W5A,
67b6ec31
TI
1074 ALC880_FIXUP_3ST_BASE,
1075 ALC880_FIXUP_3ST,
1076 ALC880_FIXUP_3ST_DIG,
1077 ALC880_FIXUP_5ST_BASE,
1078 ALC880_FIXUP_5ST,
1079 ALC880_FIXUP_5ST_DIG,
1080 ALC880_FIXUP_6ST_BASE,
1081 ALC880_FIXUP_6ST,
1082 ALC880_FIXUP_6ST_DIG,
5397145f 1083 ALC880_FIXUP_6ST_AUTOMUTE,
ee3b2969
TI
1084};
1085
cf5a2279
TI
1086/* enable the volume-knob widget support on NID 0x21 */
1087static void alc880_fixup_vol_knob(struct hda_codec *codec,
1727a771 1088 const struct hda_fixup *fix, int action)
cf5a2279 1089{
1727a771 1090 if (action == HDA_FIXUP_ACT_PROBE)
62f949bf
TI
1091 snd_hda_jack_detect_enable_callback(codec, 0x21,
1092 alc_update_knob_master);
cf5a2279
TI
1093}
1094
1727a771 1095static const struct hda_fixup alc880_fixups[] = {
411225a0 1096 [ALC880_FIXUP_GPIO1] = {
1727a771 1097 .type = HDA_FIXUP_VERBS,
411225a0
TI
1098 .v.verbs = alc_gpio1_init_verbs,
1099 },
ee3b2969 1100 [ALC880_FIXUP_GPIO2] = {
1727a771 1101 .type = HDA_FIXUP_VERBS,
ee3b2969
TI
1102 .v.verbs = alc_gpio2_init_verbs,
1103 },
1104 [ALC880_FIXUP_MEDION_RIM] = {
1727a771 1105 .type = HDA_FIXUP_VERBS,
ee3b2969
TI
1106 .v.verbs = (const struct hda_verb[]) {
1107 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1108 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1109 { }
1110 },
1111 .chained = true,
1112 .chain_id = ALC880_FIXUP_GPIO2,
1113 },
dc6af52d 1114 [ALC880_FIXUP_LG] = {
1727a771
TI
1115 .type = HDA_FIXUP_PINS,
1116 .v.pins = (const struct hda_pintbl[]) {
dc6af52d
TI
1117 /* disable bogus unused pins */
1118 { 0x16, 0x411111f0 },
1119 { 0x18, 0x411111f0 },
1120 { 0x1a, 0x411111f0 },
1121 { }
1122 }
1123 },
db8a38e5
TI
1124 [ALC880_FIXUP_LG_LW25] = {
1125 .type = HDA_FIXUP_PINS,
1126 .v.pins = (const struct hda_pintbl[]) {
1127 { 0x1a, 0x0181344f }, /* line-in */
1128 { 0x1b, 0x0321403f }, /* headphone */
1129 { }
1130 }
1131 },
f02aab5d 1132 [ALC880_FIXUP_W810] = {
1727a771
TI
1133 .type = HDA_FIXUP_PINS,
1134 .v.pins = (const struct hda_pintbl[]) {
f02aab5d
TI
1135 /* disable bogus unused pins */
1136 { 0x17, 0x411111f0 },
1137 { }
1138 },
1139 .chained = true,
1140 .chain_id = ALC880_FIXUP_GPIO2,
1141 },
27e917f8 1142 [ALC880_FIXUP_EAPD_COEF] = {
1727a771 1143 .type = HDA_FIXUP_VERBS,
27e917f8
TI
1144 .v.verbs = (const struct hda_verb[]) {
1145 /* change to EAPD mode */
1146 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1147 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
1148 {}
1149 },
1150 },
b9368f5c 1151 [ALC880_FIXUP_TCL_S700] = {
1727a771 1152 .type = HDA_FIXUP_VERBS,
b9368f5c
TI
1153 .v.verbs = (const struct hda_verb[]) {
1154 /* change to EAPD mode */
1155 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1156 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
1157 {}
1158 },
1159 .chained = true,
1160 .chain_id = ALC880_FIXUP_GPIO2,
1161 },
cf5a2279 1162 [ALC880_FIXUP_VOL_KNOB] = {
1727a771 1163 .type = HDA_FIXUP_FUNC,
cf5a2279
TI
1164 .v.func = alc880_fixup_vol_knob,
1165 },
1166 [ALC880_FIXUP_FUJITSU] = {
1167 /* override all pins as BIOS on old Amilo is broken */
1727a771
TI
1168 .type = HDA_FIXUP_PINS,
1169 .v.pins = (const struct hda_pintbl[]) {
bb148bde 1170 { 0x14, 0x0121401f }, /* HP */
cf5a2279
TI
1171 { 0x15, 0x99030120 }, /* speaker */
1172 { 0x16, 0x99030130 }, /* bass speaker */
1173 { 0x17, 0x411111f0 }, /* N/A */
1174 { 0x18, 0x411111f0 }, /* N/A */
1175 { 0x19, 0x01a19950 }, /* mic-in */
1176 { 0x1a, 0x411111f0 }, /* N/A */
1177 { 0x1b, 0x411111f0 }, /* N/A */
1178 { 0x1c, 0x411111f0 }, /* N/A */
1179 { 0x1d, 0x411111f0 }, /* N/A */
1180 { 0x1e, 0x01454140 }, /* SPDIF out */
1181 { }
1182 },
1183 .chained = true,
1184 .chain_id = ALC880_FIXUP_VOL_KNOB,
1185 },
ba533818
TI
1186 [ALC880_FIXUP_F1734] = {
1187 /* almost compatible with FUJITSU, but no bass and SPDIF */
1727a771
TI
1188 .type = HDA_FIXUP_PINS,
1189 .v.pins = (const struct hda_pintbl[]) {
bb148bde 1190 { 0x14, 0x0121401f }, /* HP */
ba533818
TI
1191 { 0x15, 0x99030120 }, /* speaker */
1192 { 0x16, 0x411111f0 }, /* N/A */
1193 { 0x17, 0x411111f0 }, /* N/A */
1194 { 0x18, 0x411111f0 }, /* N/A */
1195 { 0x19, 0x01a19950 }, /* mic-in */
1196 { 0x1a, 0x411111f0 }, /* N/A */
1197 { 0x1b, 0x411111f0 }, /* N/A */
1198 { 0x1c, 0x411111f0 }, /* N/A */
1199 { 0x1d, 0x411111f0 }, /* N/A */
1200 { 0x1e, 0x411111f0 }, /* N/A */
1201 { }
1202 },
1203 .chained = true,
1204 .chain_id = ALC880_FIXUP_VOL_KNOB,
1205 },
817de92f
TI
1206 [ALC880_FIXUP_UNIWILL] = {
1207 /* need to fix HP and speaker pins to be parsed correctly */
1727a771
TI
1208 .type = HDA_FIXUP_PINS,
1209 .v.pins = (const struct hda_pintbl[]) {
817de92f
TI
1210 { 0x14, 0x0121411f }, /* HP */
1211 { 0x15, 0x99030120 }, /* speaker */
1212 { 0x16, 0x99030130 }, /* bass speaker */
1213 { }
1214 },
1215 },
967b88c4 1216 [ALC880_FIXUP_UNIWILL_DIG] = {
1727a771
TI
1217 .type = HDA_FIXUP_PINS,
1218 .v.pins = (const struct hda_pintbl[]) {
967b88c4
TI
1219 /* disable bogus unused pins */
1220 { 0x17, 0x411111f0 },
1221 { 0x19, 0x411111f0 },
1222 { 0x1b, 0x411111f0 },
1223 { 0x1f, 0x411111f0 },
1224 { }
1225 }
1226 },
96e225f6 1227 [ALC880_FIXUP_Z71V] = {
1727a771
TI
1228 .type = HDA_FIXUP_PINS,
1229 .v.pins = (const struct hda_pintbl[]) {
96e225f6
TI
1230 /* set up the whole pins as BIOS is utterly broken */
1231 { 0x14, 0x99030120 }, /* speaker */
1232 { 0x15, 0x0121411f }, /* HP */
1233 { 0x16, 0x411111f0 }, /* N/A */
1234 { 0x17, 0x411111f0 }, /* N/A */
1235 { 0x18, 0x01a19950 }, /* mic-in */
1236 { 0x19, 0x411111f0 }, /* N/A */
1237 { 0x1a, 0x01813031 }, /* line-in */
1238 { 0x1b, 0x411111f0 }, /* N/A */
1239 { 0x1c, 0x411111f0 }, /* N/A */
1240 { 0x1d, 0x411111f0 }, /* N/A */
1241 { 0x1e, 0x0144111e }, /* SPDIF */
1242 { }
1243 }
1244 },
487a588d
TI
1245 [ALC880_FIXUP_ASUS_W5A] = {
1246 .type = HDA_FIXUP_PINS,
1247 .v.pins = (const struct hda_pintbl[]) {
1248 /* set up the whole pins as BIOS is utterly broken */
1249 { 0x14, 0x0121411f }, /* HP */
1250 { 0x15, 0x411111f0 }, /* N/A */
1251 { 0x16, 0x411111f0 }, /* N/A */
1252 { 0x17, 0x411111f0 }, /* N/A */
1253 { 0x18, 0x90a60160 }, /* mic */
1254 { 0x19, 0x411111f0 }, /* N/A */
1255 { 0x1a, 0x411111f0 }, /* N/A */
1256 { 0x1b, 0x411111f0 }, /* N/A */
1257 { 0x1c, 0x411111f0 }, /* N/A */
1258 { 0x1d, 0x411111f0 }, /* N/A */
1259 { 0x1e, 0xb743111e }, /* SPDIF out */
1260 { }
1261 },
1262 .chained = true,
1263 .chain_id = ALC880_FIXUP_GPIO1,
1264 },
67b6ec31 1265 [ALC880_FIXUP_3ST_BASE] = {
1727a771
TI
1266 .type = HDA_FIXUP_PINS,
1267 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1268 { 0x14, 0x01014010 }, /* line-out */
1269 { 0x15, 0x411111f0 }, /* N/A */
1270 { 0x16, 0x411111f0 }, /* N/A */
1271 { 0x17, 0x411111f0 }, /* N/A */
1272 { 0x18, 0x01a19c30 }, /* mic-in */
1273 { 0x19, 0x0121411f }, /* HP */
1274 { 0x1a, 0x01813031 }, /* line-in */
1275 { 0x1b, 0x02a19c40 }, /* front-mic */
1276 { 0x1c, 0x411111f0 }, /* N/A */
1277 { 0x1d, 0x411111f0 }, /* N/A */
1278 /* 0x1e is filled in below */
1279 { 0x1f, 0x411111f0 }, /* N/A */
1280 { }
1281 }
1282 },
1283 [ALC880_FIXUP_3ST] = {
1727a771
TI
1284 .type = HDA_FIXUP_PINS,
1285 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1286 { 0x1e, 0x411111f0 }, /* N/A */
1287 { }
1288 },
1289 .chained = true,
1290 .chain_id = ALC880_FIXUP_3ST_BASE,
1291 },
1292 [ALC880_FIXUP_3ST_DIG] = {
1727a771
TI
1293 .type = HDA_FIXUP_PINS,
1294 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1295 { 0x1e, 0x0144111e }, /* SPDIF */
1296 { }
1297 },
1298 .chained = true,
1299 .chain_id = ALC880_FIXUP_3ST_BASE,
1300 },
1301 [ALC880_FIXUP_5ST_BASE] = {
1727a771
TI
1302 .type = HDA_FIXUP_PINS,
1303 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1304 { 0x14, 0x01014010 }, /* front */
1305 { 0x15, 0x411111f0 }, /* N/A */
1306 { 0x16, 0x01011411 }, /* CLFE */
1307 { 0x17, 0x01016412 }, /* surr */
1308 { 0x18, 0x01a19c30 }, /* mic-in */
1309 { 0x19, 0x0121411f }, /* HP */
1310 { 0x1a, 0x01813031 }, /* line-in */
1311 { 0x1b, 0x02a19c40 }, /* front-mic */
1312 { 0x1c, 0x411111f0 }, /* N/A */
1313 { 0x1d, 0x411111f0 }, /* N/A */
1314 /* 0x1e is filled in below */
1315 { 0x1f, 0x411111f0 }, /* N/A */
1316 { }
1317 }
1318 },
1319 [ALC880_FIXUP_5ST] = {
1727a771
TI
1320 .type = HDA_FIXUP_PINS,
1321 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1322 { 0x1e, 0x411111f0 }, /* N/A */
1323 { }
1324 },
1325 .chained = true,
1326 .chain_id = ALC880_FIXUP_5ST_BASE,
1327 },
1328 [ALC880_FIXUP_5ST_DIG] = {
1727a771
TI
1329 .type = HDA_FIXUP_PINS,
1330 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1331 { 0x1e, 0x0144111e }, /* SPDIF */
1332 { }
1333 },
1334 .chained = true,
1335 .chain_id = ALC880_FIXUP_5ST_BASE,
1336 },
1337 [ALC880_FIXUP_6ST_BASE] = {
1727a771
TI
1338 .type = HDA_FIXUP_PINS,
1339 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1340 { 0x14, 0x01014010 }, /* front */
1341 { 0x15, 0x01016412 }, /* surr */
1342 { 0x16, 0x01011411 }, /* CLFE */
1343 { 0x17, 0x01012414 }, /* side */
1344 { 0x18, 0x01a19c30 }, /* mic-in */
1345 { 0x19, 0x02a19c40 }, /* front-mic */
1346 { 0x1a, 0x01813031 }, /* line-in */
1347 { 0x1b, 0x0121411f }, /* HP */
1348 { 0x1c, 0x411111f0 }, /* N/A */
1349 { 0x1d, 0x411111f0 }, /* N/A */
1350 /* 0x1e is filled in below */
1351 { 0x1f, 0x411111f0 }, /* N/A */
1352 { }
1353 }
1354 },
1355 [ALC880_FIXUP_6ST] = {
1727a771
TI
1356 .type = HDA_FIXUP_PINS,
1357 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1358 { 0x1e, 0x411111f0 }, /* N/A */
1359 { }
1360 },
1361 .chained = true,
1362 .chain_id = ALC880_FIXUP_6ST_BASE,
1363 },
1364 [ALC880_FIXUP_6ST_DIG] = {
1727a771
TI
1365 .type = HDA_FIXUP_PINS,
1366 .v.pins = (const struct hda_pintbl[]) {
67b6ec31
TI
1367 { 0x1e, 0x0144111e }, /* SPDIF */
1368 { }
1369 },
1370 .chained = true,
1371 .chain_id = ALC880_FIXUP_6ST_BASE,
1372 },
5397145f
TI
1373 [ALC880_FIXUP_6ST_AUTOMUTE] = {
1374 .type = HDA_FIXUP_PINS,
1375 .v.pins = (const struct hda_pintbl[]) {
1376 { 0x1b, 0x0121401f }, /* HP with jack detect */
1377 { }
1378 },
1379 .chained_before = true,
1380 .chain_id = ALC880_FIXUP_6ST_BASE,
1381 },
ee3b2969
TI
1382};
1383
1384static const struct snd_pci_quirk alc880_fixup_tbl[] = {
f02aab5d 1385 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
487a588d 1386 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
96e225f6 1387 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
29e3fdcc 1388 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
6538de03 1389 SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE),
29e3fdcc 1390 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
27e917f8 1391 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
967b88c4 1392 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
ba533818 1393 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
817de92f 1394 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
7833c7e8 1395 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
f02aab5d 1396 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
ee3b2969 1397 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
5397145f 1398 SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
a161574e 1399 SND_PCI_QUIRK(0x1734, 0x107c, "FSC Amilo M1437", ALC880_FIXUP_FUJITSU),
cf5a2279 1400 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
ba533818 1401 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
cf5a2279 1402 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
dc6af52d
TI
1403 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1404 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1405 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
db8a38e5 1406 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
b9368f5c 1407 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
67b6ec31
TI
1408
1409 /* Below is the copied entries from alc880_quirks.c.
1410 * It's not quite sure whether BIOS sets the correct pin-config table
1411 * on these machines, thus they are kept to be compatible with
1412 * the old static quirks. Once when it's confirmed to work without
1413 * these overrides, it'd be better to remove.
1414 */
1415 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1416 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1417 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1418 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1419 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1420 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1421 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1422 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1423 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1424 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1425 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1426 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1427 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1428 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1429 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1430 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1431 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1432 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1433 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1434 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1435 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1436 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1437 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1438 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1439 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1440 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1441 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1442 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1443 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1444 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1445 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1446 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1447 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1448 /* default Intel */
1449 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1450 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1451 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1452 {}
1453};
1454
1727a771 1455static const struct hda_model_fixup alc880_fixup_models[] = {
67b6ec31
TI
1456 {.id = ALC880_FIXUP_3ST, .name = "3stack"},
1457 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1458 {.id = ALC880_FIXUP_5ST, .name = "5stack"},
1459 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1460 {.id = ALC880_FIXUP_6ST, .name = "6stack"},
1461 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
5397145f 1462 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
ee3b2969
TI
1463 {}
1464};
1465
1466
1d045db9
TI
1467/*
1468 * OK, here we have finally the patch for ALC880
1469 */
1d045db9 1470static int patch_alc880(struct hda_codec *codec)
60db6b53 1471{
1d045db9 1472 struct alc_spec *spec;
1d045db9 1473 int err;
f6a92248 1474
3de95173
TI
1475 err = alc_alloc_spec(codec, 0x0b);
1476 if (err < 0)
1477 return err;
64154835 1478
3de95173 1479 spec = codec->spec;
08c189f2 1480 spec->gen.need_dac_fix = 1;
7504b6cd 1481 spec->gen.beep_nid = 0x01;
f53281e6 1482
225068ab
TI
1483 codec->patch_ops.unsol_event = alc880_unsol_event;
1484
1727a771 1485 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
67b6ec31 1486 alc880_fixups);
1727a771 1487 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
ee3b2969 1488
67b6ec31
TI
1489 /* automatic parse from the BIOS config */
1490 err = alc880_parse_auto_config(codec);
1491 if (err < 0)
1492 goto error;
fe3eb0a7 1493
7504b6cd 1494 if (!spec->gen.no_analog)
3e6179b8 1495 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
f53281e6 1496
1727a771 1497 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 1498
1d045db9 1499 return 0;
e16fb6d1
TI
1500
1501 error:
1502 alc_free(codec);
1503 return err;
226b1ec8
KY
1504}
1505
1d045db9 1506
60db6b53 1507/*
1d045db9 1508 * ALC260 support
60db6b53 1509 */
1d045db9 1510static int alc260_parse_auto_config(struct hda_codec *codec)
f6a92248 1511{
1d045db9 1512 static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
3e6179b8
TI
1513 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1514 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
f6a92248
KY
1515}
1516
1d045db9
TI
1517/*
1518 * Pin config fixes
1519 */
1520enum {
ca8f0424
TI
1521 ALC260_FIXUP_HP_DC5750,
1522 ALC260_FIXUP_HP_PIN_0F,
1523 ALC260_FIXUP_COEF,
15317ab2 1524 ALC260_FIXUP_GPIO1,
20f7d928
TI
1525 ALC260_FIXUP_GPIO1_TOGGLE,
1526 ALC260_FIXUP_REPLACER,
0a1c4fa2 1527 ALC260_FIXUP_HP_B1900,
118cb4a4 1528 ALC260_FIXUP_KN1,
39aedee7 1529 ALC260_FIXUP_FSC_S7020,
5ebd3bbd 1530 ALC260_FIXUP_FSC_S7020_JWSE,
d08c5ef2 1531 ALC260_FIXUP_VAIO_PINS,
1d045db9
TI
1532};
1533
20f7d928
TI
1534static void alc260_gpio1_automute(struct hda_codec *codec)
1535{
1536 struct alc_spec *spec = codec->spec;
1537 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
08c189f2 1538 spec->gen.hp_jack_present);
20f7d928
TI
1539}
1540
1541static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1727a771 1542 const struct hda_fixup *fix, int action)
20f7d928
TI
1543{
1544 struct alc_spec *spec = codec->spec;
1727a771 1545 if (action == HDA_FIXUP_ACT_PROBE) {
20f7d928
TI
1546 /* although the machine has only one output pin, we need to
1547 * toggle GPIO1 according to the jack state
1548 */
08c189f2
TI
1549 spec->gen.automute_hook = alc260_gpio1_automute;
1550 spec->gen.detect_hp = 1;
1551 spec->gen.automute_speaker = 1;
1552 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
62f949bf 1553 snd_hda_jack_detect_enable_callback(codec, 0x0f,
08c189f2 1554 snd_hda_gen_hp_automute);
c9ce6b26 1555 snd_hda_add_verbs(codec, alc_gpio1_init_verbs);
20f7d928
TI
1556 }
1557}
1558
118cb4a4 1559static void alc260_fixup_kn1(struct hda_codec *codec,
1727a771 1560 const struct hda_fixup *fix, int action)
118cb4a4
TI
1561{
1562 struct alc_spec *spec = codec->spec;
1727a771 1563 static const struct hda_pintbl pincfgs[] = {
118cb4a4
TI
1564 { 0x0f, 0x02214000 }, /* HP/speaker */
1565 { 0x12, 0x90a60160 }, /* int mic */
1566 { 0x13, 0x02a19000 }, /* ext mic */
1567 { 0x18, 0x01446000 }, /* SPDIF out */
1568 /* disable bogus I/O pins */
1569 { 0x10, 0x411111f0 },
1570 { 0x11, 0x411111f0 },
1571 { 0x14, 0x411111f0 },
1572 { 0x15, 0x411111f0 },
1573 { 0x16, 0x411111f0 },
1574 { 0x17, 0x411111f0 },
1575 { 0x19, 0x411111f0 },
1576 { }
1577 };
1578
1579 switch (action) {
1727a771
TI
1580 case HDA_FIXUP_ACT_PRE_PROBE:
1581 snd_hda_apply_pincfgs(codec, pincfgs);
118cb4a4 1582 break;
1727a771 1583 case HDA_FIXUP_ACT_PROBE:
118cb4a4
TI
1584 spec->init_amp = ALC_INIT_NONE;
1585 break;
1586 }
1587}
1588
39aedee7
TI
1589static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1590 const struct hda_fixup *fix, int action)
1591{
1592 struct alc_spec *spec = codec->spec;
5ebd3bbd
TI
1593 if (action == HDA_FIXUP_ACT_PROBE)
1594 spec->init_amp = ALC_INIT_NONE;
1595}
39aedee7 1596
5ebd3bbd
TI
1597static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1598 const struct hda_fixup *fix, int action)
1599{
1600 struct alc_spec *spec = codec->spec;
1601 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
f811c3cf 1602 spec->gen.add_jack_modes = 1;
5ebd3bbd 1603 spec->gen.hp_mic = 1;
e6e0ee50 1604 }
39aedee7
TI
1605}
1606
1727a771 1607static const struct hda_fixup alc260_fixups[] = {
ca8f0424 1608 [ALC260_FIXUP_HP_DC5750] = {
1727a771
TI
1609 .type = HDA_FIXUP_PINS,
1610 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
1611 { 0x11, 0x90130110 }, /* speaker */
1612 { }
1613 }
1614 },
ca8f0424 1615 [ALC260_FIXUP_HP_PIN_0F] = {
1727a771
TI
1616 .type = HDA_FIXUP_PINS,
1617 .v.pins = (const struct hda_pintbl[]) {
ca8f0424
TI
1618 { 0x0f, 0x01214000 }, /* HP */
1619 { }
1620 }
1621 },
1622 [ALC260_FIXUP_COEF] = {
1727a771 1623 .type = HDA_FIXUP_VERBS,
ca8f0424 1624 .v.verbs = (const struct hda_verb[]) {
e30cf2d2
RM
1625 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1626 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3040 },
ca8f0424
TI
1627 { }
1628 },
ca8f0424 1629 },
15317ab2 1630 [ALC260_FIXUP_GPIO1] = {
1727a771 1631 .type = HDA_FIXUP_VERBS,
15317ab2
TI
1632 .v.verbs = alc_gpio1_init_verbs,
1633 },
20f7d928 1634 [ALC260_FIXUP_GPIO1_TOGGLE] = {
1727a771 1635 .type = HDA_FIXUP_FUNC,
20f7d928
TI
1636 .v.func = alc260_fixup_gpio1_toggle,
1637 .chained = true,
1638 .chain_id = ALC260_FIXUP_HP_PIN_0F,
1639 },
1640 [ALC260_FIXUP_REPLACER] = {
1727a771 1641 .type = HDA_FIXUP_VERBS,
20f7d928 1642 .v.verbs = (const struct hda_verb[]) {
192a98e2
TI
1643 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1644 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3050 },
20f7d928
TI
1645 { }
1646 },
1647 .chained = true,
1648 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1649 },
0a1c4fa2 1650 [ALC260_FIXUP_HP_B1900] = {
1727a771 1651 .type = HDA_FIXUP_FUNC,
0a1c4fa2
TI
1652 .v.func = alc260_fixup_gpio1_toggle,
1653 .chained = true,
1654 .chain_id = ALC260_FIXUP_COEF,
118cb4a4
TI
1655 },
1656 [ALC260_FIXUP_KN1] = {
1727a771 1657 .type = HDA_FIXUP_FUNC,
118cb4a4
TI
1658 .v.func = alc260_fixup_kn1,
1659 },
39aedee7
TI
1660 [ALC260_FIXUP_FSC_S7020] = {
1661 .type = HDA_FIXUP_FUNC,
1662 .v.func = alc260_fixup_fsc_s7020,
1663 },
5ebd3bbd
TI
1664 [ALC260_FIXUP_FSC_S7020_JWSE] = {
1665 .type = HDA_FIXUP_FUNC,
1666 .v.func = alc260_fixup_fsc_s7020_jwse,
1667 .chained = true,
1668 .chain_id = ALC260_FIXUP_FSC_S7020,
1669 },
d08c5ef2
TI
1670 [ALC260_FIXUP_VAIO_PINS] = {
1671 .type = HDA_FIXUP_PINS,
1672 .v.pins = (const struct hda_pintbl[]) {
1673 /* Pin configs are missing completely on some VAIOs */
1674 { 0x0f, 0x01211020 },
1675 { 0x10, 0x0001003f },
1676 { 0x11, 0x411111f0 },
1677 { 0x12, 0x01a15930 },
1678 { 0x13, 0x411111f0 },
1679 { 0x14, 0x411111f0 },
1680 { 0x15, 0x411111f0 },
1681 { 0x16, 0x411111f0 },
1682 { 0x17, 0x411111f0 },
1683 { 0x18, 0x411111f0 },
1684 { 0x19, 0x411111f0 },
1685 { }
1686 }
1687 },
1d045db9
TI
1688};
1689
1690static const struct snd_pci_quirk alc260_fixup_tbl[] = {
15317ab2 1691 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
ca8f0424 1692 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
15317ab2 1693 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
ca8f0424 1694 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
0a1c4fa2 1695 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
d08c5ef2 1696 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
0f5a5b85 1697 SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
39aedee7 1698 SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
b1f58085 1699 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
118cb4a4 1700 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
20f7d928 1701 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
ca8f0424 1702 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
1d045db9
TI
1703 {}
1704};
1705
5ebd3bbd
TI
1706static const struct hda_model_fixup alc260_fixup_models[] = {
1707 {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1708 {.id = ALC260_FIXUP_COEF, .name = "coef"},
1709 {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1710 {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1711 {}
1712};
1713
1d045db9
TI
1714/*
1715 */
1d045db9 1716static int patch_alc260(struct hda_codec *codec)
977ddd6b 1717{
1d045db9 1718 struct alc_spec *spec;
c3c2c9e7 1719 int err;
1d045db9 1720
3de95173
TI
1721 err = alc_alloc_spec(codec, 0x07);
1722 if (err < 0)
1723 return err;
1d045db9 1724
3de95173 1725 spec = codec->spec;
ea46c3c8
TI
1726 /* as quite a few machines require HP amp for speaker outputs,
1727 * it's easier to enable it unconditionally; even if it's unneeded,
1728 * it's almost harmless.
1729 */
1730 spec->gen.prefer_hp_amp = 1;
7504b6cd 1731 spec->gen.beep_nid = 0x01;
1d045db9 1732
225068ab
TI
1733 spec->shutup = alc_eapd_shutup;
1734
5ebd3bbd
TI
1735 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1736 alc260_fixups);
1727a771 1737 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
977ddd6b 1738
c3c2c9e7
TI
1739 /* automatic parse from the BIOS config */
1740 err = alc260_parse_auto_config(codec);
1741 if (err < 0)
1742 goto error;
977ddd6b 1743
7504b6cd 1744 if (!spec->gen.no_analog)
3e6179b8 1745 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
977ddd6b 1746
1727a771 1747 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 1748
1d045db9 1749 return 0;
e16fb6d1
TI
1750
1751 error:
1752 alc_free(codec);
1753 return err;
6981d184
TI
1754}
1755
1d045db9
TI
1756
1757/*
1758 * ALC882/883/885/888/889 support
1759 *
1760 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1761 * configuration. Each pin widget can choose any input DACs and a mixer.
1762 * Each ADC is connected from a mixer of all inputs. This makes possible
1763 * 6-channel independent captures.
1764 *
1765 * In addition, an independent DAC for the multi-playback (not used in this
1766 * driver yet).
1767 */
1d045db9
TI
1768
1769/*
1770 * Pin config fixes
1771 */
ff818c24 1772enum {
5c0ebfbe
TI
1773 ALC882_FIXUP_ABIT_AW9D_MAX,
1774 ALC882_FIXUP_LENOVO_Y530,
1775 ALC882_FIXUP_PB_M5210,
1776 ALC882_FIXUP_ACER_ASPIRE_7736,
1777 ALC882_FIXUP_ASUS_W90V,
8f239214 1778 ALC889_FIXUP_CD,
b2c53e20 1779 ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
5c0ebfbe 1780 ALC889_FIXUP_VAIO_TT,
0e7cc2e7 1781 ALC888_FIXUP_EEE1601,
177943a3 1782 ALC882_FIXUP_EAPD,
7a6069bf 1783 ALC883_FIXUP_EAPD,
8812c4f9 1784 ALC883_FIXUP_ACER_EAPD,
1a97b7f2
TI
1785 ALC882_FIXUP_GPIO1,
1786 ALC882_FIXUP_GPIO2,
eb844d51 1787 ALC882_FIXUP_GPIO3,
68ef0561
TI
1788 ALC889_FIXUP_COEF,
1789 ALC882_FIXUP_ASUS_W2JC,
c3e837bb
TI
1790 ALC882_FIXUP_ACER_ASPIRE_4930G,
1791 ALC882_FIXUP_ACER_ASPIRE_8930G,
1792 ALC882_FIXUP_ASPIRE_8930G_VERBS,
5671087f 1793 ALC885_FIXUP_MACPRO_GPIO,
02a237b2 1794 ALC889_FIXUP_DAC_ROUTE,
1a97b7f2
TI
1795 ALC889_FIXUP_MBP_VREF,
1796 ALC889_FIXUP_IMAC91_VREF,
e7729a41 1797 ALC889_FIXUP_MBA11_VREF,
0756f09c 1798 ALC889_FIXUP_MBA21_VREF,
c20f31ec 1799 ALC889_FIXUP_MP11_VREF,
9f660a1c 1800 ALC889_FIXUP_MP41_VREF,
6e72aa5f 1801 ALC882_FIXUP_INV_DMIC,
e427c237 1802 ALC882_FIXUP_NO_PRIMARY_HP,
1f0bbf03 1803 ALC887_FIXUP_ASUS_BASS,
eb9ca3ab 1804 ALC887_FIXUP_BASS_CHMAP,
7beb3a6e 1805 ALC1220_FIXUP_GB_DUAL_CODECS,
0202f5cd 1806 ALC1220_FIXUP_CLEVO_P950,
ff818c24
TI
1807};
1808
68ef0561 1809static void alc889_fixup_coef(struct hda_codec *codec,
1727a771 1810 const struct hda_fixup *fix, int action)
68ef0561 1811{
1727a771 1812 if (action != HDA_FIXUP_ACT_INIT)
68ef0561 1813 return;
1df8874b 1814 alc_update_coef_idx(codec, 7, 0, 0x2030);
68ef0561
TI
1815}
1816
5671087f
TI
1817/* toggle speaker-output according to the hp-jack state */
1818static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
1819{
1820 unsigned int gpiostate, gpiomask, gpiodir;
1821
7639a06c 1822 gpiostate = snd_hda_codec_read(codec, codec->core.afg, 0,
5671087f
TI
1823 AC_VERB_GET_GPIO_DATA, 0);
1824
1825 if (!muted)
1826 gpiostate |= (1 << pin);
1827 else
1828 gpiostate &= ~(1 << pin);
1829
7639a06c 1830 gpiomask = snd_hda_codec_read(codec, codec->core.afg, 0,
5671087f
TI
1831 AC_VERB_GET_GPIO_MASK, 0);
1832 gpiomask |= (1 << pin);
1833
7639a06c 1834 gpiodir = snd_hda_codec_read(codec, codec->core.afg, 0,
5671087f
TI
1835 AC_VERB_GET_GPIO_DIRECTION, 0);
1836 gpiodir |= (1 << pin);
1837
1838
7639a06c 1839 snd_hda_codec_write(codec, codec->core.afg, 0,
5671087f 1840 AC_VERB_SET_GPIO_MASK, gpiomask);
7639a06c 1841 snd_hda_codec_write(codec, codec->core.afg, 0,
5671087f
TI
1842 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1843
1844 msleep(1);
1845
7639a06c 1846 snd_hda_codec_write(codec, codec->core.afg, 0,
5671087f
TI
1847 AC_VERB_SET_GPIO_DATA, gpiostate);
1848}
1849
1850/* set up GPIO at initialization */
1851static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1727a771 1852 const struct hda_fixup *fix, int action)
5671087f 1853{
1727a771 1854 if (action != HDA_FIXUP_ACT_INIT)
5671087f
TI
1855 return;
1856 alc882_gpio_mute(codec, 0, 0);
1857 alc882_gpio_mute(codec, 1, 0);
1858}
1859
02a237b2
TI
1860/* Fix the connection of some pins for ALC889:
1861 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1862 * work correctly (bko#42740)
1863 */
1864static void alc889_fixup_dac_route(struct hda_codec *codec,
1727a771 1865 const struct hda_fixup *fix, int action)
02a237b2 1866{
1727a771 1867 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
ef8d60fb 1868 /* fake the connections during parsing the tree */
02a237b2
TI
1869 hda_nid_t conn1[2] = { 0x0c, 0x0d };
1870 hda_nid_t conn2[2] = { 0x0e, 0x0f };
1871 snd_hda_override_conn_list(codec, 0x14, 2, conn1);
1872 snd_hda_override_conn_list(codec, 0x15, 2, conn1);
1873 snd_hda_override_conn_list(codec, 0x18, 2, conn2);
1874 snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
1727a771 1875 } else if (action == HDA_FIXUP_ACT_PROBE) {
ef8d60fb
TI
1876 /* restore the connections */
1877 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1878 snd_hda_override_conn_list(codec, 0x14, 5, conn);
1879 snd_hda_override_conn_list(codec, 0x15, 5, conn);
1880 snd_hda_override_conn_list(codec, 0x18, 5, conn);
1881 snd_hda_override_conn_list(codec, 0x1a, 5, conn);
02a237b2
TI
1882 }
1883}
1884
1a97b7f2
TI
1885/* Set VREF on HP pin */
1886static void alc889_fixup_mbp_vref(struct hda_codec *codec,
1727a771 1887 const struct hda_fixup *fix, int action)
1a97b7f2
TI
1888{
1889 struct alc_spec *spec = codec->spec;
9f660a1c 1890 static hda_nid_t nids[3] = { 0x14, 0x15, 0x19 };
1a97b7f2
TI
1891 int i;
1892
1727a771 1893 if (action != HDA_FIXUP_ACT_INIT)
1a97b7f2
TI
1894 return;
1895 for (i = 0; i < ARRAY_SIZE(nids); i++) {
1896 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1897 if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1898 continue;
d3f02d60 1899 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1a97b7f2 1900 val |= AC_PINCTL_VREF_80;
cdd03ced 1901 snd_hda_set_pin_ctl(codec, nids[i], val);
08c189f2 1902 spec->gen.keep_vref_in_automute = 1;
1a97b7f2
TI
1903 break;
1904 }
1905}
1906
0756f09c
TI
1907static void alc889_fixup_mac_pins(struct hda_codec *codec,
1908 const hda_nid_t *nids, int num_nids)
1a97b7f2
TI
1909{
1910 struct alc_spec *spec = codec->spec;
1a97b7f2
TI
1911 int i;
1912
0756f09c 1913 for (i = 0; i < num_nids; i++) {
1a97b7f2 1914 unsigned int val;
d3f02d60 1915 val = snd_hda_codec_get_pin_target(codec, nids[i]);
1a97b7f2 1916 val |= AC_PINCTL_VREF_50;
cdd03ced 1917 snd_hda_set_pin_ctl(codec, nids[i], val);
1a97b7f2 1918 }
08c189f2 1919 spec->gen.keep_vref_in_automute = 1;
1a97b7f2
TI
1920}
1921
0756f09c
TI
1922/* Set VREF on speaker pins on imac91 */
1923static void alc889_fixup_imac91_vref(struct hda_codec *codec,
1924 const struct hda_fixup *fix, int action)
1925{
1926 static hda_nid_t nids[2] = { 0x18, 0x1a };
1927
1928 if (action == HDA_FIXUP_ACT_INIT)
1929 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1930}
1931
e7729a41
AV
1932/* Set VREF on speaker pins on mba11 */
1933static void alc889_fixup_mba11_vref(struct hda_codec *codec,
1934 const struct hda_fixup *fix, int action)
1935{
1936 static hda_nid_t nids[1] = { 0x18 };
1937
1938 if (action == HDA_FIXUP_ACT_INIT)
1939 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1940}
1941
0756f09c
TI
1942/* Set VREF on speaker pins on mba21 */
1943static void alc889_fixup_mba21_vref(struct hda_codec *codec,
1944 const struct hda_fixup *fix, int action)
1945{
1946 static hda_nid_t nids[2] = { 0x18, 0x19 };
1947
1948 if (action == HDA_FIXUP_ACT_INIT)
1949 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
1950}
1951
e427c237 1952/* Don't take HP output as primary
d9111496
FLVC
1953 * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
1954 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
e427c237
TI
1955 */
1956static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
1727a771 1957 const struct hda_fixup *fix, int action)
e427c237
TI
1958{
1959 struct alc_spec *spec = codec->spec;
da96fb5b 1960 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
08c189f2 1961 spec->gen.no_primary_hp = 1;
da96fb5b
TI
1962 spec->gen.no_multi_io = 1;
1963 }
e427c237
TI
1964}
1965
eb9ca3ab
TI
1966static void alc_fixup_bass_chmap(struct hda_codec *codec,
1967 const struct hda_fixup *fix, int action);
1968
7beb3a6e
TI
1969/* For dual-codec configuration, we need to disable some features to avoid
1970 * conflicts of kctls and PCM streams
1971 */
1972static void alc_fixup_dual_codecs(struct hda_codec *codec,
1973 const struct hda_fixup *fix, int action)
1974{
1975 struct alc_spec *spec = codec->spec;
1976
1977 if (action != HDA_FIXUP_ACT_PRE_PROBE)
1978 return;
1979 /* disable vmaster */
1980 spec->gen.suppress_vmaster = 1;
1981 /* auto-mute and auto-mic switch don't work with multiple codecs */
1982 spec->gen.suppress_auto_mute = 1;
1983 spec->gen.suppress_auto_mic = 1;
1984 /* disable aamix as well */
1985 spec->gen.mixer_nid = 0;
1986 /* add location prefix to avoid conflicts */
1987 codec->force_pin_prefix = 1;
1988}
1989
1990static void rename_ctl(struct hda_codec *codec, const char *oldname,
1991 const char *newname)
1992{
1993 struct snd_kcontrol *kctl;
1994
1995 kctl = snd_hda_find_mixer_ctl(codec, oldname);
1996 if (kctl)
1997 strcpy(kctl->id.name, newname);
1998}
1999
2000static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec,
2001 const struct hda_fixup *fix,
2002 int action)
2003{
2004 alc_fixup_dual_codecs(codec, fix, action);
2005 switch (action) {
2006 case HDA_FIXUP_ACT_PRE_PROBE:
2007 /* override card longname to provide a unique UCM profile */
2008 strcpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
2009 break;
2010 case HDA_FIXUP_ACT_BUILD:
2011 /* rename Capture controls depending on the codec */
2012 rename_ctl(codec, "Capture Volume",
2013 codec->addr == 0 ?
2014 "Rear-Panel Capture Volume" :
2015 "Front-Panel Capture Volume");
2016 rename_ctl(codec, "Capture Switch",
2017 codec->addr == 0 ?
2018 "Rear-Panel Capture Switch" :
2019 "Front-Panel Capture Switch");
2020 break;
2021 }
2022}
2023
0202f5cd
P
2024static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
2025 const struct hda_fixup *fix,
2026 int action)
2027{
2028 hda_nid_t conn1[1] = { 0x0c };
2029
2030 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2031 return;
2032
2033 alc_update_coef_idx(codec, 0x7, 0, 0x3c3);
2034 /* We therefore want to make sure 0x14 (front headphone) and
2035 * 0x1b (speakers) use the stereo DAC 0x02
2036 */
2037 snd_hda_override_conn_list(codec, 0x14, 1, conn1);
2038 snd_hda_override_conn_list(codec, 0x1b, 1, conn1);
2039}
2040
1727a771 2041static const struct hda_fixup alc882_fixups[] = {
5c0ebfbe 2042 [ALC882_FIXUP_ABIT_AW9D_MAX] = {
1727a771
TI
2043 .type = HDA_FIXUP_PINS,
2044 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
2045 { 0x15, 0x01080104 }, /* side */
2046 { 0x16, 0x01011012 }, /* rear */
2047 { 0x17, 0x01016011 }, /* clfe */
2785591a 2048 { }
145a902b
DH
2049 }
2050 },
5c0ebfbe 2051 [ALC882_FIXUP_LENOVO_Y530] = {
1727a771
TI
2052 .type = HDA_FIXUP_PINS,
2053 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
2054 { 0x15, 0x99130112 }, /* rear int speakers */
2055 { 0x16, 0x99130111 }, /* subwoofer */
ac612407
DH
2056 { }
2057 }
2058 },
5c0ebfbe 2059 [ALC882_FIXUP_PB_M5210] = {
fd108215
TI
2060 .type = HDA_FIXUP_PINCTLS,
2061 .v.pins = (const struct hda_pintbl[]) {
2062 { 0x19, PIN_VREF50 },
357f915e
KY
2063 {}
2064 }
2065 },
5c0ebfbe 2066 [ALC882_FIXUP_ACER_ASPIRE_7736] = {
1727a771 2067 .type = HDA_FIXUP_FUNC,
23d30f28 2068 .v.func = alc_fixup_sku_ignore,
6981d184 2069 },
5c0ebfbe 2070 [ALC882_FIXUP_ASUS_W90V] = {
1727a771
TI
2071 .type = HDA_FIXUP_PINS,
2072 .v.pins = (const struct hda_pintbl[]) {
5cdf745e
TI
2073 { 0x16, 0x99130110 }, /* fix sequence for CLFE */
2074 { }
2075 }
2076 },
8f239214 2077 [ALC889_FIXUP_CD] = {
1727a771
TI
2078 .type = HDA_FIXUP_PINS,
2079 .v.pins = (const struct hda_pintbl[]) {
8f239214
MB
2080 { 0x1c, 0x993301f0 }, /* CD */
2081 { }
2082 }
2083 },
b2c53e20
DH
2084 [ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
2085 .type = HDA_FIXUP_PINS,
2086 .v.pins = (const struct hda_pintbl[]) {
2087 { 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
2088 { }
2089 },
2090 .chained = true,
2091 .chain_id = ALC889_FIXUP_CD,
2092 },
5c0ebfbe 2093 [ALC889_FIXUP_VAIO_TT] = {
1727a771
TI
2094 .type = HDA_FIXUP_PINS,
2095 .v.pins = (const struct hda_pintbl[]) {
5c0ebfbe
TI
2096 { 0x17, 0x90170111 }, /* hidden surround speaker */
2097 { }
2098 }
2099 },
0e7cc2e7 2100 [ALC888_FIXUP_EEE1601] = {
1727a771 2101 .type = HDA_FIXUP_VERBS,
0e7cc2e7
TI
2102 .v.verbs = (const struct hda_verb[]) {
2103 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2104 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
2105 { }
2106 }
177943a3
TI
2107 },
2108 [ALC882_FIXUP_EAPD] = {
1727a771 2109 .type = HDA_FIXUP_VERBS,
177943a3
TI
2110 .v.verbs = (const struct hda_verb[]) {
2111 /* change to EAPD mode */
2112 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2113 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2114 { }
2115 }
2116 },
7a6069bf 2117 [ALC883_FIXUP_EAPD] = {
1727a771 2118 .type = HDA_FIXUP_VERBS,
7a6069bf
TI
2119 .v.verbs = (const struct hda_verb[]) {
2120 /* change to EAPD mode */
2121 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2122 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2123 { }
2124 }
2125 },
8812c4f9 2126 [ALC883_FIXUP_ACER_EAPD] = {
1727a771 2127 .type = HDA_FIXUP_VERBS,
8812c4f9
TI
2128 .v.verbs = (const struct hda_verb[]) {
2129 /* eanable EAPD on Acer laptops */
2130 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2131 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2132 { }
2133 }
2134 },
1a97b7f2 2135 [ALC882_FIXUP_GPIO1] = {
1727a771 2136 .type = HDA_FIXUP_VERBS,
1a97b7f2
TI
2137 .v.verbs = alc_gpio1_init_verbs,
2138 },
2139 [ALC882_FIXUP_GPIO2] = {
1727a771 2140 .type = HDA_FIXUP_VERBS,
1a97b7f2
TI
2141 .v.verbs = alc_gpio2_init_verbs,
2142 },
eb844d51 2143 [ALC882_FIXUP_GPIO3] = {
1727a771 2144 .type = HDA_FIXUP_VERBS,
eb844d51
TI
2145 .v.verbs = alc_gpio3_init_verbs,
2146 },
68ef0561 2147 [ALC882_FIXUP_ASUS_W2JC] = {
1727a771 2148 .type = HDA_FIXUP_VERBS,
68ef0561
TI
2149 .v.verbs = alc_gpio1_init_verbs,
2150 .chained = true,
2151 .chain_id = ALC882_FIXUP_EAPD,
2152 },
2153 [ALC889_FIXUP_COEF] = {
1727a771 2154 .type = HDA_FIXUP_FUNC,
68ef0561
TI
2155 .v.func = alc889_fixup_coef,
2156 },
c3e837bb 2157 [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
1727a771
TI
2158 .type = HDA_FIXUP_PINS,
2159 .v.pins = (const struct hda_pintbl[]) {
c3e837bb
TI
2160 { 0x16, 0x99130111 }, /* CLFE speaker */
2161 { 0x17, 0x99130112 }, /* surround speaker */
2162 { }
038d4fef
TI
2163 },
2164 .chained = true,
2165 .chain_id = ALC882_FIXUP_GPIO1,
c3e837bb
TI
2166 },
2167 [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
1727a771
TI
2168 .type = HDA_FIXUP_PINS,
2169 .v.pins = (const struct hda_pintbl[]) {
c3e837bb
TI
2170 { 0x16, 0x99130111 }, /* CLFE speaker */
2171 { 0x1b, 0x99130112 }, /* surround speaker */
2172 { }
2173 },
2174 .chained = true,
2175 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2176 },
2177 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2178 /* additional init verbs for Acer Aspire 8930G */
1727a771 2179 .type = HDA_FIXUP_VERBS,
c3e837bb
TI
2180 .v.verbs = (const struct hda_verb[]) {
2181 /* Enable all DACs */
2182 /* DAC DISABLE/MUTE 1? */
2183 /* setting bits 1-5 disables DAC nids 0x02-0x06
2184 * apparently. Init=0x38 */
2185 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2186 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2187 /* DAC DISABLE/MUTE 2? */
2188 /* some bit here disables the other DACs.
2189 * Init=0x4900 */
2190 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2191 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2192 /* DMIC fix
2193 * This laptop has a stereo digital microphone.
2194 * The mics are only 1cm apart which makes the stereo
2195 * useless. However, either the mic or the ALC889
2196 * makes the signal become a difference/sum signal
2197 * instead of standard stereo, which is annoying.
2198 * So instead we flip this bit which makes the
2199 * codec replicate the sum signal to both channels,
2200 * turning it into a normal mono mic.
2201 */
2202 /* DMIC_CONTROL? Init value = 0x0001 */
2203 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2204 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2205 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2206 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2207 { }
038d4fef
TI
2208 },
2209 .chained = true,
2210 .chain_id = ALC882_FIXUP_GPIO1,
c3e837bb 2211 },
5671087f 2212 [ALC885_FIXUP_MACPRO_GPIO] = {
1727a771 2213 .type = HDA_FIXUP_FUNC,
5671087f
TI
2214 .v.func = alc885_fixup_macpro_gpio,
2215 },
02a237b2 2216 [ALC889_FIXUP_DAC_ROUTE] = {
1727a771 2217 .type = HDA_FIXUP_FUNC,
02a237b2
TI
2218 .v.func = alc889_fixup_dac_route,
2219 },
1a97b7f2 2220 [ALC889_FIXUP_MBP_VREF] = {
1727a771 2221 .type = HDA_FIXUP_FUNC,
1a97b7f2
TI
2222 .v.func = alc889_fixup_mbp_vref,
2223 .chained = true,
2224 .chain_id = ALC882_FIXUP_GPIO1,
2225 },
2226 [ALC889_FIXUP_IMAC91_VREF] = {
1727a771 2227 .type = HDA_FIXUP_FUNC,
1a97b7f2
TI
2228 .v.func = alc889_fixup_imac91_vref,
2229 .chained = true,
2230 .chain_id = ALC882_FIXUP_GPIO1,
2231 },
e7729a41
AV
2232 [ALC889_FIXUP_MBA11_VREF] = {
2233 .type = HDA_FIXUP_FUNC,
2234 .v.func = alc889_fixup_mba11_vref,
2235 .chained = true,
2236 .chain_id = ALC889_FIXUP_MBP_VREF,
2237 },
0756f09c
TI
2238 [ALC889_FIXUP_MBA21_VREF] = {
2239 .type = HDA_FIXUP_FUNC,
2240 .v.func = alc889_fixup_mba21_vref,
2241 .chained = true,
2242 .chain_id = ALC889_FIXUP_MBP_VREF,
2243 },
c20f31ec
TI
2244 [ALC889_FIXUP_MP11_VREF] = {
2245 .type = HDA_FIXUP_FUNC,
2246 .v.func = alc889_fixup_mba11_vref,
2247 .chained = true,
2248 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2249 },
9f660a1c
MK
2250 [ALC889_FIXUP_MP41_VREF] = {
2251 .type = HDA_FIXUP_FUNC,
2252 .v.func = alc889_fixup_mbp_vref,
2253 .chained = true,
2254 .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2255 },
6e72aa5f 2256 [ALC882_FIXUP_INV_DMIC] = {
1727a771 2257 .type = HDA_FIXUP_FUNC,
9d36a7dc 2258 .v.func = alc_fixup_inv_dmic,
6e72aa5f 2259 },
e427c237 2260 [ALC882_FIXUP_NO_PRIMARY_HP] = {
1727a771 2261 .type = HDA_FIXUP_FUNC,
e427c237
TI
2262 .v.func = alc882_fixup_no_primary_hp,
2263 },
1f0bbf03
TI
2264 [ALC887_FIXUP_ASUS_BASS] = {
2265 .type = HDA_FIXUP_PINS,
2266 .v.pins = (const struct hda_pintbl[]) {
2267 {0x16, 0x99130130}, /* bass speaker */
2268 {}
2269 },
eb9ca3ab
TI
2270 .chained = true,
2271 .chain_id = ALC887_FIXUP_BASS_CHMAP,
2272 },
2273 [ALC887_FIXUP_BASS_CHMAP] = {
2274 .type = HDA_FIXUP_FUNC,
2275 .v.func = alc_fixup_bass_chmap,
1f0bbf03 2276 },
7beb3a6e
TI
2277 [ALC1220_FIXUP_GB_DUAL_CODECS] = {
2278 .type = HDA_FIXUP_FUNC,
2279 .v.func = alc1220_fixup_gb_dual_codecs,
2280 },
0202f5cd
P
2281 [ALC1220_FIXUP_CLEVO_P950] = {
2282 .type = HDA_FIXUP_FUNC,
2283 .v.func = alc1220_fixup_clevo_p950,
2284 },
ff818c24
TI
2285};
2286
1d045db9 2287static const struct snd_pci_quirk alc882_fixup_tbl[] = {
8812c4f9
TI
2288 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2289 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
b5d724b1 2290 SND_PCI_QUIRK(0x1025, 0x0107, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
8812c4f9
TI
2291 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2292 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2293 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2294 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
c3e837bb
TI
2295 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2296 ALC882_FIXUP_ACER_ASPIRE_4930G),
2297 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2298 ALC882_FIXUP_ACER_ASPIRE_4930G),
2299 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2300 ALC882_FIXUP_ACER_ASPIRE_8930G),
2301 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2302 ALC882_FIXUP_ACER_ASPIRE_8930G),
2303 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2304 ALC882_FIXUP_ACER_ASPIRE_4930G),
2305 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2306 ALC882_FIXUP_ACER_ASPIRE_4930G),
2307 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2308 ALC882_FIXUP_ACER_ASPIRE_4930G),
5c0ebfbe 2309 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
f5c53d89
TI
2310 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2311 ALC882_FIXUP_ACER_ASPIRE_4930G),
02a237b2 2312 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
fe97da1f 2313 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
ac9b1cdd 2314 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
177943a3 2315 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
5c0ebfbe 2316 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
68ef0561 2317 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
0e7cc2e7 2318 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
1f0bbf03 2319 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
85bcf96c 2320 SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
ac9b1cdd 2321 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
e427c237 2322 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
3f3c3714 2323 SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
12e31a78 2324 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
c44d9b11 2325 SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
5671087f
TI
2326
2327 /* All Apple entries are in codec SSIDs */
1a97b7f2
TI
2328 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2329 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2330 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
c20f31ec 2331 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
5671087f
TI
2332 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2333 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
1a97b7f2
TI
2334 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2335 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
5671087f 2336 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
e7729a41 2337 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
0756f09c 2338 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
1a97b7f2
TI
2339 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2340 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
5671087f 2341 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
1a97b7f2
TI
2342 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2343 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2344 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
9f660a1c 2345 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 4,1/5,1", ALC889_FIXUP_MP41_VREF),
05193639 2346 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
1a97b7f2
TI
2347 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2348 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
649ccd08 2349 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF),
5671087f 2350
7a6069bf 2351 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
b2c53e20 2352 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
7beb3a6e 2353 SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
d2c3b14e 2354 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
63691587 2355 SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
d2c3b14e 2356 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
5c0ebfbe 2357 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
0202f5cd 2358 SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
7a6069bf
TI
2359 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2360 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
ac9b1cdd 2361 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
68ef0561 2362 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
ff818c24
TI
2363 {}
2364};
2365
1727a771 2366static const struct hda_model_fixup alc882_fixup_models[] = {
912093bc
TI
2367 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2368 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2369 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
6e72aa5f 2370 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
e427c237 2371 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
ba90d6a6 2372 {.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
912093bc
TI
2373 {}
2374};
2375
f6a92248 2376/*
1d045db9 2377 * BIOS auto configuration
f6a92248 2378 */
1d045db9
TI
2379/* almost identical with ALC880 parser... */
2380static int alc882_parse_auto_config(struct hda_codec *codec)
2381{
1d045db9 2382 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
3e6179b8
TI
2383 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2384 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
1d045db9 2385}
b896b4eb 2386
1d045db9
TI
2387/*
2388 */
1d045db9 2389static int patch_alc882(struct hda_codec *codec)
f6a92248
KY
2390{
2391 struct alc_spec *spec;
1a97b7f2 2392 int err;
f6a92248 2393
3de95173
TI
2394 err = alc_alloc_spec(codec, 0x0b);
2395 if (err < 0)
2396 return err;
f6a92248 2397
3de95173 2398 spec = codec->spec;
1f0f4b80 2399
7639a06c 2400 switch (codec->core.vendor_id) {
1d045db9
TI
2401 case 0x10ec0882:
2402 case 0x10ec0885:
acf08081 2403 case 0x10ec0900:
a535ad57 2404 case 0x10ec1220:
1d045db9
TI
2405 break;
2406 default:
2407 /* ALC883 and variants */
2408 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2409 break;
c793bec5 2410 }
977ddd6b 2411
1727a771 2412 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
912093bc 2413 alc882_fixups);
1727a771 2414 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
ff818c24 2415
1d045db9
TI
2416 alc_auto_parse_customize_define(codec);
2417
7504b6cd
TI
2418 if (has_cdefine_beep(codec))
2419 spec->gen.beep_nid = 0x01;
2420
1a97b7f2
TI
2421 /* automatic parse from the BIOS config */
2422 err = alc882_parse_auto_config(codec);
2423 if (err < 0)
2424 goto error;
f6a92248 2425
7504b6cd 2426 if (!spec->gen.no_analog && spec->gen.beep_nid)
1d045db9 2427 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
f6a92248 2428
1727a771 2429 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 2430
f6a92248 2431 return 0;
e16fb6d1
TI
2432
2433 error:
2434 alc_free(codec);
2435 return err;
f6a92248
KY
2436}
2437
df694daa 2438
df694daa 2439/*
1d045db9 2440 * ALC262 support
df694daa 2441 */
1d045db9 2442static int alc262_parse_auto_config(struct hda_codec *codec)
df694daa 2443{
1d045db9 2444 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
3e6179b8
TI
2445 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2446 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
df694daa
KY
2447}
2448
df694daa 2449/*
1d045db9 2450 * Pin config fixes
df694daa 2451 */
cfc9b06f 2452enum {
ea4e7af1 2453 ALC262_FIXUP_FSC_H270,
7513e6da 2454 ALC262_FIXUP_FSC_S7110,
ea4e7af1
TI
2455 ALC262_FIXUP_HP_Z200,
2456 ALC262_FIXUP_TYAN,
c470150c 2457 ALC262_FIXUP_LENOVO_3000,
b42590b8
TI
2458 ALC262_FIXUP_BENQ,
2459 ALC262_FIXUP_BENQ_T31,
6e72aa5f 2460 ALC262_FIXUP_INV_DMIC,
b5c6611f 2461 ALC262_FIXUP_INTEL_BAYLEYBAY,
cfc9b06f
TI
2462};
2463
1727a771 2464static const struct hda_fixup alc262_fixups[] = {
ea4e7af1 2465 [ALC262_FIXUP_FSC_H270] = {
1727a771
TI
2466 .type = HDA_FIXUP_PINS,
2467 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
2468 { 0x14, 0x99130110 }, /* speaker */
2469 { 0x15, 0x0221142f }, /* front HP */
2470 { 0x1b, 0x0121141f }, /* rear HP */
2471 { }
2472 }
2473 },
7513e6da
TI
2474 [ALC262_FIXUP_FSC_S7110] = {
2475 .type = HDA_FIXUP_PINS,
2476 .v.pins = (const struct hda_pintbl[]) {
2477 { 0x15, 0x90170110 }, /* speaker */
2478 { }
2479 },
2480 .chained = true,
2481 .chain_id = ALC262_FIXUP_BENQ,
2482 },
ea4e7af1 2483 [ALC262_FIXUP_HP_Z200] = {
1727a771
TI
2484 .type = HDA_FIXUP_PINS,
2485 .v.pins = (const struct hda_pintbl[]) {
1d045db9 2486 { 0x16, 0x99130120 }, /* internal speaker */
73413b12
TI
2487 { }
2488 }
cfc9b06f 2489 },
ea4e7af1 2490 [ALC262_FIXUP_TYAN] = {
1727a771
TI
2491 .type = HDA_FIXUP_PINS,
2492 .v.pins = (const struct hda_pintbl[]) {
ea4e7af1
TI
2493 { 0x14, 0x1993e1f0 }, /* int AUX */
2494 { }
2495 }
2496 },
c470150c 2497 [ALC262_FIXUP_LENOVO_3000] = {
fd108215
TI
2498 .type = HDA_FIXUP_PINCTLS,
2499 .v.pins = (const struct hda_pintbl[]) {
2500 { 0x19, PIN_VREF50 },
b42590b8
TI
2501 {}
2502 },
2503 .chained = true,
2504 .chain_id = ALC262_FIXUP_BENQ,
2505 },
2506 [ALC262_FIXUP_BENQ] = {
1727a771 2507 .type = HDA_FIXUP_VERBS,
b42590b8 2508 .v.verbs = (const struct hda_verb[]) {
c470150c
TI
2509 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2510 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2511 {}
2512 }
2513 },
b42590b8 2514 [ALC262_FIXUP_BENQ_T31] = {
1727a771 2515 .type = HDA_FIXUP_VERBS,
b42590b8
TI
2516 .v.verbs = (const struct hda_verb[]) {
2517 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2518 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2519 {}
2520 }
2521 },
6e72aa5f 2522 [ALC262_FIXUP_INV_DMIC] = {
1727a771 2523 .type = HDA_FIXUP_FUNC,
9d36a7dc 2524 .v.func = alc_fixup_inv_dmic,
6e72aa5f 2525 },
b5c6611f
ML
2526 [ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2527 .type = HDA_FIXUP_FUNC,
2528 .v.func = alc_fixup_no_depop_delay,
2529 },
cfc9b06f
TI
2530};
2531
1d045db9 2532static const struct snd_pci_quirk alc262_fixup_tbl[] = {
ea4e7af1 2533 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
7513e6da 2534 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
3dcd3be3 2535 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
ea4e7af1
TI
2536 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2537 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
c470150c 2538 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
b42590b8
TI
2539 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2540 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
b5c6611f 2541 SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
cfc9b06f
TI
2542 {}
2543};
df694daa 2544
1727a771 2545static const struct hda_model_fixup alc262_fixup_models[] = {
6e72aa5f
TI
2546 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2547 {}
2548};
1d045db9 2549
1d045db9
TI
2550/*
2551 */
1d045db9 2552static int patch_alc262(struct hda_codec *codec)
df694daa
KY
2553{
2554 struct alc_spec *spec;
df694daa
KY
2555 int err;
2556
3de95173
TI
2557 err = alc_alloc_spec(codec, 0x0b);
2558 if (err < 0)
2559 return err;
df694daa 2560
3de95173 2561 spec = codec->spec;
08c189f2 2562 spec->gen.shared_mic_vref_pin = 0x18;
1d045db9 2563
225068ab
TI
2564 spec->shutup = alc_eapd_shutup;
2565
1d045db9
TI
2566#if 0
2567 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
2568 * under-run
2569 */
98b24883 2570 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
1d045db9 2571#endif
1d045db9
TI
2572 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2573
1727a771 2574 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
6e72aa5f 2575 alc262_fixups);
1727a771 2576 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9c7f852e 2577
af741c15
TI
2578 alc_auto_parse_customize_define(codec);
2579
7504b6cd
TI
2580 if (has_cdefine_beep(codec))
2581 spec->gen.beep_nid = 0x01;
2582
42399f7a
TI
2583 /* automatic parse from the BIOS config */
2584 err = alc262_parse_auto_config(codec);
2585 if (err < 0)
2586 goto error;
df694daa 2587
7504b6cd 2588 if (!spec->gen.no_analog && spec->gen.beep_nid)
1d045db9 2589 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2134ea4f 2590
1727a771 2591 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 2592
1da177e4 2593 return 0;
e16fb6d1
TI
2594
2595 error:
2596 alc_free(codec);
2597 return err;
1da177e4
LT
2598}
2599
f32610ed 2600/*
1d045db9 2601 * ALC268
f32610ed 2602 */
1d045db9 2603/* bind Beep switches of both NID 0x0f and 0x10 */
a717777d
TI
2604static int alc268_beep_switch_put(struct snd_kcontrol *kcontrol,
2605 struct snd_ctl_elem_value *ucontrol)
2606{
2607 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2608 unsigned long pval;
2609 int err;
2610
2611 mutex_lock(&codec->control_mutex);
2612 pval = kcontrol->private_value;
2613 kcontrol->private_value = (pval & ~0xff) | 0x0f;
2614 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2615 if (err >= 0) {
2616 kcontrol->private_value = (pval & ~0xff) | 0x10;
2617 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2618 }
2619 kcontrol->private_value = pval;
2620 mutex_unlock(&codec->control_mutex);
2621 return err;
2622}
f32610ed 2623
1d045db9
TI
2624static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2625 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
a717777d
TI
2626 {
2627 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2628 .name = "Beep Playback Switch",
2629 .subdevice = HDA_SUBDEV_AMP_FLAG,
2630 .info = snd_hda_mixer_amp_switch_info,
2631 .get = snd_hda_mixer_amp_switch_get,
2632 .put = alc268_beep_switch_put,
2633 .private_value = HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT)
2634 },
1d045db9 2635 { }
f32610ed
JS
2636};
2637
1d045db9
TI
2638/* set PCBEEP vol = 0, mute connections */
2639static const struct hda_verb alc268_beep_init_verbs[] = {
2640 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2641 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2642 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2643 { }
f32610ed
JS
2644};
2645
6e72aa5f
TI
2646enum {
2647 ALC268_FIXUP_INV_DMIC,
cb766404 2648 ALC268_FIXUP_HP_EAPD,
24eff328 2649 ALC268_FIXUP_SPDIF,
6e72aa5f
TI
2650};
2651
1727a771 2652static const struct hda_fixup alc268_fixups[] = {
6e72aa5f 2653 [ALC268_FIXUP_INV_DMIC] = {
1727a771 2654 .type = HDA_FIXUP_FUNC,
9d36a7dc 2655 .v.func = alc_fixup_inv_dmic,
6e72aa5f 2656 },
cb766404 2657 [ALC268_FIXUP_HP_EAPD] = {
1727a771 2658 .type = HDA_FIXUP_VERBS,
cb766404
TI
2659 .v.verbs = (const struct hda_verb[]) {
2660 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2661 {}
2662 }
2663 },
24eff328
TI
2664 [ALC268_FIXUP_SPDIF] = {
2665 .type = HDA_FIXUP_PINS,
2666 .v.pins = (const struct hda_pintbl[]) {
2667 { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2668 {}
2669 }
2670 },
6e72aa5f
TI
2671};
2672
1727a771 2673static const struct hda_model_fixup alc268_fixup_models[] = {
6e72aa5f 2674 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
cb766404
TI
2675 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2676 {}
2677};
2678
2679static const struct snd_pci_quirk alc268_fixup_tbl[] = {
24eff328 2680 SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
fcd8f3b1 2681 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
cb766404
TI
2682 /* below is codec SSID since multiple Toshiba laptops have the
2683 * same PCI SSID 1179:ff00
2684 */
2685 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
6e72aa5f
TI
2686 {}
2687};
2688
f32610ed
JS
2689/*
2690 * BIOS auto configuration
2691 */
1d045db9 2692static int alc268_parse_auto_config(struct hda_codec *codec)
f32610ed 2693{
3e6179b8 2694 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
7504b6cd 2695 return alc_parse_auto_config(codec, NULL, alc268_ssids);
f32610ed
JS
2696}
2697
1d045db9
TI
2698/*
2699 */
1d045db9 2700static int patch_alc268(struct hda_codec *codec)
f32610ed
JS
2701{
2702 struct alc_spec *spec;
7504b6cd 2703 int err;
f32610ed 2704
1d045db9 2705 /* ALC268 has no aa-loopback mixer */
3de95173
TI
2706 err = alc_alloc_spec(codec, 0);
2707 if (err < 0)
2708 return err;
2709
2710 spec = codec->spec;
7504b6cd 2711 spec->gen.beep_nid = 0x01;
1f0f4b80 2712
225068ab
TI
2713 spec->shutup = alc_eapd_shutup;
2714
1727a771
TI
2715 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2716 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6e72aa5f 2717
6ebb8053
TI
2718 /* automatic parse from the BIOS config */
2719 err = alc268_parse_auto_config(codec);
e16fb6d1
TI
2720 if (err < 0)
2721 goto error;
f32610ed 2722
7504b6cd
TI
2723 if (err > 0 && !spec->gen.no_analog &&
2724 spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2725 add_mixer(spec, alc268_beep_mixer);
2726 snd_hda_add_verbs(codec, alc268_beep_init_verbs);
1d045db9
TI
2727 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
2728 /* override the amp caps for beep generator */
2729 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
2730 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
2731 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
2732 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2733 (0 << AC_AMPCAP_MUTE_SHIFT));
2f893286
KY
2734 }
2735
1727a771 2736 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6e72aa5f 2737
f32610ed 2738 return 0;
e16fb6d1
TI
2739
2740 error:
2741 alc_free(codec);
2742 return err;
f32610ed
JS
2743}
2744
bc9f98a9 2745/*
1d045db9 2746 * ALC269
bc9f98a9 2747 */
08c189f2 2748
1d045db9 2749static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
1d045db9 2750 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
bc9f98a9
KY
2751};
2752
1d045db9 2753static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
1d045db9 2754 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
bc9f98a9 2755};
291702f0 2756
1d045db9
TI
2757/* different alc269-variants */
2758enum {
2759 ALC269_TYPE_ALC269VA,
2760 ALC269_TYPE_ALC269VB,
2761 ALC269_TYPE_ALC269VC,
adcc70b2 2762 ALC269_TYPE_ALC269VD,
065380f0
KY
2763 ALC269_TYPE_ALC280,
2764 ALC269_TYPE_ALC282,
2af02be7 2765 ALC269_TYPE_ALC283,
065380f0 2766 ALC269_TYPE_ALC284,
4731d5de 2767 ALC269_TYPE_ALC293,
7fc7d047 2768 ALC269_TYPE_ALC286,
506b62c3 2769 ALC269_TYPE_ALC298,
1d04c9de 2770 ALC269_TYPE_ALC255,
4344aec8 2771 ALC269_TYPE_ALC256,
0a6f0600 2772 ALC269_TYPE_ALC215,
4231430d 2773 ALC269_TYPE_ALC225,
dcd4f0db 2774 ALC269_TYPE_ALC294,
6fbae35a 2775 ALC269_TYPE_ALC700,
bc9f98a9
KY
2776};
2777
2778/*
1d045db9 2779 * BIOS auto configuration
bc9f98a9 2780 */
1d045db9
TI
2781static int alc269_parse_auto_config(struct hda_codec *codec)
2782{
1d045db9 2783 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
3e6179b8
TI
2784 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
2785 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2786 struct alc_spec *spec = codec->spec;
adcc70b2
KY
2787 const hda_nid_t *ssids;
2788
2789 switch (spec->codec_variant) {
2790 case ALC269_TYPE_ALC269VA:
2791 case ALC269_TYPE_ALC269VC:
065380f0
KY
2792 case ALC269_TYPE_ALC280:
2793 case ALC269_TYPE_ALC284:
4731d5de 2794 case ALC269_TYPE_ALC293:
adcc70b2
KY
2795 ssids = alc269va_ssids;
2796 break;
2797 case ALC269_TYPE_ALC269VB:
2798 case ALC269_TYPE_ALC269VD:
065380f0 2799 case ALC269_TYPE_ALC282:
2af02be7 2800 case ALC269_TYPE_ALC283:
7fc7d047 2801 case ALC269_TYPE_ALC286:
506b62c3 2802 case ALC269_TYPE_ALC298:
1d04c9de 2803 case ALC269_TYPE_ALC255:
4344aec8 2804 case ALC269_TYPE_ALC256:
0a6f0600 2805 case ALC269_TYPE_ALC215:
4231430d 2806 case ALC269_TYPE_ALC225:
dcd4f0db 2807 case ALC269_TYPE_ALC294:
6fbae35a 2808 case ALC269_TYPE_ALC700:
adcc70b2
KY
2809 ssids = alc269_ssids;
2810 break;
2811 default:
2812 ssids = alc269_ssids;
2813 break;
2814 }
bc9f98a9 2815
3e6179b8 2816 return alc_parse_auto_config(codec, alc269_ignore, ssids);
1d045db9 2817}
bc9f98a9 2818
f7ae9ba0
KY
2819static int find_ext_mic_pin(struct hda_codec *codec);
2820
2821static void alc286_shutup(struct hda_codec *codec)
2822{
2823 int i;
2824 int mic_pin = find_ext_mic_pin(codec);
2825 /* don't shut up pins when unloading the driver; otherwise it breaks
2826 * the default pin setup at the next load of the driver
2827 */
2828 if (codec->bus->shutdown)
2829 return;
2830 for (i = 0; i < codec->init_pins.used; i++) {
2831 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
2832 /* use read here for syncing after issuing each verb */
2833 if (pin->nid != mic_pin)
2834 snd_hda_codec_read(codec, pin->nid, 0,
2835 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
2836 }
2837 codec->pins_shutup = 1;
2838}
2839
1387e2d1 2840static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
1d045db9 2841{
98b24883 2842 alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
1d045db9 2843}
291702f0 2844
1d045db9
TI
2845static void alc269_shutup(struct hda_codec *codec)
2846{
adcc70b2
KY
2847 struct alc_spec *spec = codec->spec;
2848
1387e2d1
KY
2849 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
2850 alc269vb_toggle_power_output(codec, 0);
2851 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
2852 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9
TI
2853 msleep(150);
2854 }
9bfb2844 2855 snd_hda_shutup_pins(codec);
1d045db9 2856}
291702f0 2857
54db6c39
TI
2858static struct coef_fw alc282_coefs[] = {
2859 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
32fa7e49 2860 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
54db6c39
TI
2861 WRITE_COEF(0x07, 0x0200), /* DMIC control */
2862 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2863 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
2864 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
2865 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
2866 WRITE_COEF(0x0e, 0x6e00), /* LDO1/2/3, DAC/ADC */
2867 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
2868 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
2869 WRITE_COEF(0x6f, 0x0), /* Class D test 4 */
2870 UPDATE_COEF(0x0c, 0xfe00, 0), /* IO power down directly */
2871 WRITE_COEF(0x34, 0xa0c0), /* ANC */
2872 UPDATE_COEF(0x16, 0x0008, 0), /* AGC MUX */
2873 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
2874 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
2875 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
2876 WRITE_COEF(0x63, 0x2902), /* PLL */
2877 WRITE_COEF(0x68, 0xa080), /* capless control 2 */
2878 WRITE_COEF(0x69, 0x3400), /* capless control 3 */
2879 WRITE_COEF(0x6a, 0x2f3e), /* capless control 4 */
2880 WRITE_COEF(0x6b, 0x0), /* capless control 5 */
2881 UPDATE_COEF(0x6d, 0x0fff, 0x0900), /* class D test 2 */
2882 WRITE_COEF(0x6e, 0x110a), /* class D test 3 */
2883 UPDATE_COEF(0x70, 0x00f8, 0x00d8), /* class D test 5 */
2884 WRITE_COEF(0x71, 0x0014), /* class D test 6 */
2885 WRITE_COEF(0x72, 0xc2ba), /* classD OCP */
2886 UPDATE_COEF(0x77, 0x0f80, 0), /* classD pure DC test */
2887 WRITE_COEF(0x6c, 0xfc06), /* Class D amp control */
2888 {}
2889};
2890
cb149cb3
KY
2891static void alc282_restore_default_value(struct hda_codec *codec)
2892{
54db6c39 2893 alc_process_coef_fw(codec, alc282_coefs);
cb149cb3
KY
2894}
2895
7b5c7a02
KY
2896static void alc282_init(struct hda_codec *codec)
2897{
2898 struct alc_spec *spec = codec->spec;
2899 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2900 bool hp_pin_sense;
2901 int coef78;
2902
cb149cb3
KY
2903 alc282_restore_default_value(codec);
2904
7b5c7a02
KY
2905 if (!hp_pin)
2906 return;
2907 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2908 coef78 = alc_read_coef_idx(codec, 0x78);
2909
2910 /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
2911 /* Headphone capless set to high power mode */
2912 alc_write_coef_idx(codec, 0x78, 0x9004);
2913
2914 if (hp_pin_sense)
2915 msleep(2);
2916
2917 snd_hda_codec_write(codec, hp_pin, 0,
2918 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2919
2920 if (hp_pin_sense)
2921 msleep(85);
2922
2923 snd_hda_codec_write(codec, hp_pin, 0,
2924 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
2925
2926 if (hp_pin_sense)
2927 msleep(100);
2928
2929 /* Headphone capless set to normal mode */
2930 alc_write_coef_idx(codec, 0x78, coef78);
2931}
2932
2933static void alc282_shutup(struct hda_codec *codec)
2934{
2935 struct alc_spec *spec = codec->spec;
2936 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2937 bool hp_pin_sense;
2938 int coef78;
2939
2940 if (!hp_pin) {
2941 alc269_shutup(codec);
2942 return;
2943 }
2944
2945 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2946 coef78 = alc_read_coef_idx(codec, 0x78);
2947 alc_write_coef_idx(codec, 0x78, 0x9004);
2948
2949 if (hp_pin_sense)
2950 msleep(2);
2951
2952 snd_hda_codec_write(codec, hp_pin, 0,
2953 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2954
2955 if (hp_pin_sense)
2956 msleep(85);
2957
2958 snd_hda_codec_write(codec, hp_pin, 0,
2959 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
2960
2961 if (hp_pin_sense)
2962 msleep(100);
2963
2964 alc_auto_setup_eapd(codec, false);
2965 snd_hda_shutup_pins(codec);
2966 alc_write_coef_idx(codec, 0x78, coef78);
2967}
2968
54db6c39
TI
2969static struct coef_fw alc283_coefs[] = {
2970 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
56779864 2971 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
54db6c39
TI
2972 WRITE_COEF(0x07, 0x0200), /* DMIC control */
2973 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2974 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
2975 WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
2976 WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
2977 WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
2978 UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
2979 UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
2980 WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
2981 UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
2982 WRITE_COEF(0x22, 0xa0c0), /* ANC */
2983 UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
2984 UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
2985 UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
2986 WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
2987 WRITE_COEF(0x2e, 0x2902), /* PLL */
2988 WRITE_COEF(0x33, 0xa080), /* capless control 2 */
2989 WRITE_COEF(0x34, 0x3400), /* capless control 3 */
2990 WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
2991 WRITE_COEF(0x36, 0x0), /* capless control 5 */
2992 UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
2993 WRITE_COEF(0x39, 0x110a), /* class D test 3 */
2994 UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
2995 WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
2996 WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
2997 UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
2998 WRITE_COEF(0x49, 0x0), /* test mode */
2999 UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
3000 UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
3001 WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
56779864 3002 UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
54db6c39
TI
3003 {}
3004};
3005
6bd55b04
KY
3006static void alc283_restore_default_value(struct hda_codec *codec)
3007{
54db6c39 3008 alc_process_coef_fw(codec, alc283_coefs);
6bd55b04
KY
3009}
3010
2af02be7
KY
3011static void alc283_init(struct hda_codec *codec)
3012{
3013 struct alc_spec *spec = codec->spec;
3014 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3015 bool hp_pin_sense;
2af02be7 3016
8314f225
KY
3017 if (!spec->gen.autocfg.hp_outs) {
3018 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3019 hp_pin = spec->gen.autocfg.line_out_pins[0];
3020 }
3021
6bd55b04
KY
3022 alc283_restore_default_value(codec);
3023
2af02be7
KY
3024 if (!hp_pin)
3025 return;
a59d7199
KY
3026
3027 msleep(30);
2af02be7
KY
3028 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3029
3030 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3031 /* Headphone capless set to high power mode */
3032 alc_write_coef_idx(codec, 0x43, 0x9004);
3033
3034 snd_hda_codec_write(codec, hp_pin, 0,
3035 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3036
3037 if (hp_pin_sense)
3038 msleep(85);
3039
3040 snd_hda_codec_write(codec, hp_pin, 0,
3041 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3042
3043 if (hp_pin_sense)
3044 msleep(85);
3045 /* Index 0x46 Combo jack auto switch control 2 */
3046 /* 3k pull low control for Headset jack. */
98b24883 3047 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
2af02be7
KY
3048 /* Headphone capless set to normal mode */
3049 alc_write_coef_idx(codec, 0x43, 0x9614);
3050}
3051
3052static void alc283_shutup(struct hda_codec *codec)
3053{
3054 struct alc_spec *spec = codec->spec;
3055 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3056 bool hp_pin_sense;
2af02be7 3057
8314f225
KY
3058 if (!spec->gen.autocfg.hp_outs) {
3059 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
3060 hp_pin = spec->gen.autocfg.line_out_pins[0];
3061 }
3062
2af02be7
KY
3063 if (!hp_pin) {
3064 alc269_shutup(codec);
3065 return;
3066 }
3067
3068 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3069
3070 alc_write_coef_idx(codec, 0x43, 0x9004);
3071
b450b17c
HP
3072 /*depop hp during suspend*/
3073 alc_write_coef_idx(codec, 0x06, 0x2100);
3074
2af02be7
KY
3075 snd_hda_codec_write(codec, hp_pin, 0,
3076 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3077
3078 if (hp_pin_sense)
88011c09 3079 msleep(100);
2af02be7
KY
3080
3081 snd_hda_codec_write(codec, hp_pin, 0,
3082 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3083
98b24883 3084 alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
2af02be7
KY
3085
3086 if (hp_pin_sense)
88011c09 3087 msleep(100);
0435b3ff 3088 alc_auto_setup_eapd(codec, false);
2af02be7
KY
3089 snd_hda_shutup_pins(codec);
3090 alc_write_coef_idx(codec, 0x43, 0x9614);
3091}
3092
4a219ef8
KY
3093static void alc256_init(struct hda_codec *codec)
3094{
3095 struct alc_spec *spec = codec->spec;
3096 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3097 bool hp_pin_sense;
3098
3099 if (!hp_pin)
3100 return;
3101
3102 msleep(30);
3103
3104 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3105
3106 if (hp_pin_sense)
3107 msleep(2);
3108
3109 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3110
3111 snd_hda_codec_write(codec, hp_pin, 0,
3112 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3113
3114 if (hp_pin_sense)
3115 msleep(85);
3116
3117 snd_hda_codec_write(codec, hp_pin, 0,
3118 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3119
3120 if (hp_pin_sense)
3121 msleep(100);
3122
3123 alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3124 alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3125}
3126
3127static void alc256_shutup(struct hda_codec *codec)
3128{
3129 struct alc_spec *spec = codec->spec;
3130 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3131 bool hp_pin_sense;
3132
3133 if (!hp_pin) {
3134 alc269_shutup(codec);
3135 return;
3136 }
3137
3138 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3139
3140 if (hp_pin_sense)
3141 msleep(2);
3142
3143 snd_hda_codec_write(codec, hp_pin, 0,
3144 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3145
3146 if (hp_pin_sense)
3147 msleep(85);
3148
3149 snd_hda_codec_write(codec, hp_pin, 0,
3150 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3151
3152 alc_update_coef_idx(codec, 0x46, 0, 3 << 12); /* 3k pull low control for Headset jack. */
3153
3154 if (hp_pin_sense)
3155 msleep(100);
3156
3157 alc_auto_setup_eapd(codec, false);
3158 snd_hda_shutup_pins(codec);
3159}
3160
c2d6af53
KY
3161static void alc_default_init(struct hda_codec *codec)
3162{
3163 struct alc_spec *spec = codec->spec;
3164 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3165 bool hp_pin_sense;
3166
3167 if (!hp_pin)
3168 return;
3169
3170 msleep(30);
3171
3172 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3173
3174 if (hp_pin_sense)
3175 msleep(2);
3176
3177 snd_hda_codec_write(codec, hp_pin, 0,
3178 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3179
3180 if (hp_pin_sense)
3181 msleep(85);
3182
3183 snd_hda_codec_write(codec, hp_pin, 0,
3184 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3185
3186 if (hp_pin_sense)
3187 msleep(100);
3188}
3189
3190static void alc_default_shutup(struct hda_codec *codec)
3191{
3192 struct alc_spec *spec = codec->spec;
3193 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
3194 bool hp_pin_sense;
3195
3196 if (!hp_pin) {
3197 alc269_shutup(codec);
3198 return;
3199 }
3200
3201 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3202
3203 if (hp_pin_sense)
3204 msleep(2);
3205
3206 snd_hda_codec_write(codec, hp_pin, 0,
3207 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3208
3209 if (hp_pin_sense)
3210 msleep(85);
3211
3212 snd_hda_codec_write(codec, hp_pin, 0,
3213 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3214
3215 if (hp_pin_sense)
3216 msleep(100);
3217
3218 alc_auto_setup_eapd(codec, false);
3219 snd_hda_shutup_pins(codec);
3220}
3221
ad60d502
KY
3222static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3223 unsigned int val)
3224{
3225 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3226 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3227 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3228}
3229
3230static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3231{
3232 unsigned int val;
3233
3234 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3235 val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3236 & 0xffff;
3237 val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3238 << 16;
3239 return val;
3240}
3241
3242static void alc5505_dsp_halt(struct hda_codec *codec)
3243{
3244 unsigned int val;
3245
3246 alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3247 alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3248 alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3249 alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3250 alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3251 alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3252 alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3253 val = alc5505_coef_get(codec, 0x6220);
3254 alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3255}
3256
3257static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3258{
3259 alc5505_coef_set(codec, 0x61b8, 0x04133302);
3260 alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3261 alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3262 alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3263 alc5505_coef_set(codec, 0x6220, 0x2002010f);
3264 alc5505_coef_set(codec, 0x880c, 0x00000004);
3265}
3266
3267static void alc5505_dsp_init(struct hda_codec *codec)
3268{
3269 unsigned int val;
3270
3271 alc5505_dsp_halt(codec);
3272 alc5505_dsp_back_from_halt(codec);
3273 alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3274 alc5505_coef_set(codec, 0x61b0, 0x5b16);
3275 alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3276 alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3277 alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3278 alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3279 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3280 alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3281 alc5505_coef_set(codec, 0x61b8, 0x04173302);
3282 alc5505_coef_set(codec, 0x61b8, 0x04163302);
3283 alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3284 alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3285 alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3286
3287 val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3288 if (val <= 3)
3289 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3290 else
3291 alc5505_coef_set(codec, 0x6220, 0x6002018f);
3292
3293 alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
3294 alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
3295 alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
3296 alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
3297 alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
3298 alc5505_coef_set(codec, 0x880c, 0x00000003);
3299 alc5505_coef_set(codec, 0x880c, 0x00000010);
cd63a5ff
TI
3300
3301#ifdef HALT_REALTEK_ALC5505
3302 alc5505_dsp_halt(codec);
3303#endif
ad60d502
KY
3304}
3305
cd63a5ff
TI
3306#ifdef HALT_REALTEK_ALC5505
3307#define alc5505_dsp_suspend(codec) /* NOP */
3308#define alc5505_dsp_resume(codec) /* NOP */
3309#else
3310#define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec)
3311#define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec)
3312#endif
3313
2a43952a 3314#ifdef CONFIG_PM
ad60d502
KY
3315static int alc269_suspend(struct hda_codec *codec)
3316{
3317 struct alc_spec *spec = codec->spec;
3318
3319 if (spec->has_alc5505_dsp)
cd63a5ff 3320 alc5505_dsp_suspend(codec);
ad60d502
KY
3321 return alc_suspend(codec);
3322}
3323
1d045db9
TI
3324static int alc269_resume(struct hda_codec *codec)
3325{
adcc70b2
KY
3326 struct alc_spec *spec = codec->spec;
3327
1387e2d1
KY
3328 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3329 alc269vb_toggle_power_output(codec, 0);
3330 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
adcc70b2 3331 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9
TI
3332 msleep(150);
3333 }
8c427226 3334
1d045db9 3335 codec->patch_ops.init(codec);
f1d4e28b 3336
1387e2d1
KY
3337 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3338 alc269vb_toggle_power_output(codec, 1);
3339 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
adcc70b2 3340 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
1d045db9
TI
3341 msleep(200);
3342 }
f1d4e28b 3343
eeecd9d1 3344 regcache_sync(codec->core.regmap);
1d045db9 3345 hda_call_check_power_status(codec, 0x01);
f475371a
HW
3346
3347 /* on some machine, the BIOS will clear the codec gpio data when enter
3348 * suspend, and won't restore the data after resume, so we restore it
3349 * in the driver.
3350 */
3351 if (spec->gpio_led)
7639a06c 3352 snd_hda_codec_write(codec, codec->core.afg, 0, AC_VERB_SET_GPIO_DATA,
f475371a
HW
3353 spec->gpio_led);
3354
ad60d502 3355 if (spec->has_alc5505_dsp)
cd63a5ff 3356 alc5505_dsp_resume(codec);
c5177c86 3357
1d045db9
TI
3358 return 0;
3359}
2a43952a 3360#endif /* CONFIG_PM */
f1d4e28b 3361
108cc108 3362static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
1727a771 3363 const struct hda_fixup *fix, int action)
108cc108
DH
3364{
3365 struct alc_spec *spec = codec->spec;
3366
1727a771 3367 if (action == HDA_FIXUP_ACT_PRE_PROBE)
108cc108
DH
3368 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3369}
3370
1d045db9 3371static void alc269_fixup_hweq(struct hda_codec *codec,
1727a771 3372 const struct hda_fixup *fix, int action)
1d045db9 3373{
98b24883
TI
3374 if (action == HDA_FIXUP_ACT_INIT)
3375 alc_update_coef_idx(codec, 0x1e, 0, 0x80);
1d045db9 3376}
f1d4e28b 3377
7c478f03
DH
3378static void alc269_fixup_headset_mic(struct hda_codec *codec,
3379 const struct hda_fixup *fix, int action)
3380{
3381 struct alc_spec *spec = codec->spec;
3382
3383 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3384 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3385}
3386
1d045db9 3387static void alc271_fixup_dmic(struct hda_codec *codec,
1727a771 3388 const struct hda_fixup *fix, int action)
1d045db9
TI
3389{
3390 static const struct hda_verb verbs[] = {
3391 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
3392 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
3393 {}
3394 };
3395 unsigned int cfg;
f1d4e28b 3396
7639a06c
TI
3397 if (strcmp(codec->core.chip_name, "ALC271X") &&
3398 strcmp(codec->core.chip_name, "ALC269VB"))
1d045db9
TI
3399 return;
3400 cfg = snd_hda_codec_get_pincfg(codec, 0x12);
3401 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
3402 snd_hda_sequence_write(codec, verbs);
3403}
f1d4e28b 3404
017f2a10 3405static void alc269_fixup_pcm_44k(struct hda_codec *codec,
1727a771 3406 const struct hda_fixup *fix, int action)
017f2a10
TI
3407{
3408 struct alc_spec *spec = codec->spec;
3409
1727a771 3410 if (action != HDA_FIXUP_ACT_PROBE)
017f2a10
TI
3411 return;
3412
3413 /* Due to a hardware problem on Lenovo Ideadpad, we need to
3414 * fix the sample rate of analog I/O to 44.1kHz
3415 */
08c189f2
TI
3416 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
3417 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
017f2a10
TI
3418}
3419
adabb3ec 3420static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
1727a771 3421 const struct hda_fixup *fix, int action)
adabb3ec 3422{
adabb3ec
TI
3423 /* The digital-mic unit sends PDM (differential signal) instead of
3424 * the standard PCM, thus you can't record a valid mono stream as is.
3425 * Below is a workaround specific to ALC269 to control the dmic
3426 * signal source as mono.
3427 */
98b24883
TI
3428 if (action == HDA_FIXUP_ACT_INIT)
3429 alc_update_coef_idx(codec, 0x07, 0, 0x80);
adabb3ec
TI
3430}
3431
24519911
TI
3432static void alc269_quanta_automute(struct hda_codec *codec)
3433{
08c189f2 3434 snd_hda_gen_update_outputs(codec);
24519911 3435
1687ccc8
TI
3436 alc_write_coef_idx(codec, 0x0c, 0x680);
3437 alc_write_coef_idx(codec, 0x0c, 0x480);
24519911
TI
3438}
3439
3440static void alc269_fixup_quanta_mute(struct hda_codec *codec,
1727a771 3441 const struct hda_fixup *fix, int action)
24519911
TI
3442{
3443 struct alc_spec *spec = codec->spec;
1727a771 3444 if (action != HDA_FIXUP_ACT_PROBE)
24519911 3445 return;
08c189f2 3446 spec->gen.automute_hook = alc269_quanta_automute;
24519911
TI
3447}
3448
d240d1dc 3449static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
1a4f69d5 3450 struct hda_jack_callback *jack)
d240d1dc
DH
3451{
3452 struct alc_spec *spec = codec->spec;
3453 int vref;
3454 msleep(200);
3455 snd_hda_gen_hp_automute(codec, jack);
3456
3457 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
3458 msleep(100);
3459 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3460 vref);
3461 msleep(500);
3462 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3463 vref);
3464}
3465
3466static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
3467 const struct hda_fixup *fix, int action)
3468{
3469 struct alc_spec *spec = codec->spec;
3470 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3471 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3472 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
3473 }
3474}
3475
3476
08fb0d0e
TI
3477/* update mute-LED according to the speaker mute state via mic VREF pin */
3478static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
6d3cd5d4
DH
3479{
3480 struct hda_codec *codec = private_data;
08fb0d0e
TI
3481 struct alc_spec *spec = codec->spec;
3482 unsigned int pinval;
3483
3484 if (spec->mute_led_polarity)
3485 enabled = !enabled;
415d555e
TI
3486 pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid);
3487 pinval &= ~AC_PINCTL_VREFEN;
3488 pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80;
08fb0d0e
TI
3489 if (spec->mute_led_nid)
3490 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
6d3cd5d4
DH
3491}
3492
d5b6b65e
DH
3493/* Make sure the led works even in runtime suspend */
3494static unsigned int led_power_filter(struct hda_codec *codec,
3495 hda_nid_t nid,
3496 unsigned int power_state)
3497{
3498 struct alc_spec *spec = codec->spec;
3499
50dd9050
HW
3500 if (power_state != AC_PWRST_D3 || nid == 0 ||
3501 (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
d5b6b65e
DH
3502 return power_state;
3503
3504 /* Set pin ctl again, it might have just been set to 0 */
3505 snd_hda_set_pin_ctl(codec, nid,
3506 snd_hda_codec_get_pin_target(codec, nid));
3507
cffd3966 3508 return snd_hda_gen_path_power_filter(codec, nid, power_state);
d5b6b65e
DH
3509}
3510
08fb0d0e
TI
3511static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
3512 const struct hda_fixup *fix, int action)
6d3cd5d4
DH
3513{
3514 struct alc_spec *spec = codec->spec;
08fb0d0e
TI
3515 const struct dmi_device *dev = NULL;
3516
3517 if (action != HDA_FIXUP_ACT_PRE_PROBE)
3518 return;
3519
3520 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
3521 int pol, pin;
3522 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
3523 continue;
3524 if (pin < 0x0a || pin >= 0x10)
3525 break;
3526 spec->mute_led_polarity = pol;
3527 spec->mute_led_nid = pin - 0x0a + 0x18;
3528 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
fd25a97a 3529 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3530 codec->power_filter = led_power_filter;
4e76a883
TI
3531 codec_dbg(codec,
3532 "Detected mute LED for %x:%d\n", spec->mute_led_nid,
08fb0d0e 3533 spec->mute_led_polarity);
6d3cd5d4
DH
3534 break;
3535 }
3536}
3537
d06ac143
DH
3538static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
3539 const struct hda_fixup *fix, int action)
3540{
3541 struct alc_spec *spec = codec->spec;
3542 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3543 spec->mute_led_polarity = 0;
3544 spec->mute_led_nid = 0x18;
3545 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3546 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3547 codec->power_filter = led_power_filter;
d06ac143
DH
3548 }
3549}
3550
08fb0d0e
TI
3551static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
3552 const struct hda_fixup *fix, int action)
420b0feb
TI
3553{
3554 struct alc_spec *spec = codec->spec;
9bb1f06f 3555 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
08fb0d0e
TI
3556 spec->mute_led_polarity = 0;
3557 spec->mute_led_nid = 0x19;
3558 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
fd25a97a 3559 spec->gen.vmaster_mute_enum = 1;
d5b6b65e 3560 codec->power_filter = led_power_filter;
420b0feb
TI
3561 }
3562}
3563
0f32fd19
TI
3564/* update LED status via GPIO */
3565static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
3566 bool enabled)
9f5c6faf 3567{
9f5c6faf
TI
3568 struct alc_spec *spec = codec->spec;
3569 unsigned int oldval = spec->gpio_led;
3570
0f32fd19
TI
3571 if (spec->mute_led_polarity)
3572 enabled = !enabled;
3573
9f5c6faf 3574 if (enabled)
0f32fd19 3575 spec->gpio_led &= ~mask;
9f5c6faf 3576 else
0f32fd19 3577 spec->gpio_led |= mask;
9f5c6faf
TI
3578 if (spec->gpio_led != oldval)
3579 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
3580 spec->gpio_led);
3581}
3582
0f32fd19
TI
3583/* turn on/off mute LED via GPIO per vmaster hook */
3584static void alc_fixup_gpio_mute_hook(void *private_data, int enabled)
9f5c6faf 3585{
0f32fd19 3586 struct hda_codec *codec = private_data;
9f5c6faf 3587 struct alc_spec *spec = codec->spec;
9f5c6faf 3588
0f32fd19
TI
3589 alc_update_gpio_led(codec, spec->gpio_mute_led_mask, enabled);
3590}
9f5c6faf 3591
0f32fd19
TI
3592/* turn on/off mic-mute LED via GPIO per capture hook */
3593static void alc_fixup_gpio_mic_mute_hook(struct hda_codec *codec,
3594 struct snd_kcontrol *kcontrol,
3595 struct snd_ctl_elem_value *ucontrol)
3596{
3597 struct alc_spec *spec = codec->spec;
3598
3599 if (ucontrol)
3600 alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
3601 ucontrol->value.integer.value[0] ||
3602 ucontrol->value.integer.value[1]);
9f5c6faf
TI
3603}
3604
3605static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
3606 const struct hda_fixup *fix, int action)
3607{
3608 struct alc_spec *spec = codec->spec;
3609 static const struct hda_verb gpio_init[] = {
3610 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
3611 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
3612 {}
3613 };
3614
3615 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
0f32fd19
TI
3616 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
3617 spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook;
9f5c6faf 3618 spec->gpio_led = 0;
0f32fd19
TI
3619 spec->mute_led_polarity = 0;
3620 spec->gpio_mute_led_mask = 0x08;
3621 spec->gpio_mic_led_mask = 0x10;
9f5c6faf
TI
3622 snd_hda_add_verbs(codec, gpio_init);
3623 }
3624}
3625
eaa8e5ef
KY
3626static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
3627 const struct hda_fixup *fix, int action)
3628{
3629 struct alc_spec *spec = codec->spec;
3630 static const struct hda_verb gpio_init[] = {
3631 { 0x01, AC_VERB_SET_GPIO_MASK, 0x22 },
3632 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x22 },
3633 {}
3634 };
3635
3636 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3637 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
3638 spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook;
9f5c6faf 3639 spec->gpio_led = 0;
eaa8e5ef
KY
3640 spec->mute_led_polarity = 0;
3641 spec->gpio_mute_led_mask = 0x02;
3642 spec->gpio_mic_led_mask = 0x20;
9f5c6faf
TI
3643 snd_hda_add_verbs(codec, gpio_init);
3644 }
3645}
3646
9c5dc3bf
KY
3647/* turn on/off mic-mute LED per capture hook */
3648static void alc269_fixup_hp_cap_mic_mute_hook(struct hda_codec *codec,
3649 struct snd_kcontrol *kcontrol,
3650 struct snd_ctl_elem_value *ucontrol)
3651{
3652 struct alc_spec *spec = codec->spec;
3653 unsigned int pinval, enable, disable;
3654
fc1fad93 3655 pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid);
9c5dc3bf
KY
3656 pinval &= ~AC_PINCTL_VREFEN;
3657 enable = pinval | AC_PINCTL_VREF_80;
3658 disable = pinval | AC_PINCTL_VREF_HIZ;
3659
3660 if (!ucontrol)
3661 return;
3662
3663 if (ucontrol->value.integer.value[0] ||
3664 ucontrol->value.integer.value[1])
3665 pinval = disable;
3666 else
3667 pinval = enable;
3668
3669 if (spec->cap_mute_led_nid)
3670 snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval);
3671}
3672
3673static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
3674 const struct hda_fixup *fix, int action)
3675{
3676 struct alc_spec *spec = codec->spec;
3677 static const struct hda_verb gpio_init[] = {
3678 { 0x01, AC_VERB_SET_GPIO_MASK, 0x08 },
3679 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x08 },
3680 {}
3681 };
3682
3683 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
0f32fd19 3684 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
9c5dc3bf
KY
3685 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3686 spec->gpio_led = 0;
0f32fd19
TI
3687 spec->mute_led_polarity = 0;
3688 spec->gpio_mute_led_mask = 0x08;
9c5dc3bf
KY
3689 spec->cap_mute_led_nid = 0x18;
3690 snd_hda_add_verbs(codec, gpio_init);
50dd9050 3691 codec->power_filter = led_power_filter;
9c5dc3bf
KY
3692 }
3693}
3694
7a5255f1
DH
3695static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
3696 const struct hda_fixup *fix, int action)
3697{
3698 /* Like hp_gpio_mic1_led, but also needs GPIO4 low to enable headphone amp */
3699 struct alc_spec *spec = codec->spec;
3700 static const struct hda_verb gpio_init[] = {
3701 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
3702 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
3703 {}
3704 };
3705
3706 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
0f32fd19 3707 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
7a5255f1
DH
3708 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3709 spec->gpio_led = 0;
0f32fd19
TI
3710 spec->mute_led_polarity = 0;
3711 spec->gpio_mute_led_mask = 0x08;
7a5255f1
DH
3712 spec->cap_mute_led_nid = 0x18;
3713 snd_hda_add_verbs(codec, gpio_init);
3714 codec->power_filter = led_power_filter;
3715 }
3716}
3717
33f4acd3
DH
3718static void gpio2_mic_hotkey_event(struct hda_codec *codec,
3719 struct hda_jack_callback *event)
3720{
3721 struct alc_spec *spec = codec->spec;
3722
3723 /* GPIO2 just toggles on a keypress/keyrelease cycle. Therefore
3724 send both key on and key off event for every interrupt. */
c7b60a89 3725 input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 1);
33f4acd3 3726 input_sync(spec->kb_dev);
c7b60a89 3727 input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 0);
33f4acd3
DH
3728 input_sync(spec->kb_dev);
3729}
33f4acd3 3730
3694cb29
K
3731static int alc_register_micmute_input_device(struct hda_codec *codec)
3732{
3733 struct alc_spec *spec = codec->spec;
c7b60a89 3734 int i;
3694cb29
K
3735
3736 spec->kb_dev = input_allocate_device();
3737 if (!spec->kb_dev) {
3738 codec_err(codec, "Out of memory (input_allocate_device)\n");
3739 return -ENOMEM;
3740 }
c7b60a89
HW
3741
3742 spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX] = KEY_MICMUTE;
3743
3694cb29
K
3744 spec->kb_dev->name = "Microphone Mute Button";
3745 spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY);
c7b60a89
HW
3746 spec->kb_dev->keycodesize = sizeof(spec->alc_mute_keycode_map[0]);
3747 spec->kb_dev->keycodemax = ARRAY_SIZE(spec->alc_mute_keycode_map);
3748 spec->kb_dev->keycode = spec->alc_mute_keycode_map;
3749 for (i = 0; i < ARRAY_SIZE(spec->alc_mute_keycode_map); i++)
3750 set_bit(spec->alc_mute_keycode_map[i], spec->kb_dev->keybit);
3694cb29
K
3751
3752 if (input_register_device(spec->kb_dev)) {
3753 codec_err(codec, "input_register_device failed\n");
3754 input_free_device(spec->kb_dev);
3755 spec->kb_dev = NULL;
3756 return -ENOMEM;
3757 }
3758
3759 return 0;
3760}
3761
33f4acd3
DH
3762static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
3763 const struct hda_fixup *fix, int action)
3764{
33f4acd3
DH
3765 /* GPIO1 = set according to SKU external amp
3766 GPIO2 = mic mute hotkey
3767 GPIO3 = mute LED
3768 GPIO4 = mic mute LED */
3769 static const struct hda_verb gpio_init[] = {
3770 { 0x01, AC_VERB_SET_GPIO_MASK, 0x1e },
3771 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x1a },
3772 { 0x01, AC_VERB_SET_GPIO_DATA, 0x02 },
3773 {}
3774 };
3775
3776 struct alc_spec *spec = codec->spec;
3777
3778 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3694cb29 3779 if (alc_register_micmute_input_device(codec) != 0)
33f4acd3 3780 return;
33f4acd3
DH
3781
3782 snd_hda_add_verbs(codec, gpio_init);
7639a06c 3783 snd_hda_codec_write_cache(codec, codec->core.afg, 0,
33f4acd3 3784 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04);
7639a06c 3785 snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
33f4acd3
DH
3786 gpio2_mic_hotkey_event);
3787
3788 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
3789 spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook;
3790 spec->gpio_led = 0;
3791 spec->mute_led_polarity = 0;
3792 spec->gpio_mute_led_mask = 0x08;
3793 spec->gpio_mic_led_mask = 0x10;
3794 return;
3795 }
3796
3797 if (!spec->kb_dev)
3798 return;
3799
3800 switch (action) {
3801 case HDA_FIXUP_ACT_PROBE:
3802 spec->init_amp = ALC_INIT_DEFAULT;
3803 break;
3804 case HDA_FIXUP_ACT_FREE:
3805 input_unregister_device(spec->kb_dev);
33f4acd3
DH
3806 spec->kb_dev = NULL;
3807 }
33f4acd3
DH
3808}
3809
3694cb29
K
3810static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
3811 const struct hda_fixup *fix, int action)
3812{
3813 /* Line2 = mic mute hotkey
3814 GPIO2 = mic mute LED */
3815 static const struct hda_verb gpio_init[] = {
3816 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
3817 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
3818 {}
3819 };
3820
3821 struct alc_spec *spec = codec->spec;
3822
3823 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3824 if (alc_register_micmute_input_device(codec) != 0)
3825 return;
3826
3827 snd_hda_add_verbs(codec, gpio_init);
3828 snd_hda_jack_detect_enable_callback(codec, 0x1b,
3829 gpio2_mic_hotkey_event);
3830
3831 spec->gen.cap_sync_hook = alc_fixup_gpio_mic_mute_hook;
3832 spec->gpio_led = 0;
3833 spec->mute_led_polarity = 0;
3834 spec->gpio_mic_led_mask = 0x04;
3835 return;
3836 }
3837
3838 if (!spec->kb_dev)
3839 return;
3840
3841 switch (action) {
3842 case HDA_FIXUP_ACT_PROBE:
3843 spec->init_amp = ALC_INIT_DEFAULT;
3844 break;
3845 case HDA_FIXUP_ACT_FREE:
3846 input_unregister_device(spec->kb_dev);
3847 spec->kb_dev = NULL;
3848 }
3849}
3850
9c5dc3bf
KY
3851static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
3852 const struct hda_fixup *fix, int action)
3853{
3854 struct alc_spec *spec = codec->spec;
3855
3856 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3857 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3858 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3859 spec->mute_led_polarity = 0;
3860 spec->mute_led_nid = 0x1a;
3861 spec->cap_mute_led_nid = 0x18;
3862 spec->gen.vmaster_mute_enum = 1;
3863 codec->power_filter = led_power_filter;
3864 }
3865}
3866
5a36767a
KY
3867static struct coef_fw alc225_pre_hsmode[] = {
3868 UPDATE_COEF(0x4a, 1<<8, 0),
3869 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0),
3870 UPDATE_COEF(0x63, 3<<14, 3<<14),
3871 UPDATE_COEF(0x4a, 3<<4, 2<<4),
3872 UPDATE_COEF(0x4a, 3<<10, 3<<10),
3873 UPDATE_COEF(0x45, 0x3f<<10, 0x34<<10),
3874 UPDATE_COEF(0x4a, 3<<10, 0),
3875 {}
3876};
3877
73bdd597
DH
3878static void alc_headset_mode_unplugged(struct hda_codec *codec)
3879{
54db6c39 3880 static struct coef_fw coef0255[] = {
54db6c39
TI
3881 WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
3882 UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
3883 WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
3884 WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
3885 {}
3886 };
e69e7e03
KY
3887 static struct coef_fw coef0255_1[] = {
3888 WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
3889 {}
3890 };
3891 static struct coef_fw coef0256[] = {
3892 WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */
3893 {}
3894 };
54db6c39
TI
3895 static struct coef_fw coef0233[] = {
3896 WRITE_COEF(0x1b, 0x0c0b),
3897 WRITE_COEF(0x45, 0xc429),
3898 UPDATE_COEF(0x35, 0x4000, 0),
3899 WRITE_COEF(0x06, 0x2104),
3900 WRITE_COEF(0x1a, 0x0001),
3901 WRITE_COEF(0x26, 0x0004),
3902 WRITE_COEF(0x32, 0x42a3),
3903 {}
3904 };
f3b70332
KY
3905 static struct coef_fw coef0288[] = {
3906 UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
3907 UPDATE_COEF(0x50, 0x2000, 0x2000),
3908 UPDATE_COEF(0x56, 0x0006, 0x0006),
3909 UPDATE_COEF(0x66, 0x0008, 0),
3910 UPDATE_COEF(0x67, 0x2000, 0),
3911 {}
3912 };
89542936
KY
3913 static struct coef_fw coef0298[] = {
3914 UPDATE_COEF(0x19, 0x1300, 0x0300),
3915 {}
3916 };
54db6c39
TI
3917 static struct coef_fw coef0292[] = {
3918 WRITE_COEF(0x76, 0x000e),
3919 WRITE_COEF(0x6c, 0x2400),
3920 WRITE_COEF(0x18, 0x7308),
3921 WRITE_COEF(0x6b, 0xc429),
3922 {}
3923 };
3924 static struct coef_fw coef0293[] = {
3925 UPDATE_COEF(0x10, 7<<8, 6<<8), /* SET Line1 JD to 0 */
3926 UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
3927 UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */
3928 UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
3929 WRITE_COEF(0x45, 0xc429), /* Set to TRS type */
3930 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
3931 {}
3932 };
3933 static struct coef_fw coef0668[] = {
3934 WRITE_COEF(0x15, 0x0d40),
3935 WRITE_COEF(0xb7, 0x802b),
3936 {}
3937 };
4cc9b9d6 3938 static struct coef_fw coef0225[] = {
5a36767a 3939 UPDATE_COEF(0x63, 3<<14, 0),
4cc9b9d6
KY
3940 {}
3941 };
71683c32
KY
3942 static struct coef_fw coef0274[] = {
3943 UPDATE_COEF(0x4a, 0x0100, 0),
3944 UPDATE_COEFEX(0x57, 0x05, 0x4000, 0),
3945 UPDATE_COEF(0x6b, 0xf000, 0x5000),
3946 UPDATE_COEF(0x4a, 0x0010, 0),
3947 UPDATE_COEF(0x4a, 0x0c00, 0x0c00),
3948 WRITE_COEF(0x45, 0x5289),
3949 UPDATE_COEF(0x4a, 0x0c00, 0),
3950 {}
3951 };
54db6c39 3952
7639a06c 3953 switch (codec->core.vendor_id) {
9a22a8f5 3954 case 0x10ec0255:
e69e7e03
KY
3955 alc_process_coef_fw(codec, coef0255_1);
3956 alc_process_coef_fw(codec, coef0255);
3957 break;
736f20a7 3958 case 0x10ec0236:
7081adf3 3959 case 0x10ec0256:
e69e7e03 3960 alc_process_coef_fw(codec, coef0256);
54db6c39 3961 alc_process_coef_fw(codec, coef0255);
9a22a8f5 3962 break;
71683c32
KY
3963 case 0x10ec0234:
3964 case 0x10ec0274:
3965 case 0x10ec0294:
3966 alc_process_coef_fw(codec, coef0274);
3967 break;
13fd08a3 3968 case 0x10ec0233:
73bdd597 3969 case 0x10ec0283:
54db6c39 3970 alc_process_coef_fw(codec, coef0233);
73bdd597 3971 break;
f3b70332
KY
3972 case 0x10ec0286:
3973 case 0x10ec0288:
89542936
KY
3974 alc_process_coef_fw(codec, coef0288);
3975 break;
1a5bc8d9 3976 case 0x10ec0298:
89542936 3977 alc_process_coef_fw(codec, coef0298);
f3b70332
KY
3978 alc_process_coef_fw(codec, coef0288);
3979 break;
73bdd597 3980 case 0x10ec0292:
54db6c39 3981 alc_process_coef_fw(codec, coef0292);
73bdd597 3982 break;
a22aa26f 3983 case 0x10ec0293:
54db6c39 3984 alc_process_coef_fw(codec, coef0293);
a22aa26f 3985 break;
73bdd597 3986 case 0x10ec0668:
54db6c39 3987 alc_process_coef_fw(codec, coef0668);
73bdd597 3988 break;
4cc9b9d6 3989 case 0x10ec0225:
7d727869 3990 case 0x10ec0295:
28f1f9b2 3991 case 0x10ec0299:
4cc9b9d6
KY
3992 alc_process_coef_fw(codec, coef0225);
3993 break;
78f4f7c2
KY
3994 case 0x10ec0867:
3995 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
3996 break;
73bdd597 3997 }
4e76a883 3998 codec_dbg(codec, "Headset jack set to unplugged mode.\n");
73bdd597
DH
3999}
4000
4001
4002static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
4003 hda_nid_t mic_pin)
4004{
54db6c39
TI
4005 static struct coef_fw coef0255[] = {
4006 WRITE_COEFEX(0x57, 0x03, 0x8aa6),
4007 WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
4008 {}
4009 };
4010 static struct coef_fw coef0233[] = {
4011 UPDATE_COEF(0x35, 0, 1<<14),
4012 WRITE_COEF(0x06, 0x2100),
4013 WRITE_COEF(0x1a, 0x0021),
4014 WRITE_COEF(0x26, 0x008c),
4015 {}
4016 };
f3b70332 4017 static struct coef_fw coef0288[] = {
89542936 4018 UPDATE_COEF(0x4f, 0x00c0, 0),
f3b70332
KY
4019 UPDATE_COEF(0x50, 0x2000, 0),
4020 UPDATE_COEF(0x56, 0x0006, 0),
4021 UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4022 UPDATE_COEF(0x66, 0x0008, 0x0008),
4023 UPDATE_COEF(0x67, 0x2000, 0x2000),
4024 {}
4025 };
54db6c39
TI
4026 static struct coef_fw coef0292[] = {
4027 WRITE_COEF(0x19, 0xa208),
4028 WRITE_COEF(0x2e, 0xacf0),
4029 {}
4030 };
4031 static struct coef_fw coef0293[] = {
4032 UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
4033 UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */
4034 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
4035 {}
4036 };
4037 static struct coef_fw coef0688[] = {
4038 WRITE_COEF(0xb7, 0x802b),
4039 WRITE_COEF(0xb5, 0x1040),
4040 UPDATE_COEF(0xc3, 0, 1<<12),
4041 {}
4042 };
4cc9b9d6
KY
4043 static struct coef_fw coef0225[] = {
4044 UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14),
4045 UPDATE_COEF(0x4a, 3<<4, 2<<4),
4046 UPDATE_COEF(0x63, 3<<14, 0),
4047 {}
4048 };
71683c32
KY
4049 static struct coef_fw coef0274[] = {
4050 UPDATE_COEFEX(0x57, 0x05, 0x4000, 0x4000),
4051 UPDATE_COEF(0x4a, 0x0010, 0),
4052 UPDATE_COEF(0x6b, 0xf000, 0),
4053 {}
4054 };
54db6c39 4055
7639a06c 4056 switch (codec->core.vendor_id) {
736f20a7 4057 case 0x10ec0236:
9a22a8f5 4058 case 0x10ec0255:
7081adf3 4059 case 0x10ec0256:
9a22a8f5
KY
4060 alc_write_coef_idx(codec, 0x45, 0xc489);
4061 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4062 alc_process_coef_fw(codec, coef0255);
9a22a8f5
KY
4063 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4064 break;
71683c32
KY
4065 case 0x10ec0234:
4066 case 0x10ec0274:
4067 case 0x10ec0294:
4068 alc_write_coef_idx(codec, 0x45, 0x4689);
4069 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4070 alc_process_coef_fw(codec, coef0274);
4071 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4072 break;
13fd08a3 4073 case 0x10ec0233:
73bdd597
DH
4074 case 0x10ec0283:
4075 alc_write_coef_idx(codec, 0x45, 0xc429);
4076 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4077 alc_process_coef_fw(codec, coef0233);
73bdd597
DH
4078 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4079 break;
f3b70332
KY
4080 case 0x10ec0286:
4081 case 0x10ec0288:
1a5bc8d9 4082 case 0x10ec0298:
f3b70332
KY
4083 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4084 alc_process_coef_fw(codec, coef0288);
4085 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4086 break;
73bdd597
DH
4087 case 0x10ec0292:
4088 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4089 alc_process_coef_fw(codec, coef0292);
73bdd597 4090 break;
a22aa26f
KY
4091 case 0x10ec0293:
4092 /* Set to TRS mode */
4093 alc_write_coef_idx(codec, 0x45, 0xc429);
4094 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4095 alc_process_coef_fw(codec, coef0293);
a22aa26f
KY
4096 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4097 break;
78f4f7c2
KY
4098 case 0x10ec0867:
4099 alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14);
4100 /* fallthru */
9eb5d0e6 4101 case 0x10ec0221:
1f8b46cd
DH
4102 case 0x10ec0662:
4103 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4104 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4105 break;
73bdd597
DH
4106 case 0x10ec0668:
4107 alc_write_coef_idx(codec, 0x11, 0x0001);
4108 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
54db6c39 4109 alc_process_coef_fw(codec, coef0688);
73bdd597
DH
4110 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4111 break;
4cc9b9d6 4112 case 0x10ec0225:
7d727869 4113 case 0x10ec0295:
28f1f9b2 4114 case 0x10ec0299:
5a36767a 4115 alc_process_coef_fw(codec, alc225_pre_hsmode);
4cc9b9d6
KY
4116 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
4117 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4118 alc_process_coef_fw(codec, coef0225);
4119 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4120 break;
73bdd597 4121 }
4e76a883 4122 codec_dbg(codec, "Headset jack set to mic-in mode.\n");
73bdd597
DH
4123}
4124
4125static void alc_headset_mode_default(struct hda_codec *codec)
4126{
2ae95577 4127 static struct coef_fw coef0225[] = {
5a36767a
KY
4128 UPDATE_COEF(0x45, 0x3f<<10, 0x30<<10),
4129 UPDATE_COEF(0x45, 0x3f<<10, 0x31<<10),
4130 UPDATE_COEF(0x49, 3<<8, 0<<8),
4131 UPDATE_COEF(0x4a, 3<<4, 3<<4),
4132 UPDATE_COEF(0x63, 3<<14, 0),
4133 UPDATE_COEF(0x67, 0xf000, 0x3000),
2ae95577
DH
4134 {}
4135 };
54db6c39
TI
4136 static struct coef_fw coef0255[] = {
4137 WRITE_COEF(0x45, 0xc089),
4138 WRITE_COEF(0x45, 0xc489),
4139 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4140 WRITE_COEF(0x49, 0x0049),
4141 {}
4142 };
4143 static struct coef_fw coef0233[] = {
4144 WRITE_COEF(0x06, 0x2100),
4145 WRITE_COEF(0x32, 0x4ea3),
4146 {}
4147 };
f3b70332
KY
4148 static struct coef_fw coef0288[] = {
4149 UPDATE_COEF(0x4f, 0xfcc0, 0xc400), /* Set to TRS type */
4150 UPDATE_COEF(0x50, 0x2000, 0x2000),
4151 UPDATE_COEF(0x56, 0x0006, 0x0006),
4152 UPDATE_COEF(0x66, 0x0008, 0),
4153 UPDATE_COEF(0x67, 0x2000, 0),
4154 {}
4155 };
54db6c39
TI
4156 static struct coef_fw coef0292[] = {
4157 WRITE_COEF(0x76, 0x000e),
4158 WRITE_COEF(0x6c, 0x2400),
4159 WRITE_COEF(0x6b, 0xc429),
4160 WRITE_COEF(0x18, 0x7308),
4161 {}
4162 };
4163 static struct coef_fw coef0293[] = {
4164 UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4165 WRITE_COEF(0x45, 0xC429), /* Set to TRS type */
4166 UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
4167 {}
4168 };
4169 static struct coef_fw coef0688[] = {
4170 WRITE_COEF(0x11, 0x0041),
4171 WRITE_COEF(0x15, 0x0d40),
4172 WRITE_COEF(0xb7, 0x802b),
4173 {}
4174 };
71683c32
KY
4175 static struct coef_fw coef0274[] = {
4176 WRITE_COEF(0x45, 0x4289),
4177 UPDATE_COEF(0x4a, 0x0010, 0x0010),
4178 UPDATE_COEF(0x6b, 0x0f00, 0),
4179 UPDATE_COEF(0x49, 0x0300, 0x0300),
4180 {}
4181 };
54db6c39 4182
7639a06c 4183 switch (codec->core.vendor_id) {
2ae95577 4184 case 0x10ec0225:
7d727869 4185 case 0x10ec0295:
28f1f9b2 4186 case 0x10ec0299:
5a36767a 4187 alc_process_coef_fw(codec, alc225_pre_hsmode);
2ae95577
DH
4188 alc_process_coef_fw(codec, coef0225);
4189 break;
736f20a7 4190 case 0x10ec0236:
9a22a8f5 4191 case 0x10ec0255:
7081adf3 4192 case 0x10ec0256:
54db6c39 4193 alc_process_coef_fw(codec, coef0255);
9a22a8f5 4194 break;
71683c32
KY
4195 case 0x10ec0234:
4196 case 0x10ec0274:
4197 case 0x10ec0294:
4198 alc_process_coef_fw(codec, coef0274);
4199 break;
13fd08a3 4200 case 0x10ec0233:
73bdd597 4201 case 0x10ec0283:
54db6c39 4202 alc_process_coef_fw(codec, coef0233);
73bdd597 4203 break;
f3b70332
KY
4204 case 0x10ec0286:
4205 case 0x10ec0288:
1a5bc8d9 4206 case 0x10ec0298:
f3b70332
KY
4207 alc_process_coef_fw(codec, coef0288);
4208 break;
73bdd597 4209 case 0x10ec0292:
54db6c39 4210 alc_process_coef_fw(codec, coef0292);
73bdd597 4211 break;
a22aa26f 4212 case 0x10ec0293:
54db6c39 4213 alc_process_coef_fw(codec, coef0293);
a22aa26f 4214 break;
73bdd597 4215 case 0x10ec0668:
54db6c39 4216 alc_process_coef_fw(codec, coef0688);
73bdd597 4217 break;
78f4f7c2
KY
4218 case 0x10ec0867:
4219 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4220 break;
73bdd597 4221 }
4e76a883 4222 codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
73bdd597
DH
4223}
4224
4225/* Iphone type */
4226static void alc_headset_mode_ctia(struct hda_codec *codec)
4227{
89542936
KY
4228 int val;
4229
54db6c39
TI
4230 static struct coef_fw coef0255[] = {
4231 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
4232 WRITE_COEF(0x1b, 0x0c2b),
4233 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4234 {}
4235 };
e69e7e03
KY
4236 static struct coef_fw coef0256[] = {
4237 WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
4238 WRITE_COEF(0x1b, 0x0c6b),
4239 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4240 {}
4241 };
54db6c39
TI
4242 static struct coef_fw coef0233[] = {
4243 WRITE_COEF(0x45, 0xd429),
4244 WRITE_COEF(0x1b, 0x0c2b),
4245 WRITE_COEF(0x32, 0x4ea3),
4246 {}
4247 };
f3b70332
KY
4248 static struct coef_fw coef0288[] = {
4249 UPDATE_COEF(0x50, 0x2000, 0x2000),
4250 UPDATE_COEF(0x56, 0x0006, 0x0006),
4251 UPDATE_COEF(0x66, 0x0008, 0),
4252 UPDATE_COEF(0x67, 0x2000, 0),
4253 {}
4254 };
54db6c39
TI
4255 static struct coef_fw coef0292[] = {
4256 WRITE_COEF(0x6b, 0xd429),
4257 WRITE_COEF(0x76, 0x0008),
4258 WRITE_COEF(0x18, 0x7388),
4259 {}
4260 };
4261 static struct coef_fw coef0293[] = {
4262 WRITE_COEF(0x45, 0xd429), /* Set to ctia type */
4263 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
4264 {}
4265 };
4266 static struct coef_fw coef0688[] = {
4267 WRITE_COEF(0x11, 0x0001),
4268 WRITE_COEF(0x15, 0x0d60),
4269 WRITE_COEF(0xc3, 0x0000),
4270 {}
4271 };
5a36767a 4272 static struct coef_fw coef0225_1[] = {
4cc9b9d6 4273 UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
5a36767a
KY
4274 UPDATE_COEF(0x63, 3<<14, 2<<14),
4275 {}
4276 };
4277 static struct coef_fw coef0225_2[] = {
4278 UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
4279 UPDATE_COEF(0x63, 3<<14, 1<<14),
4cc9b9d6
KY
4280 {}
4281 };
54db6c39 4282
7639a06c 4283 switch (codec->core.vendor_id) {
9a22a8f5 4284 case 0x10ec0255:
54db6c39 4285 alc_process_coef_fw(codec, coef0255);
9a22a8f5 4286 break;
736f20a7 4287 case 0x10ec0236:
e69e7e03
KY
4288 case 0x10ec0256:
4289 alc_process_coef_fw(codec, coef0256);
4290 break;
71683c32
KY
4291 case 0x10ec0234:
4292 case 0x10ec0274:
4293 case 0x10ec0294:
4294 alc_write_coef_idx(codec, 0x45, 0xd689);
4295 break;
13fd08a3 4296 case 0x10ec0233:
73bdd597 4297 case 0x10ec0283:
54db6c39 4298 alc_process_coef_fw(codec, coef0233);
73bdd597 4299 break;
1a5bc8d9 4300 case 0x10ec0298:
89542936
KY
4301 val = alc_read_coef_idx(codec, 0x50);
4302 if (val & (1 << 12)) {
4303 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
4304 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4305 msleep(300);
4306 } else {
4307 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
4308 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4309 msleep(300);
4310 }
4311 break;
f3b70332
KY
4312 case 0x10ec0286:
4313 case 0x10ec0288:
4314 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
4315 msleep(300);
4316 alc_process_coef_fw(codec, coef0288);
4317 break;
73bdd597 4318 case 0x10ec0292:
54db6c39 4319 alc_process_coef_fw(codec, coef0292);
73bdd597 4320 break;
a22aa26f 4321 case 0x10ec0293:
54db6c39 4322 alc_process_coef_fw(codec, coef0293);
a22aa26f 4323 break;
73bdd597 4324 case 0x10ec0668:
54db6c39 4325 alc_process_coef_fw(codec, coef0688);
73bdd597 4326 break;
4cc9b9d6 4327 case 0x10ec0225:
7d727869 4328 case 0x10ec0295:
28f1f9b2 4329 case 0x10ec0299:
5a36767a
KY
4330 val = alc_read_coef_idx(codec, 0x45);
4331 if (val & (1 << 9))
4332 alc_process_coef_fw(codec, coef0225_2);
4333 else
4334 alc_process_coef_fw(codec, coef0225_1);
4cc9b9d6 4335 break;
78f4f7c2
KY
4336 case 0x10ec0867:
4337 alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4338 break;
73bdd597 4339 }
4e76a883 4340 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
73bdd597
DH
4341}
4342
4343/* Nokia type */
4344static void alc_headset_mode_omtp(struct hda_codec *codec)
4345{
54db6c39
TI
4346 static struct coef_fw coef0255[] = {
4347 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
4348 WRITE_COEF(0x1b, 0x0c2b),
4349 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4350 {}
4351 };
e69e7e03
KY
4352 static struct coef_fw coef0256[] = {
4353 WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
4354 WRITE_COEF(0x1b, 0x0c6b),
4355 WRITE_COEFEX(0x57, 0x03, 0x8ea6),
4356 {}
4357 };
54db6c39
TI
4358 static struct coef_fw coef0233[] = {
4359 WRITE_COEF(0x45, 0xe429),
4360 WRITE_COEF(0x1b, 0x0c2b),
4361 WRITE_COEF(0x32, 0x4ea3),
4362 {}
4363 };
f3b70332
KY
4364 static struct coef_fw coef0288[] = {
4365 UPDATE_COEF(0x50, 0x2000, 0x2000),
4366 UPDATE_COEF(0x56, 0x0006, 0x0006),
4367 UPDATE_COEF(0x66, 0x0008, 0),
4368 UPDATE_COEF(0x67, 0x2000, 0),
4369 {}
4370 };
54db6c39
TI
4371 static struct coef_fw coef0292[] = {
4372 WRITE_COEF(0x6b, 0xe429),
4373 WRITE_COEF(0x76, 0x0008),
4374 WRITE_COEF(0x18, 0x7388),
4375 {}
4376 };
4377 static struct coef_fw coef0293[] = {
4378 WRITE_COEF(0x45, 0xe429), /* Set to omtp type */
4379 UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
4380 {}
4381 };
4382 static struct coef_fw coef0688[] = {
4383 WRITE_COEF(0x11, 0x0001),
4384 WRITE_COEF(0x15, 0x0d50),
4385 WRITE_COEF(0xc3, 0x0000),
4386 {}
4387 };
4cc9b9d6
KY
4388 static struct coef_fw coef0225[] = {
4389 UPDATE_COEF(0x45, 0x3f<<10, 0x39<<10),
5a36767a 4390 UPDATE_COEF(0x63, 3<<14, 2<<14),
4cc9b9d6
KY
4391 {}
4392 };
54db6c39 4393
7639a06c 4394 switch (codec->core.vendor_id) {
9a22a8f5 4395 case 0x10ec0255:
54db6c39 4396 alc_process_coef_fw(codec, coef0255);
9a22a8f5 4397 break;
736f20a7 4398 case 0x10ec0236:
e69e7e03
KY
4399 case 0x10ec0256:
4400 alc_process_coef_fw(codec, coef0256);
4401 break;
71683c32
KY
4402 case 0x10ec0234:
4403 case 0x10ec0274:
4404 case 0x10ec0294:
4405 alc_write_coef_idx(codec, 0x45, 0xe689);
4406 break;
13fd08a3 4407 case 0x10ec0233:
73bdd597 4408 case 0x10ec0283:
54db6c39 4409 alc_process_coef_fw(codec, coef0233);
73bdd597 4410 break;
1a5bc8d9
KY
4411 case 0x10ec0298:
4412 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */
89542936
KY
4413 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
4414 msleep(300);
4415 break;
f3b70332
KY
4416 case 0x10ec0286:
4417 case 0x10ec0288:
4418 alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
4419 msleep(300);
4420 alc_process_coef_fw(codec, coef0288);
4421 break;
73bdd597 4422 case 0x10ec0292:
54db6c39 4423 alc_process_coef_fw(codec, coef0292);
73bdd597 4424 break;
a22aa26f 4425 case 0x10ec0293:
54db6c39 4426 alc_process_coef_fw(codec, coef0293);
a22aa26f 4427 break;
73bdd597 4428 case 0x10ec0668:
54db6c39 4429 alc_process_coef_fw(codec, coef0688);
73bdd597 4430 break;
4cc9b9d6 4431 case 0x10ec0225:
7d727869 4432 case 0x10ec0295:
28f1f9b2 4433 case 0x10ec0299:
4cc9b9d6
KY
4434 alc_process_coef_fw(codec, coef0225);
4435 break;
73bdd597 4436 }
4e76a883 4437 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
73bdd597
DH
4438}
4439
4440static void alc_determine_headset_type(struct hda_codec *codec)
4441{
4442 int val;
4443 bool is_ctia = false;
4444 struct alc_spec *spec = codec->spec;
54db6c39
TI
4445 static struct coef_fw coef0255[] = {
4446 WRITE_COEF(0x45, 0xd089), /* combo jack auto switch control(Check type)*/
4447 WRITE_COEF(0x49, 0x0149), /* combo jack auto switch control(Vref
4448 conteol) */
4449 {}
4450 };
f3b70332
KY
4451 static struct coef_fw coef0288[] = {
4452 UPDATE_COEF(0x4f, 0xfcc0, 0xd400), /* Check Type */
4453 {}
4454 };
89542936
KY
4455 static struct coef_fw coef0298[] = {
4456 UPDATE_COEF(0x50, 0x2000, 0x2000),
4457 UPDATE_COEF(0x56, 0x0006, 0x0006),
4458 UPDATE_COEF(0x66, 0x0008, 0),
4459 UPDATE_COEF(0x67, 0x2000, 0),
4460 UPDATE_COEF(0x19, 0x1300, 0x1300),
4461 {}
4462 };
54db6c39
TI
4463 static struct coef_fw coef0293[] = {
4464 UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */
4465 WRITE_COEF(0x45, 0xD429), /* Set to ctia type */
4466 {}
4467 };
4468 static struct coef_fw coef0688[] = {
4469 WRITE_COEF(0x11, 0x0001),
4470 WRITE_COEF(0xb7, 0x802b),
4471 WRITE_COEF(0x15, 0x0d60),
4472 WRITE_COEF(0xc3, 0x0c00),
4473 {}
4474 };
71683c32
KY
4475 static struct coef_fw coef0274[] = {
4476 UPDATE_COEF(0x4a, 0x0010, 0),
4477 UPDATE_COEF(0x4a, 0x8000, 0),
4478 WRITE_COEF(0x45, 0xd289),
4479 UPDATE_COEF(0x49, 0x0300, 0x0300),
4480 {}
4481 };
73bdd597 4482
7639a06c 4483 switch (codec->core.vendor_id) {
736f20a7 4484 case 0x10ec0236:
9a22a8f5 4485 case 0x10ec0255:
7081adf3 4486 case 0x10ec0256:
54db6c39 4487 alc_process_coef_fw(codec, coef0255);
9a22a8f5
KY
4488 msleep(300);
4489 val = alc_read_coef_idx(codec, 0x46);
4490 is_ctia = (val & 0x0070) == 0x0070;
4491 break;
71683c32
KY
4492 case 0x10ec0234:
4493 case 0x10ec0274:
4494 case 0x10ec0294:
4495 alc_process_coef_fw(codec, coef0274);
4496 msleep(80);
4497 val = alc_read_coef_idx(codec, 0x46);
4498 is_ctia = (val & 0x00f0) == 0x00f0;
4499 break;
13fd08a3 4500 case 0x10ec0233:
73bdd597
DH
4501 case 0x10ec0283:
4502 alc_write_coef_idx(codec, 0x45, 0xd029);
4503 msleep(300);
4504 val = alc_read_coef_idx(codec, 0x46);
4505 is_ctia = (val & 0x0070) == 0x0070;
4506 break;
1a5bc8d9 4507 case 0x10ec0298:
89542936
KY
4508 snd_hda_codec_write(codec, 0x21, 0,
4509 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
4510 msleep(100);
4511 snd_hda_codec_write(codec, 0x21, 0,
4512 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
4513 msleep(200);
4514
4515 val = alc_read_coef_idx(codec, 0x50);
4516 if (val & (1 << 12)) {
4517 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
4518 alc_process_coef_fw(codec, coef0288);
4519 msleep(350);
4520 val = alc_read_coef_idx(codec, 0x50);
4521 is_ctia = (val & 0x0070) == 0x0070;
4522 } else {
4523 alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
4524 alc_process_coef_fw(codec, coef0288);
4525 msleep(350);
4526 val = alc_read_coef_idx(codec, 0x50);
4527 is_ctia = (val & 0x0070) == 0x0070;
4528 }
4529 alc_process_coef_fw(codec, coef0298);
4530 snd_hda_codec_write(codec, 0x21, 0,
4531 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4532 msleep(75);
4533 snd_hda_codec_write(codec, 0x21, 0,
4534 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4535 break;
f3b70332
KY
4536 case 0x10ec0286:
4537 case 0x10ec0288:
4538 alc_process_coef_fw(codec, coef0288);
4539 msleep(350);
4540 val = alc_read_coef_idx(codec, 0x50);
4541 is_ctia = (val & 0x0070) == 0x0070;
4542 break;
73bdd597
DH
4543 case 0x10ec0292:
4544 alc_write_coef_idx(codec, 0x6b, 0xd429);
4545 msleep(300);
4546 val = alc_read_coef_idx(codec, 0x6c);
4547 is_ctia = (val & 0x001c) == 0x001c;
4548 break;
a22aa26f 4549 case 0x10ec0293:
54db6c39 4550 alc_process_coef_fw(codec, coef0293);
a22aa26f
KY
4551 msleep(300);
4552 val = alc_read_coef_idx(codec, 0x46);
4553 is_ctia = (val & 0x0070) == 0x0070;
4554 break;
73bdd597 4555 case 0x10ec0668:
54db6c39 4556 alc_process_coef_fw(codec, coef0688);
73bdd597
DH
4557 msleep(300);
4558 val = alc_read_coef_idx(codec, 0xbe);
4559 is_ctia = (val & 0x1c02) == 0x1c02;
4560 break;
4cc9b9d6 4561 case 0x10ec0225:
7d727869 4562 case 0x10ec0295:
28f1f9b2 4563 case 0x10ec0299:
5a36767a
KY
4564 alc_process_coef_fw(codec, alc225_pre_hsmode);
4565 alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000);
4566 val = alc_read_coef_idx(codec, 0x45);
4567 if (val & (1 << 9)) {
4568 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
4569 alc_update_coef_idx(codec, 0x49, 3<<8, 2<<8);
4570 msleep(800);
4571 val = alc_read_coef_idx(codec, 0x46);
4572 is_ctia = (val & 0x00f0) == 0x00f0;
4573 } else {
4574 alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
4575 alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8);
4576 msleep(800);
4577 val = alc_read_coef_idx(codec, 0x46);
4578 is_ctia = (val & 0x00f0) == 0x00f0;
4579 }
4580 alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6);
4581 alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4);
4582 alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
4cc9b9d6 4583 break;
78f4f7c2
KY
4584 case 0x10ec0867:
4585 is_ctia = true;
4586 break;
73bdd597
DH
4587 }
4588
4e76a883 4589 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
73bdd597
DH
4590 is_ctia ? "yes" : "no");
4591 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
4592}
4593
4594static void alc_update_headset_mode(struct hda_codec *codec)
4595{
4596 struct alc_spec *spec = codec->spec;
4597
4598 hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
4599 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
4600
4601 int new_headset_mode;
4602
4603 if (!snd_hda_jack_detect(codec, hp_pin))
4604 new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
4605 else if (mux_pin == spec->headset_mic_pin)
4606 new_headset_mode = ALC_HEADSET_MODE_HEADSET;
4607 else if (mux_pin == spec->headphone_mic_pin)
4608 new_headset_mode = ALC_HEADSET_MODE_MIC;
4609 else
4610 new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
4611
5959a6bc
DH
4612 if (new_headset_mode == spec->current_headset_mode) {
4613 snd_hda_gen_update_outputs(codec);
73bdd597 4614 return;
5959a6bc 4615 }
73bdd597
DH
4616
4617 switch (new_headset_mode) {
4618 case ALC_HEADSET_MODE_UNPLUGGED:
4619 alc_headset_mode_unplugged(codec);
4620 spec->gen.hp_jack_present = false;
4621 break;
4622 case ALC_HEADSET_MODE_HEADSET:
4623 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
4624 alc_determine_headset_type(codec);
4625 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
4626 alc_headset_mode_ctia(codec);
4627 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
4628 alc_headset_mode_omtp(codec);
4629 spec->gen.hp_jack_present = true;
4630 break;
4631 case ALC_HEADSET_MODE_MIC:
4632 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
4633 spec->gen.hp_jack_present = false;
4634 break;
4635 case ALC_HEADSET_MODE_HEADPHONE:
4636 alc_headset_mode_default(codec);
4637 spec->gen.hp_jack_present = true;
4638 break;
4639 }
4640 if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
4641 snd_hda_set_pin_ctl_cache(codec, hp_pin,
4642 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
1f8b46cd 4643 if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
73bdd597
DH
4644 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
4645 PIN_VREFHIZ);
4646 }
4647 spec->current_headset_mode = new_headset_mode;
4648
4649 snd_hda_gen_update_outputs(codec);
4650}
4651
4652static void alc_update_headset_mode_hook(struct hda_codec *codec,
7fe30711
TI
4653 struct snd_kcontrol *kcontrol,
4654 struct snd_ctl_elem_value *ucontrol)
73bdd597
DH
4655{
4656 alc_update_headset_mode(codec);
4657}
4658
1a4f69d5
TI
4659static void alc_update_headset_jack_cb(struct hda_codec *codec,
4660 struct hda_jack_callback *jack)
73bdd597
DH
4661{
4662 struct alc_spec *spec = codec->spec;
5db4d34b 4663 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
73bdd597
DH
4664 snd_hda_gen_hp_automute(codec, jack);
4665}
4666
4667static void alc_probe_headset_mode(struct hda_codec *codec)
4668{
4669 int i;
4670 struct alc_spec *spec = codec->spec;
4671 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4672
4673 /* Find mic pins */
4674 for (i = 0; i < cfg->num_inputs; i++) {
4675 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
4676 spec->headset_mic_pin = cfg->inputs[i].pin;
4677 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
4678 spec->headphone_mic_pin = cfg->inputs[i].pin;
4679 }
4680
4681 spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
4682 spec->gen.automute_hook = alc_update_headset_mode;
4683 spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
4684}
4685
4686static void alc_fixup_headset_mode(struct hda_codec *codec,
4687 const struct hda_fixup *fix, int action)
4688{
4689 struct alc_spec *spec = codec->spec;
4690
4691 switch (action) {
4692 case HDA_FIXUP_ACT_PRE_PROBE:
4693 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
4694 break;
4695 case HDA_FIXUP_ACT_PROBE:
4696 alc_probe_headset_mode(codec);
4697 break;
4698 case HDA_FIXUP_ACT_INIT:
4699 spec->current_headset_mode = 0;
4700 alc_update_headset_mode(codec);
4701 break;
4702 }
4703}
4704
4705static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
4706 const struct hda_fixup *fix, int action)
4707{
4708 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4709 struct alc_spec *spec = codec->spec;
4710 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4711 }
4712 else
4713 alc_fixup_headset_mode(codec, fix, action);
4714}
4715
31278997
KY
4716static void alc255_set_default_jack_type(struct hda_codec *codec)
4717{
4718 /* Set to iphone type */
e69e7e03 4719 static struct coef_fw alc255fw[] = {
54db6c39
TI
4720 WRITE_COEF(0x1b, 0x880b),
4721 WRITE_COEF(0x45, 0xd089),
4722 WRITE_COEF(0x1b, 0x080b),
4723 WRITE_COEF(0x46, 0x0004),
4724 WRITE_COEF(0x1b, 0x0c0b),
4725 {}
4726 };
e69e7e03
KY
4727 static struct coef_fw alc256fw[] = {
4728 WRITE_COEF(0x1b, 0x884b),
4729 WRITE_COEF(0x45, 0xd089),
4730 WRITE_COEF(0x1b, 0x084b),
4731 WRITE_COEF(0x46, 0x0004),
4732 WRITE_COEF(0x1b, 0x0c4b),
4733 {}
4734 };
4735 switch (codec->core.vendor_id) {
4736 case 0x10ec0255:
4737 alc_process_coef_fw(codec, alc255fw);
4738 break;
736f20a7 4739 case 0x10ec0236:
e69e7e03
KY
4740 case 0x10ec0256:
4741 alc_process_coef_fw(codec, alc256fw);
4742 break;
4743 }
31278997
KY
4744 msleep(30);
4745}
4746
9a22a8f5
KY
4747static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
4748 const struct hda_fixup *fix, int action)
4749{
4750 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
31278997 4751 alc255_set_default_jack_type(codec);
9a22a8f5
KY
4752 }
4753 alc_fixup_headset_mode(codec, fix, action);
4754}
4755
31278997
KY
4756static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
4757 const struct hda_fixup *fix, int action)
4758{
4759 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4760 struct alc_spec *spec = codec->spec;
4761 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4762 alc255_set_default_jack_type(codec);
4763 }
4764 else
4765 alc_fixup_headset_mode(codec, fix, action);
4766}
4767
e1e62b98
KY
4768static void alc288_update_headset_jack_cb(struct hda_codec *codec,
4769 struct hda_jack_callback *jack)
4770{
4771 struct alc_spec *spec = codec->spec;
4772 int present;
4773
4774 alc_update_headset_jack_cb(codec, jack);
4775 /* Headset Mic enable or disable, only for Dell Dino */
4776 present = spec->gen.hp_jack_present ? 0x40 : 0;
4777 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
4778 present);
4779}
4780
4781static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec,
4782 const struct hda_fixup *fix, int action)
4783{
4784 alc_fixup_headset_mode(codec, fix, action);
4785 if (action == HDA_FIXUP_ACT_PROBE) {
4786 struct alc_spec *spec = codec->spec;
4787 spec->gen.hp_automute_hook = alc288_update_headset_jack_cb;
4788 }
4789}
4790
493a52a9
HW
4791static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
4792 const struct hda_fixup *fix, int action)
4793{
4794 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4795 struct alc_spec *spec = codec->spec;
4796 spec->gen.auto_mute_via_amp = 1;
4797 }
4798}
4799
9b745ab8
TI
4800static void alc_no_shutup(struct hda_codec *codec)
4801{
4802}
4803
4804static void alc_fixup_no_shutup(struct hda_codec *codec,
4805 const struct hda_fixup *fix, int action)
4806{
972aa2c7 4807 if (action == HDA_FIXUP_ACT_PROBE) {
9b745ab8
TI
4808 struct alc_spec *spec = codec->spec;
4809 spec->shutup = alc_no_shutup;
4810 }
4811}
4812
5e6db669
GM
4813static void alc_fixup_disable_aamix(struct hda_codec *codec,
4814 const struct hda_fixup *fix, int action)
4815{
4816 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4817 struct alc_spec *spec = codec->spec;
4818 /* Disable AA-loopback as it causes white noise */
4819 spec->gen.mixer_nid = 0;
4820 }
4821}
4822
7f57d803
TI
4823/* fixup for Thinkpad docks: add dock pins, avoid HP parser fixup */
4824static void alc_fixup_tpt440_dock(struct hda_codec *codec,
4825 const struct hda_fixup *fix, int action)
4826{
4827 static const struct hda_pintbl pincfgs[] = {
4828 { 0x16, 0x21211010 }, /* dock headphone */
4829 { 0x19, 0x21a11010 }, /* dock mic */
4830 { }
4831 };
4832 struct alc_spec *spec = codec->spec;
4833
4834 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
157f0b7f 4835 spec->shutup = alc_no_shutup; /* reduce click noise */
70a0976b 4836 spec->reboot_notify = alc_d3_at_reboot; /* reduce noise */
7f57d803
TI
4837 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
4838 codec->power_save_node = 0; /* avoid click noises */
4839 snd_hda_apply_pincfgs(codec, pincfgs);
4840 }
4841}
4842
9476d369 4843static void alc_shutup_dell_xps13(struct hda_codec *codec)
033b0a7c
GM
4844{
4845 struct alc_spec *spec = codec->spec;
9476d369 4846 int hp_pin = spec->gen.autocfg.hp_pins[0];
033b0a7c 4847
9476d369
GM
4848 /* Prevent pop noises when headphones are plugged in */
4849 snd_hda_codec_write(codec, hp_pin, 0,
4850 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
4851 msleep(20);
033b0a7c
GM
4852}
4853
4854static void alc_fixup_dell_xps13(struct hda_codec *codec,
4855 const struct hda_fixup *fix, int action)
4856{
3e1b0c4a
TI
4857 struct alc_spec *spec = codec->spec;
4858 struct hda_input_mux *imux = &spec->gen.input_mux;
4859 int i;
f38663ab 4860
3e1b0c4a
TI
4861 switch (action) {
4862 case HDA_FIXUP_ACT_PRE_PROBE:
4863 /* mic pin 0x19 must be initialized with Vref Hi-Z, otherwise
4864 * it causes a click noise at start up
4865 */
4866 snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
4867 break;
4868 case HDA_FIXUP_ACT_PROBE:
9476d369 4869 spec->shutup = alc_shutup_dell_xps13;
f38663ab
GM
4870
4871 /* Make the internal mic the default input source. */
4872 for (i = 0; i < imux->num_items; i++) {
4873 if (spec->gen.imux_pins[i] == 0x12) {
4874 spec->gen.cur_mux[0] = i;
4875 break;
4876 }
4877 }
3e1b0c4a 4878 break;
033b0a7c
GM
4879 }
4880}
4881
1f8b46cd
DH
4882static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
4883 const struct hda_fixup *fix, int action)
4884{
4885 struct alc_spec *spec = codec->spec;
4886
4887 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4888 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4889 spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
b40eda64
DH
4890
4891 /* Disable boost for mic-in permanently. (This code is only called
4892 from quirks that guarantee that the headphone is at NID 0x1b.) */
4893 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
4894 snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
1f8b46cd
DH
4895 } else
4896 alc_fixup_headset_mode(codec, fix, action);
4897}
4898
73bdd597
DH
4899static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
4900 const struct hda_fixup *fix, int action)
4901{
4902 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
73bdd597 4903 alc_write_coef_idx(codec, 0xc4, 0x8000);
98b24883 4904 alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
73bdd597
DH
4905 snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
4906 }
4907 alc_fixup_headset_mode(codec, fix, action);
4908}
4909
bde7bc60
CCC
4910/* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
4911static int find_ext_mic_pin(struct hda_codec *codec)
4912{
4913 struct alc_spec *spec = codec->spec;
4914 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4915 hda_nid_t nid;
4916 unsigned int defcfg;
4917 int i;
4918
4919 for (i = 0; i < cfg->num_inputs; i++) {
4920 if (cfg->inputs[i].type != AUTO_PIN_MIC)
4921 continue;
4922 nid = cfg->inputs[i].pin;
4923 defcfg = snd_hda_codec_get_pincfg(codec, nid);
4924 if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
4925 continue;
4926 return nid;
4927 }
4928
4929 return 0;
4930}
4931
08a978db 4932static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
1727a771 4933 const struct hda_fixup *fix,
08a978db
DR
4934 int action)
4935{
4936 struct alc_spec *spec = codec->spec;
4937
0db75790 4938 if (action == HDA_FIXUP_ACT_PROBE) {
bde7bc60
CCC
4939 int mic_pin = find_ext_mic_pin(codec);
4940 int hp_pin = spec->gen.autocfg.hp_pins[0];
4941
4942 if (snd_BUG_ON(!mic_pin || !hp_pin))
0db75790 4943 return;
bde7bc60 4944 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
0db75790 4945 }
08a978db 4946}
693b613d 4947
3e0d611b
DH
4948static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
4949 const struct hda_fixup *fix,
4950 int action)
4951{
4952 struct alc_spec *spec = codec->spec;
4953 struct auto_pin_cfg *cfg = &spec->gen.autocfg;
4954 int i;
4955
4956 /* The mic boosts on level 2 and 3 are too noisy
4957 on the internal mic input.
4958 Therefore limit the boost to 0 or 1. */
4959
4960 if (action != HDA_FIXUP_ACT_PROBE)
4961 return;
4962
4963 for (i = 0; i < cfg->num_inputs; i++) {
4964 hda_nid_t nid = cfg->inputs[i].pin;
4965 unsigned int defcfg;
4966 if (cfg->inputs[i].type != AUTO_PIN_MIC)
4967 continue;
4968 defcfg = snd_hda_codec_get_pincfg(codec, nid);
4969 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
4970 continue;
4971
4972 snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
4973 (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
4974 (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4975 (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
4976 (0 << AC_AMPCAP_MUTE_SHIFT));
4977 }
4978}
4979
cd217a63 4980static void alc283_hp_automute_hook(struct hda_codec *codec,
1a4f69d5 4981 struct hda_jack_callback *jack)
cd217a63
KY
4982{
4983 struct alc_spec *spec = codec->spec;
4984 int vref;
4985
4986 msleep(200);
4987 snd_hda_gen_hp_automute(codec, jack);
4988
4989 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
4990
4991 msleep(600);
4992 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4993 vref);
4994}
4995
cd217a63
KY
4996static void alc283_fixup_chromebook(struct hda_codec *codec,
4997 const struct hda_fixup *fix, int action)
4998{
4999 struct alc_spec *spec = codec->spec;
cd217a63
KY
5000
5001 switch (action) {
5002 case HDA_FIXUP_ACT_PRE_PROBE:
0202e99c 5003 snd_hda_override_wcaps(codec, 0x03, 0);
d2e92709
TI
5004 /* Disable AA-loopback as it causes white noise */
5005 spec->gen.mixer_nid = 0;
38070219 5006 break;
0202e99c 5007 case HDA_FIXUP_ACT_INIT:
de9481cb
KY
5008 /* MIC2-VREF control */
5009 /* Set to manual mode */
98b24883 5010 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
0202e99c 5011 /* Enable Line1 input control by verb */
98b24883 5012 alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
0202e99c
KY
5013 break;
5014 }
5015}
5016
5017static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
5018 const struct hda_fixup *fix, int action)
5019{
5020 struct alc_spec *spec = codec->spec;
0202e99c
KY
5021
5022 switch (action) {
5023 case HDA_FIXUP_ACT_PRE_PROBE:
cd217a63 5024 spec->gen.hp_automute_hook = alc283_hp_automute_hook;
38070219
KY
5025 break;
5026 case HDA_FIXUP_ACT_INIT:
cd217a63
KY
5027 /* MIC2-VREF control */
5028 /* Set to manual mode */
98b24883 5029 alc_update_coef_idx(codec, 0x06, 0x000c, 0);
cd217a63
KY
5030 break;
5031 }
5032}
5033
7bba2157
TI
5034/* mute tablet speaker pin (0x14) via dock plugging in addition */
5035static void asus_tx300_automute(struct hda_codec *codec)
5036{
5037 struct alc_spec *spec = codec->spec;
5038 snd_hda_gen_update_outputs(codec);
5039 if (snd_hda_jack_detect(codec, 0x1b))
5040 spec->gen.mute_bits |= (1ULL << 0x14);
5041}
5042
5043static void alc282_fixup_asus_tx300(struct hda_codec *codec,
5044 const struct hda_fixup *fix, int action)
5045{
5046 struct alc_spec *spec = codec->spec;
5047 /* TX300 needs to set up GPIO2 for the speaker amp */
5048 static const struct hda_verb gpio2_verbs[] = {
5049 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
5050 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
5051 { 0x01, AC_VERB_SET_GPIO_DATA, 0x04 },
5052 {}
5053 };
5054 static const struct hda_pintbl dock_pins[] = {
5055 { 0x1b, 0x21114000 }, /* dock speaker pin */
5056 {}
5057 };
7bba2157
TI
5058
5059 switch (action) {
5060 case HDA_FIXUP_ACT_PRE_PROBE:
5061 snd_hda_add_verbs(codec, gpio2_verbs);
5062 snd_hda_apply_pincfgs(codec, dock_pins);
5063 spec->gen.auto_mute_via_amp = 1;
5064 spec->gen.automute_hook = asus_tx300_automute;
5065 snd_hda_jack_detect_enable_callback(codec, 0x1b,
7bba2157
TI
5066 snd_hda_gen_hp_automute);
5067 break;
5068 case HDA_FIXUP_ACT_BUILD:
5069 /* this is a bit tricky; give more sane names for the main
5070 * (tablet) speaker and the dock speaker, respectively
5071 */
56798e6b
TI
5072 rename_ctl(codec, "Speaker Playback Switch",
5073 "Dock Speaker Playback Switch");
5074 rename_ctl(codec, "Bass Speaker Playback Switch",
5075 "Speaker Playback Switch");
7bba2157
TI
5076 break;
5077 }
5078}
5079
338cae56
DH
5080static void alc290_fixup_mono_speakers(struct hda_codec *codec,
5081 const struct hda_fixup *fix, int action)
5082{
0f4881dc
DH
5083 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5084 /* DAC node 0x03 is giving mono output. We therefore want to
5085 make sure 0x14 (front speaker) and 0x15 (headphones) use the
5086 stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
5087 hda_nid_t conn1[2] = { 0x0c };
5088 snd_hda_override_conn_list(codec, 0x14, 1, conn1);
5089 snd_hda_override_conn_list(codec, 0x15, 1, conn1);
5090 }
338cae56
DH
5091}
5092
dd9aa335
HW
5093static void alc298_fixup_speaker_volume(struct hda_codec *codec,
5094 const struct hda_fixup *fix, int action)
5095{
5096 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5097 /* The speaker is routed to the Node 0x06 by a mistake, as a result
5098 we can't adjust the speaker's volume since this node does not has
5099 Amp-out capability. we change the speaker's route to:
5100 Node 0x02 (Audio Output) -> Node 0x0c (Audio Mixer) -> Node 0x17 (
5101 Pin Complex), since Node 0x02 has Amp-out caps, we can adjust
5102 speaker's volume now. */
5103
5104 hda_nid_t conn1[1] = { 0x0c };
5105 snd_hda_override_conn_list(codec, 0x17, 1, conn1);
5106 }
5107}
5108
98973f2f
KP
5109/* Hook to update amp GPIO4 for automute */
5110static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
5111 struct hda_jack_callback *jack)
5112{
5113 struct alc_spec *spec = codec->spec;
5114
5115 snd_hda_gen_hp_automute(codec, jack);
5116 /* mute_led_polarity is set to 0, so we pass inverted value here */
5117 alc_update_gpio_led(codec, 0x10, !spec->gen.hp_jack_present);
5118}
5119
5120/* Manage GPIOs for HP EliteBook Folio 9480m.
5121 *
5122 * GPIO4 is the headphone amplifier power control
5123 * GPIO3 is the audio output mute indicator LED
5124 */
5125
5126static void alc280_fixup_hp_9480m(struct hda_codec *codec,
5127 const struct hda_fixup *fix,
5128 int action)
5129{
5130 struct alc_spec *spec = codec->spec;
5131 static const struct hda_verb gpio_init[] = {
5132 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
5133 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
5134 {}
5135 };
5136
5137 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5138 /* Set the hooks to turn the headphone amp on/off
5139 * as needed
5140 */
5141 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
5142 spec->gen.hp_automute_hook = alc280_hp_gpio4_automute_hook;
5143
5144 /* The GPIOs are currently off */
5145 spec->gpio_led = 0;
5146
5147 /* GPIO3 is connected to the output mute LED,
5148 * high is on, low is off
5149 */
5150 spec->mute_led_polarity = 0;
5151 spec->gpio_mute_led_mask = 0x08;
5152
5153 /* Initialize GPIO configuration */
5154 snd_hda_add_verbs(codec, gpio_init);
5155 }
5156}
5157
ca169cc2
KY
5158static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
5159 const struct hda_fixup *fix,
5160 int action)
5161{
5162 alc_fixup_dual_codecs(codec, fix, action);
5163 switch (action) {
5164 case HDA_FIXUP_ACT_PRE_PROBE:
5165 /* override card longname to provide a unique UCM profile */
5166 strcpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
5167 break;
5168 case HDA_FIXUP_ACT_BUILD:
5169 /* rename Capture controls depending on the codec */
5170 rename_ctl(codec, "Capture Volume",
5171 codec->addr == 0 ?
5172 "Rear-Panel Capture Volume" :
5173 "Front-Panel Capture Volume");
5174 rename_ctl(codec, "Capture Switch",
5175 codec->addr == 0 ?
5176 "Rear-Panel Capture Switch" :
5177 "Front-Panel Capture Switch");
5178 break;
5179 }
5180}
5181
b317b032
TI
5182/* for hda_fixup_thinkpad_acpi() */
5183#include "thinkpad_helper.c"
b67ae3f1 5184
00ef9940
HW
5185/* for dell wmi mic mute led */
5186#include "dell_wmi_helper.c"
5187
1d045db9
TI
5188enum {
5189 ALC269_FIXUP_SONY_VAIO,
5190 ALC275_FIXUP_SONY_VAIO_GPIO2,
5191 ALC269_FIXUP_DELL_M101Z,
5192 ALC269_FIXUP_SKU_IGNORE,
5193 ALC269_FIXUP_ASUS_G73JW,
5194 ALC269_FIXUP_LENOVO_EAPD,
5195 ALC275_FIXUP_SONY_HWEQ,
e9bd7d5c 5196 ALC275_FIXUP_SONY_DISABLE_AAMIX,
1d045db9 5197 ALC271_FIXUP_DMIC,
017f2a10 5198 ALC269_FIXUP_PCM_44K,
adabb3ec 5199 ALC269_FIXUP_STEREO_DMIC,
7c478f03 5200 ALC269_FIXUP_HEADSET_MIC,
24519911
TI
5201 ALC269_FIXUP_QUANTA_MUTE,
5202 ALC269_FIXUP_LIFEBOOK,
2041d564 5203 ALC269_FIXUP_LIFEBOOK_EXTMIC,
cc7016ab 5204 ALC269_FIXUP_LIFEBOOK_HP_PIN,
4df3fd17 5205 ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT,
a4297b5d
TI
5206 ALC269_FIXUP_AMIC,
5207 ALC269_FIXUP_DMIC,
5208 ALC269VB_FIXUP_AMIC,
5209 ALC269VB_FIXUP_DMIC,
08fb0d0e 5210 ALC269_FIXUP_HP_MUTE_LED,
d06ac143 5211 ALC269_FIXUP_HP_MUTE_LED_MIC1,
08fb0d0e 5212 ALC269_FIXUP_HP_MUTE_LED_MIC2,
9f5c6faf 5213 ALC269_FIXUP_HP_GPIO_LED,
9c5dc3bf
KY
5214 ALC269_FIXUP_HP_GPIO_MIC1_LED,
5215 ALC269_FIXUP_HP_LINE1_MIC1_LED,
693b613d 5216 ALC269_FIXUP_INV_DMIC,
108cc108 5217 ALC269_FIXUP_LENOVO_DOCK,
9b745ab8 5218 ALC269_FIXUP_NO_SHUTUP,
88cfcf86 5219 ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
108cc108 5220 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
73bdd597
DH
5221 ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
5222 ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
338cae56 5223 ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
fcc6c877 5224 ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
73bdd597
DH
5225 ALC269_FIXUP_HEADSET_MODE,
5226 ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
7819717b 5227 ALC269_FIXUP_ASPIRE_HEADSET_MIC,
d240d1dc
DH
5228 ALC269_FIXUP_ASUS_X101_FUNC,
5229 ALC269_FIXUP_ASUS_X101_VERB,
5230 ALC269_FIXUP_ASUS_X101,
08a978db
DR
5231 ALC271_FIXUP_AMIC_MIC2,
5232 ALC271_FIXUP_HP_GATE_MIC_JACK,
b1e8972e 5233 ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
42397004 5234 ALC269_FIXUP_ACER_AC700,
3e0d611b 5235 ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
2cede303 5236 ALC269VB_FIXUP_ASUS_ZENBOOK,
23870831 5237 ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
8e35cd4a 5238 ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
02b504d9 5239 ALC269VB_FIXUP_ORDISSIMO_EVE2,
cd217a63 5240 ALC283_FIXUP_CHROME_BOOK,
0202e99c 5241 ALC283_FIXUP_SENSE_COMBO_JACK,
7bba2157 5242 ALC282_FIXUP_ASUS_TX300,
1bb3e062 5243 ALC283_FIXUP_INT_MIC,
338cae56 5244 ALC290_FIXUP_MONO_SPEAKERS,
0f4881dc
DH
5245 ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
5246 ALC290_FIXUP_SUBWOOFER,
5247 ALC290_FIXUP_SUBWOOFER_HSJACK,
b67ae3f1 5248 ALC269_FIXUP_THINKPAD_ACPI,
56f27013 5249 ALC269_FIXUP_DMIC_THINKPAD_ACPI,
5824ce8d 5250 ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
615966ad 5251 ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
9a22a8f5 5252 ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
31278997 5253 ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
9a22a8f5 5254 ALC255_FIXUP_HEADSET_MODE,
31278997 5255 ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
a22aa26f 5256 ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
1c37c223 5257 ALC292_FIXUP_TPT440_DOCK,
9a811230 5258 ALC292_FIXUP_TPT440,
abaa2274 5259 ALC283_FIXUP_HEADSET_MIC,
00ef9940 5260 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED,
1a22e775 5261 ALC282_FIXUP_ASPIRE_V5_PINS,
7a5255f1 5262 ALC280_FIXUP_HP_GPIO4,
eaa8e5ef 5263 ALC286_FIXUP_HP_GPIO_LED,
33f4acd3 5264 ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY,
b4b33f9d 5265 ALC280_FIXUP_HP_DOCK_PINS,
04d5466a 5266 ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED,
98973f2f 5267 ALC280_FIXUP_HP_9480M,
e1e62b98
KY
5268 ALC288_FIXUP_DELL_HEADSET_MODE,
5269 ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
5270 ALC288_FIXUP_DELL_XPS_13_GPIO6,
831bfdf9
HW
5271 ALC288_FIXUP_DELL_XPS_13,
5272 ALC288_FIXUP_DISABLE_AAMIX,
8b99aba7
TI
5273 ALC292_FIXUP_DELL_E7X,
5274 ALC292_FIXUP_DISABLE_AAMIX,
c04017ea 5275 ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK,
977e6276 5276 ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
2f726aec 5277 ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
6ed1131f 5278 ALC275_FIXUP_DELL_XPS,
8c69729b 5279 ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE,
23adc192 5280 ALC293_FIXUP_LENOVO_SPK_NOISE,
3694cb29 5281 ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
3b43b71f 5282 ALC255_FIXUP_DELL_SPK_NOISE,
2ae95577 5283 ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
f883982d 5284 ALC280_FIXUP_HP_HEADSET_MIC,
e549d190 5285 ALC221_FIXUP_HP_FRONT_MIC,
c636b95e 5286 ALC292_FIXUP_TPT460,
dd9aa335 5287 ALC298_FIXUP_SPK_VOLUME,
fd06c77e 5288 ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
823ff161 5289 ALC269_FIXUP_ATIV_BOOK_8,
9eb5d0e6 5290 ALC221_FIXUP_HP_MIC_NO_PRESENCE,
c1732ede
CC
5291 ALC256_FIXUP_ASUS_HEADSET_MODE,
5292 ALC256_FIXUP_ASUS_MIC,
eeed4cd1 5293 ALC256_FIXUP_ASUS_AIO_GPIO2,
216d7aeb
CC
5294 ALC233_FIXUP_ASUS_MIC_NO_PRESENCE,
5295 ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
ca169cc2 5296 ALC233_FIXUP_LENOVO_MULTI_CODECS,
f33f79f3 5297 ALC294_FIXUP_LENOVO_MIC_LOCATION,
b84e8436 5298 ALC700_FIXUP_INTEL_REFERENCE,
f1d4e28b
KY
5299};
5300
1727a771 5301static const struct hda_fixup alc269_fixups[] = {
1d045db9 5302 [ALC269_FIXUP_SONY_VAIO] = {
fd108215
TI
5303 .type = HDA_FIXUP_PINCTLS,
5304 .v.pins = (const struct hda_pintbl[]) {
5305 {0x19, PIN_VREFGRD},
1d045db9
TI
5306 {}
5307 }
f1d4e28b 5308 },
1d045db9 5309 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
1727a771 5310 .type = HDA_FIXUP_VERBS,
1d045db9
TI
5311 .v.verbs = (const struct hda_verb[]) {
5312 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
5313 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
5314 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5315 { }
5316 },
5317 .chained = true,
5318 .chain_id = ALC269_FIXUP_SONY_VAIO
5319 },
5320 [ALC269_FIXUP_DELL_M101Z] = {
1727a771 5321 .type = HDA_FIXUP_VERBS,
1d045db9
TI
5322 .v.verbs = (const struct hda_verb[]) {
5323 /* Enables internal speaker */
5324 {0x20, AC_VERB_SET_COEF_INDEX, 13},
5325 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
5326 {}
5327 }
5328 },
5329 [ALC269_FIXUP_SKU_IGNORE] = {
1727a771 5330 .type = HDA_FIXUP_FUNC,
23d30f28 5331 .v.func = alc_fixup_sku_ignore,
1d045db9
TI
5332 },
5333 [ALC269_FIXUP_ASUS_G73JW] = {
1727a771
TI
5334 .type = HDA_FIXUP_PINS,
5335 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
5336 { 0x17, 0x99130111 }, /* subwoofer */
5337 { }
5338 }
5339 },
5340 [ALC269_FIXUP_LENOVO_EAPD] = {
1727a771 5341 .type = HDA_FIXUP_VERBS,
1d045db9
TI
5342 .v.verbs = (const struct hda_verb[]) {
5343 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
5344 {}
5345 }
5346 },
5347 [ALC275_FIXUP_SONY_HWEQ] = {
1727a771 5348 .type = HDA_FIXUP_FUNC,
1d045db9
TI
5349 .v.func = alc269_fixup_hweq,
5350 .chained = true,
5351 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
5352 },
e9bd7d5c
TI
5353 [ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
5354 .type = HDA_FIXUP_FUNC,
5355 .v.func = alc_fixup_disable_aamix,
5356 .chained = true,
5357 .chain_id = ALC269_FIXUP_SONY_VAIO
5358 },
1d045db9 5359 [ALC271_FIXUP_DMIC] = {
1727a771 5360 .type = HDA_FIXUP_FUNC,
1d045db9 5361 .v.func = alc271_fixup_dmic,
f1d4e28b 5362 },
017f2a10 5363 [ALC269_FIXUP_PCM_44K] = {
1727a771 5364 .type = HDA_FIXUP_FUNC,
017f2a10 5365 .v.func = alc269_fixup_pcm_44k,
012e7eb1
DH
5366 .chained = true,
5367 .chain_id = ALC269_FIXUP_QUANTA_MUTE
017f2a10 5368 },
adabb3ec 5369 [ALC269_FIXUP_STEREO_DMIC] = {
1727a771 5370 .type = HDA_FIXUP_FUNC,
adabb3ec
TI
5371 .v.func = alc269_fixup_stereo_dmic,
5372 },
7c478f03
DH
5373 [ALC269_FIXUP_HEADSET_MIC] = {
5374 .type = HDA_FIXUP_FUNC,
5375 .v.func = alc269_fixup_headset_mic,
5376 },
24519911 5377 [ALC269_FIXUP_QUANTA_MUTE] = {
1727a771 5378 .type = HDA_FIXUP_FUNC,
24519911
TI
5379 .v.func = alc269_fixup_quanta_mute,
5380 },
5381 [ALC269_FIXUP_LIFEBOOK] = {
1727a771
TI
5382 .type = HDA_FIXUP_PINS,
5383 .v.pins = (const struct hda_pintbl[]) {
24519911
TI
5384 { 0x1a, 0x2101103f }, /* dock line-out */
5385 { 0x1b, 0x23a11040 }, /* dock mic-in */
5386 { }
5387 },
5388 .chained = true,
5389 .chain_id = ALC269_FIXUP_QUANTA_MUTE
5390 },
2041d564
DH
5391 [ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
5392 .type = HDA_FIXUP_PINS,
5393 .v.pins = (const struct hda_pintbl[]) {
5394 { 0x19, 0x01a1903c }, /* headset mic, with jack detect */
5395 { }
5396 },
5397 },
cc7016ab
TI
5398 [ALC269_FIXUP_LIFEBOOK_HP_PIN] = {
5399 .type = HDA_FIXUP_PINS,
5400 .v.pins = (const struct hda_pintbl[]) {
5401 { 0x21, 0x0221102f }, /* HP out */
5402 { }
5403 },
5404 },
4df3fd17
TI
5405 [ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT] = {
5406 .type = HDA_FIXUP_FUNC,
5407 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
5408 },
a4297b5d 5409 [ALC269_FIXUP_AMIC] = {
1727a771
TI
5410 .type = HDA_FIXUP_PINS,
5411 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
5412 { 0x14, 0x99130110 }, /* speaker */
5413 { 0x15, 0x0121401f }, /* HP out */
5414 { 0x18, 0x01a19c20 }, /* mic */
5415 { 0x19, 0x99a3092f }, /* int-mic */
5416 { }
5417 },
5418 },
5419 [ALC269_FIXUP_DMIC] = {
1727a771
TI
5420 .type = HDA_FIXUP_PINS,
5421 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
5422 { 0x12, 0x99a3092f }, /* int-mic */
5423 { 0x14, 0x99130110 }, /* speaker */
5424 { 0x15, 0x0121401f }, /* HP out */
5425 { 0x18, 0x01a19c20 }, /* mic */
5426 { }
5427 },
5428 },
5429 [ALC269VB_FIXUP_AMIC] = {
1727a771
TI
5430 .type = HDA_FIXUP_PINS,
5431 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
5432 { 0x14, 0x99130110 }, /* speaker */
5433 { 0x18, 0x01a19c20 }, /* mic */
5434 { 0x19, 0x99a3092f }, /* int-mic */
5435 { 0x21, 0x0121401f }, /* HP out */
5436 { }
5437 },
5438 },
2267ea97 5439 [ALC269VB_FIXUP_DMIC] = {
1727a771
TI
5440 .type = HDA_FIXUP_PINS,
5441 .v.pins = (const struct hda_pintbl[]) {
a4297b5d
TI
5442 { 0x12, 0x99a3092f }, /* int-mic */
5443 { 0x14, 0x99130110 }, /* speaker */
5444 { 0x18, 0x01a19c20 }, /* mic */
5445 { 0x21, 0x0121401f }, /* HP out */
5446 { }
5447 },
5448 },
08fb0d0e 5449 [ALC269_FIXUP_HP_MUTE_LED] = {
1727a771 5450 .type = HDA_FIXUP_FUNC,
08fb0d0e 5451 .v.func = alc269_fixup_hp_mute_led,
6d3cd5d4 5452 },
d06ac143
DH
5453 [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
5454 .type = HDA_FIXUP_FUNC,
5455 .v.func = alc269_fixup_hp_mute_led_mic1,
5456 },
08fb0d0e 5457 [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
1727a771 5458 .type = HDA_FIXUP_FUNC,
08fb0d0e 5459 .v.func = alc269_fixup_hp_mute_led_mic2,
420b0feb 5460 },
9f5c6faf
TI
5461 [ALC269_FIXUP_HP_GPIO_LED] = {
5462 .type = HDA_FIXUP_FUNC,
5463 .v.func = alc269_fixup_hp_gpio_led,
5464 },
9c5dc3bf
KY
5465 [ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
5466 .type = HDA_FIXUP_FUNC,
5467 .v.func = alc269_fixup_hp_gpio_mic1_led,
5468 },
5469 [ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
5470 .type = HDA_FIXUP_FUNC,
5471 .v.func = alc269_fixup_hp_line1_mic1_led,
5472 },
693b613d 5473 [ALC269_FIXUP_INV_DMIC] = {
1727a771 5474 .type = HDA_FIXUP_FUNC,
9d36a7dc 5475 .v.func = alc_fixup_inv_dmic,
693b613d 5476 },
9b745ab8
TI
5477 [ALC269_FIXUP_NO_SHUTUP] = {
5478 .type = HDA_FIXUP_FUNC,
5479 .v.func = alc_fixup_no_shutup,
5480 },
108cc108 5481 [ALC269_FIXUP_LENOVO_DOCK] = {
1727a771
TI
5482 .type = HDA_FIXUP_PINS,
5483 .v.pins = (const struct hda_pintbl[]) {
108cc108
DH
5484 { 0x19, 0x23a11040 }, /* dock mic */
5485 { 0x1b, 0x2121103f }, /* dock headphone */
5486 { }
5487 },
5488 .chained = true,
5489 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
5490 },
5491 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
1727a771 5492 .type = HDA_FIXUP_FUNC,
108cc108 5493 .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
52129000
DH
5494 .chained = true,
5495 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
108cc108 5496 },
73bdd597
DH
5497 [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
5498 .type = HDA_FIXUP_PINS,
5499 .v.pins = (const struct hda_pintbl[]) {
5500 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5501 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
5502 { }
5503 },
5504 .chained = true,
5505 .chain_id = ALC269_FIXUP_HEADSET_MODE
5506 },
5507 [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
5508 .type = HDA_FIXUP_PINS,
5509 .v.pins = (const struct hda_pintbl[]) {
5510 { 0x16, 0x21014020 }, /* dock line out */
5511 { 0x19, 0x21a19030 }, /* dock mic */
5512 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5513 { }
5514 },
5515 .chained = true,
5516 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
5517 },
338cae56
DH
5518 [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
5519 .type = HDA_FIXUP_PINS,
5520 .v.pins = (const struct hda_pintbl[]) {
5521 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5522 { }
5523 },
5524 .chained = true,
5525 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
5526 },
fcc6c877
KY
5527 [ALC269_FIXUP_DELL4_MIC_NO_PRESENCE] = {
5528 .type = HDA_FIXUP_PINS,
5529 .v.pins = (const struct hda_pintbl[]) {
5530 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5531 { 0x1b, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
5532 { }
5533 },
5534 .chained = true,
5535 .chain_id = ALC269_FIXUP_HEADSET_MODE
5536 },
73bdd597
DH
5537 [ALC269_FIXUP_HEADSET_MODE] = {
5538 .type = HDA_FIXUP_FUNC,
5539 .v.func = alc_fixup_headset_mode,
6676f308
HW
5540 .chained = true,
5541 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
73bdd597
DH
5542 },
5543 [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
5544 .type = HDA_FIXUP_FUNC,
5545 .v.func = alc_fixup_headset_mode_no_hp_mic,
5546 },
7819717b
TI
5547 [ALC269_FIXUP_ASPIRE_HEADSET_MIC] = {
5548 .type = HDA_FIXUP_PINS,
5549 .v.pins = (const struct hda_pintbl[]) {
5550 { 0x19, 0x01a1913c }, /* headset mic w/o jack detect */
5551 { }
5552 },
5553 .chained = true,
5554 .chain_id = ALC269_FIXUP_HEADSET_MODE,
5555 },
88cfcf86
DH
5556 [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
5557 .type = HDA_FIXUP_PINS,
5558 .v.pins = (const struct hda_pintbl[]) {
5559 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5560 { }
5561 },
fbc78ad6
DH
5562 .chained = true,
5563 .chain_id = ALC269_FIXUP_HEADSET_MIC
88cfcf86 5564 },
d240d1dc
DH
5565 [ALC269_FIXUP_ASUS_X101_FUNC] = {
5566 .type = HDA_FIXUP_FUNC,
5567 .v.func = alc269_fixup_x101_headset_mic,
5568 },
5569 [ALC269_FIXUP_ASUS_X101_VERB] = {
5570 .type = HDA_FIXUP_VERBS,
5571 .v.verbs = (const struct hda_verb[]) {
5572 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5573 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
5574 {0x20, AC_VERB_SET_PROC_COEF, 0x0310},
5575 { }
5576 },
5577 .chained = true,
5578 .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
5579 },
5580 [ALC269_FIXUP_ASUS_X101] = {
5581 .type = HDA_FIXUP_PINS,
5582 .v.pins = (const struct hda_pintbl[]) {
5583 { 0x18, 0x04a1182c }, /* Headset mic */
5584 { }
5585 },
5586 .chained = true,
5587 .chain_id = ALC269_FIXUP_ASUS_X101_VERB
5588 },
08a978db 5589 [ALC271_FIXUP_AMIC_MIC2] = {
1727a771
TI
5590 .type = HDA_FIXUP_PINS,
5591 .v.pins = (const struct hda_pintbl[]) {
08a978db
DR
5592 { 0x14, 0x99130110 }, /* speaker */
5593 { 0x19, 0x01a19c20 }, /* mic */
5594 { 0x1b, 0x99a7012f }, /* int-mic */
5595 { 0x21, 0x0121401f }, /* HP out */
5596 { }
5597 },
5598 },
5599 [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
1727a771 5600 .type = HDA_FIXUP_FUNC,
08a978db
DR
5601 .v.func = alc271_hp_gate_mic_jack,
5602 .chained = true,
5603 .chain_id = ALC271_FIXUP_AMIC_MIC2,
5604 },
b1e8972e
OR
5605 [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
5606 .type = HDA_FIXUP_FUNC,
5607 .v.func = alc269_fixup_limit_int_mic_boost,
5608 .chained = true,
5609 .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
5610 },
42397004
DR
5611 [ALC269_FIXUP_ACER_AC700] = {
5612 .type = HDA_FIXUP_PINS,
5613 .v.pins = (const struct hda_pintbl[]) {
5614 { 0x12, 0x99a3092f }, /* int-mic */
5615 { 0x14, 0x99130110 }, /* speaker */
5616 { 0x18, 0x03a11c20 }, /* mic */
5617 { 0x1e, 0x0346101e }, /* SPDIF1 */
5618 { 0x21, 0x0321101f }, /* HP out */
5619 { }
5620 },
5621 .chained = true,
5622 .chain_id = ALC271_FIXUP_DMIC,
5623 },
3e0d611b
DH
5624 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
5625 .type = HDA_FIXUP_FUNC,
5626 .v.func = alc269_fixup_limit_int_mic_boost,
2793769f
DH
5627 .chained = true,
5628 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
3e0d611b 5629 },
2cede303
OR
5630 [ALC269VB_FIXUP_ASUS_ZENBOOK] = {
5631 .type = HDA_FIXUP_FUNC,
5632 .v.func = alc269_fixup_limit_int_mic_boost,
5633 .chained = true,
5634 .chain_id = ALC269VB_FIXUP_DMIC,
5635 },
23870831
TI
5636 [ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
5637 .type = HDA_FIXUP_VERBS,
5638 .v.verbs = (const struct hda_verb[]) {
5639 /* class-D output amp +5dB */
5640 { 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
5641 { 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
5642 {}
5643 },
5644 .chained = true,
5645 .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
5646 },
8e35cd4a
DH
5647 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
5648 .type = HDA_FIXUP_FUNC,
5649 .v.func = alc269_fixup_limit_int_mic_boost,
5650 .chained = true,
5651 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
5652 },
02b504d9
AA
5653 [ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
5654 .type = HDA_FIXUP_PINS,
5655 .v.pins = (const struct hda_pintbl[]) {
5656 { 0x12, 0x99a3092f }, /* int-mic */
5657 { 0x18, 0x03a11d20 }, /* mic */
5658 { 0x19, 0x411111f0 }, /* Unused bogus pin */
5659 { }
5660 },
5661 },
cd217a63
KY
5662 [ALC283_FIXUP_CHROME_BOOK] = {
5663 .type = HDA_FIXUP_FUNC,
5664 .v.func = alc283_fixup_chromebook,
5665 },
0202e99c
KY
5666 [ALC283_FIXUP_SENSE_COMBO_JACK] = {
5667 .type = HDA_FIXUP_FUNC,
5668 .v.func = alc283_fixup_sense_combo_jack,
5669 .chained = true,
5670 .chain_id = ALC283_FIXUP_CHROME_BOOK,
5671 },
7bba2157
TI
5672 [ALC282_FIXUP_ASUS_TX300] = {
5673 .type = HDA_FIXUP_FUNC,
5674 .v.func = alc282_fixup_asus_tx300,
5675 },
1bb3e062
KY
5676 [ALC283_FIXUP_INT_MIC] = {
5677 .type = HDA_FIXUP_VERBS,
5678 .v.verbs = (const struct hda_verb[]) {
5679 {0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
5680 {0x20, AC_VERB_SET_PROC_COEF, 0x0011},
5681 { }
5682 },
5683 .chained = true,
5684 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
5685 },
0f4881dc
DH
5686 [ALC290_FIXUP_SUBWOOFER_HSJACK] = {
5687 .type = HDA_FIXUP_PINS,
5688 .v.pins = (const struct hda_pintbl[]) {
5689 { 0x17, 0x90170112 }, /* subwoofer */
5690 { }
5691 },
5692 .chained = true,
5693 .chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
5694 },
5695 [ALC290_FIXUP_SUBWOOFER] = {
5696 .type = HDA_FIXUP_PINS,
5697 .v.pins = (const struct hda_pintbl[]) {
5698 { 0x17, 0x90170112 }, /* subwoofer */
5699 { }
5700 },
5701 .chained = true,
5702 .chain_id = ALC290_FIXUP_MONO_SPEAKERS,
5703 },
338cae56
DH
5704 [ALC290_FIXUP_MONO_SPEAKERS] = {
5705 .type = HDA_FIXUP_FUNC,
5706 .v.func = alc290_fixup_mono_speakers,
0f4881dc
DH
5707 },
5708 [ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
5709 .type = HDA_FIXUP_FUNC,
5710 .v.func = alc290_fixup_mono_speakers,
338cae56
DH
5711 .chained = true,
5712 .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
5713 },
b67ae3f1
DH
5714 [ALC269_FIXUP_THINKPAD_ACPI] = {
5715 .type = HDA_FIXUP_FUNC,
b317b032 5716 .v.func = hda_fixup_thinkpad_acpi,
09da111a
TI
5717 .chained = true,
5718 .chain_id = ALC269_FIXUP_SKU_IGNORE,
b67ae3f1 5719 },
56f27013
DH
5720 [ALC269_FIXUP_DMIC_THINKPAD_ACPI] = {
5721 .type = HDA_FIXUP_FUNC,
5722 .v.func = alc_fixup_inv_dmic,
5723 .chained = true,
5724 .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
5725 },
5824ce8d
CC
5726 [ALC255_FIXUP_ACER_MIC_NO_PRESENCE] = {
5727 .type = HDA_FIXUP_PINS,
5728 .v.pins = (const struct hda_pintbl[]) {
5729 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5730 { }
5731 },
5732 .chained = true,
5733 .chain_id = ALC255_FIXUP_HEADSET_MODE
5734 },
615966ad
CC
5735 [ALC255_FIXUP_ASUS_MIC_NO_PRESENCE] = {
5736 .type = HDA_FIXUP_PINS,
5737 .v.pins = (const struct hda_pintbl[]) {
5738 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5739 { }
5740 },
5741 .chained = true,
5742 .chain_id = ALC255_FIXUP_HEADSET_MODE
5743 },
9a22a8f5
KY
5744 [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
5745 .type = HDA_FIXUP_PINS,
5746 .v.pins = (const struct hda_pintbl[]) {
5747 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5748 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
5749 { }
5750 },
5751 .chained = true,
5752 .chain_id = ALC255_FIXUP_HEADSET_MODE
5753 },
31278997
KY
5754 [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
5755 .type = HDA_FIXUP_PINS,
5756 .v.pins = (const struct hda_pintbl[]) {
5757 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5758 { }
5759 },
5760 .chained = true,
5761 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
5762 },
9a22a8f5
KY
5763 [ALC255_FIXUP_HEADSET_MODE] = {
5764 .type = HDA_FIXUP_FUNC,
5765 .v.func = alc_fixup_headset_mode_alc255,
4a83d42a
HW
5766 .chained = true,
5767 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
9a22a8f5 5768 },
31278997
KY
5769 [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
5770 .type = HDA_FIXUP_FUNC,
5771 .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
5772 },
a22aa26f
KY
5773 [ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
5774 .type = HDA_FIXUP_PINS,
5775 .v.pins = (const struct hda_pintbl[]) {
5776 { 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
5777 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5778 { }
5779 },
5780 .chained = true,
5781 .chain_id = ALC269_FIXUP_HEADSET_MODE
5782 },
1c37c223 5783 [ALC292_FIXUP_TPT440_DOCK] = {
ec56af67 5784 .type = HDA_FIXUP_FUNC,
7f57d803 5785 .v.func = alc_fixup_tpt440_dock,
1c37c223
TI
5786 .chained = true,
5787 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
5788 },
9a811230
TI
5789 [ALC292_FIXUP_TPT440] = {
5790 .type = HDA_FIXUP_FUNC,
157f0b7f 5791 .v.func = alc_fixup_disable_aamix,
9a811230
TI
5792 .chained = true,
5793 .chain_id = ALC292_FIXUP_TPT440_DOCK,
5794 },
abaa2274 5795 [ALC283_FIXUP_HEADSET_MIC] = {
9dc12862
DD
5796 .type = HDA_FIXUP_PINS,
5797 .v.pins = (const struct hda_pintbl[]) {
5798 { 0x19, 0x04a110f0 },
5799 { },
5800 },
5801 },
00ef9940
HW
5802 [ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED] = {
5803 .type = HDA_FIXUP_FUNC,
5804 .v.func = alc_fixup_dell_wmi,
00ef9940 5805 },
1a22e775
TI
5806 [ALC282_FIXUP_ASPIRE_V5_PINS] = {
5807 .type = HDA_FIXUP_PINS,
5808 .v.pins = (const struct hda_pintbl[]) {
5809 { 0x12, 0x90a60130 },
5810 { 0x14, 0x90170110 },
5811 { 0x17, 0x40000008 },
5812 { 0x18, 0x411111f0 },
0420694d 5813 { 0x19, 0x01a1913c },
1a22e775
TI
5814 { 0x1a, 0x411111f0 },
5815 { 0x1b, 0x411111f0 },
5816 { 0x1d, 0x40f89b2d },
5817 { 0x1e, 0x411111f0 },
5818 { 0x21, 0x0321101f },
5819 { },
5820 },
5821 },
7a5255f1
DH
5822 [ALC280_FIXUP_HP_GPIO4] = {
5823 .type = HDA_FIXUP_FUNC,
5824 .v.func = alc280_fixup_hp_gpio4,
5825 },
eaa8e5ef
KY
5826 [ALC286_FIXUP_HP_GPIO_LED] = {
5827 .type = HDA_FIXUP_FUNC,
5828 .v.func = alc286_fixup_hp_gpio_led,
5829 },
33f4acd3
DH
5830 [ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY] = {
5831 .type = HDA_FIXUP_FUNC,
5832 .v.func = alc280_fixup_hp_gpio2_mic_hotkey,
5833 },
b4b33f9d
TC
5834 [ALC280_FIXUP_HP_DOCK_PINS] = {
5835 .type = HDA_FIXUP_PINS,
5836 .v.pins = (const struct hda_pintbl[]) {
5837 { 0x1b, 0x21011020 }, /* line-out */
5838 { 0x1a, 0x01a1903c }, /* headset mic */
5839 { 0x18, 0x2181103f }, /* line-in */
5840 { },
5841 },
5842 .chained = true,
5843 .chain_id = ALC280_FIXUP_HP_GPIO4
5844 },
04d5466a
JK
5845 [ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED] = {
5846 .type = HDA_FIXUP_PINS,
5847 .v.pins = (const struct hda_pintbl[]) {
5848 { 0x1b, 0x21011020 }, /* line-out */
5849 { 0x18, 0x2181103f }, /* line-in */
5850 { },
5851 },
5852 .chained = true,
5853 .chain_id = ALC269_FIXUP_HP_GPIO_MIC1_LED
5854 },
98973f2f
KP
5855 [ALC280_FIXUP_HP_9480M] = {
5856 .type = HDA_FIXUP_FUNC,
5857 .v.func = alc280_fixup_hp_9480m,
5858 },
e1e62b98
KY
5859 [ALC288_FIXUP_DELL_HEADSET_MODE] = {
5860 .type = HDA_FIXUP_FUNC,
5861 .v.func = alc_fixup_headset_mode_dell_alc288,
5862 .chained = true,
5863 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
5864 },
5865 [ALC288_FIXUP_DELL1_MIC_NO_PRESENCE] = {
5866 .type = HDA_FIXUP_PINS,
5867 .v.pins = (const struct hda_pintbl[]) {
5868 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5869 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
5870 { }
5871 },
5872 .chained = true,
5873 .chain_id = ALC288_FIXUP_DELL_HEADSET_MODE
5874 },
5875 [ALC288_FIXUP_DELL_XPS_13_GPIO6] = {
5876 .type = HDA_FIXUP_VERBS,
5877 .v.verbs = (const struct hda_verb[]) {
5878 {0x01, AC_VERB_SET_GPIO_MASK, 0x40},
5879 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x40},
5880 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5881 { }
5882 },
5883 .chained = true,
5884 .chain_id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE
5885 },
831bfdf9
HW
5886 [ALC288_FIXUP_DISABLE_AAMIX] = {
5887 .type = HDA_FIXUP_FUNC,
5888 .v.func = alc_fixup_disable_aamix,
5889 .chained = true,
5890 .chain_id = ALC288_FIXUP_DELL_XPS_13_GPIO6
5891 },
5892 [ALC288_FIXUP_DELL_XPS_13] = {
5893 .type = HDA_FIXUP_FUNC,
5894 .v.func = alc_fixup_dell_xps13,
5895 .chained = true,
5896 .chain_id = ALC288_FIXUP_DISABLE_AAMIX
5897 },
8b99aba7
TI
5898 [ALC292_FIXUP_DISABLE_AAMIX] = {
5899 .type = HDA_FIXUP_FUNC,
5900 .v.func = alc_fixup_disable_aamix,
831bfdf9
HW
5901 .chained = true,
5902 .chain_id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE
8b99aba7 5903 },
c04017ea
DH
5904 [ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK] = {
5905 .type = HDA_FIXUP_FUNC,
5906 .v.func = alc_fixup_disable_aamix,
5907 .chained = true,
5908 .chain_id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE
5909 },
8b99aba7
TI
5910 [ALC292_FIXUP_DELL_E7X] = {
5911 .type = HDA_FIXUP_FUNC,
5912 .v.func = alc_fixup_dell_xps13,
5913 .chained = true,
5914 .chain_id = ALC292_FIXUP_DISABLE_AAMIX
5915 },
977e6276
KY
5916 [ALC298_FIXUP_DELL1_MIC_NO_PRESENCE] = {
5917 .type = HDA_FIXUP_PINS,
5918 .v.pins = (const struct hda_pintbl[]) {
5919 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5920 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
5921 { }
5922 },
5923 .chained = true,
5924 .chain_id = ALC269_FIXUP_HEADSET_MODE
5925 },
2f726aec
HW
5926 [ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE] = {
5927 .type = HDA_FIXUP_PINS,
5928 .v.pins = (const struct hda_pintbl[]) {
5929 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
5930 { }
5931 },
5932 .chained = true,
5933 .chain_id = ALC269_FIXUP_HEADSET_MODE
5934 },
6ed1131f
KY
5935 [ALC275_FIXUP_DELL_XPS] = {
5936 .type = HDA_FIXUP_VERBS,
5937 .v.verbs = (const struct hda_verb[]) {
5938 /* Enables internal speaker */
5939 {0x20, AC_VERB_SET_COEF_INDEX, 0x1f},
5940 {0x20, AC_VERB_SET_PROC_COEF, 0x00c0},
5941 {0x20, AC_VERB_SET_COEF_INDEX, 0x30},
5942 {0x20, AC_VERB_SET_PROC_COEF, 0x00b1},
5943 {}
5944 }
5945 },
8c69729b
HW
5946 [ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE] = {
5947 .type = HDA_FIXUP_VERBS,
5948 .v.verbs = (const struct hda_verb[]) {
5949 /* Disable pass-through path for FRONT 14h */
5950 {0x20, AC_VERB_SET_COEF_INDEX, 0x36},
5951 {0x20, AC_VERB_SET_PROC_COEF, 0x1737},
5952 {}
5953 },
5954 .chained = true,
5955 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
5956 },
23adc192
HW
5957 [ALC293_FIXUP_LENOVO_SPK_NOISE] = {
5958 .type = HDA_FIXUP_FUNC,
5959 .v.func = alc_fixup_disable_aamix,
5960 .chained = true,
5961 .chain_id = ALC269_FIXUP_THINKPAD_ACPI
5962 },
3694cb29
K
5963 [ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY] = {
5964 .type = HDA_FIXUP_FUNC,
5965 .v.func = alc233_fixup_lenovo_line2_mic_hotkey,
5966 },
3b43b71f
KHF
5967 [ALC255_FIXUP_DELL_SPK_NOISE] = {
5968 .type = HDA_FIXUP_FUNC,
5969 .v.func = alc_fixup_disable_aamix,
5970 .chained = true,
5971 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
5972 },
2ae95577
DH
5973 [ALC225_FIXUP_DELL1_MIC_NO_PRESENCE] = {
5974 .type = HDA_FIXUP_VERBS,
5975 .v.verbs = (const struct hda_verb[]) {
5976 /* Disable pass-through path for FRONT 14h */
5977 { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
5978 { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
5979 {}
5980 },
5981 .chained = true,
5982 .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
5983 },
f883982d
TI
5984 [ALC280_FIXUP_HP_HEADSET_MIC] = {
5985 .type = HDA_FIXUP_FUNC,
5986 .v.func = alc_fixup_disable_aamix,
5987 .chained = true,
5988 .chain_id = ALC269_FIXUP_HEADSET_MIC,
5989 },
e549d190
HW
5990 [ALC221_FIXUP_HP_FRONT_MIC] = {
5991 .type = HDA_FIXUP_PINS,
5992 .v.pins = (const struct hda_pintbl[]) {
5993 { 0x19, 0x02a19020 }, /* Front Mic */
5994 { }
5995 },
5996 },
c636b95e
SE
5997 [ALC292_FIXUP_TPT460] = {
5998 .type = HDA_FIXUP_FUNC,
5999 .v.func = alc_fixup_tpt440_dock,
6000 .chained = true,
6001 .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE,
6002 },
dd9aa335
HW
6003 [ALC298_FIXUP_SPK_VOLUME] = {
6004 .type = HDA_FIXUP_FUNC,
6005 .v.func = alc298_fixup_speaker_volume,
59ec4b57 6006 .chained = true,
2f726aec 6007 .chain_id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
dd9aa335 6008 },
fd06c77e
KHF
6009 [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
6010 .type = HDA_FIXUP_PINS,
6011 .v.pins = (const struct hda_pintbl[]) {
6012 { 0x1b, 0x90170151 },
6013 { }
6014 },
6015 .chained = true,
6016 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6017 },
823ff161
GM
6018 [ALC269_FIXUP_ATIV_BOOK_8] = {
6019 .type = HDA_FIXUP_FUNC,
6020 .v.func = alc_fixup_auto_mute_via_amp,
6021 .chained = true,
6022 .chain_id = ALC269_FIXUP_NO_SHUTUP
6023 },
9eb5d0e6
KY
6024 [ALC221_FIXUP_HP_MIC_NO_PRESENCE] = {
6025 .type = HDA_FIXUP_PINS,
6026 .v.pins = (const struct hda_pintbl[]) {
6027 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6028 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6029 { }
6030 },
6031 .chained = true,
6032 .chain_id = ALC269_FIXUP_HEADSET_MODE
6033 },
c1732ede
CC
6034 [ALC256_FIXUP_ASUS_HEADSET_MODE] = {
6035 .type = HDA_FIXUP_FUNC,
6036 .v.func = alc_fixup_headset_mode,
6037 },
6038 [ALC256_FIXUP_ASUS_MIC] = {
6039 .type = HDA_FIXUP_PINS,
6040 .v.pins = (const struct hda_pintbl[]) {
6041 { 0x13, 0x90a60160 }, /* use as internal mic */
6042 { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
6043 { }
6044 },
6045 .chained = true,
6046 .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
6047 },
eeed4cd1
CC
6048 [ALC256_FIXUP_ASUS_AIO_GPIO2] = {
6049 .type = HDA_FIXUP_VERBS,
6050 .v.verbs = (const struct hda_verb[]) {
6051 /* Set up GPIO2 for the speaker amp */
6052 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
6053 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
6054 { 0x01, AC_VERB_SET_GPIO_DATA, 0x04 },
6055 {}
6056 },
6057 },
216d7aeb
CC
6058 [ALC233_FIXUP_ASUS_MIC_NO_PRESENCE] = {
6059 .type = HDA_FIXUP_PINS,
6060 .v.pins = (const struct hda_pintbl[]) {
6061 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6062 { }
6063 },
6064 .chained = true,
6065 .chain_id = ALC269_FIXUP_HEADSET_MIC
6066 },
6067 [ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE] = {
6068 .type = HDA_FIXUP_VERBS,
6069 .v.verbs = (const struct hda_verb[]) {
6070 /* Enables internal speaker */
6071 {0x20, AC_VERB_SET_COEF_INDEX, 0x40},
6072 {0x20, AC_VERB_SET_PROC_COEF, 0x8800},
6073 {}
6074 },
6075 .chained = true,
6076 .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
6077 },
ca169cc2
KY
6078 [ALC233_FIXUP_LENOVO_MULTI_CODECS] = {
6079 .type = HDA_FIXUP_FUNC,
6080 .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
6081 },
f33f79f3
HW
6082 [ALC294_FIXUP_LENOVO_MIC_LOCATION] = {
6083 .type = HDA_FIXUP_PINS,
6084 .v.pins = (const struct hda_pintbl[]) {
6085 /* Change the mic location from front to right, otherwise there are
6086 two front mics with the same name, pulseaudio can't handle them.
6087 This is just a temporary workaround, after applying this fixup,
6088 there will be one "Front Mic" and one "Mic" in this machine.
6089 */
6090 { 0x1a, 0x04a19040 },
6091 { }
6092 },
6093 },
b84e8436
PH
6094 [ALC700_FIXUP_INTEL_REFERENCE] = {
6095 .type = HDA_FIXUP_VERBS,
6096 .v.verbs = (const struct hda_verb[]) {
6097 /* Enables internal speaker */
6098 {0x20, AC_VERB_SET_COEF_INDEX, 0x45},
6099 {0x20, AC_VERB_SET_PROC_COEF, 0x5289},
6100 {0x20, AC_VERB_SET_COEF_INDEX, 0x4A},
6101 {0x20, AC_VERB_SET_PROC_COEF, 0x001b},
6102 {0x58, AC_VERB_SET_COEF_INDEX, 0x00},
6103 {0x58, AC_VERB_SET_PROC_COEF, 0x3888},
6104 {0x20, AC_VERB_SET_COEF_INDEX, 0x6f},
6105 {0x20, AC_VERB_SET_PROC_COEF, 0x2c0b},
6106 {}
6107 }
6108 },
f1d4e28b
KY
6109};
6110
1d045db9 6111static const struct snd_pci_quirk alc269_fixup_tbl[] = {
a6b92b66 6112 SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
693b613d
DH
6113 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
6114 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
aaedfb47 6115 SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
7819717b
TI
6116 SND_PCI_QUIRK(0x1025, 0x072d, "Acer Aspire V5-571G", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
6117 SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
aaedfb47
DH
6118 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
6119 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
02322ac9 6120 SND_PCI_QUIRK(0x1025, 0x0762, "Acer Aspire E1-472", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
b1e8972e 6121 SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
1a22e775 6122 SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
b9c2fa52 6123 SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK),
aaedfb47 6124 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
6ed1131f 6125 SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
86f799b8 6126 SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X),
cf52103a 6127 SND_PCI_QUIRK(0x1028, 0x05be, "Dell Latitude E6540", ALC292_FIXUP_DELL_E7X),
8b99aba7
TI
6128 SND_PCI_QUIRK(0x1028, 0x05ca, "Dell Latitude E7240", ALC292_FIXUP_DELL_E7X),
6129 SND_PCI_QUIRK(0x1028, 0x05cb, "Dell Latitude E7440", ALC292_FIXUP_DELL_E7X),
0f4881dc 6130 SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
73bdd597
DH
6131 SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
6132 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
6133 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
0f4881dc
DH
6134 SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
6135 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
98070576 6136 SND_PCI_QUIRK(0x1028, 0x062c, "Dell Latitude E5550", ALC292_FIXUP_DELL_E7X),
4275554d 6137 SND_PCI_QUIRK(0x1028, 0x062e, "Dell Latitude E7450", ALC292_FIXUP_DELL_E7X),
0f4881dc 6138 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
a22aa26f
KY
6139 SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6140 SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
831bfdf9 6141 SND_PCI_QUIRK(0x1028, 0x0665, "Dell XPS 13", ALC288_FIXUP_DELL_XPS_13),
afecb146 6142 SND_PCI_QUIRK(0x1028, 0x0669, "Dell Optiplex 9020m", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
3a05d12f 6143 SND_PCI_QUIRK(0x1028, 0x069a, "Dell Vostro 5480", ALC290_FIXUP_SUBWOOFER_HSJACK),
8b72415d 6144 SND_PCI_QUIRK(0x1028, 0x06c7, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
b734304f
KY
6145 SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6146 SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
c04017ea
DH
6147 SND_PCI_QUIRK(0x1028, 0x06db, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6148 SND_PCI_QUIRK(0x1028, 0x06dd, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6149 SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6150 SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
6151 SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
423cd785 6152 SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13 9350", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
fd06c77e 6153 SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
3b43b71f 6154 SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
423cd785 6155 SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
dd9aa335 6156 SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
493de342 6157 SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
a22aa26f
KY
6158 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
6159 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
08fb0d0e 6160 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
9f5c6faf 6161 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
8e35cd4a 6162 SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
33f4acd3 6163 SND_PCI_QUIRK(0x103c, 0x225f, "HP", ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY),
c60666bd 6164 /* ALC282 */
7976eb49 6165 SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164 6166 SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164 6167 SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9c5dc3bf
KY
6168 SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6169 SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6170 SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
6171 SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
9c5dc3bf 6172 SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
c60666bd 6173 SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6174 SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6175 SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164 6176 SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
eaa8e5ef 6177 SND_PCI_QUIRK(0x103c, 0x2271, "HP", ALC286_FIXUP_HP_GPIO_LED),
b4b33f9d 6178 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC280_FIXUP_HP_DOCK_PINS),
3271cb22 6179 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC280_FIXUP_HP_DOCK_PINS),
c60666bd 6180 SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6181 SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6182 SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6183 SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 6184 SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
98973f2f 6185 SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC280_FIXUP_HP_9480M),
9c5dc3bf
KY
6186 SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6187 SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
c60666bd 6188 /* ALC290 */
9c5dc3bf 6189 SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf 6190 SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf 6191 SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf
KY
6192 SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6193 SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6194 SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6195 SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6196 SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf 6197 SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
04d5466a 6198 SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED),
c60666bd 6199 SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6200 SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6201 SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6202 SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
9c5dc3bf
KY
6203 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
6204 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
9c5dc3bf 6205 SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
c60666bd 6206 SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 6207 SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 6208 SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6209 SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6210 SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd
KY
6211 SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6212 SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
c60666bd 6213 SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8a02b164
KY
6214 SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6215 SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6216 SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
6217 SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
f883982d 6218 SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
e549d190 6219 SND_PCI_QUIRK(0x103c, 0x8256, "HP", ALC221_FIXUP_HP_FRONT_MIC),
9eb5d0e6
KY
6220 SND_PCI_QUIRK(0x103c, 0x82bf, "HP", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
6221 SND_PCI_QUIRK(0x103c, 0x82c0, "HP", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
c1732ede 6222 SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
7bba2157 6223 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
3e0d611b 6224 SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
c1732ede 6225 SND_PCI_QUIRK(0x1043, 0x10c0, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
4eab0ea1 6226 SND_PCI_QUIRK(0x1043, 0x10d0, "ASUS X540LA/X540LJ", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
3e0d611b 6227 SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
4eab0ea1
TI
6228 SND_PCI_QUIRK(0x1043, 0x11c0, "ASUS X556UR", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
6229 SND_PCI_QUIRK(0x1043, 0x1290, "ASUS X441SA", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
6230 SND_PCI_QUIRK(0x1043, 0x12a0, "ASUS X441UV", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
c1732ede
CC
6231 SND_PCI_QUIRK(0x1043, 0x12f0, "ASUS X541UV", ALC256_FIXUP_ASUS_MIC),
6232 SND_PCI_QUIRK(0x1043, 0x12e0, "ASUS X541SA", ALC256_FIXUP_ASUS_MIC),
6233 SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC),
2cede303 6234 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
23870831 6235 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
3e0d611b 6236 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
017f2a10 6237 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
28e8af8a 6238 SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),
693b613d 6239 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
615966ad 6240 SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
4eab0ea1 6241 SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
c1732ede 6242 SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
eeed4cd1 6243 SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
adabb3ec
TI
6244 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
6245 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
6246 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
6247 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
d240d1dc 6248 SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
f88abaa0 6249 SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
88cfcf86 6250 SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
1d045db9
TI
6251 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
6252 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
6253 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
e9bd7d5c 6254 SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
24519911 6255 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
4df3fd17 6256 SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT),
cc7016ab 6257 SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
88776f36 6258 SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
2041d564 6259 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
b84e8436 6260 SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
a33cc48d 6261 SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
823ff161 6262 SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
abaa2274
AA
6263 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
6264 SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
ca169cc2 6265 SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC233_FIXUP_LENOVO_MULTI_CODECS),
1d045db9
TI
6266 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
6267 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
6268 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
6269 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
6270 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
707fba3f 6271 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
c8415a48 6272 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
84f98fdf 6273 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
4407be6b 6274 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
108cc108 6275 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
aaedfb47 6276 SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
9a811230 6277 SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440),
1c37c223 6278 SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
a12137e7 6279 SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
59a51a6b 6280 SND_PCI_QUIRK(0x17aa, 0x2211, "Thinkpad W541", ALC292_FIXUP_TPT440_DOCK),
6d16941a 6281 SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK),
7c21539c 6282 SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK),
a4a9e082 6283 SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
b6903c0e 6284 SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK),
d05ea7da 6285 SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK),
c0278669 6286 SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK),
dab38e43 6287 SND_PCI_QUIRK(0x17aa, 0x2231, "Thinkpad T560", ALC292_FIXUP_TPT460),
c636b95e 6288 SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460),
3694cb29 6289 SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
6ef2f68f 6290 SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
f33f79f3 6291 SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
29693efc 6292 SND_PCI_QUIRK(0x17aa, 0x3112, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
56f27013 6293 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
fedb2245 6294 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
9b745ab8 6295 SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP),
a4a9e082 6296 SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
1bb3e062 6297 SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
c497d9f9 6298 SND_PCI_QUIRK(0x17aa, 0x501e, "Thinkpad L440", ALC292_FIXUP_TPT440_DOCK),
cd5302c0 6299 SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
f2aa1110 6300 SND_PCI_QUIRK(0x17aa, 0x5034, "Thinkpad T450", ALC292_FIXUP_TPT440_DOCK),
80b311d3 6301 SND_PCI_QUIRK(0x17aa, 0x5036, "Thinkpad T450s", ALC292_FIXUP_TPT440_DOCK),
09ea9976 6302 SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK),
037e1197 6303 SND_PCI_QUIRK(0x17aa, 0x504a, "ThinkPad X260", ALC292_FIXUP_TPT440_DOCK),
23adc192 6304 SND_PCI_QUIRK(0x17aa, 0x504b, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE),
0f087ee3 6305 SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460),
9cd25743 6306 SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460),
0f087ee3 6307 SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460),
cd5302c0 6308 SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
012e7eb1 6309 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
1d045db9 6310 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
02b504d9 6311 SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
a4297b5d 6312
a7f3eedc 6313#if 0
a4297b5d
TI
6314 /* Below is a quirk table taken from the old code.
6315 * Basically the device should work as is without the fixup table.
6316 * If BIOS doesn't give a proper info, enable the corresponding
6317 * fixup entry.
7d7eb9ea 6318 */
a4297b5d
TI
6319 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
6320 ALC269_FIXUP_AMIC),
6321 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
a4297b5d
TI
6322 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
6323 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
6324 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
6325 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
6326 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
6327 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
6328 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
6329 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
6330 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
6331 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
6332 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
6333 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
6334 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
6335 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
6336 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
6337 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
6338 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
6339 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
6340 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
6341 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
6342 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
6343 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
6344 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
6345 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
6346 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
6347 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
6348 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
6349 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
6350 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
6351 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
6352 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
6353 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
6354 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
6355 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
6356 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
6357 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
6358 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
6359 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
6360#endif
6361 {}
6362};
6363
214eef76
DH
6364static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
6365 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
6366 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
6367 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
6368 SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
6369 {}
6370};
6371
1727a771 6372static const struct hda_model_fixup alc269_fixup_models[] = {
a4297b5d
TI
6373 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
6374 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
6e72aa5f
TI
6375 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
6376 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
6377 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
7c478f03 6378 {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
b016951e
TI
6379 {.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
6380 {.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = "headset-mode-no-hp-mic"},
108cc108 6381 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
9f5c6faf 6382 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
04d5466a 6383 {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"},
e32aa85a
DH
6384 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
6385 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
be8ef16a 6386 {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
0202e99c 6387 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
1c37c223 6388 {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
9a811230 6389 {.id = ALC292_FIXUP_TPT440, .name = "tpt440"},
c636b95e 6390 {.id = ALC292_FIXUP_TPT460, .name = "tpt460"},
ba90d6a6 6391 {.id = ALC233_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
28d1d6d2 6392 {.id = ALC700_FIXUP_INTEL_REFERENCE, .name = "alc700-ref"},
1d045db9 6393 {}
6dda9f4a 6394};
cfc5a845 6395#define ALC225_STANDARD_PINS \
cfc5a845 6396 {0x21, 0x04211020}
6dda9f4a 6397
e8191a8e
HW
6398#define ALC256_STANDARD_PINS \
6399 {0x12, 0x90a60140}, \
6400 {0x14, 0x90170110}, \
e8191a8e
HW
6401 {0x21, 0x02211020}
6402
fea185e2 6403#define ALC282_STANDARD_PINS \
11580297 6404 {0x14, 0x90170110}
e1e62b98 6405
fea185e2 6406#define ALC290_STANDARD_PINS \
11580297 6407 {0x12, 0x99a30130}
fea185e2
DH
6408
6409#define ALC292_STANDARD_PINS \
6410 {0x14, 0x90170110}, \
11580297 6411 {0x15, 0x0221401f}
977e6276 6412
3f640970
HW
6413#define ALC295_STANDARD_PINS \
6414 {0x12, 0xb7a60130}, \
6415 {0x14, 0x90170110}, \
3f640970
HW
6416 {0x21, 0x04211020}
6417
703867e2
WS
6418#define ALC298_STANDARD_PINS \
6419 {0x12, 0x90a60130}, \
6420 {0x21, 0x03211020}
6421
e1918938 6422static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
5824ce8d
CC
6423 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
6424 {0x12, 0x90a601c0},
6425 {0x14, 0x90171120},
6426 {0x21, 0x02211030}),
615966ad
CC
6427 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
6428 {0x14, 0x90170110},
6429 {0x1b, 0x90a70130},
6430 {0x21, 0x03211020}),
6431 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
6432 {0x1a, 0x90a70130},
6433 {0x1b, 0x90170110},
6434 {0x21, 0x03211020}),
2ae95577 6435 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
cfc5a845 6436 ALC225_STANDARD_PINS,
8a132099 6437 {0x12, 0xb7a60130},
cfc5a845 6438 {0x14, 0x901701a0}),
2ae95577 6439 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
cfc5a845 6440 ALC225_STANDARD_PINS,
8a132099 6441 {0x12, 0xb7a60130},
cfc5a845 6442 {0x14, 0x901701b0}),
8a132099
HW
6443 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6444 ALC225_STANDARD_PINS,
6445 {0x12, 0xb7a60150},
6446 {0x14, 0x901701a0}),
6447 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6448 ALC225_STANDARD_PINS,
6449 {0x12, 0xb7a60150},
6450 {0x14, 0x901701b0}),
6451 SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6452 ALC225_STANDARD_PINS,
6453 {0x12, 0xb7a60130},
6454 {0x1b, 0x90170110}),
f265788c
HW
6455 SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6456 {0x12, 0x90a60140},
6457 {0x14, 0x90170110},
6458 {0x21, 0x02211020}),
6459 SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6460 {0x12, 0x90a60140},
6461 {0x14, 0x90170150},
6462 {0x21, 0x02211020}),
c77900e6 6463 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
c77900e6 6464 {0x14, 0x90170110},
c77900e6 6465 {0x21, 0x02211020}),
86c72d1c
HW
6466 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6467 {0x14, 0x90170130},
6468 {0x21, 0x02211040}),
76c2132e
DH
6469 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6470 {0x12, 0x90a60140},
6471 {0x14, 0x90170110},
76c2132e
DH
6472 {0x21, 0x02211020}),
6473 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6474 {0x12, 0x90a60160},
6475 {0x14, 0x90170120},
76c2132e 6476 {0x21, 0x02211030}),
392c9da2
HW
6477 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6478 {0x14, 0x90170110},
6479 {0x1b, 0x02011020},
6480 {0x21, 0x0221101f}),
6aecd871
HW
6481 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6482 {0x14, 0x90170110},
6483 {0x1b, 0x01011020},
6484 {0x21, 0x0221101f}),
cba59972 6485 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
cba59972 6486 {0x14, 0x90170130},
cba59972 6487 {0x1b, 0x01014020},
cba59972 6488 {0x21, 0x0221103f}),
6aecd871
HW
6489 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6490 {0x14, 0x90170130},
6491 {0x1b, 0x01011020},
6492 {0x21, 0x0221103f}),
59ec4b57
HW
6493 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6494 {0x14, 0x90170130},
6495 {0x1b, 0x02011020},
6496 {0x21, 0x0221103f}),
e9c28e16 6497 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
e9c28e16 6498 {0x14, 0x90170150},
e9c28e16 6499 {0x1b, 0x02011020},
e9c28e16
WS
6500 {0x21, 0x0221105f}),
6501 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
e9c28e16 6502 {0x14, 0x90170110},
e9c28e16 6503 {0x1b, 0x01014020},
e9c28e16 6504 {0x21, 0x0221101f}),
76c2132e
DH
6505 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6506 {0x12, 0x90a60160},
6507 {0x14, 0x90170120},
6508 {0x17, 0x90170140},
76c2132e
DH
6509 {0x21, 0x0321102f}),
6510 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6511 {0x12, 0x90a60160},
6512 {0x14, 0x90170130},
76c2132e
DH
6513 {0x21, 0x02211040}),
6514 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6515 {0x12, 0x90a60160},
6516 {0x14, 0x90170140},
76c2132e
DH
6517 {0x21, 0x02211050}),
6518 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6519 {0x12, 0x90a60170},
6520 {0x14, 0x90170120},
76c2132e
DH
6521 {0x21, 0x02211030}),
6522 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6523 {0x12, 0x90a60170},
6524 {0x14, 0x90170130},
76c2132e 6525 {0x21, 0x02211040}),
0a1f90a9
HW
6526 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6527 {0x12, 0x90a60170},
6528 {0x14, 0x90171130},
6529 {0x21, 0x02211040}),
70658b99 6530 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
70658b99
HW
6531 {0x12, 0x90a60170},
6532 {0x14, 0x90170140},
70658b99 6533 {0x21, 0x02211050}),
9b5a4e39 6534 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5548", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9b5a4e39
DH
6535 {0x12, 0x90a60180},
6536 {0x14, 0x90170130},
9b5a4e39 6537 {0x21, 0x02211040}),
f90d83b3
AK
6538 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5565", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6539 {0x12, 0x90a60180},
6540 {0x14, 0x90170120},
6541 {0x21, 0x02211030}),
989dbe4a
HW
6542 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6543 {0x1b, 0x01011020},
6544 {0x21, 0x02211010}),
81a1231b 6545 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
81a1231b
KY
6546 {0x12, 0x90a60160},
6547 {0x14, 0x90170120},
81a1231b 6548 {0x21, 0x02211030}),
f83c3292
WS
6549 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6550 {0x12, 0x90a60170},
6551 {0x14, 0x90170120},
6552 {0x21, 0x02211030}),
311042d1
SB
6553 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell Inspiron 5468", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6554 {0x12, 0x90a60180},
6555 {0x14, 0x90170120},
6556 {0x21, 0x02211030}),
3f640970
HW
6557 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6558 {0x12, 0xb7a60130},
6559 {0x14, 0x90170110},
6560 {0x21, 0x02211020}),
7081adf3 6561 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
11580297 6562 ALC256_STANDARD_PINS),
c1732ede
CC
6563 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
6564 {0x14, 0x90170110},
6565 {0x1b, 0x90a70130},
6566 {0x21, 0x04211020}),
6567 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
6568 {0x14, 0x90170110},
6569 {0x1b, 0x90a70130},
6570 {0x21, 0x03211020}),
75ee94b2
HW
6571 SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
6572 {0x12, 0xb7a60130},
6573 {0x13, 0xb8a61140},
6574 {0x16, 0x90170110},
6575 {0x21, 0x04211020}),
cf51eb9d
DH
6576 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
6577 {0x12, 0x90a60130},
cf51eb9d
DH
6578 {0x14, 0x90170110},
6579 {0x15, 0x0421101f},
11580297 6580 {0x1a, 0x04a11020}),
0279661b
HW
6581 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED,
6582 {0x12, 0x90a60140},
0279661b
HW
6583 {0x14, 0x90170110},
6584 {0x15, 0x0421101f},
0279661b 6585 {0x18, 0x02811030},
0279661b 6586 {0x1a, 0x04a1103f},
11580297 6587 {0x1b, 0x02011020}),
42304474 6588 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 6589 ALC282_STANDARD_PINS,
42304474 6590 {0x12, 0x99a30130},
42304474 6591 {0x19, 0x03a11020},
42304474 6592 {0x21, 0x0321101f}),
2c609999 6593 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 6594 ALC282_STANDARD_PINS,
2c609999 6595 {0x12, 0x99a30130},
2c609999 6596 {0x19, 0x03a11020},
2c609999
HW
6597 {0x21, 0x03211040}),
6598 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 6599 ALC282_STANDARD_PINS,
2c609999 6600 {0x12, 0x99a30130},
2c609999 6601 {0x19, 0x03a11030},
2c609999
HW
6602 {0x21, 0x03211020}),
6603 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 6604 ALC282_STANDARD_PINS,
2c609999 6605 {0x12, 0x99a30130},
2c609999 6606 {0x19, 0x04a11020},
2c609999 6607 {0x21, 0x0421101f}),
200afc09 6608 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED,
aec856d0 6609 ALC282_STANDARD_PINS,
200afc09 6610 {0x12, 0x90a60140},
200afc09 6611 {0x19, 0x04a11030},
200afc09 6612 {0x21, 0x04211020}),
76c2132e 6613 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
aec856d0 6614 ALC282_STANDARD_PINS,
76c2132e 6615 {0x12, 0x90a60130},
76c2132e
DH
6616 {0x21, 0x0321101f}),
6617 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
6618 {0x12, 0x90a60160},
6619 {0x14, 0x90170120},
76c2132e 6620 {0x21, 0x02211030}),
bc262179 6621 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
aec856d0 6622 ALC282_STANDARD_PINS,
bc262179 6623 {0x12, 0x90a60130},
bc262179 6624 {0x19, 0x03a11020},
bc262179 6625 {0x21, 0x0321101f}),
e1e62b98 6626 SND_HDA_PIN_QUIRK(0x10ec0288, 0x1028, "Dell", ALC288_FIXUP_DELL_XPS_13_GPIO6,
e1e62b98 6627 {0x12, 0x90a60120},
e1e62b98 6628 {0x14, 0x90170110},
e1e62b98 6629 {0x21, 0x0321101f}),
e4442bcf 6630 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 6631 ALC290_STANDARD_PINS,
e4442bcf 6632 {0x15, 0x04211040},
e4442bcf 6633 {0x18, 0x90170112},
11580297 6634 {0x1a, 0x04a11020}),
e4442bcf 6635 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 6636 ALC290_STANDARD_PINS,
e4442bcf 6637 {0x15, 0x04211040},
e4442bcf 6638 {0x18, 0x90170110},
11580297 6639 {0x1a, 0x04a11020}),
e4442bcf 6640 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 6641 ALC290_STANDARD_PINS,
e4442bcf 6642 {0x15, 0x0421101f},
11580297 6643 {0x1a, 0x04a11020}),
e4442bcf 6644 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 6645 ALC290_STANDARD_PINS,
e4442bcf 6646 {0x15, 0x04211020},
11580297 6647 {0x1a, 0x04a11040}),
e4442bcf 6648 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 6649 ALC290_STANDARD_PINS,
e4442bcf
HW
6650 {0x14, 0x90170110},
6651 {0x15, 0x04211020},
11580297 6652 {0x1a, 0x04a11040}),
e4442bcf 6653 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 6654 ALC290_STANDARD_PINS,
e4442bcf
HW
6655 {0x14, 0x90170110},
6656 {0x15, 0x04211020},
11580297 6657 {0x1a, 0x04a11020}),
e4442bcf 6658 SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
aec856d0 6659 ALC290_STANDARD_PINS,
e4442bcf
HW
6660 {0x14, 0x90170110},
6661 {0x15, 0x0421101f},
11580297 6662 {0x1a, 0x04a11020}),
e8818fa8 6663 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
aec856d0 6664 ALC292_STANDARD_PINS,
e8818fa8 6665 {0x12, 0x90a60140},
e8818fa8 6666 {0x16, 0x01014020},
11580297 6667 {0x19, 0x01a19030}),
e8818fa8 6668 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
aec856d0 6669 ALC292_STANDARD_PINS,
e8818fa8 6670 {0x12, 0x90a60140},
e8818fa8
HW
6671 {0x16, 0x01014020},
6672 {0x18, 0x02a19031},
11580297 6673 {0x19, 0x01a1903e}),
76c2132e 6674 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
aec856d0 6675 ALC292_STANDARD_PINS,
11580297 6676 {0x12, 0x90a60140}),
76c2132e 6677 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
aec856d0 6678 ALC292_STANDARD_PINS,
76c2132e 6679 {0x13, 0x90a60140},
76c2132e 6680 {0x16, 0x21014020},
11580297 6681 {0x19, 0x21a19030}),
e03fdbde 6682 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
aec856d0 6683 ALC292_STANDARD_PINS,
11580297 6684 {0x13, 0x90a60140}),
3f640970 6685 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
f771d5bb
HW
6686 ALC295_STANDARD_PINS,
6687 {0x17, 0x21014020},
6688 {0x18, 0x21a19030}),
6689 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
6690 ALC295_STANDARD_PINS,
6691 {0x17, 0x21014040},
6692 {0x18, 0x21a19050}),
3f307834
HW
6693 SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
6694 ALC295_STANDARD_PINS),
9f502ff5
TI
6695 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
6696 ALC298_STANDARD_PINS,
6697 {0x17, 0x90170110}),
977e6276 6698 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
703867e2
WS
6699 ALC298_STANDARD_PINS,
6700 {0x17, 0x90170140}),
6701 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
6702 ALC298_STANDARD_PINS,
9f502ff5 6703 {0x17, 0x90170150}),
9f1bc2c4
KHF
6704 SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_SPK_VOLUME,
6705 {0x12, 0xb7a60140},
6706 {0x13, 0xb7a60150},
6707 {0x17, 0x90170110},
6708 {0x1a, 0x03011020},
6709 {0x21, 0x03211030}),
fcc6c877
KY
6710 SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
6711 ALC225_STANDARD_PINS,
6712 {0x12, 0xb7a60130},
fcc6c877 6713 {0x17, 0x90170110}),
e1918938
HW
6714 {}
6715};
6dda9f4a 6716
546bb678 6717static void alc269_fill_coef(struct hda_codec *codec)
1d045db9 6718{
526af6eb 6719 struct alc_spec *spec = codec->spec;
1d045db9 6720 int val;
ebb83eeb 6721
526af6eb 6722 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
546bb678 6723 return;
526af6eb 6724
1bb7e43e 6725 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
1d045db9
TI
6726 alc_write_coef_idx(codec, 0xf, 0x960b);
6727 alc_write_coef_idx(codec, 0xe, 0x8817);
6728 }
ebb83eeb 6729
1bb7e43e 6730 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
1d045db9
TI
6731 alc_write_coef_idx(codec, 0xf, 0x960b);
6732 alc_write_coef_idx(codec, 0xe, 0x8814);
6733 }
ebb83eeb 6734
1bb7e43e 6735 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
1d045db9 6736 /* Power up output pin */
98b24883 6737 alc_update_coef_idx(codec, 0x04, 0, 1<<11);
1d045db9 6738 }
ebb83eeb 6739
1bb7e43e 6740 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
1d045db9 6741 val = alc_read_coef_idx(codec, 0xd);
f3ee07d8 6742 if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
1d045db9
TI
6743 /* Capless ramp up clock control */
6744 alc_write_coef_idx(codec, 0xd, val | (1<<10));
6745 }
6746 val = alc_read_coef_idx(codec, 0x17);
f3ee07d8 6747 if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
1d045db9
TI
6748 /* Class D power on reset */
6749 alc_write_coef_idx(codec, 0x17, val | (1<<7));
6750 }
6751 }
ebb83eeb 6752
98b24883
TI
6753 /* HP */
6754 alc_update_coef_idx(codec, 0x4, 0, 1<<11);
1d045db9 6755}
a7f2371f 6756
1d045db9
TI
6757/*
6758 */
1d045db9
TI
6759static int patch_alc269(struct hda_codec *codec)
6760{
6761 struct alc_spec *spec;
3de95173 6762 int err;
f1d4e28b 6763
3de95173 6764 err = alc_alloc_spec(codec, 0x0b);
e16fb6d1 6765 if (err < 0)
3de95173
TI
6766 return err;
6767
6768 spec = codec->spec;
08c189f2 6769 spec->gen.shared_mic_vref_pin = 0x18;
8b99aba7 6770 codec->power_save_node = 1;
e16fb6d1 6771
225068ab
TI
6772#ifdef CONFIG_PM
6773 codec->patch_ops.suspend = alc269_suspend;
6774 codec->patch_ops.resume = alc269_resume;
6775#endif
c2d6af53
KY
6776 spec->shutup = alc_default_shutup;
6777 spec->init_hook = alc_default_init;
225068ab 6778
1727a771 6779 snd_hda_pick_fixup(codec, alc269_fixup_models,
9f720bb9 6780 alc269_fixup_tbl, alc269_fixups);
e1918938 6781 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups);
214eef76
DH
6782 snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
6783 alc269_fixups);
1727a771 6784 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9f720bb9
HRK
6785
6786 alc_auto_parse_customize_define(codec);
6787
7504b6cd
TI
6788 if (has_cdefine_beep(codec))
6789 spec->gen.beep_nid = 0x01;
6790
7639a06c 6791 switch (codec->core.vendor_id) {
065380f0 6792 case 0x10ec0269:
1d045db9 6793 spec->codec_variant = ALC269_TYPE_ALC269VA;
1bb7e43e
TI
6794 switch (alc_get_coef0(codec) & 0x00f0) {
6795 case 0x0010:
5100cd07
TI
6796 if (codec->bus->pci &&
6797 codec->bus->pci->subsystem_vendor == 0x1025 &&
e16fb6d1 6798 spec->cdefine.platform_type == 1)
20ca0c35 6799 err = alc_codec_rename(codec, "ALC271X");
1d045db9 6800 spec->codec_variant = ALC269_TYPE_ALC269VB;
1bb7e43e
TI
6801 break;
6802 case 0x0020:
5100cd07
TI
6803 if (codec->bus->pci &&
6804 codec->bus->pci->subsystem_vendor == 0x17aa &&
e16fb6d1 6805 codec->bus->pci->subsystem_device == 0x21f3)
20ca0c35 6806 err = alc_codec_rename(codec, "ALC3202");
1d045db9 6807 spec->codec_variant = ALC269_TYPE_ALC269VC;
1bb7e43e 6808 break;
adcc70b2
KY
6809 case 0x0030:
6810 spec->codec_variant = ALC269_TYPE_ALC269VD;
6811 break;
1bb7e43e 6812 default:
1d045db9 6813 alc_fix_pll_init(codec, 0x20, 0x04, 15);
1bb7e43e 6814 }
e16fb6d1
TI
6815 if (err < 0)
6816 goto error;
c2d6af53 6817 spec->shutup = alc269_shutup;
546bb678 6818 spec->init_hook = alc269_fill_coef;
1d045db9 6819 alc269_fill_coef(codec);
065380f0
KY
6820 break;
6821
6822 case 0x10ec0280:
6823 case 0x10ec0290:
6824 spec->codec_variant = ALC269_TYPE_ALC280;
6825 break;
6826 case 0x10ec0282:
065380f0 6827 spec->codec_variant = ALC269_TYPE_ALC282;
7b5c7a02
KY
6828 spec->shutup = alc282_shutup;
6829 spec->init_hook = alc282_init;
065380f0 6830 break;
2af02be7
KY
6831 case 0x10ec0233:
6832 case 0x10ec0283:
6833 spec->codec_variant = ALC269_TYPE_ALC283;
6834 spec->shutup = alc283_shutup;
6835 spec->init_hook = alc283_init;
6836 break;
065380f0
KY
6837 case 0x10ec0284:
6838 case 0x10ec0292:
6839 spec->codec_variant = ALC269_TYPE_ALC284;
6840 break;
161ebf29 6841 case 0x10ec0293:
4731d5de 6842 spec->codec_variant = ALC269_TYPE_ALC293;
161ebf29 6843 break;
7fc7d047 6844 case 0x10ec0286:
7c665932 6845 case 0x10ec0288:
7fc7d047 6846 spec->codec_variant = ALC269_TYPE_ALC286;
f7ae9ba0 6847 spec->shutup = alc286_shutup;
7fc7d047 6848 break;
506b62c3
KY
6849 case 0x10ec0298:
6850 spec->codec_variant = ALC269_TYPE_ALC298;
6851 break;
1d04c9de
KY
6852 case 0x10ec0255:
6853 spec->codec_variant = ALC269_TYPE_ALC255;
6854 break;
736f20a7 6855 case 0x10ec0236:
4344aec8
KY
6856 case 0x10ec0256:
6857 spec->codec_variant = ALC269_TYPE_ALC256;
4a219ef8
KY
6858 spec->shutup = alc256_shutup;
6859 spec->init_hook = alc256_init;
7d1b6e29 6860 spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
d32b6666 6861 alc_update_coef_idx(codec, 0x36, 1 << 13, 1 << 5); /* Switch pcbeep path to Line in path*/
4344aec8 6862 break;
0a6f0600
KY
6863 case 0x10ec0215:
6864 case 0x10ec0285:
6865 case 0x10ec0289:
6866 spec->codec_variant = ALC269_TYPE_ALC215;
6867 spec->gen.mixer_nid = 0;
6868 break;
4231430d 6869 case 0x10ec0225:
7d727869 6870 case 0x10ec0295:
fa16b69f 6871 spec->codec_variant = ALC269_TYPE_ALC225;
e674ac9a 6872 spec->gen.mixer_nid = 0; /* no loopback on ALC225 ALC295 */
fa16b69f 6873 break;
28f1f9b2 6874 case 0x10ec0299:
4231430d 6875 spec->codec_variant = ALC269_TYPE_ALC225;
fa16b69f 6876 spec->gen.mixer_nid = 0; /* no loopback on ALC299 */
4231430d 6877 break;
dcd4f0db
KY
6878 case 0x10ec0234:
6879 case 0x10ec0274:
6880 case 0x10ec0294:
6881 spec->codec_variant = ALC269_TYPE_ALC294;
532a7784 6882 spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
71683c32 6883 alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
dcd4f0db 6884 break;
6fbae35a
KY
6885 case 0x10ec0700:
6886 case 0x10ec0701:
6887 case 0x10ec0703:
6888 spec->codec_variant = ALC269_TYPE_ALC700;
6889 spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
6890 alc_update_coef_idx(codec, 0x4a, 0, 1 << 15); /* Combo jack auto trigger control */
6891 break;
6892
1d045db9 6893 }
6dda9f4a 6894
ad60d502 6895 if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
97a26570 6896 spec->has_alc5505_dsp = 1;
ad60d502
KY
6897 spec->init_hook = alc5505_dsp_init;
6898 }
6899
a4297b5d
TI
6900 /* automatic parse from the BIOS config */
6901 err = alc269_parse_auto_config(codec);
e16fb6d1
TI
6902 if (err < 0)
6903 goto error;
6dda9f4a 6904
7d1b6e29
DH
6905 if (!spec->gen.no_analog && spec->gen.beep_nid && spec->gen.mixer_nid)
6906 set_beep_amp(spec, spec->gen.mixer_nid, 0x04, HDA_INPUT);
f1d4e28b 6907
1727a771 6908 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 6909
1d045db9 6910 return 0;
e16fb6d1
TI
6911
6912 error:
6913 alc_free(codec);
6914 return err;
1d045db9 6915}
f1d4e28b 6916
1d045db9
TI
6917/*
6918 * ALC861
6919 */
622e84cd 6920
1d045db9 6921static int alc861_parse_auto_config(struct hda_codec *codec)
6dda9f4a 6922{
1d045db9 6923 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
3e6179b8
TI
6924 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
6925 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
604401a9
TI
6926}
6927
1d045db9
TI
6928/* Pin config fixes */
6929enum {
e652f4c8
TI
6930 ALC861_FIXUP_FSC_AMILO_PI1505,
6931 ALC861_FIXUP_AMP_VREF_0F,
6932 ALC861_FIXUP_NO_JACK_DETECT,
6933 ALC861_FIXUP_ASUS_A6RP,
6ddf0fd1 6934 ALC660_FIXUP_ASUS_W7J,
1d045db9 6935};
7085ec12 6936
31150f23
TI
6937/* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
6938static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
1727a771 6939 const struct hda_fixup *fix, int action)
31150f23
TI
6940{
6941 struct alc_spec *spec = codec->spec;
6942 unsigned int val;
6943
1727a771 6944 if (action != HDA_FIXUP_ACT_INIT)
31150f23 6945 return;
d3f02d60 6946 val = snd_hda_codec_get_pin_target(codec, 0x0f);
31150f23
TI
6947 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
6948 val |= AC_PINCTL_IN_EN;
6949 val |= AC_PINCTL_VREF_50;
cdd03ced 6950 snd_hda_set_pin_ctl(codec, 0x0f, val);
08c189f2 6951 spec->gen.keep_vref_in_automute = 1;
31150f23
TI
6952}
6953
e652f4c8
TI
6954/* suppress the jack-detection */
6955static void alc_fixup_no_jack_detect(struct hda_codec *codec,
1727a771 6956 const struct hda_fixup *fix, int action)
e652f4c8 6957{
1727a771 6958 if (action == HDA_FIXUP_ACT_PRE_PROBE)
e652f4c8 6959 codec->no_jack_detect = 1;
7d7eb9ea 6960}
e652f4c8 6961
1727a771 6962static const struct hda_fixup alc861_fixups[] = {
e652f4c8 6963 [ALC861_FIXUP_FSC_AMILO_PI1505] = {
1727a771
TI
6964 .type = HDA_FIXUP_PINS,
6965 .v.pins = (const struct hda_pintbl[]) {
1d045db9
TI
6966 { 0x0b, 0x0221101f }, /* HP */
6967 { 0x0f, 0x90170310 }, /* speaker */
6968 { }
6969 }
6970 },
e652f4c8 6971 [ALC861_FIXUP_AMP_VREF_0F] = {
1727a771 6972 .type = HDA_FIXUP_FUNC,
31150f23 6973 .v.func = alc861_fixup_asus_amp_vref_0f,
3b25eb69 6974 },
e652f4c8 6975 [ALC861_FIXUP_NO_JACK_DETECT] = {
1727a771 6976 .type = HDA_FIXUP_FUNC,
e652f4c8
TI
6977 .v.func = alc_fixup_no_jack_detect,
6978 },
6979 [ALC861_FIXUP_ASUS_A6RP] = {
1727a771 6980 .type = HDA_FIXUP_FUNC,
e652f4c8
TI
6981 .v.func = alc861_fixup_asus_amp_vref_0f,
6982 .chained = true,
6983 .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
6ddf0fd1
TI
6984 },
6985 [ALC660_FIXUP_ASUS_W7J] = {
6986 .type = HDA_FIXUP_VERBS,
6987 .v.verbs = (const struct hda_verb[]) {
6988 /* ASUS W7J needs a magic pin setup on unused NID 0x10
6989 * for enabling outputs
6990 */
6991 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6992 { }
6993 },
e652f4c8 6994 }
1d045db9 6995};
7085ec12 6996
1d045db9 6997static const struct snd_pci_quirk alc861_fixup_tbl[] = {
6ddf0fd1 6998 SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
e7ca237b 6999 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
e652f4c8
TI
7000 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
7001 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
7002 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
7003 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
7004 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
7005 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
1d045db9
TI
7006 {}
7007};
3af9ee6b 7008
1d045db9
TI
7009/*
7010 */
1d045db9 7011static int patch_alc861(struct hda_codec *codec)
7085ec12 7012{
1d045db9 7013 struct alc_spec *spec;
1d045db9 7014 int err;
7085ec12 7015
3de95173
TI
7016 err = alc_alloc_spec(codec, 0x15);
7017 if (err < 0)
7018 return err;
1d045db9 7019
3de95173 7020 spec = codec->spec;
7504b6cd 7021 spec->gen.beep_nid = 0x23;
1d045db9 7022
225068ab
TI
7023#ifdef CONFIG_PM
7024 spec->power_hook = alc_power_eapd;
7025#endif
7026
1727a771
TI
7027 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
7028 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
3af9ee6b 7029
cb4e4824
TI
7030 /* automatic parse from the BIOS config */
7031 err = alc861_parse_auto_config(codec);
e16fb6d1
TI
7032 if (err < 0)
7033 goto error;
3af9ee6b 7034
7504b6cd 7035 if (!spec->gen.no_analog)
3e6179b8 7036 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
7085ec12 7037
1727a771 7038 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 7039
1d045db9 7040 return 0;
e16fb6d1
TI
7041
7042 error:
7043 alc_free(codec);
7044 return err;
7085ec12
TI
7045}
7046
1d045db9
TI
7047/*
7048 * ALC861-VD support
7049 *
7050 * Based on ALC882
7051 *
7052 * In addition, an independent DAC
7053 */
1d045db9 7054static int alc861vd_parse_auto_config(struct hda_codec *codec)
bc9f98a9 7055{
1d045db9 7056 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
3e6179b8
TI
7057 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
7058 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
ce764ab2
TI
7059}
7060
1d045db9 7061enum {
8fdcb6fe
TI
7062 ALC660VD_FIX_ASUS_GPIO1,
7063 ALC861VD_FIX_DALLAS,
1d045db9 7064};
ce764ab2 7065
8fdcb6fe
TI
7066/* exclude VREF80 */
7067static void alc861vd_fixup_dallas(struct hda_codec *codec,
1727a771 7068 const struct hda_fixup *fix, int action)
8fdcb6fe 7069{
1727a771 7070 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
b78562b1
TI
7071 snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
7072 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
8fdcb6fe
TI
7073 }
7074}
7075
1727a771 7076static const struct hda_fixup alc861vd_fixups[] = {
1d045db9 7077 [ALC660VD_FIX_ASUS_GPIO1] = {
1727a771 7078 .type = HDA_FIXUP_VERBS,
1d045db9 7079 .v.verbs = (const struct hda_verb[]) {
8fdcb6fe 7080 /* reset GPIO1 */
1d045db9
TI
7081 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7082 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
7083 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
7084 { }
7085 }
7086 },
8fdcb6fe 7087 [ALC861VD_FIX_DALLAS] = {
1727a771 7088 .type = HDA_FIXUP_FUNC,
8fdcb6fe
TI
7089 .v.func = alc861vd_fixup_dallas,
7090 },
1d045db9 7091};
ce764ab2 7092
1d045db9 7093static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
8fdcb6fe 7094 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
1d045db9 7095 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
8fdcb6fe 7096 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
1d045db9
TI
7097 {}
7098};
ce764ab2 7099
1d045db9
TI
7100/*
7101 */
1d045db9 7102static int patch_alc861vd(struct hda_codec *codec)
ce764ab2 7103{
1d045db9 7104 struct alc_spec *spec;
cb4e4824 7105 int err;
ce764ab2 7106
3de95173
TI
7107 err = alc_alloc_spec(codec, 0x0b);
7108 if (err < 0)
7109 return err;
1d045db9 7110
3de95173 7111 spec = codec->spec;
7504b6cd 7112 spec->gen.beep_nid = 0x23;
1d045db9 7113
225068ab
TI
7114 spec->shutup = alc_eapd_shutup;
7115
1727a771
TI
7116 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
7117 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1d045db9 7118
cb4e4824
TI
7119 /* automatic parse from the BIOS config */
7120 err = alc861vd_parse_auto_config(codec);
e16fb6d1
TI
7121 if (err < 0)
7122 goto error;
ce764ab2 7123
7504b6cd 7124 if (!spec->gen.no_analog)
3e6179b8 7125 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1d045db9 7126
1727a771 7127 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 7128
ce764ab2 7129 return 0;
e16fb6d1
TI
7130
7131 error:
7132 alc_free(codec);
7133 return err;
ce764ab2
TI
7134}
7135
1d045db9
TI
7136/*
7137 * ALC662 support
7138 *
7139 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
7140 * configuration. Each pin widget can choose any input DACs and a mixer.
7141 * Each ADC is connected from a mixer of all inputs. This makes possible
7142 * 6-channel independent captures.
7143 *
7144 * In addition, an independent DAC for the multi-playback (not used in this
7145 * driver yet).
7146 */
1d045db9
TI
7147
7148/*
7149 * BIOS auto configuration
7150 */
7151
bc9f98a9
KY
7152static int alc662_parse_auto_config(struct hda_codec *codec)
7153{
4c6d72d1 7154 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
3e6179b8
TI
7155 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
7156 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
7157 const hda_nid_t *ssids;
ee979a14 7158
7639a06c
TI
7159 if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
7160 codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
7161 codec->core.vendor_id == 0x10ec0671)
3e6179b8 7162 ssids = alc663_ssids;
6227cdce 7163 else
3e6179b8
TI
7164 ssids = alc662_ssids;
7165 return alc_parse_auto_config(codec, alc662_ignore, ssids);
bc9f98a9
KY
7166}
7167
6be7948f 7168static void alc272_fixup_mario(struct hda_codec *codec,
1727a771 7169 const struct hda_fixup *fix, int action)
6fc398cb 7170{
9bb1f06f 7171 if (action != HDA_FIXUP_ACT_PRE_PROBE)
6fc398cb 7172 return;
6be7948f
TB
7173 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
7174 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
7175 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
7176 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
7177 (0 << AC_AMPCAP_MUTE_SHIFT)))
4e76a883 7178 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
6be7948f
TB
7179}
7180
8e383953
TI
7181static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
7182 { .channels = 2,
7183 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
7184 { .channels = 4,
7185 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
7186 SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
7187 { }
7188};
7189
7190/* override the 2.1 chmap */
eb9ca3ab 7191static void alc_fixup_bass_chmap(struct hda_codec *codec,
8e383953
TI
7192 const struct hda_fixup *fix, int action)
7193{
7194 if (action == HDA_FIXUP_ACT_BUILD) {
7195 struct alc_spec *spec = codec->spec;
bbbc7e85 7196 spec->gen.pcm_rec[0]->stream[0].chmap = asus_pcm_2_1_chmaps;
8e383953
TI
7197 }
7198}
7199
bf68665d
TI
7200/* avoid D3 for keeping GPIO up */
7201static unsigned int gpio_led_power_filter(struct hda_codec *codec,
7202 hda_nid_t nid,
7203 unsigned int power_state)
7204{
7205 struct alc_spec *spec = codec->spec;
7639a06c 7206 if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_led)
bf68665d
TI
7207 return AC_PWRST_D0;
7208 return power_state;
7209}
7210
3e887f37
TI
7211static void alc662_fixup_led_gpio1(struct hda_codec *codec,
7212 const struct hda_fixup *fix, int action)
7213{
7214 struct alc_spec *spec = codec->spec;
7215 static const struct hda_verb gpio_init[] = {
7216 { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
7217 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
7218 {}
7219 };
7220
7221 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
0f32fd19 7222 spec->gen.vmaster_mute.hook = alc_fixup_gpio_mute_hook;
3e887f37 7223 spec->gpio_led = 0;
0f32fd19
TI
7224 spec->mute_led_polarity = 1;
7225 spec->gpio_mute_led_mask = 0x01;
3e887f37 7226 snd_hda_add_verbs(codec, gpio_init);
bf68665d 7227 codec->power_filter = gpio_led_power_filter;
3e887f37
TI
7228 }
7229}
7230
c6790c8e
KY
7231static void alc662_usi_automute_hook(struct hda_codec *codec,
7232 struct hda_jack_callback *jack)
7233{
7234 struct alc_spec *spec = codec->spec;
7235 int vref;
7236 msleep(200);
7237 snd_hda_gen_hp_automute(codec, jack);
7238
7239 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
7240 msleep(100);
7241 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7242 vref);
7243}
7244
7245static void alc662_fixup_usi_headset_mic(struct hda_codec *codec,
7246 const struct hda_fixup *fix, int action)
7247{
7248 struct alc_spec *spec = codec->spec;
7249 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
7250 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
7251 spec->gen.hp_automute_hook = alc662_usi_automute_hook;
7252 }
7253}
7254
f3f9185f
KY
7255static struct coef_fw alc668_coefs[] = {
7256 WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03, 0x0),
7257 WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06, 0x0), WRITE_COEF(0x07, 0x0f80),
7258 WRITE_COEF(0x08, 0x0031), WRITE_COEF(0x0a, 0x0060), WRITE_COEF(0x0b, 0x0),
7259 WRITE_COEF(0x0c, 0x7cf7), WRITE_COEF(0x0d, 0x1080), WRITE_COEF(0x0e, 0x7f7f),
7260 WRITE_COEF(0x0f, 0xcccc), WRITE_COEF(0x10, 0xddcc), WRITE_COEF(0x11, 0x0001),
7261 WRITE_COEF(0x13, 0x0), WRITE_COEF(0x14, 0x2aa0), WRITE_COEF(0x17, 0xa940),
7262 WRITE_COEF(0x19, 0x0), WRITE_COEF(0x1a, 0x0), WRITE_COEF(0x1b, 0x0),
7263 WRITE_COEF(0x1c, 0x0), WRITE_COEF(0x1d, 0x0), WRITE_COEF(0x1e, 0x7418),
7264 WRITE_COEF(0x1f, 0x0804), WRITE_COEF(0x20, 0x4200), WRITE_COEF(0x21, 0x0468),
7265 WRITE_COEF(0x22, 0x8ccc), WRITE_COEF(0x23, 0x0250), WRITE_COEF(0x24, 0x7418),
7266 WRITE_COEF(0x27, 0x0), WRITE_COEF(0x28, 0x8ccc), WRITE_COEF(0x2a, 0xff00),
7267 WRITE_COEF(0x2b, 0x8000), WRITE_COEF(0xa7, 0xff00), WRITE_COEF(0xa8, 0x8000),
7268 WRITE_COEF(0xaa, 0x2e17), WRITE_COEF(0xab, 0xa0c0), WRITE_COEF(0xac, 0x0),
7269 WRITE_COEF(0xad, 0x0), WRITE_COEF(0xae, 0x2ac6), WRITE_COEF(0xaf, 0xa480),
7270 WRITE_COEF(0xb0, 0x0), WRITE_COEF(0xb1, 0x0), WRITE_COEF(0xb2, 0x0),
7271 WRITE_COEF(0xb3, 0x0), WRITE_COEF(0xb4, 0x0), WRITE_COEF(0xb5, 0x1040),
7272 WRITE_COEF(0xb6, 0xd697), WRITE_COEF(0xb7, 0x902b), WRITE_COEF(0xb8, 0xd697),
7273 WRITE_COEF(0xb9, 0x902b), WRITE_COEF(0xba, 0xb8ba), WRITE_COEF(0xbb, 0xaaab),
7274 WRITE_COEF(0xbc, 0xaaaf), WRITE_COEF(0xbd, 0x6aaa), WRITE_COEF(0xbe, 0x1c02),
7275 WRITE_COEF(0xc0, 0x00ff), WRITE_COEF(0xc1, 0x0fa6),
7276 {}
7277};
7278
7279static void alc668_restore_default_value(struct hda_codec *codec)
7280{
7281 alc_process_coef_fw(codec, alc668_coefs);
7282}
7283
6cb3b707 7284enum {
2df03514 7285 ALC662_FIXUP_ASPIRE,
3e887f37 7286 ALC662_FIXUP_LED_GPIO1,
6cb3b707 7287 ALC662_FIXUP_IDEAPAD,
6be7948f 7288 ALC272_FIXUP_MARIO,
d2ebd479 7289 ALC662_FIXUP_CZC_P10T,
94024cd1 7290 ALC662_FIXUP_SKU_IGNORE,
e59ea3ed 7291 ALC662_FIXUP_HP_RP5800,
53c334ad
TI
7292 ALC662_FIXUP_ASUS_MODE1,
7293 ALC662_FIXUP_ASUS_MODE2,
7294 ALC662_FIXUP_ASUS_MODE3,
7295 ALC662_FIXUP_ASUS_MODE4,
7296 ALC662_FIXUP_ASUS_MODE5,
7297 ALC662_FIXUP_ASUS_MODE6,
7298 ALC662_FIXUP_ASUS_MODE7,
7299 ALC662_FIXUP_ASUS_MODE8,
1565cc35 7300 ALC662_FIXUP_NO_JACK_DETECT,
edfe3bfc 7301 ALC662_FIXUP_ZOTAC_Z68,
125821ae 7302 ALC662_FIXUP_INV_DMIC,
1f8b46cd 7303 ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
73bdd597 7304 ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
1f8b46cd 7305 ALC662_FIXUP_HEADSET_MODE,
73bdd597 7306 ALC668_FIXUP_HEADSET_MODE,
8e54b4ac 7307 ALC662_FIXUP_BASS_MODE4_CHMAP,
61a75f13 7308 ALC662_FIXUP_BASS_16,
a30c9aaa 7309 ALC662_FIXUP_BASS_1A,
8e54b4ac 7310 ALC662_FIXUP_BASS_CHMAP,
493a52a9 7311 ALC668_FIXUP_AUTO_MUTE,
5e6db669 7312 ALC668_FIXUP_DELL_DISABLE_AAMIX,
033b0a7c 7313 ALC668_FIXUP_DELL_XPS13,
9d4dc584 7314 ALC662_FIXUP_ASUS_Nx50,
fc7438b1 7315 ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
3231e205 7316 ALC668_FIXUP_ASUS_Nx51,
78f4f7c2
KY
7317 ALC891_FIXUP_HEADSET_MODE,
7318 ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
9b51fe3e 7319 ALC662_FIXUP_ACER_VERITON,
1a3f0991 7320 ALC892_FIXUP_ASROCK_MOBO,
c6790c8e
KY
7321 ALC662_FIXUP_USI_FUNC,
7322 ALC662_FIXUP_USI_HEADSET_MODE,
ca169cc2 7323 ALC662_FIXUP_LENOVO_MULTI_CODECS,
6cb3b707
DH
7324};
7325
1727a771 7326static const struct hda_fixup alc662_fixups[] = {
2df03514 7327 [ALC662_FIXUP_ASPIRE] = {
1727a771
TI
7328 .type = HDA_FIXUP_PINS,
7329 .v.pins = (const struct hda_pintbl[]) {
2df03514
DC
7330 { 0x15, 0x99130112 }, /* subwoofer */
7331 { }
7332 }
7333 },
3e887f37
TI
7334 [ALC662_FIXUP_LED_GPIO1] = {
7335 .type = HDA_FIXUP_FUNC,
7336 .v.func = alc662_fixup_led_gpio1,
7337 },
6cb3b707 7338 [ALC662_FIXUP_IDEAPAD] = {
1727a771
TI
7339 .type = HDA_FIXUP_PINS,
7340 .v.pins = (const struct hda_pintbl[]) {
6cb3b707
DH
7341 { 0x17, 0x99130112 }, /* subwoofer */
7342 { }
3e887f37
TI
7343 },
7344 .chained = true,
7345 .chain_id = ALC662_FIXUP_LED_GPIO1,
6cb3b707 7346 },
6be7948f 7347 [ALC272_FIXUP_MARIO] = {
1727a771 7348 .type = HDA_FIXUP_FUNC,
b5bfbc67 7349 .v.func = alc272_fixup_mario,
d2ebd479
AA
7350 },
7351 [ALC662_FIXUP_CZC_P10T] = {
1727a771 7352 .type = HDA_FIXUP_VERBS,
d2ebd479
AA
7353 .v.verbs = (const struct hda_verb[]) {
7354 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
7355 {}
7356 }
7357 },
94024cd1 7358 [ALC662_FIXUP_SKU_IGNORE] = {
1727a771 7359 .type = HDA_FIXUP_FUNC,
23d30f28 7360 .v.func = alc_fixup_sku_ignore,
c6b35874 7361 },
e59ea3ed 7362 [ALC662_FIXUP_HP_RP5800] = {
1727a771
TI
7363 .type = HDA_FIXUP_PINS,
7364 .v.pins = (const struct hda_pintbl[]) {
e59ea3ed
TI
7365 { 0x14, 0x0221201f }, /* HP out */
7366 { }
7367 },
7368 .chained = true,
7369 .chain_id = ALC662_FIXUP_SKU_IGNORE
7370 },
53c334ad 7371 [ALC662_FIXUP_ASUS_MODE1] = {
1727a771
TI
7372 .type = HDA_FIXUP_PINS,
7373 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
7374 { 0x14, 0x99130110 }, /* speaker */
7375 { 0x18, 0x01a19c20 }, /* mic */
7376 { 0x19, 0x99a3092f }, /* int-mic */
7377 { 0x21, 0x0121401f }, /* HP out */
7378 { }
7379 },
7380 .chained = true,
7381 .chain_id = ALC662_FIXUP_SKU_IGNORE
7382 },
7383 [ALC662_FIXUP_ASUS_MODE2] = {
1727a771
TI
7384 .type = HDA_FIXUP_PINS,
7385 .v.pins = (const struct hda_pintbl[]) {
2996bdba
TI
7386 { 0x14, 0x99130110 }, /* speaker */
7387 { 0x18, 0x01a19820 }, /* mic */
7388 { 0x19, 0x99a3092f }, /* int-mic */
7389 { 0x1b, 0x0121401f }, /* HP out */
7390 { }
7391 },
53c334ad
TI
7392 .chained = true,
7393 .chain_id = ALC662_FIXUP_SKU_IGNORE
7394 },
7395 [ALC662_FIXUP_ASUS_MODE3] = {
1727a771
TI
7396 .type = HDA_FIXUP_PINS,
7397 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
7398 { 0x14, 0x99130110 }, /* speaker */
7399 { 0x15, 0x0121441f }, /* HP */
7400 { 0x18, 0x01a19840 }, /* mic */
7401 { 0x19, 0x99a3094f }, /* int-mic */
7402 { 0x21, 0x01211420 }, /* HP2 */
7403 { }
7404 },
7405 .chained = true,
7406 .chain_id = ALC662_FIXUP_SKU_IGNORE
7407 },
7408 [ALC662_FIXUP_ASUS_MODE4] = {
1727a771
TI
7409 .type = HDA_FIXUP_PINS,
7410 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
7411 { 0x14, 0x99130110 }, /* speaker */
7412 { 0x16, 0x99130111 }, /* speaker */
7413 { 0x18, 0x01a19840 }, /* mic */
7414 { 0x19, 0x99a3094f }, /* int-mic */
7415 { 0x21, 0x0121441f }, /* HP */
7416 { }
7417 },
7418 .chained = true,
7419 .chain_id = ALC662_FIXUP_SKU_IGNORE
7420 },
7421 [ALC662_FIXUP_ASUS_MODE5] = {
1727a771
TI
7422 .type = HDA_FIXUP_PINS,
7423 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
7424 { 0x14, 0x99130110 }, /* speaker */
7425 { 0x15, 0x0121441f }, /* HP */
7426 { 0x16, 0x99130111 }, /* speaker */
7427 { 0x18, 0x01a19840 }, /* mic */
7428 { 0x19, 0x99a3094f }, /* int-mic */
7429 { }
7430 },
7431 .chained = true,
7432 .chain_id = ALC662_FIXUP_SKU_IGNORE
7433 },
7434 [ALC662_FIXUP_ASUS_MODE6] = {
1727a771
TI
7435 .type = HDA_FIXUP_PINS,
7436 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
7437 { 0x14, 0x99130110 }, /* speaker */
7438 { 0x15, 0x01211420 }, /* HP2 */
7439 { 0x18, 0x01a19840 }, /* mic */
7440 { 0x19, 0x99a3094f }, /* int-mic */
7441 { 0x1b, 0x0121441f }, /* HP */
7442 { }
7443 },
7444 .chained = true,
7445 .chain_id = ALC662_FIXUP_SKU_IGNORE
7446 },
7447 [ALC662_FIXUP_ASUS_MODE7] = {
1727a771
TI
7448 .type = HDA_FIXUP_PINS,
7449 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
7450 { 0x14, 0x99130110 }, /* speaker */
7451 { 0x17, 0x99130111 }, /* speaker */
7452 { 0x18, 0x01a19840 }, /* mic */
7453 { 0x19, 0x99a3094f }, /* int-mic */
7454 { 0x1b, 0x01214020 }, /* HP */
7455 { 0x21, 0x0121401f }, /* HP */
7456 { }
7457 },
7458 .chained = true,
7459 .chain_id = ALC662_FIXUP_SKU_IGNORE
7460 },
7461 [ALC662_FIXUP_ASUS_MODE8] = {
1727a771
TI
7462 .type = HDA_FIXUP_PINS,
7463 .v.pins = (const struct hda_pintbl[]) {
53c334ad
TI
7464 { 0x14, 0x99130110 }, /* speaker */
7465 { 0x12, 0x99a30970 }, /* int-mic */
7466 { 0x15, 0x01214020 }, /* HP */
7467 { 0x17, 0x99130111 }, /* speaker */
7468 { 0x18, 0x01a19840 }, /* mic */
7469 { 0x21, 0x0121401f }, /* HP */
7470 { }
7471 },
7472 .chained = true,
7473 .chain_id = ALC662_FIXUP_SKU_IGNORE
2996bdba 7474 },
1565cc35 7475 [ALC662_FIXUP_NO_JACK_DETECT] = {
1727a771 7476 .type = HDA_FIXUP_FUNC,
1565cc35
TI
7477 .v.func = alc_fixup_no_jack_detect,
7478 },
edfe3bfc 7479 [ALC662_FIXUP_ZOTAC_Z68] = {
1727a771
TI
7480 .type = HDA_FIXUP_PINS,
7481 .v.pins = (const struct hda_pintbl[]) {
edfe3bfc
DH
7482 { 0x1b, 0x02214020 }, /* Front HP */
7483 { }
7484 }
7485 },
125821ae 7486 [ALC662_FIXUP_INV_DMIC] = {
1727a771 7487 .type = HDA_FIXUP_FUNC,
9d36a7dc 7488 .v.func = alc_fixup_inv_dmic,
125821ae 7489 },
033b0a7c
GM
7490 [ALC668_FIXUP_DELL_XPS13] = {
7491 .type = HDA_FIXUP_FUNC,
7492 .v.func = alc_fixup_dell_xps13,
7493 .chained = true,
7494 .chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
7495 },
5e6db669
GM
7496 [ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
7497 .type = HDA_FIXUP_FUNC,
7498 .v.func = alc_fixup_disable_aamix,
7499 .chained = true,
7500 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
7501 },
493a52a9
HW
7502 [ALC668_FIXUP_AUTO_MUTE] = {
7503 .type = HDA_FIXUP_FUNC,
7504 .v.func = alc_fixup_auto_mute_via_amp,
7505 .chained = true,
7506 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
7507 },
1f8b46cd
DH
7508 [ALC662_FIXUP_DELL_MIC_NO_PRESENCE] = {
7509 .type = HDA_FIXUP_PINS,
7510 .v.pins = (const struct hda_pintbl[]) {
7511 { 0x19, 0x03a1113c }, /* use as headset mic, without its own jack detect */
7512 /* headphone mic by setting pin control of 0x1b (headphone out) to in + vref_50 */
7513 { }
7514 },
7515 .chained = true,
7516 .chain_id = ALC662_FIXUP_HEADSET_MODE
7517 },
7518 [ALC662_FIXUP_HEADSET_MODE] = {
7519 .type = HDA_FIXUP_FUNC,
7520 .v.func = alc_fixup_headset_mode_alc662,
7521 },
73bdd597
DH
7522 [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
7523 .type = HDA_FIXUP_PINS,
7524 .v.pins = (const struct hda_pintbl[]) {
7525 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
7526 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
7527 { }
7528 },
7529 .chained = true,
7530 .chain_id = ALC668_FIXUP_HEADSET_MODE
7531 },
7532 [ALC668_FIXUP_HEADSET_MODE] = {
7533 .type = HDA_FIXUP_FUNC,
7534 .v.func = alc_fixup_headset_mode_alc668,
7535 },
8e54b4ac 7536 [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
8e383953 7537 .type = HDA_FIXUP_FUNC,
eb9ca3ab 7538 .v.func = alc_fixup_bass_chmap,
8e383953
TI
7539 .chained = true,
7540 .chain_id = ALC662_FIXUP_ASUS_MODE4
7541 },
61a75f13
DH
7542 [ALC662_FIXUP_BASS_16] = {
7543 .type = HDA_FIXUP_PINS,
7544 .v.pins = (const struct hda_pintbl[]) {
7545 {0x16, 0x80106111}, /* bass speaker */
7546 {}
7547 },
7548 .chained = true,
7549 .chain_id = ALC662_FIXUP_BASS_CHMAP,
7550 },
a30c9aaa
TI
7551 [ALC662_FIXUP_BASS_1A] = {
7552 .type = HDA_FIXUP_PINS,
7553 .v.pins = (const struct hda_pintbl[]) {
7554 {0x1a, 0x80106111}, /* bass speaker */
7555 {}
7556 },
8e54b4ac
DH
7557 .chained = true,
7558 .chain_id = ALC662_FIXUP_BASS_CHMAP,
a30c9aaa 7559 },
8e54b4ac 7560 [ALC662_FIXUP_BASS_CHMAP] = {
a30c9aaa 7561 .type = HDA_FIXUP_FUNC,
eb9ca3ab 7562 .v.func = alc_fixup_bass_chmap,
a30c9aaa 7563 },
9d4dc584
BM
7564 [ALC662_FIXUP_ASUS_Nx50] = {
7565 .type = HDA_FIXUP_FUNC,
7566 .v.func = alc_fixup_auto_mute_via_amp,
7567 .chained = true,
7568 .chain_id = ALC662_FIXUP_BASS_1A
7569 },
fc7438b1
MP
7570 [ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE] = {
7571 .type = HDA_FIXUP_FUNC,
7572 .v.func = alc_fixup_headset_mode_alc668,
7573 .chain_id = ALC662_FIXUP_BASS_CHMAP
7574 },
3231e205
YP
7575 [ALC668_FIXUP_ASUS_Nx51] = {
7576 .type = HDA_FIXUP_PINS,
7577 .v.pins = (const struct hda_pintbl[]) {
fc7438b1
MP
7578 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
7579 { 0x1a, 0x90170151 }, /* bass speaker */
7580 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
3231e205
YP
7581 {}
7582 },
7583 .chained = true,
fc7438b1 7584 .chain_id = ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
3231e205 7585 },
78f4f7c2
KY
7586 [ALC891_FIXUP_HEADSET_MODE] = {
7587 .type = HDA_FIXUP_FUNC,
7588 .v.func = alc_fixup_headset_mode,
7589 },
7590 [ALC891_FIXUP_DELL_MIC_NO_PRESENCE] = {
7591 .type = HDA_FIXUP_PINS,
7592 .v.pins = (const struct hda_pintbl[]) {
7593 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
7594 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
7595 { }
7596 },
7597 .chained = true,
7598 .chain_id = ALC891_FIXUP_HEADSET_MODE
7599 },
9b51fe3e
SB
7600 [ALC662_FIXUP_ACER_VERITON] = {
7601 .type = HDA_FIXUP_PINS,
7602 .v.pins = (const struct hda_pintbl[]) {
7603 { 0x15, 0x50170120 }, /* no internal speaker */
7604 { }
7605 }
7606 },
1a3f0991
TI
7607 [ALC892_FIXUP_ASROCK_MOBO] = {
7608 .type = HDA_FIXUP_PINS,
7609 .v.pins = (const struct hda_pintbl[]) {
7610 { 0x15, 0x40f000f0 }, /* disabled */
7611 { 0x16, 0x40f000f0 }, /* disabled */
1a3f0991
TI
7612 { }
7613 }
7614 },
c6790c8e
KY
7615 [ALC662_FIXUP_USI_FUNC] = {
7616 .type = HDA_FIXUP_FUNC,
7617 .v.func = alc662_fixup_usi_headset_mic,
7618 },
7619 [ALC662_FIXUP_USI_HEADSET_MODE] = {
7620 .type = HDA_FIXUP_PINS,
7621 .v.pins = (const struct hda_pintbl[]) {
7622 { 0x19, 0x02a1913c }, /* use as headset mic, without its own jack detect */
7623 { 0x18, 0x01a1903d },
7624 { }
7625 },
7626 .chained = true,
7627 .chain_id = ALC662_FIXUP_USI_FUNC
7628 },
ca169cc2
KY
7629 [ALC662_FIXUP_LENOVO_MULTI_CODECS] = {
7630 .type = HDA_FIXUP_FUNC,
7631 .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
7632 },
6cb3b707
DH
7633};
7634
a9111321 7635static const struct snd_pci_quirk alc662_fixup_tbl[] = {
53c334ad 7636 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
d3d3835c 7637 SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
02f6ff90 7638 SND_PCI_QUIRK(0x1025, 0x0241, "Packard Bell DOTS", ALC662_FIXUP_INV_DMIC),
a6c47a85 7639 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
94024cd1 7640 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
125821ae 7641 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
1801928e 7642 SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
2df03514 7643 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
73bdd597
DH
7644 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
7645 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
c5d019c3 7646 SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
033b0a7c 7647 SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
467e1436 7648 SND_PCI_QUIRK(0x1028, 0x060d, "Dell M3800", ALC668_FIXUP_DELL_XPS13),
09d2014f 7649 SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
ad8ff99e 7650 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
8dc9abb9
KY
7651 SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
7652 SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
6a98e34b 7653 SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
e59ea3ed 7654 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
2da2dc9e 7655 SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE),
83a9efb5 7656 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
db8948e6 7657 SND_PCI_QUIRK(0x1043, 0x13df, "Asus N550JX", ALC662_FIXUP_BASS_1A),
9d4dc584 7658 SND_PCI_QUIRK(0x1043, 0x129d, "Asus N750", ALC662_FIXUP_ASUS_Nx50),
8e54b4ac 7659 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
61a75f13 7660 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
3231e205
YP
7661 SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
7662 SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
c7efff92 7663 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
61a75f13 7664 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
8e54b4ac 7665 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
1565cc35 7666 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
53c334ad 7667 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
a0e90acc 7668 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
c6790c8e 7669 SND_PCI_QUIRK(0x14cd, 0x5003, "USI", ALC662_FIXUP_USI_HEADSET_MODE),
ca169cc2 7670 SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC662_FIXUP_LENOVO_MULTI_CODECS),
d4118588 7671 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
6cb3b707 7672 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
1a3f0991 7673 SND_PCI_QUIRK(0x1849, 0x5892, "ASRock B150M", ALC892_FIXUP_ASROCK_MOBO),
edfe3bfc 7674 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
9b51fe3e 7675 SND_PCI_QUIRK(0x1b0a, 0x01b8, "ACER Veriton", ALC662_FIXUP_ACER_VERITON),
d2ebd479 7676 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
53c334ad
TI
7677
7678#if 0
7679 /* Below is a quirk table taken from the old code.
7680 * Basically the device should work as is without the fixup table.
7681 * If BIOS doesn't give a proper info, enable the corresponding
7682 * fixup entry.
7d7eb9ea 7683 */
53c334ad
TI
7684 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
7685 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
7686 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
7687 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
7688 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
7689 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
7690 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
7691 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
7692 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
7693 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
7694 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
7695 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
7696 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
7697 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
7698 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
7699 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
7700 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
7701 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
7702 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
7703 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
7704 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
7705 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
7706 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
7707 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
7708 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
7709 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
7710 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
7711 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
7712 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
7713 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
7714 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
7715 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
7716 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
7717 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
7718 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
7719 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
7720 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
7721 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
7722 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
7723 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
7724 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
7725 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
7726 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
7727 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
7728 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
7729 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
7730 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
7731 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
7732 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
7733 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
7734#endif
6cb3b707
DH
7735 {}
7736};
7737
1727a771 7738static const struct hda_model_fixup alc662_fixup_models[] = {
6be7948f 7739 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
53c334ad
TI
7740 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
7741 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
7742 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
7743 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
7744 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
7745 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
7746 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
7747 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
6e72aa5f 7748 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
e32aa85a 7749 {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
ba90d6a6 7750 {.id = ALC662_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
6be7948f
TB
7751 {}
7752};
6cb3b707 7753
532895c5 7754static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
78f4f7c2
KY
7755 SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
7756 {0x17, 0x02211010},
7757 {0x18, 0x01a19030},
7758 {0x1a, 0x01813040},
7759 {0x21, 0x01014020}),
1f8b46cd 7760 SND_HDA_PIN_QUIRK(0x10ec0662, 0x1028, "Dell", ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
1f8b46cd 7761 {0x14, 0x01014010},
1f8b46cd 7762 {0x18, 0x01a19020},
1f8b46cd 7763 {0x1a, 0x0181302f},
11580297 7764 {0x1b, 0x0221401f}),
76c2132e
DH
7765 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
7766 {0x12, 0x99a30130},
7767 {0x14, 0x90170110},
7768 {0x15, 0x0321101f},
11580297 7769 {0x16, 0x03011020}),
76c2132e
DH
7770 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
7771 {0x12, 0x99a30140},
7772 {0x14, 0x90170110},
7773 {0x15, 0x0321101f},
11580297 7774 {0x16, 0x03011020}),
76c2132e
DH
7775 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
7776 {0x12, 0x99a30150},
7777 {0x14, 0x90170110},
7778 {0x15, 0x0321101f},
11580297 7779 {0x16, 0x03011020}),
76c2132e 7780 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
76c2132e
DH
7781 {0x14, 0x90170110},
7782 {0x15, 0x0321101f},
11580297 7783 {0x16, 0x03011020}),
76c2132e
DH
7784 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
7785 {0x12, 0x90a60130},
7786 {0x14, 0x90170110},
11580297 7787 {0x15, 0x0321101f}),
532895c5
HW
7788 {}
7789};
7790
1d045db9
TI
7791/*
7792 */
bc9f98a9
KY
7793static int patch_alc662(struct hda_codec *codec)
7794{
7795 struct alc_spec *spec;
3de95173 7796 int err;
bc9f98a9 7797
3de95173
TI
7798 err = alc_alloc_spec(codec, 0x0b);
7799 if (err < 0)
7800 return err;
bc9f98a9 7801
3de95173 7802 spec = codec->spec;
1f0f4b80 7803
225068ab
TI
7804 spec->shutup = alc_eapd_shutup;
7805
53c334ad
TI
7806 /* handle multiple HPs as is */
7807 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
7808
2c3bf9ab
TI
7809 alc_fix_pll_init(codec, 0x20, 0x04, 15);
7810
7639a06c 7811 switch (codec->core.vendor_id) {
f3f9185f
KY
7812 case 0x10ec0668:
7813 spec->init_hook = alc668_restore_default_value;
7814 break;
f3f9185f 7815 }
8663ff75 7816
1727a771 7817 snd_hda_pick_fixup(codec, alc662_fixup_models,
8e5a0509 7818 alc662_fixup_tbl, alc662_fixups);
532895c5 7819 snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups);
1727a771 7820 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
8e5a0509
TI
7821
7822 alc_auto_parse_customize_define(codec);
7823
7504b6cd
TI
7824 if (has_cdefine_beep(codec))
7825 spec->gen.beep_nid = 0x01;
7826
1bb7e43e 7827 if ((alc_get_coef0(codec) & (1 << 14)) &&
5100cd07 7828 codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
e16fb6d1 7829 spec->cdefine.platform_type == 1) {
6134b1a2
WY
7830 err = alc_codec_rename(codec, "ALC272X");
7831 if (err < 0)
e16fb6d1 7832 goto error;
20ca0c35 7833 }
274693f3 7834
b9c5106c
TI
7835 /* automatic parse from the BIOS config */
7836 err = alc662_parse_auto_config(codec);
e16fb6d1
TI
7837 if (err < 0)
7838 goto error;
bc9f98a9 7839
7504b6cd 7840 if (!spec->gen.no_analog && spec->gen.beep_nid) {
7639a06c 7841 switch (codec->core.vendor_id) {
da00c244
KY
7842 case 0x10ec0662:
7843 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
7844 break;
7845 case 0x10ec0272:
7846 case 0x10ec0663:
7847 case 0x10ec0665:
9ad54547 7848 case 0x10ec0668:
da00c244
KY
7849 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
7850 break;
7851 case 0x10ec0273:
7852 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
7853 break;
7854 }
cec27c89 7855 }
2134ea4f 7856
1727a771 7857 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
589876e2 7858
bc9f98a9 7859 return 0;
801f49d3 7860
e16fb6d1
TI
7861 error:
7862 alc_free(codec);
7863 return err;
b478b998
KY
7864}
7865
d1eb57f4
KY
7866/*
7867 * ALC680 support
7868 */
d1eb57f4 7869
d1eb57f4
KY
7870static int alc680_parse_auto_config(struct hda_codec *codec)
7871{
3e6179b8 7872 return alc_parse_auto_config(codec, NULL, NULL);
d1eb57f4
KY
7873}
7874
d1eb57f4 7875/*
d1eb57f4 7876 */
d1eb57f4
KY
7877static int patch_alc680(struct hda_codec *codec)
7878{
d1eb57f4
KY
7879 int err;
7880
1f0f4b80 7881 /* ALC680 has no aa-loopback mixer */
3de95173
TI
7882 err = alc_alloc_spec(codec, 0);
7883 if (err < 0)
7884 return err;
1f0f4b80 7885
1ebec5f2
TI
7886 /* automatic parse from the BIOS config */
7887 err = alc680_parse_auto_config(codec);
7888 if (err < 0) {
7889 alc_free(codec);
7890 return err;
d1eb57f4
KY
7891 }
7892
d1eb57f4
KY
7893 return 0;
7894}
7895
1da177e4
LT
7896/*
7897 * patch entries
7898 */
b9a94a9c 7899static const struct hda_device_id snd_hda_id_realtek[] = {
0a6f0600 7900 HDA_CODEC_ENTRY(0x10ec0215, "ALC215", patch_alc269),
b9a94a9c 7901 HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
4231430d 7902 HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
b9a94a9c
TI
7903 HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
7904 HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
dcd4f0db 7905 HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
b9a94a9c 7906 HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269),
736f20a7 7907 HDA_CODEC_ENTRY(0x10ec0236, "ALC236", patch_alc269),
b9a94a9c
TI
7908 HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269),
7909 HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269),
7910 HDA_CODEC_ENTRY(0x10ec0260, "ALC260", patch_alc260),
7911 HDA_CODEC_ENTRY(0x10ec0262, "ALC262", patch_alc262),
7912 HDA_CODEC_ENTRY(0x10ec0267, "ALC267", patch_alc268),
7913 HDA_CODEC_ENTRY(0x10ec0268, "ALC268", patch_alc268),
7914 HDA_CODEC_ENTRY(0x10ec0269, "ALC269", patch_alc269),
7915 HDA_CODEC_ENTRY(0x10ec0270, "ALC270", patch_alc269),
7916 HDA_CODEC_ENTRY(0x10ec0272, "ALC272", patch_alc662),
dcd4f0db 7917 HDA_CODEC_ENTRY(0x10ec0274, "ALC274", patch_alc269),
b9a94a9c
TI
7918 HDA_CODEC_ENTRY(0x10ec0275, "ALC275", patch_alc269),
7919 HDA_CODEC_ENTRY(0x10ec0276, "ALC276", patch_alc269),
7920 HDA_CODEC_ENTRY(0x10ec0280, "ALC280", patch_alc269),
7921 HDA_CODEC_ENTRY(0x10ec0282, "ALC282", patch_alc269),
7922 HDA_CODEC_ENTRY(0x10ec0283, "ALC283", patch_alc269),
7923 HDA_CODEC_ENTRY(0x10ec0284, "ALC284", patch_alc269),
0a6f0600 7924 HDA_CODEC_ENTRY(0x10ec0285, "ALC285", patch_alc269),
b9a94a9c
TI
7925 HDA_CODEC_ENTRY(0x10ec0286, "ALC286", patch_alc269),
7926 HDA_CODEC_ENTRY(0x10ec0288, "ALC288", patch_alc269),
0a6f0600 7927 HDA_CODEC_ENTRY(0x10ec0289, "ALC289", patch_alc269),
b9a94a9c
TI
7928 HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
7929 HDA_CODEC_ENTRY(0x10ec0292, "ALC292", patch_alc269),
7930 HDA_CODEC_ENTRY(0x10ec0293, "ALC293", patch_alc269),
dcd4f0db 7931 HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269),
7d727869 7932 HDA_CODEC_ENTRY(0x10ec0295, "ALC295", patch_alc269),
b9a94a9c 7933 HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
28f1f9b2 7934 HDA_CODEC_ENTRY(0x10ec0299, "ALC299", patch_alc269),
b9a94a9c
TI
7935 HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
7936 HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
7937 HDA_CODEC_ENTRY(0x10ec0861, "ALC861", patch_alc861),
7938 HDA_CODEC_ENTRY(0x10ec0862, "ALC861-VD", patch_alc861vd),
7939 HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100002, "ALC662 rev2", patch_alc882),
7940 HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100101, "ALC662 rev1", patch_alc662),
7941 HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100300, "ALC662 rev3", patch_alc662),
7942 HDA_CODEC_ENTRY(0x10ec0663, "ALC663", patch_alc662),
7943 HDA_CODEC_ENTRY(0x10ec0665, "ALC665", patch_alc662),
7944 HDA_CODEC_ENTRY(0x10ec0667, "ALC667", patch_alc662),
7945 HDA_CODEC_ENTRY(0x10ec0668, "ALC668", patch_alc662),
7946 HDA_CODEC_ENTRY(0x10ec0670, "ALC670", patch_alc662),
7947 HDA_CODEC_ENTRY(0x10ec0671, "ALC671", patch_alc662),
7948 HDA_CODEC_ENTRY(0x10ec0680, "ALC680", patch_alc680),
6fbae35a
KY
7949 HDA_CODEC_ENTRY(0x10ec0700, "ALC700", patch_alc269),
7950 HDA_CODEC_ENTRY(0x10ec0701, "ALC701", patch_alc269),
7951 HDA_CODEC_ENTRY(0x10ec0703, "ALC703", patch_alc269),
78f4f7c2 7952 HDA_CODEC_ENTRY(0x10ec0867, "ALC891", patch_alc662),
b9a94a9c
TI
7953 HDA_CODEC_ENTRY(0x10ec0880, "ALC880", patch_alc880),
7954 HDA_CODEC_ENTRY(0x10ec0882, "ALC882", patch_alc882),
7955 HDA_CODEC_ENTRY(0x10ec0883, "ALC883", patch_alc882),
7956 HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100101, "ALC889A", patch_alc882),
7957 HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100103, "ALC889A", patch_alc882),
7958 HDA_CODEC_ENTRY(0x10ec0885, "ALC885", patch_alc882),
7959 HDA_CODEC_ENTRY(0x10ec0887, "ALC887", patch_alc882),
7960 HDA_CODEC_REV_ENTRY(0x10ec0888, 0x100101, "ALC1200", patch_alc882),
7961 HDA_CODEC_ENTRY(0x10ec0888, "ALC888", patch_alc882),
7962 HDA_CODEC_ENTRY(0x10ec0889, "ALC889", patch_alc882),
7963 HDA_CODEC_ENTRY(0x10ec0892, "ALC892", patch_alc662),
7964 HDA_CODEC_ENTRY(0x10ec0899, "ALC898", patch_alc882),
7965 HDA_CODEC_ENTRY(0x10ec0900, "ALC1150", patch_alc882),
65553b12 7966 HDA_CODEC_ENTRY(0x10ec1168, "ALC1220", patch_alc882),
a535ad57 7967 HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
1da177e4
LT
7968 {} /* terminator */
7969};
b9a94a9c 7970MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_realtek);
1289e9e8
TI
7971
7972MODULE_LICENSE("GPL");
7973MODULE_DESCRIPTION("Realtek HD-audio codec");
7974
d8a766a1 7975static struct hda_codec_driver realtek_driver = {
b9a94a9c 7976 .id = snd_hda_id_realtek,
1289e9e8
TI
7977};
7978
d8a766a1 7979module_hda_codec_driver(realtek_driver);