1 /* 2 * Universal Interface for Intel High Definition Audio Codec 3 * 4 * HD audio interface patch for Realtek ALC codecs 5 * 6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> 7 * PeiSen Hou <pshou@realtek.com.tw> 8 * Takashi Iwai <tiwai@suse.de> 9 * Jonathan Woithe <jwoithe@just42.net> 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 26 #include <linux/init.h> 27 #include <linux/delay.h> 28 #include <linux/slab.h> 29 #include <linux/pci.h> 30 #include <linux/dmi.h> 31 #include <linux/module.h> 32 #include <sound/core.h> 33 #include <sound/jack.h> 34 #include "hda_codec.h" 35 #include "hda_local.h" 36 #include "hda_auto_parser.h" 37 #include "hda_jack.h" 38 #include "hda_generic.h" 39 40 /* keep halting ALC5505 DSP, for power saving */ 41 #define HALT_REALTEK_ALC5505 42 43 /* unsol event tags */ 44 #define ALC_DCVOL_EVENT 0x08 45 46 /* for GPIO Poll */ 47 #define GPIO_MASK 0x03 48 49 /* extra amp-initialization sequence types */ 50 enum { 51 ALC_INIT_NONE, 52 ALC_INIT_DEFAULT, 53 ALC_INIT_GPIO1, 54 ALC_INIT_GPIO2, 55 ALC_INIT_GPIO3, 56 }; 57 58 enum { 59 ALC_HEADSET_MODE_UNKNOWN, 60 ALC_HEADSET_MODE_UNPLUGGED, 61 ALC_HEADSET_MODE_HEADSET, 62 ALC_HEADSET_MODE_MIC, 63 ALC_HEADSET_MODE_HEADPHONE, 64 }; 65 66 enum { 67 ALC_HEADSET_TYPE_UNKNOWN, 68 ALC_HEADSET_TYPE_CTIA, 69 ALC_HEADSET_TYPE_OMTP, 70 }; 71 72 struct alc_customize_define { 73 unsigned int sku_cfg; 74 unsigned char port_connectivity; 75 unsigned char check_sum; 76 unsigned char customization; 77 unsigned char external_amp; 78 unsigned int enable_pcbeep:1; 79 unsigned int platform_type:1; 80 unsigned int swap:1; 81 unsigned int override:1; 82 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */ 83 }; 84 85 struct alc_spec { 86 struct hda_gen_spec gen; /* must be at head */ 87 88 /* codec parameterization */ 89 const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 90 unsigned int num_mixers; 91 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ 92 93 struct alc_customize_define cdefine; 94 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */ 95 96 /* inverted dmic fix */ 97 unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */ 98 unsigned int inv_dmic_muted:1; /* R-ch of inv d-mic is muted? */ 99 hda_nid_t inv_dmic_pin; 100 101 /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */ 102 int mute_led_polarity; 103 hda_nid_t mute_led_nid; 104 hda_nid_t cap_mute_led_nid; 105 106 unsigned int gpio_led; /* used for alc269_fixup_hp_gpio_led() */ 107 108 hda_nid_t headset_mic_pin; 109 hda_nid_t headphone_mic_pin; 110 int current_headset_mode; 111 int current_headset_type; 112 113 /* hooks */ 114 void (*init_hook)(struct hda_codec *codec); 115 #ifdef CONFIG_PM 116 void (*power_hook)(struct hda_codec *codec); 117 #endif 118 void (*shutup)(struct hda_codec *codec); 119 120 int init_amp; 121 int codec_variant; /* flag for other variants */ 122 unsigned int has_alc5505_dsp:1; 123 unsigned int no_depop_delay:1; 124 125 /* for PLL fix */ 126 hda_nid_t pll_nid; 127 unsigned int pll_coef_idx, pll_coef_bit; 128 unsigned int coef0; 129 }; 130 131 /* 132 * Append the given mixer and verb elements for the later use 133 * The mixer array is referred in build_controls(), and init_verbs are 134 * called in init(). 135 */ 136 static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix) 137 { 138 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) 139 return; 140 spec->mixers[spec->num_mixers++] = mix; 141 } 142 143 /* 144 * GPIO setup tables, used in initialization 145 */ 146 /* Enable GPIO mask and set output */ 147 static const struct hda_verb alc_gpio1_init_verbs[] = { 148 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 149 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 150 {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, 151 { } 152 }; 153 154 static const struct hda_verb alc_gpio2_init_verbs[] = { 155 {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, 156 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, 157 {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, 158 { } 159 }; 160 161 static const struct hda_verb alc_gpio3_init_verbs[] = { 162 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 163 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 164 {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 165 { } 166 }; 167 168 /* 169 * Fix hardware PLL issue 170 * On some codecs, the analog PLL gating control must be off while 171 * the default value is 1. 172 */ 173 static void alc_fix_pll(struct hda_codec *codec) 174 { 175 struct alc_spec *spec = codec->spec; 176 unsigned int val; 177 178 if (!spec->pll_nid) 179 return; 180 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, 181 spec->pll_coef_idx); 182 val = snd_hda_codec_read(codec, spec->pll_nid, 0, 183 AC_VERB_GET_PROC_COEF, 0); 184 if (val == -1) 185 return; 186 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, 187 spec->pll_coef_idx); 188 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, 189 val & ~(1 << spec->pll_coef_bit)); 190 } 191 192 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, 193 unsigned int coef_idx, unsigned int coef_bit) 194 { 195 struct alc_spec *spec = codec->spec; 196 spec->pll_nid = nid; 197 spec->pll_coef_idx = coef_idx; 198 spec->pll_coef_bit = coef_bit; 199 alc_fix_pll(codec); 200 } 201 202 /* update the master volume per volume-knob's unsol event */ 203 static void alc_update_knob_master(struct hda_codec *codec, struct hda_jack_tbl *jack) 204 { 205 unsigned int val; 206 struct snd_kcontrol *kctl; 207 struct snd_ctl_elem_value *uctl; 208 209 kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); 210 if (!kctl) 211 return; 212 uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); 213 if (!uctl) 214 return; 215 val = snd_hda_codec_read(codec, jack->nid, 0, 216 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); 217 val &= HDA_AMP_VOLMASK; 218 uctl->value.integer.value[0] = val; 219 uctl->value.integer.value[1] = val; 220 kctl->put(kctl, uctl); 221 kfree(uctl); 222 } 223 224 static void alc880_unsol_event(struct hda_codec *codec, unsigned int res) 225 { 226 /* For some reason, the res given from ALC880 is broken. 227 Here we adjust it properly. */ 228 snd_hda_jack_unsol_event(codec, res >> 2); 229 } 230 231 /* additional initialization for ALC888 variants */ 232 static void alc888_coef_init(struct hda_codec *codec) 233 { 234 unsigned int tmp; 235 236 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); 237 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); 238 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); 239 if ((tmp & 0xf0) == 0x20) 240 /* alc888S-VC */ 241 snd_hda_codec_read(codec, 0x20, 0, 242 AC_VERB_SET_PROC_COEF, 0x830); 243 else 244 /* alc888-VB */ 245 snd_hda_codec_read(codec, 0x20, 0, 246 AC_VERB_SET_PROC_COEF, 0x3030); 247 } 248 249 /* additional initialization for ALC889 variants */ 250 static void alc889_coef_init(struct hda_codec *codec) 251 { 252 unsigned int tmp; 253 254 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); 255 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); 256 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); 257 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); 258 } 259 260 /* turn on/off EAPD control (only if available) */ 261 static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) 262 { 263 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) 264 return; 265 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) 266 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, 267 on ? 2 : 0); 268 } 269 270 /* turn on/off EAPD controls of the codec */ 271 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) 272 { 273 /* We currently only handle front, HP */ 274 static hda_nid_t pins[] = { 275 0x0f, 0x10, 0x14, 0x15, 0 276 }; 277 hda_nid_t *p; 278 for (p = pins; *p; p++) 279 set_eapd(codec, *p, on); 280 } 281 282 /* generic shutup callback; 283 * just turning off EPAD and a little pause for avoiding pop-noise 284 */ 285 static void alc_eapd_shutup(struct hda_codec *codec) 286 { 287 struct alc_spec *spec = codec->spec; 288 289 alc_auto_setup_eapd(codec, false); 290 if (!spec->no_depop_delay) 291 msleep(200); 292 snd_hda_shutup_pins(codec); 293 } 294 295 /* generic EAPD initialization */ 296 static void alc_auto_init_amp(struct hda_codec *codec, int type) 297 { 298 unsigned int tmp; 299 300 alc_auto_setup_eapd(codec, true); 301 switch (type) { 302 case ALC_INIT_GPIO1: 303 snd_hda_sequence_write(codec, alc_gpio1_init_verbs); 304 break; 305 case ALC_INIT_GPIO2: 306 snd_hda_sequence_write(codec, alc_gpio2_init_verbs); 307 break; 308 case ALC_INIT_GPIO3: 309 snd_hda_sequence_write(codec, alc_gpio3_init_verbs); 310 break; 311 case ALC_INIT_DEFAULT: 312 switch (codec->vendor_id) { 313 case 0x10ec0260: 314 snd_hda_codec_write(codec, 0x1a, 0, 315 AC_VERB_SET_COEF_INDEX, 7); 316 tmp = snd_hda_codec_read(codec, 0x1a, 0, 317 AC_VERB_GET_PROC_COEF, 0); 318 snd_hda_codec_write(codec, 0x1a, 0, 319 AC_VERB_SET_COEF_INDEX, 7); 320 snd_hda_codec_write(codec, 0x1a, 0, 321 AC_VERB_SET_PROC_COEF, 322 tmp | 0x2010); 323 break; 324 case 0x10ec0262: 325 case 0x10ec0880: 326 case 0x10ec0882: 327 case 0x10ec0883: 328 case 0x10ec0885: 329 case 0x10ec0887: 330 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ 331 case 0x10ec0900: 332 alc889_coef_init(codec); 333 break; 334 case 0x10ec0888: 335 alc888_coef_init(codec); 336 break; 337 #if 0 /* XXX: This may cause the silent output on speaker on some machines */ 338 case 0x10ec0267: 339 case 0x10ec0268: 340 snd_hda_codec_write(codec, 0x20, 0, 341 AC_VERB_SET_COEF_INDEX, 7); 342 tmp = snd_hda_codec_read(codec, 0x20, 0, 343 AC_VERB_GET_PROC_COEF, 0); 344 snd_hda_codec_write(codec, 0x20, 0, 345 AC_VERB_SET_COEF_INDEX, 7); 346 snd_hda_codec_write(codec, 0x20, 0, 347 AC_VERB_SET_PROC_COEF, 348 tmp | 0x3000); 349 break; 350 #endif /* XXX */ 351 } 352 break; 353 } 354 } 355 356 357 /* 358 * Realtek SSID verification 359 */ 360 361 /* Could be any non-zero and even value. When used as fixup, tells 362 * the driver to ignore any present sku defines. 363 */ 364 #define ALC_FIXUP_SKU_IGNORE (2) 365 366 static void alc_fixup_sku_ignore(struct hda_codec *codec, 367 const struct hda_fixup *fix, int action) 368 { 369 struct alc_spec *spec = codec->spec; 370 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 371 spec->cdefine.fixup = 1; 372 spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE; 373 } 374 } 375 376 static void alc_fixup_no_depop_delay(struct hda_codec *codec, 377 const struct hda_fixup *fix, int action) 378 { 379 struct alc_spec *spec = codec->spec; 380 381 if (action == HDA_FIXUP_ACT_PROBE) { 382 spec->no_depop_delay = 1; 383 codec->depop_delay = 0; 384 } 385 } 386 387 static int alc_auto_parse_customize_define(struct hda_codec *codec) 388 { 389 unsigned int ass, tmp, i; 390 unsigned nid = 0; 391 struct alc_spec *spec = codec->spec; 392 393 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ 394 395 if (spec->cdefine.fixup) { 396 ass = spec->cdefine.sku_cfg; 397 if (ass == ALC_FIXUP_SKU_IGNORE) 398 return -1; 399 goto do_sku; 400 } 401 402 if (!codec->bus->pci) 403 return -1; 404 ass = codec->subsystem_id & 0xffff; 405 if (ass != codec->bus->pci->subsystem_device && (ass & 1)) 406 goto do_sku; 407 408 nid = 0x1d; 409 if (codec->vendor_id == 0x10ec0260) 410 nid = 0x17; 411 ass = snd_hda_codec_get_pincfg(codec, nid); 412 413 if (!(ass & 1)) { 414 codec_info(codec, "%s: SKU not ready 0x%08x\n", 415 codec->chip_name, ass); 416 return -1; 417 } 418 419 /* check sum */ 420 tmp = 0; 421 for (i = 1; i < 16; i++) { 422 if ((ass >> i) & 1) 423 tmp++; 424 } 425 if (((ass >> 16) & 0xf) != tmp) 426 return -1; 427 428 spec->cdefine.port_connectivity = ass >> 30; 429 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; 430 spec->cdefine.check_sum = (ass >> 16) & 0xf; 431 spec->cdefine.customization = ass >> 8; 432 do_sku: 433 spec->cdefine.sku_cfg = ass; 434 spec->cdefine.external_amp = (ass & 0x38) >> 3; 435 spec->cdefine.platform_type = (ass & 0x4) >> 2; 436 spec->cdefine.swap = (ass & 0x2) >> 1; 437 spec->cdefine.override = ass & 0x1; 438 439 codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n", 440 nid, spec->cdefine.sku_cfg); 441 codec_dbg(codec, "SKU: port_connectivity=0x%x\n", 442 spec->cdefine.port_connectivity); 443 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); 444 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); 445 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization); 446 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp); 447 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type); 448 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap); 449 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override); 450 451 return 0; 452 } 453 454 /* return the position of NID in the list, or -1 if not found */ 455 static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) 456 { 457 int i; 458 for (i = 0; i < nums; i++) 459 if (list[i] == nid) 460 return i; 461 return -1; 462 } 463 /* return true if the given NID is found in the list */ 464 static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) 465 { 466 return find_idx_in_nid_list(nid, list, nums) >= 0; 467 } 468 469 /* check subsystem ID and set up device-specific initialization; 470 * return 1 if initialized, 0 if invalid SSID 471 */ 472 /* 32-bit subsystem ID for BIOS loading in HD Audio codec. 473 * 31 ~ 16 : Manufacture ID 474 * 15 ~ 8 : SKU ID 475 * 7 ~ 0 : Assembly ID 476 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 477 */ 478 static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports) 479 { 480 unsigned int ass, tmp, i; 481 unsigned nid; 482 struct alc_spec *spec = codec->spec; 483 484 if (spec->cdefine.fixup) { 485 ass = spec->cdefine.sku_cfg; 486 if (ass == ALC_FIXUP_SKU_IGNORE) 487 return 0; 488 goto do_sku; 489 } 490 491 ass = codec->subsystem_id & 0xffff; 492 if (codec->bus->pci && 493 ass != codec->bus->pci->subsystem_device && (ass & 1)) 494 goto do_sku; 495 496 /* invalid SSID, check the special NID pin defcfg instead */ 497 /* 498 * 31~30 : port connectivity 499 * 29~21 : reserve 500 * 20 : PCBEEP input 501 * 19~16 : Check sum (15:1) 502 * 15~1 : Custom 503 * 0 : override 504 */ 505 nid = 0x1d; 506 if (codec->vendor_id == 0x10ec0260) 507 nid = 0x17; 508 ass = snd_hda_codec_get_pincfg(codec, nid); 509 codec_dbg(codec, 510 "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n", 511 ass, nid); 512 if (!(ass & 1)) 513 return 0; 514 if ((ass >> 30) != 1) /* no physical connection */ 515 return 0; 516 517 /* check sum */ 518 tmp = 0; 519 for (i = 1; i < 16; i++) { 520 if ((ass >> i) & 1) 521 tmp++; 522 } 523 if (((ass >> 16) & 0xf) != tmp) 524 return 0; 525 do_sku: 526 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", 527 ass & 0xffff, codec->vendor_id); 528 /* 529 * 0 : override 530 * 1 : Swap Jack 531 * 2 : 0 --> Desktop, 1 --> Laptop 532 * 3~5 : External Amplifier control 533 * 7~6 : Reserved 534 */ 535 tmp = (ass & 0x38) >> 3; /* external Amp control */ 536 switch (tmp) { 537 case 1: 538 spec->init_amp = ALC_INIT_GPIO1; 539 break; 540 case 3: 541 spec->init_amp = ALC_INIT_GPIO2; 542 break; 543 case 7: 544 spec->init_amp = ALC_INIT_GPIO3; 545 break; 546 case 5: 547 default: 548 spec->init_amp = ALC_INIT_DEFAULT; 549 break; 550 } 551 552 /* is laptop or Desktop and enable the function "Mute internal speaker 553 * when the external headphone out jack is plugged" 554 */ 555 if (!(ass & 0x8000)) 556 return 1; 557 /* 558 * 10~8 : Jack location 559 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered 560 * 14~13: Resvered 561 * 15 : 1 --> enable the function "Mute internal speaker 562 * when the external headphone out jack is plugged" 563 */ 564 if (!spec->gen.autocfg.hp_pins[0] && 565 !(spec->gen.autocfg.line_out_pins[0] && 566 spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) { 567 hda_nid_t nid; 568 tmp = (ass >> 11) & 0x3; /* HP to chassis */ 569 nid = ports[tmp]; 570 if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins, 571 spec->gen.autocfg.line_outs)) 572 return 1; 573 spec->gen.autocfg.hp_pins[0] = nid; 574 } 575 return 1; 576 } 577 578 /* Check the validity of ALC subsystem-id 579 * ports contains an array of 4 pin NIDs for port-A, E, D and I */ 580 static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports) 581 { 582 if (!alc_subsystem_id(codec, ports)) { 583 struct alc_spec *spec = codec->spec; 584 codec_dbg(codec, 585 "realtek: Enable default setup for auto mode as fallback\n"); 586 spec->init_amp = ALC_INIT_DEFAULT; 587 } 588 } 589 590 /* 591 * COEF access helper functions 592 */ 593 594 static int alc_read_coefex_idx(struct hda_codec *codec, 595 hda_nid_t nid, 596 unsigned int coef_idx) 597 { 598 unsigned int val; 599 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, 600 coef_idx); 601 val = snd_hda_codec_read(codec, nid, 0, 602 AC_VERB_GET_PROC_COEF, 0); 603 return val; 604 } 605 606 #define alc_read_coef_idx(codec, coef_idx) \ 607 alc_read_coefex_idx(codec, 0x20, coef_idx) 608 609 static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid, 610 unsigned int coef_idx, 611 unsigned int coef_val) 612 { 613 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, 614 coef_idx); 615 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, 616 coef_val); 617 } 618 619 #define alc_write_coef_idx(codec, coef_idx, coef_val) \ 620 alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val) 621 622 /* a special bypass for COEF 0; read the cached value at the second time */ 623 static unsigned int alc_get_coef0(struct hda_codec *codec) 624 { 625 struct alc_spec *spec = codec->spec; 626 if (!spec->coef0) 627 spec->coef0 = alc_read_coef_idx(codec, 0); 628 return spec->coef0; 629 } 630 631 /* 632 */ 633 634 static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx) 635 { 636 struct hda_gen_spec *spec = codec->spec; 637 if (spec->dyn_adc_switch) 638 adc_idx = spec->dyn_adc_idx[imux_idx]; 639 return spec->adc_nids[adc_idx]; 640 } 641 642 static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx) 643 { 644 struct alc_spec *spec = codec->spec; 645 struct hda_input_mux *imux = &spec->gen.input_mux; 646 struct nid_path *path; 647 hda_nid_t nid; 648 int i, dir, parm; 649 unsigned int val; 650 651 for (i = 0; i < imux->num_items; i++) { 652 if (spec->gen.imux_pins[i] == spec->inv_dmic_pin) 653 break; 654 } 655 if (i >= imux->num_items) 656 return; 657 658 path = snd_hda_get_nid_path(codec, spec->inv_dmic_pin, 659 get_adc_nid(codec, adc_idx, i)); 660 val = path->ctls[NID_PATH_MUTE_CTL]; 661 if (!val) 662 return; 663 nid = get_amp_nid_(val); 664 dir = get_amp_direction_(val); 665 parm = AC_AMP_SET_RIGHT | 666 (dir == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT); 667 668 /* flush all cached amps at first */ 669 snd_hda_codec_flush_cache(codec); 670 671 /* we care only right channel */ 672 val = snd_hda_codec_amp_read(codec, nid, 1, dir, 0); 673 if (val & 0x80) /* if already muted, we don't need to touch */ 674 return; 675 val |= 0x80; 676 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 677 parm | val); 678 } 679 680 /* 681 * Inverted digital-mic handling 682 * 683 * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch" 684 * gives the additional mute only to the right channel of the digital mic 685 * capture stream. This is a workaround for avoiding the almost silence 686 * by summing the stereo stream from some (known to be ForteMedia) 687 * digital mic unit. 688 * 689 * The logic is to call alc_inv_dmic_sync() after each action (possibly) 690 * modifying ADC amp. When the mute flag is set, it mutes the R-channel 691 * without caching so that the cache can still keep the original value. 692 * The cached value is then restored when the flag is set off or any other 693 * than d-mic is used as the current input source. 694 */ 695 static void alc_inv_dmic_sync(struct hda_codec *codec, bool force) 696 { 697 struct alc_spec *spec = codec->spec; 698 int src, nums; 699 700 if (!spec->inv_dmic_fixup) 701 return; 702 if (!spec->inv_dmic_muted && !force) 703 return; 704 nums = spec->gen.dyn_adc_switch ? 1 : spec->gen.num_adc_nids; 705 for (src = 0; src < nums; src++) { 706 bool dmic_fixup = false; 707 708 if (spec->inv_dmic_muted && 709 spec->gen.imux_pins[spec->gen.cur_mux[src]] == spec->inv_dmic_pin) 710 dmic_fixup = true; 711 if (!dmic_fixup && !force) 712 continue; 713 alc_inv_dmic_sync_adc(codec, src); 714 } 715 } 716 717 static void alc_inv_dmic_hook(struct hda_codec *codec, 718 struct snd_kcontrol *kcontrol, 719 struct snd_ctl_elem_value *ucontrol) 720 { 721 alc_inv_dmic_sync(codec, false); 722 } 723 724 static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol, 725 struct snd_ctl_elem_value *ucontrol) 726 { 727 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 728 struct alc_spec *spec = codec->spec; 729 730 ucontrol->value.integer.value[0] = !spec->inv_dmic_muted; 731 return 0; 732 } 733 734 static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol, 735 struct snd_ctl_elem_value *ucontrol) 736 { 737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 738 struct alc_spec *spec = codec->spec; 739 unsigned int val = !ucontrol->value.integer.value[0]; 740 741 if (val == spec->inv_dmic_muted) 742 return 0; 743 spec->inv_dmic_muted = val; 744 alc_inv_dmic_sync(codec, true); 745 return 0; 746 } 747 748 static const struct snd_kcontrol_new alc_inv_dmic_sw = { 749 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 750 .name = "Inverted Internal Mic Capture Switch", 751 .info = snd_ctl_boolean_mono_info, 752 .get = alc_inv_dmic_sw_get, 753 .put = alc_inv_dmic_sw_put, 754 }; 755 756 static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid) 757 { 758 struct alc_spec *spec = codec->spec; 759 760 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &alc_inv_dmic_sw)) 761 return -ENOMEM; 762 spec->inv_dmic_fixup = 1; 763 spec->inv_dmic_muted = 0; 764 spec->inv_dmic_pin = nid; 765 spec->gen.cap_sync_hook = alc_inv_dmic_hook; 766 return 0; 767 } 768 769 /* typically the digital mic is put at node 0x12 */ 770 static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec, 771 const struct hda_fixup *fix, int action) 772 { 773 if (action == HDA_FIXUP_ACT_PROBE) 774 alc_add_inv_dmic_mixer(codec, 0x12); 775 } 776 777 778 #ifdef CONFIG_SND_HDA_INPUT_BEEP 779 /* additional beep mixers; the actual parameters are overwritten at build */ 780 static const struct snd_kcontrol_new alc_beep_mixer[] = { 781 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), 782 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), 783 { } /* end */ 784 }; 785 #endif 786 787 static int alc_build_controls(struct hda_codec *codec) 788 { 789 struct alc_spec *spec = codec->spec; 790 int i, err; 791 792 err = snd_hda_gen_build_controls(codec); 793 if (err < 0) 794 return err; 795 796 for (i = 0; i < spec->num_mixers; i++) { 797 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 798 if (err < 0) 799 return err; 800 } 801 802 #ifdef CONFIG_SND_HDA_INPUT_BEEP 803 /* create beep controls if needed */ 804 if (spec->beep_amp) { 805 const struct snd_kcontrol_new *knew; 806 for (knew = alc_beep_mixer; knew->name; knew++) { 807 struct snd_kcontrol *kctl; 808 kctl = snd_ctl_new1(knew, codec); 809 if (!kctl) 810 return -ENOMEM; 811 kctl->private_value = spec->beep_amp; 812 err = snd_hda_ctl_add(codec, 0, kctl); 813 if (err < 0) 814 return err; 815 } 816 } 817 #endif 818 819 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD); 820 return 0; 821 } 822 823 824 /* 825 * Common callbacks 826 */ 827 828 static int alc_init(struct hda_codec *codec) 829 { 830 struct alc_spec *spec = codec->spec; 831 832 if (spec->init_hook) 833 spec->init_hook(codec); 834 835 alc_fix_pll(codec); 836 alc_auto_init_amp(codec, spec->init_amp); 837 838 snd_hda_gen_init(codec); 839 840 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT); 841 842 return 0; 843 } 844 845 static inline void alc_shutup(struct hda_codec *codec) 846 { 847 struct alc_spec *spec = codec->spec; 848 849 if (spec && spec->shutup) 850 spec->shutup(codec); 851 else 852 snd_hda_shutup_pins(codec); 853 } 854 855 #define alc_free snd_hda_gen_free 856 857 #ifdef CONFIG_PM 858 static void alc_power_eapd(struct hda_codec *codec) 859 { 860 alc_auto_setup_eapd(codec, false); 861 } 862 863 static int alc_suspend(struct hda_codec *codec) 864 { 865 struct alc_spec *spec = codec->spec; 866 alc_shutup(codec); 867 if (spec && spec->power_hook) 868 spec->power_hook(codec); 869 return 0; 870 } 871 #endif 872 873 #ifdef CONFIG_PM 874 static int alc_resume(struct hda_codec *codec) 875 { 876 struct alc_spec *spec = codec->spec; 877 878 if (!spec->no_depop_delay) 879 msleep(150); /* to avoid pop noise */ 880 codec->patch_ops.init(codec); 881 snd_hda_codec_resume_amp(codec); 882 snd_hda_codec_resume_cache(codec); 883 alc_inv_dmic_sync(codec, true); 884 hda_call_check_power_status(codec, 0x01); 885 return 0; 886 } 887 #endif 888 889 /* 890 */ 891 static const struct hda_codec_ops alc_patch_ops = { 892 .build_controls = alc_build_controls, 893 .build_pcms = snd_hda_gen_build_pcms, 894 .init = alc_init, 895 .free = alc_free, 896 .unsol_event = snd_hda_jack_unsol_event, 897 #ifdef CONFIG_PM 898 .resume = alc_resume, 899 .suspend = alc_suspend, 900 .check_power_status = snd_hda_gen_check_power_status, 901 #endif 902 .reboot_notify = alc_shutup, 903 }; 904 905 906 /* replace the codec chip_name with the given string */ 907 static int alc_codec_rename(struct hda_codec *codec, const char *name) 908 { 909 kfree(codec->chip_name); 910 codec->chip_name = kstrdup(name, GFP_KERNEL); 911 if (!codec->chip_name) { 912 alc_free(codec); 913 return -ENOMEM; 914 } 915 return 0; 916 } 917 918 /* 919 * Rename codecs appropriately from COEF value or subvendor id 920 */ 921 struct alc_codec_rename_table { 922 unsigned int vendor_id; 923 unsigned short coef_mask; 924 unsigned short coef_bits; 925 const char *name; 926 }; 927 928 struct alc_codec_rename_pci_table { 929 unsigned int codec_vendor_id; 930 unsigned short pci_subvendor; 931 unsigned short pci_subdevice; 932 const char *name; 933 }; 934 935 static struct alc_codec_rename_table rename_tbl[] = { 936 { 0x10ec0221, 0xf00f, 0x1003, "ALC231" }, 937 { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, 938 { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, 939 { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, 940 { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, 941 { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, 942 { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, 943 { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, 944 { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" }, 945 { 0x10ec0662, 0xffff, 0x4020, "ALC656" }, 946 { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, 947 { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, 948 { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, 949 { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, 950 { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, 951 { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, 952 { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, 953 { } /* terminator */ 954 }; 955 956 static struct alc_codec_rename_pci_table rename_pci_tbl[] = { 957 { 0x10ec0280, 0x1028, 0, "ALC3220" }, 958 { 0x10ec0282, 0x1028, 0, "ALC3221" }, 959 { 0x10ec0283, 0x1028, 0, "ALC3223" }, 960 { 0x10ec0288, 0x1028, 0, "ALC3263" }, 961 { 0x10ec0292, 0x1028, 0, "ALC3226" }, 962 { 0x10ec0293, 0x1028, 0, "ALC3235" }, 963 { 0x10ec0255, 0x1028, 0, "ALC3234" }, 964 { 0x10ec0668, 0x1028, 0, "ALC3661" }, 965 { 0x10ec0275, 0x1028, 0, "ALC3260" }, 966 { 0x10ec0899, 0x1028, 0, "ALC3861" }, 967 { 0x10ec0670, 0x1025, 0, "ALC669X" }, 968 { 0x10ec0676, 0x1025, 0, "ALC679X" }, 969 { 0x10ec0282, 0x1043, 0, "ALC3229" }, 970 { 0x10ec0233, 0x1043, 0, "ALC3236" }, 971 { 0x10ec0280, 0x103c, 0, "ALC3228" }, 972 { 0x10ec0282, 0x103c, 0, "ALC3227" }, 973 { 0x10ec0286, 0x103c, 0, "ALC3242" }, 974 { 0x10ec0290, 0x103c, 0, "ALC3241" }, 975 { 0x10ec0668, 0x103c, 0, "ALC3662" }, 976 { 0x10ec0283, 0x17aa, 0, "ALC3239" }, 977 { 0x10ec0292, 0x17aa, 0, "ALC3232" }, 978 { } /* terminator */ 979 }; 980 981 static int alc_codec_rename_from_preset(struct hda_codec *codec) 982 { 983 const struct alc_codec_rename_table *p; 984 const struct alc_codec_rename_pci_table *q; 985 986 for (p = rename_tbl; p->vendor_id; p++) { 987 if (p->vendor_id != codec->vendor_id) 988 continue; 989 if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) 990 return alc_codec_rename(codec, p->name); 991 } 992 993 if (!codec->bus->pci) 994 return 0; 995 for (q = rename_pci_tbl; q->codec_vendor_id; q++) { 996 if (q->codec_vendor_id != codec->vendor_id) 997 continue; 998 if (q->pci_subvendor != codec->bus->pci->subsystem_vendor) 999 continue; 1000 if (!q->pci_subdevice || 1001 q->pci_subdevice == codec->bus->pci->subsystem_device) 1002 return alc_codec_rename(codec, q->name); 1003 } 1004 1005 return 0; 1006 } 1007 1008 1009 /* 1010 * Digital-beep handlers 1011 */ 1012 #ifdef CONFIG_SND_HDA_INPUT_BEEP 1013 #define set_beep_amp(spec, nid, idx, dir) \ 1014 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) 1015 1016 static const struct snd_pci_quirk beep_white_list[] = { 1017 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1), 1018 SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1), 1019 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), 1020 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1), 1021 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), 1022 SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), 1023 SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), 1024 SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), 1025 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), 1026 {} 1027 }; 1028 1029 static inline int has_cdefine_beep(struct hda_codec *codec) 1030 { 1031 struct alc_spec *spec = codec->spec; 1032 const struct snd_pci_quirk *q; 1033 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); 1034 if (q) 1035 return q->value; 1036 return spec->cdefine.enable_pcbeep; 1037 } 1038 #else 1039 #define set_beep_amp(spec, nid, idx, dir) /* NOP */ 1040 #define has_cdefine_beep(codec) 0 1041 #endif 1042 1043 /* parse the BIOS configuration and set up the alc_spec */ 1044 /* return 1 if successful, 0 if the proper config is not found, 1045 * or a negative error code 1046 */ 1047 static int alc_parse_auto_config(struct hda_codec *codec, 1048 const hda_nid_t *ignore_nids, 1049 const hda_nid_t *ssid_nids) 1050 { 1051 struct alc_spec *spec = codec->spec; 1052 struct auto_pin_cfg *cfg = &spec->gen.autocfg; 1053 int err; 1054 1055 err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, 1056 spec->parse_flags); 1057 if (err < 0) 1058 return err; 1059 1060 if (ssid_nids) 1061 alc_ssid_check(codec, ssid_nids); 1062 1063 err = snd_hda_gen_parse_auto_config(codec, cfg); 1064 if (err < 0) 1065 return err; 1066 1067 return 1; 1068 } 1069 1070 /* common preparation job for alc_spec */ 1071 static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) 1072 { 1073 struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1074 int err; 1075 1076 if (!spec) 1077 return -ENOMEM; 1078 codec->spec = spec; 1079 snd_hda_gen_spec_init(&spec->gen); 1080 spec->gen.mixer_nid = mixer_nid; 1081 spec->gen.own_eapd_ctl = 1; 1082 codec->single_adc_amp = 1; 1083 /* FIXME: do we need this for all Realtek codec models? */ 1084 codec->spdif_status_reset = 1; 1085 1086 err = alc_codec_rename_from_preset(codec); 1087 if (err < 0) { 1088 kfree(spec); 1089 return err; 1090 } 1091 return 0; 1092 } 1093 1094 static int alc880_parse_auto_config(struct hda_codec *codec) 1095 { 1096 static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; 1097 static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 1098 return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); 1099 } 1100 1101 /* 1102 * ALC880 fix-ups 1103 */ 1104 enum { 1105 ALC880_FIXUP_GPIO1, 1106 ALC880_FIXUP_GPIO2, 1107 ALC880_FIXUP_MEDION_RIM, 1108 ALC880_FIXUP_LG, 1109 ALC880_FIXUP_LG_LW25, 1110 ALC880_FIXUP_W810, 1111 ALC880_FIXUP_EAPD_COEF, 1112 ALC880_FIXUP_TCL_S700, 1113 ALC880_FIXUP_VOL_KNOB, 1114 ALC880_FIXUP_FUJITSU, 1115 ALC880_FIXUP_F1734, 1116 ALC880_FIXUP_UNIWILL, 1117 ALC880_FIXUP_UNIWILL_DIG, 1118 ALC880_FIXUP_Z71V, 1119 ALC880_FIXUP_ASUS_W5A, 1120 ALC880_FIXUP_3ST_BASE, 1121 ALC880_FIXUP_3ST, 1122 ALC880_FIXUP_3ST_DIG, 1123 ALC880_FIXUP_5ST_BASE, 1124 ALC880_FIXUP_5ST, 1125 ALC880_FIXUP_5ST_DIG, 1126 ALC880_FIXUP_6ST_BASE, 1127 ALC880_FIXUP_6ST, 1128 ALC880_FIXUP_6ST_DIG, 1129 ALC880_FIXUP_6ST_AUTOMUTE, 1130 }; 1131 1132 /* enable the volume-knob widget support on NID 0x21 */ 1133 static void alc880_fixup_vol_knob(struct hda_codec *codec, 1134 const struct hda_fixup *fix, int action) 1135 { 1136 if (action == HDA_FIXUP_ACT_PROBE) 1137 snd_hda_jack_detect_enable_callback(codec, 0x21, ALC_DCVOL_EVENT, alc_update_knob_master); 1138 } 1139 1140 static const struct hda_fixup alc880_fixups[] = { 1141 [ALC880_FIXUP_GPIO1] = { 1142 .type = HDA_FIXUP_VERBS, 1143 .v.verbs = alc_gpio1_init_verbs, 1144 }, 1145 [ALC880_FIXUP_GPIO2] = { 1146 .type = HDA_FIXUP_VERBS, 1147 .v.verbs = alc_gpio2_init_verbs, 1148 }, 1149 [ALC880_FIXUP_MEDION_RIM] = { 1150 .type = HDA_FIXUP_VERBS, 1151 .v.verbs = (const struct hda_verb[]) { 1152 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 1153 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, 1154 { } 1155 }, 1156 .chained = true, 1157 .chain_id = ALC880_FIXUP_GPIO2, 1158 }, 1159 [ALC880_FIXUP_LG] = { 1160 .type = HDA_FIXUP_PINS, 1161 .v.pins = (const struct hda_pintbl[]) { 1162 /* disable bogus unused pins */ 1163 { 0x16, 0x411111f0 }, 1164 { 0x18, 0x411111f0 }, 1165 { 0x1a, 0x411111f0 }, 1166 { } 1167 } 1168 }, 1169 [ALC880_FIXUP_LG_LW25] = { 1170 .type = HDA_FIXUP_PINS, 1171 .v.pins = (const struct hda_pintbl[]) { 1172 { 0x1a, 0x0181344f }, /* line-in */ 1173 { 0x1b, 0x0321403f }, /* headphone */ 1174 { } 1175 } 1176 }, 1177 [ALC880_FIXUP_W810] = { 1178 .type = HDA_FIXUP_PINS, 1179 .v.pins = (const struct hda_pintbl[]) { 1180 /* disable bogus unused pins */ 1181 { 0x17, 0x411111f0 }, 1182 { } 1183 }, 1184 .chained = true, 1185 .chain_id = ALC880_FIXUP_GPIO2, 1186 }, 1187 [ALC880_FIXUP_EAPD_COEF] = { 1188 .type = HDA_FIXUP_VERBS, 1189 .v.verbs = (const struct hda_verb[]) { 1190 /* change to EAPD mode */ 1191 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 1192 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, 1193 {} 1194 }, 1195 }, 1196 [ALC880_FIXUP_TCL_S700] = { 1197 .type = HDA_FIXUP_VERBS, 1198 .v.verbs = (const struct hda_verb[]) { 1199 /* change to EAPD mode */ 1200 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 1201 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, 1202 {} 1203 }, 1204 .chained = true, 1205 .chain_id = ALC880_FIXUP_GPIO2, 1206 }, 1207 [ALC880_FIXUP_VOL_KNOB] = { 1208 .type = HDA_FIXUP_FUNC, 1209 .v.func = alc880_fixup_vol_knob, 1210 }, 1211 [ALC880_FIXUP_FUJITSU] = { 1212 /* override all pins as BIOS on old Amilo is broken */ 1213 .type = HDA_FIXUP_PINS, 1214 .v.pins = (const struct hda_pintbl[]) { 1215 { 0x14, 0x0121411f }, /* HP */ 1216 { 0x15, 0x99030120 }, /* speaker */ 1217 { 0x16, 0x99030130 }, /* bass speaker */ 1218 { 0x17, 0x411111f0 }, /* N/A */ 1219 { 0x18, 0x411111f0 }, /* N/A */ 1220 { 0x19, 0x01a19950 }, /* mic-in */ 1221 { 0x1a, 0x411111f0 }, /* N/A */ 1222 { 0x1b, 0x411111f0 }, /* N/A */ 1223 { 0x1c, 0x411111f0 }, /* N/A */ 1224 { 0x1d, 0x411111f0 }, /* N/A */ 1225 { 0x1e, 0x01454140 }, /* SPDIF out */ 1226 { } 1227 }, 1228 .chained = true, 1229 .chain_id = ALC880_FIXUP_VOL_KNOB, 1230 }, 1231 [ALC880_FIXUP_F1734] = { 1232 /* almost compatible with FUJITSU, but no bass and SPDIF */ 1233 .type = HDA_FIXUP_PINS, 1234 .v.pins = (const struct hda_pintbl[]) { 1235 { 0x14, 0x0121411f }, /* HP */ 1236 { 0x15, 0x99030120 }, /* speaker */ 1237 { 0x16, 0x411111f0 }, /* N/A */ 1238 { 0x17, 0x411111f0 }, /* N/A */ 1239 { 0x18, 0x411111f0 }, /* N/A */ 1240 { 0x19, 0x01a19950 }, /* mic-in */ 1241 { 0x1a, 0x411111f0 }, /* N/A */ 1242 { 0x1b, 0x411111f0 }, /* N/A */ 1243 { 0x1c, 0x411111f0 }, /* N/A */ 1244 { 0x1d, 0x411111f0 }, /* N/A */ 1245 { 0x1e, 0x411111f0 }, /* N/A */ 1246 { } 1247 }, 1248 .chained = true, 1249 .chain_id = ALC880_FIXUP_VOL_KNOB, 1250 }, 1251 [ALC880_FIXUP_UNIWILL] = { 1252 /* need to fix HP and speaker pins to be parsed correctly */ 1253 .type = HDA_FIXUP_PINS, 1254 .v.pins = (const struct hda_pintbl[]) { 1255 { 0x14, 0x0121411f }, /* HP */ 1256 { 0x15, 0x99030120 }, /* speaker */ 1257 { 0x16, 0x99030130 }, /* bass speaker */ 1258 { } 1259 }, 1260 }, 1261 [ALC880_FIXUP_UNIWILL_DIG] = { 1262 .type = HDA_FIXUP_PINS, 1263 .v.pins = (const struct hda_pintbl[]) { 1264 /* disable bogus unused pins */ 1265 { 0x17, 0x411111f0 }, 1266 { 0x19, 0x411111f0 }, 1267 { 0x1b, 0x411111f0 }, 1268 { 0x1f, 0x411111f0 }, 1269 { } 1270 } 1271 }, 1272 [ALC880_FIXUP_Z71V] = { 1273 .type = HDA_FIXUP_PINS, 1274 .v.pins = (const struct hda_pintbl[]) { 1275 /* set up the whole pins as BIOS is utterly broken */ 1276 { 0x14, 0x99030120 }, /* speaker */ 1277 { 0x15, 0x0121411f }, /* HP */ 1278 { 0x16, 0x411111f0 }, /* N/A */ 1279 { 0x17, 0x411111f0 }, /* N/A */ 1280 { 0x18, 0x01a19950 }, /* mic-in */ 1281 { 0x19, 0x411111f0 }, /* N/A */ 1282 { 0x1a, 0x01813031 }, /* line-in */ 1283 { 0x1b, 0x411111f0 }, /* N/A */ 1284 { 0x1c, 0x411111f0 }, /* N/A */ 1285 { 0x1d, 0x411111f0 }, /* N/A */ 1286 { 0x1e, 0x0144111e }, /* SPDIF */ 1287 { } 1288 } 1289 }, 1290 [ALC880_FIXUP_ASUS_W5A] = { 1291 .type = HDA_FIXUP_PINS, 1292 .v.pins = (const struct hda_pintbl[]) { 1293 /* set up the whole pins as BIOS is utterly broken */ 1294 { 0x14, 0x0121411f }, /* HP */ 1295 { 0x15, 0x411111f0 }, /* N/A */ 1296 { 0x16, 0x411111f0 }, /* N/A */ 1297 { 0x17, 0x411111f0 }, /* N/A */ 1298 { 0x18, 0x90a60160 }, /* mic */ 1299 { 0x19, 0x411111f0 }, /* N/A */ 1300 { 0x1a, 0x411111f0 }, /* N/A */ 1301 { 0x1b, 0x411111f0 }, /* N/A */ 1302 { 0x1c, 0x411111f0 }, /* N/A */ 1303 { 0x1d, 0x411111f0 }, /* N/A */ 1304 { 0x1e, 0xb743111e }, /* SPDIF out */ 1305 { } 1306 }, 1307 .chained = true, 1308 .chain_id = ALC880_FIXUP_GPIO1, 1309 }, 1310 [ALC880_FIXUP_3ST_BASE] = { 1311 .type = HDA_FIXUP_PINS, 1312 .v.pins = (const struct hda_pintbl[]) { 1313 { 0x14, 0x01014010 }, /* line-out */ 1314 { 0x15, 0x411111f0 }, /* N/A */ 1315 { 0x16, 0x411111f0 }, /* N/A */ 1316 { 0x17, 0x411111f0 }, /* N/A */ 1317 { 0x18, 0x01a19c30 }, /* mic-in */ 1318 { 0x19, 0x0121411f }, /* HP */ 1319 { 0x1a, 0x01813031 }, /* line-in */ 1320 { 0x1b, 0x02a19c40 }, /* front-mic */ 1321 { 0x1c, 0x411111f0 }, /* N/A */ 1322 { 0x1d, 0x411111f0 }, /* N/A */ 1323 /* 0x1e is filled in below */ 1324 { 0x1f, 0x411111f0 }, /* N/A */ 1325 { } 1326 } 1327 }, 1328 [ALC880_FIXUP_3ST] = { 1329 .type = HDA_FIXUP_PINS, 1330 .v.pins = (const struct hda_pintbl[]) { 1331 { 0x1e, 0x411111f0 }, /* N/A */ 1332 { } 1333 }, 1334 .chained = true, 1335 .chain_id = ALC880_FIXUP_3ST_BASE, 1336 }, 1337 [ALC880_FIXUP_3ST_DIG] = { 1338 .type = HDA_FIXUP_PINS, 1339 .v.pins = (const struct hda_pintbl[]) { 1340 { 0x1e, 0x0144111e }, /* SPDIF */ 1341 { } 1342 }, 1343 .chained = true, 1344 .chain_id = ALC880_FIXUP_3ST_BASE, 1345 }, 1346 [ALC880_FIXUP_5ST_BASE] = { 1347 .type = HDA_FIXUP_PINS, 1348 .v.pins = (const struct hda_pintbl[]) { 1349 { 0x14, 0x01014010 }, /* front */ 1350 { 0x15, 0x411111f0 }, /* N/A */ 1351 { 0x16, 0x01011411 }, /* CLFE */ 1352 { 0x17, 0x01016412 }, /* surr */ 1353 { 0x18, 0x01a19c30 }, /* mic-in */ 1354 { 0x19, 0x0121411f }, /* HP */ 1355 { 0x1a, 0x01813031 }, /* line-in */ 1356 { 0x1b, 0x02a19c40 }, /* front-mic */ 1357 { 0x1c, 0x411111f0 }, /* N/A */ 1358 { 0x1d, 0x411111f0 }, /* N/A */ 1359 /* 0x1e is filled in below */ 1360 { 0x1f, 0x411111f0 }, /* N/A */ 1361 { } 1362 } 1363 }, 1364 [ALC880_FIXUP_5ST] = { 1365 .type = HDA_FIXUP_PINS, 1366 .v.pins = (const struct hda_pintbl[]) { 1367 { 0x1e, 0x411111f0 }, /* N/A */ 1368 { } 1369 }, 1370 .chained = true, 1371 .chain_id = ALC880_FIXUP_5ST_BASE, 1372 }, 1373 [ALC880_FIXUP_5ST_DIG] = { 1374 .type = HDA_FIXUP_PINS, 1375 .v.pins = (const struct hda_pintbl[]) { 1376 { 0x1e, 0x0144111e }, /* SPDIF */ 1377 { } 1378 }, 1379 .chained = true, 1380 .chain_id = ALC880_FIXUP_5ST_BASE, 1381 }, 1382 [ALC880_FIXUP_6ST_BASE] = { 1383 .type = HDA_FIXUP_PINS, 1384 .v.pins = (const struct hda_pintbl[]) { 1385 { 0x14, 0x01014010 }, /* front */ 1386 { 0x15, 0x01016412 }, /* surr */ 1387 { 0x16, 0x01011411 }, /* CLFE */ 1388 { 0x17, 0x01012414 }, /* side */ 1389 { 0x18, 0x01a19c30 }, /* mic-in */ 1390 { 0x19, 0x02a19c40 }, /* front-mic */ 1391 { 0x1a, 0x01813031 }, /* line-in */ 1392 { 0x1b, 0x0121411f }, /* HP */ 1393 { 0x1c, 0x411111f0 }, /* N/A */ 1394 { 0x1d, 0x411111f0 }, /* N/A */ 1395 /* 0x1e is filled in below */ 1396 { 0x1f, 0x411111f0 }, /* N/A */ 1397 { } 1398 } 1399 }, 1400 [ALC880_FIXUP_6ST] = { 1401 .type = HDA_FIXUP_PINS, 1402 .v.pins = (const struct hda_pintbl[]) { 1403 { 0x1e, 0x411111f0 }, /* N/A */ 1404 { } 1405 }, 1406 .chained = true, 1407 .chain_id = ALC880_FIXUP_6ST_BASE, 1408 }, 1409 [ALC880_FIXUP_6ST_DIG] = { 1410 .type = HDA_FIXUP_PINS, 1411 .v.pins = (const struct hda_pintbl[]) { 1412 { 0x1e, 0x0144111e }, /* SPDIF */ 1413 { } 1414 }, 1415 .chained = true, 1416 .chain_id = ALC880_FIXUP_6ST_BASE, 1417 }, 1418 [ALC880_FIXUP_6ST_AUTOMUTE] = { 1419 .type = HDA_FIXUP_PINS, 1420 .v.pins = (const struct hda_pintbl[]) { 1421 { 0x1b, 0x0121401f }, /* HP with jack detect */ 1422 { } 1423 }, 1424 .chained_before = true, 1425 .chain_id = ALC880_FIXUP_6ST_BASE, 1426 }, 1427 }; 1428 1429 static const struct snd_pci_quirk alc880_fixup_tbl[] = { 1430 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), 1431 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A), 1432 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), 1433 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), 1434 SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE), 1435 SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), 1436 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), 1437 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), 1438 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), 1439 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), 1440 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), 1441 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), 1442 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), 1443 SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE), 1444 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734), 1445 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), 1446 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), 1447 SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), 1448 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), 1449 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), 1450 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), 1451 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25), 1452 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), 1453 1454 /* Below is the copied entries from alc880_quirks.c. 1455 * It's not quite sure whether BIOS sets the correct pin-config table 1456 * on these machines, thus they are kept to be compatible with 1457 * the old static quirks. Once when it's confirmed to work without 1458 * these overrides, it'd be better to remove. 1459 */ 1460 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), 1461 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), 1462 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), 1463 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), 1464 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), 1465 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), 1466 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), 1467 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), 1468 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), 1469 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), 1470 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), 1471 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), 1472 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), 1473 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), 1474 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), 1475 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), 1476 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), 1477 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), 1478 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), 1479 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), 1480 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), 1481 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ 1482 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), 1483 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), 1484 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), 1485 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), 1486 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), 1487 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), 1488 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), 1489 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), 1490 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), 1491 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), 1492 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), 1493 /* default Intel */ 1494 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), 1495 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), 1496 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), 1497 {} 1498 }; 1499 1500 static const struct hda_model_fixup alc880_fixup_models[] = { 1501 {.id = ALC880_FIXUP_3ST, .name = "3stack"}, 1502 {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, 1503 {.id = ALC880_FIXUP_5ST, .name = "5stack"}, 1504 {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, 1505 {.id = ALC880_FIXUP_6ST, .name = "6stack"}, 1506 {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, 1507 {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"}, 1508 {} 1509 }; 1510 1511 1512 /* 1513 * OK, here we have finally the patch for ALC880 1514 */ 1515 static int patch_alc880(struct hda_codec *codec) 1516 { 1517 struct alc_spec *spec; 1518 int err; 1519 1520 err = alc_alloc_spec(codec, 0x0b); 1521 if (err < 0) 1522 return err; 1523 1524 spec = codec->spec; 1525 spec->gen.need_dac_fix = 1; 1526 spec->gen.beep_nid = 0x01; 1527 1528 snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, 1529 alc880_fixups); 1530 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 1531 1532 /* automatic parse from the BIOS config */ 1533 err = alc880_parse_auto_config(codec); 1534 if (err < 0) 1535 goto error; 1536 1537 if (!spec->gen.no_analog) 1538 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 1539 1540 codec->patch_ops = alc_patch_ops; 1541 codec->patch_ops.unsol_event = alc880_unsol_event; 1542 1543 1544 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 1545 1546 return 0; 1547 1548 error: 1549 alc_free(codec); 1550 return err; 1551 } 1552 1553 1554 /* 1555 * ALC260 support 1556 */ 1557 static int alc260_parse_auto_config(struct hda_codec *codec) 1558 { 1559 static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; 1560 static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; 1561 return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); 1562 } 1563 1564 /* 1565 * Pin config fixes 1566 */ 1567 enum { 1568 ALC260_FIXUP_HP_DC5750, 1569 ALC260_FIXUP_HP_PIN_0F, 1570 ALC260_FIXUP_COEF, 1571 ALC260_FIXUP_GPIO1, 1572 ALC260_FIXUP_GPIO1_TOGGLE, 1573 ALC260_FIXUP_REPLACER, 1574 ALC260_FIXUP_HP_B1900, 1575 ALC260_FIXUP_KN1, 1576 ALC260_FIXUP_FSC_S7020, 1577 ALC260_FIXUP_FSC_S7020_JWSE, 1578 ALC260_FIXUP_VAIO_PINS, 1579 }; 1580 1581 static void alc260_gpio1_automute(struct hda_codec *codec) 1582 { 1583 struct alc_spec *spec = codec->spec; 1584 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1585 spec->gen.hp_jack_present); 1586 } 1587 1588 static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, 1589 const struct hda_fixup *fix, int action) 1590 { 1591 struct alc_spec *spec = codec->spec; 1592 if (action == HDA_FIXUP_ACT_PROBE) { 1593 /* although the machine has only one output pin, we need to 1594 * toggle GPIO1 according to the jack state 1595 */ 1596 spec->gen.automute_hook = alc260_gpio1_automute; 1597 spec->gen.detect_hp = 1; 1598 spec->gen.automute_speaker = 1; 1599 spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ 1600 snd_hda_jack_detect_enable_callback(codec, 0x0f, HDA_GEN_HP_EVENT, 1601 snd_hda_gen_hp_automute); 1602 snd_hda_add_verbs(codec, alc_gpio1_init_verbs); 1603 } 1604 } 1605 1606 static void alc260_fixup_kn1(struct hda_codec *codec, 1607 const struct hda_fixup *fix, int action) 1608 { 1609 struct alc_spec *spec = codec->spec; 1610 static const struct hda_pintbl pincfgs[] = { 1611 { 0x0f, 0x02214000 }, /* HP/speaker */ 1612 { 0x12, 0x90a60160 }, /* int mic */ 1613 { 0x13, 0x02a19000 }, /* ext mic */ 1614 { 0x18, 0x01446000 }, /* SPDIF out */ 1615 /* disable bogus I/O pins */ 1616 { 0x10, 0x411111f0 }, 1617 { 0x11, 0x411111f0 }, 1618 { 0x14, 0x411111f0 }, 1619 { 0x15, 0x411111f0 }, 1620 { 0x16, 0x411111f0 }, 1621 { 0x17, 0x411111f0 }, 1622 { 0x19, 0x411111f0 }, 1623 { } 1624 }; 1625 1626 switch (action) { 1627 case HDA_FIXUP_ACT_PRE_PROBE: 1628 snd_hda_apply_pincfgs(codec, pincfgs); 1629 break; 1630 case HDA_FIXUP_ACT_PROBE: 1631 spec->init_amp = ALC_INIT_NONE; 1632 break; 1633 } 1634 } 1635 1636 static void alc260_fixup_fsc_s7020(struct hda_codec *codec, 1637 const struct hda_fixup *fix, int action) 1638 { 1639 struct alc_spec *spec = codec->spec; 1640 if (action == HDA_FIXUP_ACT_PROBE) 1641 spec->init_amp = ALC_INIT_NONE; 1642 } 1643 1644 static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec, 1645 const struct hda_fixup *fix, int action) 1646 { 1647 struct alc_spec *spec = codec->spec; 1648 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 1649 spec->gen.add_jack_modes = 1; 1650 spec->gen.hp_mic = 1; 1651 } 1652 } 1653 1654 static const struct hda_fixup alc260_fixups[] = { 1655 [ALC260_FIXUP_HP_DC5750] = { 1656 .type = HDA_FIXUP_PINS, 1657 .v.pins = (const struct hda_pintbl[]) { 1658 { 0x11, 0x90130110 }, /* speaker */ 1659 { } 1660 } 1661 }, 1662 [ALC260_FIXUP_HP_PIN_0F] = { 1663 .type = HDA_FIXUP_PINS, 1664 .v.pins = (const struct hda_pintbl[]) { 1665 { 0x0f, 0x01214000 }, /* HP */ 1666 { } 1667 } 1668 }, 1669 [ALC260_FIXUP_COEF] = { 1670 .type = HDA_FIXUP_VERBS, 1671 .v.verbs = (const struct hda_verb[]) { 1672 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 }, 1673 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3040 }, 1674 { } 1675 }, 1676 }, 1677 [ALC260_FIXUP_GPIO1] = { 1678 .type = HDA_FIXUP_VERBS, 1679 .v.verbs = alc_gpio1_init_verbs, 1680 }, 1681 [ALC260_FIXUP_GPIO1_TOGGLE] = { 1682 .type = HDA_FIXUP_FUNC, 1683 .v.func = alc260_fixup_gpio1_toggle, 1684 .chained = true, 1685 .chain_id = ALC260_FIXUP_HP_PIN_0F, 1686 }, 1687 [ALC260_FIXUP_REPLACER] = { 1688 .type = HDA_FIXUP_VERBS, 1689 .v.verbs = (const struct hda_verb[]) { 1690 { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 }, 1691 { 0x1a, AC_VERB_SET_PROC_COEF, 0x3050 }, 1692 { } 1693 }, 1694 .chained = true, 1695 .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, 1696 }, 1697 [ALC260_FIXUP_HP_B1900] = { 1698 .type = HDA_FIXUP_FUNC, 1699 .v.func = alc260_fixup_gpio1_toggle, 1700 .chained = true, 1701 .chain_id = ALC260_FIXUP_COEF, 1702 }, 1703 [ALC260_FIXUP_KN1] = { 1704 .type = HDA_FIXUP_FUNC, 1705 .v.func = alc260_fixup_kn1, 1706 }, 1707 [ALC260_FIXUP_FSC_S7020] = { 1708 .type = HDA_FIXUP_FUNC, 1709 .v.func = alc260_fixup_fsc_s7020, 1710 }, 1711 [ALC260_FIXUP_FSC_S7020_JWSE] = { 1712 .type = HDA_FIXUP_FUNC, 1713 .v.func = alc260_fixup_fsc_s7020_jwse, 1714 .chained = true, 1715 .chain_id = ALC260_FIXUP_FSC_S7020, 1716 }, 1717 [ALC260_FIXUP_VAIO_PINS] = { 1718 .type = HDA_FIXUP_PINS, 1719 .v.pins = (const struct hda_pintbl[]) { 1720 /* Pin configs are missing completely on some VAIOs */ 1721 { 0x0f, 0x01211020 }, 1722 { 0x10, 0x0001003f }, 1723 { 0x11, 0x411111f0 }, 1724 { 0x12, 0x01a15930 }, 1725 { 0x13, 0x411111f0 }, 1726 { 0x14, 0x411111f0 }, 1727 { 0x15, 0x411111f0 }, 1728 { 0x16, 0x411111f0 }, 1729 { 0x17, 0x411111f0 }, 1730 { 0x18, 0x411111f0 }, 1731 { 0x19, 0x411111f0 }, 1732 { } 1733 } 1734 }, 1735 }; 1736 1737 static const struct snd_pci_quirk alc260_fixup_tbl[] = { 1738 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), 1739 SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), 1740 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), 1741 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), 1742 SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), 1743 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS), 1744 SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F), 1745 SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020), 1746 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), 1747 SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), 1748 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), 1749 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), 1750 {} 1751 }; 1752 1753 static const struct hda_model_fixup alc260_fixup_models[] = { 1754 {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"}, 1755 {.id = ALC260_FIXUP_COEF, .name = "coef"}, 1756 {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"}, 1757 {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"}, 1758 {} 1759 }; 1760 1761 /* 1762 */ 1763 static int patch_alc260(struct hda_codec *codec) 1764 { 1765 struct alc_spec *spec; 1766 int err; 1767 1768 err = alc_alloc_spec(codec, 0x07); 1769 if (err < 0) 1770 return err; 1771 1772 spec = codec->spec; 1773 /* as quite a few machines require HP amp for speaker outputs, 1774 * it's easier to enable it unconditionally; even if it's unneeded, 1775 * it's almost harmless. 1776 */ 1777 spec->gen.prefer_hp_amp = 1; 1778 spec->gen.beep_nid = 0x01; 1779 1780 snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl, 1781 alc260_fixups); 1782 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 1783 1784 /* automatic parse from the BIOS config */ 1785 err = alc260_parse_auto_config(codec); 1786 if (err < 0) 1787 goto error; 1788 1789 if (!spec->gen.no_analog) 1790 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); 1791 1792 codec->patch_ops = alc_patch_ops; 1793 spec->shutup = alc_eapd_shutup; 1794 1795 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 1796 1797 return 0; 1798 1799 error: 1800 alc_free(codec); 1801 return err; 1802 } 1803 1804 1805 /* 1806 * ALC882/883/885/888/889 support 1807 * 1808 * ALC882 is almost identical with ALC880 but has cleaner and more flexible 1809 * configuration. Each pin widget can choose any input DACs and a mixer. 1810 * Each ADC is connected from a mixer of all inputs. This makes possible 1811 * 6-channel independent captures. 1812 * 1813 * In addition, an independent DAC for the multi-playback (not used in this 1814 * driver yet). 1815 */ 1816 1817 /* 1818 * Pin config fixes 1819 */ 1820 enum { 1821 ALC882_FIXUP_ABIT_AW9D_MAX, 1822 ALC882_FIXUP_LENOVO_Y530, 1823 ALC882_FIXUP_PB_M5210, 1824 ALC882_FIXUP_ACER_ASPIRE_7736, 1825 ALC882_FIXUP_ASUS_W90V, 1826 ALC889_FIXUP_CD, 1827 ALC889_FIXUP_FRONT_HP_NO_PRESENCE, 1828 ALC889_FIXUP_VAIO_TT, 1829 ALC888_FIXUP_EEE1601, 1830 ALC882_FIXUP_EAPD, 1831 ALC883_FIXUP_EAPD, 1832 ALC883_FIXUP_ACER_EAPD, 1833 ALC882_FIXUP_GPIO1, 1834 ALC882_FIXUP_GPIO2, 1835 ALC882_FIXUP_GPIO3, 1836 ALC889_FIXUP_COEF, 1837 ALC882_FIXUP_ASUS_W2JC, 1838 ALC882_FIXUP_ACER_ASPIRE_4930G, 1839 ALC882_FIXUP_ACER_ASPIRE_8930G, 1840 ALC882_FIXUP_ASPIRE_8930G_VERBS, 1841 ALC885_FIXUP_MACPRO_GPIO, 1842 ALC889_FIXUP_DAC_ROUTE, 1843 ALC889_FIXUP_MBP_VREF, 1844 ALC889_FIXUP_IMAC91_VREF, 1845 ALC889_FIXUP_MBA11_VREF, 1846 ALC889_FIXUP_MBA21_VREF, 1847 ALC889_FIXUP_MP11_VREF, 1848 ALC882_FIXUP_INV_DMIC, 1849 ALC882_FIXUP_NO_PRIMARY_HP, 1850 ALC887_FIXUP_ASUS_BASS, 1851 ALC887_FIXUP_BASS_CHMAP, 1852 }; 1853 1854 static void alc889_fixup_coef(struct hda_codec *codec, 1855 const struct hda_fixup *fix, int action) 1856 { 1857 if (action != HDA_FIXUP_ACT_INIT) 1858 return; 1859 alc889_coef_init(codec); 1860 } 1861 1862 /* toggle speaker-output according to the hp-jack state */ 1863 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) 1864 { 1865 unsigned int gpiostate, gpiomask, gpiodir; 1866 1867 gpiostate = snd_hda_codec_read(codec, codec->afg, 0, 1868 AC_VERB_GET_GPIO_DATA, 0); 1869 1870 if (!muted) 1871 gpiostate |= (1 << pin); 1872 else 1873 gpiostate &= ~(1 << pin); 1874 1875 gpiomask = snd_hda_codec_read(codec, codec->afg, 0, 1876 AC_VERB_GET_GPIO_MASK, 0); 1877 gpiomask |= (1 << pin); 1878 1879 gpiodir = snd_hda_codec_read(codec, codec->afg, 0, 1880 AC_VERB_GET_GPIO_DIRECTION, 0); 1881 gpiodir |= (1 << pin); 1882 1883 1884 snd_hda_codec_write(codec, codec->afg, 0, 1885 AC_VERB_SET_GPIO_MASK, gpiomask); 1886 snd_hda_codec_write(codec, codec->afg, 0, 1887 AC_VERB_SET_GPIO_DIRECTION, gpiodir); 1888 1889 msleep(1); 1890 1891 snd_hda_codec_write(codec, codec->afg, 0, 1892 AC_VERB_SET_GPIO_DATA, gpiostate); 1893 } 1894 1895 /* set up GPIO at initialization */ 1896 static void alc885_fixup_macpro_gpio(struct hda_codec *codec, 1897 const struct hda_fixup *fix, int action) 1898 { 1899 if (action != HDA_FIXUP_ACT_INIT) 1900 return; 1901 alc882_gpio_mute(codec, 0, 0); 1902 alc882_gpio_mute(codec, 1, 0); 1903 } 1904 1905 /* Fix the connection of some pins for ALC889: 1906 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't 1907 * work correctly (bko#42740) 1908 */ 1909 static void alc889_fixup_dac_route(struct hda_codec *codec, 1910 const struct hda_fixup *fix, int action) 1911 { 1912 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 1913 /* fake the connections during parsing the tree */ 1914 hda_nid_t conn1[2] = { 0x0c, 0x0d }; 1915 hda_nid_t conn2[2] = { 0x0e, 0x0f }; 1916 snd_hda_override_conn_list(codec, 0x14, 2, conn1); 1917 snd_hda_override_conn_list(codec, 0x15, 2, conn1); 1918 snd_hda_override_conn_list(codec, 0x18, 2, conn2); 1919 snd_hda_override_conn_list(codec, 0x1a, 2, conn2); 1920 } else if (action == HDA_FIXUP_ACT_PROBE) { 1921 /* restore the connections */ 1922 hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; 1923 snd_hda_override_conn_list(codec, 0x14, 5, conn); 1924 snd_hda_override_conn_list(codec, 0x15, 5, conn); 1925 snd_hda_override_conn_list(codec, 0x18, 5, conn); 1926 snd_hda_override_conn_list(codec, 0x1a, 5, conn); 1927 } 1928 } 1929 1930 /* Set VREF on HP pin */ 1931 static void alc889_fixup_mbp_vref(struct hda_codec *codec, 1932 const struct hda_fixup *fix, int action) 1933 { 1934 struct alc_spec *spec = codec->spec; 1935 static hda_nid_t nids[2] = { 0x14, 0x15 }; 1936 int i; 1937 1938 if (action != HDA_FIXUP_ACT_INIT) 1939 return; 1940 for (i = 0; i < ARRAY_SIZE(nids); i++) { 1941 unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); 1942 if (get_defcfg_device(val) != AC_JACK_HP_OUT) 1943 continue; 1944 val = snd_hda_codec_get_pin_target(codec, nids[i]); 1945 val |= AC_PINCTL_VREF_80; 1946 snd_hda_set_pin_ctl(codec, nids[i], val); 1947 spec->gen.keep_vref_in_automute = 1; 1948 break; 1949 } 1950 } 1951 1952 static void alc889_fixup_mac_pins(struct hda_codec *codec, 1953 const hda_nid_t *nids, int num_nids) 1954 { 1955 struct alc_spec *spec = codec->spec; 1956 int i; 1957 1958 for (i = 0; i < num_nids; i++) { 1959 unsigned int val; 1960 val = snd_hda_codec_get_pin_target(codec, nids[i]); 1961 val |= AC_PINCTL_VREF_50; 1962 snd_hda_set_pin_ctl(codec, nids[i], val); 1963 } 1964 spec->gen.keep_vref_in_automute = 1; 1965 } 1966 1967 /* Set VREF on speaker pins on imac91 */ 1968 static void alc889_fixup_imac91_vref(struct hda_codec *codec, 1969 const struct hda_fixup *fix, int action) 1970 { 1971 static hda_nid_t nids[2] = { 0x18, 0x1a }; 1972 1973 if (action == HDA_FIXUP_ACT_INIT) 1974 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); 1975 } 1976 1977 /* Set VREF on speaker pins on mba11 */ 1978 static void alc889_fixup_mba11_vref(struct hda_codec *codec, 1979 const struct hda_fixup *fix, int action) 1980 { 1981 static hda_nid_t nids[1] = { 0x18 }; 1982 1983 if (action == HDA_FIXUP_ACT_INIT) 1984 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); 1985 } 1986 1987 /* Set VREF on speaker pins on mba21 */ 1988 static void alc889_fixup_mba21_vref(struct hda_codec *codec, 1989 const struct hda_fixup *fix, int action) 1990 { 1991 static hda_nid_t nids[2] = { 0x18, 0x19 }; 1992 1993 if (action == HDA_FIXUP_ACT_INIT) 1994 alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids)); 1995 } 1996 1997 /* Don't take HP output as primary 1998 * Strangely, the speaker output doesn't work on Vaio Z and some Vaio 1999 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05 2000 */ 2001 static void alc882_fixup_no_primary_hp(struct hda_codec *codec, 2002 const struct hda_fixup *fix, int action) 2003 { 2004 struct alc_spec *spec = codec->spec; 2005 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 2006 spec->gen.no_primary_hp = 1; 2007 spec->gen.no_multi_io = 1; 2008 } 2009 } 2010 2011 static void alc_fixup_bass_chmap(struct hda_codec *codec, 2012 const struct hda_fixup *fix, int action); 2013 2014 static const struct hda_fixup alc882_fixups[] = { 2015 [ALC882_FIXUP_ABIT_AW9D_MAX] = { 2016 .type = HDA_FIXUP_PINS, 2017 .v.pins = (const struct hda_pintbl[]) { 2018 { 0x15, 0x01080104 }, /* side */ 2019 { 0x16, 0x01011012 }, /* rear */ 2020 { 0x17, 0x01016011 }, /* clfe */ 2021 { } 2022 } 2023 }, 2024 [ALC882_FIXUP_LENOVO_Y530] = { 2025 .type = HDA_FIXUP_PINS, 2026 .v.pins = (const struct hda_pintbl[]) { 2027 { 0x15, 0x99130112 }, /* rear int speakers */ 2028 { 0x16, 0x99130111 }, /* subwoofer */ 2029 { } 2030 } 2031 }, 2032 [ALC882_FIXUP_PB_M5210] = { 2033 .type = HDA_FIXUP_PINCTLS, 2034 .v.pins = (const struct hda_pintbl[]) { 2035 { 0x19, PIN_VREF50 }, 2036 {} 2037 } 2038 }, 2039 [ALC882_FIXUP_ACER_ASPIRE_7736] = { 2040 .type = HDA_FIXUP_FUNC, 2041 .v.func = alc_fixup_sku_ignore, 2042 }, 2043 [ALC882_FIXUP_ASUS_W90V] = { 2044 .type = HDA_FIXUP_PINS, 2045 .v.pins = (const struct hda_pintbl[]) { 2046 { 0x16, 0x99130110 }, /* fix sequence for CLFE */ 2047 { } 2048 } 2049 }, 2050 [ALC889_FIXUP_CD] = { 2051 .type = HDA_FIXUP_PINS, 2052 .v.pins = (const struct hda_pintbl[]) { 2053 { 0x1c, 0x993301f0 }, /* CD */ 2054 { } 2055 } 2056 }, 2057 [ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = { 2058 .type = HDA_FIXUP_PINS, 2059 .v.pins = (const struct hda_pintbl[]) { 2060 { 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */ 2061 { } 2062 }, 2063 .chained = true, 2064 .chain_id = ALC889_FIXUP_CD, 2065 }, 2066 [ALC889_FIXUP_VAIO_TT] = { 2067 .type = HDA_FIXUP_PINS, 2068 .v.pins = (const struct hda_pintbl[]) { 2069 { 0x17, 0x90170111 }, /* hidden surround speaker */ 2070 { } 2071 } 2072 }, 2073 [ALC888_FIXUP_EEE1601] = { 2074 .type = HDA_FIXUP_VERBS, 2075 .v.verbs = (const struct hda_verb[]) { 2076 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, 2077 { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, 2078 { } 2079 } 2080 }, 2081 [ALC882_FIXUP_EAPD] = { 2082 .type = HDA_FIXUP_VERBS, 2083 .v.verbs = (const struct hda_verb[]) { 2084 /* change to EAPD mode */ 2085 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 2086 { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, 2087 { } 2088 } 2089 }, 2090 [ALC883_FIXUP_EAPD] = { 2091 .type = HDA_FIXUP_VERBS, 2092 .v.verbs = (const struct hda_verb[]) { 2093 /* change to EAPD mode */ 2094 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 2095 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, 2096 { } 2097 } 2098 }, 2099 [ALC883_FIXUP_ACER_EAPD] = { 2100 .type = HDA_FIXUP_VERBS, 2101 .v.verbs = (const struct hda_verb[]) { 2102 /* eanable EAPD on Acer laptops */ 2103 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 2104 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, 2105 { } 2106 } 2107 }, 2108 [ALC882_FIXUP_GPIO1] = { 2109 .type = HDA_FIXUP_VERBS, 2110 .v.verbs = alc_gpio1_init_verbs, 2111 }, 2112 [ALC882_FIXUP_GPIO2] = { 2113 .type = HDA_FIXUP_VERBS, 2114 .v.verbs = alc_gpio2_init_verbs, 2115 }, 2116 [ALC882_FIXUP_GPIO3] = { 2117 .type = HDA_FIXUP_VERBS, 2118 .v.verbs = alc_gpio3_init_verbs, 2119 }, 2120 [ALC882_FIXUP_ASUS_W2JC] = { 2121 .type = HDA_FIXUP_VERBS, 2122 .v.verbs = alc_gpio1_init_verbs, 2123 .chained = true, 2124 .chain_id = ALC882_FIXUP_EAPD, 2125 }, 2126 [ALC889_FIXUP_COEF] = { 2127 .type = HDA_FIXUP_FUNC, 2128 .v.func = alc889_fixup_coef, 2129 }, 2130 [ALC882_FIXUP_ACER_ASPIRE_4930G] = { 2131 .type = HDA_FIXUP_PINS, 2132 .v.pins = (const struct hda_pintbl[]) { 2133 { 0x16, 0x99130111 }, /* CLFE speaker */ 2134 { 0x17, 0x99130112 }, /* surround speaker */ 2135 { } 2136 }, 2137 .chained = true, 2138 .chain_id = ALC882_FIXUP_GPIO1, 2139 }, 2140 [ALC882_FIXUP_ACER_ASPIRE_8930G] = { 2141 .type = HDA_FIXUP_PINS, 2142 .v.pins = (const struct hda_pintbl[]) { 2143 { 0x16, 0x99130111 }, /* CLFE speaker */ 2144 { 0x1b, 0x99130112 }, /* surround speaker */ 2145 { } 2146 }, 2147 .chained = true, 2148 .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, 2149 }, 2150 [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { 2151 /* additional init verbs for Acer Aspire 8930G */ 2152 .type = HDA_FIXUP_VERBS, 2153 .v.verbs = (const struct hda_verb[]) { 2154 /* Enable all DACs */ 2155 /* DAC DISABLE/MUTE 1? */ 2156 /* setting bits 1-5 disables DAC nids 0x02-0x06 2157 * apparently. Init=0x38 */ 2158 { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, 2159 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, 2160 /* DAC DISABLE/MUTE 2? */ 2161 /* some bit here disables the other DACs. 2162 * Init=0x4900 */ 2163 { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, 2164 { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, 2165 /* DMIC fix 2166 * This laptop has a stereo digital microphone. 2167 * The mics are only 1cm apart which makes the stereo 2168 * useless. However, either the mic or the ALC889 2169 * makes the signal become a difference/sum signal 2170 * instead of standard stereo, which is annoying. 2171 * So instead we flip this bit which makes the 2172 * codec replicate the sum signal to both channels, 2173 * turning it into a normal mono mic. 2174 */ 2175 /* DMIC_CONTROL? Init value = 0x0001 */ 2176 { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, 2177 { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, 2178 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 2179 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, 2180 { } 2181 }, 2182 .chained = true, 2183 .chain_id = ALC882_FIXUP_GPIO1, 2184 }, 2185 [ALC885_FIXUP_MACPRO_GPIO] = { 2186 .type = HDA_FIXUP_FUNC, 2187 .v.func = alc885_fixup_macpro_gpio, 2188 }, 2189 [ALC889_FIXUP_DAC_ROUTE] = { 2190 .type = HDA_FIXUP_FUNC, 2191 .v.func = alc889_fixup_dac_route, 2192 }, 2193 [ALC889_FIXUP_MBP_VREF] = { 2194 .type = HDA_FIXUP_FUNC, 2195 .v.func = alc889_fixup_mbp_vref, 2196 .chained = true, 2197 .chain_id = ALC882_FIXUP_GPIO1, 2198 }, 2199 [ALC889_FIXUP_IMAC91_VREF] = { 2200 .type = HDA_FIXUP_FUNC, 2201 .v.func = alc889_fixup_imac91_vref, 2202 .chained = true, 2203 .chain_id = ALC882_FIXUP_GPIO1, 2204 }, 2205 [ALC889_FIXUP_MBA11_VREF] = { 2206 .type = HDA_FIXUP_FUNC, 2207 .v.func = alc889_fixup_mba11_vref, 2208 .chained = true, 2209 .chain_id = ALC889_FIXUP_MBP_VREF, 2210 }, 2211 [ALC889_FIXUP_MBA21_VREF] = { 2212 .type = HDA_FIXUP_FUNC, 2213 .v.func = alc889_fixup_mba21_vref, 2214 .chained = true, 2215 .chain_id = ALC889_FIXUP_MBP_VREF, 2216 }, 2217 [ALC889_FIXUP_MP11_VREF] = { 2218 .type = HDA_FIXUP_FUNC, 2219 .v.func = alc889_fixup_mba11_vref, 2220 .chained = true, 2221 .chain_id = ALC885_FIXUP_MACPRO_GPIO, 2222 }, 2223 [ALC882_FIXUP_INV_DMIC] = { 2224 .type = HDA_FIXUP_FUNC, 2225 .v.func = alc_fixup_inv_dmic_0x12, 2226 }, 2227 [ALC882_FIXUP_NO_PRIMARY_HP] = { 2228 .type = HDA_FIXUP_FUNC, 2229 .v.func = alc882_fixup_no_primary_hp, 2230 }, 2231 [ALC887_FIXUP_ASUS_BASS] = { 2232 .type = HDA_FIXUP_PINS, 2233 .v.pins = (const struct hda_pintbl[]) { 2234 {0x16, 0x99130130}, /* bass speaker */ 2235 {} 2236 }, 2237 .chained = true, 2238 .chain_id = ALC887_FIXUP_BASS_CHMAP, 2239 }, 2240 [ALC887_FIXUP_BASS_CHMAP] = { 2241 .type = HDA_FIXUP_FUNC, 2242 .v.func = alc_fixup_bass_chmap, 2243 }, 2244 }; 2245 2246 static const struct snd_pci_quirk alc882_fixup_tbl[] = { 2247 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), 2248 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), 2249 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), 2250 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), 2251 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), 2252 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), 2253 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", 2254 ALC882_FIXUP_ACER_ASPIRE_4930G), 2255 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", 2256 ALC882_FIXUP_ACER_ASPIRE_4930G), 2257 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", 2258 ALC882_FIXUP_ACER_ASPIRE_8930G), 2259 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", 2260 ALC882_FIXUP_ACER_ASPIRE_8930G), 2261 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", 2262 ALC882_FIXUP_ACER_ASPIRE_4930G), 2263 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", 2264 ALC882_FIXUP_ACER_ASPIRE_4930G), 2265 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", 2266 ALC882_FIXUP_ACER_ASPIRE_4930G), 2267 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), 2268 SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G", 2269 ALC882_FIXUP_ACER_ASPIRE_4930G), 2270 SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), 2271 SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G), 2272 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736), 2273 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), 2274 SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), 2275 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), 2276 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), 2277 SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS), 2278 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), 2279 SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP), 2280 SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP), 2281 2282 /* All Apple entries are in codec SSIDs */ 2283 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), 2284 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), 2285 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), 2286 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF), 2287 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), 2288 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), 2289 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), 2290 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), 2291 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), 2292 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF), 2293 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF), 2294 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), 2295 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), 2296 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), 2297 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), 2298 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), 2299 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), 2300 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO), 2301 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF), 2302 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), 2303 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), 2304 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), 2305 2306 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), 2307 SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), 2308 SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), 2309 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE), 2310 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX), 2311 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), 2312 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), 2313 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), 2314 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), 2315 {} 2316 }; 2317 2318 static const struct hda_model_fixup alc882_fixup_models[] = { 2319 {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, 2320 {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"}, 2321 {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"}, 2322 {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"}, 2323 {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"}, 2324 {} 2325 }; 2326 2327 /* 2328 * BIOS auto configuration 2329 */ 2330 /* almost identical with ALC880 parser... */ 2331 static int alc882_parse_auto_config(struct hda_codec *codec) 2332 { 2333 static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; 2334 static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 2335 return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); 2336 } 2337 2338 /* 2339 */ 2340 static int patch_alc882(struct hda_codec *codec) 2341 { 2342 struct alc_spec *spec; 2343 int err; 2344 2345 err = alc_alloc_spec(codec, 0x0b); 2346 if (err < 0) 2347 return err; 2348 2349 spec = codec->spec; 2350 2351 switch (codec->vendor_id) { 2352 case 0x10ec0882: 2353 case 0x10ec0885: 2354 case 0x10ec0900: 2355 break; 2356 default: 2357 /* ALC883 and variants */ 2358 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 2359 break; 2360 } 2361 2362 snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, 2363 alc882_fixups); 2364 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 2365 2366 alc_auto_parse_customize_define(codec); 2367 2368 if (has_cdefine_beep(codec)) 2369 spec->gen.beep_nid = 0x01; 2370 2371 /* automatic parse from the BIOS config */ 2372 err = alc882_parse_auto_config(codec); 2373 if (err < 0) 2374 goto error; 2375 2376 if (!spec->gen.no_analog && spec->gen.beep_nid) 2377 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 2378 2379 codec->patch_ops = alc_patch_ops; 2380 2381 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 2382 2383 return 0; 2384 2385 error: 2386 alc_free(codec); 2387 return err; 2388 } 2389 2390 2391 /* 2392 * ALC262 support 2393 */ 2394 static int alc262_parse_auto_config(struct hda_codec *codec) 2395 { 2396 static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; 2397 static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 2398 return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); 2399 } 2400 2401 /* 2402 * Pin config fixes 2403 */ 2404 enum { 2405 ALC262_FIXUP_FSC_H270, 2406 ALC262_FIXUP_FSC_S7110, 2407 ALC262_FIXUP_HP_Z200, 2408 ALC262_FIXUP_TYAN, 2409 ALC262_FIXUP_LENOVO_3000, 2410 ALC262_FIXUP_BENQ, 2411 ALC262_FIXUP_BENQ_T31, 2412 ALC262_FIXUP_INV_DMIC, 2413 ALC262_FIXUP_INTEL_BAYLEYBAY, 2414 }; 2415 2416 static const struct hda_fixup alc262_fixups[] = { 2417 [ALC262_FIXUP_FSC_H270] = { 2418 .type = HDA_FIXUP_PINS, 2419 .v.pins = (const struct hda_pintbl[]) { 2420 { 0x14, 0x99130110 }, /* speaker */ 2421 { 0x15, 0x0221142f }, /* front HP */ 2422 { 0x1b, 0x0121141f }, /* rear HP */ 2423 { } 2424 } 2425 }, 2426 [ALC262_FIXUP_FSC_S7110] = { 2427 .type = HDA_FIXUP_PINS, 2428 .v.pins = (const struct hda_pintbl[]) { 2429 { 0x15, 0x90170110 }, /* speaker */ 2430 { } 2431 }, 2432 .chained = true, 2433 .chain_id = ALC262_FIXUP_BENQ, 2434 }, 2435 [ALC262_FIXUP_HP_Z200] = { 2436 .type = HDA_FIXUP_PINS, 2437 .v.pins = (const struct hda_pintbl[]) { 2438 { 0x16, 0x99130120 }, /* internal speaker */ 2439 { } 2440 } 2441 }, 2442 [ALC262_FIXUP_TYAN] = { 2443 .type = HDA_FIXUP_PINS, 2444 .v.pins = (const struct hda_pintbl[]) { 2445 { 0x14, 0x1993e1f0 }, /* int AUX */ 2446 { } 2447 } 2448 }, 2449 [ALC262_FIXUP_LENOVO_3000] = { 2450 .type = HDA_FIXUP_PINCTLS, 2451 .v.pins = (const struct hda_pintbl[]) { 2452 { 0x19, PIN_VREF50 }, 2453 {} 2454 }, 2455 .chained = true, 2456 .chain_id = ALC262_FIXUP_BENQ, 2457 }, 2458 [ALC262_FIXUP_BENQ] = { 2459 .type = HDA_FIXUP_VERBS, 2460 .v.verbs = (const struct hda_verb[]) { 2461 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 2462 { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, 2463 {} 2464 } 2465 }, 2466 [ALC262_FIXUP_BENQ_T31] = { 2467 .type = HDA_FIXUP_VERBS, 2468 .v.verbs = (const struct hda_verb[]) { 2469 { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, 2470 { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, 2471 {} 2472 } 2473 }, 2474 [ALC262_FIXUP_INV_DMIC] = { 2475 .type = HDA_FIXUP_FUNC, 2476 .v.func = alc_fixup_inv_dmic_0x12, 2477 }, 2478 [ALC262_FIXUP_INTEL_BAYLEYBAY] = { 2479 .type = HDA_FIXUP_FUNC, 2480 .v.func = alc_fixup_no_depop_delay, 2481 }, 2482 }; 2483 2484 static const struct snd_pci_quirk alc262_fixup_tbl[] = { 2485 SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), 2486 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110), 2487 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), 2488 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), 2489 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), 2490 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), 2491 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), 2492 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), 2493 SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY), 2494 {} 2495 }; 2496 2497 static const struct hda_model_fixup alc262_fixup_models[] = { 2498 {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"}, 2499 {} 2500 }; 2501 2502 /* 2503 */ 2504 static int patch_alc262(struct hda_codec *codec) 2505 { 2506 struct alc_spec *spec; 2507 int err; 2508 2509 err = alc_alloc_spec(codec, 0x0b); 2510 if (err < 0) 2511 return err; 2512 2513 spec = codec->spec; 2514 spec->gen.shared_mic_vref_pin = 0x18; 2515 2516 #if 0 2517 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is 2518 * under-run 2519 */ 2520 { 2521 int tmp; 2522 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 2523 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); 2524 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 2525 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); 2526 } 2527 #endif 2528 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 2529 2530 snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl, 2531 alc262_fixups); 2532 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 2533 2534 alc_auto_parse_customize_define(codec); 2535 2536 if (has_cdefine_beep(codec)) 2537 spec->gen.beep_nid = 0x01; 2538 2539 /* automatic parse from the BIOS config */ 2540 err = alc262_parse_auto_config(codec); 2541 if (err < 0) 2542 goto error; 2543 2544 if (!spec->gen.no_analog && spec->gen.beep_nid) 2545 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 2546 2547 codec->patch_ops = alc_patch_ops; 2548 spec->shutup = alc_eapd_shutup; 2549 2550 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 2551 2552 return 0; 2553 2554 error: 2555 alc_free(codec); 2556 return err; 2557 } 2558 2559 /* 2560 * ALC268 2561 */ 2562 /* bind Beep switches of both NID 0x0f and 0x10 */ 2563 static const struct hda_bind_ctls alc268_bind_beep_sw = { 2564 .ops = &snd_hda_bind_sw, 2565 .values = { 2566 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), 2567 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), 2568 0 2569 }, 2570 }; 2571 2572 static const struct snd_kcontrol_new alc268_beep_mixer[] = { 2573 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), 2574 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), 2575 { } 2576 }; 2577 2578 /* set PCBEEP vol = 0, mute connections */ 2579 static const struct hda_verb alc268_beep_init_verbs[] = { 2580 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2581 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2582 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2583 { } 2584 }; 2585 2586 enum { 2587 ALC268_FIXUP_INV_DMIC, 2588 ALC268_FIXUP_HP_EAPD, 2589 ALC268_FIXUP_SPDIF, 2590 }; 2591 2592 static const struct hda_fixup alc268_fixups[] = { 2593 [ALC268_FIXUP_INV_DMIC] = { 2594 .type = HDA_FIXUP_FUNC, 2595 .v.func = alc_fixup_inv_dmic_0x12, 2596 }, 2597 [ALC268_FIXUP_HP_EAPD] = { 2598 .type = HDA_FIXUP_VERBS, 2599 .v.verbs = (const struct hda_verb[]) { 2600 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0}, 2601 {} 2602 } 2603 }, 2604 [ALC268_FIXUP_SPDIF] = { 2605 .type = HDA_FIXUP_PINS, 2606 .v.pins = (const struct hda_pintbl[]) { 2607 { 0x1e, 0x014b1180 }, /* enable SPDIF out */ 2608 {} 2609 } 2610 }, 2611 }; 2612 2613 static const struct hda_model_fixup alc268_fixup_models[] = { 2614 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"}, 2615 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"}, 2616 {} 2617 }; 2618 2619 static const struct snd_pci_quirk alc268_fixup_tbl[] = { 2620 SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF), 2621 SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC), 2622 /* below is codec SSID since multiple Toshiba laptops have the 2623 * same PCI SSID 1179:ff00 2624 */ 2625 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD), 2626 {} 2627 }; 2628 2629 /* 2630 * BIOS auto configuration 2631 */ 2632 static int alc268_parse_auto_config(struct hda_codec *codec) 2633 { 2634 static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 2635 return alc_parse_auto_config(codec, NULL, alc268_ssids); 2636 } 2637 2638 /* 2639 */ 2640 static int patch_alc268(struct hda_codec *codec) 2641 { 2642 struct alc_spec *spec; 2643 int err; 2644 2645 /* ALC268 has no aa-loopback mixer */ 2646 err = alc_alloc_spec(codec, 0); 2647 if (err < 0) 2648 return err; 2649 2650 spec = codec->spec; 2651 spec->gen.beep_nid = 0x01; 2652 2653 snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); 2654 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 2655 2656 /* automatic parse from the BIOS config */ 2657 err = alc268_parse_auto_config(codec); 2658 if (err < 0) 2659 goto error; 2660 2661 if (err > 0 && !spec->gen.no_analog && 2662 spec->gen.autocfg.speaker_pins[0] != 0x1d) { 2663 add_mixer(spec, alc268_beep_mixer); 2664 snd_hda_add_verbs(codec, alc268_beep_init_verbs); 2665 if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) 2666 /* override the amp caps for beep generator */ 2667 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, 2668 (0x0c << AC_AMPCAP_OFFSET_SHIFT) | 2669 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | 2670 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | 2671 (0 << AC_AMPCAP_MUTE_SHIFT)); 2672 } 2673 2674 codec->patch_ops = alc_patch_ops; 2675 spec->shutup = alc_eapd_shutup; 2676 2677 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 2678 2679 return 0; 2680 2681 error: 2682 alc_free(codec); 2683 return err; 2684 } 2685 2686 /* 2687 * ALC269 2688 */ 2689 2690 static int playback_pcm_open(struct hda_pcm_stream *hinfo, 2691 struct hda_codec *codec, 2692 struct snd_pcm_substream *substream) 2693 { 2694 struct hda_gen_spec *spec = codec->spec; 2695 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, 2696 hinfo); 2697 } 2698 2699 static int playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2700 struct hda_codec *codec, 2701 unsigned int stream_tag, 2702 unsigned int format, 2703 struct snd_pcm_substream *substream) 2704 { 2705 struct hda_gen_spec *spec = codec->spec; 2706 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, 2707 stream_tag, format, substream); 2708 } 2709 2710 static int playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 2711 struct hda_codec *codec, 2712 struct snd_pcm_substream *substream) 2713 { 2714 struct hda_gen_spec *spec = codec->spec; 2715 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 2716 } 2717 2718 static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { 2719 .substreams = 1, 2720 .channels_min = 2, 2721 .channels_max = 8, 2722 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ 2723 /* NID is set in alc_build_pcms */ 2724 .ops = { 2725 .open = playback_pcm_open, 2726 .prepare = playback_pcm_prepare, 2727 .cleanup = playback_pcm_cleanup 2728 }, 2729 }; 2730 2731 static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { 2732 .substreams = 1, 2733 .channels_min = 2, 2734 .channels_max = 2, 2735 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ 2736 /* NID is set in alc_build_pcms */ 2737 }; 2738 2739 /* different alc269-variants */ 2740 enum { 2741 ALC269_TYPE_ALC269VA, 2742 ALC269_TYPE_ALC269VB, 2743 ALC269_TYPE_ALC269VC, 2744 ALC269_TYPE_ALC269VD, 2745 ALC269_TYPE_ALC280, 2746 ALC269_TYPE_ALC282, 2747 ALC269_TYPE_ALC283, 2748 ALC269_TYPE_ALC284, 2749 ALC269_TYPE_ALC285, 2750 ALC269_TYPE_ALC286, 2751 ALC269_TYPE_ALC255, 2752 }; 2753 2754 /* 2755 * BIOS auto configuration 2756 */ 2757 static int alc269_parse_auto_config(struct hda_codec *codec) 2758 { 2759 static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; 2760 static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; 2761 static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 2762 struct alc_spec *spec = codec->spec; 2763 const hda_nid_t *ssids; 2764 2765 switch (spec->codec_variant) { 2766 case ALC269_TYPE_ALC269VA: 2767 case ALC269_TYPE_ALC269VC: 2768 case ALC269_TYPE_ALC280: 2769 case ALC269_TYPE_ALC284: 2770 case ALC269_TYPE_ALC285: 2771 ssids = alc269va_ssids; 2772 break; 2773 case ALC269_TYPE_ALC269VB: 2774 case ALC269_TYPE_ALC269VD: 2775 case ALC269_TYPE_ALC282: 2776 case ALC269_TYPE_ALC283: 2777 case ALC269_TYPE_ALC286: 2778 case ALC269_TYPE_ALC255: 2779 ssids = alc269_ssids; 2780 break; 2781 default: 2782 ssids = alc269_ssids; 2783 break; 2784 } 2785 2786 return alc_parse_auto_config(codec, alc269_ignore, ssids); 2787 } 2788 2789 static int find_ext_mic_pin(struct hda_codec *codec); 2790 2791 static void alc286_shutup(struct hda_codec *codec) 2792 { 2793 int i; 2794 int mic_pin = find_ext_mic_pin(codec); 2795 /* don't shut up pins when unloading the driver; otherwise it breaks 2796 * the default pin setup at the next load of the driver 2797 */ 2798 if (codec->bus->shutdown) 2799 return; 2800 for (i = 0; i < codec->init_pins.used; i++) { 2801 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); 2802 /* use read here for syncing after issuing each verb */ 2803 if (pin->nid != mic_pin) 2804 snd_hda_codec_read(codec, pin->nid, 0, 2805 AC_VERB_SET_PIN_WIDGET_CONTROL, 0); 2806 } 2807 codec->pins_shutup = 1; 2808 } 2809 2810 static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up) 2811 { 2812 int val = alc_read_coef_idx(codec, 0x04); 2813 if (val == -1) 2814 return; 2815 if (power_up) 2816 val |= 1 << 11; 2817 else 2818 val &= ~(1 << 11); 2819 alc_write_coef_idx(codec, 0x04, val); 2820 } 2821 2822 static void alc269_shutup(struct hda_codec *codec) 2823 { 2824 struct alc_spec *spec = codec->spec; 2825 2826 if (spec->codec_variant == ALC269_TYPE_ALC269VB) 2827 alc269vb_toggle_power_output(codec, 0); 2828 if (spec->codec_variant == ALC269_TYPE_ALC269VB && 2829 (alc_get_coef0(codec) & 0x00ff) == 0x018) { 2830 msleep(150); 2831 } 2832 snd_hda_shutup_pins(codec); 2833 } 2834 2835 static void alc282_restore_default_value(struct hda_codec *codec) 2836 { 2837 int val; 2838 2839 /* Power Down Control */ 2840 alc_write_coef_idx(codec, 0x03, 0x0002); 2841 /* FIFO and filter clock */ 2842 alc_write_coef_idx(codec, 0x05, 0x0700); 2843 /* DMIC control */ 2844 alc_write_coef_idx(codec, 0x07, 0x0200); 2845 /* Analog clock */ 2846 val = alc_read_coef_idx(codec, 0x06); 2847 alc_write_coef_idx(codec, 0x06, (val & ~0x00f0) | 0x0); 2848 /* JD */ 2849 val = alc_read_coef_idx(codec, 0x08); 2850 alc_write_coef_idx(codec, 0x08, (val & ~0xfffc) | 0x0c2c); 2851 /* JD offset1 */ 2852 alc_write_coef_idx(codec, 0x0a, 0xcccc); 2853 /* JD offset2 */ 2854 alc_write_coef_idx(codec, 0x0b, 0xcccc); 2855 /* LDO1/2/3, DAC/ADC */ 2856 alc_write_coef_idx(codec, 0x0e, 0x6e00); 2857 /* JD */ 2858 val = alc_read_coef_idx(codec, 0x0f); 2859 alc_write_coef_idx(codec, 0x0f, (val & ~0xf800) | 0x1000); 2860 /* Capless */ 2861 val = alc_read_coef_idx(codec, 0x10); 2862 alc_write_coef_idx(codec, 0x10, (val & ~0xfc00) | 0x0c00); 2863 /* Class D test 4 */ 2864 alc_write_coef_idx(codec, 0x6f, 0x0); 2865 /* IO power down directly */ 2866 val = alc_read_coef_idx(codec, 0x0c); 2867 alc_write_coef_idx(codec, 0x0c, (val & ~0xfe00) | 0x0); 2868 /* ANC */ 2869 alc_write_coef_idx(codec, 0x34, 0xa0c0); 2870 /* AGC MUX */ 2871 val = alc_read_coef_idx(codec, 0x16); 2872 alc_write_coef_idx(codec, 0x16, (val & ~0x0008) | 0x0); 2873 /* DAC simple content protection */ 2874 val = alc_read_coef_idx(codec, 0x1d); 2875 alc_write_coef_idx(codec, 0x1d, (val & ~0x00e0) | 0x0); 2876 /* ADC simple content protection */ 2877 val = alc_read_coef_idx(codec, 0x1f); 2878 alc_write_coef_idx(codec, 0x1f, (val & ~0x00e0) | 0x0); 2879 /* DAC ADC Zero Detection */ 2880 alc_write_coef_idx(codec, 0x21, 0x8804); 2881 /* PLL */ 2882 alc_write_coef_idx(codec, 0x63, 0x2902); 2883 /* capless control 2 */ 2884 alc_write_coef_idx(codec, 0x68, 0xa080); 2885 /* capless control 3 */ 2886 alc_write_coef_idx(codec, 0x69, 0x3400); 2887 /* capless control 4 */ 2888 alc_write_coef_idx(codec, 0x6a, 0x2f3e); 2889 /* capless control 5 */ 2890 alc_write_coef_idx(codec, 0x6b, 0x0); 2891 /* class D test 2 */ 2892 val = alc_read_coef_idx(codec, 0x6d); 2893 alc_write_coef_idx(codec, 0x6d, (val & ~0x0fff) | 0x0900); 2894 /* class D test 3 */ 2895 alc_write_coef_idx(codec, 0x6e, 0x110a); 2896 /* class D test 5 */ 2897 val = alc_read_coef_idx(codec, 0x70); 2898 alc_write_coef_idx(codec, 0x70, (val & ~0x00f8) | 0x00d8); 2899 /* class D test 6 */ 2900 alc_write_coef_idx(codec, 0x71, 0x0014); 2901 /* classD OCP */ 2902 alc_write_coef_idx(codec, 0x72, 0xc2ba); 2903 /* classD pure DC test */ 2904 val = alc_read_coef_idx(codec, 0x77); 2905 alc_write_coef_idx(codec, 0x77, (val & ~0x0f80) | 0x0); 2906 /* Class D amp control */ 2907 alc_write_coef_idx(codec, 0x6c, 0xfc06); 2908 } 2909 2910 static void alc282_init(struct hda_codec *codec) 2911 { 2912 struct alc_spec *spec = codec->spec; 2913 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0]; 2914 bool hp_pin_sense; 2915 int coef78; 2916 2917 alc282_restore_default_value(codec); 2918 2919 if (!hp_pin) 2920 return; 2921 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin); 2922 coef78 = alc_read_coef_idx(codec, 0x78); 2923 2924 /* Index 0x78 Direct Drive HP AMP LPM Control 1 */ 2925 /* Headphone capless set to high power mode */ 2926 alc_write_coef_idx(codec, 0x78, 0x9004); 2927 2928 if (hp_pin_sense) 2929 msleep(2); 2930 2931 snd_hda_codec_write(codec, hp_pin, 0, 2932 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); 2933 2934 if (hp_pin_sense) 2935 msleep(85); 2936 2937 snd_hda_codec_write(codec, hp_pin, 0, 2938 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 2939 2940 if (hp_pin_sense) 2941 msleep(100); 2942 2943 /* Headphone capless set to normal mode */ 2944 alc_write_coef_idx(codec, 0x78, coef78); 2945 } 2946 2947 static void alc282_shutup(struct hda_codec *codec) 2948 { 2949 struct alc_spec *spec = codec->spec; 2950 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0]; 2951 bool hp_pin_sense; 2952 int coef78; 2953 2954 if (!hp_pin) { 2955 alc269_shutup(codec); 2956 return; 2957 } 2958 2959 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin); 2960 coef78 = alc_read_coef_idx(codec, 0x78); 2961 alc_write_coef_idx(codec, 0x78, 0x9004); 2962 2963 if (hp_pin_sense) 2964 msleep(2); 2965 2966 snd_hda_codec_write(codec, hp_pin, 0, 2967 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); 2968 2969 if (hp_pin_sense) 2970 msleep(85); 2971 2972 snd_hda_codec_write(codec, hp_pin, 0, 2973 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); 2974 2975 if (hp_pin_sense) 2976 msleep(100); 2977 2978 alc_auto_setup_eapd(codec, false); 2979 snd_hda_shutup_pins(codec); 2980 alc_write_coef_idx(codec, 0x78, coef78); 2981 } 2982 2983 static void alc283_restore_default_value(struct hda_codec *codec) 2984 { 2985 int val; 2986 2987 /* Power Down Control */ 2988 alc_write_coef_idx(codec, 0x03, 0x0002); 2989 /* FIFO and filter clock */ 2990 alc_write_coef_idx(codec, 0x05, 0x0700); 2991 /* DMIC control */ 2992 alc_write_coef_idx(codec, 0x07, 0x0200); 2993 /* Analog clock */ 2994 val = alc_read_coef_idx(codec, 0x06); 2995 alc_write_coef_idx(codec, 0x06, (val & ~0x00f0) | 0x0); 2996 /* JD */ 2997 val = alc_read_coef_idx(codec, 0x08); 2998 alc_write_coef_idx(codec, 0x08, (val & ~0xfffc) | 0x0c2c); 2999 /* JD offset1 */ 3000 alc_write_coef_idx(codec, 0x0a, 0xcccc); 3001 /* JD offset2 */ 3002 alc_write_coef_idx(codec, 0x0b, 0xcccc); 3003 /* LDO1/2/3, DAC/ADC */ 3004 alc_write_coef_idx(codec, 0x0e, 0x6fc0); 3005 /* JD */ 3006 val = alc_read_coef_idx(codec, 0x0f); 3007 alc_write_coef_idx(codec, 0x0f, (val & ~0xf800) | 0x1000); 3008 /* Capless */ 3009 val = alc_read_coef_idx(codec, 0x10); 3010 alc_write_coef_idx(codec, 0x10, (val & ~0xfc00) | 0x0c00); 3011 /* Class D test 4 */ 3012 alc_write_coef_idx(codec, 0x3a, 0x0); 3013 /* IO power down directly */ 3014 val = alc_read_coef_idx(codec, 0x0c); 3015 alc_write_coef_idx(codec, 0x0c, (val & ~0xfe00) | 0x0); 3016 /* ANC */ 3017 alc_write_coef_idx(codec, 0x22, 0xa0c0); 3018 /* AGC MUX */ 3019 val = alc_read_coefex_idx(codec, 0x53, 0x01); 3020 alc_write_coefex_idx(codec, 0x53, 0x01, (val & ~0x000f) | 0x0008); 3021 /* DAC simple content protection */ 3022 val = alc_read_coef_idx(codec, 0x1d); 3023 alc_write_coef_idx(codec, 0x1d, (val & ~0x00e0) | 0x0); 3024 /* ADC simple content protection */ 3025 val = alc_read_coef_idx(codec, 0x1f); 3026 alc_write_coef_idx(codec, 0x1f, (val & ~0x00e0) | 0x0); 3027 /* DAC ADC Zero Detection */ 3028 alc_write_coef_idx(codec, 0x21, 0x8804); 3029 /* PLL */ 3030 alc_write_coef_idx(codec, 0x2e, 0x2902); 3031 /* capless control 2 */ 3032 alc_write_coef_idx(codec, 0x33, 0xa080); 3033 /* capless control 3 */ 3034 alc_write_coef_idx(codec, 0x34, 0x3400); 3035 /* capless control 4 */ 3036 alc_write_coef_idx(codec, 0x35, 0x2f3e); 3037 /* capless control 5 */ 3038 alc_write_coef_idx(codec, 0x36, 0x0); 3039 /* class D test 2 */ 3040 val = alc_read_coef_idx(codec, 0x38); 3041 alc_write_coef_idx(codec, 0x38, (val & ~0x0fff) | 0x0900); 3042 /* class D test 3 */ 3043 alc_write_coef_idx(codec, 0x39, 0x110a); 3044 /* class D test 5 */ 3045 val = alc_read_coef_idx(codec, 0x3b); 3046 alc_write_coef_idx(codec, 0x3b, (val & ~0x00f8) | 0x00d8); 3047 /* class D test 6 */ 3048 alc_write_coef_idx(codec, 0x3c, 0x0014); 3049 /* classD OCP */ 3050 alc_write_coef_idx(codec, 0x3d, 0xc2ba); 3051 /* classD pure DC test */ 3052 val = alc_read_coef_idx(codec, 0x42); 3053 alc_write_coef_idx(codec, 0x42, (val & ~0x0f80) | 0x0); 3054 /* test mode */ 3055 alc_write_coef_idx(codec, 0x49, 0x0); 3056 /* Class D DC enable */ 3057 val = alc_read_coef_idx(codec, 0x40); 3058 alc_write_coef_idx(codec, 0x40, (val & ~0xf800) | 0x9800); 3059 /* DC offset */ 3060 val = alc_read_coef_idx(codec, 0x42); 3061 alc_write_coef_idx(codec, 0x42, (val & ~0xf000) | 0x2000); 3062 /* Class D amp control */ 3063 alc_write_coef_idx(codec, 0x37, 0xfc06); 3064 } 3065 3066 static void alc283_init(struct hda_codec *codec) 3067 { 3068 struct alc_spec *spec = codec->spec; 3069 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0]; 3070 bool hp_pin_sense; 3071 int val; 3072 3073 if (!spec->gen.autocfg.hp_outs) { 3074 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT) 3075 hp_pin = spec->gen.autocfg.line_out_pins[0]; 3076 } 3077 3078 alc283_restore_default_value(codec); 3079 3080 if (!hp_pin) 3081 return; 3082 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin); 3083 3084 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */ 3085 /* Headphone capless set to high power mode */ 3086 alc_write_coef_idx(codec, 0x43, 0x9004); 3087 3088 snd_hda_codec_write(codec, hp_pin, 0, 3089 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); 3090 3091 if (hp_pin_sense) 3092 msleep(85); 3093 3094 snd_hda_codec_write(codec, hp_pin, 0, 3095 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 3096 3097 if (hp_pin_sense) 3098 msleep(85); 3099 /* Index 0x46 Combo jack auto switch control 2 */ 3100 /* 3k pull low control for Headset jack. */ 3101 val = alc_read_coef_idx(codec, 0x46); 3102 alc_write_coef_idx(codec, 0x46, val & ~(3 << 12)); 3103 /* Headphone capless set to normal mode */ 3104 alc_write_coef_idx(codec, 0x43, 0x9614); 3105 } 3106 3107 static void alc283_shutup(struct hda_codec *codec) 3108 { 3109 struct alc_spec *spec = codec->spec; 3110 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0]; 3111 bool hp_pin_sense; 3112 int val; 3113 3114 if (!spec->gen.autocfg.hp_outs) { 3115 if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT) 3116 hp_pin = spec->gen.autocfg.line_out_pins[0]; 3117 } 3118 3119 if (!hp_pin) { 3120 alc269_shutup(codec); 3121 return; 3122 } 3123 3124 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin); 3125 3126 alc_write_coef_idx(codec, 0x43, 0x9004); 3127 3128 snd_hda_codec_write(codec, hp_pin, 0, 3129 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); 3130 3131 if (hp_pin_sense) 3132 msleep(100); 3133 3134 snd_hda_codec_write(codec, hp_pin, 0, 3135 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); 3136 3137 val = alc_read_coef_idx(codec, 0x46); 3138 alc_write_coef_idx(codec, 0x46, val | (3 << 12)); 3139 3140 if (hp_pin_sense) 3141 msleep(100); 3142 alc_auto_setup_eapd(codec, false); 3143 snd_hda_shutup_pins(codec); 3144 alc_write_coef_idx(codec, 0x43, 0x9614); 3145 } 3146 3147 static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg, 3148 unsigned int val) 3149 { 3150 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1); 3151 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */ 3152 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */ 3153 } 3154 3155 static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg) 3156 { 3157 unsigned int val; 3158 3159 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1); 3160 val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0) 3161 & 0xffff; 3162 val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0) 3163 << 16; 3164 return val; 3165 } 3166 3167 static void alc5505_dsp_halt(struct hda_codec *codec) 3168 { 3169 unsigned int val; 3170 3171 alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */ 3172 alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */ 3173 alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */ 3174 alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */ 3175 alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */ 3176 alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */ 3177 alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */ 3178 val = alc5505_coef_get(codec, 0x6220); 3179 alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */ 3180 } 3181 3182 static void alc5505_dsp_back_from_halt(struct hda_codec *codec) 3183 { 3184 alc5505_coef_set(codec, 0x61b8, 0x04133302); 3185 alc5505_coef_set(codec, 0x61b0, 0x00005b16); 3186 alc5505_coef_set(codec, 0x61b4, 0x040a2b02); 3187 alc5505_coef_set(codec, 0x6230, 0xf80d4011); 3188 alc5505_coef_set(codec, 0x6220, 0x2002010f); 3189 alc5505_coef_set(codec, 0x880c, 0x00000004); 3190 } 3191 3192 static void alc5505_dsp_init(struct hda_codec *codec) 3193 { 3194 unsigned int val; 3195 3196 alc5505_dsp_halt(codec); 3197 alc5505_dsp_back_from_halt(codec); 3198 alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */ 3199 alc5505_coef_set(codec, 0x61b0, 0x5b16); 3200 alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */ 3201 alc5505_coef_set(codec, 0x61b4, 0x04132b02); 3202 alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/ 3203 alc5505_coef_set(codec, 0x61b8, 0x041f3302); 3204 snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */ 3205 alc5505_coef_set(codec, 0x61b8, 0x041b3302); 3206 alc5505_coef_set(codec, 0x61b8, 0x04173302); 3207 alc5505_coef_set(codec, 0x61b8, 0x04163302); 3208 alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */ 3209 alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */ 3210 alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */ 3211 3212 val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */ 3213 if (val <= 3) 3214 alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */ 3215 else 3216 alc5505_coef_set(codec, 0x6220, 0x6002018f); 3217 3218 alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/ 3219 alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */ 3220 alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */ 3221 alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */ 3222 alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */ 3223 alc5505_coef_set(codec, 0x880c, 0x00000003); 3224 alc5505_coef_set(codec, 0x880c, 0x00000010); 3225 3226 #ifdef HALT_REALTEK_ALC5505 3227 alc5505_dsp_halt(codec); 3228 #endif 3229 } 3230 3231 #ifdef HALT_REALTEK_ALC5505 3232 #define alc5505_dsp_suspend(codec) /* NOP */ 3233 #define alc5505_dsp_resume(codec) /* NOP */ 3234 #else 3235 #define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec) 3236 #define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec) 3237 #endif 3238 3239 #ifdef CONFIG_PM 3240 static int alc269_suspend(struct hda_codec *codec) 3241 { 3242 struct alc_spec *spec = codec->spec; 3243 3244 if (spec->has_alc5505_dsp) 3245 alc5505_dsp_suspend(codec); 3246 return alc_suspend(codec); 3247 } 3248 3249 static int alc269_resume(struct hda_codec *codec) 3250 { 3251 struct alc_spec *spec = codec->spec; 3252 3253 if (spec->codec_variant == ALC269_TYPE_ALC269VB) 3254 alc269vb_toggle_power_output(codec, 0); 3255 if (spec->codec_variant == ALC269_TYPE_ALC269VB && 3256 (alc_get_coef0(codec) & 0x00ff) == 0x018) { 3257 msleep(150); 3258 } 3259 3260 codec->patch_ops.init(codec); 3261 3262 if (spec->codec_variant == ALC269_TYPE_ALC269VB) 3263 alc269vb_toggle_power_output(codec, 1); 3264 if (spec->codec_variant == ALC269_TYPE_ALC269VB && 3265 (alc_get_coef0(codec) & 0x00ff) == 0x017) { 3266 msleep(200); 3267 } 3268 3269 snd_hda_codec_resume_amp(codec); 3270 snd_hda_codec_resume_cache(codec); 3271 alc_inv_dmic_sync(codec, true); 3272 hda_call_check_power_status(codec, 0x01); 3273 3274 /* on some machine, the BIOS will clear the codec gpio data when enter 3275 * suspend, and won't restore the data after resume, so we restore it 3276 * in the driver. 3277 */ 3278 if (spec->gpio_led) 3279 snd_hda_codec_write(codec, codec->afg, 0, AC_VERB_SET_GPIO_DATA, 3280 spec->gpio_led); 3281 3282 if (spec->has_alc5505_dsp) 3283 alc5505_dsp_resume(codec); 3284 3285 return 0; 3286 } 3287 #endif /* CONFIG_PM */ 3288 3289 static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec, 3290 const struct hda_fixup *fix, int action) 3291 { 3292 struct alc_spec *spec = codec->spec; 3293 3294 if (action == HDA_FIXUP_ACT_PRE_PROBE) 3295 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; 3296 } 3297 3298 static void alc269_fixup_hweq(struct hda_codec *codec, 3299 const struct hda_fixup *fix, int action) 3300 { 3301 int coef; 3302 3303 if (action != HDA_FIXUP_ACT_INIT) 3304 return; 3305 coef = alc_read_coef_idx(codec, 0x1e); 3306 alc_write_coef_idx(codec, 0x1e, coef | 0x80); 3307 } 3308 3309 static void alc269_fixup_headset_mic(struct hda_codec *codec, 3310 const struct hda_fixup *fix, int action) 3311 { 3312 struct alc_spec *spec = codec->spec; 3313 3314 if (action == HDA_FIXUP_ACT_PRE_PROBE) 3315 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC; 3316 } 3317 3318 static void alc271_fixup_dmic(struct hda_codec *codec, 3319 const struct hda_fixup *fix, int action) 3320 { 3321 static const struct hda_verb verbs[] = { 3322 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, 3323 {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, 3324 {} 3325 }; 3326 unsigned int cfg; 3327 3328 if (strcmp(codec->chip_name, "ALC271X") && 3329 strcmp(codec->chip_name, "ALC269VB")) 3330 return; 3331 cfg = snd_hda_codec_get_pincfg(codec, 0x12); 3332 if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) 3333 snd_hda_sequence_write(codec, verbs); 3334 } 3335 3336 static void alc269_fixup_pcm_44k(struct hda_codec *codec, 3337 const struct hda_fixup *fix, int action) 3338 { 3339 struct alc_spec *spec = codec->spec; 3340 3341 if (action != HDA_FIXUP_ACT_PROBE) 3342 return; 3343 3344 /* Due to a hardware problem on Lenovo Ideadpad, we need to 3345 * fix the sample rate of analog I/O to 44.1kHz 3346 */ 3347 spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback; 3348 spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture; 3349 } 3350 3351 static void alc269_fixup_stereo_dmic(struct hda_codec *codec, 3352 const struct hda_fixup *fix, int action) 3353 { 3354 int coef; 3355 3356 if (action != HDA_FIXUP_ACT_INIT) 3357 return; 3358 /* The digital-mic unit sends PDM (differential signal) instead of 3359 * the standard PCM, thus you can't record a valid mono stream as is. 3360 * Below is a workaround specific to ALC269 to control the dmic 3361 * signal source as mono. 3362 */ 3363 coef = alc_read_coef_idx(codec, 0x07); 3364 alc_write_coef_idx(codec, 0x07, coef | 0x80); 3365 } 3366 3367 static void alc269_quanta_automute(struct hda_codec *codec) 3368 { 3369 snd_hda_gen_update_outputs(codec); 3370 3371 snd_hda_codec_write(codec, 0x20, 0, 3372 AC_VERB_SET_COEF_INDEX, 0x0c); 3373 snd_hda_codec_write(codec, 0x20, 0, 3374 AC_VERB_SET_PROC_COEF, 0x680); 3375 3376 snd_hda_codec_write(codec, 0x20, 0, 3377 AC_VERB_SET_COEF_INDEX, 0x0c); 3378 snd_hda_codec_write(codec, 0x20, 0, 3379 AC_VERB_SET_PROC_COEF, 0x480); 3380 } 3381 3382 static void alc269_fixup_quanta_mute(struct hda_codec *codec, 3383 const struct hda_fixup *fix, int action) 3384 { 3385 struct alc_spec *spec = codec->spec; 3386 if (action != HDA_FIXUP_ACT_PROBE) 3387 return; 3388 spec->gen.automute_hook = alc269_quanta_automute; 3389 } 3390 3391 static void alc269_x101_hp_automute_hook(struct hda_codec *codec, 3392 struct hda_jack_tbl *jack) 3393 { 3394 struct alc_spec *spec = codec->spec; 3395 int vref; 3396 msleep(200); 3397 snd_hda_gen_hp_automute(codec, jack); 3398 3399 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0; 3400 msleep(100); 3401 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 3402 vref); 3403 msleep(500); 3404 snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 3405 vref); 3406 } 3407 3408 static void alc269_fixup_x101_headset_mic(struct hda_codec *codec, 3409 const struct hda_fixup *fix, int action) 3410 { 3411 struct alc_spec *spec = codec->spec; 3412 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 3413 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC; 3414 spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook; 3415 } 3416 } 3417 3418 3419 /* update mute-LED according to the speaker mute state via mic VREF pin */ 3420 static void alc269_fixup_mic_mute_hook(void *private_data, int enabled) 3421 { 3422 struct hda_codec *codec = private_data; 3423 struct alc_spec *spec = codec->spec; 3424 unsigned int pinval; 3425 3426 if (spec->mute_led_polarity) 3427 enabled = !enabled; 3428 pinval = snd_hda_codec_get_pin_target(codec, spec->mute_led_nid); 3429 pinval &= ~AC_PINCTL_VREFEN; 3430 pinval |= enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80; 3431 if (spec->mute_led_nid) 3432 snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval); 3433 } 3434 3435 /* Make sure the led works even in runtime suspend */ 3436 static unsigned int led_power_filter(struct hda_codec *codec, 3437 hda_nid_t nid, 3438 unsigned int power_state) 3439 { 3440 struct alc_spec *spec = codec->spec; 3441 3442 if (power_state != AC_PWRST_D3 || nid == 0 || 3443 (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid)) 3444 return power_state; 3445 3446 /* Set pin ctl again, it might have just been set to 0 */ 3447 snd_hda_set_pin_ctl(codec, nid, 3448 snd_hda_codec_get_pin_target(codec, nid)); 3449 3450 return AC_PWRST_D0; 3451 } 3452 3453 static void alc269_fixup_hp_mute_led(struct hda_codec *codec, 3454 const struct hda_fixup *fix, int action) 3455 { 3456 struct alc_spec *spec = codec->spec; 3457 const struct dmi_device *dev = NULL; 3458 3459 if (action != HDA_FIXUP_ACT_PRE_PROBE) 3460 return; 3461 3462 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) { 3463 int pol, pin; 3464 if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2) 3465 continue; 3466 if (pin < 0x0a || pin >= 0x10) 3467 break; 3468 spec->mute_led_polarity = pol; 3469 spec->mute_led_nid = pin - 0x0a + 0x18; 3470 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; 3471 spec->gen.vmaster_mute_enum = 1; 3472 codec->power_filter = led_power_filter; 3473 codec_dbg(codec, 3474 "Detected mute LED for %x:%d\n", spec->mute_led_nid, 3475 spec->mute_led_polarity); 3476 break; 3477 } 3478 } 3479 3480 static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec, 3481 const struct hda_fixup *fix, int action) 3482 { 3483 struct alc_spec *spec = codec->spec; 3484 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 3485 spec->mute_led_polarity = 0; 3486 spec->mute_led_nid = 0x18; 3487 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; 3488 spec->gen.vmaster_mute_enum = 1; 3489 codec->power_filter = led_power_filter; 3490 } 3491 } 3492 3493 static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec, 3494 const struct hda_fixup *fix, int action) 3495 { 3496 struct alc_spec *spec = codec->spec; 3497 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 3498 spec->mute_led_polarity = 0; 3499 spec->mute_led_nid = 0x19; 3500 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; 3501 spec->gen.vmaster_mute_enum = 1; 3502 codec->power_filter = led_power_filter; 3503 } 3504 } 3505 3506 /* turn on/off mute LED per vmaster hook */ 3507 static void alc269_fixup_hp_gpio_mute_hook(void *private_data, int enabled) 3508 { 3509 struct hda_codec *codec = private_data; 3510 struct alc_spec *spec = codec->spec; 3511 unsigned int oldval = spec->gpio_led; 3512 3513 if (enabled) 3514 spec->gpio_led &= ~0x08; 3515 else 3516 spec->gpio_led |= 0x08; 3517 if (spec->gpio_led != oldval) 3518 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 3519 spec->gpio_led); 3520 } 3521 3522 /* turn on/off mic-mute LED per capture hook */ 3523 static void alc269_fixup_hp_gpio_mic_mute_hook(struct hda_codec *codec, 3524 struct snd_kcontrol *kcontrol, 3525 struct snd_ctl_elem_value *ucontrol) 3526 { 3527 struct alc_spec *spec = codec->spec; 3528 unsigned int oldval = spec->gpio_led; 3529 3530 if (!ucontrol) 3531 return; 3532 3533 if (ucontrol->value.integer.value[0] || 3534 ucontrol->value.integer.value[1]) 3535 spec->gpio_led &= ~0x10; 3536 else 3537 spec->gpio_led |= 0x10; 3538 if (spec->gpio_led != oldval) 3539 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 3540 spec->gpio_led); 3541 } 3542 3543 static void alc269_fixup_hp_gpio_led(struct hda_codec *codec, 3544 const struct hda_fixup *fix, int action) 3545 { 3546 struct alc_spec *spec = codec->spec; 3547 static const struct hda_verb gpio_init[] = { 3548 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 }, 3549 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 }, 3550 {} 3551 }; 3552 3553 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 3554 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook; 3555 spec->gen.cap_sync_hook = alc269_fixup_hp_gpio_mic_mute_hook; 3556 spec->gpio_led = 0; 3557 snd_hda_add_verbs(codec, gpio_init); 3558 } 3559 } 3560 3561 /* turn on/off mic-mute LED per capture hook */ 3562 static void alc269_fixup_hp_cap_mic_mute_hook(struct hda_codec *codec, 3563 struct snd_kcontrol *kcontrol, 3564 struct snd_ctl_elem_value *ucontrol) 3565 { 3566 struct alc_spec *spec = codec->spec; 3567 unsigned int pinval, enable, disable; 3568 3569 pinval = snd_hda_codec_get_pin_target(codec, spec->cap_mute_led_nid); 3570 pinval &= ~AC_PINCTL_VREFEN; 3571 enable = pinval | AC_PINCTL_VREF_80; 3572 disable = pinval | AC_PINCTL_VREF_HIZ; 3573 3574 if (!ucontrol) 3575 return; 3576 3577 if (ucontrol->value.integer.value[0] || 3578 ucontrol->value.integer.value[1]) 3579 pinval = disable; 3580 else 3581 pinval = enable; 3582 3583 if (spec->cap_mute_led_nid) 3584 snd_hda_set_pin_ctl_cache(codec, spec->cap_mute_led_nid, pinval); 3585 } 3586 3587 static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec, 3588 const struct hda_fixup *fix, int action) 3589 { 3590 struct alc_spec *spec = codec->spec; 3591 static const struct hda_verb gpio_init[] = { 3592 { 0x01, AC_VERB_SET_GPIO_MASK, 0x08 }, 3593 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x08 }, 3594 {} 3595 }; 3596 3597 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 3598 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook; 3599 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook; 3600 spec->gpio_led = 0; 3601 spec->cap_mute_led_nid = 0x18; 3602 snd_hda_add_verbs(codec, gpio_init); 3603 codec->power_filter = led_power_filter; 3604 } 3605 } 3606 3607 static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec, 3608 const struct hda_fixup *fix, int action) 3609 { 3610 struct alc_spec *spec = codec->spec; 3611 3612 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 3613 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; 3614 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook; 3615 spec->mute_led_polarity = 0; 3616 spec->mute_led_nid = 0x1a; 3617 spec->cap_mute_led_nid = 0x18; 3618 spec->gen.vmaster_mute_enum = 1; 3619 codec->power_filter = led_power_filter; 3620 } 3621 } 3622 3623 static void alc_headset_mode_unplugged(struct hda_codec *codec) 3624 { 3625 int val; 3626 3627 switch (codec->vendor_id) { 3628 case 0x10ec0255: 3629 /* LDO and MISC control */ 3630 alc_write_coef_idx(codec, 0x1b, 0x0c0b); 3631 /* UAJ function set to menual mode */ 3632 alc_write_coef_idx(codec, 0x45, 0xd089); 3633 /* Direct Drive HP Amp control(Set to verb control)*/ 3634 val = alc_read_coefex_idx(codec, 0x57, 0x05); 3635 alc_write_coefex_idx(codec, 0x57, 0x05, val & ~(1<<14)); 3636 /* Set MIC2 Vref gate with HP */ 3637 alc_write_coef_idx(codec, 0x06, 0x6104); 3638 /* Direct Drive HP Amp control */ 3639 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6); 3640 break; 3641 case 0x10ec0233: 3642 case 0x10ec0283: 3643 alc_write_coef_idx(codec, 0x1b, 0x0c0b); 3644 alc_write_coef_idx(codec, 0x45, 0xc429); 3645 val = alc_read_coef_idx(codec, 0x35); 3646 alc_write_coef_idx(codec, 0x35, val & 0xbfff); 3647 alc_write_coef_idx(codec, 0x06, 0x2104); 3648 alc_write_coef_idx(codec, 0x1a, 0x0001); 3649 alc_write_coef_idx(codec, 0x26, 0x0004); 3650 alc_write_coef_idx(codec, 0x32, 0x42a3); 3651 break; 3652 case 0x10ec0292: 3653 alc_write_coef_idx(codec, 0x76, 0x000e); 3654 alc_write_coef_idx(codec, 0x6c, 0x2400); 3655 alc_write_coef_idx(codec, 0x18, 0x7308); 3656 alc_write_coef_idx(codec, 0x6b, 0xc429); 3657 break; 3658 case 0x10ec0293: 3659 /* SET Line1 JD to 0 */ 3660 val = alc_read_coef_idx(codec, 0x10); 3661 alc_write_coef_idx(codec, 0x10, (val & ~(7<<8)) | 6<<8); 3662 /* SET charge pump by verb */ 3663 val = alc_read_coefex_idx(codec, 0x57, 0x05); 3664 alc_write_coefex_idx(codec, 0x57, 0x05, (val & ~(1<<15|1<<13)) | 0x0); 3665 /* SET EN_OSW to 1 */ 3666 val = alc_read_coefex_idx(codec, 0x57, 0x03); 3667 alc_write_coefex_idx(codec, 0x57, 0x03, (val & ~(1<<10)) | (1<<10) ); 3668 /* Combo JD gating with LINE1-VREFO */ 3669 val = alc_read_coef_idx(codec, 0x1a); 3670 alc_write_coef_idx(codec, 0x1a, (val & ~(1<<3)) | (1<<3)); 3671 /* Set to TRS type */ 3672 alc_write_coef_idx(codec, 0x45, 0xc429); 3673 /* Combo Jack auto detect */ 3674 val = alc_read_coef_idx(codec, 0x4a); 3675 alc_write_coef_idx(codec, 0x4a, (val & 0xfff0) | 0x000e); 3676 break; 3677 case 0x10ec0668: 3678 alc_write_coef_idx(codec, 0x15, 0x0d40); 3679 alc_write_coef_idx(codec, 0xb7, 0x802b); 3680 break; 3681 } 3682 codec_dbg(codec, "Headset jack set to unplugged mode.\n"); 3683 } 3684 3685 3686 static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin, 3687 hda_nid_t mic_pin) 3688 { 3689 int val; 3690 3691 switch (codec->vendor_id) { 3692 case 0x10ec0255: 3693 alc_write_coef_idx(codec, 0x45, 0xc489); 3694 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); 3695 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8aa6); 3696 /* Set MIC2 Vref gate to normal */ 3697 alc_write_coef_idx(codec, 0x06, 0x6100); 3698 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); 3699 break; 3700 case 0x10ec0233: 3701 case 0x10ec0283: 3702 alc_write_coef_idx(codec, 0x45, 0xc429); 3703 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); 3704 val = alc_read_coef_idx(codec, 0x35); 3705 alc_write_coef_idx(codec, 0x35, val | 1<<14); 3706 alc_write_coef_idx(codec, 0x06, 0x2100); 3707 alc_write_coef_idx(codec, 0x1a, 0x0021); 3708 alc_write_coef_idx(codec, 0x26, 0x008c); 3709 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); 3710 break; 3711 case 0x10ec0292: 3712 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); 3713 alc_write_coef_idx(codec, 0x19, 0xa208); 3714 alc_write_coef_idx(codec, 0x2e, 0xacf0); 3715 break; 3716 case 0x10ec0293: 3717 /* Set to TRS mode */ 3718 alc_write_coef_idx(codec, 0x45, 0xc429); 3719 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); 3720 /* SET charge pump by verb */ 3721 val = alc_read_coefex_idx(codec, 0x57, 0x05); 3722 alc_write_coefex_idx(codec, 0x57, 0x05, (val & ~(1<<15|1<<13)) | (1<<15|1<<13)); 3723 /* SET EN_OSW to 0 */ 3724 val = alc_read_coefex_idx(codec, 0x57, 0x03); 3725 alc_write_coefex_idx(codec, 0x57, 0x03, (val & ~(1<<10)) | 0x0); 3726 /* Combo JD gating without LINE1-VREFO */ 3727 val = alc_read_coef_idx(codec, 0x1a); 3728 alc_write_coef_idx(codec, 0x1a, (val & ~(1<<3)) | 0x0); 3729 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); 3730 break; 3731 case 0x10ec0668: 3732 alc_write_coef_idx(codec, 0x11, 0x0001); 3733 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); 3734 alc_write_coef_idx(codec, 0xb7, 0x802b); 3735 alc_write_coef_idx(codec, 0xb5, 0x1040); 3736 val = alc_read_coef_idx(codec, 0xc3); 3737 alc_write_coef_idx(codec, 0xc3, val | 1<<12); 3738 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); 3739 break; 3740 } 3741 codec_dbg(codec, "Headset jack set to mic-in mode.\n"); 3742 } 3743 3744 static void alc_headset_mode_default(struct hda_codec *codec) 3745 { 3746 int val; 3747 3748 switch (codec->vendor_id) { 3749 case 0x10ec0255: 3750 alc_write_coef_idx(codec, 0x45, 0xc089); 3751 alc_write_coef_idx(codec, 0x45, 0xc489); 3752 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6); 3753 alc_write_coef_idx(codec, 0x49, 0x0049); 3754 break; 3755 case 0x10ec0233: 3756 case 0x10ec0283: 3757 alc_write_coef_idx(codec, 0x06, 0x2100); 3758 alc_write_coef_idx(codec, 0x32, 0x4ea3); 3759 break; 3760 case 0x10ec0292: 3761 alc_write_coef_idx(codec, 0x76, 0x000e); 3762 alc_write_coef_idx(codec, 0x6c, 0x2400); 3763 alc_write_coef_idx(codec, 0x6b, 0xc429); 3764 alc_write_coef_idx(codec, 0x18, 0x7308); 3765 break; 3766 case 0x10ec0293: 3767 /* Combo Jack auto detect */ 3768 val = alc_read_coef_idx(codec, 0x4a); 3769 alc_write_coef_idx(codec, 0x4a, (val & 0xfff0) | 0x000e); 3770 /* Set to TRS type */ 3771 alc_write_coef_idx(codec, 0x45, 0xC429); 3772 /* Combo JD gating without LINE1-VREFO */ 3773 val = alc_read_coef_idx(codec, 0x1a); 3774 alc_write_coef_idx(codec, 0x1a, (val & ~(1<<3)) | 0x0); 3775 break; 3776 case 0x10ec0668: 3777 alc_write_coef_idx(codec, 0x11, 0x0041); 3778 alc_write_coef_idx(codec, 0x15, 0x0d40); 3779 alc_write_coef_idx(codec, 0xb7, 0x802b); 3780 break; 3781 } 3782 codec_dbg(codec, "Headset jack set to headphone (default) mode.\n"); 3783 } 3784 3785 /* Iphone type */ 3786 static void alc_headset_mode_ctia(struct hda_codec *codec) 3787 { 3788 int val; 3789 3790 switch (codec->vendor_id) { 3791 case 0x10ec0255: 3792 /* Set to CTIA type */ 3793 alc_write_coef_idx(codec, 0x45, 0xd489); 3794 alc_write_coef_idx(codec, 0x1b, 0x0c2b); 3795 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6); 3796 break; 3797 case 0x10ec0233: 3798 case 0x10ec0283: 3799 alc_write_coef_idx(codec, 0x45, 0xd429); 3800 alc_write_coef_idx(codec, 0x1b, 0x0c2b); 3801 alc_write_coef_idx(codec, 0x32, 0x4ea3); 3802 break; 3803 case 0x10ec0292: 3804 alc_write_coef_idx(codec, 0x6b, 0xd429); 3805 alc_write_coef_idx(codec, 0x76, 0x0008); 3806 alc_write_coef_idx(codec, 0x18, 0x7388); 3807 break; 3808 case 0x10ec0293: 3809 /* Set to ctia type */ 3810 alc_write_coef_idx(codec, 0x45, 0xd429); 3811 /* SET Line1 JD to 1 */ 3812 val = alc_read_coef_idx(codec, 0x10); 3813 alc_write_coef_idx(codec, 0x10, (val & ~(7<<8)) | 7<<8); 3814 break; 3815 case 0x10ec0668: 3816 alc_write_coef_idx(codec, 0x11, 0x0001); 3817 alc_write_coef_idx(codec, 0x15, 0x0d60); 3818 alc_write_coef_idx(codec, 0xc3, 0x0000); 3819 break; 3820 } 3821 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n"); 3822 } 3823 3824 /* Nokia type */ 3825 static void alc_headset_mode_omtp(struct hda_codec *codec) 3826 { 3827 int val; 3828 3829 switch (codec->vendor_id) { 3830 case 0x10ec0255: 3831 /* Set to OMTP Type */ 3832 alc_write_coef_idx(codec, 0x45, 0xe489); 3833 alc_write_coef_idx(codec, 0x1b, 0x0c2b); 3834 alc_write_coefex_idx(codec, 0x57, 0x03, 0x8ea6); 3835 break; 3836 case 0x10ec0233: 3837 case 0x10ec0283: 3838 alc_write_coef_idx(codec, 0x45, 0xe429); 3839 alc_write_coef_idx(codec, 0x1b, 0x0c2b); 3840 alc_write_coef_idx(codec, 0x32, 0x4ea3); 3841 break; 3842 case 0x10ec0292: 3843 alc_write_coef_idx(codec, 0x6b, 0xe429); 3844 alc_write_coef_idx(codec, 0x76, 0x0008); 3845 alc_write_coef_idx(codec, 0x18, 0x7388); 3846 break; 3847 case 0x10ec0293: 3848 /* Set to omtp type */ 3849 alc_write_coef_idx(codec, 0x45, 0xe429); 3850 /* SET Line1 JD to 1 */ 3851 val = alc_read_coef_idx(codec, 0x10); 3852 alc_write_coef_idx(codec, 0x10, (val & ~(7<<8)) | 7<<8); 3853 break; 3854 case 0x10ec0668: 3855 alc_write_coef_idx(codec, 0x11, 0x0001); 3856 alc_write_coef_idx(codec, 0x15, 0x0d50); 3857 alc_write_coef_idx(codec, 0xc3, 0x0000); 3858 break; 3859 } 3860 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n"); 3861 } 3862 3863 static void alc_determine_headset_type(struct hda_codec *codec) 3864 { 3865 int val; 3866 bool is_ctia = false; 3867 struct alc_spec *spec = codec->spec; 3868 3869 switch (codec->vendor_id) { 3870 case 0x10ec0255: 3871 /* combo jack auto switch control(Check type)*/ 3872 alc_write_coef_idx(codec, 0x45, 0xd089); 3873 /* combo jack auto switch control(Vref conteol) */ 3874 alc_write_coef_idx(codec, 0x49, 0x0149); 3875 msleep(300); 3876 val = alc_read_coef_idx(codec, 0x46); 3877 is_ctia = (val & 0x0070) == 0x0070; 3878 break; 3879 case 0x10ec0233: 3880 case 0x10ec0283: 3881 alc_write_coef_idx(codec, 0x45, 0xd029); 3882 msleep(300); 3883 val = alc_read_coef_idx(codec, 0x46); 3884 is_ctia = (val & 0x0070) == 0x0070; 3885 break; 3886 case 0x10ec0292: 3887 alc_write_coef_idx(codec, 0x6b, 0xd429); 3888 msleep(300); 3889 val = alc_read_coef_idx(codec, 0x6c); 3890 is_ctia = (val & 0x001c) == 0x001c; 3891 break; 3892 case 0x10ec0293: 3893 /* Combo Jack auto detect */ 3894 val = alc_read_coef_idx(codec, 0x4a); 3895 alc_write_coef_idx(codec, 0x4a, (val & 0xfff0) | 0x0008); 3896 /* Set to ctia type */ 3897 alc_write_coef_idx(codec, 0x45, 0xD429); 3898 msleep(300); 3899 val = alc_read_coef_idx(codec, 0x46); 3900 is_ctia = (val & 0x0070) == 0x0070; 3901 break; 3902 case 0x10ec0668: 3903 alc_write_coef_idx(codec, 0x11, 0x0001); 3904 alc_write_coef_idx(codec, 0xb7, 0x802b); 3905 alc_write_coef_idx(codec, 0x15, 0x0d60); 3906 alc_write_coef_idx(codec, 0xc3, 0x0c00); 3907 msleep(300); 3908 val = alc_read_coef_idx(codec, 0xbe); 3909 is_ctia = (val & 0x1c02) == 0x1c02; 3910 break; 3911 } 3912 3913 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n", 3914 is_ctia ? "yes" : "no"); 3915 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP; 3916 } 3917 3918 static void alc_update_headset_mode(struct hda_codec *codec) 3919 { 3920 struct alc_spec *spec = codec->spec; 3921 3922 hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]]; 3923 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0]; 3924 3925 int new_headset_mode; 3926 3927 if (!snd_hda_jack_detect(codec, hp_pin)) 3928 new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED; 3929 else if (mux_pin == spec->headset_mic_pin) 3930 new_headset_mode = ALC_HEADSET_MODE_HEADSET; 3931 else if (mux_pin == spec->headphone_mic_pin) 3932 new_headset_mode = ALC_HEADSET_MODE_MIC; 3933 else 3934 new_headset_mode = ALC_HEADSET_MODE_HEADPHONE; 3935 3936 if (new_headset_mode == spec->current_headset_mode) { 3937 snd_hda_gen_update_outputs(codec); 3938 return; 3939 } 3940 3941 switch (new_headset_mode) { 3942 case ALC_HEADSET_MODE_UNPLUGGED: 3943 alc_headset_mode_unplugged(codec); 3944 spec->gen.hp_jack_present = false; 3945 break; 3946 case ALC_HEADSET_MODE_HEADSET: 3947 if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN) 3948 alc_determine_headset_type(codec); 3949 if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA) 3950 alc_headset_mode_ctia(codec); 3951 else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP) 3952 alc_headset_mode_omtp(codec); 3953 spec->gen.hp_jack_present = true; 3954 break; 3955 case ALC_HEADSET_MODE_MIC: 3956 alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin); 3957 spec->gen.hp_jack_present = false; 3958 break; 3959 case ALC_HEADSET_MODE_HEADPHONE: 3960 alc_headset_mode_default(codec); 3961 spec->gen.hp_jack_present = true; 3962 break; 3963 } 3964 if (new_headset_mode != ALC_HEADSET_MODE_MIC) { 3965 snd_hda_set_pin_ctl_cache(codec, hp_pin, 3966 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); 3967 if (spec->headphone_mic_pin) 3968 snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin, 3969 PIN_VREFHIZ); 3970 } 3971 spec->current_headset_mode = new_headset_mode; 3972 3973 snd_hda_gen_update_outputs(codec); 3974 } 3975 3976 static void alc_update_headset_mode_hook(struct hda_codec *codec, 3977 struct snd_kcontrol *kcontrol, 3978 struct snd_ctl_elem_value *ucontrol) 3979 { 3980 alc_update_headset_mode(codec); 3981 } 3982 3983 static void alc_update_headset_jack_cb(struct hda_codec *codec, struct hda_jack_tbl *jack) 3984 { 3985 struct alc_spec *spec = codec->spec; 3986 spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN; 3987 snd_hda_gen_hp_automute(codec, jack); 3988 } 3989 3990 static void alc_probe_headset_mode(struct hda_codec *codec) 3991 { 3992 int i; 3993 struct alc_spec *spec = codec->spec; 3994 struct auto_pin_cfg *cfg = &spec->gen.autocfg; 3995 3996 /* Find mic pins */ 3997 for (i = 0; i < cfg->num_inputs; i++) { 3998 if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin) 3999 spec->headset_mic_pin = cfg->inputs[i].pin; 4000 if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin) 4001 spec->headphone_mic_pin = cfg->inputs[i].pin; 4002 } 4003 4004 spec->gen.cap_sync_hook = alc_update_headset_mode_hook; 4005 spec->gen.automute_hook = alc_update_headset_mode; 4006 spec->gen.hp_automute_hook = alc_update_headset_jack_cb; 4007 } 4008 4009 static void alc_fixup_headset_mode(struct hda_codec *codec, 4010 const struct hda_fixup *fix, int action) 4011 { 4012 struct alc_spec *spec = codec->spec; 4013 4014 switch (action) { 4015 case HDA_FIXUP_ACT_PRE_PROBE: 4016 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC; 4017 break; 4018 case HDA_FIXUP_ACT_PROBE: 4019 alc_probe_headset_mode(codec); 4020 break; 4021 case HDA_FIXUP_ACT_INIT: 4022 spec->current_headset_mode = 0; 4023 alc_update_headset_mode(codec); 4024 break; 4025 } 4026 } 4027 4028 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec, 4029 const struct hda_fixup *fix, int action) 4030 { 4031 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 4032 struct alc_spec *spec = codec->spec; 4033 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC; 4034 } 4035 else 4036 alc_fixup_headset_mode(codec, fix, action); 4037 } 4038 4039 static void alc255_set_default_jack_type(struct hda_codec *codec) 4040 { 4041 /* Set to iphone type */ 4042 alc_write_coef_idx(codec, 0x1b, 0x880b); 4043 alc_write_coef_idx(codec, 0x45, 0xd089); 4044 alc_write_coef_idx(codec, 0x1b, 0x080b); 4045 alc_write_coef_idx(codec, 0x46, 0x0004); 4046 alc_write_coef_idx(codec, 0x1b, 0x0c0b); 4047 msleep(30); 4048 } 4049 4050 static void alc_fixup_headset_mode_alc255(struct hda_codec *codec, 4051 const struct hda_fixup *fix, int action) 4052 { 4053 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 4054 alc255_set_default_jack_type(codec); 4055 } 4056 alc_fixup_headset_mode(codec, fix, action); 4057 } 4058 4059 static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec, 4060 const struct hda_fixup *fix, int action) 4061 { 4062 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 4063 struct alc_spec *spec = codec->spec; 4064 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC; 4065 alc255_set_default_jack_type(codec); 4066 } 4067 else 4068 alc_fixup_headset_mode(codec, fix, action); 4069 } 4070 4071 static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec, 4072 const struct hda_fixup *fix, int action) 4073 { 4074 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 4075 struct alc_spec *spec = codec->spec; 4076 spec->gen.auto_mute_via_amp = 1; 4077 } 4078 } 4079 4080 static void alc_no_shutup(struct hda_codec *codec) 4081 { 4082 } 4083 4084 static void alc_fixup_no_shutup(struct hda_codec *codec, 4085 const struct hda_fixup *fix, int action) 4086 { 4087 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 4088 struct alc_spec *spec = codec->spec; 4089 spec->shutup = alc_no_shutup; 4090 } 4091 } 4092 4093 static void alc_fixup_disable_aamix(struct hda_codec *codec, 4094 const struct hda_fixup *fix, int action) 4095 { 4096 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 4097 struct alc_spec *spec = codec->spec; 4098 /* Disable AA-loopback as it causes white noise */ 4099 spec->gen.mixer_nid = 0; 4100 } 4101 } 4102 4103 static unsigned int alc_power_filter_xps13(struct hda_codec *codec, 4104 hda_nid_t nid, 4105 unsigned int power_state) 4106 { 4107 struct alc_spec *spec = codec->spec; 4108 4109 /* Avoid pop noises when headphones are plugged in */ 4110 if (spec->gen.hp_jack_present) 4111 if (nid == codec->afg || nid == 0x02 || nid == 0x15) 4112 return AC_PWRST_D0; 4113 return power_state; 4114 } 4115 4116 static void alc_fixup_dell_xps13(struct hda_codec *codec, 4117 const struct hda_fixup *fix, int action) 4118 { 4119 if (action == HDA_FIXUP_ACT_PROBE) { 4120 struct alc_spec *spec = codec->spec; 4121 struct hda_input_mux *imux = &spec->gen.input_mux; 4122 int i; 4123 4124 spec->shutup = alc_no_shutup; 4125 codec->power_filter = alc_power_filter_xps13; 4126 4127 /* Make the internal mic the default input source. */ 4128 for (i = 0; i < imux->num_items; i++) { 4129 if (spec->gen.imux_pins[i] == 0x12) { 4130 spec->gen.cur_mux[0] = i; 4131 break; 4132 } 4133 } 4134 } 4135 } 4136 4137 static void alc_fixup_headset_mode_alc668(struct hda_codec *codec, 4138 const struct hda_fixup *fix, int action) 4139 { 4140 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 4141 int val; 4142 alc_write_coef_idx(codec, 0xc4, 0x8000); 4143 val = alc_read_coef_idx(codec, 0xc2); 4144 alc_write_coef_idx(codec, 0xc2, val & 0xfe); 4145 snd_hda_set_pin_ctl_cache(codec, 0x18, 0); 4146 } 4147 alc_fixup_headset_mode(codec, fix, action); 4148 } 4149 4150 /* Returns the nid of the external mic input pin, or 0 if it cannot be found. */ 4151 static int find_ext_mic_pin(struct hda_codec *codec) 4152 { 4153 struct alc_spec *spec = codec->spec; 4154 struct auto_pin_cfg *cfg = &spec->gen.autocfg; 4155 hda_nid_t nid; 4156 unsigned int defcfg; 4157 int i; 4158 4159 for (i = 0; i < cfg->num_inputs; i++) { 4160 if (cfg->inputs[i].type != AUTO_PIN_MIC) 4161 continue; 4162 nid = cfg->inputs[i].pin; 4163 defcfg = snd_hda_codec_get_pincfg(codec, nid); 4164 if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT) 4165 continue; 4166 return nid; 4167 } 4168 4169 return 0; 4170 } 4171 4172 static void alc271_hp_gate_mic_jack(struct hda_codec *codec, 4173 const struct hda_fixup *fix, 4174 int action) 4175 { 4176 struct alc_spec *spec = codec->spec; 4177 4178 if (action == HDA_FIXUP_ACT_PROBE) { 4179 int mic_pin = find_ext_mic_pin(codec); 4180 int hp_pin = spec->gen.autocfg.hp_pins[0]; 4181 4182 if (snd_BUG_ON(!mic_pin || !hp_pin)) 4183 return; 4184 snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin); 4185 } 4186 } 4187 4188 static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec, 4189 const struct hda_fixup *fix, 4190 int action) 4191 { 4192 struct alc_spec *spec = codec->spec; 4193 struct auto_pin_cfg *cfg = &spec->gen.autocfg; 4194 int i; 4195 4196 /* The mic boosts on level 2 and 3 are too noisy 4197 on the internal mic input. 4198 Therefore limit the boost to 0 or 1. */ 4199 4200 if (action != HDA_FIXUP_ACT_PROBE) 4201 return; 4202 4203 for (i = 0; i < cfg->num_inputs; i++) { 4204 hda_nid_t nid = cfg->inputs[i].pin; 4205 unsigned int defcfg; 4206 if (cfg->inputs[i].type != AUTO_PIN_MIC) 4207 continue; 4208 defcfg = snd_hda_codec_get_pincfg(codec, nid); 4209 if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) 4210 continue; 4211 4212 snd_hda_override_amp_caps(codec, nid, HDA_INPUT, 4213 (0x00 << AC_AMPCAP_OFFSET_SHIFT) | 4214 (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) | 4215 (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) | 4216 (0 << AC_AMPCAP_MUTE_SHIFT)); 4217 } 4218 } 4219 4220 static void alc283_hp_automute_hook(struct hda_codec *codec, 4221 struct hda_jack_tbl *jack) 4222 { 4223 struct alc_spec *spec = codec->spec; 4224 int vref; 4225 4226 msleep(200); 4227 snd_hda_gen_hp_automute(codec, jack); 4228 4229 vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0; 4230 4231 msleep(600); 4232 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4233 vref); 4234 } 4235 4236 static void alc283_fixup_chromebook(struct hda_codec *codec, 4237 const struct hda_fixup *fix, int action) 4238 { 4239 struct alc_spec *spec = codec->spec; 4240 int val; 4241 4242 switch (action) { 4243 case HDA_FIXUP_ACT_PRE_PROBE: 4244 snd_hda_override_wcaps(codec, 0x03, 0); 4245 /* Disable AA-loopback as it causes white noise */ 4246 spec->gen.mixer_nid = 0; 4247 break; 4248 case HDA_FIXUP_ACT_INIT: 4249 /* MIC2-VREF control */ 4250 /* Set to manual mode */ 4251 val = alc_read_coef_idx(codec, 0x06); 4252 alc_write_coef_idx(codec, 0x06, val & ~0x000c); 4253 /* Enable Line1 input control by verb */ 4254 val = alc_read_coef_idx(codec, 0x1a); 4255 alc_write_coef_idx(codec, 0x1a, val | (1 << 4)); 4256 break; 4257 } 4258 } 4259 4260 static void alc283_fixup_sense_combo_jack(struct hda_codec *codec, 4261 const struct hda_fixup *fix, int action) 4262 { 4263 struct alc_spec *spec = codec->spec; 4264 int val; 4265 4266 switch (action) { 4267 case HDA_FIXUP_ACT_PRE_PROBE: 4268 spec->gen.hp_automute_hook = alc283_hp_automute_hook; 4269 break; 4270 case HDA_FIXUP_ACT_INIT: 4271 /* MIC2-VREF control */ 4272 /* Set to manual mode */ 4273 val = alc_read_coef_idx(codec, 0x06); 4274 alc_write_coef_idx(codec, 0x06, val & ~0x000c); 4275 break; 4276 } 4277 } 4278 4279 /* mute tablet speaker pin (0x14) via dock plugging in addition */ 4280 static void asus_tx300_automute(struct hda_codec *codec) 4281 { 4282 struct alc_spec *spec = codec->spec; 4283 snd_hda_gen_update_outputs(codec); 4284 if (snd_hda_jack_detect(codec, 0x1b)) 4285 spec->gen.mute_bits |= (1ULL << 0x14); 4286 } 4287 4288 static void alc282_fixup_asus_tx300(struct hda_codec *codec, 4289 const struct hda_fixup *fix, int action) 4290 { 4291 struct alc_spec *spec = codec->spec; 4292 /* TX300 needs to set up GPIO2 for the speaker amp */ 4293 static const struct hda_verb gpio2_verbs[] = { 4294 { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 }, 4295 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 }, 4296 { 0x01, AC_VERB_SET_GPIO_DATA, 0x04 }, 4297 {} 4298 }; 4299 static const struct hda_pintbl dock_pins[] = { 4300 { 0x1b, 0x21114000 }, /* dock speaker pin */ 4301 {} 4302 }; 4303 struct snd_kcontrol *kctl; 4304 4305 switch (action) { 4306 case HDA_FIXUP_ACT_PRE_PROBE: 4307 snd_hda_add_verbs(codec, gpio2_verbs); 4308 snd_hda_apply_pincfgs(codec, dock_pins); 4309 spec->gen.auto_mute_via_amp = 1; 4310 spec->gen.automute_hook = asus_tx300_automute; 4311 snd_hda_jack_detect_enable_callback(codec, 0x1b, 4312 HDA_GEN_HP_EVENT, 4313 snd_hda_gen_hp_automute); 4314 break; 4315 case HDA_FIXUP_ACT_BUILD: 4316 /* this is a bit tricky; give more sane names for the main 4317 * (tablet) speaker and the dock speaker, respectively 4318 */ 4319 kctl = snd_hda_find_mixer_ctl(codec, "Speaker Playback Switch"); 4320 if (kctl) 4321 strcpy(kctl->id.name, "Dock Speaker Playback Switch"); 4322 kctl = snd_hda_find_mixer_ctl(codec, "Bass Speaker Playback Switch"); 4323 if (kctl) 4324 strcpy(kctl->id.name, "Speaker Playback Switch"); 4325 break; 4326 } 4327 } 4328 4329 static void alc290_fixup_mono_speakers(struct hda_codec *codec, 4330 const struct hda_fixup *fix, int action) 4331 { 4332 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 4333 /* DAC node 0x03 is giving mono output. We therefore want to 4334 make sure 0x14 (front speaker) and 0x15 (headphones) use the 4335 stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */ 4336 hda_nid_t conn1[2] = { 0x0c }; 4337 snd_hda_override_conn_list(codec, 0x14, 1, conn1); 4338 snd_hda_override_conn_list(codec, 0x15, 1, conn1); 4339 } 4340 } 4341 4342 /* for hda_fixup_thinkpad_acpi() */ 4343 #include "thinkpad_helper.c" 4344 4345 /* for dell wmi mic mute led */ 4346 #include "dell_wmi_helper.c" 4347 4348 enum { 4349 ALC269_FIXUP_SONY_VAIO, 4350 ALC275_FIXUP_SONY_VAIO_GPIO2, 4351 ALC269_FIXUP_DELL_M101Z, 4352 ALC269_FIXUP_SKU_IGNORE, 4353 ALC269_FIXUP_ASUS_G73JW, 4354 ALC269_FIXUP_LENOVO_EAPD, 4355 ALC275_FIXUP_SONY_HWEQ, 4356 ALC275_FIXUP_SONY_DISABLE_AAMIX, 4357 ALC271_FIXUP_DMIC, 4358 ALC269_FIXUP_PCM_44K, 4359 ALC269_FIXUP_STEREO_DMIC, 4360 ALC269_FIXUP_HEADSET_MIC, 4361 ALC269_FIXUP_QUANTA_MUTE, 4362 ALC269_FIXUP_LIFEBOOK, 4363 ALC269_FIXUP_LIFEBOOK_EXTMIC, 4364 ALC269_FIXUP_AMIC, 4365 ALC269_FIXUP_DMIC, 4366 ALC269VB_FIXUP_AMIC, 4367 ALC269VB_FIXUP_DMIC, 4368 ALC269_FIXUP_HP_MUTE_LED, 4369 ALC269_FIXUP_HP_MUTE_LED_MIC1, 4370 ALC269_FIXUP_HP_MUTE_LED_MIC2, 4371 ALC269_FIXUP_HP_GPIO_LED, 4372 ALC269_FIXUP_HP_GPIO_MIC1_LED, 4373 ALC269_FIXUP_HP_LINE1_MIC1_LED, 4374 ALC269_FIXUP_INV_DMIC, 4375 ALC269_FIXUP_LENOVO_DOCK, 4376 ALC269_FIXUP_NO_SHUTUP, 4377 ALC286_FIXUP_SONY_MIC_NO_PRESENCE, 4378 ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT, 4379 ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, 4380 ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, 4381 ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, 4382 ALC269_FIXUP_HEADSET_MODE, 4383 ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, 4384 ALC269_FIXUP_ASUS_X101_FUNC, 4385 ALC269_FIXUP_ASUS_X101_VERB, 4386 ALC269_FIXUP_ASUS_X101, 4387 ALC271_FIXUP_AMIC_MIC2, 4388 ALC271_FIXUP_HP_GATE_MIC_JACK, 4389 ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572, 4390 ALC269_FIXUP_ACER_AC700, 4391 ALC269_FIXUP_LIMIT_INT_MIC_BOOST, 4392 ALC269VB_FIXUP_ASUS_ZENBOOK, 4393 ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A, 4394 ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED, 4395 ALC269VB_FIXUP_ORDISSIMO_EVE2, 4396 ALC283_FIXUP_CHROME_BOOK, 4397 ALC283_FIXUP_SENSE_COMBO_JACK, 4398 ALC282_FIXUP_ASUS_TX300, 4399 ALC283_FIXUP_INT_MIC, 4400 ALC290_FIXUP_MONO_SPEAKERS, 4401 ALC290_FIXUP_MONO_SPEAKERS_HSJACK, 4402 ALC290_FIXUP_SUBWOOFER, 4403 ALC290_FIXUP_SUBWOOFER_HSJACK, 4404 ALC269_FIXUP_THINKPAD_ACPI, 4405 ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 4406 ALC255_FIXUP_DELL2_MIC_NO_PRESENCE, 4407 ALC255_FIXUP_HEADSET_MODE, 4408 ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC, 4409 ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, 4410 ALC292_FIXUP_TPT440_DOCK, 4411 ALC283_FIXUP_BXBT2807_MIC, 4412 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED, 4413 ALC282_FIXUP_ASPIRE_V5_PINS, 4414 }; 4415 4416 static const struct hda_fixup alc269_fixups[] = { 4417 [ALC269_FIXUP_SONY_VAIO] = { 4418 .type = HDA_FIXUP_PINCTLS, 4419 .v.pins = (const struct hda_pintbl[]) { 4420 {0x19, PIN_VREFGRD}, 4421 {} 4422 } 4423 }, 4424 [ALC275_FIXUP_SONY_VAIO_GPIO2] = { 4425 .type = HDA_FIXUP_VERBS, 4426 .v.verbs = (const struct hda_verb[]) { 4427 {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, 4428 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, 4429 {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, 4430 { } 4431 }, 4432 .chained = true, 4433 .chain_id = ALC269_FIXUP_SONY_VAIO 4434 }, 4435 [ALC269_FIXUP_DELL_M101Z] = { 4436 .type = HDA_FIXUP_VERBS, 4437 .v.verbs = (const struct hda_verb[]) { 4438 /* Enables internal speaker */ 4439 {0x20, AC_VERB_SET_COEF_INDEX, 13}, 4440 {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, 4441 {} 4442 } 4443 }, 4444 [ALC269_FIXUP_SKU_IGNORE] = { 4445 .type = HDA_FIXUP_FUNC, 4446 .v.func = alc_fixup_sku_ignore, 4447 }, 4448 [ALC269_FIXUP_ASUS_G73JW] = { 4449 .type = HDA_FIXUP_PINS, 4450 .v.pins = (const struct hda_pintbl[]) { 4451 { 0x17, 0x99130111 }, /* subwoofer */ 4452 { } 4453 } 4454 }, 4455 [ALC269_FIXUP_LENOVO_EAPD] = { 4456 .type = HDA_FIXUP_VERBS, 4457 .v.verbs = (const struct hda_verb[]) { 4458 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, 4459 {} 4460 } 4461 }, 4462 [ALC275_FIXUP_SONY_HWEQ] = { 4463 .type = HDA_FIXUP_FUNC, 4464 .v.func = alc269_fixup_hweq, 4465 .chained = true, 4466 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 4467 }, 4468 [ALC275_FIXUP_SONY_DISABLE_AAMIX] = { 4469 .type = HDA_FIXUP_FUNC, 4470 .v.func = alc_fixup_disable_aamix, 4471 .chained = true, 4472 .chain_id = ALC269_FIXUP_SONY_VAIO 4473 }, 4474 [ALC271_FIXUP_DMIC] = { 4475 .type = HDA_FIXUP_FUNC, 4476 .v.func = alc271_fixup_dmic, 4477 }, 4478 [ALC269_FIXUP_PCM_44K] = { 4479 .type = HDA_FIXUP_FUNC, 4480 .v.func = alc269_fixup_pcm_44k, 4481 .chained = true, 4482 .chain_id = ALC269_FIXUP_QUANTA_MUTE 4483 }, 4484 [ALC269_FIXUP_STEREO_DMIC] = { 4485 .type = HDA_FIXUP_FUNC, 4486 .v.func = alc269_fixup_stereo_dmic, 4487 }, 4488 [ALC269_FIXUP_HEADSET_MIC] = { 4489 .type = HDA_FIXUP_FUNC, 4490 .v.func = alc269_fixup_headset_mic, 4491 }, 4492 [ALC269_FIXUP_QUANTA_MUTE] = { 4493 .type = HDA_FIXUP_FUNC, 4494 .v.func = alc269_fixup_quanta_mute, 4495 }, 4496 [ALC269_FIXUP_LIFEBOOK] = { 4497 .type = HDA_FIXUP_PINS, 4498 .v.pins = (const struct hda_pintbl[]) { 4499 { 0x1a, 0x2101103f }, /* dock line-out */ 4500 { 0x1b, 0x23a11040 }, /* dock mic-in */ 4501 { } 4502 }, 4503 .chained = true, 4504 .chain_id = ALC269_FIXUP_QUANTA_MUTE 4505 }, 4506 [ALC269_FIXUP_LIFEBOOK_EXTMIC] = { 4507 .type = HDA_FIXUP_PINS, 4508 .v.pins = (const struct hda_pintbl[]) { 4509 { 0x19, 0x01a1903c }, /* headset mic, with jack detect */ 4510 { } 4511 }, 4512 }, 4513 [ALC269_FIXUP_AMIC] = { 4514 .type = HDA_FIXUP_PINS, 4515 .v.pins = (const struct hda_pintbl[]) { 4516 { 0x14, 0x99130110 }, /* speaker */ 4517 { 0x15, 0x0121401f }, /* HP out */ 4518 { 0x18, 0x01a19c20 }, /* mic */ 4519 { 0x19, 0x99a3092f }, /* int-mic */ 4520 { } 4521 }, 4522 }, 4523 [ALC269_FIXUP_DMIC] = { 4524 .type = HDA_FIXUP_PINS, 4525 .v.pins = (const struct hda_pintbl[]) { 4526 { 0x12, 0x99a3092f }, /* int-mic */ 4527 { 0x14, 0x99130110 }, /* speaker */ 4528 { 0x15, 0x0121401f }, /* HP out */ 4529 { 0x18, 0x01a19c20 }, /* mic */ 4530 { } 4531 }, 4532 }, 4533 [ALC269VB_FIXUP_AMIC] = { 4534 .type = HDA_FIXUP_PINS, 4535 .v.pins = (const struct hda_pintbl[]) { 4536 { 0x14, 0x99130110 }, /* speaker */ 4537 { 0x18, 0x01a19c20 }, /* mic */ 4538 { 0x19, 0x99a3092f }, /* int-mic */ 4539 { 0x21, 0x0121401f }, /* HP out */ 4540 { } 4541 }, 4542 }, 4543 [ALC269VB_FIXUP_DMIC] = { 4544 .type = HDA_FIXUP_PINS, 4545 .v.pins = (const struct hda_pintbl[]) { 4546 { 0x12, 0x99a3092f }, /* int-mic */ 4547 { 0x14, 0x99130110 }, /* speaker */ 4548 { 0x18, 0x01a19c20 }, /* mic */ 4549 { 0x21, 0x0121401f }, /* HP out */ 4550 { } 4551 }, 4552 }, 4553 [ALC269_FIXUP_HP_MUTE_LED] = { 4554 .type = HDA_FIXUP_FUNC, 4555 .v.func = alc269_fixup_hp_mute_led, 4556 }, 4557 [ALC269_FIXUP_HP_MUTE_LED_MIC1] = { 4558 .type = HDA_FIXUP_FUNC, 4559 .v.func = alc269_fixup_hp_mute_led_mic1, 4560 }, 4561 [ALC269_FIXUP_HP_MUTE_LED_MIC2] = { 4562 .type = HDA_FIXUP_FUNC, 4563 .v.func = alc269_fixup_hp_mute_led_mic2, 4564 }, 4565 [ALC269_FIXUP_HP_GPIO_LED] = { 4566 .type = HDA_FIXUP_FUNC, 4567 .v.func = alc269_fixup_hp_gpio_led, 4568 }, 4569 [ALC269_FIXUP_HP_GPIO_MIC1_LED] = { 4570 .type = HDA_FIXUP_FUNC, 4571 .v.func = alc269_fixup_hp_gpio_mic1_led, 4572 }, 4573 [ALC269_FIXUP_HP_LINE1_MIC1_LED] = { 4574 .type = HDA_FIXUP_FUNC, 4575 .v.func = alc269_fixup_hp_line1_mic1_led, 4576 }, 4577 [ALC269_FIXUP_INV_DMIC] = { 4578 .type = HDA_FIXUP_FUNC, 4579 .v.func = alc_fixup_inv_dmic_0x12, 4580 }, 4581 [ALC269_FIXUP_NO_SHUTUP] = { 4582 .type = HDA_FIXUP_FUNC, 4583 .v.func = alc_fixup_no_shutup, 4584 }, 4585 [ALC269_FIXUP_LENOVO_DOCK] = { 4586 .type = HDA_FIXUP_PINS, 4587 .v.pins = (const struct hda_pintbl[]) { 4588 { 0x19, 0x23a11040 }, /* dock mic */ 4589 { 0x1b, 0x2121103f }, /* dock headphone */ 4590 { } 4591 }, 4592 .chained = true, 4593 .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT 4594 }, 4595 [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = { 4596 .type = HDA_FIXUP_FUNC, 4597 .v.func = alc269_fixup_pincfg_no_hp_to_lineout, 4598 .chained = true, 4599 .chain_id = ALC269_FIXUP_THINKPAD_ACPI, 4600 }, 4601 [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = { 4602 .type = HDA_FIXUP_PINS, 4603 .v.pins = (const struct hda_pintbl[]) { 4604 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */ 4605 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */ 4606 { } 4607 }, 4608 .chained = true, 4609 .chain_id = ALC269_FIXUP_HEADSET_MODE 4610 }, 4611 [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = { 4612 .type = HDA_FIXUP_PINS, 4613 .v.pins = (const struct hda_pintbl[]) { 4614 { 0x16, 0x21014020 }, /* dock line out */ 4615 { 0x19, 0x21a19030 }, /* dock mic */ 4616 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */ 4617 { } 4618 }, 4619 .chained = true, 4620 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC 4621 }, 4622 [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = { 4623 .type = HDA_FIXUP_PINS, 4624 .v.pins = (const struct hda_pintbl[]) { 4625 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */ 4626 { } 4627 }, 4628 .chained = true, 4629 .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC 4630 }, 4631 [ALC269_FIXUP_HEADSET_MODE] = { 4632 .type = HDA_FIXUP_FUNC, 4633 .v.func = alc_fixup_headset_mode, 4634 }, 4635 [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = { 4636 .type = HDA_FIXUP_FUNC, 4637 .v.func = alc_fixup_headset_mode_no_hp_mic, 4638 }, 4639 [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = { 4640 .type = HDA_FIXUP_PINS, 4641 .v.pins = (const struct hda_pintbl[]) { 4642 { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */ 4643 { } 4644 }, 4645 .chained = true, 4646 .chain_id = ALC269_FIXUP_HEADSET_MIC 4647 }, 4648 [ALC269_FIXUP_ASUS_X101_FUNC] = { 4649 .type = HDA_FIXUP_FUNC, 4650 .v.func = alc269_fixup_x101_headset_mic, 4651 }, 4652 [ALC269_FIXUP_ASUS_X101_VERB] = { 4653 .type = HDA_FIXUP_VERBS, 4654 .v.verbs = (const struct hda_verb[]) { 4655 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 4656 {0x20, AC_VERB_SET_COEF_INDEX, 0x08}, 4657 {0x20, AC_VERB_SET_PROC_COEF, 0x0310}, 4658 { } 4659 }, 4660 .chained = true, 4661 .chain_id = ALC269_FIXUP_ASUS_X101_FUNC 4662 }, 4663 [ALC269_FIXUP_ASUS_X101] = { 4664 .type = HDA_FIXUP_PINS, 4665 .v.pins = (const struct hda_pintbl[]) { 4666 { 0x18, 0x04a1182c }, /* Headset mic */ 4667 { } 4668 }, 4669 .chained = true, 4670 .chain_id = ALC269_FIXUP_ASUS_X101_VERB 4671 }, 4672 [ALC271_FIXUP_AMIC_MIC2] = { 4673 .type = HDA_FIXUP_PINS, 4674 .v.pins = (const struct hda_pintbl[]) { 4675 { 0x14, 0x99130110 }, /* speaker */ 4676 { 0x19, 0x01a19c20 }, /* mic */ 4677 { 0x1b, 0x99a7012f }, /* int-mic */ 4678 { 0x21, 0x0121401f }, /* HP out */ 4679 { } 4680 }, 4681 }, 4682 [ALC271_FIXUP_HP_GATE_MIC_JACK] = { 4683 .type = HDA_FIXUP_FUNC, 4684 .v.func = alc271_hp_gate_mic_jack, 4685 .chained = true, 4686 .chain_id = ALC271_FIXUP_AMIC_MIC2, 4687 }, 4688 [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = { 4689 .type = HDA_FIXUP_FUNC, 4690 .v.func = alc269_fixup_limit_int_mic_boost, 4691 .chained = true, 4692 .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK, 4693 }, 4694 [ALC269_FIXUP_ACER_AC700] = { 4695 .type = HDA_FIXUP_PINS, 4696 .v.pins = (const struct hda_pintbl[]) { 4697 { 0x12, 0x99a3092f }, /* int-mic */ 4698 { 0x14, 0x99130110 }, /* speaker */ 4699 { 0x18, 0x03a11c20 }, /* mic */ 4700 { 0x1e, 0x0346101e }, /* SPDIF1 */ 4701 { 0x21, 0x0321101f }, /* HP out */ 4702 { } 4703 }, 4704 .chained = true, 4705 .chain_id = ALC271_FIXUP_DMIC, 4706 }, 4707 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = { 4708 .type = HDA_FIXUP_FUNC, 4709 .v.func = alc269_fixup_limit_int_mic_boost, 4710 .chained = true, 4711 .chain_id = ALC269_FIXUP_THINKPAD_ACPI, 4712 }, 4713 [ALC269VB_FIXUP_ASUS_ZENBOOK] = { 4714 .type = HDA_FIXUP_FUNC, 4715 .v.func = alc269_fixup_limit_int_mic_boost, 4716 .chained = true, 4717 .chain_id = ALC269VB_FIXUP_DMIC, 4718 }, 4719 [ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = { 4720 .type = HDA_FIXUP_VERBS, 4721 .v.verbs = (const struct hda_verb[]) { 4722 /* class-D output amp +5dB */ 4723 { 0x20, AC_VERB_SET_COEF_INDEX, 0x12 }, 4724 { 0x20, AC_VERB_SET_PROC_COEF, 0x2800 }, 4725 {} 4726 }, 4727 .chained = true, 4728 .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK, 4729 }, 4730 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = { 4731 .type = HDA_FIXUP_FUNC, 4732 .v.func = alc269_fixup_limit_int_mic_boost, 4733 .chained = true, 4734 .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1, 4735 }, 4736 [ALC269VB_FIXUP_ORDISSIMO_EVE2] = { 4737 .type = HDA_FIXUP_PINS, 4738 .v.pins = (const struct hda_pintbl[]) { 4739 { 0x12, 0x99a3092f }, /* int-mic */ 4740 { 0x18, 0x03a11d20 }, /* mic */ 4741 { 0x19, 0x411111f0 }, /* Unused bogus pin */ 4742 { } 4743 }, 4744 }, 4745 [ALC283_FIXUP_CHROME_BOOK] = { 4746 .type = HDA_FIXUP_FUNC, 4747 .v.func = alc283_fixup_chromebook, 4748 }, 4749 [ALC283_FIXUP_SENSE_COMBO_JACK] = { 4750 .type = HDA_FIXUP_FUNC, 4751 .v.func = alc283_fixup_sense_combo_jack, 4752 .chained = true, 4753 .chain_id = ALC283_FIXUP_CHROME_BOOK, 4754 }, 4755 [ALC282_FIXUP_ASUS_TX300] = { 4756 .type = HDA_FIXUP_FUNC, 4757 .v.func = alc282_fixup_asus_tx300, 4758 }, 4759 [ALC283_FIXUP_INT_MIC] = { 4760 .type = HDA_FIXUP_VERBS, 4761 .v.verbs = (const struct hda_verb[]) { 4762 {0x20, AC_VERB_SET_COEF_INDEX, 0x1a}, 4763 {0x20, AC_VERB_SET_PROC_COEF, 0x0011}, 4764 { } 4765 }, 4766 .chained = true, 4767 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST 4768 }, 4769 [ALC290_FIXUP_SUBWOOFER_HSJACK] = { 4770 .type = HDA_FIXUP_PINS, 4771 .v.pins = (const struct hda_pintbl[]) { 4772 { 0x17, 0x90170112 }, /* subwoofer */ 4773 { } 4774 }, 4775 .chained = true, 4776 .chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK, 4777 }, 4778 [ALC290_FIXUP_SUBWOOFER] = { 4779 .type = HDA_FIXUP_PINS, 4780 .v.pins = (const struct hda_pintbl[]) { 4781 { 0x17, 0x90170112 }, /* subwoofer */ 4782 { } 4783 }, 4784 .chained = true, 4785 .chain_id = ALC290_FIXUP_MONO_SPEAKERS, 4786 }, 4787 [ALC290_FIXUP_MONO_SPEAKERS] = { 4788 .type = HDA_FIXUP_FUNC, 4789 .v.func = alc290_fixup_mono_speakers, 4790 }, 4791 [ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = { 4792 .type = HDA_FIXUP_FUNC, 4793 .v.func = alc290_fixup_mono_speakers, 4794 .chained = true, 4795 .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, 4796 }, 4797 [ALC269_FIXUP_THINKPAD_ACPI] = { 4798 .type = HDA_FIXUP_FUNC, 4799 .v.func = hda_fixup_thinkpad_acpi, 4800 }, 4801 [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = { 4802 .type = HDA_FIXUP_PINS, 4803 .v.pins = (const struct hda_pintbl[]) { 4804 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */ 4805 { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */ 4806 { } 4807 }, 4808 .chained = true, 4809 .chain_id = ALC255_FIXUP_HEADSET_MODE 4810 }, 4811 [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = { 4812 .type = HDA_FIXUP_PINS, 4813 .v.pins = (const struct hda_pintbl[]) { 4814 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */ 4815 { } 4816 }, 4817 .chained = true, 4818 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC 4819 }, 4820 [ALC255_FIXUP_HEADSET_MODE] = { 4821 .type = HDA_FIXUP_FUNC, 4822 .v.func = alc_fixup_headset_mode_alc255, 4823 }, 4824 [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = { 4825 .type = HDA_FIXUP_FUNC, 4826 .v.func = alc_fixup_headset_mode_alc255_no_hp_mic, 4827 }, 4828 [ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = { 4829 .type = HDA_FIXUP_PINS, 4830 .v.pins = (const struct hda_pintbl[]) { 4831 { 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */ 4832 { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */ 4833 { } 4834 }, 4835 .chained = true, 4836 .chain_id = ALC269_FIXUP_HEADSET_MODE 4837 }, 4838 [ALC292_FIXUP_TPT440_DOCK] = { 4839 .type = HDA_FIXUP_PINS, 4840 .v.pins = (const struct hda_pintbl[]) { 4841 { 0x16, 0x21211010 }, /* dock headphone */ 4842 { 0x19, 0x21a11010 }, /* dock mic */ 4843 { } 4844 }, 4845 .chained = true, 4846 .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST 4847 }, 4848 [ALC283_FIXUP_BXBT2807_MIC] = { 4849 .type = HDA_FIXUP_PINS, 4850 .v.pins = (const struct hda_pintbl[]) { 4851 { 0x19, 0x04a110f0 }, 4852 { }, 4853 }, 4854 }, 4855 [ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED] = { 4856 .type = HDA_FIXUP_FUNC, 4857 .v.func = alc_fixup_dell_wmi, 4858 .chained_before = true, 4859 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE 4860 }, 4861 [ALC282_FIXUP_ASPIRE_V5_PINS] = { 4862 .type = HDA_FIXUP_PINS, 4863 .v.pins = (const struct hda_pintbl[]) { 4864 { 0x12, 0x90a60130 }, 4865 { 0x14, 0x90170110 }, 4866 { 0x17, 0x40000008 }, 4867 { 0x18, 0x411111f0 }, 4868 { 0x19, 0x411111f0 }, 4869 { 0x1a, 0x411111f0 }, 4870 { 0x1b, 0x411111f0 }, 4871 { 0x1d, 0x40f89b2d }, 4872 { 0x1e, 0x411111f0 }, 4873 { 0x21, 0x0321101f }, 4874 { }, 4875 }, 4876 }, 4877 4878 }; 4879 4880 static const struct snd_pci_quirk alc269_fixup_tbl[] = { 4881 SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC), 4882 SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC), 4883 SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC), 4884 SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700), 4885 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK), 4886 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK), 4887 SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572), 4888 SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS), 4889 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), 4890 SND_PCI_QUIRK(0x1028, 0x05bd, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4891 SND_PCI_QUIRK(0x1028, 0x05be, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4892 SND_PCI_QUIRK(0x1028, 0x05c4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4893 SND_PCI_QUIRK(0x1028, 0x05c5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4894 SND_PCI_QUIRK(0x1028, 0x05c6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4895 SND_PCI_QUIRK(0x1028, 0x05c7, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4896 SND_PCI_QUIRK(0x1028, 0x05c8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4897 SND_PCI_QUIRK(0x1028, 0x05c9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4898 SND_PCI_QUIRK(0x1028, 0x05ca, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4899 SND_PCI_QUIRK(0x1028, 0x05cb, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4900 SND_PCI_QUIRK(0x1028, 0x05cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4901 SND_PCI_QUIRK(0x1028, 0x05cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4902 SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER), 4903 SND_PCI_QUIRK(0x1028, 0x05de, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4904 SND_PCI_QUIRK(0x1028, 0x05e0, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4905 SND_PCI_QUIRK(0x1028, 0x05e9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4906 SND_PCI_QUIRK(0x1028, 0x05ea, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4907 SND_PCI_QUIRK(0x1028, 0x05eb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4908 SND_PCI_QUIRK(0x1028, 0x05ec, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4909 SND_PCI_QUIRK(0x1028, 0x05ed, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4910 SND_PCI_QUIRK(0x1028, 0x05ee, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4911 SND_PCI_QUIRK(0x1028, 0x05f3, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4912 SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4913 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4914 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4915 SND_PCI_QUIRK(0x1028, 0x05f8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4916 SND_PCI_QUIRK(0x1028, 0x05f9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4917 SND_PCI_QUIRK(0x1028, 0x05fb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4918 SND_PCI_QUIRK(0x1028, 0x0606, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4919 SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4920 SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4921 SND_PCI_QUIRK(0x1028, 0x0610, "Dell", ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED), 4922 SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4923 SND_PCI_QUIRK(0x1028, 0x0614, "Dell Inspiron 3135", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4924 SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK), 4925 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK), 4926 SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED), 4927 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK), 4928 SND_PCI_QUIRK(0x1028, 0x063f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4929 SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 4930 SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 4931 SND_PCI_QUIRK(0x1028, 0x0668, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE), 4932 SND_PCI_QUIRK(0x1028, 0x0669, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE), 4933 SND_PCI_QUIRK(0x1028, 0x0684, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4934 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4935 SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4936 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 4937 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 4938 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), 4939 SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED), 4940 SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4941 SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4942 SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED), 4943 /* ALC282 */ 4944 SND_PCI_QUIRK(0x103c, 0x21f8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4945 SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4946 SND_PCI_QUIRK(0x103c, 0x220d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4947 SND_PCI_QUIRK(0x103c, 0x220e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4948 SND_PCI_QUIRK(0x103c, 0x220f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4949 SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4950 SND_PCI_QUIRK(0x103c, 0x2211, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4951 SND_PCI_QUIRK(0x103c, 0x2212, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4952 SND_PCI_QUIRK(0x103c, 0x2213, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4953 SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4954 SND_PCI_QUIRK(0x103c, 0x2234, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4955 SND_PCI_QUIRK(0x103c, 0x2235, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4956 SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4957 SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4958 SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4959 SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4960 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4961 SND_PCI_QUIRK(0x103c, 0x2247, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4962 SND_PCI_QUIRK(0x103c, 0x2248, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4963 SND_PCI_QUIRK(0x103c, 0x2249, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4964 SND_PCI_QUIRK(0x103c, 0x224a, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4965 SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4966 SND_PCI_QUIRK(0x103c, 0x224c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4967 SND_PCI_QUIRK(0x103c, 0x224d, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED), 4968 SND_PCI_QUIRK(0x103c, 0x2266, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4969 SND_PCI_QUIRK(0x103c, 0x2267, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4970 SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4971 SND_PCI_QUIRK(0x103c, 0x2269, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4972 SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4973 SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4974 SND_PCI_QUIRK(0x103c, 0x226c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4975 SND_PCI_QUIRK(0x103c, 0x226d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4976 SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4977 SND_PCI_QUIRK(0x103c, 0x226f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4978 SND_PCI_QUIRK(0x103c, 0x227a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4979 SND_PCI_QUIRK(0x103c, 0x227b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4980 SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4981 SND_PCI_QUIRK(0x103c, 0x22a0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4982 SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4983 SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4984 SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4985 SND_PCI_QUIRK(0x103c, 0x22c0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4986 SND_PCI_QUIRK(0x103c, 0x22c1, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4987 SND_PCI_QUIRK(0x103c, 0x22c2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4988 SND_PCI_QUIRK(0x103c, 0x22cd, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4989 SND_PCI_QUIRK(0x103c, 0x22ce, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4990 SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4991 SND_PCI_QUIRK(0x103c, 0x22d0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4992 SND_PCI_QUIRK(0x103c, 0x22da, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4993 SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4994 SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4995 SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4996 SND_PCI_QUIRK(0x103c, 0x8004, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4997 /* ALC290 */ 4998 SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4999 SND_PCI_QUIRK(0x103c, 0x221c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5000 SND_PCI_QUIRK(0x103c, 0x221d, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5001 SND_PCI_QUIRK(0x103c, 0x2220, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5002 SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5003 SND_PCI_QUIRK(0x103c, 0x2222, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5004 SND_PCI_QUIRK(0x103c, 0x2223, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5005 SND_PCI_QUIRK(0x103c, 0x2224, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5006 SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5007 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5008 SND_PCI_QUIRK(0x103c, 0x2247, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5009 SND_PCI_QUIRK(0x103c, 0x2248, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5010 SND_PCI_QUIRK(0x103c, 0x2249, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5011 SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5012 SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5013 SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5014 SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5015 SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5016 SND_PCI_QUIRK(0x103c, 0x2258, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5017 SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5018 SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5019 SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5020 SND_PCI_QUIRK(0x103c, 0x2261, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5021 SND_PCI_QUIRK(0x103c, 0x2262, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5022 SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5023 SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5024 SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5025 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5026 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5027 SND_PCI_QUIRK(0x103c, 0x2277, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5028 SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 5029 SND_PCI_QUIRK(0x103c, 0x227d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5030 SND_PCI_QUIRK(0x103c, 0x227e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5031 SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5032 SND_PCI_QUIRK(0x103c, 0x2280, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5033 SND_PCI_QUIRK(0x103c, 0x2281, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5034 SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5035 SND_PCI_QUIRK(0x103c, 0x2289, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5036 SND_PCI_QUIRK(0x103c, 0x228a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5037 SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5038 SND_PCI_QUIRK(0x103c, 0x228c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5039 SND_PCI_QUIRK(0x103c, 0x228d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5040 SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5041 SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5042 SND_PCI_QUIRK(0x103c, 0x22c6, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5043 SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5044 SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5045 SND_PCI_QUIRK(0x103c, 0x22c3, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5046 SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5047 SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5048 SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5049 SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5050 SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 5051 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), 5052 SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 5053 SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 5054 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK), 5055 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A), 5056 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), 5057 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), 5058 SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC), 5059 SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 5060 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), 5061 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), 5062 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), 5063 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), 5064 SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101), 5065 SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE), 5066 SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE), 5067 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), 5068 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), 5069 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), 5070 SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX), 5071 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), 5072 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC), 5073 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_BXBT2807_MIC), 5074 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), 5075 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), 5076 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), 5077 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), 5078 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), 5079 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK), 5080 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK), 5081 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK), 5082 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK), 5083 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK), 5084 SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK), 5085 SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440_DOCK), 5086 SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK), 5087 SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK), 5088 SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 5089 SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 5090 SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 5091 SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP), 5092 SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 5093 SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC), 5094 SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 5095 SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 5096 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), 5097 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), 5098 SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */ 5099 5100 #if 0 5101 /* Below is a quirk table taken from the old code. 5102 * Basically the device should work as is without the fixup table. 5103 * If BIOS doesn't give a proper info, enable the corresponding 5104 * fixup entry. 5105 */ 5106 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", 5107 ALC269_FIXUP_AMIC), 5108 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), 5109 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), 5110 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), 5111 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), 5112 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), 5113 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), 5114 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), 5115 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), 5116 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), 5117 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), 5118 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), 5119 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), 5120 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), 5121 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), 5122 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), 5123 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), 5124 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), 5125 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), 5126 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), 5127 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), 5128 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), 5129 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), 5130 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), 5131 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), 5132 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), 5133 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), 5134 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), 5135 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), 5136 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), 5137 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), 5138 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), 5139 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), 5140 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), 5141 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), 5142 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), 5143 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), 5144 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), 5145 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), 5146 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), 5147 #endif 5148 {} 5149 }; 5150 5151 static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = { 5152 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), 5153 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED), 5154 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), 5155 SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI), 5156 {} 5157 }; 5158 5159 static const struct hda_model_fixup alc269_fixup_models[] = { 5160 {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, 5161 {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, 5162 {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"}, 5163 {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"}, 5164 {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"}, 5165 {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"}, 5166 {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"}, 5167 {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"}, 5168 {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"}, 5169 {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"}, 5170 {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"}, 5171 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"}, 5172 {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"}, 5173 {} 5174 }; 5175 5176 static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { 5177 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 5178 {0x12, 0x90a60140}, 5179 {0x14, 0x90170110}, 5180 {0x17, 0x40000000}, 5181 {0x18, 0x411111f0}, 5182 {0x19, 0x411111f0}, 5183 {0x1a, 0x411111f0}, 5184 {0x1b, 0x411111f0}, 5185 {0x1d, 0x40700001}, 5186 {0x1e, 0x411111f0}, 5187 {0x21, 0x02211020}), 5188 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 5189 {0x12, 0x90a60160}, 5190 {0x14, 0x90170120}, 5191 {0x17, 0x40000000}, 5192 {0x18, 0x411111f0}, 5193 {0x19, 0x411111f0}, 5194 {0x1a, 0x411111f0}, 5195 {0x1b, 0x411111f0}, 5196 {0x1d, 0x40700001}, 5197 {0x1e, 0x411111f0}, 5198 {0x21, 0x02211030}), 5199 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 5200 {0x12, 0x90a60160}, 5201 {0x14, 0x90170120}, 5202 {0x17, 0x90170140}, 5203 {0x18, 0x40000000}, 5204 {0x19, 0x411111f0}, 5205 {0x1a, 0x411111f0}, 5206 {0x1b, 0x411111f0}, 5207 {0x1d, 0x41163b05}, 5208 {0x1e, 0x411111f0}, 5209 {0x21, 0x0321102f}), 5210 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 5211 {0x12, 0x90a60160}, 5212 {0x14, 0x90170130}, 5213 {0x17, 0x40000000}, 5214 {0x18, 0x411111f0}, 5215 {0x19, 0x411111f0}, 5216 {0x1a, 0x411111f0}, 5217 {0x1b, 0x411111f0}, 5218 {0x1d, 0x40700001}, 5219 {0x1e, 0x411111f0}, 5220 {0x21, 0x02211040}), 5221 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 5222 {0x12, 0x90a60160}, 5223 {0x14, 0x90170140}, 5224 {0x17, 0x40000000}, 5225 {0x18, 0x411111f0}, 5226 {0x19, 0x411111f0}, 5227 {0x1a, 0x411111f0}, 5228 {0x1b, 0x411111f0}, 5229 {0x1d, 0x40700001}, 5230 {0x1e, 0x411111f0}, 5231 {0x21, 0x02211050}), 5232 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 5233 {0x12, 0x90a60170}, 5234 {0x14, 0x90170120}, 5235 {0x17, 0x40000000}, 5236 {0x18, 0x411111f0}, 5237 {0x19, 0x411111f0}, 5238 {0x1a, 0x411111f0}, 5239 {0x1b, 0x411111f0}, 5240 {0x1d, 0x40700001}, 5241 {0x1e, 0x411111f0}, 5242 {0x21, 0x02211030}), 5243 SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 5244 {0x12, 0x90a60170}, 5245 {0x14, 0x90170130}, 5246 {0x17, 0x40000000}, 5247 {0x18, 0x411111f0}, 5248 {0x19, 0x411111f0}, 5249 {0x1a, 0x411111f0}, 5250 {0x1b, 0x411111f0}, 5251 {0x1d, 0x40700001}, 5252 {0x1e, 0x411111f0}, 5253 {0x21, 0x02211040}), 5254 SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1, 5255 {0x12, 0x99a30130}, 5256 {0x14, 0x90170110}, 5257 {0x17, 0x40000000}, 5258 {0x18, 0x411111f0}, 5259 {0x19, 0x03a11020}, 5260 {0x1a, 0x411111f0}, 5261 {0x1b, 0x411111f0}, 5262 {0x1d, 0x40f41905}, 5263 {0x1e, 0x411111f0}, 5264 {0x21, 0x0321101f}), 5265 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, 5266 {0x12, 0x90a60130}, 5267 {0x14, 0x90170110}, 5268 {0x17, 0x40020008}, 5269 {0x18, 0x411111f0}, 5270 {0x19, 0x411111f0}, 5271 {0x1a, 0x411111f0}, 5272 {0x1b, 0x411111f0}, 5273 {0x1d, 0x40e00001}, 5274 {0x1e, 0x411111f0}, 5275 {0x21, 0x0321101f}), 5276 SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, 5277 {0x12, 0x90a60160}, 5278 {0x14, 0x90170120}, 5279 {0x17, 0x40000000}, 5280 {0x18, 0x411111f0}, 5281 {0x19, 0x411111f0}, 5282 {0x1a, 0x411111f0}, 5283 {0x1b, 0x411111f0}, 5284 {0x1d, 0x40700001}, 5285 {0x1e, 0x411111f0}, 5286 {0x21, 0x02211030}), 5287 SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, 5288 {0x12, 0x90a60140}, 5289 {0x13, 0x411111f0}, 5290 {0x14, 0x90170110}, 5291 {0x15, 0x0221401f}, 5292 {0x16, 0x411111f0}, 5293 {0x18, 0x411111f0}, 5294 {0x19, 0x411111f0}, 5295 {0x1a, 0x411111f0}, 5296 {0x1b, 0x411111f0}, 5297 {0x1d, 0x40700001}, 5298 {0x1e, 0x411111f0}), 5299 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, 5300 {0x12, 0x40000000}, 5301 {0x13, 0x90a60140}, 5302 {0x14, 0x90170110}, 5303 {0x15, 0x0221401f}, 5304 {0x16, 0x21014020}, 5305 {0x18, 0x411111f0}, 5306 {0x19, 0x21a19030}, 5307 {0x1a, 0x411111f0}, 5308 {0x1b, 0x411111f0}, 5309 {0x1d, 0x40700001}, 5310 {0x1e, 0x411111f0}), 5311 SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, 5312 {0x12, 0x40000000}, 5313 {0x13, 0x90a60140}, 5314 {0x14, 0x90170110}, 5315 {0x15, 0x0221401f}, 5316 {0x16, 0x411111f0}, 5317 {0x18, 0x411111f0}, 5318 {0x19, 0x411111f0}, 5319 {0x1a, 0x411111f0}, 5320 {0x1b, 0x411111f0}, 5321 {0x1d, 0x40700001}, 5322 {0x1e, 0x411111f0}), 5323 {} 5324 }; 5325 5326 static void alc269_fill_coef(struct hda_codec *codec) 5327 { 5328 struct alc_spec *spec = codec->spec; 5329 int val; 5330 5331 if (spec->codec_variant != ALC269_TYPE_ALC269VB) 5332 return; 5333 5334 if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { 5335 alc_write_coef_idx(codec, 0xf, 0x960b); 5336 alc_write_coef_idx(codec, 0xe, 0x8817); 5337 } 5338 5339 if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { 5340 alc_write_coef_idx(codec, 0xf, 0x960b); 5341 alc_write_coef_idx(codec, 0xe, 0x8814); 5342 } 5343 5344 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { 5345 val = alc_read_coef_idx(codec, 0x04); 5346 /* Power up output pin */ 5347 if (val != -1) 5348 alc_write_coef_idx(codec, 0x04, val | (1<<11)); 5349 } 5350 5351 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { 5352 val = alc_read_coef_idx(codec, 0xd); 5353 if (val != -1 && (val & 0x0c00) >> 10 != 0x1) { 5354 /* Capless ramp up clock control */ 5355 alc_write_coef_idx(codec, 0xd, val | (1<<10)); 5356 } 5357 val = alc_read_coef_idx(codec, 0x17); 5358 if (val != -1 && (val & 0x01c0) >> 6 != 0x4) { 5359 /* Class D power on reset */ 5360 alc_write_coef_idx(codec, 0x17, val | (1<<7)); 5361 } 5362 } 5363 5364 val = alc_read_coef_idx(codec, 0xd); /* Class D */ 5365 if (val != -1) 5366 alc_write_coef_idx(codec, 0xd, val | (1<<14)); 5367 5368 val = alc_read_coef_idx(codec, 0x4); /* HP */ 5369 if (val != -1) 5370 alc_write_coef_idx(codec, 0x4, val | (1<<11)); 5371 } 5372 5373 /* 5374 */ 5375 static int patch_alc269(struct hda_codec *codec) 5376 { 5377 struct alc_spec *spec; 5378 int err; 5379 5380 err = alc_alloc_spec(codec, 0x0b); 5381 if (err < 0) 5382 return err; 5383 5384 spec = codec->spec; 5385 spec->gen.shared_mic_vref_pin = 0x18; 5386 5387 snd_hda_pick_fixup(codec, alc269_fixup_models, 5388 alc269_fixup_tbl, alc269_fixups); 5389 snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups); 5390 snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl, 5391 alc269_fixups); 5392 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 5393 5394 alc_auto_parse_customize_define(codec); 5395 5396 if (has_cdefine_beep(codec)) 5397 spec->gen.beep_nid = 0x01; 5398 5399 switch (codec->vendor_id) { 5400 case 0x10ec0269: 5401 spec->codec_variant = ALC269_TYPE_ALC269VA; 5402 switch (alc_get_coef0(codec) & 0x00f0) { 5403 case 0x0010: 5404 if (codec->bus->pci && 5405 codec->bus->pci->subsystem_vendor == 0x1025 && 5406 spec->cdefine.platform_type == 1) 5407 err = alc_codec_rename(codec, "ALC271X"); 5408 spec->codec_variant = ALC269_TYPE_ALC269VB; 5409 break; 5410 case 0x0020: 5411 if (codec->bus->pci && 5412 codec->bus->pci->subsystem_vendor == 0x17aa && 5413 codec->bus->pci->subsystem_device == 0x21f3) 5414 err = alc_codec_rename(codec, "ALC3202"); 5415 spec->codec_variant = ALC269_TYPE_ALC269VC; 5416 break; 5417 case 0x0030: 5418 spec->codec_variant = ALC269_TYPE_ALC269VD; 5419 break; 5420 default: 5421 alc_fix_pll_init(codec, 0x20, 0x04, 15); 5422 } 5423 if (err < 0) 5424 goto error; 5425 spec->init_hook = alc269_fill_coef; 5426 alc269_fill_coef(codec); 5427 break; 5428 5429 case 0x10ec0280: 5430 case 0x10ec0290: 5431 spec->codec_variant = ALC269_TYPE_ALC280; 5432 break; 5433 case 0x10ec0282: 5434 spec->codec_variant = ALC269_TYPE_ALC282; 5435 spec->shutup = alc282_shutup; 5436 spec->init_hook = alc282_init; 5437 break; 5438 case 0x10ec0233: 5439 case 0x10ec0283: 5440 spec->codec_variant = ALC269_TYPE_ALC283; 5441 spec->shutup = alc283_shutup; 5442 spec->init_hook = alc283_init; 5443 break; 5444 case 0x10ec0284: 5445 case 0x10ec0292: 5446 spec->codec_variant = ALC269_TYPE_ALC284; 5447 break; 5448 case 0x10ec0285: 5449 case 0x10ec0293: 5450 spec->codec_variant = ALC269_TYPE_ALC285; 5451 break; 5452 case 0x10ec0286: 5453 case 0x10ec0288: 5454 spec->codec_variant = ALC269_TYPE_ALC286; 5455 spec->shutup = alc286_shutup; 5456 break; 5457 case 0x10ec0255: 5458 spec->codec_variant = ALC269_TYPE_ALC255; 5459 break; 5460 } 5461 5462 if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) { 5463 spec->has_alc5505_dsp = 1; 5464 spec->init_hook = alc5505_dsp_init; 5465 } 5466 5467 /* automatic parse from the BIOS config */ 5468 err = alc269_parse_auto_config(codec); 5469 if (err < 0) 5470 goto error; 5471 5472 if (!spec->gen.no_analog && spec->gen.beep_nid) 5473 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 5474 5475 codec->patch_ops = alc_patch_ops; 5476 #ifdef CONFIG_PM 5477 codec->patch_ops.suspend = alc269_suspend; 5478 codec->patch_ops.resume = alc269_resume; 5479 #endif 5480 if (!spec->shutup) 5481 spec->shutup = alc269_shutup; 5482 5483 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 5484 5485 return 0; 5486 5487 error: 5488 alc_free(codec); 5489 return err; 5490 } 5491 5492 /* 5493 * ALC861 5494 */ 5495 5496 static int alc861_parse_auto_config(struct hda_codec *codec) 5497 { 5498 static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; 5499 static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; 5500 return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); 5501 } 5502 5503 /* Pin config fixes */ 5504 enum { 5505 ALC861_FIXUP_FSC_AMILO_PI1505, 5506 ALC861_FIXUP_AMP_VREF_0F, 5507 ALC861_FIXUP_NO_JACK_DETECT, 5508 ALC861_FIXUP_ASUS_A6RP, 5509 ALC660_FIXUP_ASUS_W7J, 5510 }; 5511 5512 /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ 5513 static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, 5514 const struct hda_fixup *fix, int action) 5515 { 5516 struct alc_spec *spec = codec->spec; 5517 unsigned int val; 5518 5519 if (action != HDA_FIXUP_ACT_INIT) 5520 return; 5521 val = snd_hda_codec_get_pin_target(codec, 0x0f); 5522 if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) 5523 val |= AC_PINCTL_IN_EN; 5524 val |= AC_PINCTL_VREF_50; 5525 snd_hda_set_pin_ctl(codec, 0x0f, val); 5526 spec->gen.keep_vref_in_automute = 1; 5527 } 5528 5529 /* suppress the jack-detection */ 5530 static void alc_fixup_no_jack_detect(struct hda_codec *codec, 5531 const struct hda_fixup *fix, int action) 5532 { 5533 if (action == HDA_FIXUP_ACT_PRE_PROBE) 5534 codec->no_jack_detect = 1; 5535 } 5536 5537 static const struct hda_fixup alc861_fixups[] = { 5538 [ALC861_FIXUP_FSC_AMILO_PI1505] = { 5539 .type = HDA_FIXUP_PINS, 5540 .v.pins = (const struct hda_pintbl[]) { 5541 { 0x0b, 0x0221101f }, /* HP */ 5542 { 0x0f, 0x90170310 }, /* speaker */ 5543 { } 5544 } 5545 }, 5546 [ALC861_FIXUP_AMP_VREF_0F] = { 5547 .type = HDA_FIXUP_FUNC, 5548 .v.func = alc861_fixup_asus_amp_vref_0f, 5549 }, 5550 [ALC861_FIXUP_NO_JACK_DETECT] = { 5551 .type = HDA_FIXUP_FUNC, 5552 .v.func = alc_fixup_no_jack_detect, 5553 }, 5554 [ALC861_FIXUP_ASUS_A6RP] = { 5555 .type = HDA_FIXUP_FUNC, 5556 .v.func = alc861_fixup_asus_amp_vref_0f, 5557 .chained = true, 5558 .chain_id = ALC861_FIXUP_NO_JACK_DETECT, 5559 }, 5560 [ALC660_FIXUP_ASUS_W7J] = { 5561 .type = HDA_FIXUP_VERBS, 5562 .v.verbs = (const struct hda_verb[]) { 5563 /* ASUS W7J needs a magic pin setup on unused NID 0x10 5564 * for enabling outputs 5565 */ 5566 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 5567 { } 5568 }, 5569 } 5570 }; 5571 5572 static const struct snd_pci_quirk alc861_fixup_tbl[] = { 5573 SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J), 5574 SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J), 5575 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), 5576 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), 5577 SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), 5578 SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), 5579 SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), 5580 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505), 5581 {} 5582 }; 5583 5584 /* 5585 */ 5586 static int patch_alc861(struct hda_codec *codec) 5587 { 5588 struct alc_spec *spec; 5589 int err; 5590 5591 err = alc_alloc_spec(codec, 0x15); 5592 if (err < 0) 5593 return err; 5594 5595 spec = codec->spec; 5596 spec->gen.beep_nid = 0x23; 5597 5598 snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); 5599 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 5600 5601 /* automatic parse from the BIOS config */ 5602 err = alc861_parse_auto_config(codec); 5603 if (err < 0) 5604 goto error; 5605 5606 if (!spec->gen.no_analog) 5607 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); 5608 5609 codec->patch_ops = alc_patch_ops; 5610 #ifdef CONFIG_PM 5611 spec->power_hook = alc_power_eapd; 5612 #endif 5613 5614 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 5615 5616 return 0; 5617 5618 error: 5619 alc_free(codec); 5620 return err; 5621 } 5622 5623 /* 5624 * ALC861-VD support 5625 * 5626 * Based on ALC882 5627 * 5628 * In addition, an independent DAC 5629 */ 5630 static int alc861vd_parse_auto_config(struct hda_codec *codec) 5631 { 5632 static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; 5633 static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 5634 return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); 5635 } 5636 5637 enum { 5638 ALC660VD_FIX_ASUS_GPIO1, 5639 ALC861VD_FIX_DALLAS, 5640 }; 5641 5642 /* exclude VREF80 */ 5643 static void alc861vd_fixup_dallas(struct hda_codec *codec, 5644 const struct hda_fixup *fix, int action) 5645 { 5646 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 5647 snd_hda_override_pin_caps(codec, 0x18, 0x00000734); 5648 snd_hda_override_pin_caps(codec, 0x19, 0x0000073c); 5649 } 5650 } 5651 5652 static const struct hda_fixup alc861vd_fixups[] = { 5653 [ALC660VD_FIX_ASUS_GPIO1] = { 5654 .type = HDA_FIXUP_VERBS, 5655 .v.verbs = (const struct hda_verb[]) { 5656 /* reset GPIO1 */ 5657 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 5658 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 5659 {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, 5660 { } 5661 } 5662 }, 5663 [ALC861VD_FIX_DALLAS] = { 5664 .type = HDA_FIXUP_FUNC, 5665 .v.func = alc861vd_fixup_dallas, 5666 }, 5667 }; 5668 5669 static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { 5670 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), 5671 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), 5672 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), 5673 {} 5674 }; 5675 5676 /* 5677 */ 5678 static int patch_alc861vd(struct hda_codec *codec) 5679 { 5680 struct alc_spec *spec; 5681 int err; 5682 5683 err = alc_alloc_spec(codec, 0x0b); 5684 if (err < 0) 5685 return err; 5686 5687 spec = codec->spec; 5688 spec->gen.beep_nid = 0x23; 5689 5690 snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); 5691 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 5692 5693 /* automatic parse from the BIOS config */ 5694 err = alc861vd_parse_auto_config(codec); 5695 if (err < 0) 5696 goto error; 5697 5698 if (!spec->gen.no_analog) 5699 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 5700 5701 codec->patch_ops = alc_patch_ops; 5702 5703 spec->shutup = alc_eapd_shutup; 5704 5705 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 5706 5707 return 0; 5708 5709 error: 5710 alc_free(codec); 5711 return err; 5712 } 5713 5714 /* 5715 * ALC662 support 5716 * 5717 * ALC662 is almost identical with ALC880 but has cleaner and more flexible 5718 * configuration. Each pin widget can choose any input DACs and a mixer. 5719 * Each ADC is connected from a mixer of all inputs. This makes possible 5720 * 6-channel independent captures. 5721 * 5722 * In addition, an independent DAC for the multi-playback (not used in this 5723 * driver yet). 5724 */ 5725 5726 /* 5727 * BIOS auto configuration 5728 */ 5729 5730 static int alc662_parse_auto_config(struct hda_codec *codec) 5731 { 5732 static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; 5733 static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; 5734 static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; 5735 const hda_nid_t *ssids; 5736 5737 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || 5738 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670 || 5739 codec->vendor_id == 0x10ec0671) 5740 ssids = alc663_ssids; 5741 else 5742 ssids = alc662_ssids; 5743 return alc_parse_auto_config(codec, alc662_ignore, ssids); 5744 } 5745 5746 static void alc272_fixup_mario(struct hda_codec *codec, 5747 const struct hda_fixup *fix, int action) 5748 { 5749 if (action != HDA_FIXUP_ACT_PRE_PROBE) 5750 return; 5751 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, 5752 (0x3b << AC_AMPCAP_OFFSET_SHIFT) | 5753 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | 5754 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | 5755 (0 << AC_AMPCAP_MUTE_SHIFT))) 5756 codec_warn(codec, "failed to override amp caps for NID 0x2\n"); 5757 } 5758 5759 static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = { 5760 { .channels = 2, 5761 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } }, 5762 { .channels = 4, 5763 .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, 5764 SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */ 5765 { } 5766 }; 5767 5768 /* override the 2.1 chmap */ 5769 static void alc_fixup_bass_chmap(struct hda_codec *codec, 5770 const struct hda_fixup *fix, int action) 5771 { 5772 if (action == HDA_FIXUP_ACT_BUILD) { 5773 struct alc_spec *spec = codec->spec; 5774 spec->gen.pcm_rec[0].stream[0].chmap = asus_pcm_2_1_chmaps; 5775 } 5776 } 5777 5778 /* turn on/off mute LED per vmaster hook */ 5779 static void alc662_led_gpio1_mute_hook(void *private_data, int enabled) 5780 { 5781 struct hda_codec *codec = private_data; 5782 struct alc_spec *spec = codec->spec; 5783 unsigned int oldval = spec->gpio_led; 5784 5785 if (enabled) 5786 spec->gpio_led &= ~0x01; 5787 else 5788 spec->gpio_led |= 0x01; 5789 if (spec->gpio_led != oldval) 5790 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 5791 spec->gpio_led); 5792 } 5793 5794 /* avoid D3 for keeping GPIO up */ 5795 static unsigned int gpio_led_power_filter(struct hda_codec *codec, 5796 hda_nid_t nid, 5797 unsigned int power_state) 5798 { 5799 struct alc_spec *spec = codec->spec; 5800 if (nid == codec->afg && power_state == AC_PWRST_D3 && spec->gpio_led) 5801 return AC_PWRST_D0; 5802 return power_state; 5803 } 5804 5805 static void alc662_fixup_led_gpio1(struct hda_codec *codec, 5806 const struct hda_fixup *fix, int action) 5807 { 5808 struct alc_spec *spec = codec->spec; 5809 static const struct hda_verb gpio_init[] = { 5810 { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 }, 5811 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 }, 5812 {} 5813 }; 5814 5815 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 5816 spec->gen.vmaster_mute.hook = alc662_led_gpio1_mute_hook; 5817 spec->gpio_led = 0; 5818 snd_hda_add_verbs(codec, gpio_init); 5819 codec->power_filter = gpio_led_power_filter; 5820 } 5821 } 5822 5823 enum { 5824 ALC662_FIXUP_ASPIRE, 5825 ALC662_FIXUP_LED_GPIO1, 5826 ALC662_FIXUP_IDEAPAD, 5827 ALC272_FIXUP_MARIO, 5828 ALC662_FIXUP_CZC_P10T, 5829 ALC662_FIXUP_SKU_IGNORE, 5830 ALC662_FIXUP_HP_RP5800, 5831 ALC662_FIXUP_ASUS_MODE1, 5832 ALC662_FIXUP_ASUS_MODE2, 5833 ALC662_FIXUP_ASUS_MODE3, 5834 ALC662_FIXUP_ASUS_MODE4, 5835 ALC662_FIXUP_ASUS_MODE5, 5836 ALC662_FIXUP_ASUS_MODE6, 5837 ALC662_FIXUP_ASUS_MODE7, 5838 ALC662_FIXUP_ASUS_MODE8, 5839 ALC662_FIXUP_NO_JACK_DETECT, 5840 ALC662_FIXUP_ZOTAC_Z68, 5841 ALC662_FIXUP_INV_DMIC, 5842 ALC668_FIXUP_DELL_MIC_NO_PRESENCE, 5843 ALC668_FIXUP_HEADSET_MODE, 5844 ALC662_FIXUP_BASS_MODE4_CHMAP, 5845 ALC662_FIXUP_BASS_16, 5846 ALC662_FIXUP_BASS_1A, 5847 ALC662_FIXUP_BASS_CHMAP, 5848 ALC668_FIXUP_AUTO_MUTE, 5849 ALC668_FIXUP_DELL_DISABLE_AAMIX, 5850 ALC668_FIXUP_DELL_XPS13, 5851 }; 5852 5853 static const struct hda_fixup alc662_fixups[] = { 5854 [ALC662_FIXUP_ASPIRE] = { 5855 .type = HDA_FIXUP_PINS, 5856 .v.pins = (const struct hda_pintbl[]) { 5857 { 0x15, 0x99130112 }, /* subwoofer */ 5858 { } 5859 } 5860 }, 5861 [ALC662_FIXUP_LED_GPIO1] = { 5862 .type = HDA_FIXUP_FUNC, 5863 .v.func = alc662_fixup_led_gpio1, 5864 }, 5865 [ALC662_FIXUP_IDEAPAD] = { 5866 .type = HDA_FIXUP_PINS, 5867 .v.pins = (const struct hda_pintbl[]) { 5868 { 0x17, 0x99130112 }, /* subwoofer */ 5869 { } 5870 }, 5871 .chained = true, 5872 .chain_id = ALC662_FIXUP_LED_GPIO1, 5873 }, 5874 [ALC272_FIXUP_MARIO] = { 5875 .type = HDA_FIXUP_FUNC, 5876 .v.func = alc272_fixup_mario, 5877 }, 5878 [ALC662_FIXUP_CZC_P10T] = { 5879 .type = HDA_FIXUP_VERBS, 5880 .v.verbs = (const struct hda_verb[]) { 5881 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, 5882 {} 5883 } 5884 }, 5885 [ALC662_FIXUP_SKU_IGNORE] = { 5886 .type = HDA_FIXUP_FUNC, 5887 .v.func = alc_fixup_sku_ignore, 5888 }, 5889 [ALC662_FIXUP_HP_RP5800] = { 5890 .type = HDA_FIXUP_PINS, 5891 .v.pins = (const struct hda_pintbl[]) { 5892 { 0x14, 0x0221201f }, /* HP out */ 5893 { } 5894 }, 5895 .chained = true, 5896 .chain_id = ALC662_FIXUP_SKU_IGNORE 5897 }, 5898 [ALC662_FIXUP_ASUS_MODE1] = { 5899 .type = HDA_FIXUP_PINS, 5900 .v.pins = (const struct hda_pintbl[]) { 5901 { 0x14, 0x99130110 }, /* speaker */ 5902 { 0x18, 0x01a19c20 }, /* mic */ 5903 { 0x19, 0x99a3092f }, /* int-mic */ 5904 { 0x21, 0x0121401f }, /* HP out */ 5905 { } 5906 }, 5907 .chained = true, 5908 .chain_id = ALC662_FIXUP_SKU_IGNORE 5909 }, 5910 [ALC662_FIXUP_ASUS_MODE2] = { 5911 .type = HDA_FIXUP_PINS, 5912 .v.pins = (const struct hda_pintbl[]) { 5913 { 0x14, 0x99130110 }, /* speaker */ 5914 { 0x18, 0x01a19820 }, /* mic */ 5915 { 0x19, 0x99a3092f }, /* int-mic */ 5916 { 0x1b, 0x0121401f }, /* HP out */ 5917 { } 5918 }, 5919 .chained = true, 5920 .chain_id = ALC662_FIXUP_SKU_IGNORE 5921 }, 5922 [ALC662_FIXUP_ASUS_MODE3] = { 5923 .type = HDA_FIXUP_PINS, 5924 .v.pins = (const struct hda_pintbl[]) { 5925 { 0x14, 0x99130110 }, /* speaker */ 5926 { 0x15, 0x0121441f }, /* HP */ 5927 { 0x18, 0x01a19840 }, /* mic */ 5928 { 0x19, 0x99a3094f }, /* int-mic */ 5929 { 0x21, 0x01211420 }, /* HP2 */ 5930 { } 5931 }, 5932 .chained = true, 5933 .chain_id = ALC662_FIXUP_SKU_IGNORE 5934 }, 5935 [ALC662_FIXUP_ASUS_MODE4] = { 5936 .type = HDA_FIXUP_PINS, 5937 .v.pins = (const struct hda_pintbl[]) { 5938 { 0x14, 0x99130110 }, /* speaker */ 5939 { 0x16, 0x99130111 }, /* speaker */ 5940 { 0x18, 0x01a19840 }, /* mic */ 5941 { 0x19, 0x99a3094f }, /* int-mic */ 5942 { 0x21, 0x0121441f }, /* HP */ 5943 { } 5944 }, 5945 .chained = true, 5946 .chain_id = ALC662_FIXUP_SKU_IGNORE 5947 }, 5948 [ALC662_FIXUP_ASUS_MODE5] = { 5949 .type = HDA_FIXUP_PINS, 5950 .v.pins = (const struct hda_pintbl[]) { 5951 { 0x14, 0x99130110 }, /* speaker */ 5952 { 0x15, 0x0121441f }, /* HP */ 5953 { 0x16, 0x99130111 }, /* speaker */ 5954 { 0x18, 0x01a19840 }, /* mic */ 5955 { 0x19, 0x99a3094f }, /* int-mic */ 5956 { } 5957 }, 5958 .chained = true, 5959 .chain_id = ALC662_FIXUP_SKU_IGNORE 5960 }, 5961 [ALC662_FIXUP_ASUS_MODE6] = { 5962 .type = HDA_FIXUP_PINS, 5963 .v.pins = (const struct hda_pintbl[]) { 5964 { 0x14, 0x99130110 }, /* speaker */ 5965 { 0x15, 0x01211420 }, /* HP2 */ 5966 { 0x18, 0x01a19840 }, /* mic */ 5967 { 0x19, 0x99a3094f }, /* int-mic */ 5968 { 0x1b, 0x0121441f }, /* HP */ 5969 { } 5970 }, 5971 .chained = true, 5972 .chain_id = ALC662_FIXUP_SKU_IGNORE 5973 }, 5974 [ALC662_FIXUP_ASUS_MODE7] = { 5975 .type = HDA_FIXUP_PINS, 5976 .v.pins = (const struct hda_pintbl[]) { 5977 { 0x14, 0x99130110 }, /* speaker */ 5978 { 0x17, 0x99130111 }, /* speaker */ 5979 { 0x18, 0x01a19840 }, /* mic */ 5980 { 0x19, 0x99a3094f }, /* int-mic */ 5981 { 0x1b, 0x01214020 }, /* HP */ 5982 { 0x21, 0x0121401f }, /* HP */ 5983 { } 5984 }, 5985 .chained = true, 5986 .chain_id = ALC662_FIXUP_SKU_IGNORE 5987 }, 5988 [ALC662_FIXUP_ASUS_MODE8] = { 5989 .type = HDA_FIXUP_PINS, 5990 .v.pins = (const struct hda_pintbl[]) { 5991 { 0x14, 0x99130110 }, /* speaker */ 5992 { 0x12, 0x99a30970 }, /* int-mic */ 5993 { 0x15, 0x01214020 }, /* HP */ 5994 { 0x17, 0x99130111 }, /* speaker */ 5995 { 0x18, 0x01a19840 }, /* mic */ 5996 { 0x21, 0x0121401f }, /* HP */ 5997 { } 5998 }, 5999 .chained = true, 6000 .chain_id = ALC662_FIXUP_SKU_IGNORE 6001 }, 6002 [ALC662_FIXUP_NO_JACK_DETECT] = { 6003 .type = HDA_FIXUP_FUNC, 6004 .v.func = alc_fixup_no_jack_detect, 6005 }, 6006 [ALC662_FIXUP_ZOTAC_Z68] = { 6007 .type = HDA_FIXUP_PINS, 6008 .v.pins = (const struct hda_pintbl[]) { 6009 { 0x1b, 0x02214020 }, /* Front HP */ 6010 { } 6011 } 6012 }, 6013 [ALC662_FIXUP_INV_DMIC] = { 6014 .type = HDA_FIXUP_FUNC, 6015 .v.func = alc_fixup_inv_dmic_0x12, 6016 }, 6017 [ALC668_FIXUP_DELL_XPS13] = { 6018 .type = HDA_FIXUP_FUNC, 6019 .v.func = alc_fixup_dell_xps13, 6020 .chained = true, 6021 .chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX 6022 }, 6023 [ALC668_FIXUP_DELL_DISABLE_AAMIX] = { 6024 .type = HDA_FIXUP_FUNC, 6025 .v.func = alc_fixup_disable_aamix, 6026 .chained = true, 6027 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE 6028 }, 6029 [ALC668_FIXUP_AUTO_MUTE] = { 6030 .type = HDA_FIXUP_FUNC, 6031 .v.func = alc_fixup_auto_mute_via_amp, 6032 .chained = true, 6033 .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE 6034 }, 6035 [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = { 6036 .type = HDA_FIXUP_PINS, 6037 .v.pins = (const struct hda_pintbl[]) { 6038 { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */ 6039 { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */ 6040 { } 6041 }, 6042 .chained = true, 6043 .chain_id = ALC668_FIXUP_HEADSET_MODE 6044 }, 6045 [ALC668_FIXUP_HEADSET_MODE] = { 6046 .type = HDA_FIXUP_FUNC, 6047 .v.func = alc_fixup_headset_mode_alc668, 6048 }, 6049 [ALC662_FIXUP_BASS_MODE4_CHMAP] = { 6050 .type = HDA_FIXUP_FUNC, 6051 .v.func = alc_fixup_bass_chmap, 6052 .chained = true, 6053 .chain_id = ALC662_FIXUP_ASUS_MODE4 6054 }, 6055 [ALC662_FIXUP_BASS_16] = { 6056 .type = HDA_FIXUP_PINS, 6057 .v.pins = (const struct hda_pintbl[]) { 6058 {0x16, 0x80106111}, /* bass speaker */ 6059 {} 6060 }, 6061 .chained = true, 6062 .chain_id = ALC662_FIXUP_BASS_CHMAP, 6063 }, 6064 [ALC662_FIXUP_BASS_1A] = { 6065 .type = HDA_FIXUP_PINS, 6066 .v.pins = (const struct hda_pintbl[]) { 6067 {0x1a, 0x80106111}, /* bass speaker */ 6068 {} 6069 }, 6070 .chained = true, 6071 .chain_id = ALC662_FIXUP_BASS_CHMAP, 6072 }, 6073 [ALC662_FIXUP_BASS_CHMAP] = { 6074 .type = HDA_FIXUP_FUNC, 6075 .v.func = alc_fixup_bass_chmap, 6076 }, 6077 }; 6078 6079 static const struct snd_pci_quirk alc662_fixup_tbl[] = { 6080 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), 6081 SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC), 6082 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), 6083 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), 6084 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC), 6085 SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC), 6086 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), 6087 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 6088 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 6089 SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13), 6090 SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13), 6091 SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 6092 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 6093 SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 6094 SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 6095 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), 6096 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A), 6097 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP), 6098 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16), 6099 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16), 6100 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP), 6101 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), 6102 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), 6103 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), 6104 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), 6105 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), 6106 SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68), 6107 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), 6108 6109 #if 0 6110 /* Below is a quirk table taken from the old code. 6111 * Basically the device should work as is without the fixup table. 6112 * If BIOS doesn't give a proper info, enable the corresponding 6113 * fixup entry. 6114 */ 6115 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), 6116 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), 6117 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), 6118 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), 6119 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), 6120 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6121 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), 6122 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), 6123 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), 6124 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6125 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), 6126 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), 6127 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), 6128 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), 6129 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), 6130 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6131 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), 6132 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), 6133 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6134 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), 6135 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), 6136 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6137 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), 6138 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), 6139 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), 6140 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6141 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), 6142 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), 6143 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6144 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), 6145 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6146 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6147 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), 6148 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), 6149 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), 6150 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), 6151 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), 6152 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), 6153 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), 6154 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), 6155 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), 6156 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), 6157 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), 6158 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), 6159 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), 6160 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), 6161 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), 6162 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), 6163 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), 6164 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), 6165 #endif 6166 {} 6167 }; 6168 6169 static const struct hda_model_fixup alc662_fixup_models[] = { 6170 {.id = ALC272_FIXUP_MARIO, .name = "mario"}, 6171 {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, 6172 {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, 6173 {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, 6174 {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, 6175 {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, 6176 {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, 6177 {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, 6178 {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, 6179 {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"}, 6180 {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"}, 6181 {} 6182 }; 6183 6184 static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = { 6185 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE, 6186 {0x12, 0x99a30130}, 6187 {0x14, 0x90170110}, 6188 {0x15, 0x0321101f}, 6189 {0x16, 0x03011020}, 6190 {0x18, 0x40000008}, 6191 {0x19, 0x411111f0}, 6192 {0x1a, 0x411111f0}, 6193 {0x1b, 0x411111f0}, 6194 {0x1d, 0x41000001}, 6195 {0x1e, 0x411111f0}, 6196 {0x1f, 0x411111f0}), 6197 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE, 6198 {0x12, 0x99a30140}, 6199 {0x14, 0x90170110}, 6200 {0x15, 0x0321101f}, 6201 {0x16, 0x03011020}, 6202 {0x18, 0x40000008}, 6203 {0x19, 0x411111f0}, 6204 {0x1a, 0x411111f0}, 6205 {0x1b, 0x411111f0}, 6206 {0x1d, 0x41000001}, 6207 {0x1e, 0x411111f0}, 6208 {0x1f, 0x411111f0}), 6209 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE, 6210 {0x12, 0x99a30150}, 6211 {0x14, 0x90170110}, 6212 {0x15, 0x0321101f}, 6213 {0x16, 0x03011020}, 6214 {0x18, 0x40000008}, 6215 {0x19, 0x411111f0}, 6216 {0x1a, 0x411111f0}, 6217 {0x1b, 0x411111f0}, 6218 {0x1d, 0x41000001}, 6219 {0x1e, 0x411111f0}, 6220 {0x1f, 0x411111f0}), 6221 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE, 6222 {0x12, 0x411111f0}, 6223 {0x14, 0x90170110}, 6224 {0x15, 0x0321101f}, 6225 {0x16, 0x03011020}, 6226 {0x18, 0x40000008}, 6227 {0x19, 0x411111f0}, 6228 {0x1a, 0x411111f0}, 6229 {0x1b, 0x411111f0}, 6230 {0x1d, 0x41000001}, 6231 {0x1e, 0x411111f0}, 6232 {0x1f, 0x411111f0}), 6233 SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE, 6234 {0x12, 0x90a60130}, 6235 {0x14, 0x90170110}, 6236 {0x15, 0x0321101f}, 6237 {0x16, 0x40000000}, 6238 {0x18, 0x411111f0}, 6239 {0x19, 0x411111f0}, 6240 {0x1a, 0x411111f0}, 6241 {0x1b, 0x411111f0}, 6242 {0x1d, 0x40d6832d}, 6243 {0x1e, 0x411111f0}, 6244 {0x1f, 0x411111f0}), 6245 {} 6246 }; 6247 6248 static void alc662_fill_coef(struct hda_codec *codec) 6249 { 6250 int val, coef; 6251 6252 coef = alc_get_coef0(codec); 6253 6254 switch (codec->vendor_id) { 6255 case 0x10ec0662: 6256 if ((coef & 0x00f0) == 0x0030) { 6257 val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */ 6258 alc_write_coef_idx(codec, 0x4, val & ~(1<<10)); 6259 } 6260 break; 6261 case 0x10ec0272: 6262 case 0x10ec0273: 6263 case 0x10ec0663: 6264 case 0x10ec0665: 6265 case 0x10ec0670: 6266 case 0x10ec0671: 6267 case 0x10ec0672: 6268 val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */ 6269 alc_write_coef_idx(codec, 0xd, val | (1<<14)); 6270 break; 6271 } 6272 } 6273 6274 /* 6275 */ 6276 static int patch_alc662(struct hda_codec *codec) 6277 { 6278 struct alc_spec *spec; 6279 int err; 6280 6281 err = alc_alloc_spec(codec, 0x0b); 6282 if (err < 0) 6283 return err; 6284 6285 spec = codec->spec; 6286 6287 /* handle multiple HPs as is */ 6288 spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; 6289 6290 alc_fix_pll_init(codec, 0x20, 0x04, 15); 6291 6292 spec->init_hook = alc662_fill_coef; 6293 alc662_fill_coef(codec); 6294 6295 snd_hda_pick_fixup(codec, alc662_fixup_models, 6296 alc662_fixup_tbl, alc662_fixups); 6297 snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups); 6298 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 6299 6300 alc_auto_parse_customize_define(codec); 6301 6302 if (has_cdefine_beep(codec)) 6303 spec->gen.beep_nid = 0x01; 6304 6305 if ((alc_get_coef0(codec) & (1 << 14)) && 6306 codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 && 6307 spec->cdefine.platform_type == 1) { 6308 err = alc_codec_rename(codec, "ALC272X"); 6309 if (err < 0) 6310 goto error; 6311 } 6312 6313 /* automatic parse from the BIOS config */ 6314 err = alc662_parse_auto_config(codec); 6315 if (err < 0) 6316 goto error; 6317 6318 if (!spec->gen.no_analog && spec->gen.beep_nid) { 6319 switch (codec->vendor_id) { 6320 case 0x10ec0662: 6321 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 6322 break; 6323 case 0x10ec0272: 6324 case 0x10ec0663: 6325 case 0x10ec0665: 6326 case 0x10ec0668: 6327 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 6328 break; 6329 case 0x10ec0273: 6330 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); 6331 break; 6332 } 6333 } 6334 6335 codec->patch_ops = alc_patch_ops; 6336 spec->shutup = alc_eapd_shutup; 6337 6338 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 6339 6340 return 0; 6341 6342 error: 6343 alc_free(codec); 6344 return err; 6345 } 6346 6347 /* 6348 * ALC680 support 6349 */ 6350 6351 static int alc680_parse_auto_config(struct hda_codec *codec) 6352 { 6353 return alc_parse_auto_config(codec, NULL, NULL); 6354 } 6355 6356 /* 6357 */ 6358 static int patch_alc680(struct hda_codec *codec) 6359 { 6360 int err; 6361 6362 /* ALC680 has no aa-loopback mixer */ 6363 err = alc_alloc_spec(codec, 0); 6364 if (err < 0) 6365 return err; 6366 6367 /* automatic parse from the BIOS config */ 6368 err = alc680_parse_auto_config(codec); 6369 if (err < 0) { 6370 alc_free(codec); 6371 return err; 6372 } 6373 6374 codec->patch_ops = alc_patch_ops; 6375 6376 return 0; 6377 } 6378 6379 /* 6380 * patch entries 6381 */ 6382 static const struct hda_codec_preset snd_hda_preset_realtek[] = { 6383 { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, 6384 { .id = 0x10ec0231, .name = "ALC231", .patch = patch_alc269 }, 6385 { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 }, 6386 { .id = 0x10ec0235, .name = "ALC233", .patch = patch_alc269 }, 6387 { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 }, 6388 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, 6389 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, 6390 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, 6391 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, 6392 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, 6393 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, 6394 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, 6395 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, 6396 { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, 6397 { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 }, 6398 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, 6399 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, 6400 { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 }, 6401 { .id = 0x10ec0285, .name = "ALC285", .patch = patch_alc269 }, 6402 { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 }, 6403 { .id = 0x10ec0288, .name = "ALC288", .patch = patch_alc269 }, 6404 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, 6405 { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 }, 6406 { .id = 0x10ec0293, .name = "ALC293", .patch = patch_alc269 }, 6407 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", 6408 .patch = patch_alc861 }, 6409 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, 6410 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, 6411 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, 6412 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", 6413 .patch = patch_alc882 }, 6414 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", 6415 .patch = patch_alc662 }, 6416 { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", 6417 .patch = patch_alc662 }, 6418 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, 6419 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, 6420 { .id = 0x10ec0667, .name = "ALC667", .patch = patch_alc662 }, 6421 { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 }, 6422 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, 6423 { .id = 0x10ec0671, .name = "ALC671", .patch = patch_alc662 }, 6424 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, 6425 { .id = 0x10ec0867, .name = "ALC891", .patch = patch_alc882 }, 6426 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 6427 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 6428 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, 6429 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", 6430 .patch = patch_alc882 }, 6431 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", 6432 .patch = patch_alc882 }, 6433 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 6434 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, 6435 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", 6436 .patch = patch_alc882 }, 6437 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, 6438 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, 6439 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, 6440 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, 6441 { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 }, 6442 {} /* terminator */ 6443 }; 6444 6445 MODULE_ALIAS("snd-hda-codec-id:10ec*"); 6446 6447 MODULE_LICENSE("GPL"); 6448 MODULE_DESCRIPTION("Realtek HD-audio codec"); 6449 6450 static struct hda_codec_preset_list realtek_list = { 6451 .preset = snd_hda_preset_realtek, 6452 .owner = THIS_MODULE, 6453 }; 6454 6455 static int __init patch_realtek_init(void) 6456 { 6457 return snd_hda_add_codec_preset(&realtek_list); 6458 } 6459 6460 static void __exit patch_realtek_exit(void) 6461 { 6462 snd_hda_delete_codec_preset(&realtek_list); 6463 } 6464 6465 module_init(patch_realtek_init) 6466 module_exit(patch_realtek_exit) 6467