linux/sound/pci/hda/patch_realtek.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0-or-later
   2/*
   3 * Universal Interface for Intel High Definition Audio Codec
   4 *
   5 * HD audio interface patch for Realtek ALC codecs
   6 *
   7 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
   8 *                    PeiSen Hou <pshou@realtek.com.tw>
   9 *                    Takashi Iwai <tiwai@suse.de>
  10 *                    Jonathan Woithe <jwoithe@just42.net>
  11 */
  12
  13#include <linux/init.h>
  14#include <linux/delay.h>
  15#include <linux/slab.h>
  16#include <linux/pci.h>
  17#include <linux/dmi.h>
  18#include <linux/module.h>
  19#include <linux/input.h>
  20#include <linux/leds.h>
  21#include <sound/core.h>
  22#include <sound/jack.h>
  23#include <sound/hda_codec.h>
  24#include "hda_local.h"
  25#include "hda_auto_parser.h"
  26#include "hda_jack.h"
  27#include "hda_generic.h"
  28
  29/* keep halting ALC5505 DSP, for power saving */
  30#define HALT_REALTEK_ALC5505
  31
  32/* extra amp-initialization sequence types */
  33enum {
  34        ALC_INIT_UNDEFINED,
  35        ALC_INIT_NONE,
  36        ALC_INIT_DEFAULT,
  37};
  38
  39enum {
  40        ALC_HEADSET_MODE_UNKNOWN,
  41        ALC_HEADSET_MODE_UNPLUGGED,
  42        ALC_HEADSET_MODE_HEADSET,
  43        ALC_HEADSET_MODE_MIC,
  44        ALC_HEADSET_MODE_HEADPHONE,
  45};
  46
  47enum {
  48        ALC_HEADSET_TYPE_UNKNOWN,
  49        ALC_HEADSET_TYPE_CTIA,
  50        ALC_HEADSET_TYPE_OMTP,
  51};
  52
  53enum {
  54        ALC_KEY_MICMUTE_INDEX,
  55};
  56
  57struct alc_customize_define {
  58        unsigned int  sku_cfg;
  59        unsigned char port_connectivity;
  60        unsigned char check_sum;
  61        unsigned char customization;
  62        unsigned char external_amp;
  63        unsigned int  enable_pcbeep:1;
  64        unsigned int  platform_type:1;
  65        unsigned int  swap:1;
  66        unsigned int  override:1;
  67        unsigned int  fixup:1; /* Means that this sku is set by driver, not read from hw */
  68};
  69
  70struct alc_coef_led {
  71        unsigned int idx;
  72        unsigned int mask;
  73        unsigned int on;
  74        unsigned int off;
  75};
  76
  77struct alc_spec {
  78        struct hda_gen_spec gen; /* must be at head */
  79
  80        /* codec parameterization */
  81        struct alc_customize_define cdefine;
  82        unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
  83
  84        /* GPIO bits */
  85        unsigned int gpio_mask;
  86        unsigned int gpio_dir;
  87        unsigned int gpio_data;
  88        bool gpio_write_delay;  /* add a delay before writing gpio_data */
  89
  90        /* mute LED for HP laptops, see vref_mute_led_set() */
  91        int mute_led_polarity;
  92        int micmute_led_polarity;
  93        hda_nid_t mute_led_nid;
  94        hda_nid_t cap_mute_led_nid;
  95
  96        unsigned int gpio_mute_led_mask;
  97        unsigned int gpio_mic_led_mask;
  98        struct alc_coef_led mute_led_coef;
  99        struct alc_coef_led mic_led_coef;
 100
 101        hda_nid_t headset_mic_pin;
 102        hda_nid_t headphone_mic_pin;
 103        int current_headset_mode;
 104        int current_headset_type;
 105
 106        /* hooks */
 107        void (*init_hook)(struct hda_codec *codec);
 108#ifdef CONFIG_PM
 109        void (*power_hook)(struct hda_codec *codec);
 110#endif
 111        void (*shutup)(struct hda_codec *codec);
 112
 113        int init_amp;
 114        int codec_variant;      /* flag for other variants */
 115        unsigned int has_alc5505_dsp:1;
 116        unsigned int no_depop_delay:1;
 117        unsigned int done_hp_init:1;
 118        unsigned int no_shutup_pins:1;
 119        unsigned int ultra_low_power:1;
 120        unsigned int has_hs_key:1;
 121        unsigned int no_internal_mic_pin:1;
 122
 123        /* for PLL fix */
 124        hda_nid_t pll_nid;
 125        unsigned int pll_coef_idx, pll_coef_bit;
 126        unsigned int coef0;
 127        struct input_dev *kb_dev;
 128        u8 alc_mute_keycode_map[1];
 129};
 130
 131/*
 132 * COEF access helper functions
 133 */
 134
 135static int alc_read_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
 136                               unsigned int coef_idx)
 137{
 138        unsigned int val;
 139
 140        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
 141        val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
 142        return val;
 143}
 144
 145#define alc_read_coef_idx(codec, coef_idx) \
 146        alc_read_coefex_idx(codec, 0x20, coef_idx)
 147
 148static void alc_write_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
 149                                 unsigned int coef_idx, unsigned int coef_val)
 150{
 151        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, coef_idx);
 152        snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PROC_COEF, coef_val);
 153}
 154
 155#define alc_write_coef_idx(codec, coef_idx, coef_val) \
 156        alc_write_coefex_idx(codec, 0x20, coef_idx, coef_val)
 157
 158static void alc_update_coefex_idx(struct hda_codec *codec, hda_nid_t nid,
 159                                  unsigned int coef_idx, unsigned int mask,
 160                                  unsigned int bits_set)
 161{
 162        unsigned int val = alc_read_coefex_idx(codec, nid, coef_idx);
 163
 164        if (val != -1)
 165                alc_write_coefex_idx(codec, nid, coef_idx,
 166                                     (val & ~mask) | bits_set);
 167}
 168
 169#define alc_update_coef_idx(codec, coef_idx, mask, bits_set)    \
 170        alc_update_coefex_idx(codec, 0x20, coef_idx, mask, bits_set)
 171
 172/* a special bypass for COEF 0; read the cached value at the second time */
 173static unsigned int alc_get_coef0(struct hda_codec *codec)
 174{
 175        struct alc_spec *spec = codec->spec;
 176
 177        if (!spec->coef0)
 178                spec->coef0 = alc_read_coef_idx(codec, 0);
 179        return spec->coef0;
 180}
 181
 182/* coef writes/updates batch */
 183struct coef_fw {
 184        unsigned char nid;
 185        unsigned char idx;
 186        unsigned short mask;
 187        unsigned short val;
 188};
 189
 190#define UPDATE_COEFEX(_nid, _idx, _mask, _val) \
 191        { .nid = (_nid), .idx = (_idx), .mask = (_mask), .val = (_val) }
 192#define WRITE_COEFEX(_nid, _idx, _val) UPDATE_COEFEX(_nid, _idx, -1, _val)
 193#define WRITE_COEF(_idx, _val) WRITE_COEFEX(0x20, _idx, _val)
 194#define UPDATE_COEF(_idx, _mask, _val) UPDATE_COEFEX(0x20, _idx, _mask, _val)
 195
 196static void alc_process_coef_fw(struct hda_codec *codec,
 197                                const struct coef_fw *fw)
 198{
 199        for (; fw->nid; fw++) {
 200                if (fw->mask == (unsigned short)-1)
 201                        alc_write_coefex_idx(codec, fw->nid, fw->idx, fw->val);
 202                else
 203                        alc_update_coefex_idx(codec, fw->nid, fw->idx,
 204                                              fw->mask, fw->val);
 205        }
 206}
 207
 208/*
 209 * GPIO setup tables, used in initialization
 210 */
 211
 212/* Enable GPIO mask and set output */
 213static void alc_setup_gpio(struct hda_codec *codec, unsigned int mask)
 214{
 215        struct alc_spec *spec = codec->spec;
 216
 217        spec->gpio_mask |= mask;
 218        spec->gpio_dir |= mask;
 219        spec->gpio_data |= mask;
 220}
 221
 222static void alc_write_gpio_data(struct hda_codec *codec)
 223{
 224        struct alc_spec *spec = codec->spec;
 225
 226        snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
 227                            spec->gpio_data);
 228}
 229
 230static void alc_update_gpio_data(struct hda_codec *codec, unsigned int mask,
 231                                 bool on)
 232{
 233        struct alc_spec *spec = codec->spec;
 234        unsigned int oldval = spec->gpio_data;
 235
 236        if (on)
 237                spec->gpio_data |= mask;
 238        else
 239                spec->gpio_data &= ~mask;
 240        if (oldval != spec->gpio_data)
 241                alc_write_gpio_data(codec);
 242}
 243
 244static void alc_write_gpio(struct hda_codec *codec)
 245{
 246        struct alc_spec *spec = codec->spec;
 247
 248        if (!spec->gpio_mask)
 249                return;
 250
 251        snd_hda_codec_write(codec, codec->core.afg, 0,
 252                            AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
 253        snd_hda_codec_write(codec, codec->core.afg, 0,
 254                            AC_VERB_SET_GPIO_DIRECTION, spec->gpio_dir);
 255        if (spec->gpio_write_delay)
 256                msleep(1);
 257        alc_write_gpio_data(codec);
 258}
 259
 260static void alc_fixup_gpio(struct hda_codec *codec, int action,
 261                           unsigned int mask)
 262{
 263        if (action == HDA_FIXUP_ACT_PRE_PROBE)
 264                alc_setup_gpio(codec, mask);
 265}
 266
 267static void alc_fixup_gpio1(struct hda_codec *codec,
 268                            const struct hda_fixup *fix, int action)
 269{
 270        alc_fixup_gpio(codec, action, 0x01);
 271}
 272
 273static void alc_fixup_gpio2(struct hda_codec *codec,
 274                            const struct hda_fixup *fix, int action)
 275{
 276        alc_fixup_gpio(codec, action, 0x02);
 277}
 278
 279static void alc_fixup_gpio3(struct hda_codec *codec,
 280                            const struct hda_fixup *fix, int action)
 281{
 282        alc_fixup_gpio(codec, action, 0x03);
 283}
 284
 285static void alc_fixup_gpio4(struct hda_codec *codec,
 286                            const struct hda_fixup *fix, int action)
 287{
 288        alc_fixup_gpio(codec, action, 0x04);
 289}
 290
 291static void alc_fixup_micmute_led(struct hda_codec *codec,
 292                                  const struct hda_fixup *fix, int action)
 293{
 294        if (action == HDA_FIXUP_ACT_PRE_PROBE)
 295                snd_hda_gen_add_micmute_led_cdev(codec, NULL);
 296}
 297
 298/*
 299 * Fix hardware PLL issue
 300 * On some codecs, the analog PLL gating control must be off while
 301 * the default value is 1.
 302 */
 303static void alc_fix_pll(struct hda_codec *codec)
 304{
 305        struct alc_spec *spec = codec->spec;
 306
 307        if (spec->pll_nid)
 308                alc_update_coefex_idx(codec, spec->pll_nid, spec->pll_coef_idx,
 309                                      1 << spec->pll_coef_bit, 0);
 310}
 311
 312static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
 313                             unsigned int coef_idx, unsigned int coef_bit)
 314{
 315        struct alc_spec *spec = codec->spec;
 316        spec->pll_nid = nid;
 317        spec->pll_coef_idx = coef_idx;
 318        spec->pll_coef_bit = coef_bit;
 319        alc_fix_pll(codec);
 320}
 321
 322/* update the master volume per volume-knob's unsol event */
 323static void alc_update_knob_master(struct hda_codec *codec,
 324                                   struct hda_jack_callback *jack)
 325{
 326        unsigned int val;
 327        struct snd_kcontrol *kctl;
 328        struct snd_ctl_elem_value *uctl;
 329
 330        kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
 331        if (!kctl)
 332                return;
 333        uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
 334        if (!uctl)
 335                return;
 336        val = snd_hda_codec_read(codec, jack->nid, 0,
 337                                 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
 338        val &= HDA_AMP_VOLMASK;
 339        uctl->value.integer.value[0] = val;
 340        uctl->value.integer.value[1] = val;
 341        kctl->put(kctl, uctl);
 342        kfree(uctl);
 343}
 344
 345static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
 346{
 347        /* For some reason, the res given from ALC880 is broken.
 348           Here we adjust it properly. */
 349        snd_hda_jack_unsol_event(codec, res >> 2);
 350}
 351
 352/* Change EAPD to verb control */
 353static void alc_fill_eapd_coef(struct hda_codec *codec)
 354{
 355        int coef;
 356
 357        coef = alc_get_coef0(codec);
 358
 359        switch (codec->core.vendor_id) {
 360        case 0x10ec0262:
 361                alc_update_coef_idx(codec, 0x7, 0, 1<<5);
 362                break;
 363        case 0x10ec0267:
 364        case 0x10ec0268:
 365                alc_update_coef_idx(codec, 0x7, 0, 1<<13);
 366                break;
 367        case 0x10ec0269:
 368                if ((coef & 0x00f0) == 0x0010)
 369                        alc_update_coef_idx(codec, 0xd, 0, 1<<14);
 370                if ((coef & 0x00f0) == 0x0020)
 371                        alc_update_coef_idx(codec, 0x4, 1<<15, 0);
 372                if ((coef & 0x00f0) == 0x0030)
 373                        alc_update_coef_idx(codec, 0x10, 1<<9, 0);
 374                break;
 375        case 0x10ec0280:
 376        case 0x10ec0284:
 377        case 0x10ec0290:
 378        case 0x10ec0292:
 379                alc_update_coef_idx(codec, 0x4, 1<<15, 0);
 380                break;
 381        case 0x10ec0225:
 382        case 0x10ec0295:
 383        case 0x10ec0299:
 384                alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
 385                fallthrough;
 386        case 0x10ec0215:
 387        case 0x10ec0230:
 388        case 0x10ec0233:
 389        case 0x10ec0235:
 390        case 0x10ec0236:
 391        case 0x10ec0245:
 392        case 0x10ec0255:
 393        case 0x10ec0256:
 394        case 0x10ec0257:
 395        case 0x10ec0282:
 396        case 0x10ec0283:
 397        case 0x10ec0286:
 398        case 0x10ec0288:
 399        case 0x10ec0285:
 400        case 0x10ec0298:
 401        case 0x10ec0289:
 402        case 0x10ec0300:
 403                alc_update_coef_idx(codec, 0x10, 1<<9, 0);
 404                break;
 405        case 0x10ec0275:
 406                alc_update_coef_idx(codec, 0xe, 0, 1<<0);
 407                break;
 408        case 0x10ec0287:
 409                alc_update_coef_idx(codec, 0x10, 1<<9, 0);
 410                alc_write_coef_idx(codec, 0x8, 0x4ab7);
 411                break;
 412        case 0x10ec0293:
 413                alc_update_coef_idx(codec, 0xa, 1<<13, 0);
 414                break;
 415        case 0x10ec0234:
 416        case 0x10ec0274:
 417        case 0x10ec0294:
 418        case 0x10ec0700:
 419        case 0x10ec0701:
 420        case 0x10ec0703:
 421        case 0x10ec0711:
 422                alc_update_coef_idx(codec, 0x10, 1<<15, 0);
 423                break;
 424        case 0x10ec0662:
 425                if ((coef & 0x00f0) == 0x0030)
 426                        alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
 427                break;
 428        case 0x10ec0272:
 429        case 0x10ec0273:
 430        case 0x10ec0663:
 431        case 0x10ec0665:
 432        case 0x10ec0670:
 433        case 0x10ec0671:
 434        case 0x10ec0672:
 435                alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
 436                break;
 437        case 0x10ec0222:
 438        case 0x10ec0623:
 439                alc_update_coef_idx(codec, 0x19, 1<<13, 0);
 440                break;
 441        case 0x10ec0668:
 442                alc_update_coef_idx(codec, 0x7, 3<<13, 0);
 443                break;
 444        case 0x10ec0867:
 445                alc_update_coef_idx(codec, 0x4, 1<<10, 0);
 446                break;
 447        case 0x10ec0888:
 448                if ((coef & 0x00f0) == 0x0020 || (coef & 0x00f0) == 0x0030)
 449                        alc_update_coef_idx(codec, 0x7, 1<<5, 0);
 450                break;
 451        case 0x10ec0892:
 452        case 0x10ec0897:
 453                alc_update_coef_idx(codec, 0x7, 1<<5, 0);
 454                break;
 455        case 0x10ec0899:
 456        case 0x10ec0900:
 457        case 0x10ec0b00:
 458        case 0x10ec1168:
 459        case 0x10ec1220:
 460                alc_update_coef_idx(codec, 0x7, 1<<1, 0);
 461                break;
 462        }
 463}
 464
 465/* additional initialization for ALC888 variants */
 466static void alc888_coef_init(struct hda_codec *codec)
 467{
 468        switch (alc_get_coef0(codec) & 0x00f0) {
 469        /* alc888-VA */
 470        case 0x00:
 471        /* alc888-VB */
 472        case 0x10:
 473                alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */
 474                break;
 475        }
 476}
 477
 478/* turn on/off EAPD control (only if available) */
 479static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
 480{
 481        if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
 482                return;
 483        if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
 484                snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
 485                                    on ? 2 : 0);
 486}
 487
 488/* turn on/off EAPD controls of the codec */
 489static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
 490{
 491        /* We currently only handle front, HP */
 492        static const hda_nid_t pins[] = {
 493                0x0f, 0x10, 0x14, 0x15, 0x17, 0
 494        };
 495        const hda_nid_t *p;
 496        for (p = pins; *p; p++)
 497                set_eapd(codec, *p, on);
 498}
 499
 500static int find_ext_mic_pin(struct hda_codec *codec);
 501
 502static void alc_headset_mic_no_shutup(struct hda_codec *codec)
 503{
 504        const struct hda_pincfg *pin;
 505        int mic_pin = find_ext_mic_pin(codec);
 506        int i;
 507
 508        /* don't shut up pins when unloading the driver; otherwise it breaks
 509         * the default pin setup at the next load of the driver
 510         */
 511        if (codec->bus->shutdown)
 512                return;
 513
 514        snd_array_for_each(&codec->init_pins, i, pin) {
 515                /* use read here for syncing after issuing each verb */
 516                if (pin->nid != mic_pin)
 517                        snd_hda_codec_read(codec, pin->nid, 0,
 518                                        AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
 519        }
 520
 521        codec->pins_shutup = 1;
 522}
 523
 524static void alc_shutup_pins(struct hda_codec *codec)
 525{
 526        struct alc_spec *spec = codec->spec;
 527
 528        switch (codec->core.vendor_id) {
 529        case 0x10ec0236:
 530        case 0x10ec0256:
 531        case 0x10ec0283:
 532        case 0x10ec0286:
 533        case 0x10ec0288:
 534        case 0x10ec0298:
 535                alc_headset_mic_no_shutup(codec);
 536                break;
 537        default:
 538                if (!spec->no_shutup_pins)
 539                        snd_hda_shutup_pins(codec);
 540                break;
 541        }
 542}
 543
 544/* generic shutup callback;
 545 * just turning off EAPD and a little pause for avoiding pop-noise
 546 */
 547static void alc_eapd_shutup(struct hda_codec *codec)
 548{
 549        struct alc_spec *spec = codec->spec;
 550
 551        alc_auto_setup_eapd(codec, false);
 552        if (!spec->no_depop_delay)
 553                msleep(200);
 554        alc_shutup_pins(codec);
 555}
 556
 557/* generic EAPD initialization */
 558static void alc_auto_init_amp(struct hda_codec *codec, int type)
 559{
 560        alc_auto_setup_eapd(codec, true);
 561        alc_write_gpio(codec);
 562        switch (type) {
 563        case ALC_INIT_DEFAULT:
 564                switch (codec->core.vendor_id) {
 565                case 0x10ec0260:
 566                        alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
 567                        break;
 568                case 0x10ec0880:
 569                case 0x10ec0882:
 570                case 0x10ec0883:
 571                case 0x10ec0885:
 572                        alc_update_coef_idx(codec, 7, 0, 0x2030);
 573                        break;
 574                case 0x10ec0888:
 575                        alc888_coef_init(codec);
 576                        break;
 577                }
 578                break;
 579        }
 580}
 581
 582/* get a primary headphone pin if available */
 583static hda_nid_t alc_get_hp_pin(struct alc_spec *spec)
 584{
 585        if (spec->gen.autocfg.hp_pins[0])
 586                return spec->gen.autocfg.hp_pins[0];
 587        if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
 588                return spec->gen.autocfg.line_out_pins[0];
 589        return 0;
 590}
 591
 592/*
 593 * Realtek SSID verification
 594 */
 595
 596/* Could be any non-zero and even value. When used as fixup, tells
 597 * the driver to ignore any present sku defines.
 598 */
 599#define ALC_FIXUP_SKU_IGNORE (2)
 600
 601static void alc_fixup_sku_ignore(struct hda_codec *codec,
 602                                 const struct hda_fixup *fix, int action)
 603{
 604        struct alc_spec *spec = codec->spec;
 605        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
 606                spec->cdefine.fixup = 1;
 607                spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
 608        }
 609}
 610
 611static void alc_fixup_no_depop_delay(struct hda_codec *codec,
 612                                    const struct hda_fixup *fix, int action)
 613{
 614        struct alc_spec *spec = codec->spec;
 615
 616        if (action == HDA_FIXUP_ACT_PROBE) {
 617                spec->no_depop_delay = 1;
 618                codec->depop_delay = 0;
 619        }
 620}
 621
 622static int alc_auto_parse_customize_define(struct hda_codec *codec)
 623{
 624        unsigned int ass, tmp, i;
 625        unsigned nid = 0;
 626        struct alc_spec *spec = codec->spec;
 627
 628        spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
 629
 630        if (spec->cdefine.fixup) {
 631                ass = spec->cdefine.sku_cfg;
 632                if (ass == ALC_FIXUP_SKU_IGNORE)
 633                        return -1;
 634                goto do_sku;
 635        }
 636
 637        if (!codec->bus->pci)
 638                return -1;
 639        ass = codec->core.subsystem_id & 0xffff;
 640        if (ass != codec->bus->pci->subsystem_device && (ass & 1))
 641                goto do_sku;
 642
 643        nid = 0x1d;
 644        if (codec->core.vendor_id == 0x10ec0260)
 645                nid = 0x17;
 646        ass = snd_hda_codec_get_pincfg(codec, nid);
 647
 648        if (!(ass & 1)) {
 649                codec_info(codec, "%s: SKU not ready 0x%08x\n",
 650                           codec->core.chip_name, ass);
 651                return -1;
 652        }
 653
 654        /* check sum */
 655        tmp = 0;
 656        for (i = 1; i < 16; i++) {
 657                if ((ass >> i) & 1)
 658                        tmp++;
 659        }
 660        if (((ass >> 16) & 0xf) != tmp)
 661                return -1;
 662
 663        spec->cdefine.port_connectivity = ass >> 30;
 664        spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
 665        spec->cdefine.check_sum = (ass >> 16) & 0xf;
 666        spec->cdefine.customization = ass >> 8;
 667do_sku:
 668        spec->cdefine.sku_cfg = ass;
 669        spec->cdefine.external_amp = (ass & 0x38) >> 3;
 670        spec->cdefine.platform_type = (ass & 0x4) >> 2;
 671        spec->cdefine.swap = (ass & 0x2) >> 1;
 672        spec->cdefine.override = ass & 0x1;
 673
 674        codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
 675                   nid, spec->cdefine.sku_cfg);
 676        codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
 677                   spec->cdefine.port_connectivity);
 678        codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
 679        codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
 680        codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
 681        codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
 682        codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
 683        codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
 684        codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
 685
 686        return 0;
 687}
 688
 689/* return the position of NID in the list, or -1 if not found */
 690static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
 691{
 692        int i;
 693        for (i = 0; i < nums; i++)
 694                if (list[i] == nid)
 695                        return i;
 696        return -1;
 697}
 698/* return true if the given NID is found in the list */
 699static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
 700{
 701        return find_idx_in_nid_list(nid, list, nums) >= 0;
 702}
 703
 704/* check subsystem ID and set up device-specific initialization;
 705 * return 1 if initialized, 0 if invalid SSID
 706 */
 707/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
 708 *      31 ~ 16 :       Manufacture ID
 709 *      15 ~ 8  :       SKU ID
 710 *      7  ~ 0  :       Assembly ID
 711 *      port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
 712 */
 713static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
 714{
 715        unsigned int ass, tmp, i;
 716        unsigned nid;
 717        struct alc_spec *spec = codec->spec;
 718
 719        if (spec->cdefine.fixup) {
 720                ass = spec->cdefine.sku_cfg;
 721                if (ass == ALC_FIXUP_SKU_IGNORE)
 722                        return 0;
 723                goto do_sku;
 724        }
 725
 726        ass = codec->core.subsystem_id & 0xffff;
 727        if (codec->bus->pci &&
 728            ass != codec->bus->pci->subsystem_device && (ass & 1))
 729                goto do_sku;
 730
 731        /* invalid SSID, check the special NID pin defcfg instead */
 732        /*
 733         * 31~30        : port connectivity
 734         * 29~21        : reserve
 735         * 20           : PCBEEP input
 736         * 19~16        : Check sum (15:1)
 737         * 15~1         : Custom
 738         * 0            : override
 739        */
 740        nid = 0x1d;
 741        if (codec->core.vendor_id == 0x10ec0260)
 742                nid = 0x17;
 743        ass = snd_hda_codec_get_pincfg(codec, nid);
 744        codec_dbg(codec,
 745                  "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
 746                   ass, nid);
 747        if (!(ass & 1))
 748                return 0;
 749        if ((ass >> 30) != 1)   /* no physical connection */
 750                return 0;
 751
 752        /* check sum */
 753        tmp = 0;
 754        for (i = 1; i < 16; i++) {
 755                if ((ass >> i) & 1)
 756                        tmp++;
 757        }
 758        if (((ass >> 16) & 0xf) != tmp)
 759                return 0;
 760do_sku:
 761        codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
 762                   ass & 0xffff, codec->core.vendor_id);
 763        /*
 764         * 0 : override
 765         * 1 :  Swap Jack
 766         * 2 : 0 --> Desktop, 1 --> Laptop
 767         * 3~5 : External Amplifier control
 768         * 7~6 : Reserved
 769        */
 770        tmp = (ass & 0x38) >> 3;        /* external Amp control */
 771        if (spec->init_amp == ALC_INIT_UNDEFINED) {
 772                switch (tmp) {
 773                case 1:
 774                        alc_setup_gpio(codec, 0x01);
 775                        break;
 776                case 3:
 777                        alc_setup_gpio(codec, 0x02);
 778                        break;
 779                case 7:
 780                        alc_setup_gpio(codec, 0x03);
 781                        break;
 782                case 5:
 783                default:
 784                        spec->init_amp = ALC_INIT_DEFAULT;
 785                        break;
 786                }
 787        }
 788
 789        /* is laptop or Desktop and enable the function "Mute internal speaker
 790         * when the external headphone out jack is plugged"
 791         */
 792        if (!(ass & 0x8000))
 793                return 1;
 794        /*
 795         * 10~8 : Jack location
 796         * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
 797         * 14~13: Resvered
 798         * 15   : 1 --> enable the function "Mute internal speaker
 799         *              when the external headphone out jack is plugged"
 800         */
 801        if (!alc_get_hp_pin(spec)) {
 802                hda_nid_t nid;
 803                tmp = (ass >> 11) & 0x3;        /* HP to chassis */
 804                nid = ports[tmp];
 805                if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
 806                                      spec->gen.autocfg.line_outs))
 807                        return 1;
 808                spec->gen.autocfg.hp_pins[0] = nid;
 809        }
 810        return 1;
 811}
 812
 813/* Check the validity of ALC subsystem-id
 814 * ports contains an array of 4 pin NIDs for port-A, E, D and I */
 815static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
 816{
 817        if (!alc_subsystem_id(codec, ports)) {
 818                struct alc_spec *spec = codec->spec;
 819                if (spec->init_amp == ALC_INIT_UNDEFINED) {
 820                        codec_dbg(codec,
 821                                  "realtek: Enable default setup for auto mode as fallback\n");
 822                        spec->init_amp = ALC_INIT_DEFAULT;
 823                }
 824        }
 825}
 826
 827/*
 828 */
 829
 830static void alc_fixup_inv_dmic(struct hda_codec *codec,
 831                               const struct hda_fixup *fix, int action)
 832{
 833        struct alc_spec *spec = codec->spec;
 834
 835        spec->gen.inv_dmic_split = 1;
 836}
 837
 838
 839static int alc_build_controls(struct hda_codec *codec)
 840{
 841        int err;
 842
 843        err = snd_hda_gen_build_controls(codec);
 844        if (err < 0)
 845                return err;
 846
 847        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
 848        return 0;
 849}
 850
 851
 852/*
 853 * Common callbacks
 854 */
 855
 856static void alc_pre_init(struct hda_codec *codec)
 857{
 858        alc_fill_eapd_coef(codec);
 859}
 860
 861#define is_s3_resume(codec) \
 862        ((codec)->core.dev.power.power_state.event == PM_EVENT_RESUME)
 863#define is_s4_resume(codec) \
 864        ((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE)
 865
 866static int alc_init(struct hda_codec *codec)
 867{
 868        struct alc_spec *spec = codec->spec;
 869
 870        /* hibernation resume needs the full chip initialization */
 871        if (is_s4_resume(codec))
 872                alc_pre_init(codec);
 873
 874        if (spec->init_hook)
 875                spec->init_hook(codec);
 876
 877        spec->gen.skip_verbs = 1; /* applied in below */
 878        snd_hda_gen_init(codec);
 879        alc_fix_pll(codec);
 880        alc_auto_init_amp(codec, spec->init_amp);
 881        snd_hda_apply_verbs(codec); /* apply verbs here after own init */
 882
 883        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
 884
 885        return 0;
 886}
 887
 888static inline void alc_shutup(struct hda_codec *codec)
 889{
 890        struct alc_spec *spec = codec->spec;
 891
 892        if (!snd_hda_get_bool_hint(codec, "shutup"))
 893                return; /* disabled explicitly by hints */
 894
 895        if (spec && spec->shutup)
 896                spec->shutup(codec);
 897        else
 898                alc_shutup_pins(codec);
 899}
 900
 901#define alc_free        snd_hda_gen_free
 902
 903#ifdef CONFIG_PM
 904static void alc_power_eapd(struct hda_codec *codec)
 905{
 906        alc_auto_setup_eapd(codec, false);
 907}
 908
 909static int alc_suspend(struct hda_codec *codec)
 910{
 911        struct alc_spec *spec = codec->spec;
 912        alc_shutup(codec);
 913        if (spec && spec->power_hook)
 914                spec->power_hook(codec);
 915        return 0;
 916}
 917#endif
 918
 919#ifdef CONFIG_PM
 920static int alc_resume(struct hda_codec *codec)
 921{
 922        struct alc_spec *spec = codec->spec;
 923
 924        if (!spec->no_depop_delay)
 925                msleep(150); /* to avoid pop noise */
 926        codec->patch_ops.init(codec);
 927        snd_hda_regmap_sync(codec);
 928        hda_call_check_power_status(codec, 0x01);
 929        return 0;
 930}
 931#endif
 932
 933/*
 934 */
 935static const struct hda_codec_ops alc_patch_ops = {
 936        .build_controls = alc_build_controls,
 937        .build_pcms = snd_hda_gen_build_pcms,
 938        .init = alc_init,
 939        .free = alc_free,
 940        .unsol_event = snd_hda_jack_unsol_event,
 941#ifdef CONFIG_PM
 942        .resume = alc_resume,
 943        .suspend = alc_suspend,
 944        .check_power_status = snd_hda_gen_check_power_status,
 945#endif
 946};
 947
 948
 949#define alc_codec_rename(codec, name) snd_hda_codec_set_name(codec, name)
 950
 951/*
 952 * Rename codecs appropriately from COEF value or subvendor id
 953 */
 954struct alc_codec_rename_table {
 955        unsigned int vendor_id;
 956        unsigned short coef_mask;
 957        unsigned short coef_bits;
 958        const char *name;
 959};
 960
 961struct alc_codec_rename_pci_table {
 962        unsigned int codec_vendor_id;
 963        unsigned short pci_subvendor;
 964        unsigned short pci_subdevice;
 965        const char *name;
 966};
 967
 968static const struct alc_codec_rename_table rename_tbl[] = {
 969        { 0x10ec0221, 0xf00f, 0x1003, "ALC231" },
 970        { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
 971        { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
 972        { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
 973        { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
 974        { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
 975        { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
 976        { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
 977        { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
 978        { 0x10ec0662, 0xffff, 0x4020, "ALC656" },
 979        { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
 980        { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
 981        { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
 982        { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
 983        { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
 984        { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
 985        { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
 986        { } /* terminator */
 987};
 988
 989static const struct alc_codec_rename_pci_table rename_pci_tbl[] = {
 990        { 0x10ec0280, 0x1028, 0, "ALC3220" },
 991        { 0x10ec0282, 0x1028, 0, "ALC3221" },
 992        { 0x10ec0283, 0x1028, 0, "ALC3223" },
 993        { 0x10ec0288, 0x1028, 0, "ALC3263" },
 994        { 0x10ec0292, 0x1028, 0, "ALC3226" },
 995        { 0x10ec0293, 0x1028, 0, "ALC3235" },
 996        { 0x10ec0255, 0x1028, 0, "ALC3234" },
 997        { 0x10ec0668, 0x1028, 0, "ALC3661" },
 998        { 0x10ec0275, 0x1028, 0, "ALC3260" },
 999        { 0x10ec0899, 0x1028, 0, "ALC3861" },
1000        { 0x10ec0298, 0x1028, 0, "ALC3266" },
1001        { 0x10ec0236, 0x1028, 0, "ALC3204" },
1002        { 0x10ec0256, 0x1028, 0, "ALC3246" },
1003        { 0x10ec0225, 0x1028, 0, "ALC3253" },
1004        { 0x10ec0295, 0x1028, 0, "ALC3254" },
1005        { 0x10ec0299, 0x1028, 0, "ALC3271" },
1006        { 0x10ec0670, 0x1025, 0, "ALC669X" },
1007        { 0x10ec0676, 0x1025, 0, "ALC679X" },
1008        { 0x10ec0282, 0x1043, 0, "ALC3229" },
1009        { 0x10ec0233, 0x1043, 0, "ALC3236" },
1010        { 0x10ec0280, 0x103c, 0, "ALC3228" },
1011        { 0x10ec0282, 0x103c, 0, "ALC3227" },
1012        { 0x10ec0286, 0x103c, 0, "ALC3242" },
1013        { 0x10ec0290, 0x103c, 0, "ALC3241" },
1014        { 0x10ec0668, 0x103c, 0, "ALC3662" },
1015        { 0x10ec0283, 0x17aa, 0, "ALC3239" },
1016        { 0x10ec0292, 0x17aa, 0, "ALC3232" },
1017        { } /* terminator */
1018};
1019
1020static int alc_codec_rename_from_preset(struct hda_codec *codec)
1021{
1022        const struct alc_codec_rename_table *p;
1023        const struct alc_codec_rename_pci_table *q;
1024
1025        for (p = rename_tbl; p->vendor_id; p++) {
1026                if (p->vendor_id != codec->core.vendor_id)
1027                        continue;
1028                if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
1029                        return alc_codec_rename(codec, p->name);
1030        }
1031
1032        if (!codec->bus->pci)
1033                return 0;
1034        for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
1035                if (q->codec_vendor_id != codec->core.vendor_id)
1036                        continue;
1037                if (q->pci_subvendor != codec->bus->pci->subsystem_vendor)
1038                        continue;
1039                if (!q->pci_subdevice ||
1040                    q->pci_subdevice == codec->bus->pci->subsystem_device)
1041                        return alc_codec_rename(codec, q->name);
1042        }
1043
1044        return 0;
1045}
1046
1047
1048/*
1049 * Digital-beep handlers
1050 */
1051#ifdef CONFIG_SND_HDA_INPUT_BEEP
1052
1053/* additional beep mixers; private_value will be overwritten */
1054static const struct snd_kcontrol_new alc_beep_mixer[] = {
1055        HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
1056        HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
1057};
1058
1059/* set up and create beep controls */
1060static int set_beep_amp(struct alc_spec *spec, hda_nid_t nid,
1061                        int idx, int dir)
1062{
1063        struct snd_kcontrol_new *knew;
1064        unsigned int beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir);
1065        int i;
1066
1067        for (i = 0; i < ARRAY_SIZE(alc_beep_mixer); i++) {
1068                knew = snd_hda_gen_add_kctl(&spec->gen, NULL,
1069                                            &alc_beep_mixer[i]);
1070                if (!knew)
1071                        return -ENOMEM;
1072                knew->private_value = beep_amp;
1073        }
1074        return 0;
1075}
1076
1077static const struct snd_pci_quirk beep_allow_list[] = {
1078        SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
1079        SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
1080        SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
1081        SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
1082        SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
1083        SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
1084        SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
1085        SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
1086        SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
1087        /* denylist -- no beep available */
1088        SND_PCI_QUIRK(0x17aa, 0x309e, "Lenovo ThinkCentre M73", 0),
1089        SND_PCI_QUIRK(0x17aa, 0x30a3, "Lenovo ThinkCentre M93", 0),
1090        {}
1091};
1092
1093static inline int has_cdefine_beep(struct hda_codec *codec)
1094{
1095        struct alc_spec *spec = codec->spec;
1096        const struct snd_pci_quirk *q;
1097        q = snd_pci_quirk_lookup(codec->bus->pci, beep_allow_list);
1098        if (q)
1099                return q->value;
1100        return spec->cdefine.enable_pcbeep;
1101}
1102#else
1103#define set_beep_amp(spec, nid, idx, dir)       0
1104#define has_cdefine_beep(codec)         0
1105#endif
1106
1107/* parse the BIOS configuration and set up the alc_spec */
1108/* return 1 if successful, 0 if the proper config is not found,
1109 * or a negative error code
1110 */
1111static int alc_parse_auto_config(struct hda_codec *codec,
1112                                 const hda_nid_t *ignore_nids,
1113                                 const hda_nid_t *ssid_nids)
1114{
1115        struct alc_spec *spec = codec->spec;
1116        struct auto_pin_cfg *cfg = &spec->gen.autocfg;
1117        int err;
1118
1119        err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
1120                                       spec->parse_flags);
1121        if (err < 0)
1122                return err;
1123
1124        if (ssid_nids)
1125                alc_ssid_check(codec, ssid_nids);
1126
1127        err = snd_hda_gen_parse_auto_config(codec, cfg);
1128        if (err < 0)
1129                return err;
1130
1131        return 1;
1132}
1133
1134/* common preparation job for alc_spec */
1135static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
1136{
1137        struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1138        int err;
1139
1140        if (!spec)
1141                return -ENOMEM;
1142        codec->spec = spec;
1143        snd_hda_gen_spec_init(&spec->gen);
1144        spec->gen.mixer_nid = mixer_nid;
1145        spec->gen.own_eapd_ctl = 1;
1146        codec->single_adc_amp = 1;
1147        /* FIXME: do we need this for all Realtek codec models? */
1148        codec->spdif_status_reset = 1;
1149        codec->forced_resume = 1;
1150        codec->patch_ops = alc_patch_ops;
1151
1152        err = alc_codec_rename_from_preset(codec);
1153        if (err < 0) {
1154                kfree(spec);
1155                return err;
1156        }
1157        return 0;
1158}
1159
1160static int alc880_parse_auto_config(struct hda_codec *codec)
1161{
1162        static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
1163        static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
1164        return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
1165}
1166
1167/*
1168 * ALC880 fix-ups
1169 */
1170enum {
1171        ALC880_FIXUP_GPIO1,
1172        ALC880_FIXUP_GPIO2,
1173        ALC880_FIXUP_MEDION_RIM,
1174        ALC880_FIXUP_LG,
1175        ALC880_FIXUP_LG_LW25,
1176        ALC880_FIXUP_W810,
1177        ALC880_FIXUP_EAPD_COEF,
1178        ALC880_FIXUP_TCL_S700,
1179        ALC880_FIXUP_VOL_KNOB,
1180        ALC880_FIXUP_FUJITSU,
1181        ALC880_FIXUP_F1734,
1182        ALC880_FIXUP_UNIWILL,
1183        ALC880_FIXUP_UNIWILL_DIG,
1184        ALC880_FIXUP_Z71V,
1185        ALC880_FIXUP_ASUS_W5A,
1186        ALC880_FIXUP_3ST_BASE,
1187        ALC880_FIXUP_3ST,
1188        ALC880_FIXUP_3ST_DIG,
1189        ALC880_FIXUP_5ST_BASE,
1190        ALC880_FIXUP_5ST,
1191        ALC880_FIXUP_5ST_DIG,
1192        ALC880_FIXUP_6ST_BASE,
1193        ALC880_FIXUP_6ST,
1194        ALC880_FIXUP_6ST_DIG,
1195        ALC880_FIXUP_6ST_AUTOMUTE,
1196};
1197
1198/* enable the volume-knob widget support on NID 0x21 */
1199static void alc880_fixup_vol_knob(struct hda_codec *codec,
1200                                  const struct hda_fixup *fix, int action)
1201{
1202        if (action == HDA_FIXUP_ACT_PROBE)
1203                snd_hda_jack_detect_enable_callback(codec, 0x21,
1204                                                    alc_update_knob_master);
1205}
1206
1207static const struct hda_fixup alc880_fixups[] = {
1208        [ALC880_FIXUP_GPIO1] = {
1209                .type = HDA_FIXUP_FUNC,
1210                .v.func = alc_fixup_gpio1,
1211        },
1212        [ALC880_FIXUP_GPIO2] = {
1213                .type = HDA_FIXUP_FUNC,
1214                .v.func = alc_fixup_gpio2,
1215        },
1216        [ALC880_FIXUP_MEDION_RIM] = {
1217                .type = HDA_FIXUP_VERBS,
1218                .v.verbs = (const struct hda_verb[]) {
1219                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1220                        { 0x20, AC_VERB_SET_PROC_COEF,  0x3060 },
1221                        { }
1222                },
1223                .chained = true,
1224                .chain_id = ALC880_FIXUP_GPIO2,
1225        },
1226        [ALC880_FIXUP_LG] = {
1227                .type = HDA_FIXUP_PINS,
1228                .v.pins = (const struct hda_pintbl[]) {
1229                        /* disable bogus unused pins */
1230                        { 0x16, 0x411111f0 },
1231                        { 0x18, 0x411111f0 },
1232                        { 0x1a, 0x411111f0 },
1233                        { }
1234                }
1235        },
1236        [ALC880_FIXUP_LG_LW25] = {
1237                .type = HDA_FIXUP_PINS,
1238                .v.pins = (const struct hda_pintbl[]) {
1239                        { 0x1a, 0x0181344f }, /* line-in */
1240                        { 0x1b, 0x0321403f }, /* headphone */
1241                        { }
1242                }
1243        },
1244        [ALC880_FIXUP_W810] = {
1245                .type = HDA_FIXUP_PINS,
1246                .v.pins = (const struct hda_pintbl[]) {
1247                        /* disable bogus unused pins */
1248                        { 0x17, 0x411111f0 },
1249                        { }
1250                },
1251                .chained = true,
1252                .chain_id = ALC880_FIXUP_GPIO2,
1253        },
1254        [ALC880_FIXUP_EAPD_COEF] = {
1255                .type = HDA_FIXUP_VERBS,
1256                .v.verbs = (const struct hda_verb[]) {
1257                        /* change to EAPD mode */
1258                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1259                        { 0x20, AC_VERB_SET_PROC_COEF,  0x3060 },
1260                        {}
1261                },
1262        },
1263        [ALC880_FIXUP_TCL_S700] = {
1264                .type = HDA_FIXUP_VERBS,
1265                .v.verbs = (const struct hda_verb[]) {
1266                        /* change to EAPD mode */
1267                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
1268                        { 0x20, AC_VERB_SET_PROC_COEF,  0x3070 },
1269                        {}
1270                },
1271                .chained = true,
1272                .chain_id = ALC880_FIXUP_GPIO2,
1273        },
1274        [ALC880_FIXUP_VOL_KNOB] = {
1275                .type = HDA_FIXUP_FUNC,
1276                .v.func = alc880_fixup_vol_knob,
1277        },
1278        [ALC880_FIXUP_FUJITSU] = {
1279                /* override all pins as BIOS on old Amilo is broken */
1280                .type = HDA_FIXUP_PINS,
1281                .v.pins = (const struct hda_pintbl[]) {
1282                        { 0x14, 0x0121401f }, /* HP */
1283                        { 0x15, 0x99030120 }, /* speaker */
1284                        { 0x16, 0x99030130 }, /* bass speaker */
1285                        { 0x17, 0x411111f0 }, /* N/A */
1286                        { 0x18, 0x411111f0 }, /* N/A */
1287                        { 0x19, 0x01a19950 }, /* mic-in */
1288                        { 0x1a, 0x411111f0 }, /* N/A */
1289                        { 0x1b, 0x411111f0 }, /* N/A */
1290                        { 0x1c, 0x411111f0 }, /* N/A */
1291                        { 0x1d, 0x411111f0 }, /* N/A */
1292                        { 0x1e, 0x01454140 }, /* SPDIF out */
1293                        { }
1294                },
1295                .chained = true,
1296                .chain_id = ALC880_FIXUP_VOL_KNOB,
1297        },
1298        [ALC880_FIXUP_F1734] = {
1299                /* almost compatible with FUJITSU, but no bass and SPDIF */
1300                .type = HDA_FIXUP_PINS,
1301                .v.pins = (const struct hda_pintbl[]) {
1302                        { 0x14, 0x0121401f }, /* HP */
1303                        { 0x15, 0x99030120 }, /* speaker */
1304                        { 0x16, 0x411111f0 }, /* N/A */
1305                        { 0x17, 0x411111f0 }, /* N/A */
1306                        { 0x18, 0x411111f0 }, /* N/A */
1307                        { 0x19, 0x01a19950 }, /* mic-in */
1308                        { 0x1a, 0x411111f0 }, /* N/A */
1309                        { 0x1b, 0x411111f0 }, /* N/A */
1310                        { 0x1c, 0x411111f0 }, /* N/A */
1311                        { 0x1d, 0x411111f0 }, /* N/A */
1312                        { 0x1e, 0x411111f0 }, /* N/A */
1313                        { }
1314                },
1315                .chained = true,
1316                .chain_id = ALC880_FIXUP_VOL_KNOB,
1317        },
1318        [ALC880_FIXUP_UNIWILL] = {
1319                /* need to fix HP and speaker pins to be parsed correctly */
1320                .type = HDA_FIXUP_PINS,
1321                .v.pins = (const struct hda_pintbl[]) {
1322                        { 0x14, 0x0121411f }, /* HP */
1323                        { 0x15, 0x99030120 }, /* speaker */
1324                        { 0x16, 0x99030130 }, /* bass speaker */
1325                        { }
1326                },
1327        },
1328        [ALC880_FIXUP_UNIWILL_DIG] = {
1329                .type = HDA_FIXUP_PINS,
1330                .v.pins = (const struct hda_pintbl[]) {
1331                        /* disable bogus unused pins */
1332                        { 0x17, 0x411111f0 },
1333                        { 0x19, 0x411111f0 },
1334                        { 0x1b, 0x411111f0 },
1335                        { 0x1f, 0x411111f0 },
1336                        { }
1337                }
1338        },
1339        [ALC880_FIXUP_Z71V] = {
1340                .type = HDA_FIXUP_PINS,
1341                .v.pins = (const struct hda_pintbl[]) {
1342                        /* set up the whole pins as BIOS is utterly broken */
1343                        { 0x14, 0x99030120 }, /* speaker */
1344                        { 0x15, 0x0121411f }, /* HP */
1345                        { 0x16, 0x411111f0 }, /* N/A */
1346                        { 0x17, 0x411111f0 }, /* N/A */
1347                        { 0x18, 0x01a19950 }, /* mic-in */
1348                        { 0x19, 0x411111f0 }, /* N/A */
1349                        { 0x1a, 0x01813031 }, /* line-in */
1350                        { 0x1b, 0x411111f0 }, /* N/A */
1351                        { 0x1c, 0x411111f0 }, /* N/A */
1352                        { 0x1d, 0x411111f0 }, /* N/A */
1353                        { 0x1e, 0x0144111e }, /* SPDIF */
1354                        { }
1355                }
1356        },
1357        [ALC880_FIXUP_ASUS_W5A] = {
1358                .type = HDA_FIXUP_PINS,
1359                .v.pins = (const struct hda_pintbl[]) {
1360                        /* set up the whole pins as BIOS is utterly broken */
1361                        { 0x14, 0x0121411f }, /* HP */
1362                        { 0x15, 0x411111f0 }, /* N/A */
1363                        { 0x16, 0x411111f0 }, /* N/A */
1364                        { 0x17, 0x411111f0 }, /* N/A */
1365                        { 0x18, 0x90a60160 }, /* mic */
1366                        { 0x19, 0x411111f0 }, /* N/A */
1367                        { 0x1a, 0x411111f0 }, /* N/A */
1368                        { 0x1b, 0x411111f0 }, /* N/A */
1369                        { 0x1c, 0x411111f0 }, /* N/A */
1370                        { 0x1d, 0x411111f0 }, /* N/A */
1371                        { 0x1e, 0xb743111e }, /* SPDIF out */
1372                        { }
1373                },
1374                .chained = true,
1375                .chain_id = ALC880_FIXUP_GPIO1,
1376        },
1377        [ALC880_FIXUP_3ST_BASE] = {
1378                .type = HDA_FIXUP_PINS,
1379                .v.pins = (const struct hda_pintbl[]) {
1380                        { 0x14, 0x01014010 }, /* line-out */
1381                        { 0x15, 0x411111f0 }, /* N/A */
1382                        { 0x16, 0x411111f0 }, /* N/A */
1383                        { 0x17, 0x411111f0 }, /* N/A */
1384                        { 0x18, 0x01a19c30 }, /* mic-in */
1385                        { 0x19, 0x0121411f }, /* HP */
1386                        { 0x1a, 0x01813031 }, /* line-in */
1387                        { 0x1b, 0x02a19c40 }, /* front-mic */
1388                        { 0x1c, 0x411111f0 }, /* N/A */
1389                        { 0x1d, 0x411111f0 }, /* N/A */
1390                        /* 0x1e is filled in below */
1391                        { 0x1f, 0x411111f0 }, /* N/A */
1392                        { }
1393                }
1394        },
1395        [ALC880_FIXUP_3ST] = {
1396                .type = HDA_FIXUP_PINS,
1397                .v.pins = (const struct hda_pintbl[]) {
1398                        { 0x1e, 0x411111f0 }, /* N/A */
1399                        { }
1400                },
1401                .chained = true,
1402                .chain_id = ALC880_FIXUP_3ST_BASE,
1403        },
1404        [ALC880_FIXUP_3ST_DIG] = {
1405                .type = HDA_FIXUP_PINS,
1406                .v.pins = (const struct hda_pintbl[]) {
1407                        { 0x1e, 0x0144111e }, /* SPDIF */
1408                        { }
1409                },
1410                .chained = true,
1411                .chain_id = ALC880_FIXUP_3ST_BASE,
1412        },
1413        [ALC880_FIXUP_5ST_BASE] = {
1414                .type = HDA_FIXUP_PINS,
1415                .v.pins = (const struct hda_pintbl[]) {
1416                        { 0x14, 0x01014010 }, /* front */
1417                        { 0x15, 0x411111f0 }, /* N/A */
1418                        { 0x16, 0x01011411 }, /* CLFE */
1419                        { 0x17, 0x01016412 }, /* surr */
1420                        { 0x18, 0x01a19c30 }, /* mic-in */
1421                        { 0x19, 0x0121411f }, /* HP */
1422                        { 0x1a, 0x01813031 }, /* line-in */
1423                        { 0x1b, 0x02a19c40 }, /* front-mic */
1424                        { 0x1c, 0x411111f0 }, /* N/A */
1425                        { 0x1d, 0x411111f0 }, /* N/A */
1426                        /* 0x1e is filled in below */
1427                        { 0x1f, 0x411111f0 }, /* N/A */
1428                        { }
1429                }
1430        },
1431        [ALC880_FIXUP_5ST] = {
1432                .type = HDA_FIXUP_PINS,
1433                .v.pins = (const struct hda_pintbl[]) {
1434                        { 0x1e, 0x411111f0 }, /* N/A */
1435                        { }
1436                },
1437                .chained = true,
1438                .chain_id = ALC880_FIXUP_5ST_BASE,
1439        },
1440        [ALC880_FIXUP_5ST_DIG] = {
1441                .type = HDA_FIXUP_PINS,
1442                .v.pins = (const struct hda_pintbl[]) {
1443                        { 0x1e, 0x0144111e }, /* SPDIF */
1444                        { }
1445                },
1446                .chained = true,
1447                .chain_id = ALC880_FIXUP_5ST_BASE,
1448        },
1449        [ALC880_FIXUP_6ST_BASE] = {
1450                .type = HDA_FIXUP_PINS,
1451                .v.pins = (const struct hda_pintbl[]) {
1452                        { 0x14, 0x01014010 }, /* front */
1453                        { 0x15, 0x01016412 }, /* surr */
1454                        { 0x16, 0x01011411 }, /* CLFE */
1455                        { 0x17, 0x01012414 }, /* side */
1456                        { 0x18, 0x01a19c30 }, /* mic-in */
1457                        { 0x19, 0x02a19c40 }, /* front-mic */
1458                        { 0x1a, 0x01813031 }, /* line-in */
1459                        { 0x1b, 0x0121411f }, /* HP */
1460                        { 0x1c, 0x411111f0 }, /* N/A */
1461                        { 0x1d, 0x411111f0 }, /* N/A */
1462                        /* 0x1e is filled in below */
1463                        { 0x1f, 0x411111f0 }, /* N/A */
1464                        { }
1465                }
1466        },
1467        [ALC880_FIXUP_6ST] = {
1468                .type = HDA_FIXUP_PINS,
1469                .v.pins = (const struct hda_pintbl[]) {
1470                        { 0x1e, 0x411111f0 }, /* N/A */
1471                        { }
1472                },
1473                .chained = true,
1474                .chain_id = ALC880_FIXUP_6ST_BASE,
1475        },
1476        [ALC880_FIXUP_6ST_DIG] = {
1477                .type = HDA_FIXUP_PINS,
1478                .v.pins = (const struct hda_pintbl[]) {
1479                        { 0x1e, 0x0144111e }, /* SPDIF */
1480                        { }
1481                },
1482                .chained = true,
1483                .chain_id = ALC880_FIXUP_6ST_BASE,
1484        },
1485        [ALC880_FIXUP_6ST_AUTOMUTE] = {
1486                .type = HDA_FIXUP_PINS,
1487                .v.pins = (const struct hda_pintbl[]) {
1488                        { 0x1b, 0x0121401f }, /* HP with jack detect */
1489                        { }
1490                },
1491                .chained_before = true,
1492                .chain_id = ALC880_FIXUP_6ST_BASE,
1493        },
1494};
1495
1496static const struct snd_pci_quirk alc880_fixup_tbl[] = {
1497        SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
1498        SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
1499        SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
1500        SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
1501        SND_PCI_QUIRK(0x147b, 0x1045, "ABit AA8XE", ALC880_FIXUP_6ST_AUTOMUTE),
1502        SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
1503        SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
1504        SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
1505        SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
1506        SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
1507        SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
1508        SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
1509        SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
1510        SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
1511        SND_PCI_QUIRK(0x1734, 0x107c, "FSC Amilo M1437", ALC880_FIXUP_FUJITSU),
1512        SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
1513        SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
1514        SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
1515        SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1516        SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1517        SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
1518        SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
1519        SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
1520
1521        /* Below is the copied entries from alc880_quirks.c.
1522         * It's not quite sure whether BIOS sets the correct pin-config table
1523         * on these machines, thus they are kept to be compatible with
1524         * the old static quirks.  Once when it's confirmed to work without
1525         * these overrides, it'd be better to remove.
1526         */
1527        SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
1528        SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
1529        SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
1530        SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
1531        SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
1532        SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
1533        SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
1534        SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
1535        SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
1536        SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
1537        SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
1538        SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
1539        SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
1540        SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
1541        SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
1542        SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
1543        SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
1544        SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
1545        SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
1546        SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
1547        SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
1548        SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
1549        SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
1550        SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1551        SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1552        SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1553        SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1554        SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1555        SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1556        SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
1557        SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1558        SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1559        SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
1560        /* default Intel */
1561        SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
1562        SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
1563        SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
1564        {}
1565};
1566
1567static const struct hda_model_fixup alc880_fixup_models[] = {
1568        {.id = ALC880_FIXUP_3ST, .name = "3stack"},
1569        {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
1570        {.id = ALC880_FIXUP_5ST, .name = "5stack"},
1571        {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
1572        {.id = ALC880_FIXUP_6ST, .name = "6stack"},
1573        {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
1574        {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
1575        {}
1576};
1577
1578
1579/*
1580 * OK, here we have finally the patch for ALC880
1581 */
1582static int patch_alc880(struct hda_codec *codec)
1583{
1584        struct alc_spec *spec;
1585        int err;
1586
1587        err = alc_alloc_spec(codec, 0x0b);
1588        if (err < 0)
1589                return err;
1590
1591        spec = codec->spec;
1592        spec->gen.need_dac_fix = 1;
1593        spec->gen.beep_nid = 0x01;
1594
1595        codec->patch_ops.unsol_event = alc880_unsol_event;
1596
1597        alc_pre_init(codec);
1598
1599        snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
1600                       alc880_fixups);
1601        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1602
1603        /* automatic parse from the BIOS config */
1604        err = alc880_parse_auto_config(codec);
1605        if (err < 0)
1606                goto error;
1607
1608        if (!spec->gen.no_analog) {
1609                err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
1610                if (err < 0)
1611                        goto error;
1612        }
1613
1614        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1615
1616        return 0;
1617
1618 error:
1619        alc_free(codec);
1620        return err;
1621}
1622
1623
1624/*
1625 * ALC260 support
1626 */
1627static int alc260_parse_auto_config(struct hda_codec *codec)
1628{
1629        static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
1630        static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
1631        return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
1632}
1633
1634/*
1635 * Pin config fixes
1636 */
1637enum {
1638        ALC260_FIXUP_HP_DC5750,
1639        ALC260_FIXUP_HP_PIN_0F,
1640        ALC260_FIXUP_COEF,
1641        ALC260_FIXUP_GPIO1,
1642        ALC260_FIXUP_GPIO1_TOGGLE,
1643        ALC260_FIXUP_REPLACER,
1644        ALC260_FIXUP_HP_B1900,
1645        ALC260_FIXUP_KN1,
1646        ALC260_FIXUP_FSC_S7020,
1647        ALC260_FIXUP_FSC_S7020_JWSE,
1648        ALC260_FIXUP_VAIO_PINS,
1649};
1650
1651static void alc260_gpio1_automute(struct hda_codec *codec)
1652{
1653        struct alc_spec *spec = codec->spec;
1654
1655        alc_update_gpio_data(codec, 0x01, spec->gen.hp_jack_present);
1656}
1657
1658static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
1659                                      const struct hda_fixup *fix, int action)
1660{
1661        struct alc_spec *spec = codec->spec;
1662        if (action == HDA_FIXUP_ACT_PROBE) {
1663                /* although the machine has only one output pin, we need to
1664                 * toggle GPIO1 according to the jack state
1665                 */
1666                spec->gen.automute_hook = alc260_gpio1_automute;
1667                spec->gen.detect_hp = 1;
1668                spec->gen.automute_speaker = 1;
1669                spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
1670                snd_hda_jack_detect_enable_callback(codec, 0x0f,
1671                                                    snd_hda_gen_hp_automute);
1672                alc_setup_gpio(codec, 0x01);
1673        }
1674}
1675
1676static void alc260_fixup_kn1(struct hda_codec *codec,
1677                             const struct hda_fixup *fix, int action)
1678{
1679        struct alc_spec *spec = codec->spec;
1680        static const struct hda_pintbl pincfgs[] = {
1681                { 0x0f, 0x02214000 }, /* HP/speaker */
1682                { 0x12, 0x90a60160 }, /* int mic */
1683                { 0x13, 0x02a19000 }, /* ext mic */
1684                { 0x18, 0x01446000 }, /* SPDIF out */
1685                /* disable bogus I/O pins */
1686                { 0x10, 0x411111f0 },
1687                { 0x11, 0x411111f0 },
1688                { 0x14, 0x411111f0 },
1689                { 0x15, 0x411111f0 },
1690                { 0x16, 0x411111f0 },
1691                { 0x17, 0x411111f0 },
1692                { 0x19, 0x411111f0 },
1693                { }
1694        };
1695
1696        switch (action) {
1697        case HDA_FIXUP_ACT_PRE_PROBE:
1698                snd_hda_apply_pincfgs(codec, pincfgs);
1699                spec->init_amp = ALC_INIT_NONE;
1700                break;
1701        }
1702}
1703
1704static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
1705                                   const struct hda_fixup *fix, int action)
1706{
1707        struct alc_spec *spec = codec->spec;
1708        if (action == HDA_FIXUP_ACT_PRE_PROBE)
1709                spec->init_amp = ALC_INIT_NONE;
1710}
1711
1712static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
1713                                   const struct hda_fixup *fix, int action)
1714{
1715        struct alc_spec *spec = codec->spec;
1716        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1717                spec->gen.add_jack_modes = 1;
1718                spec->gen.hp_mic = 1;
1719        }
1720}
1721
1722static const struct hda_fixup alc260_fixups[] = {
1723        [ALC260_FIXUP_HP_DC5750] = {
1724                .type = HDA_FIXUP_PINS,
1725                .v.pins = (const struct hda_pintbl[]) {
1726                        { 0x11, 0x90130110 }, /* speaker */
1727                        { }
1728                }
1729        },
1730        [ALC260_FIXUP_HP_PIN_0F] = {
1731                .type = HDA_FIXUP_PINS,
1732                .v.pins = (const struct hda_pintbl[]) {
1733                        { 0x0f, 0x01214000 }, /* HP */
1734                        { }
1735                }
1736        },
1737        [ALC260_FIXUP_COEF] = {
1738                .type = HDA_FIXUP_VERBS,
1739                .v.verbs = (const struct hda_verb[]) {
1740                        { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1741                        { 0x1a, AC_VERB_SET_PROC_COEF,  0x3040 },
1742                        { }
1743                },
1744        },
1745        [ALC260_FIXUP_GPIO1] = {
1746                .type = HDA_FIXUP_FUNC,
1747                .v.func = alc_fixup_gpio1,
1748        },
1749        [ALC260_FIXUP_GPIO1_TOGGLE] = {
1750                .type = HDA_FIXUP_FUNC,
1751                .v.func = alc260_fixup_gpio1_toggle,
1752                .chained = true,
1753                .chain_id = ALC260_FIXUP_HP_PIN_0F,
1754        },
1755        [ALC260_FIXUP_REPLACER] = {
1756                .type = HDA_FIXUP_VERBS,
1757                .v.verbs = (const struct hda_verb[]) {
1758                        { 0x1a, AC_VERB_SET_COEF_INDEX, 0x07 },
1759                        { 0x1a, AC_VERB_SET_PROC_COEF,  0x3050 },
1760                        { }
1761                },
1762                .chained = true,
1763                .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
1764        },
1765        [ALC260_FIXUP_HP_B1900] = {
1766                .type = HDA_FIXUP_FUNC,
1767                .v.func = alc260_fixup_gpio1_toggle,
1768                .chained = true,
1769                .chain_id = ALC260_FIXUP_COEF,
1770        },
1771        [ALC260_FIXUP_KN1] = {
1772                .type = HDA_FIXUP_FUNC,
1773                .v.func = alc260_fixup_kn1,
1774        },
1775        [ALC260_FIXUP_FSC_S7020] = {
1776                .type = HDA_FIXUP_FUNC,
1777                .v.func = alc260_fixup_fsc_s7020,
1778        },
1779        [ALC260_FIXUP_FSC_S7020_JWSE] = {
1780                .type = HDA_FIXUP_FUNC,
1781                .v.func = alc260_fixup_fsc_s7020_jwse,
1782                .chained = true,
1783                .chain_id = ALC260_FIXUP_FSC_S7020,
1784        },
1785        [ALC260_FIXUP_VAIO_PINS] = {
1786                .type = HDA_FIXUP_PINS,
1787                .v.pins = (const struct hda_pintbl[]) {
1788                        /* Pin configs are missing completely on some VAIOs */
1789                        { 0x0f, 0x01211020 },
1790                        { 0x10, 0x0001003f },
1791                        { 0x11, 0x411111f0 },
1792                        { 0x12, 0x01a15930 },
1793                        { 0x13, 0x411111f0 },
1794                        { 0x14, 0x411111f0 },
1795                        { 0x15, 0x411111f0 },
1796                        { 0x16, 0x411111f0 },
1797                        { 0x17, 0x411111f0 },
1798                        { 0x18, 0x411111f0 },
1799                        { 0x19, 0x411111f0 },
1800                        { }
1801                }
1802        },
1803};
1804
1805static const struct snd_pci_quirk alc260_fixup_tbl[] = {
1806        SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
1807        SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
1808        SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
1809        SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
1810        SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
1811        SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
1812        SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
1813        SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
1814        SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
1815        SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
1816        SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
1817        SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
1818        {}
1819};
1820
1821static const struct hda_model_fixup alc260_fixup_models[] = {
1822        {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
1823        {.id = ALC260_FIXUP_COEF, .name = "coef"},
1824        {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
1825        {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
1826        {}
1827};
1828
1829/*
1830 */
1831static int patch_alc260(struct hda_codec *codec)
1832{
1833        struct alc_spec *spec;
1834        int err;
1835
1836        err = alc_alloc_spec(codec, 0x07);
1837        if (err < 0)
1838                return err;
1839
1840        spec = codec->spec;
1841        /* as quite a few machines require HP amp for speaker outputs,
1842         * it's easier to enable it unconditionally; even if it's unneeded,
1843         * it's almost harmless.
1844         */
1845        spec->gen.prefer_hp_amp = 1;
1846        spec->gen.beep_nid = 0x01;
1847
1848        spec->shutup = alc_eapd_shutup;
1849
1850        alc_pre_init(codec);
1851
1852        snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
1853                           alc260_fixups);
1854        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1855
1856        /* automatic parse from the BIOS config */
1857        err = alc260_parse_auto_config(codec);
1858        if (err < 0)
1859                goto error;
1860
1861        if (!spec->gen.no_analog) {
1862                err = set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
1863                if (err < 0)
1864                        goto error;
1865        }
1866
1867        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1868
1869        return 0;
1870
1871 error:
1872        alc_free(codec);
1873        return err;
1874}
1875
1876
1877/*
1878 * ALC882/883/885/888/889 support
1879 *
1880 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
1881 * configuration.  Each pin widget can choose any input DACs and a mixer.
1882 * Each ADC is connected from a mixer of all inputs.  This makes possible
1883 * 6-channel independent captures.
1884 *
1885 * In addition, an independent DAC for the multi-playback (not used in this
1886 * driver yet).
1887 */
1888
1889/*
1890 * Pin config fixes
1891 */
1892enum {
1893        ALC882_FIXUP_ABIT_AW9D_MAX,
1894        ALC882_FIXUP_LENOVO_Y530,
1895        ALC882_FIXUP_PB_M5210,
1896        ALC882_FIXUP_ACER_ASPIRE_7736,
1897        ALC882_FIXUP_ASUS_W90V,
1898        ALC889_FIXUP_CD,
1899        ALC889_FIXUP_FRONT_HP_NO_PRESENCE,
1900        ALC889_FIXUP_VAIO_TT,
1901        ALC888_FIXUP_EEE1601,
1902        ALC886_FIXUP_EAPD,
1903        ALC882_FIXUP_EAPD,
1904        ALC883_FIXUP_EAPD,
1905        ALC883_FIXUP_ACER_EAPD,
1906        ALC882_FIXUP_GPIO1,
1907        ALC882_FIXUP_GPIO2,
1908        ALC882_FIXUP_GPIO3,
1909        ALC889_FIXUP_COEF,
1910        ALC882_FIXUP_ASUS_W2JC,
1911        ALC882_FIXUP_ACER_ASPIRE_4930G,
1912        ALC882_FIXUP_ACER_ASPIRE_8930G,
1913        ALC882_FIXUP_ASPIRE_8930G_VERBS,
1914        ALC885_FIXUP_MACPRO_GPIO,
1915        ALC889_FIXUP_DAC_ROUTE,
1916        ALC889_FIXUP_MBP_VREF,
1917        ALC889_FIXUP_IMAC91_VREF,
1918        ALC889_FIXUP_MBA11_VREF,
1919        ALC889_FIXUP_MBA21_VREF,
1920        ALC889_FIXUP_MP11_VREF,
1921        ALC889_FIXUP_MP41_VREF,
1922        ALC882_FIXUP_INV_DMIC,
1923        ALC882_FIXUP_NO_PRIMARY_HP,
1924        ALC887_FIXUP_ASUS_BASS,
1925        ALC887_FIXUP_BASS_CHMAP,
1926        ALC1220_FIXUP_GB_DUAL_CODECS,
1927        ALC1220_FIXUP_CLEVO_P950,
1928        ALC1220_FIXUP_CLEVO_PB51ED,
1929        ALC1220_FIXUP_CLEVO_PB51ED_PINS,
1930        ALC887_FIXUP_ASUS_AUDIO,
1931        ALC887_FIXUP_ASUS_HMIC,
1932};
1933
1934static void alc889_fixup_coef(struct hda_codec *codec,
1935                              const struct hda_fixup *fix, int action)
1936{
1937        if (action != HDA_FIXUP_ACT_INIT)
1938                return;
1939        alc_update_coef_idx(codec, 7, 0, 0x2030);
1940}
1941
1942/* set up GPIO at initialization */
1943static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
1944                                     const struct hda_fixup *fix, int action)
1945{
1946        struct alc_spec *spec = codec->spec;
1947
1948        spec->gpio_write_delay = true;
1949        alc_fixup_gpio3(codec, fix, action);
1950}
1951
1952/* Fix the connection of some pins for ALC889:
1953 * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
1954 * work correctly (bko#42740)
1955 */
1956static void alc889_fixup_dac_route(struct hda_codec *codec,
1957                                   const struct hda_fixup *fix, int action)
1958{
1959        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1960                /* fake the connections during parsing the tree */
1961                static const hda_nid_t conn1[] = { 0x0c, 0x0d };
1962                static const hda_nid_t conn2[] = { 0x0e, 0x0f };
1963                snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
1964                snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
1965                snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn2), conn2);
1966                snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn2), conn2);
1967        } else if (action == HDA_FIXUP_ACT_PROBE) {
1968                /* restore the connections */
1969                static const hda_nid_t conn[] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
1970                snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
1971                snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn), conn);
1972                snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn), conn);
1973                snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn), conn);
1974        }
1975}
1976
1977/* Set VREF on HP pin */
1978static void alc889_fixup_mbp_vref(struct hda_codec *codec,
1979                                  const struct hda_fixup *fix, int action)
1980{
1981        static const hda_nid_t nids[] = { 0x14, 0x15, 0x19 };
1982        struct alc_spec *spec = codec->spec;
1983        int i;
1984
1985        if (action != HDA_FIXUP_ACT_INIT)
1986                return;
1987        for (i = 0; i < ARRAY_SIZE(nids); i++) {
1988                unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
1989                if (get_defcfg_device(val) != AC_JACK_HP_OUT)
1990                        continue;
1991                val = snd_hda_codec_get_pin_target(codec, nids[i]);
1992                val |= AC_PINCTL_VREF_80;
1993                snd_hda_set_pin_ctl(codec, nids[i], val);
1994                spec->gen.keep_vref_in_automute = 1;
1995                break;
1996        }
1997}
1998
1999static void alc889_fixup_mac_pins(struct hda_codec *codec,
2000                                  const hda_nid_t *nids, int num_nids)
2001{
2002        struct alc_spec *spec = codec->spec;
2003        int i;
2004
2005        for (i = 0; i < num_nids; i++) {
2006                unsigned int val;
2007                val = snd_hda_codec_get_pin_target(codec, nids[i]);
2008                val |= AC_PINCTL_VREF_50;
2009                snd_hda_set_pin_ctl(codec, nids[i], val);
2010        }
2011        spec->gen.keep_vref_in_automute = 1;
2012}
2013
2014/* Set VREF on speaker pins on imac91 */
2015static void alc889_fixup_imac91_vref(struct hda_codec *codec,
2016                                     const struct hda_fixup *fix, int action)
2017{
2018        static const hda_nid_t nids[] = { 0x18, 0x1a };
2019
2020        if (action == HDA_FIXUP_ACT_INIT)
2021                alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2022}
2023
2024/* Set VREF on speaker pins on mba11 */
2025static void alc889_fixup_mba11_vref(struct hda_codec *codec,
2026                                    const struct hda_fixup *fix, int action)
2027{
2028        static const hda_nid_t nids[] = { 0x18 };
2029
2030        if (action == HDA_FIXUP_ACT_INIT)
2031                alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2032}
2033
2034/* Set VREF on speaker pins on mba21 */
2035static void alc889_fixup_mba21_vref(struct hda_codec *codec,
2036                                    const struct hda_fixup *fix, int action)
2037{
2038        static const hda_nid_t nids[] = { 0x18, 0x19 };
2039
2040        if (action == HDA_FIXUP_ACT_INIT)
2041                alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
2042}
2043
2044/* Don't take HP output as primary
2045 * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
2046 * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
2047 */
2048static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
2049                                       const struct hda_fixup *fix, int action)
2050{
2051        struct alc_spec *spec = codec->spec;
2052        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2053                spec->gen.no_primary_hp = 1;
2054                spec->gen.no_multi_io = 1;
2055        }
2056}
2057
2058static void alc_fixup_bass_chmap(struct hda_codec *codec,
2059                                 const struct hda_fixup *fix, int action);
2060
2061/* For dual-codec configuration, we need to disable some features to avoid
2062 * conflicts of kctls and PCM streams
2063 */
2064static void alc_fixup_dual_codecs(struct hda_codec *codec,
2065                                  const struct hda_fixup *fix, int action)
2066{
2067        struct alc_spec *spec = codec->spec;
2068
2069        if (action != HDA_FIXUP_ACT_PRE_PROBE)
2070                return;
2071        /* disable vmaster */
2072        spec->gen.suppress_vmaster = 1;
2073        /* auto-mute and auto-mic switch don't work with multiple codecs */
2074        spec->gen.suppress_auto_mute = 1;
2075        spec->gen.suppress_auto_mic = 1;
2076        /* disable aamix as well */
2077        spec->gen.mixer_nid = 0;
2078        /* add location prefix to avoid conflicts */
2079        codec->force_pin_prefix = 1;
2080}
2081
2082static void rename_ctl(struct hda_codec *codec, const char *oldname,
2083                       const char *newname)
2084{
2085        struct snd_kcontrol *kctl;
2086
2087        kctl = snd_hda_find_mixer_ctl(codec, oldname);
2088        if (kctl)
2089                strcpy(kctl->id.name, newname);
2090}
2091
2092static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec,
2093                                         const struct hda_fixup *fix,
2094                                         int action)
2095{
2096        alc_fixup_dual_codecs(codec, fix, action);
2097        switch (action) {
2098        case HDA_FIXUP_ACT_PRE_PROBE:
2099                /* override card longname to provide a unique UCM profile */
2100                strcpy(codec->card->longname, "HDAudio-Gigabyte-ALC1220DualCodecs");
2101                break;
2102        case HDA_FIXUP_ACT_BUILD:
2103                /* rename Capture controls depending on the codec */
2104                rename_ctl(codec, "Capture Volume",
2105                           codec->addr == 0 ?
2106                           "Rear-Panel Capture Volume" :
2107                           "Front-Panel Capture Volume");
2108                rename_ctl(codec, "Capture Switch",
2109                           codec->addr == 0 ?
2110                           "Rear-Panel Capture Switch" :
2111                           "Front-Panel Capture Switch");
2112                break;
2113        }
2114}
2115
2116static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
2117                                     const struct hda_fixup *fix,
2118                                     int action)
2119{
2120        static const hda_nid_t conn1[] = { 0x0c };
2121
2122        if (action != HDA_FIXUP_ACT_PRE_PROBE)
2123                return;
2124
2125        alc_update_coef_idx(codec, 0x7, 0, 0x3c3);
2126        /* We therefore want to make sure 0x14 (front headphone) and
2127         * 0x1b (speakers) use the stereo DAC 0x02
2128         */
2129        snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
2130        snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
2131}
2132
2133static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
2134                                const struct hda_fixup *fix, int action);
2135
2136static void alc1220_fixup_clevo_pb51ed(struct hda_codec *codec,
2137                                     const struct hda_fixup *fix,
2138                                     int action)
2139{
2140        alc1220_fixup_clevo_p950(codec, fix, action);
2141        alc_fixup_headset_mode_no_hp_mic(codec, fix, action);
2142}
2143
2144static void alc887_asus_hp_automute_hook(struct hda_codec *codec,
2145                                         struct hda_jack_callback *jack)
2146{
2147        struct alc_spec *spec = codec->spec;
2148        unsigned int vref;
2149
2150        snd_hda_gen_hp_automute(codec, jack);
2151
2152        if (spec->gen.hp_jack_present)
2153                vref = AC_PINCTL_VREF_80;
2154        else
2155                vref = AC_PINCTL_VREF_HIZ;
2156        snd_hda_set_pin_ctl(codec, 0x19, PIN_HP | vref);
2157}
2158
2159static void alc887_fixup_asus_jack(struct hda_codec *codec,
2160                                     const struct hda_fixup *fix, int action)
2161{
2162        struct alc_spec *spec = codec->spec;
2163        if (action != HDA_FIXUP_ACT_PROBE)
2164                return;
2165        snd_hda_set_pin_ctl_cache(codec, 0x1b, PIN_HP);
2166        spec->gen.hp_automute_hook = alc887_asus_hp_automute_hook;
2167}
2168
2169static const struct hda_fixup alc882_fixups[] = {
2170        [ALC882_FIXUP_ABIT_AW9D_MAX] = {
2171                .type = HDA_FIXUP_PINS,
2172                .v.pins = (const struct hda_pintbl[]) {
2173                        { 0x15, 0x01080104 }, /* side */
2174                        { 0x16, 0x01011012 }, /* rear */
2175                        { 0x17, 0x01016011 }, /* clfe */
2176                        { }
2177                }
2178        },
2179        [ALC882_FIXUP_LENOVO_Y530] = {
2180                .type = HDA_FIXUP_PINS,
2181                .v.pins = (const struct hda_pintbl[]) {
2182                        { 0x15, 0x99130112 }, /* rear int speakers */
2183                        { 0x16, 0x99130111 }, /* subwoofer */
2184                        { }
2185                }
2186        },
2187        [ALC882_FIXUP_PB_M5210] = {
2188                .type = HDA_FIXUP_PINCTLS,
2189                .v.pins = (const struct hda_pintbl[]) {
2190                        { 0x19, PIN_VREF50 },
2191                        {}
2192                }
2193        },
2194        [ALC882_FIXUP_ACER_ASPIRE_7736] = {
2195                .type = HDA_FIXUP_FUNC,
2196                .v.func = alc_fixup_sku_ignore,
2197        },
2198        [ALC882_FIXUP_ASUS_W90V] = {
2199                .type = HDA_FIXUP_PINS,
2200                .v.pins = (const struct hda_pintbl[]) {
2201                        { 0x16, 0x99130110 }, /* fix sequence for CLFE */
2202                        { }
2203                }
2204        },
2205        [ALC889_FIXUP_CD] = {
2206                .type = HDA_FIXUP_PINS,
2207                .v.pins = (const struct hda_pintbl[]) {
2208                        { 0x1c, 0x993301f0 }, /* CD */
2209                        { }
2210                }
2211        },
2212        [ALC889_FIXUP_FRONT_HP_NO_PRESENCE] = {
2213                .type = HDA_FIXUP_PINS,
2214                .v.pins = (const struct hda_pintbl[]) {
2215                        { 0x1b, 0x02214120 }, /* Front HP jack is flaky, disable jack detect */
2216                        { }
2217                },
2218                .chained = true,
2219                .chain_id = ALC889_FIXUP_CD,
2220        },
2221        [ALC889_FIXUP_VAIO_TT] = {
2222                .type = HDA_FIXUP_PINS,
2223                .v.pins = (const struct hda_pintbl[]) {
2224                        { 0x17, 0x90170111 }, /* hidden surround speaker */
2225                        { }
2226                }
2227        },
2228        [ALC888_FIXUP_EEE1601] = {
2229                .type = HDA_FIXUP_VERBS,
2230                .v.verbs = (const struct hda_verb[]) {
2231                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2232                        { 0x20, AC_VERB_SET_PROC_COEF,  0x0838 },
2233                        { }
2234                }
2235        },
2236        [ALC886_FIXUP_EAPD] = {
2237                .type = HDA_FIXUP_VERBS,
2238                .v.verbs = (const struct hda_verb[]) {
2239                        /* change to EAPD mode */
2240                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2241                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0068 },
2242                        { }
2243                }
2244        },
2245        [ALC882_FIXUP_EAPD] = {
2246                .type = HDA_FIXUP_VERBS,
2247                .v.verbs = (const struct hda_verb[]) {
2248                        /* change to EAPD mode */
2249                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2250                        { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
2251                        { }
2252                }
2253        },
2254        [ALC883_FIXUP_EAPD] = {
2255                .type = HDA_FIXUP_VERBS,
2256                .v.verbs = (const struct hda_verb[]) {
2257                        /* change to EAPD mode */
2258                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2259                        { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2260                        { }
2261                }
2262        },
2263        [ALC883_FIXUP_ACER_EAPD] = {
2264                .type = HDA_FIXUP_VERBS,
2265                .v.verbs = (const struct hda_verb[]) {
2266                        /* eanable EAPD on Acer laptops */
2267                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2268                        { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2269                        { }
2270                }
2271        },
2272        [ALC882_FIXUP_GPIO1] = {
2273                .type = HDA_FIXUP_FUNC,
2274                .v.func = alc_fixup_gpio1,
2275        },
2276        [ALC882_FIXUP_GPIO2] = {
2277                .type = HDA_FIXUP_FUNC,
2278                .v.func = alc_fixup_gpio2,
2279        },
2280        [ALC882_FIXUP_GPIO3] = {
2281                .type = HDA_FIXUP_FUNC,
2282                .v.func = alc_fixup_gpio3,
2283        },
2284        [ALC882_FIXUP_ASUS_W2JC] = {
2285                .type = HDA_FIXUP_FUNC,
2286                .v.func = alc_fixup_gpio1,
2287                .chained = true,
2288                .chain_id = ALC882_FIXUP_EAPD,
2289        },
2290        [ALC889_FIXUP_COEF] = {
2291                .type = HDA_FIXUP_FUNC,
2292                .v.func = alc889_fixup_coef,
2293        },
2294        [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
2295                .type = HDA_FIXUP_PINS,
2296                .v.pins = (const struct hda_pintbl[]) {
2297                        { 0x16, 0x99130111 }, /* CLFE speaker */
2298                        { 0x17, 0x99130112 }, /* surround speaker */
2299                        { }
2300                },
2301                .chained = true,
2302                .chain_id = ALC882_FIXUP_GPIO1,
2303        },
2304        [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
2305                .type = HDA_FIXUP_PINS,
2306                .v.pins = (const struct hda_pintbl[]) {
2307                        { 0x16, 0x99130111 }, /* CLFE speaker */
2308                        { 0x1b, 0x99130112 }, /* surround speaker */
2309                        { }
2310                },
2311                .chained = true,
2312                .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
2313        },
2314        [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
2315                /* additional init verbs for Acer Aspire 8930G */
2316                .type = HDA_FIXUP_VERBS,
2317                .v.verbs = (const struct hda_verb[]) {
2318                        /* Enable all DACs */
2319                        /* DAC DISABLE/MUTE 1? */
2320                        /*  setting bits 1-5 disables DAC nids 0x02-0x06
2321                         *  apparently. Init=0x38 */
2322                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
2323                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2324                        /* DAC DISABLE/MUTE 2? */
2325                        /*  some bit here disables the other DACs.
2326                         *  Init=0x4900 */
2327                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
2328                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
2329                        /* DMIC fix
2330                         * This laptop has a stereo digital microphone.
2331                         * The mics are only 1cm apart which makes the stereo
2332                         * useless. However, either the mic or the ALC889
2333                         * makes the signal become a difference/sum signal
2334                         * instead of standard stereo, which is annoying.
2335                         * So instead we flip this bit which makes the
2336                         * codec replicate the sum signal to both channels,
2337                         * turning it into a normal mono mic.
2338                         */
2339                        /* DMIC_CONTROL? Init value = 0x0001 */
2340                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
2341                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
2342                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2343                        { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2344                        { }
2345                },
2346                .chained = true,
2347                .chain_id = ALC882_FIXUP_GPIO1,
2348        },
2349        [ALC885_FIXUP_MACPRO_GPIO] = {
2350                .type = HDA_FIXUP_FUNC,
2351                .v.func = alc885_fixup_macpro_gpio,
2352        },
2353        [ALC889_FIXUP_DAC_ROUTE] = {
2354                .type = HDA_FIXUP_FUNC,
2355                .v.func = alc889_fixup_dac_route,
2356        },
2357        [ALC889_FIXUP_MBP_VREF] = {
2358                .type = HDA_FIXUP_FUNC,
2359                .v.func = alc889_fixup_mbp_vref,
2360                .chained = true,
2361                .chain_id = ALC882_FIXUP_GPIO1,
2362        },
2363        [ALC889_FIXUP_IMAC91_VREF] = {
2364                .type = HDA_FIXUP_FUNC,
2365                .v.func = alc889_fixup_imac91_vref,
2366                .chained = true,
2367                .chain_id = ALC882_FIXUP_GPIO1,
2368        },
2369        [ALC889_FIXUP_MBA11_VREF] = {
2370                .type = HDA_FIXUP_FUNC,
2371                .v.func = alc889_fixup_mba11_vref,
2372                .chained = true,
2373                .chain_id = ALC889_FIXUP_MBP_VREF,
2374        },
2375        [ALC889_FIXUP_MBA21_VREF] = {
2376                .type = HDA_FIXUP_FUNC,
2377                .v.func = alc889_fixup_mba21_vref,
2378                .chained = true,
2379                .chain_id = ALC889_FIXUP_MBP_VREF,
2380        },
2381        [ALC889_FIXUP_MP11_VREF] = {
2382                .type = HDA_FIXUP_FUNC,
2383                .v.func = alc889_fixup_mba11_vref,
2384                .chained = true,
2385                .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2386        },
2387        [ALC889_FIXUP_MP41_VREF] = {
2388                .type = HDA_FIXUP_FUNC,
2389                .v.func = alc889_fixup_mbp_vref,
2390                .chained = true,
2391                .chain_id = ALC885_FIXUP_MACPRO_GPIO,
2392        },
2393        [ALC882_FIXUP_INV_DMIC] = {
2394                .type = HDA_FIXUP_FUNC,
2395                .v.func = alc_fixup_inv_dmic,
2396        },
2397        [ALC882_FIXUP_NO_PRIMARY_HP] = {
2398                .type = HDA_FIXUP_FUNC,
2399                .v.func = alc882_fixup_no_primary_hp,
2400        },
2401        [ALC887_FIXUP_ASUS_BASS] = {
2402                .type = HDA_FIXUP_PINS,
2403                .v.pins = (const struct hda_pintbl[]) {
2404                        {0x16, 0x99130130}, /* bass speaker */
2405                        {}
2406                },
2407                .chained = true,
2408                .chain_id = ALC887_FIXUP_BASS_CHMAP,
2409        },
2410        [ALC887_FIXUP_BASS_CHMAP] = {
2411                .type = HDA_FIXUP_FUNC,
2412                .v.func = alc_fixup_bass_chmap,
2413        },
2414        [ALC1220_FIXUP_GB_DUAL_CODECS] = {
2415                .type = HDA_FIXUP_FUNC,
2416                .v.func = alc1220_fixup_gb_dual_codecs,
2417        },
2418        [ALC1220_FIXUP_CLEVO_P950] = {
2419                .type = HDA_FIXUP_FUNC,
2420                .v.func = alc1220_fixup_clevo_p950,
2421        },
2422        [ALC1220_FIXUP_CLEVO_PB51ED] = {
2423                .type = HDA_FIXUP_FUNC,
2424                .v.func = alc1220_fixup_clevo_pb51ed,
2425        },
2426        [ALC1220_FIXUP_CLEVO_PB51ED_PINS] = {
2427                .type = HDA_FIXUP_PINS,
2428                .v.pins = (const struct hda_pintbl[]) {
2429                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
2430                        {}
2431                },
2432                .chained = true,
2433                .chain_id = ALC1220_FIXUP_CLEVO_PB51ED,
2434        },
2435        [ALC887_FIXUP_ASUS_AUDIO] = {
2436                .type = HDA_FIXUP_PINS,
2437                .v.pins = (const struct hda_pintbl[]) {
2438                        { 0x15, 0x02a14150 }, /* use as headset mic, without its own jack detect */
2439                        { 0x19, 0x22219420 },
2440                        {}
2441                },
2442        },
2443        [ALC887_FIXUP_ASUS_HMIC] = {
2444                .type = HDA_FIXUP_FUNC,
2445                .v.func = alc887_fixup_asus_jack,
2446                .chained = true,
2447                .chain_id = ALC887_FIXUP_ASUS_AUDIO,
2448        },
2449};
2450
2451static const struct snd_pci_quirk alc882_fixup_tbl[] = {
2452        SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
2453        SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2454        SND_PCI_QUIRK(0x1025, 0x0107, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2455        SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
2456        SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
2457        SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
2458        SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
2459        SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
2460                      ALC882_FIXUP_ACER_ASPIRE_4930G),
2461        SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
2462                      ALC882_FIXUP_ACER_ASPIRE_4930G),
2463        SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
2464                      ALC882_FIXUP_ACER_ASPIRE_8930G),
2465        SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
2466                      ALC882_FIXUP_ACER_ASPIRE_8930G),
2467        SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
2468                      ALC882_FIXUP_ACER_ASPIRE_4930G),
2469        SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
2470        SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
2471                      ALC882_FIXUP_ACER_ASPIRE_4930G),
2472        SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
2473                      ALC882_FIXUP_ACER_ASPIRE_4930G),
2474        SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
2475                      ALC882_FIXUP_ACER_ASPIRE_4930G),
2476        SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
2477        SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
2478        SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
2479        SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
2480        SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
2481        SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
2482        SND_PCI_QUIRK(0x1043, 0x2390, "Asus D700SA", ALC887_FIXUP_ASUS_HMIC),
2483        SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
2484        SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
2485        SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
2486        SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
2487        SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
2488        SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
2489        SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
2490        SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
2491
2492        /* All Apple entries are in codec SSIDs */
2493        SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
2494        SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
2495        SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2496        SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC889_FIXUP_MP11_VREF),
2497        SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
2498        SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
2499        SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
2500        SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
2501        SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
2502        SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBA11_VREF),
2503        SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBA21_VREF),
2504        SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
2505        SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
2506        SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
2507        SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
2508        SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
2509        SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
2510        SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 4,1/5,1", ALC889_FIXUP_MP41_VREF),
2511        SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
2512        SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
2513        SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
2514        SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF),
2515
2516        SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
2517        SND_PCI_QUIRK(0x13fe, 0x1009, "Advantech MIT-W101", ALC886_FIXUP_EAPD),
2518        SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
2519        SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2520        SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_CLEVO_P950),
2521        SND_PCI_QUIRK(0x1458, 0xa0ce, "Gigabyte X570 Aorus Xtreme", ALC1220_FIXUP_CLEVO_P950),
2522        SND_PCI_QUIRK(0x1462, 0x11f7, "MSI-GE63", ALC1220_FIXUP_CLEVO_P950),
2523        SND_PCI_QUIRK(0x1462, 0x1228, "MSI-GP63", ALC1220_FIXUP_CLEVO_P950),
2524        SND_PCI_QUIRK(0x1462, 0x1229, "MSI-GP73", ALC1220_FIXUP_CLEVO_P950),
2525        SND_PCI_QUIRK(0x1462, 0x1275, "MSI-GL63", ALC1220_FIXUP_CLEVO_P950),
2526        SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950),
2527        SND_PCI_QUIRK(0x1462, 0x1293, "MSI-GP65", ALC1220_FIXUP_CLEVO_P950),
2528        SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
2529        SND_PCI_QUIRK(0x1462, 0xcc34, "MSI Godlike X570", ALC1220_FIXUP_GB_DUAL_CODECS),
2530        SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
2531        SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
2532        SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
2533        SND_PCI_QUIRK(0x1558, 0x50d3, "Clevo PC50[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2534        SND_PCI_QUIRK(0x1558, 0x65d1, "Clevo PB51[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2535        SND_PCI_QUIRK(0x1558, 0x65d2, "Clevo PB51R[CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2536        SND_PCI_QUIRK(0x1558, 0x65e1, "Clevo PB51[ED][DF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2537        SND_PCI_QUIRK(0x1558, 0x65e5, "Clevo PC50D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2538        SND_PCI_QUIRK(0x1558, 0x65f1, "Clevo PC50HS", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2539        SND_PCI_QUIRK(0x1558, 0x67d1, "Clevo PB71[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2540        SND_PCI_QUIRK(0x1558, 0x67e1, "Clevo PB71[DE][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2541        SND_PCI_QUIRK(0x1558, 0x67e5, "Clevo PC70D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2542        SND_PCI_QUIRK(0x1558, 0x70d1, "Clevo PC70[ER][CDF]", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2543        SND_PCI_QUIRK(0x1558, 0x7714, "Clevo X170SM", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
2544        SND_PCI_QUIRK(0x1558, 0x7715, "Clevo X170KM-G", ALC1220_FIXUP_CLEVO_PB51ED),
2545        SND_PCI_QUIRK(0x1558, 0x9501, "Clevo P950HR", ALC1220_FIXUP_CLEVO_P950),
2546        SND_PCI_QUIRK(0x1558, 0x9506, "Clevo P955HQ", ALC1220_FIXUP_CLEVO_P950),
2547        SND_PCI_QUIRK(0x1558, 0x950a, "Clevo P955H[PR]", ALC1220_FIXUP_CLEVO_P950),
2548        SND_PCI_QUIRK(0x1558, 0x95e1, "Clevo P95xER", ALC1220_FIXUP_CLEVO_P950),
2549        SND_PCI_QUIRK(0x1558, 0x95e2, "Clevo P950ER", ALC1220_FIXUP_CLEVO_P950),
2550        SND_PCI_QUIRK(0x1558, 0x95e3, "Clevo P955[ER]T", ALC1220_FIXUP_CLEVO_P950),
2551        SND_PCI_QUIRK(0x1558, 0x95e4, "Clevo P955ER", ALC1220_FIXUP_CLEVO_P950),
2552        SND_PCI_QUIRK(0x1558, 0x95e5, "Clevo P955EE6", ALC1220_FIXUP_CLEVO_P950),
2553        SND_PCI_QUIRK(0x1558, 0x95e6, "Clevo P950R[CDF]", ALC1220_FIXUP_CLEVO_P950),
2554        SND_PCI_QUIRK(0x1558, 0x96e1, "Clevo P960[ER][CDFN]-K", ALC1220_FIXUP_CLEVO_P950),
2555        SND_PCI_QUIRK(0x1558, 0x97e1, "Clevo P970[ER][CDFN]", ALC1220_FIXUP_CLEVO_P950),
2556        SND_PCI_QUIRK(0x1558, 0x97e2, "Clevo P970RC-M", ALC1220_FIXUP_CLEVO_P950),
2557        SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
2558        SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
2559        SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
2560        SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
2561        {}
2562};
2563
2564static const struct hda_model_fixup alc882_fixup_models[] = {
2565        {.id = ALC882_FIXUP_ABIT_AW9D_MAX, .name = "abit-aw9d"},
2566        {.id = ALC882_FIXUP_LENOVO_Y530, .name = "lenovo-y530"},
2567        {.id = ALC882_FIXUP_ACER_ASPIRE_7736, .name = "acer-aspire-7736"},
2568        {.id = ALC882_FIXUP_ASUS_W90V, .name = "asus-w90v"},
2569        {.id = ALC889_FIXUP_CD, .name = "cd"},
2570        {.id = ALC889_FIXUP_FRONT_HP_NO_PRESENCE, .name = "no-front-hp"},
2571        {.id = ALC889_FIXUP_VAIO_TT, .name = "vaio-tt"},
2572        {.id = ALC888_FIXUP_EEE1601, .name = "eee1601"},
2573        {.id = ALC882_FIXUP_EAPD, .name = "alc882-eapd"},
2574        {.id = ALC883_FIXUP_EAPD, .name = "alc883-eapd"},
2575        {.id = ALC882_FIXUP_GPIO1, .name = "gpio1"},
2576        {.id = ALC882_FIXUP_GPIO2, .name = "gpio2"},
2577        {.id = ALC882_FIXUP_GPIO3, .name = "gpio3"},
2578        {.id = ALC889_FIXUP_COEF, .name = "alc889-coef"},
2579        {.id = ALC882_FIXUP_ASUS_W2JC, .name = "asus-w2jc"},
2580        {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
2581        {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
2582        {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
2583        {.id = ALC885_FIXUP_MACPRO_GPIO, .name = "macpro-gpio"},
2584        {.id = ALC889_FIXUP_DAC_ROUTE, .name = "dac-route"},
2585        {.id = ALC889_FIXUP_MBP_VREF, .name = "mbp-vref"},
2586        {.id = ALC889_FIXUP_IMAC91_VREF, .name = "imac91-vref"},
2587        {.id = ALC889_FIXUP_MBA11_VREF, .name = "mba11-vref"},
2588        {.id = ALC889_FIXUP_MBA21_VREF, .name = "mba21-vref"},
2589        {.id = ALC889_FIXUP_MP11_VREF, .name = "mp11-vref"},
2590        {.id = ALC889_FIXUP_MP41_VREF, .name = "mp41-vref"},
2591        {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
2592        {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
2593        {.id = ALC887_FIXUP_ASUS_BASS, .name = "asus-bass"},
2594        {.id = ALC1220_FIXUP_GB_DUAL_CODECS, .name = "dual-codecs"},
2595        {.id = ALC1220_FIXUP_CLEVO_P950, .name = "clevo-p950"},
2596        {}
2597};
2598
2599static const struct snd_hda_pin_quirk alc882_pin_fixup_tbl[] = {
2600        SND_HDA_PIN_QUIRK(0x10ec1220, 0x1043, "ASUS", ALC1220_FIXUP_CLEVO_P950,
2601                {0x14, 0x01014010},
2602                {0x15, 0x01011012},
2603                {0x16, 0x01016011},
2604                {0x18, 0x01a19040},
2605                {0x19, 0x02a19050},
2606                {0x1a, 0x0181304f},
2607                {0x1b, 0x0221401f},
2608                {0x1e, 0x01456130}),
2609        SND_HDA_PIN_QUIRK(0x10ec1220, 0x1462, "MS-7C35", ALC1220_FIXUP_CLEVO_P950,
2610                {0x14, 0x01015010},
2611                {0x15, 0x01011012},
2612                {0x16, 0x01011011},
2613                {0x18, 0x01a11040},
2614                {0x19, 0x02a19050},
2615                {0x1a, 0x0181104f},
2616                {0x1b, 0x0221401f},
2617                {0x1e, 0x01451130}),
2618        {}
2619};
2620
2621/*
2622 * BIOS auto configuration
2623 */
2624/* almost identical with ALC880 parser... */
2625static int alc882_parse_auto_config(struct hda_codec *codec)
2626{
2627        static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
2628        static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2629        return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
2630}
2631
2632/*
2633 */
2634static int patch_alc882(struct hda_codec *codec)
2635{
2636        struct alc_spec *spec;
2637        int err;
2638
2639        err = alc_alloc_spec(codec, 0x0b);
2640        if (err < 0)
2641                return err;
2642
2643        spec = codec->spec;
2644
2645        switch (codec->core.vendor_id) {
2646        case 0x10ec0882:
2647        case 0x10ec0885:
2648        case 0x10ec0900:
2649        case 0x10ec0b00:
2650        case 0x10ec1220:
2651                break;
2652        default:
2653                /* ALC883 and variants */
2654                alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2655                break;
2656        }
2657
2658        alc_pre_init(codec);
2659
2660        snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
2661                       alc882_fixups);
2662        snd_hda_pick_pin_fixup(codec, alc882_pin_fixup_tbl, alc882_fixups, true);
2663        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2664
2665        alc_auto_parse_customize_define(codec);
2666
2667        if (has_cdefine_beep(codec))
2668                spec->gen.beep_nid = 0x01;
2669
2670        /* automatic parse from the BIOS config */
2671        err = alc882_parse_auto_config(codec);
2672        if (err < 0)
2673                goto error;
2674
2675        if (!spec->gen.no_analog && spec->gen.beep_nid) {
2676                err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2677                if (err < 0)
2678                        goto error;
2679        }
2680
2681        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2682
2683        return 0;
2684
2685 error:
2686        alc_free(codec);
2687        return err;
2688}
2689
2690
2691/*
2692 * ALC262 support
2693 */
2694static int alc262_parse_auto_config(struct hda_codec *codec)
2695{
2696        static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
2697        static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2698        return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
2699}
2700
2701/*
2702 * Pin config fixes
2703 */
2704enum {
2705        ALC262_FIXUP_FSC_H270,
2706        ALC262_FIXUP_FSC_S7110,
2707        ALC262_FIXUP_HP_Z200,
2708        ALC262_FIXUP_TYAN,
2709        ALC262_FIXUP_LENOVO_3000,
2710        ALC262_FIXUP_BENQ,
2711        ALC262_FIXUP_BENQ_T31,
2712        ALC262_FIXUP_INV_DMIC,
2713        ALC262_FIXUP_INTEL_BAYLEYBAY,
2714};
2715
2716static const struct hda_fixup alc262_fixups[] = {
2717        [ALC262_FIXUP_FSC_H270] = {
2718                .type = HDA_FIXUP_PINS,
2719                .v.pins = (const struct hda_pintbl[]) {
2720                        { 0x14, 0x99130110 }, /* speaker */
2721                        { 0x15, 0x0221142f }, /* front HP */
2722                        { 0x1b, 0x0121141f }, /* rear HP */
2723                        { }
2724                }
2725        },
2726        [ALC262_FIXUP_FSC_S7110] = {
2727                .type = HDA_FIXUP_PINS,
2728                .v.pins = (const struct hda_pintbl[]) {
2729                        { 0x15, 0x90170110 }, /* speaker */
2730                        { }
2731                },
2732                .chained = true,
2733                .chain_id = ALC262_FIXUP_BENQ,
2734        },
2735        [ALC262_FIXUP_HP_Z200] = {
2736                .type = HDA_FIXUP_PINS,
2737                .v.pins = (const struct hda_pintbl[]) {
2738                        { 0x16, 0x99130120 }, /* internal speaker */
2739                        { }
2740                }
2741        },
2742        [ALC262_FIXUP_TYAN] = {
2743                .type = HDA_FIXUP_PINS,
2744                .v.pins = (const struct hda_pintbl[]) {
2745                        { 0x14, 0x1993e1f0 }, /* int AUX */
2746                        { }
2747                }
2748        },
2749        [ALC262_FIXUP_LENOVO_3000] = {
2750                .type = HDA_FIXUP_PINCTLS,
2751                .v.pins = (const struct hda_pintbl[]) {
2752                        { 0x19, PIN_VREF50 },
2753                        {}
2754                },
2755                .chained = true,
2756                .chain_id = ALC262_FIXUP_BENQ,
2757        },
2758        [ALC262_FIXUP_BENQ] = {
2759                .type = HDA_FIXUP_VERBS,
2760                .v.verbs = (const struct hda_verb[]) {
2761                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2762                        { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
2763                        {}
2764                }
2765        },
2766        [ALC262_FIXUP_BENQ_T31] = {
2767                .type = HDA_FIXUP_VERBS,
2768                .v.verbs = (const struct hda_verb[]) {
2769                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
2770                        { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
2771                        {}
2772                }
2773        },
2774        [ALC262_FIXUP_INV_DMIC] = {
2775                .type = HDA_FIXUP_FUNC,
2776                .v.func = alc_fixup_inv_dmic,
2777        },
2778        [ALC262_FIXUP_INTEL_BAYLEYBAY] = {
2779                .type = HDA_FIXUP_FUNC,
2780                .v.func = alc_fixup_no_depop_delay,
2781        },
2782};
2783
2784static const struct snd_pci_quirk alc262_fixup_tbl[] = {
2785        SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
2786        SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
2787        SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
2788        SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
2789        SND_PCI_QUIRK(0x1734, 0x1141, "FSC ESPRIMO U9210", ALC262_FIXUP_FSC_H270),
2790        SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
2791        SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
2792        SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
2793        SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
2794        SND_PCI_QUIRK(0x8086, 0x7270, "BayleyBay", ALC262_FIXUP_INTEL_BAYLEYBAY),
2795        {}
2796};
2797
2798static const struct hda_model_fixup alc262_fixup_models[] = {
2799        {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
2800        {.id = ALC262_FIXUP_FSC_H270, .name = "fsc-h270"},
2801        {.id = ALC262_FIXUP_FSC_S7110, .name = "fsc-s7110"},
2802        {.id = ALC262_FIXUP_HP_Z200, .name = "hp-z200"},
2803        {.id = ALC262_FIXUP_TYAN, .name = "tyan"},
2804        {.id = ALC262_FIXUP_LENOVO_3000, .name = "lenovo-3000"},
2805        {.id = ALC262_FIXUP_BENQ, .name = "benq"},
2806        {.id = ALC262_FIXUP_BENQ_T31, .name = "benq-t31"},
2807        {.id = ALC262_FIXUP_INTEL_BAYLEYBAY, .name = "bayleybay"},
2808        {}
2809};
2810
2811/*
2812 */
2813static int patch_alc262(struct hda_codec *codec)
2814{
2815        struct alc_spec *spec;
2816        int err;
2817
2818        err = alc_alloc_spec(codec, 0x0b);
2819        if (err < 0)
2820                return err;
2821
2822        spec = codec->spec;
2823        spec->gen.shared_mic_vref_pin = 0x18;
2824
2825        spec->shutup = alc_eapd_shutup;
2826
2827#if 0
2828        /* pshou 07/11/05  set a zero PCM sample to DAC when FIFO is
2829         * under-run
2830         */
2831        alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x80);
2832#endif
2833        alc_fix_pll_init(codec, 0x20, 0x0a, 10);
2834
2835        alc_pre_init(codec);
2836
2837        snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
2838                       alc262_fixups);
2839        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2840
2841        alc_auto_parse_customize_define(codec);
2842
2843        if (has_cdefine_beep(codec))
2844                spec->gen.beep_nid = 0x01;
2845
2846        /* automatic parse from the BIOS config */
2847        err = alc262_parse_auto_config(codec);
2848        if (err < 0)
2849                goto error;
2850
2851        if (!spec->gen.no_analog && spec->gen.beep_nid) {
2852                err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
2853                if (err < 0)
2854                        goto error;
2855        }
2856
2857        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
2858
2859        return 0;
2860
2861 error:
2862        alc_free(codec);
2863        return err;
2864}
2865
2866/*
2867 *  ALC268
2868 */
2869/* bind Beep switches of both NID 0x0f and 0x10 */
2870static int alc268_beep_switch_put(struct snd_kcontrol *kcontrol,
2871                                  struct snd_ctl_elem_value *ucontrol)
2872{
2873        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2874        unsigned long pval;
2875        int err;
2876
2877        mutex_lock(&codec->control_mutex);
2878        pval = kcontrol->private_value;
2879        kcontrol->private_value = (pval & ~0xff) | 0x0f;
2880        err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2881        if (err >= 0) {
2882                kcontrol->private_value = (pval & ~0xff) | 0x10;
2883                err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
2884        }
2885        kcontrol->private_value = pval;
2886        mutex_unlock(&codec->control_mutex);
2887        return err;
2888}
2889
2890static const struct snd_kcontrol_new alc268_beep_mixer[] = {
2891        HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
2892        {
2893                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2894                .name = "Beep Playback Switch",
2895                .subdevice = HDA_SUBDEV_AMP_FLAG,
2896                .info = snd_hda_mixer_amp_switch_info,
2897                .get = snd_hda_mixer_amp_switch_get,
2898                .put = alc268_beep_switch_put,
2899                .private_value = HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT)
2900        },
2901};
2902
2903/* set PCBEEP vol = 0, mute connections */
2904static const struct hda_verb alc268_beep_init_verbs[] = {
2905        {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2906        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2907        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2908        { }
2909};
2910
2911enum {
2912        ALC268_FIXUP_INV_DMIC,
2913        ALC268_FIXUP_HP_EAPD,
2914        ALC268_FIXUP_SPDIF,
2915};
2916
2917static const struct hda_fixup alc268_fixups[] = {
2918        [ALC268_FIXUP_INV_DMIC] = {
2919                .type = HDA_FIXUP_FUNC,
2920                .v.func = alc_fixup_inv_dmic,
2921        },
2922        [ALC268_FIXUP_HP_EAPD] = {
2923                .type = HDA_FIXUP_VERBS,
2924                .v.verbs = (const struct hda_verb[]) {
2925                        {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
2926                        {}
2927                }
2928        },
2929        [ALC268_FIXUP_SPDIF] = {
2930                .type = HDA_FIXUP_PINS,
2931                .v.pins = (const struct hda_pintbl[]) {
2932                        { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2933                        {}
2934                }
2935        },
2936};
2937
2938static const struct hda_model_fixup alc268_fixup_models[] = {
2939        {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
2940        {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
2941        {.id = ALC268_FIXUP_SPDIF, .name = "spdif"},
2942        {}
2943};
2944
2945static const struct snd_pci_quirk alc268_fixup_tbl[] = {
2946        SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
2947        SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
2948        /* below is codec SSID since multiple Toshiba laptops have the
2949         * same PCI SSID 1179:ff00
2950         */
2951        SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
2952        {}
2953};
2954
2955/*
2956 * BIOS auto configuration
2957 */
2958static int alc268_parse_auto_config(struct hda_codec *codec)
2959{
2960        static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
2961        return alc_parse_auto_config(codec, NULL, alc268_ssids);
2962}
2963
2964/*
2965 */
2966static int patch_alc268(struct hda_codec *codec)
2967{
2968        struct alc_spec *spec;
2969        int i, err;
2970
2971        /* ALC268 has no aa-loopback mixer */
2972        err = alc_alloc_spec(codec, 0);
2973        if (err < 0)
2974                return err;
2975
2976        spec = codec->spec;
2977        if (has_cdefine_beep(codec))
2978                spec->gen.beep_nid = 0x01;
2979
2980        spec->shutup = alc_eapd_shutup;
2981
2982        alc_pre_init(codec);
2983
2984        snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
2985        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
2986
2987        /* automatic parse from the BIOS config */
2988        err = alc268_parse_auto_config(codec);
2989        if (err < 0)
2990                goto error;
2991
2992        if (err > 0 && !spec->gen.no_analog &&
2993            spec->gen.autocfg.speaker_pins[0] != 0x1d) {
2994                for (i = 0; i < ARRAY_SIZE(alc268_beep_mixer); i++) {
2995                        if (!snd_hda_gen_add_kctl(&spec->gen, NULL,
2996                                                  &alc268_beep_mixer[i])) {
2997                                err = -ENOMEM;
2998                                goto error;
2999                        }
3000                }
3001                snd_hda_add_verbs(codec, alc268_beep_init_verbs);
3002                if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
3003                        /* override the amp caps for beep generator */
3004                        snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
3005                                          (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
3006                                          (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
3007                                          (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3008                                          (0 << AC_AMPCAP_MUTE_SHIFT));
3009        }
3010
3011        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
3012
3013        return 0;
3014
3015 error:
3016        alc_free(codec);
3017        return err;
3018}
3019
3020/*
3021 * ALC269
3022 */
3023
3024static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
3025        .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
3026};
3027
3028static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
3029        .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
3030};
3031
3032/* different alc269-variants */
3033enum {
3034        ALC269_TYPE_ALC269VA,
3035        ALC269_TYPE_ALC269VB,
3036        ALC269_TYPE_ALC269VC,
3037        ALC269_TYPE_ALC269VD,
3038        ALC269_TYPE_ALC280,
3039        ALC269_TYPE_ALC282,
3040        ALC269_TYPE_ALC283,
3041        ALC269_TYPE_ALC284,
3042        ALC269_TYPE_ALC293,
3043        ALC269_TYPE_ALC286,
3044        ALC269_TYPE_ALC298,
3045        ALC269_TYPE_ALC255,
3046        ALC269_TYPE_ALC256,
3047        ALC269_TYPE_ALC257,
3048        ALC269_TYPE_ALC215,
3049        ALC269_TYPE_ALC225,
3050        ALC269_TYPE_ALC287,
3051        ALC269_TYPE_ALC294,
3052        ALC269_TYPE_ALC300,
3053        ALC269_TYPE_ALC623,
3054        ALC269_TYPE_ALC700,
3055};
3056
3057/*
3058 * BIOS auto configuration
3059 */
3060static int alc269_parse_auto_config(struct hda_codec *codec)
3061{
3062        static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
3063        static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
3064        static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
3065        struct alc_spec *spec = codec->spec;
3066        const hda_nid_t *ssids;
3067
3068        switch (spec->codec_variant) {
3069        case ALC269_TYPE_ALC269VA:
3070        case ALC269_TYPE_ALC269VC:
3071        case ALC269_TYPE_ALC280:
3072        case ALC269_TYPE_ALC284:
3073        case ALC269_TYPE_ALC293:
3074                ssids = alc269va_ssids;
3075                break;
3076        case ALC269_TYPE_ALC269VB:
3077        case ALC269_TYPE_ALC269VD:
3078        case ALC269_TYPE_ALC282:
3079        case ALC269_TYPE_ALC283:
3080        case ALC269_TYPE_ALC286:
3081        case ALC269_TYPE_ALC298:
3082        case ALC269_TYPE_ALC255:
3083        case ALC269_TYPE_ALC256:
3084        case ALC269_TYPE_ALC257:
3085        case ALC269_TYPE_ALC215:
3086        case ALC269_TYPE_ALC225:
3087        case ALC269_TYPE_ALC287:
3088        case ALC269_TYPE_ALC294:
3089        case ALC269_TYPE_ALC300:
3090        case ALC269_TYPE_ALC623:
3091        case ALC269_TYPE_ALC700:
3092                ssids = alc269_ssids;
3093                break;
3094        default:
3095                ssids = alc269_ssids;
3096                break;
3097        }
3098
3099        return alc_parse_auto_config(codec, alc269_ignore, ssids);
3100}
3101
3102static const struct hda_jack_keymap alc_headset_btn_keymap[] = {
3103        { SND_JACK_BTN_0, KEY_PLAYPAUSE },
3104        { SND_JACK_BTN_1, KEY_VOICECOMMAND },
3105        { SND_JACK_BTN_2, KEY_VOLUMEUP },
3106        { SND_JACK_BTN_3, KEY_VOLUMEDOWN },
3107        {}
3108};
3109
3110static void alc_headset_btn_callback(struct hda_codec *codec,
3111                                     struct hda_jack_callback *jack)
3112{
3113        int report = 0;
3114
3115        if (jack->unsol_res & (7 << 13))
3116                report |= SND_JACK_BTN_0;
3117
3118        if (jack->unsol_res  & (1 << 16 | 3 << 8))
3119                report |= SND_JACK_BTN_1;
3120
3121        /* Volume up key */
3122        if (jack->unsol_res & (7 << 23))
3123                report |= SND_JACK_BTN_2;
3124
3125        /* Volume down key */
3126        if (jack->unsol_res & (7 << 10))
3127                report |= SND_JACK_BTN_3;
3128
3129        snd_hda_jack_set_button_state(codec, jack->nid, report);
3130}
3131
3132static void alc_disable_headset_jack_key(struct hda_codec *codec)
3133{
3134        struct alc_spec *spec = codec->spec;
3135
3136        if (!spec->has_hs_key)
3137                return;
3138
3139        switch (codec->core.vendor_id) {
3140        case 0x10ec0215:
3141        case 0x10ec0225:
3142        case 0x10ec0285:
3143        case 0x10ec0287:
3144        case 0x10ec0295:
3145        case 0x10ec0289:
3146        case 0x10ec0299:
3147                alc_write_coef_idx(codec, 0x48, 0x0);
3148                alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
3149                alc_update_coef_idx(codec, 0x44, 0x0045 << 8, 0x0);
3150                break;
3151        case 0x10ec0230:
3152        case 0x10ec0236:
3153        case 0x10ec0256:
3154                alc_write_coef_idx(codec, 0x48, 0x0);
3155                alc_update_coef_idx(codec, 0x49, 0x0045, 0x0);
3156                break;
3157        }
3158}
3159
3160static void alc_enable_headset_jack_key(struct hda_codec *codec)
3161{
3162        struct alc_spec *spec = codec->spec;
3163
3164        if (!spec->has_hs_key)
3165                return;
3166
3167        switch (codec->core.vendor_id) {
3168        case 0x10ec0215:
3169        case 0x10ec0225:
3170        case 0x10ec0285:
3171        case 0x10ec0287:
3172        case 0x10ec0295:
3173        case 0x10ec0289:
3174        case 0x10ec0299:
3175                alc_write_coef_idx(codec, 0x48, 0xd011);
3176                alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
3177                alc_update_coef_idx(codec, 0x44, 0x007f << 8, 0x0045 << 8);
3178                break;
3179        case 0x10ec0230:
3180        case 0x10ec0236:
3181        case 0x10ec0256:
3182                alc_write_coef_idx(codec, 0x48, 0xd011);
3183                alc_update_coef_idx(codec, 0x49, 0x007f, 0x0045);
3184                break;
3185        }
3186}
3187
3188static void alc_fixup_headset_jack(struct hda_codec *codec,
3189                                    const struct hda_fixup *fix, int action)
3190{
3191        struct alc_spec *spec = codec->spec;
3192        hda_nid_t hp_pin;
3193
3194        switch (action) {
3195        case HDA_FIXUP_ACT_PRE_PROBE:
3196                spec->has_hs_key = 1;
3197                snd_hda_jack_detect_enable_callback(codec, 0x55,
3198                                                    alc_headset_btn_callback);
3199                break;
3200        case HDA_FIXUP_ACT_BUILD:
3201                hp_pin = alc_get_hp_pin(spec);
3202                if (!hp_pin || snd_hda_jack_bind_keymap(codec, 0x55,
3203                                                        alc_headset_btn_keymap,
3204                                                        hp_pin))
3205                        snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack",
3206                                              false, SND_JACK_HEADSET,
3207                                              alc_headset_btn_keymap);
3208
3209                alc_enable_headset_jack_key(codec);
3210                break;
3211        }
3212}
3213
3214static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
3215{
3216        alc_update_coef_idx(codec, 0x04, 1 << 11, power_up ? (1 << 11) : 0);
3217}
3218
3219static void alc269_shutup(struct hda_codec *codec)
3220{
3221        struct alc_spec *spec = codec->spec;
3222
3223        if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3224                alc269vb_toggle_power_output(codec, 0);
3225        if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3226                        (alc_get_coef0(codec) & 0x00ff) == 0x018) {
3227                msleep(150);
3228        }
3229        alc_shutup_pins(codec);
3230}
3231
3232static const struct coef_fw alc282_coefs[] = {
3233        WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3234        UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3235        WRITE_COEF(0x07, 0x0200), /* DMIC control */
3236        UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3237        UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3238        WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3239        WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3240        WRITE_COEF(0x0e, 0x6e00), /* LDO1/2/3, DAC/ADC */
3241        UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3242        UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3243        WRITE_COEF(0x6f, 0x0), /* Class D test 4 */
3244        UPDATE_COEF(0x0c, 0xfe00, 0), /* IO power down directly */
3245        WRITE_COEF(0x34, 0xa0c0), /* ANC */
3246        UPDATE_COEF(0x16, 0x0008, 0), /* AGC MUX */
3247        UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3248        UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3249        WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3250        WRITE_COEF(0x63, 0x2902), /* PLL */
3251        WRITE_COEF(0x68, 0xa080), /* capless control 2 */
3252        WRITE_COEF(0x69, 0x3400), /* capless control 3 */
3253        WRITE_COEF(0x6a, 0x2f3e), /* capless control 4 */
3254        WRITE_COEF(0x6b, 0x0), /* capless control 5 */
3255        UPDATE_COEF(0x6d, 0x0fff, 0x0900), /* class D test 2 */
3256        WRITE_COEF(0x6e, 0x110a), /* class D test 3 */
3257        UPDATE_COEF(0x70, 0x00f8, 0x00d8), /* class D test 5 */
3258        WRITE_COEF(0x71, 0x0014), /* class D test 6 */
3259        WRITE_COEF(0x72, 0xc2ba), /* classD OCP */
3260        UPDATE_COEF(0x77, 0x0f80, 0), /* classD pure DC test */
3261        WRITE_COEF(0x6c, 0xfc06), /* Class D amp control */
3262        {}
3263};
3264
3265static void alc282_restore_default_value(struct hda_codec *codec)
3266{
3267        alc_process_coef_fw(codec, alc282_coefs);
3268}
3269
3270static void alc282_init(struct hda_codec *codec)
3271{
3272        struct alc_spec *spec = codec->spec;
3273        hda_nid_t hp_pin = alc_get_hp_pin(spec);
3274        bool hp_pin_sense;
3275        int coef78;
3276
3277        alc282_restore_default_value(codec);
3278
3279        if (!hp_pin)
3280                return;
3281        hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3282        coef78 = alc_read_coef_idx(codec, 0x78);
3283
3284        /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
3285        /* Headphone capless set to high power mode */
3286        alc_write_coef_idx(codec, 0x78, 0x9004);
3287
3288        if (hp_pin_sense)
3289                msleep(2);
3290
3291        snd_hda_codec_write(codec, hp_pin, 0,
3292                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3293
3294        if (hp_pin_sense)
3295                msleep(85);
3296
3297        snd_hda_codec_write(codec, hp_pin, 0,
3298                            AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3299
3300        if (hp_pin_sense)
3301                msleep(100);
3302
3303        /* Headphone capless set to normal mode */
3304        alc_write_coef_idx(codec, 0x78, coef78);
3305}
3306
3307static void alc282_shutup(struct hda_codec *codec)
3308{
3309        struct alc_spec *spec = codec->spec;
3310        hda_nid_t hp_pin = alc_get_hp_pin(spec);
3311        bool hp_pin_sense;
3312        int coef78;
3313
3314        if (!hp_pin) {
3315                alc269_shutup(codec);
3316                return;
3317        }
3318
3319        hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3320        coef78 = alc_read_coef_idx(codec, 0x78);
3321        alc_write_coef_idx(codec, 0x78, 0x9004);
3322
3323        if (hp_pin_sense)
3324                msleep(2);
3325
3326        snd_hda_codec_write(codec, hp_pin, 0,
3327                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3328
3329        if (hp_pin_sense)
3330                msleep(85);
3331
3332        if (!spec->no_shutup_pins)
3333                snd_hda_codec_write(codec, hp_pin, 0,
3334                                    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3335
3336        if (hp_pin_sense)
3337                msleep(100);
3338
3339        alc_auto_setup_eapd(codec, false);
3340        alc_shutup_pins(codec);
3341        alc_write_coef_idx(codec, 0x78, coef78);
3342}
3343
3344static const struct coef_fw alc283_coefs[] = {
3345        WRITE_COEF(0x03, 0x0002), /* Power Down Control */
3346        UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
3347        WRITE_COEF(0x07, 0x0200), /* DMIC control */
3348        UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
3349        UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
3350        WRITE_COEF(0x0a, 0xcccc), /* JD offset1 */
3351        WRITE_COEF(0x0b, 0xcccc), /* JD offset2 */
3352        WRITE_COEF(0x0e, 0x6fc0), /* LDO1/2/3, DAC/ADC */
3353        UPDATE_COEF(0x0f, 0xf800, 0x1000), /* JD */
3354        UPDATE_COEF(0x10, 0xfc00, 0x0c00), /* Capless */
3355        WRITE_COEF(0x3a, 0x0), /* Class D test 4 */
3356        UPDATE_COEF(0x0c, 0xfe00, 0x0), /* IO power down directly */
3357        WRITE_COEF(0x22, 0xa0c0), /* ANC */
3358        UPDATE_COEFEX(0x53, 0x01, 0x000f, 0x0008), /* AGC MUX */
3359        UPDATE_COEF(0x1d, 0x00e0, 0), /* DAC simple content protection */
3360        UPDATE_COEF(0x1f, 0x00e0, 0), /* ADC simple content protection */
3361        WRITE_COEF(0x21, 0x8804), /* DAC ADC Zero Detection */
3362        WRITE_COEF(0x2e, 0x2902), /* PLL */
3363        WRITE_COEF(0x33, 0xa080), /* capless control 2 */
3364        WRITE_COEF(0x34, 0x3400), /* capless control 3 */
3365        WRITE_COEF(0x35, 0x2f3e), /* capless control 4 */
3366        WRITE_COEF(0x36, 0x0), /* capless control 5 */
3367        UPDATE_COEF(0x38, 0x0fff, 0x0900), /* class D test 2 */
3368        WRITE_COEF(0x39, 0x110a), /* class D test 3 */
3369        UPDATE_COEF(0x3b, 0x00f8, 0x00d8), /* class D test 5 */
3370        WRITE_COEF(0x3c, 0x0014), /* class D test 6 */
3371        WRITE_COEF(0x3d, 0xc2ba), /* classD OCP */
3372        UPDATE_COEF(0x42, 0x0f80, 0x0), /* classD pure DC test */
3373        WRITE_COEF(0x49, 0x0), /* test mode */
3374        UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
3375        UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
3376        WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
3377        UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
3378        {}
3379};
3380
3381static void alc283_restore_default_value(struct hda_codec *codec)
3382{
3383        alc_process_coef_fw(codec, alc283_coefs);
3384}
3385
3386static void alc283_init(struct hda_codec *codec)
3387{
3388        struct alc_spec *spec = codec->spec;
3389        hda_nid_t hp_pin = alc_get_hp_pin(spec);
3390        bool hp_pin_sense;
3391
3392        alc283_restore_default_value(codec);
3393
3394        if (!hp_pin)
3395                return;
3396
3397        msleep(30);
3398        hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3399
3400        /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
3401        /* Headphone capless set to high power mode */
3402        alc_write_coef_idx(codec, 0x43, 0x9004);
3403
3404        snd_hda_codec_write(codec, hp_pin, 0,
3405                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3406
3407        if (hp_pin_sense)
3408                msleep(85);
3409
3410        snd_hda_codec_write(codec, hp_pin, 0,
3411                            AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3412
3413        if (hp_pin_sense)
3414                msleep(85);
3415        /* Index 0x46 Combo jack auto switch control 2 */
3416        /* 3k pull low control for Headset jack. */
3417        alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3418        /* Headphone capless set to normal mode */
3419        alc_write_coef_idx(codec, 0x43, 0x9614);
3420}
3421
3422static void alc283_shutup(struct hda_codec *codec)
3423{
3424        struct alc_spec *spec = codec->spec;
3425        hda_nid_t hp_pin = alc_get_hp_pin(spec);
3426        bool hp_pin_sense;
3427
3428        if (!hp_pin) {
3429                alc269_shutup(codec);
3430                return;
3431        }
3432
3433        hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3434
3435        alc_write_coef_idx(codec, 0x43, 0x9004);
3436
3437        /*depop hp during suspend*/
3438        alc_write_coef_idx(codec, 0x06, 0x2100);
3439
3440        snd_hda_codec_write(codec, hp_pin, 0,
3441                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3442
3443        if (hp_pin_sense)
3444                msleep(100);
3445
3446        if (!spec->no_shutup_pins)
3447                snd_hda_codec_write(codec, hp_pin, 0,
3448                                    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3449
3450        alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3451
3452        if (hp_pin_sense)
3453                msleep(100);
3454        alc_auto_setup_eapd(codec, false);
3455        alc_shutup_pins(codec);
3456        alc_write_coef_idx(codec, 0x43, 0x9614);
3457}
3458
3459static void alc256_init(struct hda_codec *codec)
3460{
3461        struct alc_spec *spec = codec->spec;
3462        hda_nid_t hp_pin = alc_get_hp_pin(spec);
3463        bool hp_pin_sense;
3464
3465        if (!hp_pin)
3466                hp_pin = 0x21;
3467
3468        msleep(30);
3469
3470        hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3471
3472        if (hp_pin_sense)
3473                msleep(2);
3474
3475        alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3476        if (spec->ultra_low_power) {
3477                alc_update_coef_idx(codec, 0x03, 1<<1, 1<<1);
3478                alc_update_coef_idx(codec, 0x08, 3<<2, 3<<2);
3479                alc_update_coef_idx(codec, 0x08, 7<<4, 0);
3480                alc_update_coef_idx(codec, 0x3b, 1<<15, 0);
3481                alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3482                msleep(30);
3483        }
3484
3485        snd_hda_codec_write(codec, hp_pin, 0,
3486                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3487
3488        if (hp_pin_sense || spec->ultra_low_power)
3489                msleep(85);
3490
3491        snd_hda_codec_write(codec, hp_pin, 0,
3492                            AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3493
3494        if (hp_pin_sense || spec->ultra_low_power)
3495                msleep(100);
3496
3497        alc_update_coef_idx(codec, 0x46, 3 << 12, 0);
3498        alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3499        alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 1 << 15); /* Clear bit */
3500        alc_update_coefex_idx(codec, 0x53, 0x02, 0x8000, 0 << 15);
3501        /*
3502         * Expose headphone mic (or possibly Line In on some machines) instead
3503         * of PC Beep on 1Ah, and disable 1Ah loopback for all outputs. See
3504         * Documentation/sound/hd-audio/realtek-pc-beep.rst for details of
3505         * this register.
3506         */
3507        alc_write_coef_idx(codec, 0x36, 0x5757);
3508}
3509
3510static void alc256_shutup(struct hda_codec *codec)
3511{
3512        struct alc_spec *spec = codec->spec;
3513        hda_nid_t hp_pin = alc_get_hp_pin(spec);
3514        bool hp_pin_sense;
3515
3516        if (!hp_pin)
3517                hp_pin = 0x21;
3518
3519        hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3520
3521        if (hp_pin_sense)
3522                msleep(2);
3523
3524        snd_hda_codec_write(codec, hp_pin, 0,
3525                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3526
3527        if (hp_pin_sense || spec->ultra_low_power)
3528                msleep(85);
3529
3530        /* 3k pull low control for Headset jack. */
3531        /* NOTE: call this before clearing the pin, otherwise codec stalls */
3532        /* If disable 3k pulldown control for alc257, the Mic detection will not work correctly
3533         * when booting with headset plugged. So skip setting it for the codec alc257
3534         */
3535        if (spec->codec_variant != ALC269_TYPE_ALC257 &&
3536            spec->codec_variant != ALC269_TYPE_ALC256)
3537                alc_update_coef_idx(codec, 0x46, 0, 3 << 12);
3538
3539        if (!spec->no_shutup_pins)
3540                snd_hda_codec_write(codec, hp_pin, 0,
3541                                    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3542
3543        if (hp_pin_sense || spec->ultra_low_power)
3544                msleep(100);
3545
3546        alc_auto_setup_eapd(codec, false);
3547        alc_shutup_pins(codec);
3548        if (spec->ultra_low_power) {
3549                msleep(50);
3550                alc_update_coef_idx(codec, 0x03, 1<<1, 0);
3551                alc_update_coef_idx(codec, 0x08, 7<<4, 7<<4);
3552                alc_update_coef_idx(codec, 0x08, 3<<2, 0);
3553                alc_update_coef_idx(codec, 0x3b, 1<<15, 1<<15);
3554                alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3555                msleep(30);
3556        }
3557}
3558
3559static void alc285_hp_init(struct hda_codec *codec)
3560{
3561        struct alc_spec *spec = codec->spec;
3562        hda_nid_t hp_pin = alc_get_hp_pin(spec);
3563        int i, val;
3564        int coef38, coef0d, coef36;
3565
3566        alc_update_coef_idx(codec, 0x4a, 1<<15, 1<<15); /* Reset HP JD */
3567        coef38 = alc_read_coef_idx(codec, 0x38); /* Amp control */
3568        coef0d = alc_read_coef_idx(codec, 0x0d); /* Digital Misc control */
3569        coef36 = alc_read_coef_idx(codec, 0x36); /* Passthrough Control */
3570        alc_update_coef_idx(codec, 0x38, 1<<4, 0x0);
3571        alc_update_coef_idx(codec, 0x0d, 0x110, 0x0);
3572
3573        alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
3574
3575        if (hp_pin)
3576                snd_hda_codec_write(codec, hp_pin, 0,
3577                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3578
3579        msleep(130);
3580        alc_update_coef_idx(codec, 0x36, 1<<14, 1<<14);
3581        alc_update_coef_idx(codec, 0x36, 1<<13, 0x0);
3582
3583        if (hp_pin)
3584                snd_hda_codec_write(codec, hp_pin, 0,
3585                            AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3586        msleep(10);
3587        alc_write_coef_idx(codec, 0x67, 0x0); /* Set HP depop to manual mode */
3588        alc_write_coefex_idx(codec, 0x58, 0x00, 0x7880);
3589        alc_write_coefex_idx(codec, 0x58, 0x0f, 0xf049);
3590        alc_update_coefex_idx(codec, 0x58, 0x03, 0x00f0, 0x00c0);
3591
3592        alc_write_coefex_idx(codec, 0x58, 0x00, 0xf888); /* HP depop procedure start */
3593        val = alc_read_coefex_idx(codec, 0x58, 0x00);
3594        for (i = 0; i < 20 && val & 0x8000; i++) {
3595                msleep(50);
3596                val = alc_read_coefex_idx(codec, 0x58, 0x00);
3597        } /* Wait for depop procedure finish  */
3598
3599        alc_write_coefex_idx(codec, 0x58, 0x00, val); /* write back the result */
3600        alc_update_coef_idx(codec, 0x38, 1<<4, coef38);
3601        alc_update_coef_idx(codec, 0x0d, 0x110, coef0d);
3602        alc_update_coef_idx(codec, 0x36, 3<<13, coef36);
3603
3604        msleep(50);
3605        alc_update_coef_idx(codec, 0x4a, 1<<15, 0);
3606}
3607
3608static void alc225_init(struct hda_codec *codec)
3609{
3610        struct alc_spec *spec = codec->spec;
3611        hda_nid_t hp_pin = alc_get_hp_pin(spec);
3612        bool hp1_pin_sense, hp2_pin_sense;
3613
3614        if (spec->codec_variant != ALC269_TYPE_ALC287)
3615                /* required only at boot or S3 and S4 resume time */
3616                if (!spec->done_hp_init ||
3617                        is_s3_resume(codec) ||
3618                        is_s4_resume(codec)) {
3619                        alc285_hp_init(codec);
3620                        spec->done_hp_init = true;
3621                }
3622
3623        if (!hp_pin)
3624                hp_pin = 0x21;
3625        msleep(30);
3626
3627        hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3628        hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3629
3630        if (hp1_pin_sense || hp2_pin_sense)
3631                msleep(2);
3632
3633        alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x1); /* Low power */
3634        if (spec->ultra_low_power) {
3635                alc_update_coef_idx(codec, 0x08, 0x0f << 2, 3<<2);
3636                alc_update_coef_idx(codec, 0x0e, 7<<6, 7<<6);
3637                alc_update_coef_idx(codec, 0x33, 1<<11, 0);
3638                msleep(30);
3639        }
3640
3641        if (hp1_pin_sense || spec->ultra_low_power)
3642                snd_hda_codec_write(codec, hp_pin, 0,
3643                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3644        if (hp2_pin_sense)
3645                snd_hda_codec_write(codec, 0x16, 0,
3646                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3647
3648        if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3649                msleep(85);
3650
3651        if (hp1_pin_sense || spec->ultra_low_power)
3652                snd_hda_codec_write(codec, hp_pin, 0,
3653                            AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3654        if (hp2_pin_sense)
3655                snd_hda_codec_write(codec, 0x16, 0,
3656                            AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3657
3658        if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3659                msleep(100);
3660
3661        alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3662        alc_update_coefex_idx(codec, 0x57, 0x04, 0x0007, 0x4); /* Hight power */
3663}
3664
3665static void alc225_shutup(struct hda_codec *codec)
3666{
3667        struct alc_spec *spec = codec->spec;
3668        hda_nid_t hp_pin = alc_get_hp_pin(spec);
3669        bool hp1_pin_sense, hp2_pin_sense;
3670
3671        if (!hp_pin)
3672                hp_pin = 0x21;
3673
3674        alc_disable_headset_jack_key(codec);
3675        /* 3k pull low control for Headset jack. */
3676        alc_update_coef_idx(codec, 0x4a, 0, 3 << 10);
3677
3678        hp1_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3679        hp2_pin_sense = snd_hda_jack_detect(codec, 0x16);
3680
3681        if (hp1_pin_sense || hp2_pin_sense)
3682                msleep(2);
3683
3684        if (hp1_pin_sense || spec->ultra_low_power)
3685                snd_hda_codec_write(codec, hp_pin, 0,
3686                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3687        if (hp2_pin_sense)
3688                snd_hda_codec_write(codec, 0x16, 0,
3689                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3690
3691        if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3692                msleep(85);
3693
3694        if (hp1_pin_sense || spec->ultra_low_power)
3695                snd_hda_codec_write(codec, hp_pin, 0,
3696                            AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3697        if (hp2_pin_sense)
3698                snd_hda_codec_write(codec, 0x16, 0,
3699                            AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3700
3701        if (hp1_pin_sense || hp2_pin_sense || spec->ultra_low_power)
3702                msleep(100);
3703
3704        alc_auto_setup_eapd(codec, false);
3705        alc_shutup_pins(codec);
3706        if (spec->ultra_low_power) {
3707                msleep(50);
3708                alc_update_coef_idx(codec, 0x08, 0x0f << 2, 0x0c << 2);
3709                alc_update_coef_idx(codec, 0x0e, 7<<6, 0);
3710                alc_update_coef_idx(codec, 0x33, 1<<11, 1<<11);
3711                alc_update_coef_idx(codec, 0x4a, 3<<4, 2<<4);
3712                msleep(30);
3713        }
3714
3715        alc_update_coef_idx(codec, 0x4a, 3 << 10, 0);
3716        alc_enable_headset_jack_key(codec);
3717}
3718
3719static void alc_default_init(struct hda_codec *codec)
3720{
3721        struct alc_spec *spec = codec->spec;
3722        hda_nid_t hp_pin = alc_get_hp_pin(spec);
3723        bool hp_pin_sense;
3724
3725        if (!hp_pin)
3726                return;
3727
3728        msleep(30);
3729
3730        hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3731
3732        if (hp_pin_sense)
3733                msleep(2);
3734
3735        snd_hda_codec_write(codec, hp_pin, 0,
3736                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3737
3738        if (hp_pin_sense)
3739                msleep(85);
3740
3741        snd_hda_codec_write(codec, hp_pin, 0,
3742                            AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
3743
3744        if (hp_pin_sense)
3745                msleep(100);
3746}
3747
3748static void alc_default_shutup(struct hda_codec *codec)
3749{
3750        struct alc_spec *spec = codec->spec;
3751        hda_nid_t hp_pin = alc_get_hp_pin(spec);
3752        bool hp_pin_sense;
3753
3754        if (!hp_pin) {
3755                alc269_shutup(codec);
3756                return;
3757        }
3758
3759        hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
3760
3761        if (hp_pin_sense)
3762                msleep(2);
3763
3764        snd_hda_codec_write(codec, hp_pin, 0,
3765                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3766
3767        if (hp_pin_sense)
3768                msleep(85);
3769
3770        if (!spec->no_shutup_pins)
3771                snd_hda_codec_write(codec, hp_pin, 0,
3772                                    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3773
3774        if (hp_pin_sense)
3775                msleep(100);
3776
3777        alc_auto_setup_eapd(codec, false);
3778        alc_shutup_pins(codec);
3779}
3780
3781static void alc294_hp_init(struct hda_codec *codec)
3782{
3783        struct alc_spec *spec = codec->spec;
3784        hda_nid_t hp_pin = alc_get_hp_pin(spec);
3785        int i, val;
3786
3787        if (!hp_pin)
3788                return;
3789
3790        snd_hda_codec_write(codec, hp_pin, 0,
3791                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
3792
3793        msleep(100);
3794
3795        if (!spec->no_shutup_pins)
3796                snd_hda_codec_write(codec, hp_pin, 0,
3797                                    AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
3798
3799        alc_update_coef_idx(codec, 0x6f, 0x000f, 0);/* Set HP depop to manual mode */
3800        alc_update_coefex_idx(codec, 0x58, 0x00, 0x8000, 0x8000); /* HP depop procedure start */
3801
3802        /* Wait for depop procedure finish  */
3803        val = alc_read_coefex_idx(codec, 0x58, 0x01);
3804        for (i = 0; i < 20 && val & 0x0080; i++) {
3805                msleep(50);
3806                val = alc_read_coefex_idx(codec, 0x58, 0x01);
3807        }
3808        /* Set HP depop to auto mode */
3809        alc_update_coef_idx(codec, 0x6f, 0x000f, 0x000b);
3810        msleep(50);
3811}
3812
3813static void alc294_init(struct hda_codec *codec)
3814{
3815        struct alc_spec *spec = codec->spec;
3816
3817        /* required only at boot or S4 resume time */
3818        if (!spec->done_hp_init ||
3819            codec->core.dev.power.power_state.event == PM_EVENT_RESTORE) {
3820                alc294_hp_init(codec);
3821                spec->done_hp_init = true;
3822        }
3823        alc_default_init(codec);
3824}
3825
3826static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
3827                             unsigned int val)
3828{
3829        snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3830        snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
3831        snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
3832}
3833
3834static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
3835{
3836        unsigned int val;
3837
3838        snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
3839        val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3840                & 0xffff;
3841        val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
3842                << 16;
3843        return val;
3844}
3845
3846static void alc5505_dsp_halt(struct hda_codec *codec)
3847{
3848        unsigned int val;
3849
3850        alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
3851        alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
3852        alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
3853        alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
3854        alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
3855        alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
3856        alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
3857        val = alc5505_coef_get(codec, 0x6220);
3858        alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
3859}
3860
3861static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
3862{
3863        alc5505_coef_set(codec, 0x61b8, 0x04133302);
3864        alc5505_coef_set(codec, 0x61b0, 0x00005b16);
3865        alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
3866        alc5505_coef_set(codec, 0x6230, 0xf80d4011);
3867        alc5505_coef_set(codec, 0x6220, 0x2002010f);
3868        alc5505_coef_set(codec, 0x880c, 0x00000004);
3869}
3870
3871static void alc5505_dsp_init(struct hda_codec *codec)
3872{
3873        unsigned int val;
3874
3875        alc5505_dsp_halt(codec);
3876        alc5505_dsp_back_from_halt(codec);
3877        alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
3878        alc5505_coef_set(codec, 0x61b0, 0x5b16);
3879        alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
3880        alc5505_coef_set(codec, 0x61b4, 0x04132b02);
3881        alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
3882        alc5505_coef_set(codec, 0x61b8, 0x041f3302);
3883        snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
3884        alc5505_coef_set(codec, 0x61b8, 0x041b3302);
3885        alc5505_coef_set(codec, 0x61b8, 0x04173302);
3886        alc5505_coef_set(codec, 0x61b8, 0x04163302);
3887        alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
3888        alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
3889        alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
3890
3891        val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
3892        if (val <= 3)
3893                alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
3894        else
3895                alc5505_coef_set(codec, 0x6220, 0x6002018f);
3896
3897        alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
3898        alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
3899        alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
3900        alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
3901        alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
3902        alc5505_coef_set(codec, 0x880c, 0x00000003);
3903        alc5505_coef_set(codec, 0x880c, 0x00000010);
3904
3905#ifdef HALT_REALTEK_ALC5505
3906        alc5505_dsp_halt(codec);
3907#endif
3908}
3909
3910#ifdef HALT_REALTEK_ALC5505
3911#define alc5505_dsp_suspend(codec)      do { } while (0) /* NOP */
3912#define alc5505_dsp_resume(codec)       do { } while (0) /* NOP */
3913#else
3914#define alc5505_dsp_suspend(codec)      alc5505_dsp_halt(codec)
3915#define alc5505_dsp_resume(codec)       alc5505_dsp_back_from_halt(codec)
3916#endif
3917
3918#ifdef CONFIG_PM
3919static int alc269_suspend(struct hda_codec *codec)
3920{
3921        struct alc_spec *spec = codec->spec;
3922
3923        if (spec->has_alc5505_dsp)
3924                alc5505_dsp_suspend(codec);
3925        return alc_suspend(codec);
3926}
3927
3928static int alc269_resume(struct hda_codec *codec)
3929{
3930        struct alc_spec *spec = codec->spec;
3931
3932        if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3933                alc269vb_toggle_power_output(codec, 0);
3934        if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3935                        (alc_get_coef0(codec) & 0x00ff) == 0x018) {
3936                msleep(150);
3937        }
3938
3939        codec->patch_ops.init(codec);
3940
3941        if (spec->codec_variant == ALC269_TYPE_ALC269VB)
3942                alc269vb_toggle_power_output(codec, 1);
3943        if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
3944                        (alc_get_coef0(codec) & 0x00ff) == 0x017) {
3945                msleep(200);
3946        }
3947
3948        snd_hda_regmap_sync(codec);
3949        hda_call_check_power_status(codec, 0x01);
3950
3951        /* on some machine, the BIOS will clear the codec gpio data when enter
3952         * suspend, and won't restore the data after resume, so we restore it
3953         * in the driver.
3954         */
3955        if (spec->gpio_data)
3956                alc_write_gpio_data(codec);
3957
3958        if (spec->has_alc5505_dsp)
3959                alc5505_dsp_resume(codec);
3960
3961        return 0;
3962}
3963#endif /* CONFIG_PM */
3964
3965static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
3966                                                 const struct hda_fixup *fix, int action)
3967{
3968        struct alc_spec *spec = codec->spec;
3969
3970        if (action == HDA_FIXUP_ACT_PRE_PROBE)
3971                spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
3972}
3973
3974static void alc269_fixup_pincfg_U7x7_headset_mic(struct hda_codec *codec,
3975                                                 const struct hda_fixup *fix,
3976                                                 int action)
3977{
3978        unsigned int cfg_headphone = snd_hda_codec_get_pincfg(codec, 0x21);
3979        unsigned int cfg_headset_mic = snd_hda_codec_get_pincfg(codec, 0x19);
3980
3981        if (cfg_headphone && cfg_headset_mic == 0x411111f0)
3982                snd_hda_codec_set_pincfg(codec, 0x19,
3983                        (cfg_headphone & ~AC_DEFCFG_DEVICE) |
3984                        (AC_JACK_MIC_IN << AC_DEFCFG_DEVICE_SHIFT));
3985}
3986
3987static void alc269_fixup_hweq(struct hda_codec *codec,
3988                               const struct hda_fixup *fix, int action)
3989{
3990        if (action == HDA_FIXUP_ACT_INIT)
3991                alc_update_coef_idx(codec, 0x1e, 0, 0x80);
3992}
3993
3994static void alc269_fixup_headset_mic(struct hda_codec *codec,
3995                                       const struct hda_fixup *fix, int action)
3996{
3997        struct alc_spec *spec = codec->spec;
3998
3999        if (action == HDA_FIXUP_ACT_PRE_PROBE)
4000                spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4001}
4002
4003static void alc271_fixup_dmic(struct hda_codec *codec,
4004                              const struct hda_fixup *fix, int action)
4005{
4006        static const struct hda_verb verbs[] = {
4007                {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
4008                {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
4009                {}
4010        };
4011        unsigned int cfg;
4012
4013        if (strcmp(codec->core.chip_name, "ALC271X") &&
4014            strcmp(codec->core.chip_name, "ALC269VB"))
4015                return;
4016        cfg = snd_hda_codec_get_pincfg(codec, 0x12);
4017        if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
4018                snd_hda_sequence_write(codec, verbs);
4019}
4020
4021/* Fix the speaker amp after resume, etc */
4022static void alc269vb_fixup_aspire_e1_coef(struct hda_codec *codec,
4023                                          const struct hda_fixup *fix,
4024                                          int action)
4025{
4026        if (action == HDA_FIXUP_ACT_INIT)
4027                alc_update_coef_idx(codec, 0x0d, 0x6000, 0x6000);
4028}
4029
4030static void alc269_fixup_pcm_44k(struct hda_codec *codec,
4031                                 const struct hda_fixup *fix, int action)
4032{
4033        struct alc_spec *spec = codec->spec;
4034
4035        if (action != HDA_FIXUP_ACT_PROBE)
4036                return;
4037
4038        /* Due to a hardware problem on Lenovo Ideadpad, we need to
4039         * fix the sample rate of analog I/O to 44.1kHz
4040         */
4041        spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
4042        spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
4043}
4044
4045static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
4046                                     const struct hda_fixup *fix, int action)
4047{
4048        /* The digital-mic unit sends PDM (differential signal) instead of
4049         * the standard PCM, thus you can't record a valid mono stream as is.
4050         * Below is a workaround specific to ALC269 to control the dmic
4051         * signal source as mono.
4052         */
4053        if (action == HDA_FIXUP_ACT_INIT)
4054                alc_update_coef_idx(codec, 0x07, 0, 0x80);
4055}
4056
4057static void alc269_quanta_automute(struct hda_codec *codec)
4058{
4059        snd_hda_gen_update_outputs(codec);
4060
4061        alc_write_coef_idx(codec, 0x0c, 0x680);
4062        alc_write_coef_idx(codec, 0x0c, 0x480);
4063}
4064
4065static void alc269_fixup_quanta_mute(struct hda_codec *codec,
4066                                     const struct hda_fixup *fix, int action)
4067{
4068        struct alc_spec *spec = codec->spec;
4069        if (action != HDA_FIXUP_ACT_PROBE)
4070                return;
4071        spec->gen.automute_hook = alc269_quanta_automute;
4072}
4073
4074static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
4075                                         struct hda_jack_callback *jack)
4076{
4077        struct alc_spec *spec = codec->spec;
4078        int vref;
4079        msleep(200);
4080        snd_hda_gen_hp_automute(codec, jack);
4081
4082        vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
4083        msleep(100);
4084        snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4085                            vref);
4086        msleep(500);
4087        snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4088                            vref);
4089}
4090
4091/*
4092 * Magic sequence to make Huawei Matebook X right speaker working (bko#197801)
4093 */
4094struct hda_alc298_mbxinit {
4095        unsigned char value_0x23;
4096        unsigned char value_0x25;
4097};
4098
4099static void alc298_huawei_mbx_stereo_seq(struct hda_codec *codec,
4100                                         const struct hda_alc298_mbxinit *initval,
4101                                         bool first)
4102{
4103        snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x0);
4104        alc_write_coef_idx(codec, 0x26, 0xb000);
4105
4106        if (first)
4107                snd_hda_codec_write(codec, 0x21, 0, AC_VERB_GET_PIN_SENSE, 0x0);
4108
4109        snd_hda_codec_write(codec, 0x6, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4110        alc_write_coef_idx(codec, 0x26, 0xf000);
4111        alc_write_coef_idx(codec, 0x23, initval->value_0x23);
4112
4113        if (initval->value_0x23 != 0x1e)
4114                alc_write_coef_idx(codec, 0x25, initval->value_0x25);
4115
4116        snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4117        snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4118}
4119
4120static void alc298_fixup_huawei_mbx_stereo(struct hda_codec *codec,
4121                                           const struct hda_fixup *fix,
4122                                           int action)
4123{
4124        /* Initialization magic */
4125        static const struct hda_alc298_mbxinit dac_init[] = {
4126                {0x0c, 0x00}, {0x0d, 0x00}, {0x0e, 0x00}, {0x0f, 0x00},
4127                {0x10, 0x00}, {0x1a, 0x40}, {0x1b, 0x82}, {0x1c, 0x00},
4128                {0x1d, 0x00}, {0x1e, 0x00}, {0x1f, 0x00},
4129                {0x20, 0xc2}, {0x21, 0xc8}, {0x22, 0x26}, {0x23, 0x24},
4130                {0x27, 0xff}, {0x28, 0xff}, {0x29, 0xff}, {0x2a, 0x8f},
4131                {0x2b, 0x02}, {0x2c, 0x48}, {0x2d, 0x34}, {0x2e, 0x00},
4132                {0x2f, 0x00},
4133                {0x30, 0x00}, {0x31, 0x00}, {0x32, 0x00}, {0x33, 0x00},
4134                {0x34, 0x00}, {0x35, 0x01}, {0x36, 0x93}, {0x37, 0x0c},
4135                {0x38, 0x00}, {0x39, 0x00}, {0x3a, 0xf8}, {0x38, 0x80},
4136                {}
4137        };
4138        const struct hda_alc298_mbxinit *seq;
4139
4140        if (action != HDA_FIXUP_ACT_INIT)
4141                return;
4142
4143        /* Start */
4144        snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x00);
4145        snd_hda_codec_write(codec, 0x06, 0, AC_VERB_SET_DIGI_CONVERT_3, 0x80);
4146        alc_write_coef_idx(codec, 0x26, 0xf000);
4147        alc_write_coef_idx(codec, 0x22, 0x31);
4148        alc_write_coef_idx(codec, 0x23, 0x0b);
4149        alc_write_coef_idx(codec, 0x25, 0x00);
4150        snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0x26);
4151        snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, 0xb010);
4152
4153        for (seq = dac_init; seq->value_0x23; seq++)
4154                alc298_huawei_mbx_stereo_seq(codec, seq, seq == dac_init);
4155}
4156
4157static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
4158                                     const struct hda_fixup *fix, int action)
4159{
4160        struct alc_spec *spec = codec->spec;
4161        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4162                spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
4163                spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
4164        }
4165}
4166
4167static void alc_update_vref_led(struct hda_codec *codec, hda_nid_t pin,
4168                                bool polarity, bool on)
4169{
4170        unsigned int pinval;
4171
4172        if (!pin)
4173                return;
4174        if (polarity)
4175                on = !on;
4176        pinval = snd_hda_codec_get_pin_target(codec, pin);
4177        pinval &= ~AC_PINCTL_VREFEN;
4178        pinval |= on ? AC_PINCTL_VREF_80 : AC_PINCTL_VREF_HIZ;
4179        /* temporarily power up/down for setting VREF */
4180        snd_hda_power_up_pm(codec);
4181        snd_hda_set_pin_ctl_cache(codec, pin, pinval);
4182        snd_hda_power_down_pm(codec);
4183}
4184
4185/* update mute-LED according to the speaker mute state via mic VREF pin */
4186static int vref_mute_led_set(struct led_classdev *led_cdev,
4187                             enum led_brightness brightness)
4188{
4189        struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4190        struct alc_spec *spec = codec->spec;
4191
4192        alc_update_vref_led(codec, spec->mute_led_nid,
4193                            spec->mute_led_polarity, brightness);
4194        return 0;
4195}
4196
4197/* Make sure the led works even in runtime suspend */
4198static unsigned int led_power_filter(struct hda_codec *codec,
4199                                                  hda_nid_t nid,
4200                                                  unsigned int power_state)
4201{
4202        struct alc_spec *spec = codec->spec;
4203
4204        if (power_state != AC_PWRST_D3 || nid == 0 ||
4205            (nid != spec->mute_led_nid && nid != spec->cap_mute_led_nid))
4206                return power_state;
4207
4208        /* Set pin ctl again, it might have just been set to 0 */
4209        snd_hda_set_pin_ctl(codec, nid,
4210                            snd_hda_codec_get_pin_target(codec, nid));
4211
4212        return snd_hda_gen_path_power_filter(codec, nid, power_state);
4213}
4214
4215static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
4216                                     const struct hda_fixup *fix, int action)
4217{
4218        struct alc_spec *spec = codec->spec;
4219        const struct dmi_device *dev = NULL;
4220
4221        if (action != HDA_FIXUP_ACT_PRE_PROBE)
4222                return;
4223
4224        while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
4225                int pol, pin;
4226                if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
4227                        continue;
4228                if (pin < 0x0a || pin >= 0x10)
4229                        break;
4230                spec->mute_led_polarity = pol;
4231                spec->mute_led_nid = pin - 0x0a + 0x18;
4232                snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set);
4233                codec->power_filter = led_power_filter;
4234                codec_dbg(codec,
4235                          "Detected mute LED for %x:%d\n", spec->mute_led_nid,
4236                           spec->mute_led_polarity);
4237                break;
4238        }
4239}
4240
4241static void alc269_fixup_hp_mute_led_micx(struct hda_codec *codec,
4242                                          const struct hda_fixup *fix,
4243                                          int action, hda_nid_t pin)
4244{
4245        struct alc_spec *spec = codec->spec;
4246
4247        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4248                spec->mute_led_polarity = 0;
4249                spec->mute_led_nid = pin;
4250                snd_hda_gen_add_mute_led_cdev(codec, vref_mute_led_set);
4251                codec->power_filter = led_power_filter;
4252        }
4253}
4254
4255static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
4256                                const struct hda_fixup *fix, int action)
4257{
4258        alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x18);
4259}
4260
4261static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
4262                                const struct hda_fixup *fix, int action)
4263{
4264        alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x19);
4265}
4266
4267static void alc269_fixup_hp_mute_led_mic3(struct hda_codec *codec,
4268                                const struct hda_fixup *fix, int action)
4269{
4270        alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1b);
4271}
4272
4273/* update LED status via GPIO */
4274static void alc_update_gpio_led(struct hda_codec *codec, unsigned int mask,
4275                                int polarity, bool enabled)
4276{
4277        if (polarity)
4278                enabled = !enabled;
4279        alc_update_gpio_data(codec, mask, !enabled); /* muted -> LED on */
4280}
4281
4282/* turn on/off mute LED via GPIO per vmaster hook */
4283static int gpio_mute_led_set(struct led_classdev *led_cdev,
4284                             enum led_brightness brightness)
4285{
4286        struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4287        struct alc_spec *spec = codec->spec;
4288
4289        alc_update_gpio_led(codec, spec->gpio_mute_led_mask,
4290                            spec->mute_led_polarity, !brightness);
4291        return 0;
4292}
4293
4294/* turn on/off mic-mute LED via GPIO per capture hook */
4295static int micmute_led_set(struct led_classdev *led_cdev,
4296                           enum led_brightness brightness)
4297{
4298        struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4299        struct alc_spec *spec = codec->spec;
4300
4301        alc_update_gpio_led(codec, spec->gpio_mic_led_mask,
4302                            spec->micmute_led_polarity, !brightness);
4303        return 0;
4304}
4305
4306/* setup mute and mic-mute GPIO bits, add hooks appropriately */
4307static void alc_fixup_hp_gpio_led(struct hda_codec *codec,
4308                                  int action,
4309                                  unsigned int mute_mask,
4310                                  unsigned int micmute_mask)
4311{
4312        struct alc_spec *spec = codec->spec;
4313
4314        alc_fixup_gpio(codec, action, mute_mask | micmute_mask);
4315
4316        if (action != HDA_FIXUP_ACT_PRE_PROBE)
4317                return;
4318        if (mute_mask) {
4319                spec->gpio_mute_led_mask = mute_mask;
4320                snd_hda_gen_add_mute_led_cdev(codec, gpio_mute_led_set);
4321        }
4322        if (micmute_mask) {
4323                spec->gpio_mic_led_mask = micmute_mask;
4324                snd_hda_gen_add_micmute_led_cdev(codec, micmute_led_set);
4325        }
4326}
4327
4328static void alc236_fixup_hp_gpio_led(struct hda_codec *codec,
4329                                const struct hda_fixup *fix, int action)
4330{
4331        alc_fixup_hp_gpio_led(codec, action, 0x02, 0x01);
4332}
4333
4334static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
4335                                const struct hda_fixup *fix, int action)
4336{
4337        alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4338}
4339
4340static void alc285_fixup_hp_gpio_led(struct hda_codec *codec,
4341                                const struct hda_fixup *fix, int action)
4342{
4343        alc_fixup_hp_gpio_led(codec, action, 0x04, 0x01);
4344}
4345
4346static void alc286_fixup_hp_gpio_led(struct hda_codec *codec,
4347                                const struct hda_fixup *fix, int action)
4348{
4349        alc_fixup_hp_gpio_led(codec, action, 0x02, 0x20);
4350}
4351
4352static void alc287_fixup_hp_gpio_led(struct hda_codec *codec,
4353                                const struct hda_fixup *fix, int action)
4354{
4355        alc_fixup_hp_gpio_led(codec, action, 0x10, 0);
4356}
4357
4358/* turn on/off mic-mute LED per capture hook via VREF change */
4359static int vref_micmute_led_set(struct led_classdev *led_cdev,
4360                                enum led_brightness brightness)
4361{
4362        struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4363        struct alc_spec *spec = codec->spec;
4364
4365        alc_update_vref_led(codec, spec->cap_mute_led_nid,
4366                            spec->micmute_led_polarity, brightness);
4367        return 0;
4368}
4369
4370static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
4371                                const struct hda_fixup *fix, int action)
4372{
4373        struct alc_spec *spec = codec->spec;
4374
4375        alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4376        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4377                /* Like hp_gpio_mic1_led, but also needs GPIO4 low to
4378                 * enable headphone amp
4379                 */
4380                spec->gpio_mask |= 0x10;
4381                spec->gpio_dir |= 0x10;
4382                spec->cap_mute_led_nid = 0x18;
4383                snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4384                codec->power_filter = led_power_filter;
4385        }
4386}
4387
4388static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
4389                                   const struct hda_fixup *fix, int action)
4390{
4391        struct alc_spec *spec = codec->spec;
4392
4393        alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
4394        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4395                spec->cap_mute_led_nid = 0x18;
4396                snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4397                codec->power_filter = led_power_filter;
4398        }
4399}
4400
4401/* HP Spectre x360 14 model needs a unique workaround for enabling the amp;
4402 * it needs to toggle the GPIO0 once on and off at each time (bko#210633)
4403 */
4404static void alc245_fixup_hp_x360_amp(struct hda_codec *codec,
4405                                     const struct hda_fixup *fix, int action)
4406{
4407        struct alc_spec *spec = codec->spec;
4408
4409        switch (action) {
4410        case HDA_FIXUP_ACT_PRE_PROBE:
4411                spec->gpio_mask |= 0x01;
4412                spec->gpio_dir |= 0x01;
4413                break;
4414        case HDA_FIXUP_ACT_INIT:
4415                /* need to toggle GPIO to enable the amp */
4416                alc_update_gpio_data(codec, 0x01, true);
4417                msleep(100);
4418                alc_update_gpio_data(codec, 0x01, false);
4419                break;
4420        }
4421}
4422
4423/* toggle GPIO2 at each time stream is started; we use PREPARE state instead */
4424static void alc274_hp_envy_pcm_hook(struct hda_pcm_stream *hinfo,
4425                                    struct hda_codec *codec,
4426                                    struct snd_pcm_substream *substream,
4427                                    int action)
4428{
4429        switch (action) {
4430        case HDA_GEN_PCM_ACT_PREPARE:
4431                alc_update_gpio_data(codec, 0x04, true);
4432                break;
4433        case HDA_GEN_PCM_ACT_CLEANUP:
4434                alc_update_gpio_data(codec, 0x04, false);
4435                break;
4436        }
4437}
4438
4439static void alc274_fixup_hp_envy_gpio(struct hda_codec *codec,
4440                                      const struct hda_fixup *fix,
4441                                      int action)
4442{
4443        struct alc_spec *spec = codec->spec;
4444
4445        if (action == HDA_FIXUP_ACT_PROBE) {
4446                spec->gpio_mask |= 0x04;
4447                spec->gpio_dir |= 0x04;
4448                spec->gen.pcm_playback_hook = alc274_hp_envy_pcm_hook;
4449        }
4450}
4451
4452static void alc_update_coef_led(struct hda_codec *codec,
4453                                struct alc_coef_led *led,
4454                                bool polarity, bool on)
4455{
4456        if (polarity)
4457                on = !on;
4458        /* temporarily power up/down for setting COEF bit */
4459        alc_update_coef_idx(codec, led->idx, led->mask,
4460                            on ? led->on : led->off);
4461}
4462
4463/* update mute-LED according to the speaker mute state via COEF bit */
4464static int coef_mute_led_set(struct led_classdev *led_cdev,
4465                             enum led_brightness brightness)
4466{
4467        struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4468        struct alc_spec *spec = codec->spec;
4469
4470        alc_update_coef_led(codec, &spec->mute_led_coef,
4471                            spec->mute_led_polarity, brightness);
4472        return 0;
4473}
4474
4475static void alc285_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4476                                          const struct hda_fixup *fix,
4477                                          int action)
4478{
4479        struct alc_spec *spec = codec->spec;
4480
4481        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4482                spec->mute_led_polarity = 0;
4483                spec->mute_led_coef.idx = 0x0b;
4484                spec->mute_led_coef.mask = 1 << 3;
4485                spec->mute_led_coef.on = 1 << 3;
4486                spec->mute_led_coef.off = 0;
4487                snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4488        }
4489}
4490
4491static void alc236_fixup_hp_mute_led_coefbit(struct hda_codec *codec,
4492                                          const struct hda_fixup *fix,
4493                                          int action)
4494{
4495        struct alc_spec *spec = codec->spec;
4496
4497        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4498                spec->mute_led_polarity = 0;
4499                spec->mute_led_coef.idx = 0x34;
4500                spec->mute_led_coef.mask = 1 << 5;
4501                spec->mute_led_coef.on = 0;
4502                spec->mute_led_coef.off = 1 << 5;
4503                snd_hda_gen_add_mute_led_cdev(codec, coef_mute_led_set);
4504        }
4505}
4506
4507/* turn on/off mic-mute LED per capture hook by coef bit */
4508static int coef_micmute_led_set(struct led_classdev *led_cdev,
4509                                enum led_brightness brightness)
4510{
4511        struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
4512        struct alc_spec *spec = codec->spec;
4513
4514        alc_update_coef_led(codec, &spec->mic_led_coef,
4515                            spec->micmute_led_polarity, brightness);
4516        return 0;
4517}
4518
4519static void alc285_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4520                                const struct hda_fixup *fix, int action)
4521{
4522        struct alc_spec *spec = codec->spec;
4523
4524        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4525                spec->mic_led_coef.idx = 0x19;
4526                spec->mic_led_coef.mask = 1 << 13;
4527                spec->mic_led_coef.on = 1 << 13;
4528                spec->mic_led_coef.off = 0;
4529                snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
4530        }
4531}
4532
4533static void alc236_fixup_hp_coef_micmute_led(struct hda_codec *codec,
4534                                const struct hda_fixup *fix, int action)
4535{
4536        struct alc_spec *spec = codec->spec;
4537
4538        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4539                spec->mic_led_coef.idx = 0x35;
4540                spec->mic_led_coef.mask = 3 << 2;
4541                spec->mic_led_coef.on = 2 << 2;
4542                spec->mic_led_coef.off = 1 << 2;
4543                snd_hda_gen_add_micmute_led_cdev(codec, coef_micmute_led_set);
4544        }
4545}
4546
4547static void alc285_fixup_hp_mute_led(struct hda_codec *codec,
4548                                const struct hda_fixup *fix, int action)
4549{
4550        alc285_fixup_hp_mute_led_coefbit(codec, fix, action);
4551        alc285_fixup_hp_coef_micmute_led(codec, fix, action);
4552}
4553
4554static void alc236_fixup_hp_mute_led(struct hda_codec *codec,
4555                                const struct hda_fixup *fix, int action)
4556{
4557        alc236_fixup_hp_mute_led_coefbit(codec, fix, action);
4558        alc236_fixup_hp_coef_micmute_led(codec, fix, action);
4559}
4560
4561static void alc236_fixup_hp_micmute_led_vref(struct hda_codec *codec,
4562                                const struct hda_fixup *fix, int action)
4563{
4564        struct alc_spec *spec = codec->spec;
4565
4566        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4567                spec->cap_mute_led_nid = 0x1a;
4568                snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4569                codec->power_filter = led_power_filter;
4570        }
4571}
4572
4573static void alc236_fixup_hp_mute_led_micmute_vref(struct hda_codec *codec,
4574                                const struct hda_fixup *fix, int action)
4575{
4576        alc236_fixup_hp_mute_led_coefbit(codec, fix, action);
4577        alc236_fixup_hp_micmute_led_vref(codec, fix, action);
4578}
4579
4580#if IS_REACHABLE(CONFIG_INPUT)
4581static void gpio2_mic_hotkey_event(struct hda_codec *codec,
4582                                   struct hda_jack_callback *event)
4583{
4584        struct alc_spec *spec = codec->spec;
4585
4586        /* GPIO2 just toggles on a keypress/keyrelease cycle. Therefore
4587           send both key on and key off event for every interrupt. */
4588        input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 1);
4589        input_sync(spec->kb_dev);
4590        input_report_key(spec->kb_dev, spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX], 0);
4591        input_sync(spec->kb_dev);
4592}
4593
4594static int alc_register_micmute_input_device(struct hda_codec *codec)
4595{
4596        struct alc_spec *spec = codec->spec;
4597        int i;
4598
4599        spec->kb_dev = input_allocate_device();
4600        if (!spec->kb_dev) {
4601                codec_err(codec, "Out of memory (input_allocate_device)\n");
4602                return -ENOMEM;
4603        }
4604
4605        spec->alc_mute_keycode_map[ALC_KEY_MICMUTE_INDEX] = KEY_MICMUTE;
4606
4607        spec->kb_dev->name = "Microphone Mute Button";
4608        spec->kb_dev->evbit[0] = BIT_MASK(EV_KEY);
4609        spec->kb_dev->keycodesize = sizeof(spec->alc_mute_keycode_map[0]);
4610        spec->kb_dev->keycodemax = ARRAY_SIZE(spec->alc_mute_keycode_map);
4611        spec->kb_dev->keycode = spec->alc_mute_keycode_map;
4612        for (i = 0; i < ARRAY_SIZE(spec->alc_mute_keycode_map); i++)
4613                set_bit(spec->alc_mute_keycode_map[i], spec->kb_dev->keybit);
4614
4615        if (input_register_device(spec->kb_dev)) {
4616                codec_err(codec, "input_register_device failed\n");
4617                input_free_device(spec->kb_dev);
4618                spec->kb_dev = NULL;
4619                return -ENOMEM;
4620        }
4621
4622        return 0;
4623}
4624
4625/* GPIO1 = set according to SKU external amp
4626 * GPIO2 = mic mute hotkey
4627 * GPIO3 = mute LED
4628 * GPIO4 = mic mute LED
4629 */
4630static void alc280_fixup_hp_gpio2_mic_hotkey(struct hda_codec *codec,
4631                                             const struct hda_fixup *fix, int action)
4632{
4633        struct alc_spec *spec = codec->spec;
4634
4635        alc_fixup_hp_gpio_led(codec, action, 0x08, 0x10);
4636        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4637                spec->init_amp = ALC_INIT_DEFAULT;
4638                if (alc_register_micmute_input_device(codec) != 0)
4639                        return;
4640
4641                spec->gpio_mask |= 0x06;
4642                spec->gpio_dir |= 0x02;
4643                spec->gpio_data |= 0x02;
4644                snd_hda_codec_write_cache(codec, codec->core.afg, 0,
4645                                          AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x04);
4646                snd_hda_jack_detect_enable_callback(codec, codec->core.afg,
4647                                                    gpio2_mic_hotkey_event);
4648                return;
4649        }
4650
4651        if (!spec->kb_dev)
4652                return;
4653
4654        switch (action) {
4655        case HDA_FIXUP_ACT_FREE:
4656                input_unregister_device(spec->kb_dev);
4657                spec->kb_dev = NULL;
4658        }
4659}
4660
4661/* Line2 = mic mute hotkey
4662 * GPIO2 = mic mute LED
4663 */
4664static void alc233_fixup_lenovo_line2_mic_hotkey(struct hda_codec *codec,
4665                                             const struct hda_fixup *fix, int action)
4666{
4667        struct alc_spec *spec = codec->spec;
4668
4669        alc_fixup_hp_gpio_led(codec, action, 0, 0x04);
4670        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4671                spec->init_amp = ALC_INIT_DEFAULT;
4672                if (alc_register_micmute_input_device(codec) != 0)
4673                        return;
4674
4675                snd_hda_jack_detect_enable_callback(codec, 0x1b,
4676                                                    gpio2_mic_hotkey_event);
4677                return;
4678        }
4679
4680        if (!spec->kb_dev)
4681                return;
4682
4683        switch (action) {
4684        case HDA_FIXUP_ACT_FREE:
4685                input_unregister_device(spec->kb_dev);
4686                spec->kb_dev = NULL;
4687        }
4688}
4689#else /* INPUT */
4690#define alc280_fixup_hp_gpio2_mic_hotkey        NULL
4691#define alc233_fixup_lenovo_line2_mic_hotkey    NULL
4692#endif /* INPUT */
4693
4694static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
4695                                const struct hda_fixup *fix, int action)
4696{
4697        struct alc_spec *spec = codec->spec;
4698
4699        alc269_fixup_hp_mute_led_micx(codec, fix, action, 0x1a);
4700        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
4701                spec->cap_mute_led_nid = 0x18;
4702                snd_hda_gen_add_micmute_led_cdev(codec, vref_micmute_led_set);
4703        }
4704}
4705
4706static const struct coef_fw alc225_pre_hsmode[] = {
4707        UPDATE_COEF(0x4a, 1<<8, 0),
4708        UPDATE_COEFEX(0x57, 0x05, 1<<14, 0),
4709        UPDATE_COEF(0x63, 3<<14, 3<<14),
4710        UPDATE_COEF(0x4a, 3<<4, 2<<4),
4711        UPDATE_COEF(0x4a, 3<<10, 3<<10),
4712        UPDATE_COEF(0x45, 0x3f<<10, 0x34<<10),
4713        UPDATE_COEF(0x4a, 3<<10, 0),
4714        {}
4715};
4716
4717static void alc_headset_mode_unplugged(struct hda_codec *codec)
4718{
4719        struct alc_spec *spec = codec->spec;
4720        static const struct coef_fw coef0255[] = {
4721                WRITE_COEF(0x1b, 0x0c0b), /* LDO and MISC control */
4722                WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4723                UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4724                WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4725                WRITE_COEFEX(0x57, 0x03, 0x8aa6), /* Direct Drive HP Amp control */
4726                {}
4727        };
4728        static const struct coef_fw coef0256[] = {
4729                WRITE_COEF(0x1b, 0x0c4b), /* LDO and MISC control */
4730                WRITE_COEF(0x45, 0xd089), /* UAJ function set to menual mode */
4731                WRITE_COEF(0x06, 0x6104), /* Set MIC2 Vref gate with HP */
4732                WRITE_COEFEX(0x57, 0x03, 0x09a3), /* Direct Drive HP Amp control */
4733                UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
4734                {}
4735        };
4736        static const struct coef_fw coef0233[] = {
4737                WRITE_COEF(0x1b, 0x0c0b),
4738                WRITE_COEF(0x45, 0xc429),
4739                UPDATE_COEF(0x35, 0x4000, 0),
4740                WRITE_COEF(0x06, 0x2104),
4741                WRITE_COEF(0x1a, 0x0001),
4742                WRITE_COEF(0x26, 0x0004),
4743                WRITE_COEF(0x32, 0x42a3),
4744                {}
4745        };
4746        static const struct coef_fw coef0288[] = {
4747                UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4748                UPDATE_COEF(0x50, 0x2000, 0x2000),
4749                UPDATE_COEF(0x56, 0x0006, 0x0006),
4750                UPDATE_COEF(0x66, 0x0008, 0),
4751                UPDATE_COEF(0x67, 0x2000, 0),
4752                {}
4753        };
4754        static const struct coef_fw coef0298[] = {
4755                UPDATE_COEF(0x19, 0x1300, 0x0300),
4756                {}
4757        };
4758        static const struct coef_fw coef0292[] = {
4759                WRITE_COEF(0x76, 0x000e),
4760                WRITE_COEF(0x6c, 0x2400),
4761                WRITE_COEF(0x18, 0x7308),
4762                WRITE_COEF(0x6b, 0xc429),
4763                {}
4764        };
4765        static const struct coef_fw coef0293[] = {
4766                UPDATE_COEF(0x10, 7<<8, 6<<8), /* SET Line1 JD to 0 */
4767                UPDATE_COEFEX(0x57, 0x05, 1<<15|1<<13, 0x0), /* SET charge pump by verb */
4768                UPDATE_COEFEX(0x57, 0x03, 1<<10, 1<<10), /* SET EN_OSW to 1 */
4769                UPDATE_COEF(0x1a, 1<<3, 1<<3), /* Combo JD gating with LINE1-VREFO */
4770                WRITE_COEF(0x45, 0xc429), /* Set to TRS type */
4771                UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
4772                {}
4773        };
4774        static const struct coef_fw coef0668[] = {
4775                WRITE_COEF(0x15, 0x0d40),
4776                WRITE_COEF(0xb7, 0x802b),
4777                {}
4778        };
4779        static const struct coef_fw coef0225[] = {
4780                UPDATE_COEF(0x63, 3<<14, 0),
4781                {}
4782        };
4783        static const struct coef_fw coef0274[] = {
4784                UPDATE_COEF(0x4a, 0x0100, 0),
4785                UPDATE_COEFEX(0x57, 0x05, 0x4000, 0),
4786                UPDATE_COEF(0x6b, 0xf000, 0x5000),
4787                UPDATE_COEF(0x4a, 0x0010, 0),
4788                UPDATE_COEF(0x4a, 0x0c00, 0x0c00),
4789                WRITE_COEF(0x45, 0x5289),
4790                UPDATE_COEF(0x4a, 0x0c00, 0),
4791                {}
4792        };
4793
4794        if (spec->no_internal_mic_pin) {
4795                alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
4796                return;
4797        }
4798
4799        switch (codec->core.vendor_id) {
4800        case 0x10ec0255:
4801                alc_process_coef_fw(codec, coef0255);
4802                break;
4803        case 0x10ec0230:
4804        case 0x10ec0236:
4805        case 0x10ec0256:
4806                alc_process_coef_fw(codec, coef0256);
4807                break;
4808        case 0x10ec0234:
4809        case 0x10ec0274:
4810        case 0x10ec0294:
4811                alc_process_coef_fw(codec, coef0274);
4812                break;
4813        case 0x10ec0233:
4814        case 0x10ec0283:
4815                alc_process_coef_fw(codec, coef0233);
4816                break;
4817        case 0x10ec0286:
4818        case 0x10ec0288:
4819                alc_process_coef_fw(codec, coef0288);
4820                break;
4821        case 0x10ec0298:
4822                alc_process_coef_fw(codec, coef0298);
4823                alc_process_coef_fw(codec, coef0288);
4824                break;
4825        case 0x10ec0292:
4826                alc_process_coef_fw(codec, coef0292);
4827                break;
4828        case 0x10ec0293:
4829                alc_process_coef_fw(codec, coef0293);
4830                break;
4831        case 0x10ec0668:
4832                alc_process_coef_fw(codec, coef0668);
4833                break;
4834        case 0x10ec0215:
4835        case 0x10ec0225:
4836        case 0x10ec0285:
4837        case 0x10ec0295:
4838        case 0x10ec0289:
4839        case 0x10ec0299:
4840                alc_process_coef_fw(codec, alc225_pre_hsmode);
4841                alc_process_coef_fw(codec, coef0225);
4842                break;
4843        case 0x10ec0867:
4844                alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
4845                break;
4846        }
4847        codec_dbg(codec, "Headset jack set to unplugged mode.\n");
4848}
4849
4850
4851static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
4852                                    hda_nid_t mic_pin)
4853{
4854        static const struct coef_fw coef0255[] = {
4855                WRITE_COEFEX(0x57, 0x03, 0x8aa6),
4856                WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
4857                {}
4858        };
4859        static const struct coef_fw coef0256[] = {
4860                UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14), /* Direct Drive HP Amp control(Set to verb control)*/
4861                WRITE_COEFEX(0x57, 0x03, 0x09a3),
4862                WRITE_COEF(0x06, 0x6100), /* Set MIC2 Vref gate to normal */
4863                {}
4864        };
4865        static const struct coef_fw coef0233[] = {
4866                UPDATE_COEF(0x35, 0, 1<<14),
4867                WRITE_COEF(0x06, 0x2100),
4868                WRITE_COEF(0x1a, 0x0021),
4869                WRITE_COEF(0x26, 0x008c),
4870                {}
4871        };
4872        static const struct coef_fw coef0288[] = {
4873                UPDATE_COEF(0x4f, 0x00c0, 0),
4874                UPDATE_COEF(0x50, 0x2000, 0),
4875                UPDATE_COEF(0x56, 0x0006, 0),
4876                UPDATE_COEF(0x4f, 0xfcc0, 0xc400),
4877                UPDATE_COEF(0x66, 0x0008, 0x0008),
4878                UPDATE_COEF(0x67, 0x2000, 0x2000),
4879                {}
4880        };
4881        static const struct coef_fw coef0292[] = {
4882                WRITE_COEF(0x19, 0xa208),
4883                WRITE_COEF(0x2e, 0xacf0),
4884                {}
4885        };
4886        static const struct coef_fw coef0293[] = {
4887                UPDATE_COEFEX(0x57, 0x05, 0, 1<<15|1<<13), /* SET charge pump by verb */
4888                UPDATE_COEFEX(0x57, 0x03, 1<<10, 0), /* SET EN_OSW to 0 */
4889                UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
4890                {}
4891        };
4892        static const struct coef_fw coef0688[] = {
4893                WRITE_COEF(0xb7, 0x802b),
4894                WRITE_COEF(0xb5, 0x1040),
4895                UPDATE_COEF(0xc3, 0, 1<<12),
4896                {}
4897        };
4898        static const struct coef_fw coef0225[] = {
4899                UPDATE_COEFEX(0x57, 0x05, 1<<14, 1<<14),
4900                UPDATE_COEF(0x4a, 3<<4, 2<<4),
4901                UPDATE_COEF(0x63, 3<<14, 0),
4902                {}
4903        };
4904        static const struct coef_fw coef0274[] = {
4905                UPDATE_COEFEX(0x57, 0x05, 0x4000, 0x4000),
4906                UPDATE_COEF(0x4a, 0x0010, 0),
4907                UPDATE_COEF(0x6b, 0xf000, 0),
4908                {}
4909        };
4910
4911        switch (codec->core.vendor_id) {
4912        case 0x10ec0255:
4913                alc_write_coef_idx(codec, 0x45, 0xc489);
4914                snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4915                alc_process_coef_fw(codec, coef0255);
4916                snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4917                break;
4918        case 0x10ec0230:
4919        case 0x10ec0236:
4920        case 0x10ec0256:
4921                alc_write_coef_idx(codec, 0x45, 0xc489);
4922                snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4923                alc_process_coef_fw(codec, coef0256);
4924                snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4925                break;
4926        case 0x10ec0234:
4927        case 0x10ec0274:
4928        case 0x10ec0294:
4929                alc_write_coef_idx(codec, 0x45, 0x4689);
4930                snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4931                alc_process_coef_fw(codec, coef0274);
4932                snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4933                break;
4934        case 0x10ec0233:
4935        case 0x10ec0283:
4936                alc_write_coef_idx(codec, 0x45, 0xc429);
4937                snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4938                alc_process_coef_fw(codec, coef0233);
4939                snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4940                break;
4941        case 0x10ec0286:
4942        case 0x10ec0288:
4943        case 0x10ec0298:
4944                snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4945                alc_process_coef_fw(codec, coef0288);
4946                snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4947                break;
4948        case 0x10ec0292:
4949                snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4950                alc_process_coef_fw(codec, coef0292);
4951                break;
4952        case 0x10ec0293:
4953                /* Set to TRS mode */
4954                alc_write_coef_idx(codec, 0x45, 0xc429);
4955                snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4956                alc_process_coef_fw(codec, coef0293);
4957                snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4958                break;
4959        case 0x10ec0867:
4960                alc_update_coefex_idx(codec, 0x57, 0x5, 0, 1<<14);
4961                fallthrough;
4962        case 0x10ec0221:
4963        case 0x10ec0662:
4964                snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4965                snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4966                break;
4967        case 0x10ec0668:
4968                alc_write_coef_idx(codec, 0x11, 0x0001);
4969                snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4970                alc_process_coef_fw(codec, coef0688);
4971                snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4972                break;
4973        case 0x10ec0215:
4974        case 0x10ec0225:
4975        case 0x10ec0285:
4976        case 0x10ec0295:
4977        case 0x10ec0289:
4978        case 0x10ec0299:
4979                alc_process_coef_fw(codec, alc225_pre_hsmode);
4980                alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x31<<10);
4981                snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
4982                alc_process_coef_fw(codec, coef0225);
4983                snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
4984                break;
4985        }
4986        codec_dbg(codec, "Headset jack set to mic-in mode.\n");
4987}
4988
4989static void alc_headset_mode_default(struct hda_codec *codec)
4990{
4991        static const struct coef_fw coef0225[] = {
4992                UPDATE_COEF(0x45, 0x3f<<10, 0x30<<10),
4993                UPDATE_COEF(0x45, 0x3f<<10, 0x31<<10),
4994                UPDATE_COEF(0x49, 3<<8, 0<<8),
4995                UPDATE_COEF(0x4a, 3<<4, 3<<4),
4996                UPDATE_COEF(0x63, 3<<14, 0),
4997                UPDATE_COEF(0x67, 0xf000, 0x3000),
4998                {}
4999        };
5000        static const struct coef_fw coef0255[] = {
5001                WRITE_COEF(0x45, 0xc089),
5002                WRITE_COEF(0x45, 0xc489),
5003                WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5004                WRITE_COEF(0x49, 0x0049),
5005                {}
5006        };
5007        static const struct coef_fw coef0256[] = {
5008                WRITE_COEF(0x45, 0xc489),
5009                WRITE_COEFEX(0x57, 0x03, 0x0da3),
5010                WRITE_COEF(0x49, 0x0049),
5011                UPDATE_COEFEX(0x57, 0x05, 1<<14, 0), /* Direct Drive HP Amp control(Set to verb control)*/
5012                WRITE_COEF(0x06, 0x6100),
5013                {}
5014        };
5015        static const struct coef_fw coef0233[] = {
5016                WRITE_COEF(0x06, 0x2100),
5017                WRITE_COEF(0x32, 0x4ea3),
5018                {}
5019        };
5020        static const struct coef_fw coef0288[] = {
5021                UPDATE_COEF(0x4f, 0xfcc0, 0xc400), /* Set to TRS type */
5022                UPDATE_COEF(0x50, 0x2000, 0x2000),
5023                UPDATE_COEF(0x56, 0x0006, 0x0006),
5024                UPDATE_COEF(0x66, 0x0008, 0),
5025                UPDATE_COEF(0x67, 0x2000, 0),
5026                {}
5027        };
5028        static const struct coef_fw coef0292[] = {
5029                WRITE_COEF(0x76, 0x000e),
5030                WRITE_COEF(0x6c, 0x2400),
5031                WRITE_COEF(0x6b, 0xc429),
5032                WRITE_COEF(0x18, 0x7308),
5033                {}
5034        };
5035        static const struct coef_fw coef0293[] = {
5036                UPDATE_COEF(0x4a, 0x000f, 0x000e), /* Combo Jack auto detect */
5037                WRITE_COEF(0x45, 0xC429), /* Set to TRS type */
5038                UPDATE_COEF(0x1a, 1<<3, 0), /* Combo JD gating without LINE1-VREFO */
5039                {}
5040        };
5041        static const struct coef_fw coef0688[] = {
5042                WRITE_COEF(0x11, 0x0041),
5043                WRITE_COEF(0x15, 0x0d40),
5044                WRITE_COEF(0xb7, 0x802b),
5045                {}
5046        };
5047        static const struct coef_fw coef0274[] = {
5048                WRITE_COEF(0x45, 0x4289),
5049                UPDATE_COEF(0x4a, 0x0010, 0x0010),
5050                UPDATE_COEF(0x6b, 0x0f00, 0),
5051                UPDATE_COEF(0x49, 0x0300, 0x0300),
5052                {}
5053        };
5054
5055        switch (codec->core.vendor_id) {
5056        case 0x10ec0215:
5057        case 0x10ec0225:
5058        case 0x10ec0285:
5059        case 0x10ec0295:
5060        case 0x10ec0289:
5061        case 0x10ec0299:
5062                alc_process_coef_fw(codec, alc225_pre_hsmode);
5063                alc_process_coef_fw(codec, coef0225);
5064                break;
5065        case 0x10ec0255:
5066                alc_process_coef_fw(codec, coef0255);
5067                break;
5068        case 0x10ec0230:
5069        case 0x10ec0236:
5070        case 0x10ec0256:
5071                alc_write_coef_idx(codec, 0x1b, 0x0e4b);
5072                alc_write_coef_idx(codec, 0x45, 0xc089);
5073                msleep(50);
5074                alc_process_coef_fw(codec, coef0256);
5075                break;
5076        case 0x10ec0234:
5077        case 0x10ec0274:
5078        case 0x10ec0294:
5079                alc_process_coef_fw(codec, coef0274);
5080                break;
5081        case 0x10ec0233:
5082        case 0x10ec0283:
5083                alc_process_coef_fw(codec, coef0233);
5084                break;
5085        case 0x10ec0286:
5086        case 0x10ec0288:
5087        case 0x10ec0298:
5088                alc_process_coef_fw(codec, coef0288);
5089                break;
5090        case 0x10ec0292:
5091                alc_process_coef_fw(codec, coef0292);
5092                break;
5093        case 0x10ec0293:
5094                alc_process_coef_fw(codec, coef0293);
5095                break;
5096        case 0x10ec0668:
5097                alc_process_coef_fw(codec, coef0688);
5098                break;
5099        case 0x10ec0867:
5100                alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5101                break;
5102        }
5103        codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
5104}
5105
5106/* Iphone type */
5107static void alc_headset_mode_ctia(struct hda_codec *codec)
5108{
5109        int val;
5110
5111        static const struct coef_fw coef0255[] = {
5112                WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
5113                WRITE_COEF(0x1b, 0x0c2b),
5114                WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5115                {}
5116        };
5117        static const struct coef_fw coef0256[] = {
5118                WRITE_COEF(0x45, 0xd489), /* Set to CTIA type */
5119                WRITE_COEF(0x1b, 0x0e6b),
5120                {}
5121        };
5122        static const struct coef_fw coef0233[] = {
5123                WRITE_COEF(0x45, 0xd429),
5124                WRITE_COEF(0x1b, 0x0c2b),
5125                WRITE_COEF(0x32, 0x4ea3),
5126                {}
5127        };
5128        static const struct coef_fw coef0288[] = {
5129                UPDATE_COEF(0x50, 0x2000, 0x2000),
5130                UPDATE_COEF(0x56, 0x0006, 0x0006),
5131                UPDATE_COEF(0x66, 0x0008, 0),
5132                UPDATE_COEF(0x67, 0x2000, 0),
5133                {}
5134        };
5135        static const struct coef_fw coef0292[] = {
5136                WRITE_COEF(0x6b, 0xd429),
5137                WRITE_COEF(0x76, 0x0008),
5138                WRITE_COEF(0x18, 0x7388),
5139                {}
5140        };
5141        static const struct coef_fw coef0293[] = {
5142                WRITE_COEF(0x45, 0xd429), /* Set to ctia type */
5143                UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
5144                {}
5145        };
5146        static const struct coef_fw coef0688[] = {
5147                WRITE_COEF(0x11, 0x0001),
5148                WRITE_COEF(0x15, 0x0d60),
5149                WRITE_COEF(0xc3, 0x0000),
5150                {}
5151        };
5152        static const struct coef_fw coef0225_1[] = {
5153                UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
5154                UPDATE_COEF(0x63, 3<<14, 2<<14),
5155                {}
5156        };
5157        static const struct coef_fw coef0225_2[] = {
5158                UPDATE_COEF(0x45, 0x3f<<10, 0x35<<10),
5159                UPDATE_COEF(0x63, 3<<14, 1<<14),
5160                {}
5161        };
5162
5163        switch (codec->core.vendor_id) {
5164        case 0x10ec0255:
5165                alc_process_coef_fw(codec, coef0255);
5166                break;
5167        case 0x10ec0230:
5168        case 0x10ec0236:
5169        case 0x10ec0256:
5170                alc_process_coef_fw(codec, coef0256);
5171                break;
5172        case 0x10ec0234:
5173        case 0x10ec0274:
5174        case 0x10ec0294:
5175                alc_write_coef_idx(codec, 0x45, 0xd689);
5176                break;
5177        case 0x10ec0233:
5178        case 0x10ec0283:
5179                alc_process_coef_fw(codec, coef0233);
5180                break;
5181        case 0x10ec0298:
5182                val = alc_read_coef_idx(codec, 0x50);
5183                if (val & (1 << 12)) {
5184                        alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5185                        alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5186                        msleep(300);
5187                } else {
5188                        alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5189                        alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5190                        msleep(300);
5191                }
5192                break;
5193        case 0x10ec0286:
5194        case 0x10ec0288:
5195                alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xd400);
5196                msleep(300);
5197                alc_process_coef_fw(codec, coef0288);
5198                break;
5199        case 0x10ec0292:
5200                alc_process_coef_fw(codec, coef0292);
5201                break;
5202        case 0x10ec0293:
5203                alc_process_coef_fw(codec, coef0293);
5204                break;
5205        case 0x10ec0668:
5206                alc_process_coef_fw(codec, coef0688);
5207                break;
5208        case 0x10ec0215:
5209        case 0x10ec0225:
5210        case 0x10ec0285:
5211        case 0x10ec0295:
5212        case 0x10ec0289:
5213        case 0x10ec0299:
5214                val = alc_read_coef_idx(codec, 0x45);
5215                if (val & (1 << 9))
5216                        alc_process_coef_fw(codec, coef0225_2);
5217                else
5218                        alc_process_coef_fw(codec, coef0225_1);
5219                break;
5220        case 0x10ec0867:
5221                alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5222                break;
5223        }
5224        codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
5225}
5226
5227/* Nokia type */
5228static void alc_headset_mode_omtp(struct hda_codec *codec)
5229{
5230        static const struct coef_fw coef0255[] = {
5231                WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
5232                WRITE_COEF(0x1b, 0x0c2b),
5233                WRITE_COEFEX(0x57, 0x03, 0x8ea6),
5234                {}
5235        };
5236        static const struct coef_fw coef0256[] = {
5237                WRITE_COEF(0x45, 0xe489), /* Set to OMTP Type */
5238                WRITE_COEF(0x1b, 0x0e6b),
5239                {}
5240        };
5241        static const struct coef_fw coef0233[] = {
5242                WRITE_COEF(0x45, 0xe429),
5243                WRITE_COEF(0x1b, 0x0c2b),
5244                WRITE_COEF(0x32, 0x4ea3),
5245                {}
5246        };
5247        static const struct coef_fw coef0288[] = {
5248                UPDATE_COEF(0x50, 0x2000, 0x2000),
5249                UPDATE_COEF(0x56, 0x0006, 0x0006),
5250                UPDATE_COEF(0x66, 0x0008, 0),
5251                UPDATE_COEF(0x67, 0x2000, 0),
5252                {}
5253        };
5254        static const struct coef_fw coef0292[] = {
5255                WRITE_COEF(0x6b, 0xe429),
5256                WRITE_COEF(0x76, 0x0008),
5257                WRITE_COEF(0x18, 0x7388),
5258                {}
5259        };
5260        static const struct coef_fw coef0293[] = {
5261                WRITE_COEF(0x45, 0xe429), /* Set to omtp type */
5262                UPDATE_COEF(0x10, 7<<8, 7<<8), /* SET Line1 JD to 1 */
5263                {}
5264        };
5265        static const struct coef_fw coef0688[] = {
5266                WRITE_COEF(0x11, 0x0001),
5267                WRITE_COEF(0x15, 0x0d50),
5268                WRITE_COEF(0xc3, 0x0000),
5269                {}
5270        };
5271        static const struct coef_fw coef0225[] = {
5272                UPDATE_COEF(0x45, 0x3f<<10, 0x39<<10),
5273                UPDATE_COEF(0x63, 3<<14, 2<<14),
5274                {}
5275        };
5276
5277        switch (codec->core.vendor_id) {
5278        case 0x10ec0255:
5279                alc_process_coef_fw(codec, coef0255);
5280                break;
5281        case 0x10ec0230:
5282        case 0x10ec0236:
5283        case 0x10ec0256:
5284                alc_process_coef_fw(codec, coef0256);
5285                break;
5286        case 0x10ec0234:
5287        case 0x10ec0274:
5288        case 0x10ec0294:
5289                alc_write_coef_idx(codec, 0x45, 0xe689);
5290                break;
5291        case 0x10ec0233:
5292        case 0x10ec0283:
5293                alc_process_coef_fw(codec, coef0233);
5294                break;
5295        case 0x10ec0298:
5296                alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);/* Headset output enable */
5297                alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5298                msleep(300);
5299                break;
5300        case 0x10ec0286:
5301        case 0x10ec0288:
5302                alc_update_coef_idx(codec, 0x4f, 0xfcc0, 0xe400);
5303                msleep(300);
5304                alc_process_coef_fw(codec, coef0288);
5305                break;
5306        case 0x10ec0292:
5307                alc_process_coef_fw(codec, coef0292);
5308                break;
5309        case 0x10ec0293:
5310                alc_process_coef_fw(codec, coef0293);
5311                break;
5312        case 0x10ec0668:
5313                alc_process_coef_fw(codec, coef0688);
5314                break;
5315        case 0x10ec0215:
5316        case 0x10ec0225:
5317        case 0x10ec0285:
5318        case 0x10ec0295:
5319        case 0x10ec0289:
5320        case 0x10ec0299:
5321                alc_process_coef_fw(codec, coef0225);
5322                break;
5323        }
5324        codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
5325}
5326
5327static void alc_determine_headset_type(struct hda_codec *codec)
5328{
5329        int val;
5330        bool is_ctia = false;
5331        struct alc_spec *spec = codec->spec;
5332        static const struct coef_fw coef0255[] = {
5333                WRITE_COEF(0x45, 0xd089), /* combo jack auto switch control(Check type)*/
5334                WRITE_COEF(0x49, 0x0149), /* combo jack auto switch control(Vref
5335 conteol) */
5336                {}
5337        };
5338        static const struct coef_fw coef0288[] = {
5339                UPDATE_COEF(0x4f, 0xfcc0, 0xd400), /* Check Type */
5340                {}
5341        };
5342        static const struct coef_fw coef0298[] = {
5343                UPDATE_COEF(0x50, 0x2000, 0x2000),
5344                UPDATE_COEF(0x56, 0x0006, 0x0006),
5345                UPDATE_COEF(0x66, 0x0008, 0),
5346                UPDATE_COEF(0x67, 0x2000, 0),
5347                UPDATE_COEF(0x19, 0x1300, 0x1300),
5348                {}
5349        };
5350        static const struct coef_fw coef0293[] = {
5351                UPDATE_COEF(0x4a, 0x000f, 0x0008), /* Combo Jack auto detect */
5352                WRITE_COEF(0x45, 0xD429), /* Set to ctia type */
5353                {}
5354        };
5355        static const struct coef_fw coef0688[] = {
5356                WRITE_COEF(0x11, 0x0001),
5357                WRITE_COEF(0xb7, 0x802b),
5358                WRITE_COEF(0x15, 0x0d60),
5359                WRITE_COEF(0xc3, 0x0c00),
5360                {}
5361        };
5362        static const struct coef_fw coef0274[] = {
5363                UPDATE_COEF(0x4a, 0x0010, 0),
5364                UPDATE_COEF(0x4a, 0x8000, 0),
5365                WRITE_COEF(0x45, 0xd289),
5366                UPDATE_COEF(0x49, 0x0300, 0x0300),
5367                {}
5368        };
5369
5370        if (spec->no_internal_mic_pin) {
5371                alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
5372                return;
5373        }
5374
5375        switch (codec->core.vendor_id) {
5376        case 0x10ec0255:
5377                alc_process_coef_fw(codec, coef0255);
5378                msleep(300);
5379                val = alc_read_coef_idx(codec, 0x46);
5380                is_ctia = (val & 0x0070) == 0x0070;
5381                break;
5382        case 0x10ec0230:
5383        case 0x10ec0236:
5384        case 0x10ec0256:
5385                alc_write_coef_idx(codec, 0x1b, 0x0e4b);
5386                alc_write_coef_idx(codec, 0x06, 0x6104);
5387                alc_write_coefex_idx(codec, 0x57, 0x3, 0x09a3);
5388
5389                snd_hda_codec_write(codec, 0x21, 0,
5390                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5391                msleep(80);
5392                snd_hda_codec_write(codec, 0x21, 0,
5393                            AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5394
5395                alc_process_coef_fw(codec, coef0255);
5396                msleep(300);
5397                val = alc_read_coef_idx(codec, 0x46);
5398                is_ctia = (val & 0x0070) == 0x0070;
5399
5400                alc_write_coefex_idx(codec, 0x57, 0x3, 0x0da3);
5401                alc_update_coefex_idx(codec, 0x57, 0x5, 1<<14, 0);
5402
5403                snd_hda_codec_write(codec, 0x21, 0,
5404                            AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
5405                msleep(80);
5406                snd_hda_codec_write(codec, 0x21, 0,
5407                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5408                break;
5409        case 0x10ec0234:
5410        case 0x10ec0274:
5411        case 0x10ec0294:
5412                alc_process_coef_fw(codec, coef0274);
5413                msleep(850);
5414                val = alc_read_coef_idx(codec, 0x46);
5415                is_ctia = (val & 0x00f0) == 0x00f0;
5416                break;
5417        case 0x10ec0233:
5418        case 0x10ec0283:
5419                alc_write_coef_idx(codec, 0x45, 0xd029);
5420                msleep(300);
5421                val = alc_read_coef_idx(codec, 0x46);
5422                is_ctia = (val & 0x0070) == 0x0070;
5423                break;
5424        case 0x10ec0298:
5425                snd_hda_codec_write(codec, 0x21, 0,
5426                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5427                msleep(100);
5428                snd_hda_codec_write(codec, 0x21, 0,
5429                            AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5430                msleep(200);
5431
5432                val = alc_read_coef_idx(codec, 0x50);
5433                if (val & (1 << 12)) {
5434                        alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0020);
5435                        alc_process_coef_fw(codec, coef0288);
5436                        msleep(350);
5437                        val = alc_read_coef_idx(codec, 0x50);
5438                        is_ctia = (val & 0x0070) == 0x0070;
5439                } else {
5440                        alc_update_coef_idx(codec, 0x8e, 0x0070, 0x0010);
5441                        alc_process_coef_fw(codec, coef0288);
5442                        msleep(350);
5443                        val = alc_read_coef_idx(codec, 0x50);
5444                        is_ctia = (val & 0x0070) == 0x0070;
5445                }
5446                alc_process_coef_fw(codec, coef0298);
5447                snd_hda_codec_write(codec, 0x21, 0,
5448                            AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
5449                msleep(75);
5450                snd_hda_codec_write(codec, 0x21, 0,
5451                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5452                break;
5453        case 0x10ec0286:
5454        case 0x10ec0288:
5455                alc_process_coef_fw(codec, coef0288);
5456                msleep(350);
5457                val = alc_read_coef_idx(codec, 0x50);
5458                is_ctia = (val & 0x0070) == 0x0070;
5459                break;
5460        case 0x10ec0292:
5461                alc_write_coef_idx(codec, 0x6b, 0xd429);
5462                msleep(300);
5463                val = alc_read_coef_idx(codec, 0x6c);
5464                is_ctia = (val & 0x001c) == 0x001c;
5465                break;
5466        case 0x10ec0293:
5467                alc_process_coef_fw(codec, coef0293);
5468                msleep(300);
5469                val = alc_read_coef_idx(codec, 0x46);
5470                is_ctia = (val & 0x0070) == 0x0070;
5471                break;
5472        case 0x10ec0668:
5473                alc_process_coef_fw(codec, coef0688);
5474                msleep(300);
5475                val = alc_read_coef_idx(codec, 0xbe);
5476                is_ctia = (val & 0x1c02) == 0x1c02;
5477                break;
5478        case 0x10ec0215:
5479        case 0x10ec0225:
5480        case 0x10ec0285:
5481        case 0x10ec0295:
5482        case 0x10ec0289:
5483        case 0x10ec0299:
5484                snd_hda_codec_write(codec, 0x21, 0,
5485                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5486                msleep(80);
5487                snd_hda_codec_write(codec, 0x21, 0,
5488                            AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
5489
5490                alc_process_coef_fw(codec, alc225_pre_hsmode);
5491                alc_update_coef_idx(codec, 0x67, 0xf000, 0x1000);
5492                val = alc_read_coef_idx(codec, 0x45);
5493                if (val & (1 << 9)) {
5494                        alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5495                        alc_update_coef_idx(codec, 0x49, 3<<8, 2<<8);
5496                        msleep(800);
5497                        val = alc_read_coef_idx(codec, 0x46);
5498                        is_ctia = (val & 0x00f0) == 0x00f0;
5499                } else {
5500                        alc_update_coef_idx(codec, 0x45, 0x3f<<10, 0x34<<10);
5501                        alc_update_coef_idx(codec, 0x49, 3<<8, 1<<8);
5502                        msleep(800);
5503                        val = alc_read_coef_idx(codec, 0x46);
5504                        is_ctia = (val & 0x00f0) == 0x00f0;
5505                }
5506                alc_update_coef_idx(codec, 0x4a, 7<<6, 7<<6);
5507                alc_update_coef_idx(codec, 0x4a, 3<<4, 3<<4);
5508                alc_update_coef_idx(codec, 0x67, 0xf000, 0x3000);
5509
5510                snd_hda_codec_write(codec, 0x21, 0,
5511                            AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
5512                msleep(80);
5513                snd_hda_codec_write(codec, 0x21, 0,
5514                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5515                break;
5516        case 0x10ec0867:
5517                is_ctia = true;
5518                break;
5519        }
5520
5521        codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
5522                    is_ctia ? "yes" : "no");
5523        spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
5524}
5525
5526static void alc_update_headset_mode(struct hda_codec *codec)
5527{
5528        struct alc_spec *spec = codec->spec;
5529
5530        hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
5531        hda_nid_t hp_pin = alc_get_hp_pin(spec);
5532
5533        int new_headset_mode;
5534
5535        if (!snd_hda_jack_detect(codec, hp_pin))
5536                new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
5537        else if (mux_pin == spec->headset_mic_pin)
5538                new_headset_mode = ALC_HEADSET_MODE_HEADSET;
5539        else if (mux_pin == spec->headphone_mic_pin)
5540                new_headset_mode = ALC_HEADSET_MODE_MIC;
5541        else
5542                new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
5543
5544        if (new_headset_mode == spec->current_headset_mode) {
5545                snd_hda_gen_update_outputs(codec);
5546                return;
5547        }
5548
5549        switch (new_headset_mode) {
5550        case ALC_HEADSET_MODE_UNPLUGGED:
5551                alc_headset_mode_unplugged(codec);
5552                spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
5553                spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
5554                spec->gen.hp_jack_present = false;
5555                break;
5556        case ALC_HEADSET_MODE_HEADSET:
5557                if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
5558                        alc_determine_headset_type(codec);
5559                if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
5560                        alc_headset_mode_ctia(codec);
5561                else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
5562                        alc_headset_mode_omtp(codec);
5563                spec->gen.hp_jack_present = true;
5564                break;
5565        case ALC_HEADSET_MODE_MIC:
5566                alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
5567                spec->gen.hp_jack_present = false;
5568                break;
5569        case ALC_HEADSET_MODE_HEADPHONE:
5570                alc_headset_mode_default(codec);
5571                spec->gen.hp_jack_present = true;
5572                break;
5573        }
5574        if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
5575                snd_hda_set_pin_ctl_cache(codec, hp_pin,
5576                                          AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
5577                if (spec->headphone_mic_pin && spec->headphone_mic_pin != hp_pin)
5578                        snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
5579                                                  PIN_VREFHIZ);
5580        }
5581        spec->current_headset_mode = new_headset_mode;
5582
5583        snd_hda_gen_update_outputs(codec);
5584}
5585
5586static void alc_update_headset_mode_hook(struct hda_codec *codec,
5587                                         struct snd_kcontrol *kcontrol,
5588                                         struct snd_ctl_elem_value *ucontrol)
5589{
5590        alc_update_headset_mode(codec);
5591}
5592
5593static void alc_update_headset_jack_cb(struct hda_codec *codec,
5594                                       struct hda_jack_callback *jack)
5595{
5596        snd_hda_gen_hp_automute(codec, jack);
5597        alc_update_headset_mode(codec);
5598}
5599
5600static void alc_probe_headset_mode(struct hda_codec *codec)
5601{
5602        int i;
5603        struct alc_spec *spec = codec->spec;
5604        struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5605
5606        /* Find mic pins */
5607        for (i = 0; i < cfg->num_inputs; i++) {
5608                if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
5609                        spec->headset_mic_pin = cfg->inputs[i].pin;
5610                if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
5611                        spec->headphone_mic_pin = cfg->inputs[i].pin;
5612        }
5613
5614        WARN_ON(spec->gen.cap_sync_hook);
5615        spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
5616        spec->gen.automute_hook = alc_update_headset_mode;
5617        spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
5618}
5619
5620static void alc_fixup_headset_mode(struct hda_codec *codec,
5621                                const struct hda_fixup *fix, int action)
5622{
5623        struct alc_spec *spec = codec->spec;
5624
5625        switch (action) {
5626        case HDA_FIXUP_ACT_PRE_PROBE:
5627                spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
5628                break;
5629        case HDA_FIXUP_ACT_PROBE:
5630                alc_probe_headset_mode(codec);
5631                break;
5632        case HDA_FIXUP_ACT_INIT:
5633                if (is_s3_resume(codec) || is_s4_resume(codec)) {
5634                        spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN;
5635                        spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN;
5636                }
5637                alc_update_headset_mode(codec);
5638                break;
5639        }
5640}
5641
5642static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
5643                                const struct hda_fixup *fix, int action)
5644{
5645        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5646                struct alc_spec *spec = codec->spec;
5647                spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5648        }
5649        else
5650                alc_fixup_headset_mode(codec, fix, action);
5651}
5652
5653static void alc255_set_default_jack_type(struct hda_codec *codec)
5654{
5655        /* Set to iphone type */
5656        static const struct coef_fw alc255fw[] = {
5657                WRITE_COEF(0x1b, 0x880b),
5658                WRITE_COEF(0x45, 0xd089),
5659                WRITE_COEF(0x1b, 0x080b),
5660                WRITE_COEF(0x46, 0x0004),
5661                WRITE_COEF(0x1b, 0x0c0b),
5662                {}
5663        };
5664        static const struct coef_fw alc256fw[] = {
5665                WRITE_COEF(0x1b, 0x884b),
5666                WRITE_COEF(0x45, 0xd089),
5667                WRITE_COEF(0x1b, 0x084b),
5668                WRITE_COEF(0x46, 0x0004),
5669                WRITE_COEF(0x1b, 0x0c4b),
5670                {}
5671        };
5672        switch (codec->core.vendor_id) {
5673        case 0x10ec0255:
5674                alc_process_coef_fw(codec, alc255fw);
5675                break;
5676        case 0x10ec0230:
5677        case 0x10ec0236:
5678        case 0x10ec0256:
5679                alc_process_coef_fw(codec, alc256fw);
5680                break;
5681        }
5682        msleep(30);
5683}
5684
5685static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
5686                                const struct hda_fixup *fix, int action)
5687{
5688        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5689                alc255_set_default_jack_type(codec);
5690        }
5691        alc_fixup_headset_mode(codec, fix, action);
5692}
5693
5694static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
5695                                const struct hda_fixup *fix, int action)
5696{
5697        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5698                struct alc_spec *spec = codec->spec;
5699                spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5700                alc255_set_default_jack_type(codec);
5701        } 
5702        else
5703                alc_fixup_headset_mode(codec, fix, action);
5704}
5705
5706static void alc288_update_headset_jack_cb(struct hda_codec *codec,
5707                                       struct hda_jack_callback *jack)
5708{
5709        struct alc_spec *spec = codec->spec;
5710
5711        alc_update_headset_jack_cb(codec, jack);
5712        /* Headset Mic enable or disable, only for Dell Dino */
5713        alc_update_gpio_data(codec, 0x40, spec->gen.hp_jack_present);
5714}
5715
5716static void alc_fixup_headset_mode_dell_alc288(struct hda_codec *codec,
5717                                const struct hda_fixup *fix, int action)
5718{
5719        alc_fixup_headset_mode(codec, fix, action);
5720        if (action == HDA_FIXUP_ACT_PROBE) {
5721                struct alc_spec *spec = codec->spec;
5722                /* toggled via hp_automute_hook */
5723                spec->gpio_mask |= 0x40;
5724                spec->gpio_dir |= 0x40;
5725                spec->gen.hp_automute_hook = alc288_update_headset_jack_cb;
5726        }
5727}
5728
5729static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
5730                                        const struct hda_fixup *fix, int action)
5731{
5732        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5733                struct alc_spec *spec = codec->spec;
5734                spec->gen.auto_mute_via_amp = 1;
5735        }
5736}
5737
5738static void alc_fixup_no_shutup(struct hda_codec *codec,
5739                                const struct hda_fixup *fix, int action)
5740{
5741        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5742                struct alc_spec *spec = codec->spec;
5743                spec->no_shutup_pins = 1;
5744        }
5745}
5746
5747static void alc_fixup_disable_aamix(struct hda_codec *codec,
5748                                    const struct hda_fixup *fix, int action)
5749{
5750        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5751                struct alc_spec *spec = codec->spec;
5752                /* Disable AA-loopback as it causes white noise */
5753                spec->gen.mixer_nid = 0;
5754        }
5755}
5756
5757/* fixup for Thinkpad docks: add dock pins, avoid HP parser fixup */
5758static void alc_fixup_tpt440_dock(struct hda_codec *codec,
5759                                  const struct hda_fixup *fix, int action)
5760{
5761        static const struct hda_pintbl pincfgs[] = {
5762                { 0x16, 0x21211010 }, /* dock headphone */
5763                { 0x19, 0x21a11010 }, /* dock mic */
5764                { }
5765        };
5766        struct alc_spec *spec = codec->spec;
5767
5768        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5769                spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5770                codec->power_save_node = 0; /* avoid click noises */
5771                snd_hda_apply_pincfgs(codec, pincfgs);
5772        }
5773}
5774
5775static void alc_fixup_tpt470_dock(struct hda_codec *codec,
5776                                  const struct hda_fixup *fix, int action)
5777{
5778        static const struct hda_pintbl pincfgs[] = {
5779                { 0x17, 0x21211010 }, /* dock headphone */
5780                { 0x19, 0x21a11010 }, /* dock mic */
5781                { }
5782        };
5783        struct alc_spec *spec = codec->spec;
5784
5785        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5786                spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
5787                snd_hda_apply_pincfgs(codec, pincfgs);
5788        } else if (action == HDA_FIXUP_ACT_INIT) {
5789                /* Enable DOCK device */
5790                snd_hda_codec_write(codec, 0x17, 0,
5791                            AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
5792                /* Enable DOCK device */
5793                snd_hda_codec_write(codec, 0x19, 0,
5794                            AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0);
5795        }
5796}
5797
5798static void alc_fixup_tpt470_dacs(struct hda_codec *codec,
5799                                  const struct hda_fixup *fix, int action)
5800{
5801        /* Assure the speaker pin to be coupled with DAC NID 0x03; otherwise
5802         * the speaker output becomes too low by some reason on Thinkpads with
5803         * ALC298 codec
5804         */
5805        static const hda_nid_t preferred_pairs[] = {
5806                0x14, 0x03, 0x17, 0x02, 0x21, 0x02,
5807                0
5808        };
5809        struct alc_spec *spec = codec->spec;
5810
5811        if (action == HDA_FIXUP_ACT_PRE_PROBE)
5812                spec->gen.preferred_dacs = preferred_pairs;
5813}
5814
5815static void alc295_fixup_asus_dacs(struct hda_codec *codec,
5816                                   const struct hda_fixup *fix, int action)
5817{
5818        static const hda_nid_t preferred_pairs[] = {
5819                0x17, 0x02, 0x21, 0x03, 0
5820        };
5821        struct alc_spec *spec = codec->spec;
5822
5823        if (action == HDA_FIXUP_ACT_PRE_PROBE)
5824                spec->gen.preferred_dacs = preferred_pairs;
5825}
5826
5827static void alc_shutup_dell_xps13(struct hda_codec *codec)
5828{
5829        struct alc_spec *spec = codec->spec;
5830        int hp_pin = alc_get_hp_pin(spec);
5831
5832        /* Prevent pop noises when headphones are plugged in */
5833        snd_hda_codec_write(codec, hp_pin, 0,
5834                            AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
5835        msleep(20);
5836}
5837
5838static void alc_fixup_dell_xps13(struct hda_codec *codec,
5839                                const struct hda_fixup *fix, int action)
5840{
5841        struct alc_spec *spec = codec->spec;
5842        struct hda_input_mux *imux = &spec->gen.input_mux;
5843        int i;
5844
5845        switch (action) {
5846        case HDA_FIXUP_ACT_PRE_PROBE:
5847                /* mic pin 0x19 must be initialized with Vref Hi-Z, otherwise
5848                 * it causes a click noise at start up
5849                 */
5850                snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
5851                spec->shutup = alc_shutup_dell_xps13;
5852                break;
5853        case HDA_FIXUP_ACT_PROBE:
5854                /* Make the internal mic the default input source. */
5855                for (i = 0; i < imux->num_items; i++) {
5856                        if (spec->gen.imux_pins[i] == 0x12) {
5857                                spec->gen.cur_mux[0] = i;
5858                                break;
5859                        }
5860                }
5861                break;
5862        }
5863}
5864
5865static void alc_fixup_headset_mode_alc662(struct hda_codec *codec,
5866                                const struct hda_fixup *fix, int action)
5867{
5868        struct alc_spec *spec = codec->spec;
5869
5870        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5871                spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
5872                spec->gen.hp_mic = 1; /* Mic-in is same pin as headphone */
5873
5874                /* Disable boost for mic-in permanently. (This code is only called
5875                   from quirks that guarantee that the headphone is at NID 0x1b.) */
5876                snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000);
5877                snd_hda_override_wcaps(codec, 0x1b, get_wcaps(codec, 0x1b) & ~AC_WCAP_IN_AMP);
5878        } else
5879                alc_fixup_headset_mode(codec, fix, action);
5880}
5881
5882static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
5883                                const struct hda_fixup *fix, int action)
5884{
5885        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5886                alc_write_coef_idx(codec, 0xc4, 0x8000);
5887                alc_update_coef_idx(codec, 0xc2, ~0xfe, 0);
5888                snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
5889        }
5890        alc_fixup_headset_mode(codec, fix, action);
5891}
5892
5893/* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
5894static int find_ext_mic_pin(struct hda_codec *codec)
5895{
5896        struct alc_spec *spec = codec->spec;
5897        struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5898        hda_nid_t nid;
5899        unsigned int defcfg;
5900        int i;
5901
5902        for (i = 0; i < cfg->num_inputs; i++) {
5903                if (cfg->inputs[i].type != AUTO_PIN_MIC)
5904                        continue;
5905                nid = cfg->inputs[i].pin;
5906                defcfg = snd_hda_codec_get_pincfg(codec, nid);
5907                if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
5908                        continue;
5909                return nid;
5910        }
5911
5912        return 0;
5913}
5914
5915static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
5916                                    const struct hda_fixup *fix,
5917                                    int action)
5918{
5919        struct alc_spec *spec = codec->spec;
5920
5921        if (action == HDA_FIXUP_ACT_PROBE) {
5922                int mic_pin = find_ext_mic_pin(codec);
5923                int hp_pin = alc_get_hp_pin(spec);
5924
5925                if (snd_BUG_ON(!mic_pin || !hp_pin))
5926                        return;
5927                snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
5928        }
5929}
5930
5931static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
5932                                             const struct hda_fixup *fix,
5933                                             int action)
5934{
5935        struct alc_spec *spec = codec->spec;
5936        struct auto_pin_cfg *cfg = &spec->gen.autocfg;
5937        int i;
5938
5939        /* The mic boosts on level 2 and 3 are too noisy
5940           on the internal mic input.
5941           Therefore limit the boost to 0 or 1. */
5942
5943        if (action != HDA_FIXUP_ACT_PROBE)
5944                return;
5945
5946        for (i = 0; i < cfg->num_inputs; i++) {
5947                hda_nid_t nid = cfg->inputs[i].pin;
5948                unsigned int defcfg;
5949                if (cfg->inputs[i].type != AUTO_PIN_MIC)
5950                        continue;
5951                defcfg = snd_hda_codec_get_pincfg(codec, nid);
5952                if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
5953                        continue;
5954
5955                snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
5956                                          (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
5957                                          (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5958                                          (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
5959                                          (0 << AC_AMPCAP_MUTE_SHIFT));
5960        }
5961}
5962
5963static void alc283_hp_automute_hook(struct hda_codec *codec,
5964                                    struct hda_jack_callback *jack)
5965{
5966        struct alc_spec *spec = codec->spec;
5967        int vref;
5968
5969        msleep(200);
5970        snd_hda_gen_hp_automute(codec, jack);
5971
5972        vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
5973
5974        msleep(600);
5975        snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5976                            vref);
5977}
5978
5979static void alc283_fixup_chromebook(struct hda_codec *codec,
5980                                    const struct hda_fixup *fix, int action)
5981{
5982        struct alc_spec *spec = codec->spec;
5983
5984        switch (action) {
5985        case HDA_FIXUP_ACT_PRE_PROBE:
5986                snd_hda_override_wcaps(codec, 0x03, 0);
5987                /* Disable AA-loopback as it causes white noise */
5988                spec->gen.mixer_nid = 0;
5989                break;
5990        case HDA_FIXUP_ACT_INIT:
5991                /* MIC2-VREF control */
5992                /* Set to manual mode */
5993                alc_update_coef_idx(codec, 0x06, 0x000c, 0);
5994                /* Enable Line1 input control by verb */
5995                alc_update_coef_idx(codec, 0x1a, 0, 1 << 4);
5996                break;
5997        }
5998}
5999
6000static void alc283_fixup_sense_combo_jack(struct hda_codec *codec,
6001                                    const struct hda_fixup *fix, int action)
6002{
6003        struct alc_spec *spec = codec->spec;
6004
6005        switch (action) {
6006        case HDA_FIXUP_ACT_PRE_PROBE:
6007                spec->gen.hp_automute_hook = alc283_hp_automute_hook;
6008                break;
6009        case HDA_FIXUP_ACT_INIT:
6010                /* MIC2-VREF control */
6011                /* Set to manual mode */
6012                alc_update_coef_idx(codec, 0x06, 0x000c, 0);
6013                break;
6014        }
6015}
6016
6017/* mute tablet speaker pin (0x14) via dock plugging in addition */
6018static void asus_tx300_automute(struct hda_codec *codec)
6019{
6020        struct alc_spec *spec = codec->spec;
6021        snd_hda_gen_update_outputs(codec);
6022        if (snd_hda_jack_detect(codec, 0x1b))
6023                spec->gen.mute_bits |= (1ULL << 0x14);
6024}
6025
6026static void alc282_fixup_asus_tx300(struct hda_codec *codec,
6027                                    const struct hda_fixup *fix, int action)
6028{
6029        struct alc_spec *spec = codec->spec;
6030        static const struct hda_pintbl dock_pins[] = {
6031                { 0x1b, 0x21114000 }, /* dock speaker pin */
6032                {}
6033        };
6034
6035        switch (action) {
6036        case HDA_FIXUP_ACT_PRE_PROBE:
6037                spec->init_amp = ALC_INIT_DEFAULT;
6038                /* TX300 needs to set up GPIO2 for the speaker amp */
6039                alc_setup_gpio(codec, 0x04);
6040                snd_hda_apply_pincfgs(codec, dock_pins);
6041                spec->gen.auto_mute_via_amp = 1;
6042                spec->gen.automute_hook = asus_tx300_automute;
6043                snd_hda_jack_detect_enable_callback(codec, 0x1b,
6044                                                    snd_hda_gen_hp_automute);
6045                break;
6046        case HDA_FIXUP_ACT_PROBE:
6047                spec->init_amp = ALC_INIT_DEFAULT;
6048                break;
6049        case HDA_FIXUP_ACT_BUILD:
6050                /* this is a bit tricky; give more sane names for the main
6051                 * (tablet) speaker and the dock speaker, respectively
6052                 */
6053                rename_ctl(codec, "Speaker Playback Switch",
6054                           "Dock Speaker Playback Switch");
6055                rename_ctl(codec, "Bass Speaker Playback Switch",
6056                           "Speaker Playback Switch");
6057                break;
6058        }
6059}
6060
6061static void alc290_fixup_mono_speakers(struct hda_codec *codec,
6062                                       const struct hda_fixup *fix, int action)
6063{
6064        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6065                /* DAC node 0x03 is giving mono output. We therefore want to
6066                   make sure 0x14 (front speaker) and 0x15 (headphones) use the
6067                   stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
6068                static const hda_nid_t conn1[] = { 0x0c };
6069                snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
6070                snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
6071        }
6072}
6073
6074static void alc298_fixup_speaker_volume(struct hda_codec *codec,
6075                                        const struct hda_fixup *fix, int action)
6076{
6077        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6078                /* The speaker is routed to the Node 0x06 by a mistake, as a result
6079                   we can't adjust the speaker's volume since this node does not has
6080                   Amp-out capability. we change the speaker's route to:
6081                   Node 0x02 (Audio Output) -> Node 0x0c (Audio Mixer) -> Node 0x17 (
6082                   Pin Complex), since Node 0x02 has Amp-out caps, we can adjust
6083                   speaker's volume now. */
6084
6085                static const hda_nid_t conn1[] = { 0x0c };
6086                snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn1), conn1);
6087        }
6088}
6089
6090/* disable DAC3 (0x06) selection on NID 0x17 as it has no volume amp control */
6091static void alc295_fixup_disable_dac3(struct hda_codec *codec,
6092                                      const struct hda_fixup *fix, int action)
6093{
6094        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6095                static const hda_nid_t conn[] = { 0x02, 0x03 };
6096                snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6097        }
6098}
6099
6100/* force NID 0x17 (Bass Speaker) to DAC1 to share it with the main speaker */
6101static void alc285_fixup_speaker2_to_dac1(struct hda_codec *codec,
6102                                          const struct hda_fixup *fix, int action)
6103{
6104        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6105                static const hda_nid_t conn[] = { 0x02 };
6106                snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6107        }
6108}
6109
6110/* Hook to update amp GPIO4 for automute */
6111static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
6112                                          struct hda_jack_callback *jack)
6113{
6114        struct alc_spec *spec = codec->spec;
6115
6116        snd_hda_gen_hp_automute(codec, jack);
6117        /* mute_led_polarity is set to 0, so we pass inverted value here */
6118        alc_update_gpio_led(codec, 0x10, spec->mute_led_polarity,
6119                            !spec->gen.hp_jack_present);
6120}
6121
6122/* Manage GPIOs for HP EliteBook Folio 9480m.
6123 *
6124 * GPIO4 is the headphone amplifier power control
6125 * GPIO3 is the audio output mute indicator LED
6126 */
6127
6128static void alc280_fixup_hp_9480m(struct hda_codec *codec,
6129                                  const struct hda_fixup *fix,
6130                                  int action)
6131{
6132        struct alc_spec *spec = codec->spec;
6133
6134        alc_fixup_hp_gpio_led(codec, action, 0x08, 0);
6135        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6136                /* amp at GPIO4; toggled via alc280_hp_gpio4_automute_hook() */
6137                spec->gpio_mask |= 0x10;
6138                spec->gpio_dir |= 0x10;
6139                spec->gen.hp_automute_hook = alc280_hp_gpio4_automute_hook;
6140        }
6141}
6142
6143static void alc275_fixup_gpio4_off(struct hda_codec *codec,
6144                                   const struct hda_fixup *fix,
6145                                   int action)
6146{
6147        struct alc_spec *spec = codec->spec;
6148
6149        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6150                spec->gpio_mask |= 0x04;
6151                spec->gpio_dir |= 0x04;
6152                /* set data bit low */
6153        }
6154}
6155
6156/* Quirk for Thinkpad X1 7th and 8th Gen
6157 * The following fixed routing needed
6158 * DAC1 (NID 0x02) -> Speaker (NID 0x14); some eq applied secretly
6159 * DAC2 (NID 0x03) -> Bass (NID 0x17) & Headphone (NID 0x21); sharing a DAC
6160 * DAC3 (NID 0x06) -> Unused, due to the lack of volume amp
6161 */
6162static void alc285_fixup_thinkpad_x1_gen7(struct hda_codec *codec,
6163                                          const struct hda_fixup *fix, int action)
6164{
6165        static const hda_nid_t conn[] = { 0x02, 0x03 }; /* exclude 0x06 */
6166        static const hda_nid_t preferred_pairs[] = {
6167                0x14, 0x02, 0x17, 0x03, 0x21, 0x03, 0
6168        };
6169        struct alc_spec *spec = codec->spec;
6170
6171        switch (action) {
6172        case HDA_FIXUP_ACT_PRE_PROBE:
6173                snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6174                spec->gen.preferred_dacs = preferred_pairs;
6175                break;
6176        case HDA_FIXUP_ACT_BUILD:
6177                /* The generic parser creates somewhat unintuitive volume ctls
6178                 * with the fixed routing above, and the shared DAC2 may be
6179                 * confusing for PA.
6180                 * Rename those to unique names so that PA doesn't touch them
6181                 * and use only Master volume.
6182                 */
6183                rename_ctl(codec, "Front Playback Volume", "DAC1 Playback Volume");
6184                rename_ctl(codec, "Bass Speaker Playback Volume", "DAC2 Playback Volume");
6185                break;
6186        }
6187}
6188
6189static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
6190                                         const struct hda_fixup *fix,
6191                                         int action)
6192{
6193        alc_fixup_dual_codecs(codec, fix, action);
6194        switch (action) {
6195        case HDA_FIXUP_ACT_PRE_PROBE:
6196                /* override card longname to provide a unique UCM profile */
6197                strcpy(codec->card->longname, "HDAudio-Lenovo-DualCodecs");
6198                break;
6199        case HDA_FIXUP_ACT_BUILD:
6200                /* rename Capture controls depending on the codec */
6201                rename_ctl(codec, "Capture Volume",
6202                           codec->addr == 0 ?
6203                           "Rear-Panel Capture Volume" :
6204                           "Front-Panel Capture Volume");
6205                rename_ctl(codec, "Capture Switch",
6206                           codec->addr == 0 ?
6207                           "Rear-Panel Capture Switch" :
6208                           "Front-Panel Capture Switch");
6209                break;
6210        }
6211}
6212
6213static void alc225_fixup_s3_pop_noise(struct hda_codec *codec,
6214                                      const struct hda_fixup *fix, int action)
6215{
6216        if (action != HDA_FIXUP_ACT_PRE_PROBE)
6217                return;
6218
6219        codec->power_save_node = 1;
6220}
6221
6222/* Forcibly assign NID 0x03 to HP/LO while NID 0x02 to SPK for EQ */
6223static void alc274_fixup_bind_dacs(struct hda_codec *codec,
6224                                    const struct hda_fixup *fix, int action)
6225{
6226        struct alc_spec *spec = codec->spec;
6227        static const hda_nid_t preferred_pairs[] = {
6228                0x21, 0x03, 0x1b, 0x03, 0x16, 0x02,
6229                0
6230        };
6231
6232        if (action != HDA_FIXUP_ACT_PRE_PROBE)
6233                return;
6234
6235        spec->gen.preferred_dacs = preferred_pairs;
6236        spec->gen.auto_mute_via_amp = 1;
6237        codec->power_save_node = 0;
6238}
6239
6240/* avoid DAC 0x06 for bass speaker 0x17; it has no volume control */
6241static void alc289_fixup_asus_ga401(struct hda_codec *codec,
6242                                    const struct hda_fixup *fix, int action)
6243{
6244        static const hda_nid_t preferred_pairs[] = {
6245                0x14, 0x02, 0x17, 0x02, 0x21, 0x03, 0
6246        };
6247        struct alc_spec *spec = codec->spec;
6248
6249        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
6250                spec->gen.preferred_dacs = preferred_pairs;
6251                spec->gen.obey_preferred_dacs = 1;
6252        }
6253}
6254
6255/* The DAC of NID 0x3 will introduce click/pop noise on headphones, so invalidate it */
6256static void alc285_fixup_invalidate_dacs(struct hda_codec *codec,
6257                              const struct hda_fixup *fix, int action)
6258{
6259        if (action != HDA_FIXUP_ACT_PRE_PROBE)
6260                return;
6261
6262        snd_hda_override_wcaps(codec, 0x03, 0);
6263}
6264
6265static void alc_combo_jack_hp_jd_restart(struct hda_codec *codec)
6266{
6267        switch (codec->core.vendor_id) {
6268        case 0x10ec0274:
6269        case 0x10ec0294:
6270        case 0x10ec0225:
6271        case 0x10ec0295:
6272        case 0x10ec0299:
6273                alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */
6274                alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15);
6275                break;
6276        case 0x10ec0230:
6277        case 0x10ec0235:
6278        case 0x10ec0236:
6279        case 0x10ec0255:
6280        case 0x10ec0256:
6281                alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */
6282                alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15);
6283                break;
6284        }
6285}
6286
6287static void alc295_fixup_chromebook(struct hda_codec *codec,
6288                                    const struct hda_fixup *fix, int action)
6289{
6290        struct alc_spec *spec = codec->spec;
6291
6292        switch (action) {
6293        case HDA_FIXUP_ACT_PRE_PROBE:
6294                spec->ultra_low_power = true;
6295                break;
6296        case HDA_FIXUP_ACT_INIT:
6297                alc_combo_jack_hp_jd_restart(codec);
6298                break;
6299        }
6300}
6301
6302static void alc_fixup_disable_mic_vref(struct hda_codec *codec,
6303                                  const struct hda_fixup *fix, int action)
6304{
6305        if (action == HDA_FIXUP_ACT_PRE_PROBE)
6306                snd_hda_codec_set_pin_target(codec, 0x19, PIN_VREFHIZ);
6307}
6308
6309
6310static void alc294_gx502_toggle_output(struct hda_codec *codec,
6311                                        struct hda_jack_callback *cb)
6312{
6313        /* The Windows driver sets the codec up in a very different way where
6314         * it appears to leave 0x10 = 0x8a20 set. For Linux we need to toggle it
6315         */
6316        if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6317                alc_write_coef_idx(codec, 0x10, 0x8a20);
6318        else
6319                alc_write_coef_idx(codec, 0x10, 0x0a20);
6320}
6321
6322static void alc294_fixup_gx502_hp(struct hda_codec *codec,
6323                                        const struct hda_fixup *fix, int action)
6324{
6325        /* Pin 0x21: headphones/headset mic */
6326        if (!is_jack_detectable(codec, 0x21))
6327                return;
6328
6329        switch (action) {
6330        case HDA_FIXUP_ACT_PRE_PROBE:
6331                snd_hda_jack_detect_enable_callback(codec, 0x21,
6332                                alc294_gx502_toggle_output);
6333                break;
6334        case HDA_FIXUP_ACT_INIT:
6335                /* Make sure to start in a correct state, i.e. if
6336                 * headphones have been plugged in before powering up the system
6337                 */
6338                alc294_gx502_toggle_output(codec, NULL);
6339                break;
6340        }
6341}
6342
6343static void alc294_gu502_toggle_output(struct hda_codec *codec,
6344                                       struct hda_jack_callback *cb)
6345{
6346        /* Windows sets 0x10 to 0x8420 for Node 0x20 which is
6347         * responsible from changes between speakers and headphones
6348         */
6349        if (snd_hda_jack_detect_state(codec, 0x21) == HDA_JACK_PRESENT)
6350                alc_write_coef_idx(codec, 0x10, 0x8420);
6351        else
6352                alc_write_coef_idx(codec, 0x10, 0x0a20);
6353}
6354
6355static void alc294_fixup_gu502_hp(struct hda_codec *codec,
6356                                  const struct hda_fixup *fix, int action)
6357{
6358        if (!is_jack_detectable(codec, 0x21))
6359                return;
6360
6361        switch (action) {
6362        case HDA_FIXUP_ACT_PRE_PROBE:
6363                snd_hda_jack_detect_enable_callback(codec, 0x21,
6364                                alc294_gu502_toggle_output);
6365                break;
6366        case HDA_FIXUP_ACT_INIT:
6367                alc294_gu502_toggle_output(codec, NULL);
6368                break;
6369        }
6370}
6371
6372static void  alc285_fixup_hp_gpio_amp_init(struct hda_codec *codec,
6373                              const struct hda_fixup *fix, int action)
6374{
6375        if (action != HDA_FIXUP_ACT_INIT)
6376                return;
6377
6378        msleep(100);
6379        alc_write_coef_idx(codec, 0x65, 0x0);
6380}
6381
6382static void alc274_fixup_hp_headset_mic(struct hda_codec *codec,
6383                                    const struct hda_fixup *fix, int action)
6384{
6385        switch (action) {
6386        case HDA_FIXUP_ACT_INIT:
6387                alc_combo_jack_hp_jd_restart(codec);
6388                break;
6389        }
6390}
6391
6392static void alc_fixup_no_int_mic(struct hda_codec *codec,
6393                                    const struct hda_fixup *fix, int action)
6394{
6395        struct alc_spec *spec = codec->spec;
6396
6397        switch (action) {
6398        case HDA_FIXUP_ACT_PRE_PROBE:
6399                /* Mic RING SLEEVE swap for combo jack */
6400                alc_update_coef_idx(codec, 0x45, 0xf<<12 | 1<<10, 5<<12);
6401                spec->no_internal_mic_pin = true;
6402                break;
6403        case HDA_FIXUP_ACT_INIT:
6404                alc_combo_jack_hp_jd_restart(codec);
6405                break;
6406        }
6407}
6408
6409/* GPIO1 = amplifier on/off
6410 * GPIO3 = mic mute LED
6411 */
6412static void alc285_fixup_hp_spectre_x360_eb1(struct hda_codec *codec,
6413                                          const struct hda_fixup *fix, int action)
6414{
6415        static const hda_nid_t conn[] = { 0x02 };
6416
6417        struct alc_spec *spec = codec->spec;
6418        static const struct hda_pintbl pincfgs[] = {
6419                { 0x14, 0x90170110 },  /* front/high speakers */
6420                { 0x17, 0x90170130 },  /* back/bass speakers */
6421                { }
6422        };
6423
6424        //enable micmute led
6425        alc_fixup_hp_gpio_led(codec, action, 0x00, 0x04);
6426
6427        switch (action) {
6428        case HDA_FIXUP_ACT_PRE_PROBE:
6429                spec->micmute_led_polarity = 1;
6430                /* needed for amp of back speakers */
6431                spec->gpio_mask |= 0x01;
6432                spec->gpio_dir |= 0x01;
6433                snd_hda_apply_pincfgs(codec, pincfgs);
6434                /* share DAC to have unified volume control */
6435                snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
6436                snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6437                break;
6438        case HDA_FIXUP_ACT_INIT:
6439                /* need to toggle GPIO to enable the amp of back speakers */
6440                alc_update_gpio_data(codec, 0x01, true);
6441                msleep(100);
6442                alc_update_gpio_data(codec, 0x01, false);
6443                break;
6444        }
6445}
6446
6447static void alc285_fixup_hp_spectre_x360(struct hda_codec *codec,
6448                                          const struct hda_fixup *fix, int action)
6449{
6450        static const hda_nid_t conn[] = { 0x02 };
6451        static const struct hda_pintbl pincfgs[] = {
6452                { 0x14, 0x90170110 },  /* rear speaker */
6453                { }
6454        };
6455
6456        switch (action) {
6457        case HDA_FIXUP_ACT_PRE_PROBE:
6458                snd_hda_apply_pincfgs(codec, pincfgs);
6459                /* force front speaker to DAC1 */
6460                snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
6461                break;
6462        }
6463}
6464
6465/* for hda_fixup_thinkpad_acpi() */
6466#include "thinkpad_helper.c"
6467
6468static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
6469                                    const struct hda_fixup *fix, int action)
6470{
6471        alc_fixup_no_shutup(codec, fix, action); /* reduce click noise */
6472        hda_fixup_thinkpad_acpi(codec, fix, action);
6473}
6474
6475/* Fixup for Lenovo Legion 15IMHg05 speaker output on headset removal. */
6476static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec,
6477                                                  const struct hda_fixup *fix,
6478                                                  int action)
6479{
6480        struct alc_spec *spec = codec->spec;
6481
6482        switch (action) {
6483        case HDA_FIXUP_ACT_PRE_PROBE:
6484                spec->gen.suppress_auto_mute = 1;
6485                break;
6486        }
6487}
6488
6489/* for alc295_fixup_hp_top_speakers */
6490#include "hp_x360_helper.c"
6491
6492/* for alc285_fixup_ideapad_s740_coef() */
6493#include "ideapad_s740_helper.c"
6494
6495static void alc256_fixup_tongfang_reset_persistent_settings(struct hda_codec *codec,
6496                                                            const struct hda_fixup *fix,
6497                                                            int action)
6498{
6499        /*
6500        * A certain other OS sets these coeffs to different values. On at least one TongFang
6501        * barebone these settings might survive even a cold reboot. So to restore a clean slate the
6502        * values are explicitly reset to default here. Without this, the external microphone is
6503        * always in a plugged-in state, while the internal microphone is always in an unplugged
6504        * state, breaking the ability to use the internal microphone.
6505        */
6506        alc_write_coef_idx(codec, 0x24, 0x0000);
6507        alc_write_coef_idx(codec, 0x26, 0x0000);
6508        alc_write_coef_idx(codec, 0x29, 0x3000);
6509        alc_write_coef_idx(codec, 0x37, 0xfe05);
6510        alc_write_coef_idx(codec, 0x45, 0x5089);
6511}
6512
6513enum {
6514        ALC269_FIXUP_GPIO2,
6515        ALC269_FIXUP_SONY_VAIO,
6516        ALC275_FIXUP_SONY_VAIO_GPIO2,
6517        ALC269_FIXUP_DELL_M101Z,
6518        ALC269_FIXUP_SKU_IGNORE,
6519        ALC269_FIXUP_ASUS_G73JW,
6520        ALC269_FIXUP_LENOVO_EAPD,
6521        ALC275_FIXUP_SONY_HWEQ,
6522        ALC275_FIXUP_SONY_DISABLE_AAMIX,
6523        ALC271_FIXUP_DMIC,
6524        ALC269_FIXUP_PCM_44K,
6525        ALC269_FIXUP_STEREO_DMIC,
6526        ALC269_FIXUP_HEADSET_MIC,
6527        ALC269_FIXUP_QUANTA_MUTE,
6528        ALC269_FIXUP_LIFEBOOK,
6529        ALC269_FIXUP_LIFEBOOK_EXTMIC,
6530        ALC269_FIXUP_LIFEBOOK_HP_PIN,
6531        ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT,
6532        ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC,
6533        ALC269_FIXUP_AMIC,
6534        ALC269_FIXUP_DMIC,
6535        ALC269VB_FIXUP_AMIC,
6536        ALC269VB_FIXUP_DMIC,
6537        ALC269_FIXUP_HP_MUTE_LED,
6538        ALC269_FIXUP_HP_MUTE_LED_MIC1,
6539        ALC269_FIXUP_HP_MUTE_LED_MIC2,
6540        ALC269_FIXUP_HP_MUTE_LED_MIC3,
6541        ALC269_FIXUP_HP_GPIO_LED,
6542        ALC269_FIXUP_HP_GPIO_MIC1_LED,
6543        ALC269_FIXUP_HP_LINE1_MIC1_LED,
6544        ALC269_FIXUP_INV_DMIC,
6545        ALC269_FIXUP_LENOVO_DOCK,
6546        ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST,
6547        ALC269_FIXUP_NO_SHUTUP,
6548        ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
6549        ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
6550        ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
6551        ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
6552        ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
6553        ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
6554        ALC269_FIXUP_HEADSET_MODE,
6555        ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
6556        ALC269_FIXUP_ASPIRE_HEADSET_MIC,
6557        ALC269_FIXUP_ASUS_X101_FUNC,
6558        ALC269_FIXUP_ASUS_X101_VERB,
6559        ALC269_FIXUP_ASUS_X101,
6560        ALC271_FIXUP_AMIC_MIC2,
6561        ALC271_FIXUP_HP_GATE_MIC_JACK,
6562        ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
6563        ALC269_FIXUP_ACER_AC700,
6564        ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
6565        ALC269VB_FIXUP_ASUS_ZENBOOK,
6566        ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
6567        ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
6568        ALC269VB_FIXUP_ORDISSIMO_EVE2,
6569        ALC283_FIXUP_CHROME_BOOK,
6570        ALC283_FIXUP_SENSE_COMBO_JACK,
6571        ALC282_FIXUP_ASUS_TX300,
6572        ALC283_FIXUP_INT_MIC,
6573        ALC290_FIXUP_MONO_SPEAKERS,
6574        ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
6575        ALC290_FIXUP_SUBWOOFER,
6576        ALC290_FIXUP_SUBWOOFER_HSJACK,
6577        ALC269_FIXUP_THINKPAD_ACPI,
6578        ALC269_FIXUP_DMIC_THINKPAD_ACPI,
6579        ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
6580        ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
6581        ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
6582        ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
6583        ALC255_FIXUP_HEADSET_MODE,
6584        ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
6585        ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
6586        ALC292_FIXUP_TPT440_DOCK,
6587        ALC292_FIXUP_TPT440,
6588        ALC283_FIXUP_HEADSET_MIC,
6589        ALC255_FIXUP_MIC_MUTE_LED,
6590        ALC282_FIXUP_ASPIRE_V5_PINS,
6591        ALC269VB_FIXUP_ASPIRE_E1_COEF,
6592        ALC280_FIXUP_HP_GPIO4,
6593        ALC286_FIXUP_HP_GPIO_LED,
6594        ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY,
6595        ALC280_FIXUP_HP_DOCK_PINS,
6596        ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED,
6597        ALC280_FIXUP_HP_9480M,
6598        ALC245_FIXUP_HP_X360_AMP,
6599        ALC285_FIXUP_HP_SPECTRE_X360_EB1,
6600        ALC288_FIXUP_DELL_HEADSET_MODE,
6601        ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
6602        ALC288_FIXUP_DELL_XPS_13,
6603        ALC288_FIXUP_DISABLE_AAMIX,
6604        ALC292_FIXUP_DELL_E7X_AAMIX,
6605        ALC292_FIXUP_DELL_E7X,
6606        ALC292_FIXUP_DISABLE_AAMIX,
6607        ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK,
6608        ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE,
6609        ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
6610        ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
6611        ALC275_FIXUP_DELL_XPS,
6612        ALC293_FIXUP_LENOVO_SPK_NOISE,
6613        ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
6614        ALC255_FIXUP_DELL_SPK_NOISE,
6615        ALC225_FIXUP_DISABLE_MIC_VREF,
6616        ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6617        ALC295_FIXUP_DISABLE_DAC3,
6618        ALC285_FIXUP_SPEAKER2_TO_DAC1,
6619        ALC280_FIXUP_HP_HEADSET_MIC,
6620        ALC221_FIXUP_HP_FRONT_MIC,
6621        ALC292_FIXUP_TPT460,
6622        ALC298_FIXUP_SPK_VOLUME,
6623        ALC298_FIXUP_LENOVO_SPK_VOLUME,
6624        ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER,
6625        ALC269_FIXUP_ATIV_BOOK_8,
6626        ALC221_FIXUP_HP_MIC_NO_PRESENCE,
6627        ALC256_FIXUP_ASUS_HEADSET_MODE,
6628        ALC256_FIXUP_ASUS_MIC,
6629        ALC256_FIXUP_ASUS_AIO_GPIO2,
6630        ALC233_FIXUP_ASUS_MIC_NO_PRESENCE,
6631        ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
6632        ALC233_FIXUP_LENOVO_MULTI_CODECS,
6633        ALC233_FIXUP_ACER_HEADSET_MIC,
6634        ALC294_FIXUP_LENOVO_MIC_LOCATION,
6635        ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
6636        ALC225_FIXUP_S3_POP_NOISE,
6637        ALC700_FIXUP_INTEL_REFERENCE,
6638        ALC274_FIXUP_DELL_BIND_DACS,
6639        ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
6640        ALC298_FIXUP_TPT470_DOCK_FIX,
6641        ALC298_FIXUP_TPT470_DOCK,
6642        ALC255_FIXUP_DUMMY_LINEOUT_VERB,
6643        ALC255_FIXUP_DELL_HEADSET_MIC,
6644        ALC256_FIXUP_HUAWEI_MACH_WX9_PINS,
6645        ALC298_FIXUP_HUAWEI_MBX_STEREO,
6646        ALC295_FIXUP_HP_X360,
6647        ALC221_FIXUP_HP_HEADSET_MIC,
6648        ALC285_FIXUP_LENOVO_HEADPHONE_NOISE,
6649        ALC295_FIXUP_HP_AUTO_MUTE,
6650        ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
6651        ALC294_FIXUP_ASUS_MIC,
6652        ALC294_FIXUP_ASUS_HEADSET_MIC,
6653        ALC294_FIXUP_ASUS_SPK,
6654        ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE,
6655        ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
6656        ALC255_FIXUP_ACER_HEADSET_MIC,
6657        ALC295_FIXUP_CHROME_BOOK,
6658        ALC225_FIXUP_HEADSET_JACK,
6659        ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE,
6660        ALC225_FIXUP_WYSE_AUTO_MUTE,
6661        ALC225_FIXUP_WYSE_DISABLE_MIC_VREF,
6662        ALC286_FIXUP_ACER_AIO_HEADSET_MIC,
6663        ALC256_FIXUP_ASUS_HEADSET_MIC,
6664        ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
6665        ALC299_FIXUP_PREDATOR_SPK,
6666        ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE,
6667        ALC289_FIXUP_DELL_SPK2,
6668        ALC289_FIXUP_DUAL_SPK,
6669        ALC294_FIXUP_SPK2_TO_DAC1,
6670        ALC294_FIXUP_ASUS_DUAL_SPK,
6671        ALC285_FIXUP_THINKPAD_X1_GEN7,
6672        ALC285_FIXUP_THINKPAD_HEADSET_JACK,
6673        ALC294_FIXUP_ASUS_HPE,
6674        ALC294_FIXUP_ASUS_COEF_1B,
6675        ALC294_FIXUP_ASUS_GX502_HP,
6676        ALC294_FIXUP_ASUS_GX502_PINS,
6677        ALC294_FIXUP_ASUS_GX502_VERBS,
6678        ALC294_FIXUP_ASUS_GU502_HP,
6679        ALC294_FIXUP_ASUS_GU502_PINS,
6680        ALC294_FIXUP_ASUS_GU502_VERBS,
6681        ALC285_FIXUP_HP_GPIO_LED,
6682        ALC285_FIXUP_HP_MUTE_LED,
6683        ALC236_FIXUP_HP_GPIO_LED,
6684        ALC236_FIXUP_HP_MUTE_LED,
6685        ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
6686        ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
6687        ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
6688        ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS,
6689        ALC269VC_FIXUP_ACER_HEADSET_MIC,
6690        ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE,
6691        ALC289_FIXUP_ASUS_GA401,
6692        ALC289_FIXUP_ASUS_GA502,
6693        ALC256_FIXUP_ACER_MIC_NO_PRESENCE,
6694        ALC285_FIXUP_HP_GPIO_AMP_INIT,
6695        ALC269_FIXUP_CZC_B20,
6696        ALC269_FIXUP_CZC_TMI,
6697        ALC269_FIXUP_CZC_L101,
6698        ALC269_FIXUP_LEMOTE_A1802,
6699        ALC269_FIXUP_LEMOTE_A190X,
6700        ALC256_FIXUP_INTEL_NUC8_RUGGED,
6701        ALC233_FIXUP_INTEL_NUC8_DMIC,
6702        ALC233_FIXUP_INTEL_NUC8_BOOST,
6703        ALC256_FIXUP_INTEL_NUC10,
6704        ALC255_FIXUP_XIAOMI_HEADSET_MIC,
6705        ALC274_FIXUP_HP_MIC,
6706        ALC274_FIXUP_HP_HEADSET_MIC,
6707        ALC274_FIXUP_HP_ENVY_GPIO,
6708        ALC256_FIXUP_ASUS_HPE,
6709        ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK,
6710        ALC287_FIXUP_HP_GPIO_LED,
6711        ALC256_FIXUP_HP_HEADSET_MIC,
6712        ALC236_FIXUP_DELL_AIO_HEADSET_MIC,
6713        ALC282_FIXUP_ACER_DISABLE_LINEOUT,
6714        ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST,
6715        ALC256_FIXUP_ACER_HEADSET_MIC,
6716        ALC285_FIXUP_IDEAPAD_S740_COEF,
6717        ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST,
6718        ALC295_FIXUP_ASUS_DACS,
6719        ALC295_FIXUP_HP_OMEN,
6720        ALC285_FIXUP_HP_SPECTRE_X360,
6721        ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP,
6722        ALC623_FIXUP_LENOVO_THINKSTATION_P340,
6723        ALC255_FIXUP_ACER_HEADPHONE_AND_MIC,
6724        ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST,
6725        ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS,
6726        ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
6727        ALC287_FIXUP_YOGA7_14ITL_SPEAKERS,
6728        ALC287_FIXUP_13S_GEN2_SPEAKERS,
6729        ALC256_FIXUP_TONGFANG_RESET_PERSISTENT_SETTINGS,
6730};
6731
6732static const struct hda_fixup alc269_fixups[] = {
6733        [ALC269_FIXUP_GPIO2] = {
6734                .type = HDA_FIXUP_FUNC,
6735                .v.func = alc_fixup_gpio2,
6736        },
6737        [ALC269_FIXUP_SONY_VAIO] = {
6738                .type = HDA_FIXUP_PINCTLS,
6739                .v.pins = (const struct hda_pintbl[]) {
6740                        {0x19, PIN_VREFGRD},
6741                        {}
6742                }
6743        },
6744        [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
6745                .type = HDA_FIXUP_FUNC,
6746                .v.func = alc275_fixup_gpio4_off,
6747                .chained = true,
6748                .chain_id = ALC269_FIXUP_SONY_VAIO
6749        },
6750        [ALC269_FIXUP_DELL_M101Z] = {
6751                .type = HDA_FIXUP_VERBS,
6752                .v.verbs = (const struct hda_verb[]) {
6753                        /* Enables internal speaker */
6754                        {0x20, AC_VERB_SET_COEF_INDEX, 13},
6755                        {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
6756                        {}
6757                }
6758        },
6759        [ALC269_FIXUP_SKU_IGNORE] = {
6760                .type = HDA_FIXUP_FUNC,
6761                .v.func = alc_fixup_sku_ignore,
6762        },
6763        [ALC269_FIXUP_ASUS_G73JW] = {
6764                .type = HDA_FIXUP_PINS,
6765                .v.pins = (const struct hda_pintbl[]) {
6766                        { 0x17, 0x99130111 }, /* subwoofer */
6767                        { }
6768                }
6769        },
6770        [ALC269_FIXUP_LENOVO_EAPD] = {
6771                .type = HDA_FIXUP_VERBS,
6772                .v.verbs = (const struct hda_verb[]) {
6773                        {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
6774                        {}
6775                }
6776        },
6777        [ALC275_FIXUP_SONY_HWEQ] = {
6778                .type = HDA_FIXUP_FUNC,
6779                .v.func = alc269_fixup_hweq,
6780                .chained = true,
6781                .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
6782        },
6783        [ALC275_FIXUP_SONY_DISABLE_AAMIX] = {
6784                .type = HDA_FIXUP_FUNC,
6785                .v.func = alc_fixup_disable_aamix,
6786                .chained = true,
6787                .chain_id = ALC269_FIXUP_SONY_VAIO
6788        },
6789        [ALC271_FIXUP_DMIC] = {
6790                .type = HDA_FIXUP_FUNC,
6791                .v.func = alc271_fixup_dmic,
6792        },
6793        [ALC269_FIXUP_PCM_44K] = {
6794                .type = HDA_FIXUP_FUNC,
6795                .v.func = alc269_fixup_pcm_44k,
6796                .chained = true,
6797                .chain_id = ALC269_FIXUP_QUANTA_MUTE
6798        },
6799        [ALC269_FIXUP_STEREO_DMIC] = {
6800                .type = HDA_FIXUP_FUNC,
6801                .v.func = alc269_fixup_stereo_dmic,
6802        },
6803        [ALC269_FIXUP_HEADSET_MIC] = {
6804                .type = HDA_FIXUP_FUNC,
6805                .v.func = alc269_fixup_headset_mic,
6806        },
6807        [ALC269_FIXUP_QUANTA_MUTE] = {
6808                .type = HDA_FIXUP_FUNC,
6809                .v.func = alc269_fixup_quanta_mute,
6810        },
6811        [ALC269_FIXUP_LIFEBOOK] = {
6812                .type = HDA_FIXUP_PINS,
6813                .v.pins = (const struct hda_pintbl[]) {
6814                        { 0x1a, 0x2101103f }, /* dock line-out */
6815                        { 0x1b, 0x23a11040 }, /* dock mic-in */
6816                        { }
6817                },
6818                .chained = true,
6819                .chain_id = ALC269_FIXUP_QUANTA_MUTE
6820        },
6821        [ALC269_FIXUP_LIFEBOOK_EXTMIC] = {
6822                .type = HDA_FIXUP_PINS,
6823                .v.pins = (const struct hda_pintbl[]) {
6824                        { 0x19, 0x01a1903c }, /* headset mic, with jack detect */
6825                        { }
6826                },
6827        },
6828        [ALC269_FIXUP_LIFEBOOK_HP_PIN] = {
6829                .type = HDA_FIXUP_PINS,
6830                .v.pins = (const struct hda_pintbl[]) {
6831                        { 0x21, 0x0221102f }, /* HP out */
6832                        { }
6833                },
6834        },
6835        [ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT] = {
6836                .type = HDA_FIXUP_FUNC,
6837                .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
6838        },
6839        [ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC] = {
6840                .type = HDA_FIXUP_FUNC,
6841                .v.func = alc269_fixup_pincfg_U7x7_headset_mic,
6842        },
6843        [ALC269_FIXUP_AMIC] = {
6844                .type = HDA_FIXUP_PINS,
6845                .v.pins = (const struct hda_pintbl[]) {
6846                        { 0x14, 0x99130110 }, /* speaker */
6847                        { 0x15, 0x0121401f }, /* HP out */
6848                        { 0x18, 0x01a19c20 }, /* mic */
6849                        { 0x19, 0x99a3092f }, /* int-mic */
6850                        { }
6851                },
6852        },
6853        [ALC269_FIXUP_DMIC] = {
6854                .type = HDA_FIXUP_PINS,
6855                .v.pins = (const struct hda_pintbl[]) {
6856                        { 0x12, 0x99a3092f }, /* int-mic */
6857                        { 0x14, 0x99130110 }, /* speaker */
6858                        { 0x15, 0x0121401f }, /* HP out */
6859                        { 0x18, 0x01a19c20 }, /* mic */
6860                        { }
6861                },
6862        },
6863        [ALC269VB_FIXUP_AMIC] = {
6864                .type = HDA_FIXUP_PINS,
6865                .v.pins = (const struct hda_pintbl[]) {
6866                        { 0x14, 0x99130110 }, /* speaker */
6867                        { 0x18, 0x01a19c20 }, /* mic */
6868                        { 0x19, 0x99a3092f }, /* int-mic */
6869                        { 0x21, 0x0121401f }, /* HP out */
6870                        { }
6871                },
6872        },
6873        [ALC269VB_FIXUP_DMIC] = {
6874                .type = HDA_FIXUP_PINS,
6875                .v.pins = (const struct hda_pintbl[]) {
6876                        { 0x12, 0x99a3092f }, /* int-mic */
6877                        { 0x14, 0x99130110 }, /* speaker */
6878                        { 0x18, 0x01a19c20 }, /* mic */
6879                        { 0x21, 0x0121401f }, /* HP out */
6880                        { }
6881                },
6882        },
6883        [ALC269_FIXUP_HP_MUTE_LED] = {
6884                .type = HDA_FIXUP_FUNC,
6885                .v.func = alc269_fixup_hp_mute_led,
6886        },
6887        [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
6888                .type = HDA_FIXUP_FUNC,
6889                .v.func = alc269_fixup_hp_mute_led_mic1,
6890        },
6891        [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
6892                .type = HDA_FIXUP_FUNC,
6893                .v.func = alc269_fixup_hp_mute_led_mic2,
6894        },
6895        [ALC269_FIXUP_HP_MUTE_LED_MIC3] = {
6896                .type = HDA_FIXUP_FUNC,
6897                .v.func = alc269_fixup_hp_mute_led_mic3,
6898                .chained = true,
6899                .chain_id = ALC295_FIXUP_HP_AUTO_MUTE
6900        },
6901        [ALC269_FIXUP_HP_GPIO_LED] = {
6902                .type = HDA_FIXUP_FUNC,
6903                .v.func = alc269_fixup_hp_gpio_led,
6904        },
6905        [ALC269_FIXUP_HP_GPIO_MIC1_LED] = {
6906                .type = HDA_FIXUP_FUNC,
6907                .v.func = alc269_fixup_hp_gpio_mic1_led,
6908        },
6909        [ALC269_FIXUP_HP_LINE1_MIC1_LED] = {
6910                .type = HDA_FIXUP_FUNC,
6911                .v.func = alc269_fixup_hp_line1_mic1_led,
6912        },
6913        [ALC269_FIXUP_INV_DMIC] = {
6914                .type = HDA_FIXUP_FUNC,
6915                .v.func = alc_fixup_inv_dmic,
6916        },
6917        [ALC269_FIXUP_NO_SHUTUP] = {
6918                .type = HDA_FIXUP_FUNC,
6919                .v.func = alc_fixup_no_shutup,
6920        },
6921        [ALC269_FIXUP_LENOVO_DOCK] = {
6922                .type = HDA_FIXUP_PINS,
6923                .v.pins = (const struct hda_pintbl[]) {
6924                        { 0x19, 0x23a11040 }, /* dock mic */
6925                        { 0x1b, 0x2121103f }, /* dock headphone */
6926                        { }
6927                },
6928                .chained = true,
6929                .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
6930        },
6931        [ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST] = {
6932                .type = HDA_FIXUP_FUNC,
6933                .v.func = alc269_fixup_limit_int_mic_boost,
6934                .chained = true,
6935                .chain_id = ALC269_FIXUP_LENOVO_DOCK,
6936        },
6937        [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
6938                .type = HDA_FIXUP_FUNC,
6939                .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
6940                .chained = true,
6941                .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
6942        },
6943        [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
6944                .type = HDA_FIXUP_PINS,
6945                .v.pins = (const struct hda_pintbl[]) {
6946                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6947                        { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6948                        { }
6949                },
6950                .chained = true,
6951                .chain_id = ALC269_FIXUP_HEADSET_MODE
6952        },
6953        [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
6954                .type = HDA_FIXUP_PINS,
6955                .v.pins = (const struct hda_pintbl[]) {
6956                        { 0x16, 0x21014020 }, /* dock line out */
6957                        { 0x19, 0x21a19030 }, /* dock mic */
6958                        { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6959                        { }
6960                },
6961                .chained = true,
6962                .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6963        },
6964        [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
6965                .type = HDA_FIXUP_PINS,
6966                .v.pins = (const struct hda_pintbl[]) {
6967                        { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6968                        { }
6969                },
6970                .chained = true,
6971                .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6972        },
6973        [ALC269_FIXUP_DELL4_MIC_NO_PRESENCE] = {
6974                .type = HDA_FIXUP_PINS,
6975                .v.pins = (const struct hda_pintbl[]) {
6976                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
6977                        { 0x1b, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
6978                        { }
6979                },
6980                .chained = true,
6981                .chain_id = ALC269_FIXUP_HEADSET_MODE
6982        },
6983        [ALC269_FIXUP_HEADSET_MODE] = {
6984                .type = HDA_FIXUP_FUNC,
6985                .v.func = alc_fixup_headset_mode,
6986                .chained = true,
6987                .chain_id = ALC255_FIXUP_MIC_MUTE_LED
6988        },
6989        [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
6990                .type = HDA_FIXUP_FUNC,
6991                .v.func = alc_fixup_headset_mode_no_hp_mic,
6992        },
6993        [ALC269_FIXUP_ASPIRE_HEADSET_MIC] = {
6994                .type = HDA_FIXUP_PINS,
6995                .v.pins = (const struct hda_pintbl[]) {
6996                        { 0x19, 0x01a1913c }, /* headset mic w/o jack detect */
6997                        { }
6998                },
6999                .chained = true,
7000                .chain_id = ALC269_FIXUP_HEADSET_MODE,
7001        },
7002        [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
7003                .type = HDA_FIXUP_PINS,
7004                .v.pins = (const struct hda_pintbl[]) {
7005                        { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7006                        { }
7007                },
7008                .chained = true,
7009                .chain_id = ALC269_FIXUP_HEADSET_MIC
7010        },
7011        [ALC256_FIXUP_HUAWEI_MACH_WX9_PINS] = {
7012                .type = HDA_FIXUP_PINS,
7013                .v.pins = (const struct hda_pintbl[]) {
7014                        {0x12, 0x90a60130},
7015                        {0x13, 0x40000000},
7016                        {0x14, 0x90170110},
7017                        {0x18, 0x411111f0},
7018                        {0x19, 0x04a11040},
7019                        {0x1a, 0x411111f0},
7020                        {0x1b, 0x90170112},
7021                        {0x1d, 0x40759a05},
7022                        {0x1e, 0x411111f0},
7023                        {0x21, 0x04211020},
7024                        { }
7025                },
7026                .chained = true,
7027                .chain_id = ALC255_FIXUP_MIC_MUTE_LED
7028        },
7029        [ALC298_FIXUP_HUAWEI_MBX_STEREO] = {
7030                .type = HDA_FIXUP_FUNC,
7031                .v.func = alc298_fixup_huawei_mbx_stereo,
7032                .chained = true,
7033                .chain_id = ALC255_FIXUP_MIC_MUTE_LED
7034        },
7035        [ALC269_FIXUP_ASUS_X101_FUNC] = {
7036                .type = HDA_FIXUP_FUNC,
7037                .v.func = alc269_fixup_x101_headset_mic,
7038        },
7039        [ALC269_FIXUP_ASUS_X101_VERB] = {
7040                .type = HDA_FIXUP_VERBS,
7041                .v.verbs = (const struct hda_verb[]) {
7042                        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
7043                        {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
7044                        {0x20, AC_VERB_SET_PROC_COEF,  0x0310},
7045                        { }
7046                },
7047                .chained = true,
7048                .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
7049        },
7050        [ALC269_FIXUP_ASUS_X101] = {
7051                .type = HDA_FIXUP_PINS,
7052                .v.pins = (const struct hda_pintbl[]) {
7053                        { 0x18, 0x04a1182c }, /* Headset mic */
7054                        { }
7055                },
7056                .chained = true,
7057                .chain_id = ALC269_FIXUP_ASUS_X101_VERB
7058        },
7059        [ALC271_FIXUP_AMIC_MIC2] = {
7060                .type = HDA_FIXUP_PINS,
7061                .v.pins = (const struct hda_pintbl[]) {
7062                        { 0x14, 0x99130110 }, /* speaker */
7063                        { 0x19, 0x01a19c20 }, /* mic */
7064                        { 0x1b, 0x99a7012f }, /* int-mic */
7065                        { 0x21, 0x0121401f }, /* HP out */
7066                        { }
7067                },
7068        },
7069        [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
7070                .type = HDA_FIXUP_FUNC,
7071                .v.func = alc271_hp_gate_mic_jack,
7072                .chained = true,
7073                .chain_id = ALC271_FIXUP_AMIC_MIC2,
7074        },
7075        [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
7076                .type = HDA_FIXUP_FUNC,
7077                .v.func = alc269_fixup_limit_int_mic_boost,
7078                .chained = true,
7079                .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
7080        },
7081        [ALC269_FIXUP_ACER_AC700] = {
7082                .type = HDA_FIXUP_PINS,
7083                .v.pins = (const struct hda_pintbl[]) {
7084                        { 0x12, 0x99a3092f }, /* int-mic */
7085                        { 0x14, 0x99130110 }, /* speaker */
7086                        { 0x18, 0x03a11c20 }, /* mic */
7087                        { 0x1e, 0x0346101e }, /* SPDIF1 */
7088                        { 0x21, 0x0321101f }, /* HP out */
7089                        { }
7090                },
7091                .chained = true,
7092                .chain_id = ALC271_FIXUP_DMIC,
7093        },
7094        [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
7095                .type = HDA_FIXUP_FUNC,
7096                .v.func = alc269_fixup_limit_int_mic_boost,
7097                .chained = true,
7098                .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
7099        },
7100        [ALC269VB_FIXUP_ASUS_ZENBOOK] = {
7101                .type = HDA_FIXUP_FUNC,
7102                .v.func = alc269_fixup_limit_int_mic_boost,
7103                .chained = true,
7104                .chain_id = ALC269VB_FIXUP_DMIC,
7105        },
7106        [ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A] = {
7107                .type = HDA_FIXUP_VERBS,
7108                .v.verbs = (const struct hda_verb[]) {
7109                        /* class-D output amp +5dB */
7110                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x12 },
7111                        { 0x20, AC_VERB_SET_PROC_COEF, 0x2800 },
7112                        {}
7113                },
7114                .chained = true,
7115                .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
7116        },
7117        [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
7118                .type = HDA_FIXUP_FUNC,
7119                .v.func = alc269_fixup_limit_int_mic_boost,
7120                .chained = true,
7121                .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
7122        },
7123        [ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
7124                .type = HDA_FIXUP_PINS,
7125                .v.pins = (const struct hda_pintbl[]) {
7126                        { 0x12, 0x99a3092f }, /* int-mic */
7127                        { 0x18, 0x03a11d20 }, /* mic */
7128                        { 0x19, 0x411111f0 }, /* Unused bogus pin */
7129                        { }
7130                },
7131        },
7132        [ALC283_FIXUP_CHROME_BOOK] = {
7133                .type = HDA_FIXUP_FUNC,
7134                .v.func = alc283_fixup_chromebook,
7135        },
7136        [ALC283_FIXUP_SENSE_COMBO_JACK] = {
7137                .type = HDA_FIXUP_FUNC,
7138                .v.func = alc283_fixup_sense_combo_jack,
7139                .chained = true,
7140                .chain_id = ALC283_FIXUP_CHROME_BOOK,
7141        },
7142        [ALC282_FIXUP_ASUS_TX300] = {
7143                .type = HDA_FIXUP_FUNC,
7144                .v.func = alc282_fixup_asus_tx300,
7145        },
7146        [ALC283_FIXUP_INT_MIC] = {
7147                .type = HDA_FIXUP_VERBS,
7148                .v.verbs = (const struct hda_verb[]) {
7149                        {0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
7150                        {0x20, AC_VERB_SET_PROC_COEF, 0x0011},
7151                        { }
7152                },
7153                .chained = true,
7154                .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
7155        },
7156        [ALC290_FIXUP_SUBWOOFER_HSJACK] = {
7157                .type = HDA_FIXUP_PINS,
7158                .v.pins = (const struct hda_pintbl[]) {
7159                        { 0x17, 0x90170112 }, /* subwoofer */
7160                        { }
7161                },
7162                .chained = true,
7163                .chain_id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK,
7164        },
7165        [ALC290_FIXUP_SUBWOOFER] = {
7166                .type = HDA_FIXUP_PINS,
7167                .v.pins = (const struct hda_pintbl[]) {
7168                        { 0x17, 0x90170112 }, /* subwoofer */
7169                        { }
7170                },
7171                .chained = true,
7172                .chain_id = ALC290_FIXUP_MONO_SPEAKERS,
7173        },
7174        [ALC290_FIXUP_MONO_SPEAKERS] = {
7175                .type = HDA_FIXUP_FUNC,
7176                .v.func = alc290_fixup_mono_speakers,
7177        },
7178        [ALC290_FIXUP_MONO_SPEAKERS_HSJACK] = {
7179                .type = HDA_FIXUP_FUNC,
7180                .v.func = alc290_fixup_mono_speakers,
7181                .chained = true,
7182                .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
7183        },
7184        [ALC269_FIXUP_THINKPAD_ACPI] = {
7185                .type = HDA_FIXUP_FUNC,
7186                .v.func = alc_fixup_thinkpad_acpi,
7187                .chained = true,
7188                .chain_id = ALC269_FIXUP_SKU_IGNORE,
7189        },
7190        [ALC269_FIXUP_DMIC_THINKPAD_ACPI] = {
7191                .type = HDA_FIXUP_FUNC,
7192                .v.func = alc_fixup_inv_dmic,
7193                .chained = true,
7194                .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
7195        },
7196        [ALC255_FIXUP_ACER_MIC_NO_PRESENCE] = {
7197                .type = HDA_FIXUP_PINS,
7198                .v.pins = (const struct hda_pintbl[]) {
7199                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7200                        { }
7201                },
7202                .chained = true,
7203                .chain_id = ALC255_FIXUP_HEADSET_MODE
7204        },
7205        [ALC255_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7206                .type = HDA_FIXUP_PINS,
7207                .v.pins = (const struct hda_pintbl[]) {
7208                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7209                        { }
7210                },
7211                .chained = true,
7212                .chain_id = ALC255_FIXUP_HEADSET_MODE
7213        },
7214        [ALC255_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7215                .type = HDA_FIXUP_PINS,
7216                .v.pins = (const struct hda_pintbl[]) {
7217                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7218                        { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7219                        { }
7220                },
7221                .chained = true,
7222                .chain_id = ALC255_FIXUP_HEADSET_MODE
7223        },
7224        [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
7225                .type = HDA_FIXUP_PINS,
7226                .v.pins = (const struct hda_pintbl[]) {
7227                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7228                        { }
7229                },
7230                .chained = true,
7231                .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
7232        },
7233        [ALC255_FIXUP_HEADSET_MODE] = {
7234                .type = HDA_FIXUP_FUNC,
7235                .v.func = alc_fixup_headset_mode_alc255,
7236                .chained = true,
7237                .chain_id = ALC255_FIXUP_MIC_MUTE_LED
7238        },
7239        [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
7240                .type = HDA_FIXUP_FUNC,
7241                .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
7242        },
7243        [ALC293_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7244                .type = HDA_FIXUP_PINS,
7245                .v.pins = (const struct hda_pintbl[]) {
7246                        { 0x18, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7247                        { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7248                        { }
7249                },
7250                .chained = true,
7251                .chain_id = ALC269_FIXUP_HEADSET_MODE
7252        },
7253        [ALC292_FIXUP_TPT440_DOCK] = {
7254                .type = HDA_FIXUP_FUNC,
7255                .v.func = alc_fixup_tpt440_dock,
7256                .chained = true,
7257                .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
7258        },
7259        [ALC292_FIXUP_TPT440] = {
7260                .type = HDA_FIXUP_FUNC,
7261                .v.func = alc_fixup_disable_aamix,
7262                .chained = true,
7263                .chain_id = ALC292_FIXUP_TPT440_DOCK,
7264        },
7265        [ALC283_FIXUP_HEADSET_MIC] = {
7266                .type = HDA_FIXUP_PINS,
7267                .v.pins = (const struct hda_pintbl[]) {
7268                        { 0x19, 0x04a110f0 },
7269                        { },
7270                },
7271        },
7272        [ALC255_FIXUP_MIC_MUTE_LED] = {
7273                .type = HDA_FIXUP_FUNC,
7274                .v.func = alc_fixup_micmute_led,
7275        },
7276        [ALC282_FIXUP_ASPIRE_V5_PINS] = {
7277                .type = HDA_FIXUP_PINS,
7278                .v.pins = (const struct hda_pintbl[]) {
7279                        { 0x12, 0x90a60130 },
7280                        { 0x14, 0x90170110 },
7281                        { 0x17, 0x40000008 },
7282                        { 0x18, 0x411111f0 },
7283                        { 0x19, 0x01a1913c },
7284                        { 0x1a, 0x411111f0 },
7285                        { 0x1b, 0x411111f0 },
7286                        { 0x1d, 0x40f89b2d },
7287                        { 0x1e, 0x411111f0 },
7288                        { 0x21, 0x0321101f },
7289                        { },
7290                },
7291        },
7292        [ALC269VB_FIXUP_ASPIRE_E1_COEF] = {
7293                .type = HDA_FIXUP_FUNC,
7294                .v.func = alc269vb_fixup_aspire_e1_coef,
7295        },
7296        [ALC280_FIXUP_HP_GPIO4] = {
7297                .type = HDA_FIXUP_FUNC,
7298                .v.func = alc280_fixup_hp_gpio4,
7299        },
7300        [ALC286_FIXUP_HP_GPIO_LED] = {
7301                .type = HDA_FIXUP_FUNC,
7302                .v.func = alc286_fixup_hp_gpio_led,
7303        },
7304        [ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY] = {
7305                .type = HDA_FIXUP_FUNC,
7306                .v.func = alc280_fixup_hp_gpio2_mic_hotkey,
7307        },
7308        [ALC280_FIXUP_HP_DOCK_PINS] = {
7309                .type = HDA_FIXUP_PINS,
7310                .v.pins = (const struct hda_pintbl[]) {
7311                        { 0x1b, 0x21011020 }, /* line-out */
7312                        { 0x1a, 0x01a1903c }, /* headset mic */
7313                        { 0x18, 0x2181103f }, /* line-in */
7314                        { },
7315                },
7316                .chained = true,
7317                .chain_id = ALC280_FIXUP_HP_GPIO4
7318        },
7319        [ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED] = {
7320                .type = HDA_FIXUP_PINS,
7321                .v.pins = (const struct hda_pintbl[]) {
7322                        { 0x1b, 0x21011020 }, /* line-out */
7323                        { 0x18, 0x2181103f }, /* line-in */
7324                        { },
7325                },
7326                .chained = true,
7327                .chain_id = ALC269_FIXUP_HP_GPIO_MIC1_LED
7328        },
7329        [ALC280_FIXUP_HP_9480M] = {
7330                .type = HDA_FIXUP_FUNC,
7331                .v.func = alc280_fixup_hp_9480m,
7332        },
7333        [ALC245_FIXUP_HP_X360_AMP] = {
7334                .type = HDA_FIXUP_FUNC,
7335                .v.func = alc245_fixup_hp_x360_amp,
7336        },
7337        [ALC288_FIXUP_DELL_HEADSET_MODE] = {
7338                .type = HDA_FIXUP_FUNC,
7339                .v.func = alc_fixup_headset_mode_dell_alc288,
7340                .chained = true,
7341                .chain_id = ALC255_FIXUP_MIC_MUTE_LED
7342        },
7343        [ALC288_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7344                .type = HDA_FIXUP_PINS,
7345                .v.pins = (const struct hda_pintbl[]) {
7346                        { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7347                        { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7348                        { }
7349                },
7350                .chained = true,
7351                .chain_id = ALC288_FIXUP_DELL_HEADSET_MODE
7352        },
7353        [ALC288_FIXUP_DISABLE_AAMIX] = {
7354                .type = HDA_FIXUP_FUNC,
7355                .v.func = alc_fixup_disable_aamix,
7356                .chained = true,
7357                .chain_id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE
7358        },
7359        [ALC288_FIXUP_DELL_XPS_13] = {
7360                .type = HDA_FIXUP_FUNC,
7361                .v.func = alc_fixup_dell_xps13,
7362                .chained = true,
7363                .chain_id = ALC288_FIXUP_DISABLE_AAMIX
7364        },
7365        [ALC292_FIXUP_DISABLE_AAMIX] = {
7366                .type = HDA_FIXUP_FUNC,
7367                .v.func = alc_fixup_disable_aamix,
7368                .chained = true,
7369                .chain_id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE
7370        },
7371        [ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK] = {
7372                .type = HDA_FIXUP_FUNC,
7373                .v.func = alc_fixup_disable_aamix,
7374                .chained = true,
7375                .chain_id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE
7376        },
7377        [ALC292_FIXUP_DELL_E7X_AAMIX] = {
7378                .type = HDA_FIXUP_FUNC,
7379                .v.func = alc_fixup_dell_xps13,
7380                .chained = true,
7381                .chain_id = ALC292_FIXUP_DISABLE_AAMIX
7382        },
7383        [ALC292_FIXUP_DELL_E7X] = {
7384                .type = HDA_FIXUP_FUNC,
7385                .v.func = alc_fixup_micmute_led,
7386                /* micmute fixup must be applied at last */
7387                .chained_before = true,
7388                .chain_id = ALC292_FIXUP_DELL_E7X_AAMIX,
7389        },
7390        [ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE] = {
7391                .type = HDA_FIXUP_PINS,
7392                .v.pins = (const struct hda_pintbl[]) {
7393                        { 0x18, 0x01a1913c }, /* headset mic w/o jack detect */
7394                        { }
7395                },
7396                .chained_before = true,
7397                .chain_id = ALC269_FIXUP_HEADSET_MODE,
7398        },
7399        [ALC298_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7400                .type = HDA_FIXUP_PINS,
7401                .v.pins = (const struct hda_pintbl[]) {
7402                        { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7403                        { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7404                        { }
7405                },
7406                .chained = true,
7407                .chain_id = ALC269_FIXUP_HEADSET_MODE
7408        },
7409        [ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE] = {
7410                .type = HDA_FIXUP_PINS,
7411                .v.pins = (const struct hda_pintbl[]) {
7412                        { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7413                        { }
7414                },
7415                .chained = true,
7416                .chain_id = ALC269_FIXUP_HEADSET_MODE
7417        },
7418        [ALC275_FIXUP_DELL_XPS] = {
7419                .type = HDA_FIXUP_VERBS,
7420                .v.verbs = (const struct hda_verb[]) {
7421                        /* Enables internal speaker */
7422                        {0x20, AC_VERB_SET_COEF_INDEX, 0x1f},
7423                        {0x20, AC_VERB_SET_PROC_COEF, 0x00c0},
7424                        {0x20, AC_VERB_SET_COEF_INDEX, 0x30},
7425                        {0x20, AC_VERB_SET_PROC_COEF, 0x00b1},
7426                        {}
7427                }
7428        },
7429        [ALC293_FIXUP_LENOVO_SPK_NOISE] = {
7430                .type = HDA_FIXUP_FUNC,
7431                .v.func = alc_fixup_disable_aamix,
7432                .chained = true,
7433                .chain_id = ALC269_FIXUP_THINKPAD_ACPI
7434        },
7435        [ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY] = {
7436                .type = HDA_FIXUP_FUNC,
7437                .v.func = alc233_fixup_lenovo_line2_mic_hotkey,
7438        },
7439        [ALC233_FIXUP_INTEL_NUC8_DMIC] = {
7440                .type = HDA_FIXUP_FUNC,
7441                .v.func = alc_fixup_inv_dmic,
7442                .chained = true,
7443                .chain_id = ALC233_FIXUP_INTEL_NUC8_BOOST,
7444        },
7445        [ALC233_FIXUP_INTEL_NUC8_BOOST] = {
7446                .type = HDA_FIXUP_FUNC,
7447                .v.func = alc269_fixup_limit_int_mic_boost
7448        },
7449        [ALC255_FIXUP_DELL_SPK_NOISE] = {
7450                .type = HDA_FIXUP_FUNC,
7451                .v.func = alc_fixup_disable_aamix,
7452                .chained = true,
7453                .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
7454        },
7455        [ALC225_FIXUP_DISABLE_MIC_VREF] = {
7456                .type = HDA_FIXUP_FUNC,
7457                .v.func = alc_fixup_disable_mic_vref,
7458                .chained = true,
7459                .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
7460        },
7461        [ALC225_FIXUP_DELL1_MIC_NO_PRESENCE] = {
7462                .type = HDA_FIXUP_VERBS,
7463                .v.verbs = (const struct hda_verb[]) {
7464                        /* Disable pass-through path for FRONT 14h */
7465                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
7466                        { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
7467                        {}
7468                },
7469                .chained = true,
7470                .chain_id = ALC225_FIXUP_DISABLE_MIC_VREF
7471        },
7472        [ALC280_FIXUP_HP_HEADSET_MIC] = {
7473                .type = HDA_FIXUP_FUNC,
7474                .v.func = alc_fixup_disable_aamix,
7475                .chained = true,
7476                .chain_id = ALC269_FIXUP_HEADSET_MIC,
7477        },
7478        [ALC221_FIXUP_HP_FRONT_MIC] = {
7479                .type = HDA_FIXUP_PINS,
7480                .v.pins = (const struct hda_pintbl[]) {
7481                        { 0x19, 0x02a19020 }, /* Front Mic */
7482                        { }
7483                },
7484        },
7485        [ALC292_FIXUP_TPT460] = {
7486                .type = HDA_FIXUP_FUNC,
7487                .v.func = alc_fixup_tpt440_dock,
7488                .chained = true,
7489                .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE,
7490        },
7491        [ALC298_FIXUP_SPK_VOLUME] = {
7492                .type = HDA_FIXUP_FUNC,
7493                .v.func = alc298_fixup_speaker_volume,
7494                .chained = true,
7495                .chain_id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
7496        },
7497        [ALC298_FIXUP_LENOVO_SPK_VOLUME] = {
7498                .type = HDA_FIXUP_FUNC,
7499                .v.func = alc298_fixup_speaker_volume,
7500        },
7501        [ALC295_FIXUP_DISABLE_DAC3] = {
7502                .type = HDA_FIXUP_FUNC,
7503                .v.func = alc295_fixup_disable_dac3,
7504        },
7505        [ALC285_FIXUP_SPEAKER2_TO_DAC1] = {
7506                .type = HDA_FIXUP_FUNC,
7507                .v.func = alc285_fixup_speaker2_to_dac1,
7508                .chained = true,
7509                .chain_id = ALC269_FIXUP_THINKPAD_ACPI
7510        },
7511        [ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
7512                .type = HDA_FIXUP_PINS,
7513                .v.pins = (const struct hda_pintbl[]) {
7514                        { 0x1b, 0x90170151 },
7515                        { }
7516                },
7517                .chained = true,
7518                .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
7519        },
7520        [ALC269_FIXUP_ATIV_BOOK_8] = {
7521                .type = HDA_FIXUP_FUNC,
7522                .v.func = alc_fixup_auto_mute_via_amp,
7523                .chained = true,
7524                .chain_id = ALC269_FIXUP_NO_SHUTUP
7525        },
7526        [ALC221_FIXUP_HP_MIC_NO_PRESENCE] = {
7527                .type = HDA_FIXUP_PINS,
7528                .v.pins = (const struct hda_pintbl[]) {
7529                        { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7530                        { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
7531                        { }
7532                },
7533                .chained = true,
7534                .chain_id = ALC269_FIXUP_HEADSET_MODE
7535        },
7536        [ALC256_FIXUP_ASUS_HEADSET_MODE] = {
7537                .type = HDA_FIXUP_FUNC,
7538                .v.func = alc_fixup_headset_mode,
7539        },
7540        [ALC256_FIXUP_ASUS_MIC] = {
7541                .type = HDA_FIXUP_PINS,
7542                .v.pins = (const struct hda_pintbl[]) {
7543                        { 0x13, 0x90a60160 }, /* use as internal mic */
7544                        { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
7545                        { }
7546                },
7547                .chained = true,
7548                .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7549        },
7550        [ALC256_FIXUP_ASUS_AIO_GPIO2] = {
7551                .type = HDA_FIXUP_FUNC,
7552                /* Set up GPIO2 for the speaker amp */
7553                .v.func = alc_fixup_gpio4,
7554        },
7555        [ALC233_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7556                .type = HDA_FIXUP_PINS,
7557                .v.pins = (const struct hda_pintbl[]) {
7558                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7559                        { }
7560                },
7561                .chained = true,
7562                .chain_id = ALC269_FIXUP_HEADSET_MIC
7563        },
7564        [ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE] = {
7565                .type = HDA_FIXUP_VERBS,
7566                .v.verbs = (const struct hda_verb[]) {
7567                        /* Enables internal speaker */
7568                        {0x20, AC_VERB_SET_COEF_INDEX, 0x40},
7569                        {0x20, AC_VERB_SET_PROC_COEF, 0x8800},
7570                        {}
7571                },
7572                .chained = true,
7573                .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
7574        },
7575        [ALC233_FIXUP_LENOVO_MULTI_CODECS] = {
7576                .type = HDA_FIXUP_FUNC,
7577                .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
7578                .chained = true,
7579                .chain_id = ALC269_FIXUP_GPIO2
7580        },
7581        [ALC233_FIXUP_ACER_HEADSET_MIC] = {
7582                .type = HDA_FIXUP_VERBS,
7583                .v.verbs = (const struct hda_verb[]) {
7584                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
7585                        { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
7586                        { }
7587                },
7588                .chained = true,
7589                .chain_id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE
7590        },
7591        [ALC294_FIXUP_LENOVO_MIC_LOCATION] = {
7592                .type = HDA_FIXUP_PINS,
7593                .v.pins = (const struct hda_pintbl[]) {
7594                        /* Change the mic location from front to right, otherwise there are
7595                           two front mics with the same name, pulseaudio can't handle them.
7596                           This is just a temporary workaround, after applying this fixup,
7597                           there will be one "Front Mic" and one "Mic" in this machine.
7598                         */
7599                        { 0x1a, 0x04a19040 },
7600                        { }
7601                },
7602        },
7603        [ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE] = {
7604                .type = HDA_FIXUP_PINS,
7605                .v.pins = (const struct hda_pintbl[]) {
7606                        { 0x16, 0x0101102f }, /* Rear Headset HP */
7607                        { 0x19, 0x02a1913c }, /* use as Front headset mic, without its own jack detect */
7608                        { 0x1a, 0x01a19030 }, /* Rear Headset MIC */
7609                        { 0x1b, 0x02011020 },
7610                        { }
7611                },
7612                .chained = true,
7613                .chain_id = ALC225_FIXUP_S3_POP_NOISE
7614        },
7615        [ALC225_FIXUP_S3_POP_NOISE] = {
7616                .type = HDA_FIXUP_FUNC,
7617                .v.func = alc225_fixup_s3_pop_noise,
7618                .chained = true,
7619                .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7620        },
7621        [ALC700_FIXUP_INTEL_REFERENCE] = {
7622                .type = HDA_FIXUP_VERBS,
7623                .v.verbs = (const struct hda_verb[]) {
7624                        /* Enables internal speaker */
7625                        {0x20, AC_VERB_SET_COEF_INDEX, 0x45},
7626                        {0x20, AC_VERB_SET_PROC_COEF, 0x5289},
7627                        {0x20, AC_VERB_SET_COEF_INDEX, 0x4A},
7628                        {0x20, AC_VERB_SET_PROC_COEF, 0x001b},
7629                        {0x58, AC_VERB_SET_COEF_INDEX, 0x00},
7630                        {0x58, AC_VERB_SET_PROC_COEF, 0x3888},
7631                        {0x20, AC_VERB_SET_COEF_INDEX, 0x6f},
7632                        {0x20, AC_VERB_SET_PROC_COEF, 0x2c0b},
7633                        {}
7634                }
7635        },
7636        [ALC274_FIXUP_DELL_BIND_DACS] = {
7637                .type = HDA_FIXUP_FUNC,
7638                .v.func = alc274_fixup_bind_dacs,
7639                .chained = true,
7640                .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
7641        },
7642        [ALC274_FIXUP_DELL_AIO_LINEOUT_VERB] = {
7643                .type = HDA_FIXUP_PINS,
7644                .v.pins = (const struct hda_pintbl[]) {
7645                        { 0x1b, 0x0401102f },
7646                        { }
7647                },
7648                .chained = true,
7649                .chain_id = ALC274_FIXUP_DELL_BIND_DACS
7650        },
7651        [ALC298_FIXUP_TPT470_DOCK_FIX] = {
7652                .type = HDA_FIXUP_FUNC,
7653                .v.func = alc_fixup_tpt470_dock,
7654                .chained = true,
7655                .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE
7656        },
7657        [ALC298_FIXUP_TPT470_DOCK] = {
7658                .type = HDA_FIXUP_FUNC,
7659                .v.func = alc_fixup_tpt470_dacs,
7660                .chained = true,
7661                .chain_id = ALC298_FIXUP_TPT470_DOCK_FIX
7662        },
7663        [ALC255_FIXUP_DUMMY_LINEOUT_VERB] = {
7664                .type = HDA_FIXUP_PINS,
7665                .v.pins = (const struct hda_pintbl[]) {
7666                        { 0x14, 0x0201101f },
7667                        { }
7668                },
7669                .chained = true,
7670                .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
7671        },
7672        [ALC255_FIXUP_DELL_HEADSET_MIC] = {
7673                .type = HDA_FIXUP_PINS,
7674                .v.pins = (const struct hda_pintbl[]) {
7675                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7676                        { }
7677                },
7678                .chained = true,
7679                .chain_id = ALC269_FIXUP_HEADSET_MIC
7680        },
7681        [ALC295_FIXUP_HP_X360] = {
7682                .type = HDA_FIXUP_FUNC,
7683                .v.func = alc295_fixup_hp_top_speakers,
7684                .chained = true,
7685                .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC3
7686        },
7687        [ALC221_FIXUP_HP_HEADSET_MIC] = {
7688                .type = HDA_FIXUP_PINS,
7689                .v.pins = (const struct hda_pintbl[]) {
7690                        { 0x19, 0x0181313f},
7691                        { }
7692                },
7693                .chained = true,
7694                .chain_id = ALC269_FIXUP_HEADSET_MIC
7695        },
7696        [ALC285_FIXUP_LENOVO_HEADPHONE_NOISE] = {
7697                .type = HDA_FIXUP_FUNC,
7698                .v.func = alc285_fixup_invalidate_dacs,
7699                .chained = true,
7700                .chain_id = ALC269_FIXUP_THINKPAD_ACPI
7701        },
7702        [ALC295_FIXUP_HP_AUTO_MUTE] = {
7703                .type = HDA_FIXUP_FUNC,
7704                .v.func = alc_fixup_auto_mute_via_amp,
7705        },
7706        [ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE] = {
7707                .type = HDA_FIXUP_PINS,
7708                .v.pins = (const struct hda_pintbl[]) {
7709                        { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7710                        { }
7711                },
7712                .chained = true,
7713                .chain_id = ALC269_FIXUP_HEADSET_MIC
7714        },
7715        [ALC294_FIXUP_ASUS_MIC] = {
7716                .type = HDA_FIXUP_PINS,
7717                .v.pins = (const struct hda_pintbl[]) {
7718                        { 0x13, 0x90a60160 }, /* use as internal mic */
7719                        { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
7720                        { }
7721                },
7722                .chained = true,
7723                .chain_id = ALC269_FIXUP_HEADSET_MIC
7724        },
7725        [ALC294_FIXUP_ASUS_HEADSET_MIC] = {
7726                .type = HDA_FIXUP_PINS,
7727                .v.pins = (const struct hda_pintbl[]) {
7728                        { 0x19, 0x01a1103c }, /* use as headset mic */
7729                        { }
7730                },
7731                .chained = true,
7732                .chain_id = ALC269_FIXUP_HEADSET_MIC
7733        },
7734        [ALC294_FIXUP_ASUS_SPK] = {
7735                .type = HDA_FIXUP_VERBS,
7736                .v.verbs = (const struct hda_verb[]) {
7737                        /* Set EAPD high */
7738                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x40 },
7739                        { 0x20, AC_VERB_SET_PROC_COEF, 0x8800 },
7740                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
7741                        { 0x20, AC_VERB_SET_PROC_COEF, 0x7774 },
7742                        { }
7743                },
7744                .chained = true,
7745                .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
7746        },
7747        [ALC295_FIXUP_CHROME_BOOK] = {
7748                .type = HDA_FIXUP_FUNC,
7749                .v.func = alc295_fixup_chromebook,
7750                .chained = true,
7751                .chain_id = ALC225_FIXUP_HEADSET_JACK
7752        },
7753        [ALC225_FIXUP_HEADSET_JACK] = {
7754                .type = HDA_FIXUP_FUNC,
7755                .v.func = alc_fixup_headset_jack,
7756        },
7757        [ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE] = {
7758                .type = HDA_FIXUP_PINS,
7759                .v.pins = (const struct hda_pintbl[]) {
7760                        { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7761                        { }
7762                },
7763                .chained = true,
7764                .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7765        },
7766        [ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE] = {
7767                .type = HDA_FIXUP_VERBS,
7768                .v.verbs = (const struct hda_verb[]) {
7769                        /* Disable PCBEEP-IN passthrough */
7770                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
7771                        { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
7772                        { }
7773                },
7774                .chained = true,
7775                .chain_id = ALC285_FIXUP_LENOVO_HEADPHONE_NOISE
7776        },
7777        [ALC255_FIXUP_ACER_HEADSET_MIC] = {
7778                .type = HDA_FIXUP_PINS,
7779                .v.pins = (const struct hda_pintbl[]) {
7780                        { 0x19, 0x03a11130 },
7781                        { 0x1a, 0x90a60140 }, /* use as internal mic */
7782                        { }
7783                },
7784                .chained = true,
7785                .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
7786        },
7787        [ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE] = {
7788                .type = HDA_FIXUP_PINS,
7789                .v.pins = (const struct hda_pintbl[]) {
7790                        { 0x16, 0x01011020 }, /* Rear Line out */
7791                        { 0x19, 0x01a1913c }, /* use as Front headset mic, without its own jack detect */
7792                        { }
7793                },
7794                .chained = true,
7795                .chain_id = ALC225_FIXUP_WYSE_AUTO_MUTE
7796        },
7797        [ALC225_FIXUP_WYSE_AUTO_MUTE] = {
7798                .type = HDA_FIXUP_FUNC,
7799                .v.func = alc_fixup_auto_mute_via_amp,
7800                .chained = true,
7801                .chain_id = ALC225_FIXUP_WYSE_DISABLE_MIC_VREF
7802        },
7803        [ALC225_FIXUP_WYSE_DISABLE_MIC_VREF] = {
7804                .type = HDA_FIXUP_FUNC,
7805                .v.func = alc_fixup_disable_mic_vref,
7806                .chained = true,
7807                .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
7808        },
7809        [ALC286_FIXUP_ACER_AIO_HEADSET_MIC] = {
7810                .type = HDA_FIXUP_VERBS,
7811                .v.verbs = (const struct hda_verb[]) {
7812                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x4f },
7813                        { 0x20, AC_VERB_SET_PROC_COEF, 0x5029 },
7814                        { }
7815                },
7816                .chained = true,
7817                .chain_id = ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE
7818        },
7819        [ALC256_FIXUP_ASUS_HEADSET_MIC] = {
7820                .type = HDA_FIXUP_PINS,
7821                .v.pins = (const struct hda_pintbl[]) {
7822                        { 0x19, 0x03a11020 }, /* headset mic with jack detect */
7823                        { }
7824                },
7825                .chained = true,
7826                .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7827        },
7828        [ALC256_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7829                .type = HDA_FIXUP_PINS,
7830                .v.pins = (const struct hda_pintbl[]) {
7831                        { 0x19, 0x04a11120 }, /* use as headset mic, without its own jack detect */
7832                        { }
7833                },
7834                .chained = true,
7835                .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7836        },
7837        [ALC299_FIXUP_PREDATOR_SPK] = {
7838                .type = HDA_FIXUP_PINS,
7839                .v.pins = (const struct hda_pintbl[]) {
7840                        { 0x21, 0x90170150 }, /* use as headset mic, without its own jack detect */
7841                        { }
7842                }
7843        },
7844        [ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE] = {
7845                .type = HDA_FIXUP_PINS,
7846                .v.pins = (const struct hda_pintbl[]) {
7847                        { 0x19, 0x04a11040 },
7848                        { 0x21, 0x04211020 },
7849                        { }
7850                },
7851                .chained = true,
7852                .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
7853        },
7854        [ALC289_FIXUP_DELL_SPK2] = {
7855                .type = HDA_FIXUP_PINS,
7856                .v.pins = (const struct hda_pintbl[]) {
7857                        { 0x17, 0x90170130 }, /* bass spk */
7858                        { }
7859                },
7860                .chained = true,
7861                .chain_id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE
7862        },
7863        [ALC289_FIXUP_DUAL_SPK] = {
7864                .type = HDA_FIXUP_FUNC,
7865                .v.func = alc285_fixup_speaker2_to_dac1,
7866                .chained = true,
7867                .chain_id = ALC289_FIXUP_DELL_SPK2
7868        },
7869        [ALC294_FIXUP_SPK2_TO_DAC1] = {
7870                .type = HDA_FIXUP_FUNC,
7871                .v.func = alc285_fixup_speaker2_to_dac1,
7872                .chained = true,
7873                .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
7874        },
7875        [ALC294_FIXUP_ASUS_DUAL_SPK] = {
7876                .type = HDA_FIXUP_FUNC,
7877                /* The GPIO must be pulled to initialize the AMP */
7878                .v.func = alc_fixup_gpio4,
7879                .chained = true,
7880                .chain_id = ALC294_FIXUP_SPK2_TO_DAC1
7881        },
7882        [ALC285_FIXUP_THINKPAD_X1_GEN7] = {
7883                .type = HDA_FIXUP_FUNC,
7884                .v.func = alc285_fixup_thinkpad_x1_gen7,
7885                .chained = true,
7886                .chain_id = ALC269_FIXUP_THINKPAD_ACPI
7887        },
7888        [ALC285_FIXUP_THINKPAD_HEADSET_JACK] = {
7889                .type = HDA_FIXUP_FUNC,
7890                .v.func = alc_fixup_headset_jack,
7891                .chained = true,
7892                .chain_id = ALC285_FIXUP_THINKPAD_X1_GEN7
7893        },
7894        [ALC294_FIXUP_ASUS_HPE] = {
7895                .type = HDA_FIXUP_VERBS,
7896                .v.verbs = (const struct hda_verb[]) {
7897                        /* Set EAPD high */
7898                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
7899                        { 0x20, AC_VERB_SET_PROC_COEF, 0x7774 },
7900                        { }
7901                },
7902                .chained = true,
7903                .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
7904        },
7905        [ALC294_FIXUP_ASUS_GX502_PINS] = {
7906                .type = HDA_FIXUP_PINS,
7907                .v.pins = (const struct hda_pintbl[]) {
7908                        { 0x19, 0x03a11050 }, /* front HP mic */
7909                        { 0x1a, 0x01a11830 }, /* rear external mic */
7910                        { 0x21, 0x03211020 }, /* front HP out */
7911                        { }
7912                },
7913                .chained = true,
7914                .chain_id = ALC294_FIXUP_ASUS_GX502_VERBS
7915        },
7916        [ALC294_FIXUP_ASUS_GX502_VERBS] = {
7917                .type = HDA_FIXUP_VERBS,
7918                .v.verbs = (const struct hda_verb[]) {
7919                        /* set 0x15 to HP-OUT ctrl */
7920                        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
7921                        /* unmute the 0x15 amp */
7922                        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
7923                        { }
7924                },
7925                .chained = true,
7926                .chain_id = ALC294_FIXUP_ASUS_GX502_HP
7927        },
7928        [ALC294_FIXUP_ASUS_GX502_HP] = {
7929                .type = HDA_FIXUP_FUNC,
7930                .v.func = alc294_fixup_gx502_hp,
7931        },
7932        [ALC294_FIXUP_ASUS_GU502_PINS] = {
7933                .type = HDA_FIXUP_PINS,
7934                .v.pins = (const struct hda_pintbl[]) {
7935                        { 0x19, 0x01a11050 }, /* rear HP mic */
7936                        { 0x1a, 0x01a11830 }, /* rear external mic */
7937                        { 0x21, 0x012110f0 }, /* rear HP out */
7938                        { }
7939                },
7940                .chained = true,
7941                .chain_id = ALC294_FIXUP_ASUS_GU502_VERBS
7942        },
7943        [ALC294_FIXUP_ASUS_GU502_VERBS] = {
7944                .type = HDA_FIXUP_VERBS,
7945                .v.verbs = (const struct hda_verb[]) {
7946                        /* set 0x15 to HP-OUT ctrl */
7947                        { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
7948                        /* unmute the 0x15 amp */
7949                        { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
7950                        /* set 0x1b to HP-OUT */
7951                        { 0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7952                        { }
7953                },
7954                .chained = true,
7955                .chain_id = ALC294_FIXUP_ASUS_GU502_HP
7956        },
7957        [ALC294_FIXUP_ASUS_GU502_HP] = {
7958                .type = HDA_FIXUP_FUNC,
7959                .v.func = alc294_fixup_gu502_hp,
7960        },
7961        [ALC294_FIXUP_ASUS_COEF_1B] = {
7962                .type = HDA_FIXUP_VERBS,
7963                .v.verbs = (const struct hda_verb[]) {
7964                        /* Set bit 10 to correct noisy output after reboot from
7965                         * Windows 10 (due to pop noise reduction?)
7966                         */
7967                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x1b },
7968                        { 0x20, AC_VERB_SET_PROC_COEF, 0x4e4b },
7969                        { }
7970                },
7971                .chained = true,
7972                .chain_id = ALC289_FIXUP_ASUS_GA401,
7973        },
7974        [ALC285_FIXUP_HP_GPIO_LED] = {
7975                .type = HDA_FIXUP_FUNC,
7976                .v.func = alc285_fixup_hp_gpio_led,
7977        },
7978        [ALC285_FIXUP_HP_MUTE_LED] = {
7979                .type = HDA_FIXUP_FUNC,
7980                .v.func = alc285_fixup_hp_mute_led,
7981        },
7982        [ALC236_FIXUP_HP_GPIO_LED] = {
7983                .type = HDA_FIXUP_FUNC,
7984                .v.func = alc236_fixup_hp_gpio_led,
7985        },
7986        [ALC236_FIXUP_HP_MUTE_LED] = {
7987                .type = HDA_FIXUP_FUNC,
7988                .v.func = alc236_fixup_hp_mute_led,
7989        },
7990        [ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF] = {
7991                .type = HDA_FIXUP_FUNC,
7992                .v.func = alc236_fixup_hp_mute_led_micmute_vref,
7993        },
7994        [ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = {
7995                .type = HDA_FIXUP_VERBS,
7996                .v.verbs = (const struct hda_verb[]) {
7997                        { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc5 },
7998                        { }
7999                },
8000        },
8001        [ALC295_FIXUP_ASUS_MIC_NO_PRESENCE] = {
8002                .type = HDA_FIXUP_PINS,
8003                .v.pins = (const struct hda_pintbl[]) {
8004                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8005                        { }
8006                },
8007                .chained = true,
8008                .chain_id = ALC269_FIXUP_HEADSET_MODE
8009        },
8010        [ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS] = {
8011                .type = HDA_FIXUP_PINS,
8012                .v.pins = (const struct hda_pintbl[]) {
8013                        { 0x14, 0x90100120 }, /* use as internal speaker */
8014                        { 0x18, 0x02a111f0 }, /* use as headset mic, without its own jack detect */
8015                        { 0x1a, 0x01011020 }, /* use as line out */
8016                        { },
8017                },
8018                .chained = true,
8019                .chain_id = ALC269_FIXUP_HEADSET_MIC
8020        },
8021        [ALC269VC_FIXUP_ACER_HEADSET_MIC] = {
8022                .type = HDA_FIXUP_PINS,
8023                .v.pins = (const struct hda_pintbl[]) {
8024                        { 0x18, 0x02a11030 }, /* use as headset mic */
8025                        { }
8026                },
8027                .chained = true,
8028                .chain_id = ALC269_FIXUP_HEADSET_MIC
8029        },
8030        [ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE] = {
8031                .type = HDA_FIXUP_PINS,
8032                .v.pins = (const struct hda_pintbl[]) {
8033                        { 0x18, 0x01a11130 }, /* use as headset mic, without its own jack detect */
8034                        { }
8035                },
8036                .chained = true,
8037                .chain_id = ALC269_FIXUP_HEADSET_MIC
8038        },
8039        [ALC289_FIXUP_ASUS_GA401] = {
8040                .type = HDA_FIXUP_FUNC,
8041                .v.func = alc289_fixup_asus_ga401,
8042                .chained = true,
8043                .chain_id = ALC289_FIXUP_ASUS_GA502,
8044        },
8045        [ALC289_FIXUP_ASUS_GA502] = {
8046                .type = HDA_FIXUP_PINS,
8047                .v.pins = (const struct hda_pintbl[]) {
8048                        { 0x19, 0x03a11020 }, /* headset mic with jack detect */
8049                        { }
8050                },
8051        },
8052        [ALC256_FIXUP_ACER_MIC_NO_PRESENCE] = {
8053                .type = HDA_FIXUP_PINS,
8054                .v.pins = (const struct hda_pintbl[]) {
8055                        { 0x19, 0x02a11120 }, /* use as headset mic, without its own jack detect */
8056                        { }
8057                },
8058                .chained = true,
8059                .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE
8060        },
8061        [ALC285_FIXUP_HP_GPIO_AMP_INIT] = {
8062                .type = HDA_FIXUP_FUNC,
8063                .v.func = alc285_fixup_hp_gpio_amp_init,
8064                .chained = true,
8065                .chain_id = ALC285_FIXUP_HP_GPIO_LED
8066        },
8067        [ALC269_FIXUP_CZC_B20] = {
8068                .type = HDA_FIXUP_PINS,
8069                .v.pins = (const struct hda_pintbl[]) {
8070                        { 0x12, 0x411111f0 },
8071                        { 0x14, 0x90170110 }, /* speaker */
8072                        { 0x15, 0x032f1020 }, /* HP out */
8073                        { 0x17, 0x411111f0 },
8074                        { 0x18, 0x03ab1040 }, /* mic */
8075                        { 0x19, 0xb7a7013f },
8076                        { 0x1a, 0x0181305f },
8077                        { 0x1b, 0x411111f0 },
8078                        { 0x1d, 0x411111f0 },
8079                        { 0x1e, 0x411111f0 },
8080                        { }
8081                },
8082                .chain_id = ALC269_FIXUP_DMIC,
8083        },
8084        [ALC269_FIXUP_CZC_TMI] = {
8085                .type = HDA_FIXUP_PINS,
8086                .v.pins = (const struct hda_pintbl[]) {
8087                        { 0x12, 0x4000c000 },
8088                        { 0x14, 0x90170110 }, /* speaker */
8089                        { 0x15, 0x0421401f }, /* HP out */
8090                        { 0x17, 0x411111f0 },
8091                        { 0x18, 0x04a19020 }, /* mic */
8092                        { 0x19, 0x411111f0 },
8093                        { 0x1a, 0x411111f0 },
8094                        { 0x1b, 0x411111f0 },
8095                        { 0x1d, 0x40448505 },
8096                        { 0x1e, 0x411111f0 },
8097                        { 0x20, 0x8000ffff },
8098                        { }
8099                },
8100                .chain_id = ALC269_FIXUP_DMIC,
8101        },
8102        [ALC269_FIXUP_CZC_L101] = {
8103                .type = HDA_FIXUP_PINS,
8104                .v.pins = (const struct hda_pintbl[]) {
8105                        { 0x12, 0x40000000 },
8106                        { 0x14, 0x01014010 }, /* speaker */
8107                        { 0x15, 0x411111f0 }, /* HP out */
8108                        { 0x16, 0x411111f0 },
8109                        { 0x18, 0x01a19020 }, /* mic */
8110                        { 0x19, 0x02a19021 },
8111                        { 0x1a, 0x0181302f },
8112                        { 0x1b, 0x0221401f },
8113                        { 0x1c, 0x411111f0 },
8114                        { 0x1d, 0x4044c601 },
8115                        { 0x1e, 0x411111f0 },
8116                        { }
8117                },
8118                .chain_id = ALC269_FIXUP_DMIC,
8119        },
8120        [ALC269_FIXUP_LEMOTE_A1802] = {
8121                .type = HDA_FIXUP_PINS,
8122                .v.pins = (const struct hda_pintbl[]) {
8123                        { 0x12, 0x40000000 },
8124                        { 0x14, 0x90170110 }, /* speaker */
8125                        { 0x17, 0x411111f0 },
8126                        { 0x18, 0x03a19040 }, /* mic1 */
8127                        { 0x19, 0x90a70130 }, /* mic2 */
8128                        { 0x1a, 0x411111f0 },
8129                        { 0x1b, 0x411111f0 },
8130                        { 0x1d, 0x40489d2d },
8131                        { 0x1e, 0x411111f0 },
8132                        { 0x20, 0x0003ffff },
8133                        { 0x21, 0x03214020 },
8134                        { }
8135                },
8136                .chain_id = ALC269_FIXUP_DMIC,
8137        },
8138        [ALC269_FIXUP_LEMOTE_A190X] = {
8139                .type = HDA_FIXUP_PINS,
8140                .v.pins = (const struct hda_pintbl[]) {
8141                        { 0x14, 0x99130110 }, /* speaker */
8142                        { 0x15, 0x0121401f }, /* HP out */
8143                        { 0x18, 0x01a19c20 }, /* rear  mic */
8144                        { 0x19, 0x99a3092f }, /* front mic */
8145                        { 0x1b, 0x0201401f }, /* front lineout */
8146                        { }
8147                },
8148                .chain_id = ALC269_FIXUP_DMIC,
8149        },
8150        [ALC256_FIXUP_INTEL_NUC8_RUGGED] = {
8151                .type = HDA_FIXUP_PINS,
8152                .v.pins = (const struct hda_pintbl[]) {
8153                        { 0x1b, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8154                        { }
8155                },
8156                .chained = true,
8157                .chain_id = ALC269_FIXUP_HEADSET_MODE
8158        },
8159        [ALC256_FIXUP_INTEL_NUC10] = {
8160                .type = HDA_FIXUP_PINS,
8161                .v.pins = (const struct hda_pintbl[]) {
8162                        { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8163                        { }
8164                },
8165                .chained = true,
8166                .chain_id = ALC269_FIXUP_HEADSET_MODE
8167        },
8168        [ALC255_FIXUP_XIAOMI_HEADSET_MIC] = {
8169                .type = HDA_FIXUP_VERBS,
8170                .v.verbs = (const struct hda_verb[]) {
8171                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
8172                        { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
8173                        { }
8174                },
8175                .chained = true,
8176                .chain_id = ALC289_FIXUP_ASUS_GA502
8177        },
8178        [ALC274_FIXUP_HP_MIC] = {
8179                .type = HDA_FIXUP_VERBS,
8180                .v.verbs = (const struct hda_verb[]) {
8181                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x45 },
8182                        { 0x20, AC_VERB_SET_PROC_COEF, 0x5089 },
8183                        { }
8184                },
8185        },
8186        [ALC274_FIXUP_HP_HEADSET_MIC] = {
8187                .type = HDA_FIXUP_FUNC,
8188                .v.func = alc274_fixup_hp_headset_mic,
8189                .chained = true,
8190                .chain_id = ALC274_FIXUP_HP_MIC
8191        },
8192        [ALC274_FIXUP_HP_ENVY_GPIO] = {
8193                .type = HDA_FIXUP_FUNC,
8194                .v.func = alc274_fixup_hp_envy_gpio,
8195        },
8196        [ALC256_FIXUP_ASUS_HPE] = {
8197                .type = HDA_FIXUP_VERBS,
8198                .v.verbs = (const struct hda_verb[]) {
8199                        /* Set EAPD high */
8200                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
8201                        { 0x20, AC_VERB_SET_PROC_COEF, 0x7778 },
8202                        { }
8203                },
8204                .chained = true,
8205                .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
8206        },
8207        [ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK] = {
8208                .type = HDA_FIXUP_FUNC,
8209                .v.func = alc_fixup_headset_jack,
8210                .chained = true,
8211                .chain_id = ALC269_FIXUP_THINKPAD_ACPI
8212        },
8213        [ALC287_FIXUP_HP_GPIO_LED] = {
8214                .type = HDA_FIXUP_FUNC,
8215                .v.func = alc287_fixup_hp_gpio_led,
8216        },
8217        [ALC256_FIXUP_HP_HEADSET_MIC] = {
8218                .type = HDA_FIXUP_FUNC,
8219                .v.func = alc274_fixup_hp_headset_mic,
8220        },
8221        [ALC236_FIXUP_DELL_AIO_HEADSET_MIC] = {
8222                .type = HDA_FIXUP_FUNC,
8223                .v.func = alc_fixup_no_int_mic,
8224                .chained = true,
8225                .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
8226        },
8227        [ALC282_FIXUP_ACER_DISABLE_LINEOUT] = {
8228                .type = HDA_FIXUP_PINS,
8229                .v.pins = (const struct hda_pintbl[]) {
8230                        { 0x1b, 0x411111f0 },
8231                        { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
8232                        { },
8233                },
8234                .chained = true,
8235                .chain_id = ALC269_FIXUP_HEADSET_MODE
8236        },
8237        [ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST] = {
8238                .type = HDA_FIXUP_FUNC,
8239                .v.func = alc269_fixup_limit_int_mic_boost,
8240                .chained = true,
8241                .chain_id = ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
8242        },
8243        [ALC256_FIXUP_ACER_HEADSET_MIC] = {
8244                .type = HDA_FIXUP_PINS,
8245                .v.pins = (const struct hda_pintbl[]) {
8246                        { 0x19, 0x02a1113c }, /* use as headset mic, without its own jack detect */
8247                        { 0x1a, 0x90a1092f }, /* use as internal mic */
8248                        { }
8249                },
8250                .chained = true,
8251                .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
8252        },
8253        [ALC285_FIXUP_IDEAPAD_S740_COEF] = {
8254                .type = HDA_FIXUP_FUNC,
8255                .v.func = alc285_fixup_ideapad_s740_coef,
8256                .chained = true,
8257                .chain_id = ALC269_FIXUP_THINKPAD_ACPI,
8258        },
8259        [ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST] = {
8260                .type = HDA_FIXUP_FUNC,
8261                .v.func = alc269_fixup_limit_int_mic_boost,
8262                .chained = true,
8263                .chain_id = ALC285_FIXUP_HP_MUTE_LED,
8264        },
8265        [ALC295_FIXUP_ASUS_DACS] = {
8266                .type = HDA_FIXUP_FUNC,
8267                .v.func = alc295_fixup_asus_dacs,
8268        },
8269        [ALC295_FIXUP_HP_OMEN] = {
8270                .type = HDA_FIXUP_PINS,
8271                .v.pins = (const struct hda_pintbl[]) {
8272                        { 0x12, 0xb7a60130 },
8273                        { 0x13, 0x40000000 },
8274                        { 0x14, 0x411111f0 },
8275                        { 0x16, 0x411111f0 },
8276                        { 0x17, 0x90170110 },
8277                        { 0x18, 0x411111f0 },
8278                        { 0x19, 0x02a11030 },
8279                        { 0x1a, 0x411111f0 },
8280                        { 0x1b, 0x04a19030 },
8281                        { 0x1d, 0x40600001 },
8282                        { 0x1e, 0x411111f0 },
8283                        { 0x21, 0x03211020 },
8284                        {}
8285                },
8286                .chained = true,
8287                .chain_id = ALC269_FIXUP_HP_LINE1_MIC1_LED,
8288        },
8289        [ALC285_FIXUP_HP_SPECTRE_X360] = {
8290                .type = HDA_FIXUP_FUNC,
8291                .v.func = alc285_fixup_hp_spectre_x360,
8292        },
8293        [ALC285_FIXUP_HP_SPECTRE_X360_EB1] = {
8294                .type = HDA_FIXUP_FUNC,
8295                .v.func = alc285_fixup_hp_spectre_x360_eb1
8296        },
8297        [ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP] = {
8298                .type = HDA_FIXUP_FUNC,
8299                .v.func = alc285_fixup_ideapad_s740_coef,
8300                .chained = true,
8301                .chain_id = ALC285_FIXUP_THINKPAD_HEADSET_JACK,
8302        },
8303        [ALC623_FIXUP_LENOVO_THINKSTATION_P340] = {
8304                .type = HDA_FIXUP_FUNC,
8305                .v.func = alc_fixup_no_shutup,
8306                .chained = true,
8307                .chain_id = ALC283_FIXUP_HEADSET_MIC,
8308        },
8309        [ALC255_FIXUP_ACER_HEADPHONE_AND_MIC] = {
8310                .type = HDA_FIXUP_PINS,
8311                .v.pins = (const struct hda_pintbl[]) {
8312                        { 0x21, 0x03211030 }, /* Change the Headphone location to Left */
8313                        { }
8314                },
8315                .chained = true,
8316                .chain_id = ALC255_FIXUP_XIAOMI_HEADSET_MIC
8317        },
8318        [ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST] = {
8319                .type = HDA_FIXUP_FUNC,
8320                .v.func = alc269_fixup_limit_int_mic_boost,
8321                .chained = true,
8322                .chain_id = ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF,
8323        },
8324        [ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS] = {
8325                .type = HDA_FIXUP_VERBS,
8326                //.v.verbs = legion_15imhg05_coefs,
8327                .v.verbs = (const struct hda_verb[]) {
8328                         // set left speaker Legion 7i.
8329                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8330                         { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8331
8332                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8333                         { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8334                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8335                         { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
8336                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8337
8338                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8339                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8340                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8341                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8342                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8343
8344                         // set right speaker Legion 7i.
8345                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8346                         { 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
8347
8348                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8349                         { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8350                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8351                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
8352                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8353
8354                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8355                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8356                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8357                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8358                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8359                         {}
8360                },
8361                .chained = true,
8362                .chain_id = ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE,
8363        },
8364        [ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE] = {
8365                .type = HDA_FIXUP_FUNC,
8366                .v.func = alc287_fixup_legion_15imhg05_speakers,
8367                .chained = true,
8368                .chain_id = ALC269_FIXUP_HEADSET_MODE,
8369        },
8370        [ALC287_FIXUP_YOGA7_14ITL_SPEAKERS] = {
8371                .type = HDA_FIXUP_VERBS,
8372                .v.verbs = (const struct hda_verb[]) {
8373                         // set left speaker Yoga 7i.
8374                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8375                         { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8376
8377                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8378                         { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8379                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8380                         { 0x20, AC_VERB_SET_PROC_COEF, 0x1a },
8381                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8382
8383                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8384                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8385                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8386                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8387                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8388
8389                         // set right speaker Yoga 7i.
8390                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8391                         { 0x20, AC_VERB_SET_PROC_COEF, 0x46 },
8392
8393                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8394                         { 0x20, AC_VERB_SET_PROC_COEF, 0xc },
8395                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8396                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2a },
8397                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8398
8399                         { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8400                         { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8401                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8402                         { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8403                         { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8404                         {}
8405                },
8406                .chained = true,
8407                .chain_id = ALC269_FIXUP_HEADSET_MODE,
8408        },
8409        [ALC287_FIXUP_13S_GEN2_SPEAKERS] = {
8410                .type = HDA_FIXUP_VERBS,
8411                .v.verbs = (const struct hda_verb[]) {
8412                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8413                        { 0x20, AC_VERB_SET_PROC_COEF, 0x41 },
8414                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8415                        { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8416                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8417                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8418                        { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8419                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x24 },
8420                        { 0x20, AC_VERB_SET_PROC_COEF, 0x42 },
8421                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x26 },
8422                        { 0x20, AC_VERB_SET_PROC_COEF, 0x2 },
8423                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8424                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0 },
8425                        { 0x20, AC_VERB_SET_PROC_COEF, 0xb020 },
8426                        {}
8427                },
8428                .chained = true,
8429                .chain_id = ALC269_FIXUP_HEADSET_MODE,
8430        },
8431        [ALC256_FIXUP_TONGFANG_RESET_PERSISTENT_SETTINGS] = {
8432                .type = HDA_FIXUP_FUNC,
8433                .v.func = alc256_fixup_tongfang_reset_persistent_settings,
8434        },
8435};
8436
8437static const struct snd_pci_quirk alc269_fixup_tbl[] = {
8438        SND_PCI_QUIRK(0x1025, 0x0283, "Acer TravelMate 8371", ALC269_FIXUP_INV_DMIC),
8439        SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
8440        SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
8441        SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
8442        SND_PCI_QUIRK(0x1025, 0x072d, "Acer Aspire V5-571G", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
8443        SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
8444        SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
8445        SND_PCI_QUIRK(0x1025, 0x0762, "Acer Aspire E1-472", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
8446        SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
8447        SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
8448        SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
8449        SND_PCI_QUIRK(0x1025, 0x0840, "Acer Aspire E1", ALC269VB_FIXUP_ASPIRE_E1_COEF),
8450        SND_PCI_QUIRK(0x1025, 0x101c, "Acer Veriton N2510G", ALC269_FIXUP_LIFEBOOK),
8451        SND_PCI_QUIRK(0x1025, 0x102b, "Acer Aspire C24-860", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE),
8452        SND_PCI_QUIRK(0x1025, 0x1065, "Acer Aspire C20-820", ALC269VC_FIXUP_ACER_HEADSET_MIC),
8453        SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK),
8454        SND_PCI_QUIRK(0x1025, 0x1094, "Acer Aspire E5-575T", ALC255_FIXUP_ACER_LIMIT_INT_MIC_BOOST),
8455        SND_PCI_QUIRK(0x1025, 0x1099, "Acer Aspire E5-523G", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8456        SND_PCI_QUIRK(0x1025, 0x110e, "Acer Aspire ES1-432", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8457        SND_PCI_QUIRK(0x1025, 0x1166, "Acer Veriton N4640G", ALC269_FIXUP_LIFEBOOK),
8458        SND_PCI_QUIRK(0x1025, 0x1167, "Acer Veriton N6640G", ALC269_FIXUP_LIFEBOOK),
8459        SND_PCI_QUIRK(0x1025, 0x1246, "Acer Predator Helios 500", ALC299_FIXUP_PREDATOR_SPK),
8460        SND_PCI_QUIRK(0x1025, 0x1247, "Acer vCopperbox", ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS),
8461        SND_PCI_QUIRK(0x1025, 0x1248, "Acer Veriton N4660G", ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE),
8462        SND_PCI_QUIRK(0x1025, 0x1269, "Acer SWIFT SF314-54", ALC256_FIXUP_ACER_HEADSET_MIC),
8463        SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8464        SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8465        SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8466        SND_PCI_QUIRK(0x1025, 0x129c, "Acer SWIFT SF314-55", ALC256_FIXUP_ACER_HEADSET_MIC),
8467        SND_PCI_QUIRK(0x1025, 0x1300, "Acer SWIFT SF314-56", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
8468        SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
8469        SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC),
8470        SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC),
8471        SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42", ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
8472        SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE),
8473        SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC),
8474        SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
8475        SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS),
8476        SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X),
8477        SND_PCI_QUIRK(0x1028, 0x05be, "Dell Latitude E6540", ALC292_FIXUP_DELL_E7X),
8478        SND_PCI_QUIRK(0x1028, 0x05ca, "Dell Latitude E7240", ALC292_FIXUP_DELL_E7X),
8479        SND_PCI_QUIRK(0x1028, 0x05cb, "Dell Latitude E7440", ALC292_FIXUP_DELL_E7X),
8480        SND_PCI_QUIRK(0x1028, 0x05da, "Dell Vostro 5460", ALC290_FIXUP_SUBWOOFER),
8481        SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
8482        SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
8483        SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
8484        SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
8485        SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
8486        SND_PCI_QUIRK(0x1028, 0x062c, "Dell Latitude E5550", ALC292_FIXUP_DELL_E7X),
8487        SND_PCI_QUIRK(0x1028, 0x062e, "Dell Latitude E7450", ALC292_FIXUP_DELL_E7X),
8488        SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
8489        SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8490        SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8491        SND_PCI_QUIRK(0x1028, 0x0665, "Dell XPS 13", ALC288_FIXUP_DELL_XPS_13),
8492        SND_PCI_QUIRK(0x1028, 0x0669, "Dell Optiplex 9020m", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
8493        SND_PCI_QUIRK(0x1028, 0x069a, "Dell Vostro 5480", ALC290_FIXUP_SUBWOOFER_HSJACK),
8494        SND_PCI_QUIRK(0x1028, 0x06c7, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
8495        SND_PCI_QUIRK(0x1028, 0x06d9, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8496        SND_PCI_QUIRK(0x1028, 0x06da, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8497        SND_PCI_QUIRK(0x1028, 0x06db, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8498        SND_PCI_QUIRK(0x1028, 0x06dd, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8499        SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8500        SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8501        SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
8502        SND_PCI_QUIRK(0x1028, 0x0706, "Dell Inspiron 7559", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
8503        SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
8504        SND_PCI_QUIRK(0x1028, 0x0738, "Dell Precision 5820", ALC269_FIXUP_NO_SHUTUP),
8505        SND_PCI_QUIRK(0x1028, 0x075c, "Dell XPS 27 7760", ALC298_FIXUP_SPK_VOLUME),
8506        SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
8507        SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
8508        SND_PCI_QUIRK(0x1028, 0x07b0, "Dell Precision 7520", ALC295_FIXUP_DISABLE_DAC3),
8509        SND_PCI_QUIRK(0x1028, 0x080c, "Dell WYSE", ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE),
8510        SND_PCI_QUIRK(0x1028, 0x084b, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
8511        SND_PCI_QUIRK(0x1028, 0x084e, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
8512        SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
8513        SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC),
8514        SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB),
8515        SND_PCI_QUIRK(0x1028, 0x08ad, "Dell WYSE AIO", ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE),
8516        SND_PCI_QUIRK(0x1028, 0x08ae, "Dell WYSE NB", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE),
8517        SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
8518        SND_PCI_QUIRK(0x1028, 0x097d, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
8519        SND_PCI_QUIRK(0x1028, 0x097e, "Dell Precision", ALC289_FIXUP_DUAL_SPK),
8520        SND_PCI_QUIRK(0x1028, 0x098d, "Dell Precision", ALC233_FIXUP_ASUS_MIC_NO_PRESENCE),
8521        SND_PCI_QUIRK(0x1028, 0x09bf, "Dell Precision", ALC233_FIXUP_ASUS_MIC_NO_PRESENCE),
8522        SND_PCI_QUIRK(0x1028, 0x0a2e, "Dell", ALC236_FIXUP_DELL_AIO_HEADSET_MIC),
8523        SND_PCI_QUIRK(0x1028, 0x0a30, "Dell", ALC236_FIXUP_DELL_AIO_HEADSET_MIC),
8524        SND_PCI_QUIRK(0x1028, 0x0a58, "Dell", ALC255_FIXUP_DELL_HEADSET_MIC),
8525        SND_PCI_QUIRK(0x1028, 0x0a61, "Dell XPS 15 9510", ALC289_FIXUP_DUAL_SPK),
8526        SND_PCI_QUIRK(0x1028, 0x0a62, "Dell Precision 5560", ALC289_FIXUP_DUAL_SPK),
8527        SND_PCI_QUIRK(0x1028, 0x0a9d, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE),
8528        SND_PCI_QUIRK(0x1028, 0x0a9e, "Dell Latitude 5430", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE),
8529        SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8530        SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
8531        SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
8532        SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
8533        SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
8534        SND_PCI_QUIRK(0x103c, 0x21f9, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8535        SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8536        SND_PCI_QUIRK(0x103c, 0x2214, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8537        SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8538        SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
8539        SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8540        SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8541        SND_PCI_QUIRK(0x103c, 0x2236, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8542        SND_PCI_QUIRK(0x103c, 0x2237, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8543        SND_PCI_QUIRK(0x103c, 0x2238, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8544        SND_PCI_QUIRK(0x103c, 0x2239, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8545        SND_PCI_QUIRK(0x103c, 0x224b, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED),
8546        SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8547        SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8548        SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8549        SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8550        SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8551        SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8552        SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED),
8553        SND_PCI_QUIRK(0x103c, 0x225f, "HP", ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY),
8554        SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8555        SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8556        SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8557        SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8558        SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8559        SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8560        SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8561        SND_PCI_QUIRK(0x103c, 0x226e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8562        SND_PCI_QUIRK(0x103c, 0x2271, "HP", ALC286_FIXUP_HP_GPIO_LED),
8563        SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8564        SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC280_FIXUP_HP_DOCK_PINS),
8565        SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8566        SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC280_FIXUP_HP_DOCK_PINS),
8567        SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8568        SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8569        SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8570        SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8571        SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8572        SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8573        SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8574        SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8575        SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8576        SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8577        SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8578        SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8579        SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8580        SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8581        SND_PCI_QUIRK(0x103c, 0x22db, "HP", ALC280_FIXUP_HP_9480M),
8582        SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8583        SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
8584        SND_PCI_QUIRK(0x103c, 0x2334, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8585        SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8586        SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8587        SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
8588        SND_PCI_QUIRK(0x103c, 0x802e, "HP Z240 SFF", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
8589        SND_PCI_QUIRK(0x103c, 0x802f, "HP Z240", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
8590        SND_PCI_QUIRK(0x103c, 0x8077, "HP", ALC256_FIXUP_HP_HEADSET_MIC),
8591        SND_PCI_QUIRK(0x103c, 0x8158, "HP", ALC256_FIXUP_HP_HEADSET_MIC),
8592        SND_PCI_QUIRK(0x103c, 0x820d, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8593        SND_PCI_QUIRK(0x103c, 0x8256, "HP", ALC221_FIXUP_HP_FRONT_MIC),
8594        SND_PCI_QUIRK(0x103c, 0x827e, "HP x360", ALC295_FIXUP_HP_X360),
8595        SND_PCI_QUIRK(0x103c, 0x827f, "HP x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8596        SND_PCI_QUIRK(0x103c, 0x82bf, "HP G3 mini", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
8597        SND_PCI_QUIRK(0x103c, 0x82c0, "HP G3 mini premium", ALC221_FIXUP_HP_MIC_NO_PRESENCE),
8598        SND_PCI_QUIRK(0x103c, 0x83b9, "HP Spectre x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8599        SND_PCI_QUIRK(0x103c, 0x841c, "HP Pavilion 15-CK0xx", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8600        SND_PCI_QUIRK(0x103c, 0x8497, "HP Envy x360", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8601        SND_PCI_QUIRK(0x103c, 0x84da, "HP OMEN dc0019-ur", ALC295_FIXUP_HP_OMEN),
8602        SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3),
8603        SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360),
8604        SND_PCI_QUIRK(0x103c, 0x861f, "HP Elite Dragonfly G1", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8605        SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED),
8606        SND_PCI_QUIRK(0x103c, 0x86c7, "HP Envy AiO 32", ALC274_FIXUP_HP_ENVY_GPIO),
8607        SND_PCI_QUIRK(0x103c, 0x8716, "HP Elite Dragonfly G2 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8608        SND_PCI_QUIRK(0x103c, 0x8720, "HP EliteBook x360 1040 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8609        SND_PCI_QUIRK(0x103c, 0x8724, "HP EliteBook 850 G7", ALC285_FIXUP_HP_GPIO_LED),
8610        SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED),
8611        SND_PCI_QUIRK(0x103c, 0x8730, "HP ProBook 445 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),
8612        SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8613        SND_PCI_QUIRK(0x103c, 0x8760, "HP", ALC285_FIXUP_HP_MUTE_LED),
8614        SND_PCI_QUIRK(0x103c, 0x877a, "HP", ALC285_FIXUP_HP_MUTE_LED),
8615        SND_PCI_QUIRK(0x103c, 0x877d, "HP", ALC236_FIXUP_HP_MUTE_LED),
8616        SND_PCI_QUIRK(0x103c, 0x8780, "HP ZBook Fury 17 G7 Mobile Workstation",
8617                      ALC285_FIXUP_HP_GPIO_AMP_INIT),
8618        SND_PCI_QUIRK(0x103c, 0x8783, "HP ZBook Fury 15 G7 Mobile Workstation",
8619                      ALC285_FIXUP_HP_GPIO_AMP_INIT),
8620        SND_PCI_QUIRK(0x103c, 0x87c8, "HP", ALC287_FIXUP_HP_GPIO_LED),
8621        SND_PCI_QUIRK(0x103c, 0x87e5, "HP ProBook 440 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
8622        SND_PCI_QUIRK(0x103c, 0x87e7, "HP ProBook 450 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
8623        SND_PCI_QUIRK(0x103c, 0x87f1, "HP ProBook 630 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
8624        SND_PCI_QUIRK(0x103c, 0x87f2, "HP ProBook 640 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
8625        SND_PCI_QUIRK(0x103c, 0x87f4, "HP", ALC287_FIXUP_HP_GPIO_LED),
8626        SND_PCI_QUIRK(0x103c, 0x87f5, "HP", ALC287_FIXUP_HP_GPIO_LED),
8627        SND_PCI_QUIRK(0x103c, 0x87f6, "HP Spectre x360 14", ALC245_FIXUP_HP_X360_AMP),
8628        SND_PCI_QUIRK(0x103c, 0x87f7, "HP Spectre x360 14", ALC245_FIXUP_HP_X360_AMP),
8629        SND_PCI_QUIRK(0x103c, 0x8805, "HP ProBook 650 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
8630        SND_PCI_QUIRK(0x103c, 0x880d, "HP EliteBook 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
8631        SND_PCI_QUIRK(0x103c, 0x8811, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
8632        SND_PCI_QUIRK(0x103c, 0x8812, "HP Spectre x360 15-eb1xxx", ALC285_FIXUP_HP_SPECTRE_X360_EB1),
8633        SND_PCI_QUIRK(0x103c, 0x8846, "HP EliteBook 850 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
8634        SND_PCI_QUIRK(0x103c, 0x8847, "HP EliteBook x360 830 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
8635        SND_PCI_QUIRK(0x103c, 0x884b, "HP EliteBook 840 Aero G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
8636        SND_PCI_QUIRK(0x103c, 0x884c, "HP EliteBook 840 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED),
8637        SND_PCI_QUIRK(0x103c, 0x8862, "HP ProBook 445 G8 Notebook PC", ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST),
8638        SND_PCI_QUIRK(0x103c, 0x8863, "HP ProBook 445 G8 Notebook PC", ALC236_FIXUP_HP_LIMIT_INT_MIC_BOOST),
8639        SND_PCI_QUIRK(0x103c, 0x886d, "HP ZBook Fury 17.3 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8640        SND_PCI_QUIRK(0x103c, 0x8870, "HP ZBook Fury 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8641        SND_PCI_QUIRK(0x103c, 0x8873, "HP ZBook Studio 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT),
8642        SND_PCI_QUIRK(0x103c, 0x888d, "HP ZBook Power 15.6 inch G8 Mobile Workstation PC", ALC236_FIXUP_HP_GPIO_LED),
8643        SND_PCI_QUIRK(0x103c, 0x8896, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_MUTE_LED),
8644        SND_PCI_QUIRK(0x103c, 0x8898, "HP EliteBook 845 G8 Notebook PC", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST),
8645        SND_PCI_QUIRK(0x103c, 0x88d0, "HP Pavilion 15-eh1xxx (mainboard 88D0)", ALC287_FIXUP_HP_GPIO_LED),
8646        SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
8647        SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
8648        SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8649        SND_PCI_QUIRK(0x1043, 0x10a1, "ASUS UX391UA", ALC294_FIXUP_ASUS_SPK),
8650        SND_PCI_QUIRK(0x1043, 0x10c0, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
8651        SND_PCI_QUIRK(0x1043, 0x10d0, "ASUS X540LA/X540LJ", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
8652        SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8653        SND_PCI_QUIRK(0x1043, 0x11c0, "ASUS X556UR", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
8654        SND_PCI_QUIRK(0x1043, 0x125e, "ASUS Q524UQK", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
8655        SND_PCI_QUIRK(0x1043, 0x1271, "ASUS X430UN", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
8656        SND_PCI_QUIRK(0x1043, 0x1290, "ASUS X441SA", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
8657        SND_PCI_QUIRK(0x1043, 0x12a0, "ASUS X441UV", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
8658        SND_PCI_QUIRK(0x1043, 0x12e0, "ASUS X541SA", ALC256_FIXUP_ASUS_MIC),
8659        SND_PCI_QUIRK(0x1043, 0x12f0, "ASUS X541UV", ALC256_FIXUP_ASUS_MIC),
8660        SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC),
8661        SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
8662        SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
8663        SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
8664        SND_PCI_QUIRK(0x1043, 0x1740, "ASUS UX430UA", ALC295_FIXUP_ASUS_DACS),
8665        SND_PCI_QUIRK(0x1043, 0x17d1, "ASUS UX431FL", ALC294_FIXUP_ASUS_DUAL_SPK),
8666        SND_PCI_QUIRK(0x1043, 0x1662, "ASUS GV301QH", ALC294_FIXUP_ASUS_DUAL_SPK),
8667        SND_PCI_QUIRK(0x1043, 0x1881, "ASUS Zephyrus S/M", ALC294_FIXUP_ASUS_GX502_PINS),
8668        SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC),
8669        SND_PCI_QUIRK(0x1043, 0x18f1, "Asus FX505DT", ALC256_FIXUP_ASUS_HEADSET_MIC),
8670        SND_PCI_QUIRK(0x1043, 0x194e, "ASUS UX563FD", ALC294_FIXUP_ASUS_HPE),
8671        SND_PCI_QUIRK(0x1043, 0x1982, "ASUS B1400CEPE", ALC256_FIXUP_ASUS_HPE),
8672        SND_PCI_QUIRK(0x1043, 0x19ce, "ASUS B9450FA", ALC294_FIXUP_ASUS_HPE),
8673        SND_PCI_QUIRK(0x1043, 0x19e1, "ASUS UX581LV", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE),
8674        SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
8675        SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),
8676        SND_PCI_QUIRK(0x1043, 0x1b11, "ASUS UX431DA", ALC294_FIXUP_ASUS_COEF_1B),
8677        SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
8678        SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
8679        SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8680        SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
8681        SND_PCI_QUIRK(0x1043, 0x1d4e, "ASUS TM420", ALC256_FIXUP_ASUS_HPE),
8682        SND_PCI_QUIRK(0x1043, 0x1e11, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA502),
8683        SND_PCI_QUIRK(0x1043, 0x1e51, "ASUS Zephyrus M15", ALC294_FIXUP_ASUS_GU502_PINS),
8684        SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401),
8685        SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401),
8686        SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2),
8687        SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
8688        SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
8689        SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
8690        SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
8691        SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
8692        SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
8693        SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
8694        SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
8695        SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
8696        SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
8697        SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
8698        SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
8699        SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT),
8700        SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
8701        SND_PCI_QUIRK(0x10cf, 0x1629, "Lifebook U7x7", ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC),
8702        SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
8703        SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
8704        SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
8705        SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE),
8706        SND_PCI_QUIRK(0x10ec, 0x1230, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
8707        SND_PCI_QUIRK(0x10ec, 0x1252, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
8708        SND_PCI_QUIRK(0x10ec, 0x1254, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK),
8709        SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
8710        SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
8711        SND_PCI_QUIRK(0x144d, 0xc169, "Samsung Notebook 9 Pen (NP930SBE-K01US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
8712        SND_PCI_QUIRK(0x144d, 0xc176, "Samsung Notebook 9 Pro (NP930MBE-K04US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
8713        SND_PCI_QUIRK(0x144d, 0xc189, "Samsung Galaxy Flex Book (NT950QCG-X716)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
8714        SND_PCI_QUIRK(0x144d, 0xc18a, "Samsung Galaxy Book Ion (NP930XCJ-K01US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
8715        SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
8716        SND_PCI_QUIRK(0x144d, 0xc812, "Samsung Notebook Pen S (NT950SBE-X58)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
8717        SND_PCI_QUIRK(0x144d, 0xc830, "Samsung Galaxy Book Ion (NT950XCJ-X716A)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
8718        SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
8719        SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
8720        SND_PCI_QUIRK(0x1462, 0xb171, "Cubi N 8GL (MS-B171)", ALC283_FIXUP_HEADSET_MIC),
8721        SND_PCI_QUIRK(0x152d, 0x1082, "Quanta NL3", ALC269_FIXUP_LIFEBOOK),
8722        SND_PCI_QUIRK(0x1558, 0x1323, "Clevo N130ZU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8723        SND_PCI_QUIRK(0x1558, 0x1325, "Clevo N15[01][CW]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8724        SND_PCI_QUIRK(0x1558, 0x1401, "Clevo L140[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8725        SND_PCI_QUIRK(0x1558, 0x1403, "Clevo N140CU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8726        SND_PCI_QUIRK(0x1558, 0x1404, "Clevo N150CU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8727        SND_PCI_QUIRK(0x1558, 0x14a1, "Clevo L141MU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8728        SND_PCI_QUIRK(0x1558, 0x4018, "Clevo NV40M[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8729        SND_PCI_QUIRK(0x1558, 0x4019, "Clevo NV40MZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8730        SND_PCI_QUIRK(0x1558, 0x4020, "Clevo NV40MB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8731        SND_PCI_QUIRK(0x1558, 0x40a1, "Clevo NL40GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8732        SND_PCI_QUIRK(0x1558, 0x40c1, "Clevo NL40[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8733        SND_PCI_QUIRK(0x1558, 0x40d1, "Clevo NL41DU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8734        SND_PCI_QUIRK(0x1558, 0x50a3, "Clevo NJ51GU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8735        SND_PCI_QUIRK(0x1558, 0x50b3, "Clevo NK50S[BEZ]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8736        SND_PCI_QUIRK(0x1558, 0x50b6, "Clevo NK50S5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8737        SND_PCI_QUIRK(0x1558, 0x50b8, "Clevo NK50SZ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8738        SND_PCI_QUIRK(0x1558, 0x50d5, "Clevo NP50D5", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8739        SND_PCI_QUIRK(0x1558, 0x50f0, "Clevo NH50A[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8740        SND_PCI_QUIRK(0x1558, 0x50f2, "Clevo NH50E[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8741        SND_PCI_QUIRK(0x1558, 0x50f3, "Clevo NH58DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8742        SND_PCI_QUIRK(0x1558, 0x50f5, "Clevo NH55EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8743        SND_PCI_QUIRK(0x1558, 0x50f6, "Clevo NH55DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8744        SND_PCI_QUIRK(0x1558, 0x5101, "Clevo S510WU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8745        SND_PCI_QUIRK(0x1558, 0x5157, "Clevo W517GU1", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8746        SND_PCI_QUIRK(0x1558, 0x51a1, "Clevo NS50MU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8747        SND_PCI_QUIRK(0x1558, 0x70a1, "Clevo NB70T[HJK]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8748        SND_PCI_QUIRK(0x1558, 0x70b3, "Clevo NK70SB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8749        SND_PCI_QUIRK(0x1558, 0x70f2, "Clevo NH79EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8750        SND_PCI_QUIRK(0x1558, 0x70f3, "Clevo NH77DPQ", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8751        SND_PCI_QUIRK(0x1558, 0x70f4, "Clevo NH77EPY", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8752        SND_PCI_QUIRK(0x1558, 0x70f6, "Clevo NH77DPQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8753        SND_PCI_QUIRK(0x1558, 0x8228, "Clevo NR40BU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8754        SND_PCI_QUIRK(0x1558, 0x8520, "Clevo NH50D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8755        SND_PCI_QUIRK(0x1558, 0x8521, "Clevo NH77D[CD]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8756        SND_PCI_QUIRK(0x1558, 0x8535, "Clevo NH50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8757        SND_PCI_QUIRK(0x1558, 0x8536, "Clevo NH79D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8758        SND_PCI_QUIRK(0x1558, 0x8550, "Clevo NH[57][0-9][ER][ACDH]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8759        SND_PCI_QUIRK(0x1558, 0x8551, "Clevo NH[57][0-9][ER][ACDH]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8760        SND_PCI_QUIRK(0x1558, 0x8560, "Clevo NH[57][0-9][ER][ACDH]Q", ALC269_FIXUP_HEADSET_MIC),
8761        SND_PCI_QUIRK(0x1558, 0x8561, "Clevo NH[57][0-9][ER][ACDH]Q", ALC269_FIXUP_HEADSET_MIC),
8762        SND_PCI_QUIRK(0x1558, 0x8562, "Clevo NH[57][0-9]RZ[Q]", ALC269_FIXUP_DMIC),
8763        SND_PCI_QUIRK(0x1558, 0x8668, "Clevo NP50B[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8764        SND_PCI_QUIRK(0x1558, 0x8680, "Clevo NJ50LU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8765        SND_PCI_QUIRK(0x1558, 0x8686, "Clevo NH50[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8766        SND_PCI_QUIRK(0x1558, 0x8a20, "Clevo NH55DCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8767        SND_PCI_QUIRK(0x1558, 0x8a51, "Clevo NH70RCQ-Y", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8768        SND_PCI_QUIRK(0x1558, 0x8d50, "Clevo NH55RCQ-M", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8769        SND_PCI_QUIRK(0x1558, 0x951d, "Clevo N950T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8770        SND_PCI_QUIRK(0x1558, 0x9600, "Clevo N960K[PR]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8771        SND_PCI_QUIRK(0x1558, 0x961d, "Clevo N960S[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8772        SND_PCI_QUIRK(0x1558, 0x971d, "Clevo N970T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8773        SND_PCI_QUIRK(0x1558, 0xa500, "Clevo NL5[03]RU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8774        SND_PCI_QUIRK(0x1558, 0xa600, "Clevo NL50NU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8775        SND_PCI_QUIRK(0x1558, 0xb018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8776        SND_PCI_QUIRK(0x1558, 0xb019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8777        SND_PCI_QUIRK(0x1558, 0xb022, "Clevo NH77D[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8778        SND_PCI_QUIRK(0x1558, 0xc018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8779        SND_PCI_QUIRK(0x1558, 0xc019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8780        SND_PCI_QUIRK(0x1558, 0xc022, "Clevo NH77[DC][QW]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
8781        SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC233_FIXUP_LENOVO_MULTI_CODECS),
8782        SND_PCI_QUIRK(0x17aa, 0x1048, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340),
8783        SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
8784        SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
8785        SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
8786        SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
8787        SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
8788        SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
8789        SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST),
8790        SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
8791        SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
8792        SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
8793        SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
8794        SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440),
8795        SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
8796        SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
8797        SND_PCI_QUIRK(0x17aa, 0x2211, "Thinkpad W541", ALC292_FIXUP_TPT440_DOCK),
8798        SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK),
8799        SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK),
8800        SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8801        SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK),
8802        SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK),
8803        SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK),
8804        SND_PCI_QUIRK(0x17aa, 0x222d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8805        SND_PCI_QUIRK(0x17aa, 0x222e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8806        SND_PCI_QUIRK(0x17aa, 0x2231, "Thinkpad T560", ALC292_FIXUP_TPT460),
8807        SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460),
8808        SND_PCI_QUIRK(0x17aa, 0x2245, "Thinkpad T470", ALC298_FIXUP_TPT470_DOCK),
8809        SND_PCI_QUIRK(0x17aa, 0x2246, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8810        SND_PCI_QUIRK(0x17aa, 0x2247, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8811        SND_PCI_QUIRK(0x17aa, 0x2249, "Thinkpad", ALC292_FIXUP_TPT460),
8812        SND_PCI_QUIRK(0x17aa, 0x224b, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8813        SND_PCI_QUIRK(0x17aa, 0x224c, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8814        SND_PCI_QUIRK(0x17aa, 0x224d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8815        SND_PCI_QUIRK(0x17aa, 0x225d, "Thinkpad T480", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8816        SND_PCI_QUIRK(0x17aa, 0x2292, "Thinkpad X1 Carbon 7th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
8817        SND_PCI_QUIRK(0x17aa, 0x22be, "Thinkpad X1 Carbon 8th", ALC285_FIXUP_THINKPAD_HEADSET_JACK),
8818        SND_PCI_QUIRK(0x17aa, 0x22c1, "Thinkpad P1 Gen 3", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK),
8819        SND_PCI_QUIRK(0x17aa, 0x22c2, "Thinkpad X1 Extreme Gen 3", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK),
8820        SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
8821        SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
8822        SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
8823        SND_PCI_QUIRK(0x17aa, 0x3111, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
8824        SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
8825        SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
8826        SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
8827        SND_PCI_QUIRK(0x17aa, 0x3151, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
8828        SND_PCI_QUIRK(0x17aa, 0x3176, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
8829        SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC),
8830        SND_PCI_QUIRK(0x17aa, 0x31af, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340),
8831        SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME),
8832        SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF),
8833        SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP),
8834        SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS),
8835        SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
8836        SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
8837        SND_PCI_QUIRK(0x17aa, 0x3819, "Lenovo 13s Gen2 ITL", ALC287_FIXUP_13S_GEN2_SPEAKERS),
8838        SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
8839        SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
8840        SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
8841        SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
8842        SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8843        SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
8844        SND_PCI_QUIRK(0x17aa, 0x501e, "Thinkpad L440", ALC292_FIXUP_TPT440_DOCK),
8845        SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8846        SND_PCI_QUIRK(0x17aa, 0x5034, "Thinkpad T450", ALC292_FIXUP_TPT440_DOCK),
8847        SND_PCI_QUIRK(0x17aa, 0x5036, "Thinkpad T450s", ALC292_FIXUP_TPT440_DOCK),
8848        SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK),
8849        SND_PCI_QUIRK(0x17aa, 0x504a, "ThinkPad X260", ALC292_FIXUP_TPT440_DOCK),
8850        SND_PCI_QUIRK(0x17aa, 0x504b, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE),
8851        SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460),
8852        SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460),
8853        SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460),
8854        SND_PCI_QUIRK(0x17aa, 0x505d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8855        SND_PCI_QUIRK(0x17aa, 0x505f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8856        SND_PCI_QUIRK(0x17aa, 0x5062, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8857        SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
8858        SND_PCI_QUIRK(0x17aa, 0x511e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8859        SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
8860        SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
8861        SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MACH-WX9", ALC256_FIXUP_HUAWEI_MACH_WX9_PINS),
8862        SND_PCI_QUIRK(0x1b35, 0x1235, "CZC B20", ALC269_FIXUP_CZC_B20),
8863        SND_PCI_QUIRK(0x1b35, 0x1236, "CZC TMI", ALC269_FIXUP_CZC_TMI),
8864        SND_PCI_QUIRK(0x1b35, 0x1237, "CZC L101", ALC269_FIXUP_CZC_L101),
8865        SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
8866        SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802),
8867        SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X),
8868        SND_PCI_QUIRK(0x1d05, 0x1132, "TongFang PHxTxX1", ALC256_FIXUP_TONGFANG_RESET_PERSISTENT_SETTINGS),
8869        SND_PCI_QUIRK(0x1d72, 0x1602, "RedmiBook", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
8870        SND_PCI_QUIRK(0x1d72, 0x1701, "XiaomiNotebook Pro", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE),
8871        SND_PCI_QUIRK(0x1d72, 0x1901, "RedmiBook 14", ALC256_FIXUP_ASUS_HEADSET_MIC),
8872        SND_PCI_QUIRK(0x1d72, 0x1947, "RedmiBook Air", ALC255_FIXUP_XIAOMI_HEADSET_MIC),
8873        SND_PCI_QUIRK(0x8086, 0x2074, "Intel NUC 8", ALC233_FIXUP_INTEL_NUC8_DMIC),
8874        SND_PCI_QUIRK(0x8086, 0x2080, "Intel NUC 8 Rugged", ALC256_FIXUP_INTEL_NUC8_RUGGED),
8875        SND_PCI_QUIRK(0x8086, 0x2081, "Intel NUC 10", ALC256_FIXUP_INTEL_NUC10),
8876
8877#if 0
8878        /* Below is a quirk table taken from the old code.
8879         * Basically the device should work as is without the fixup table.
8880         * If BIOS doesn't give a proper info, enable the corresponding
8881         * fixup entry.
8882         */
8883        SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
8884                      ALC269_FIXUP_AMIC),
8885        SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
8886        SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
8887        SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
8888        SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
8889        SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
8890        SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
8891        SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
8892        SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
8893        SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
8894        SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
8895        SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
8896        SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
8897        SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
8898        SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
8899        SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
8900        SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
8901        SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
8902        SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
8903        SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
8904        SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
8905        SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
8906        SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
8907        SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
8908        SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
8909        SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
8910        SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
8911        SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
8912        SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
8913        SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
8914        SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
8915        SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
8916        SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
8917        SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
8918        SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
8919        SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
8920        SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
8921        SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
8922        SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
8923        SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
8924#endif
8925        {}
8926};
8927
8928static const struct snd_pci_quirk alc269_fixup_vendor_tbl[] = {
8929        SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
8930        SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
8931        SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
8932        SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
8933        SND_PCI_QUIRK_VENDOR(0x19e5, "Huawei Matebook", ALC255_FIXUP_MIC_MUTE_LED),
8934        {}
8935};
8936
8937static const struct hda_model_fixup alc269_fixup_models[] = {
8938        {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
8939        {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
8940        {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
8941        {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
8942        {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
8943        {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
8944        {.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
8945        {.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = "headset-mode-no-hp-mic"},
8946        {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
8947        {.id = ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST, .name = "lenovo-dock-limit-boost"},
8948        {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
8949        {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"},
8950        {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
8951        {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
8952        {.id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE, .name = "dell-headset3"},
8953        {.id = ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, .name = "dell-headset4"},
8954        {.id = ALC283_FIXUP_CHROME_BOOK, .name = "alc283-dac-wcaps"},
8955        {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
8956        {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
8957        {.id = ALC292_FIXUP_TPT440, .name = "tpt440"},
8958        {.id = ALC292_FIXUP_TPT460, .name = "tpt460"},
8959        {.id = ALC298_FIXUP_TPT470_DOCK_FIX, .name = "tpt470-dock-fix"},
8960        {.id = ALC298_FIXUP_TPT470_DOCK, .name = "tpt470-dock"},
8961        {.id = ALC233_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
8962        {.id = ALC700_FIXUP_INTEL_REFERENCE, .name = "alc700-ref"},
8963        {.id = ALC269_FIXUP_SONY_VAIO, .name = "vaio"},
8964        {.id = ALC269_FIXUP_DELL_M101Z, .name = "dell-m101z"},
8965        {.id = ALC269_FIXUP_ASUS_G73JW, .name = "asus-g73jw"},
8966        {.id = ALC269_FIXUP_LENOVO_EAPD, .name = "lenovo-eapd"},
8967        {.id = ALC275_FIXUP_SONY_HWEQ, .name = "sony-hweq"},
8968        {.id = ALC269_FIXUP_PCM_44K, .name = "pcm44k"},
8969        {.id = ALC269_FIXUP_LIFEBOOK, .name = "lifebook"},
8970        {.id = ALC269_FIXUP_LIFEBOOK_EXTMIC, .name = "lifebook-extmic"},
8971        {.id = ALC269_FIXUP_LIFEBOOK_HP_PIN, .name = "lifebook-hp-pin"},
8972        {.id = ALC255_FIXUP_LIFEBOOK_U7x7_HEADSET_MIC, .name = "lifebook-u7x7"},
8973        {.id = ALC269VB_FIXUP_AMIC, .name = "alc269vb-amic"},
8974        {.id = ALC269VB_FIXUP_DMIC, .name = "alc269vb-dmic"},
8975        {.id = ALC269_FIXUP_HP_MUTE_LED_MIC1, .name = "hp-mute-led-mic1"},
8976        {.id = ALC269_FIXUP_HP_MUTE_LED_MIC2, .name = "hp-mute-led-mic2"},
8977        {.id = ALC269_FIXUP_HP_MUTE_LED_MIC3, .name = "hp-mute-led-mic3"},
8978        {.id = ALC269_FIXUP_HP_GPIO_MIC1_LED, .name = "hp-gpio-mic1"},
8979        {.id = ALC269_FIXUP_HP_LINE1_MIC1_LED, .name = "hp-line1-mic1"},
8980        {.id = ALC269_FIXUP_NO_SHUTUP, .name = "noshutup"},
8981        {.id = ALC286_FIXUP_SONY_MIC_NO_PRESENCE, .name = "sony-nomic"},
8982        {.id = ALC269_FIXUP_ASPIRE_HEADSET_MIC, .name = "aspire-headset-mic"},
8983        {.id = ALC269_FIXUP_ASUS_X101, .name = "asus-x101"},
8984        {.id = ALC271_FIXUP_HP_GATE_MIC_JACK, .name = "acer-ao7xx"},
8985        {.id = ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572, .name = "acer-aspire-e1"},
8986        {.id = ALC269_FIXUP_ACER_AC700, .name = "acer-ac700"},
8987        {.id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST, .name = "limit-mic-boost"},
8988        {.id = ALC269VB_FIXUP_ASUS_ZENBOOK, .name = "asus-zenbook"},
8989        {.id = ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A, .name = "asus-zenbook-ux31a"},
8990        {.id = ALC269VB_FIXUP_ORDISSIMO_EVE2, .name = "ordissimo"},
8991        {.id = ALC282_FIXUP_ASUS_TX300, .name = "asus-tx300"},
8992        {.id = ALC283_FIXUP_INT_MIC, .name = "alc283-int-mic"},
8993        {.id = ALC290_FIXUP_MONO_SPEAKERS_HSJACK, .name = "mono-speakers"},
8994        {.id = ALC290_FIXUP_SUBWOOFER_HSJACK, .name = "alc290-subwoofer"},
8995        {.id = ALC269_FIXUP_THINKPAD_ACPI, .name = "thinkpad"},
8996        {.id = ALC269_FIXUP_DMIC_THINKPAD_ACPI, .name = "dmic-thinkpad"},
8997        {.id = ALC255_FIXUP_ACER_MIC_NO_PRESENCE, .name = "alc255-acer"},
8998        {.id = ALC255_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc255-asus"},
8999        {.id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc255-dell1"},
9000        {.id = ALC255_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "alc255-dell2"},
9001        {.id = ALC293_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc293-dell1"},
9002        {.id = ALC283_FIXUP_HEADSET_MIC, .name = "alc283-headset"},
9003        {.id = ALC255_FIXUP_MIC_MUTE_LED, .name = "alc255-dell-mute"},
9004        {.id = ALC282_FIXUP_ASPIRE_V5_PINS, .name = "aspire-v5"},
9005        {.id = ALC269VB_FIXUP_ASPIRE_E1_COEF, .name = "aspire-e1-coef"},
9006        {.id = ALC280_FIXUP_HP_GPIO4, .name = "hp-gpio4"},
9007        {.id = ALC286_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
9008        {.id = ALC280_FIXUP_HP_GPIO2_MIC_HOTKEY, .name = "hp-gpio2-hotkey"},
9009        {.id = ALC280_FIXUP_HP_DOCK_PINS, .name = "hp-dock-pins"},
9010        {.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic"},
9011        {.id = ALC280_FIXUP_HP_9480M, .name = "hp-9480m"},
9012        {.id = ALC288_FIXUP_DELL_HEADSET_MODE, .name = "alc288-dell-headset"},
9013        {.id = ALC288_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc288-dell1"},
9014        {.id = ALC288_FIXUP_DELL_XPS_13, .name = "alc288-dell-xps13"},
9015        {.id = ALC292_FIXUP_DELL_E7X, .name = "dell-e7x"},
9016        {.id = ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK, .name = "alc293-dell"},
9017        {.id = ALC298_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc298-dell1"},
9018        {.id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE, .name = "alc298-dell-aio"},
9019        {.id = ALC275_FIXUP_DELL_XPS, .name = "alc275-dell-xps"},
9020        {.id = ALC293_FIXUP_LENOVO_SPK_NOISE, .name = "lenovo-spk-noise"},
9021        {.id = ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY, .name = "lenovo-hotkey"},
9022        {.id = ALC255_FIXUP_DELL_SPK_NOISE, .name = "dell-spk-noise"},
9023        {.id = ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "alc225-dell1"},
9024        {.id = ALC295_FIXUP_DISABLE_DAC3, .name = "alc295-disable-dac3"},
9025        {.id = ALC285_FIXUP_SPEAKER2_TO_DAC1, .name = "alc285-speaker2-to-dac1"},
9026        {.id = ALC280_FIXUP_HP_HEADSET_MIC, .name = "alc280-hp-headset"},
9027        {.id = ALC221_FIXUP_HP_FRONT_MIC, .name = "alc221-hp-mic"},
9028        {.id = ALC298_FIXUP_SPK_VOLUME, .name = "alc298-spk-volume"},
9029        {.id = ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER, .name = "dell-inspiron-7559"},
9030        {.id = ALC269_FIXUP_ATIV_BOOK_8, .name = "ativ-book"},
9031        {.id = ALC221_FIXUP_HP_MIC_NO_PRESENCE, .name = "alc221-hp-mic"},
9032        {.id = ALC256_FIXUP_ASUS_HEADSET_MODE, .name = "alc256-asus-headset"},
9033        {.id = ALC256_FIXUP_ASUS_MIC, .name = "alc256-asus-mic"},
9034        {.id = ALC256_FIXUP_ASUS_AIO_GPIO2, .name = "alc256-asus-aio"},
9035        {.id = ALC233_FIXUP_ASUS_MIC_NO_PRESENCE, .name = "alc233-asus"},
9036        {.id = ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE, .name = "alc233-eapd"},
9037        {.id = ALC294_FIXUP_LENOVO_MIC_LOCATION, .name = "alc294-lenovo-mic"},
9038        {.id = ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE, .name = "alc225-wyse"},
9039        {.id = ALC274_FIXUP_DELL_AIO_LINEOUT_VERB, .name = "alc274-dell-aio"},
9040        {.id = ALC255_FIXUP_DUMMY_LINEOUT_VERB, .name = "alc255-dummy-lineout"},
9041        {.id = ALC255_FIXUP_DELL_HEADSET_MIC, .name = "alc255-dell-headset"},
9042        {.id = ALC295_FIXUP_HP_X360, .name = "alc295-hp-x360"},
9043        {.id = ALC225_FIXUP_HEADSET_JACK, .name = "alc-headset-jack"},
9044        {.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-chrome-book"},
9045        {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
9046        {.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"},
9047        {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"},
9048        {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc298-samsung-headphone"},
9049        {.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"},
9050        {.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"},
9051        {.id = ALC245_FIXUP_HP_X360_AMP, .name = "alc245-hp-x360-amp"},
9052        {.id = ALC295_FIXUP_HP_OMEN, .name = "alc295-hp-omen"},
9053        {.id = ALC285_FIXUP_HP_SPECTRE_X360, .name = "alc285-hp-spectre-x360"},
9054        {.id = ALC285_FIXUP_HP_SPECTRE_X360_EB1, .name = "alc285-hp-spectre-x360-eb1"},
9055        {.id = ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, .name = "alc287-ideapad-bass-spk-amp"},
9056        {.id = ALC623_FIXUP_LENOVO_THINKSTATION_P340, .name = "alc623-lenovo-thinkstation-p340"},
9057        {.id = ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, .name = "alc255-acer-headphone-and-mic"},
9058        {}
9059};
9060#define ALC225_STANDARD_PINS \
9061        {0x21, 0x04211020}
9062
9063#define ALC256_STANDARD_PINS \
9064        {0x12, 0x90a60140}, \
9065        {0x14, 0x90170110}, \
9066        {0x21, 0x02211020}
9067
9068#define ALC282_STANDARD_PINS \
9069        {0x14, 0x90170110}
9070
9071#define ALC290_STANDARD_PINS \
9072        {0x12, 0x99a30130}
9073
9074#define ALC292_STANDARD_PINS \
9075        {0x14, 0x90170110}, \
9076        {0x15, 0x0221401f}
9077
9078#define ALC295_STANDARD_PINS \
9079        {0x12, 0xb7a60130}, \
9080        {0x14, 0x90170110}, \
9081        {0x21, 0x04211020}
9082
9083#define ALC298_STANDARD_PINS \
9084        {0x12, 0x90a60130}, \
9085        {0x21, 0x03211020}
9086
9087static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
9088        SND_HDA_PIN_QUIRK(0x10ec0221, 0x103c, "HP Workstation", ALC221_FIXUP_HP_HEADSET_MIC,
9089                {0x14, 0x01014020},
9090                {0x17, 0x90170110},
9091                {0x18, 0x02a11030},
9092                {0x19, 0x0181303F},
9093                {0x21, 0x0221102f}),
9094        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1025, "Acer", ALC255_FIXUP_ACER_MIC_NO_PRESENCE,
9095                {0x12, 0x90a601c0},
9096                {0x14, 0x90171120},
9097                {0x21, 0x02211030}),
9098        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
9099                {0x14, 0x90170110},
9100                {0x1b, 0x90a70130},
9101                {0x21, 0x03211020}),
9102        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1043, "ASUS", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE,
9103                {0x1a, 0x90a70130},
9104                {0x1b, 0x90170110},
9105                {0x21, 0x03211020}),
9106        SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9107                ALC225_STANDARD_PINS,
9108                {0x12, 0xb7a60130},
9109                {0x14, 0x901701a0}),
9110        SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9111                ALC225_STANDARD_PINS,
9112                {0x12, 0xb7a60130},
9113                {0x14, 0x901701b0}),
9114        SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9115                ALC225_STANDARD_PINS,
9116                {0x12, 0xb7a60150},
9117                {0x14, 0x901701a0}),
9118        SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9119                ALC225_STANDARD_PINS,
9120                {0x12, 0xb7a60150},
9121                {0x14, 0x901701b0}),
9122        SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
9123                ALC225_STANDARD_PINS,
9124                {0x12, 0xb7a60130},
9125                {0x1b, 0x90170110}),
9126        SND_HDA_PIN_QUIRK(0x10ec0233, 0x8086, "Intel NUC Skull Canyon", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9127                {0x1b, 0x01111010},
9128                {0x1e, 0x01451130},
9129                {0x21, 0x02211020}),
9130        SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
9131                {0x12, 0x90a60140},
9132                {0x14, 0x90170110},
9133                {0x19, 0x02a11030},
9134                {0x21, 0x02211020}),
9135        SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
9136                {0x14, 0x90170110},
9137                {0x19, 0x02a11030},
9138                {0x1a, 0x02a11040},
9139                {0x1b, 0x01014020},
9140                {0x21, 0x0221101f}),
9141        SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
9142                {0x14, 0x90170110},
9143                {0x19, 0x02a11030},
9144                {0x1a, 0x02a11040},
9145                {0x1b, 0x01011020},
9146                {0x21, 0x0221101f}),
9147        SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
9148                {0x14, 0x90170110},
9149                {0x19, 0x02a11020},
9150                {0x1a, 0x02a11030},
9151                {0x21, 0x0221101f}),
9152        SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC236_FIXUP_DELL_AIO_HEADSET_MIC,
9153                {0x21, 0x02211010}),
9154        SND_HDA_PIN_QUIRK(0x10ec0236, 0x103c, "HP", ALC256_FIXUP_HP_HEADSET_MIC,
9155                {0x14, 0x90170110},
9156                {0x19, 0x02a11020},
9157                {0x21, 0x02211030}),
9158        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
9159                {0x14, 0x90170110},
9160                {0x21, 0x02211020}),
9161        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9162                {0x14, 0x90170130},
9163                {0x21, 0x02211040}),
9164        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9165                {0x12, 0x90a60140},
9166                {0x14, 0x90170110},
9167                {0x21, 0x02211020}),
9168        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9169                {0x12, 0x90a60160},
9170                {0x14, 0x90170120},
9171                {0x21, 0x02211030}),
9172        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9173                {0x14, 0x90170110},
9174                {0x1b, 0x02011020},
9175                {0x21, 0x0221101f}),
9176        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9177                {0x14, 0x90170110},
9178                {0x1b, 0x01011020},
9179                {0x21, 0x0221101f}),
9180        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9181                {0x14, 0x90170130},
9182                {0x1b, 0x01014020},
9183                {0x21, 0x0221103f}),
9184        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9185                {0x14, 0x90170130},
9186                {0x1b, 0x01011020},
9187                {0x21, 0x0221103f}),
9188        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9189                {0x14, 0x90170130},
9190                {0x1b, 0x02011020},
9191                {0x21, 0x0221103f}),
9192        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9193                {0x14, 0x90170150},
9194                {0x1b, 0x02011020},
9195                {0x21, 0x0221105f}),
9196        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9197                {0x14, 0x90170110},
9198                {0x1b, 0x01014020},
9199                {0x21, 0x0221101f}),
9200        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9201                {0x12, 0x90a60160},
9202                {0x14, 0x90170120},
9203                {0x17, 0x90170140},
9204                {0x21, 0x0321102f}),
9205        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9206                {0x12, 0x90a60160},
9207                {0x14, 0x90170130},
9208                {0x21, 0x02211040}),
9209        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9210                {0x12, 0x90a60160},
9211                {0x14, 0x90170140},
9212                {0x21, 0x02211050}),
9213        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9214                {0x12, 0x90a60170},
9215                {0x14, 0x90170120},
9216                {0x21, 0x02211030}),
9217        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9218                {0x12, 0x90a60170},
9219                {0x14, 0x90170130},
9220                {0x21, 0x02211040}),
9221        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9222                {0x12, 0x90a60170},
9223                {0x14, 0x90171130},
9224                {0x21, 0x02211040}),
9225        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9226                {0x12, 0x90a60170},
9227                {0x14, 0x90170140},
9228                {0x21, 0x02211050}),
9229        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5548", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9230                {0x12, 0x90a60180},
9231                {0x14, 0x90170130},
9232                {0x21, 0x02211040}),
9233        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5565", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9234                {0x12, 0x90a60180},
9235                {0x14, 0x90170120},
9236                {0x21, 0x02211030}),
9237        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9238                {0x1b, 0x01011020},
9239                {0x21, 0x02211010}),
9240        SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
9241                {0x14, 0x90170110},
9242                {0x1b, 0x90a70130},
9243                {0x21, 0x04211020}),
9244        SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC,
9245                {0x14, 0x90170110},
9246                {0x1b, 0x90a70130},
9247                {0x21, 0x03211020}),
9248        SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
9249                {0x12, 0x90a60130},
9250                {0x14, 0x90170110},
9251                {0x21, 0x03211020}),
9252        SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
9253                {0x12, 0x90a60130},
9254                {0x14, 0x90170110},
9255                {0x21, 0x04211020}),
9256        SND_HDA_PIN_QUIRK(0x10ec0256, 0x1043, "ASUS", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE,
9257                {0x1a, 0x90a70130},
9258                {0x1b, 0x90170110},
9259                {0x21, 0x03211020}),
9260       SND_HDA_PIN_QUIRK(0x10ec0256, 0x103c, "HP", ALC256_FIXUP_HP_HEADSET_MIC,
9261                {0x14, 0x90170110},
9262                {0x19, 0x02a11020},
9263                {0x21, 0x0221101f}),
9264       SND_HDA_PIN_QUIRK(0x10ec0274, 0x103c, "HP", ALC274_FIXUP_HP_HEADSET_MIC,
9265                {0x17, 0x90170110},
9266                {0x19, 0x03a11030},
9267                {0x21, 0x03211020}),
9268        SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
9269                {0x12, 0x90a60130},
9270                {0x14, 0x90170110},
9271                {0x15, 0x0421101f},
9272                {0x1a, 0x04a11020}),
9273        SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED,
9274                {0x12, 0x90a60140},
9275                {0x14, 0x90170110},
9276                {0x15, 0x0421101f},
9277                {0x18, 0x02811030},
9278                {0x1a, 0x04a1103f},
9279                {0x1b, 0x02011020}),
9280        SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP 15 Touchsmart", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9281                ALC282_STANDARD_PINS,
9282                {0x12, 0x99a30130},
9283                {0x19, 0x03a11020},
9284                {0x21, 0x0321101f}),
9285        SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9286                ALC282_STANDARD_PINS,
9287                {0x12, 0x99a30130},
9288                {0x19, 0x03a11020},
9289                {0x21, 0x03211040}),
9290        SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9291                ALC282_STANDARD_PINS,
9292                {0x12, 0x99a30130},
9293                {0x19, 0x03a11030},
9294                {0x21, 0x03211020}),
9295        SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9296                ALC282_STANDARD_PINS,
9297                {0x12, 0x99a30130},
9298                {0x19, 0x04a11020},
9299                {0x21, 0x0421101f}),
9300        SND_HDA_PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED,
9301                ALC282_STANDARD_PINS,
9302                {0x12, 0x90a60140},
9303                {0x19, 0x04a11030},
9304                {0x21, 0x04211020}),
9305        SND_HDA_PIN_QUIRK(0x10ec0282, 0x1025, "Acer", ALC282_FIXUP_ACER_DISABLE_LINEOUT,
9306                ALC282_STANDARD_PINS,
9307                {0x12, 0x90a609c0},
9308                {0x18, 0x03a11830},
9309                {0x19, 0x04a19831},
9310                {0x1a, 0x0481303f},
9311                {0x1b, 0x04211020},
9312                {0x21, 0x0321101f}),
9313        SND_HDA_PIN_QUIRK(0x10ec0282, 0x1025, "Acer", ALC282_FIXUP_ACER_DISABLE_LINEOUT,
9314                ALC282_STANDARD_PINS,
9315                {0x12, 0x90a60940},
9316                {0x18, 0x03a11830},
9317                {0x19, 0x04a19831},
9318                {0x1a, 0x0481303f},
9319                {0x1b, 0x04211020},
9320                {0x21, 0x0321101f}),
9321        SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9322                ALC282_STANDARD_PINS,
9323                {0x12, 0x90a60130},
9324                {0x21, 0x0321101f}),
9325        SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9326                {0x12, 0x90a60160},
9327                {0x14, 0x90170120},
9328                {0x21, 0x02211030}),
9329        SND_HDA_PIN_QUIRK(0x10ec0283, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9330                ALC282_STANDARD_PINS,
9331                {0x12, 0x90a60130},
9332                {0x19, 0x03a11020},
9333                {0x21, 0x0321101f}),
9334        SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
9335                {0x12, 0x90a60130},
9336                {0x14, 0x90170110},
9337                {0x19, 0x04a11040},
9338                {0x21, 0x04211020}),
9339        SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_LENOVO_PC_BEEP_IN_NOISE,
9340                {0x14, 0x90170110},
9341                {0x19, 0x04a11040},
9342                {0x1d, 0x40600001},
9343                {0x21, 0x04211020}),
9344        SND_HDA_PIN_QUIRK(0x10ec0285, 0x17aa, "Lenovo", ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK,
9345                {0x14, 0x90170110},
9346                {0x19, 0x04a11040},
9347                {0x21, 0x04211020}),
9348        SND_HDA_PIN_QUIRK(0x10ec0287, 0x17aa, "Lenovo", ALC285_FIXUP_THINKPAD_HEADSET_JACK,
9349                {0x14, 0x90170110},
9350                {0x17, 0x90170111},
9351                {0x19, 0x03a11030},
9352                {0x21, 0x03211020}),
9353        SND_HDA_PIN_QUIRK(0x10ec0286, 0x1025, "Acer", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE,
9354                {0x12, 0x90a60130},
9355                {0x17, 0x90170110},
9356                {0x21, 0x02211020}),
9357        SND_HDA_PIN_QUIRK(0x10ec0288, 0x1028, "Dell", ALC288_FIXUP_DELL1_MIC_NO_PRESENCE,
9358                {0x12, 0x90a60120},
9359                {0x14, 0x90170110},
9360                {0x21, 0x0321101f}),
9361        SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9362                ALC290_STANDARD_PINS,
9363                {0x15, 0x04211040},
9364                {0x18, 0x90170112},
9365                {0x1a, 0x04a11020}),
9366        SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9367                ALC290_STANDARD_PINS,
9368                {0x15, 0x04211040},
9369                {0x18, 0x90170110},
9370                {0x1a, 0x04a11020}),
9371        SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9372                ALC290_STANDARD_PINS,
9373                {0x15, 0x0421101f},
9374                {0x1a, 0x04a11020}),
9375        SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9376                ALC290_STANDARD_PINS,
9377                {0x15, 0x04211020},
9378                {0x1a, 0x04a11040}),
9379        SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9380                ALC290_STANDARD_PINS,
9381                {0x14, 0x90170110},
9382                {0x15, 0x04211020},
9383                {0x1a, 0x04a11040}),
9384        SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9385                ALC290_STANDARD_PINS,
9386                {0x14, 0x90170110},
9387                {0x15, 0x04211020},
9388                {0x1a, 0x04a11020}),
9389        SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
9390                ALC290_STANDARD_PINS,
9391                {0x14, 0x90170110},
9392                {0x15, 0x0421101f},
9393                {0x1a, 0x04a11020}),
9394        SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
9395                ALC292_STANDARD_PINS,
9396                {0x12, 0x90a60140},
9397                {0x16, 0x01014020},
9398                {0x19, 0x01a19030}),
9399        SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
9400                ALC292_STANDARD_PINS,
9401                {0x12, 0x90a60140},
9402                {0x16, 0x01014020},
9403                {0x18, 0x02a19031},
9404                {0x19, 0x01a1903e}),
9405        SND_HDA_PIN_QUIRK(0x10ec0292, 0x1028, "Dell", ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
9406                ALC292_STANDARD_PINS,
9407                {0x12, 0x90a60140}),
9408        SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
9409                ALC292_STANDARD_PINS,
9410                {0x13, 0x90a60140},
9411                {0x16, 0x21014020},
9412                {0x19, 0x21a19030}),
9413        SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
9414                ALC292_STANDARD_PINS,
9415                {0x13, 0x90a60140}),
9416        SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_HPE,
9417                {0x17, 0x90170110},
9418                {0x21, 0x04211020}),
9419        SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_MIC,
9420                {0x14, 0x90170110},
9421                {0x1b, 0x90a70130},
9422                {0x21, 0x04211020}),
9423        SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
9424                {0x12, 0x90a60130},
9425                {0x17, 0x90170110},
9426                {0x21, 0x03211020}),
9427        SND_HDA_PIN_QUIRK(0x10ec0294, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
9428                {0x12, 0x90a60130},
9429                {0x17, 0x90170110},
9430                {0x21, 0x04211020}),
9431        SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC294_FIXUP_ASUS_SPK,
9432                {0x12, 0x90a60130},
9433                {0x17, 0x90170110},
9434                {0x21, 0x03211020}),
9435        SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
9436                {0x12, 0x90a60120},
9437                {0x17, 0x90170110},
9438                {0x21, 0x04211030}),
9439        SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
9440                {0x12, 0x90a60130},
9441                {0x17, 0x90170110},
9442                {0x21, 0x03211020}),
9443        SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
9444                {0x12, 0x90a60130},
9445                {0x17, 0x90170110},
9446                {0x21, 0x03211020}),
9447        SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
9448                {0x14, 0x90170110},
9449                {0x21, 0x04211020}),
9450        SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
9451                {0x14, 0x90170110},
9452                {0x21, 0x04211030}),
9453        SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9454                ALC295_STANDARD_PINS,
9455                {0x17, 0x21014020},
9456                {0x18, 0x21a19030}),
9457        SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9458                ALC295_STANDARD_PINS,
9459                {0x17, 0x21014040},
9460                {0x18, 0x21a19050}),
9461        SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
9462                ALC295_STANDARD_PINS),
9463        SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
9464                ALC298_STANDARD_PINS,
9465                {0x17, 0x90170110}),
9466        SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
9467                ALC298_STANDARD_PINS,
9468                {0x17, 0x90170140}),
9469        SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE,
9470                ALC298_STANDARD_PINS,
9471                {0x17, 0x90170150}),
9472        SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_SPK_VOLUME,
9473                {0x12, 0xb7a60140},
9474                {0x13, 0xb7a60150},
9475                {0x17, 0x90170110},
9476                {0x1a, 0x03011020},
9477                {0x21, 0x03211030}),
9478        SND_HDA_PIN_QUIRK(0x10ec0298, 0x1028, "Dell", ALC298_FIXUP_ALIENWARE_MIC_NO_PRESENCE,
9479                {0x12, 0xb7a60140},
9480                {0x17, 0x90170110},
9481                {0x1a, 0x03a11030},
9482                {0x21, 0x03211020}),
9483        SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
9484                ALC225_STANDARD_PINS,
9485                {0x12, 0xb7a60130},
9486                {0x17, 0x90170110}),
9487        SND_HDA_PIN_QUIRK(0x10ec0623, 0x17aa, "Lenovo", ALC283_FIXUP_HEADSET_MIC,
9488                {0x14, 0x01014010},
9489                {0x17, 0x90170120},
9490                {0x18, 0x02a11030},
9491                {0x19, 0x02a1103f},
9492                {0x21, 0x0221101f}),
9493        {}
9494};
9495
9496/* This is the fallback pin_fixup_tbl for alc269 family, to make the tbl match
9497 * more machines, don't need to match all valid pins, just need to match
9498 * all the pins defined in the tbl. Just because of this reason, it is possible
9499 * that a single machine matches multiple tbls, so there is one limitation:
9500 *   at most one tbl is allowed to define for the same vendor and same codec
9501 */
9502static const struct snd_hda_pin_quirk alc269_fallback_pin_fixup_tbl[] = {
9503        SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
9504                {0x19, 0x40000000},
9505                {0x1b, 0x40000000}),
9506        SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9507                {0x19, 0x40000000},
9508                {0x1a, 0x40000000}),
9509        SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
9510                {0x19, 0x40000000},
9511                {0x1a, 0x40000000}),
9512        SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
9513                {0x19, 0x40000000},
9514                {0x1a, 0x40000000}),
9515        {}
9516};
9517
9518static void alc269_fill_coef(struct hda_codec *codec)
9519{
9520        struct alc_spec *spec = codec->spec;
9521        int val;
9522
9523        if (spec->codec_variant != ALC269_TYPE_ALC269VB)
9524                return;
9525
9526        if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
9527                alc_write_coef_idx(codec, 0xf, 0x960b);
9528                alc_write_coef_idx(codec, 0xe, 0x8817);
9529        }
9530
9531        if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
9532                alc_write_coef_idx(codec, 0xf, 0x960b);
9533                alc_write_coef_idx(codec, 0xe, 0x8814);
9534        }
9535
9536        if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
9537                /* Power up output pin */
9538                alc_update_coef_idx(codec, 0x04, 0, 1<<11);
9539        }
9540
9541        if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
9542                val = alc_read_coef_idx(codec, 0xd);
9543                if (val != -1 && (val & 0x0c00) >> 10 != 0x1) {
9544                        /* Capless ramp up clock control */
9545                        alc_write_coef_idx(codec, 0xd, val | (1<<10));
9546                }
9547                val = alc_read_coef_idx(codec, 0x17);
9548                if (val != -1 && (val & 0x01c0) >> 6 != 0x4) {
9549                        /* Class D power on reset */
9550                        alc_write_coef_idx(codec, 0x17, val | (1<<7));
9551                }
9552        }
9553
9554        /* HP */
9555        alc_update_coef_idx(codec, 0x4, 0, 1<<11);
9556}
9557
9558/*
9559 */
9560static int patch_alc269(struct hda_codec *codec)
9561{
9562        struct alc_spec *spec;
9563        int err;
9564
9565        err = alc_alloc_spec(codec, 0x0b);
9566        if (err < 0)
9567                return err;
9568
9569        spec = codec->spec;
9570        spec->gen.shared_mic_vref_pin = 0x18;
9571        codec->power_save_node = 0;
9572
9573#ifdef CONFIG_PM
9574        codec->patch_ops.suspend = alc269_suspend;
9575        codec->patch_ops.resume = alc269_resume;
9576#endif
9577        spec->shutup = alc_default_shutup;
9578        spec->init_hook = alc_default_init;
9579
9580        switch (codec->core.vendor_id) {
9581        case 0x10ec0269:
9582                spec->codec_variant = ALC269_TYPE_ALC269VA;
9583                switch (alc_get_coef0(codec) & 0x00f0) {
9584                case 0x0010:
9585                        if (codec->bus->pci &&
9586                            codec->bus->pci->subsystem_vendor == 0x1025 &&
9587                            spec->cdefine.platform_type == 1)
9588                                err = alc_codec_rename(codec, "ALC271X");
9589                        spec->codec_variant = ALC269_TYPE_ALC269VB;
9590                        break;
9591                case 0x0020:
9592                        if (codec->bus->pci &&
9593                            codec->bus->pci->subsystem_vendor == 0x17aa &&
9594                            codec->bus->pci->subsystem_device == 0x21f3)
9595                                err = alc_codec_rename(codec, "ALC3202");
9596                        spec->codec_variant = ALC269_TYPE_ALC269VC;
9597                        break;
9598                case 0x0030:
9599                        spec->codec_variant = ALC269_TYPE_ALC269VD;
9600                        break;
9601                default:
9602                        alc_fix_pll_init(codec, 0x20, 0x04, 15);
9603                }
9604                if (err < 0)
9605                        goto error;
9606                spec->shutup = alc269_shutup;
9607                spec->init_hook = alc269_fill_coef;
9608                alc269_fill_coef(codec);
9609                break;
9610
9611        case 0x10ec0280:
9612        case 0x10ec0290:
9613                spec->codec_variant = ALC269_TYPE_ALC280;
9614                break;
9615        case 0x10ec0282:
9616                spec->codec_variant = ALC269_TYPE_ALC282;
9617                spec->shutup = alc282_shutup;
9618                spec->init_hook = alc282_init;
9619                break;
9620        case 0x10ec0233:
9621        case 0x10ec0283:
9622                spec->codec_variant = ALC269_TYPE_ALC283;
9623                spec->shutup = alc283_shutup;
9624                spec->init_hook = alc283_init;
9625                break;
9626        case 0x10ec0284:
9627        case 0x10ec0292:
9628                spec->codec_variant = ALC269_TYPE_ALC284;
9629                break;
9630        case 0x10ec0293:
9631                spec->codec_variant = ALC269_TYPE_ALC293;
9632                break;
9633        case 0x10ec0286:
9634        case 0x10ec0288:
9635                spec->codec_variant = ALC269_TYPE_ALC286;
9636                break;
9637        case 0x10ec0298:
9638                spec->codec_variant = ALC269_TYPE_ALC298;
9639                break;
9640        case 0x10ec0235:
9641        case 0x10ec0255:
9642                spec->codec_variant = ALC269_TYPE_ALC255;
9643                spec->shutup = alc256_shutup;
9644                spec->init_hook = alc256_init;
9645                break;
9646        case 0x10ec0230:
9647        case 0x10ec0236:
9648        case 0x10ec0256:
9649                spec->codec_variant = ALC269_TYPE_ALC256;
9650                spec->shutup = alc256_shutup;
9651                spec->init_hook = alc256_init;
9652                spec->gen.mixer_nid = 0; /* ALC256 does not have any loopback mixer path */
9653                break;
9654        case 0x10ec0257:
9655                spec->codec_variant = ALC269_TYPE_ALC257;
9656                spec->shutup = alc256_shutup;
9657                spec->init_hook = alc256_init;
9658                spec->gen.mixer_nid = 0;
9659                break;
9660        case 0x10ec0215:
9661        case 0x10ec0245:
9662        case 0x10ec0285:
9663        case 0x10ec0289:
9664                spec->codec_variant = ALC269_TYPE_ALC215;
9665                spec->shutup = alc225_shutup;
9666                spec->init_hook = alc225_init;
9667                spec->gen.mixer_nid = 0;
9668                break;
9669        case 0x10ec0225:
9670        case 0x10ec0295:
9671        case 0x10ec0299:
9672                spec->codec_variant = ALC269_TYPE_ALC225;
9673                spec->shutup = alc225_shutup;
9674                spec->init_hook = alc225_init;
9675                spec->gen.mixer_nid = 0; /* no loopback on ALC225, ALC295 and ALC299 */
9676                break;
9677        case 0x10ec0287:
9678                spec->codec_variant = ALC269_TYPE_ALC287;
9679                spec->shutup = alc225_shutup;
9680                spec->init_hook = alc225_init;
9681                spec->gen.mixer_nid = 0; /* no loopback on ALC287 */
9682                break;
9683        case 0x10ec0234:
9684        case 0x10ec0274:
9685        case 0x10ec0294:
9686                spec->codec_variant = ALC269_TYPE_ALC294;
9687                spec->gen.mixer_nid = 0; /* ALC2x4 does not have any loopback mixer path */
9688                alc_update_coef_idx(codec, 0x6b, 0x0018, (1<<4) | (1<<3)); /* UAJ MIC Vref control by verb */
9689                spec->init_hook = alc294_init;
9690                break;
9691        case 0x10ec0300:
9692                spec->codec_variant = ALC269_TYPE_ALC300;
9693                spec->gen.mixer_nid = 0; /* no loopback on ALC300 */
9694                break;
9695        case 0x10ec0623:
9696                spec->codec_variant = ALC269_TYPE_ALC623;
9697                break;
9698        case 0x10ec0700:
9699        case 0x10ec0701:
9700        case 0x10ec0703:
9701        case 0x10ec0711:
9702                spec->codec_variant = ALC269_TYPE_ALC700;
9703                spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
9704                alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
9705                spec->init_hook = alc294_init;
9706                break;
9707
9708        }
9709
9710        if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
9711                spec->has_alc5505_dsp = 1;
9712                spec->init_hook = alc5505_dsp_init;
9713        }
9714
9715        alc_pre_init(codec);
9716
9717        snd_hda_pick_fixup(codec, alc269_fixup_models,
9718                       alc269_fixup_tbl, alc269_fixups);
9719        /* FIXME: both TX300 and ROG Strix G17 have the same SSID, and
9720         * the quirk breaks the latter (bko#214101).
9721         * Clear the wrong entry.
9722         */
9723        if (codec->fixup_id == ALC282_FIXUP_ASUS_TX300 &&
9724            codec->core.vendor_id == 0x10ec0294) {
9725                codec_dbg(codec, "Clear wrong fixup for ASUS ROG Strix G17\n");
9726                codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
9727        }
9728
9729        snd_hda_pick_pin_fixup(codec, alc269_pin_fixup_tbl, alc269_fixups, true);
9730        snd_hda_pick_pin_fixup(codec, alc269_fallback_pin_fixup_tbl, alc269_fixups, false);
9731        snd_hda_pick_fixup(codec, NULL, alc269_fixup_vendor_tbl,
9732                           alc269_fixups);
9733        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9734
9735        alc_auto_parse_customize_define(codec);
9736
9737        if (has_cdefine_beep(codec))
9738                spec->gen.beep_nid = 0x01;
9739
9740        /* automatic parse from the BIOS config */
9741        err = alc269_parse_auto_config(codec);
9742        if (err < 0)
9743                goto error;
9744
9745        if (!spec->gen.no_analog && spec->gen.beep_nid && spec->gen.mixer_nid) {
9746                err = set_beep_amp(spec, spec->gen.mixer_nid, 0x04, HDA_INPUT);
9747                if (err < 0)
9748                        goto error;
9749        }
9750
9751        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
9752
9753        return 0;
9754
9755 error:
9756        alc_free(codec);
9757        return err;
9758}
9759
9760/*
9761 * ALC861
9762 */
9763
9764static int alc861_parse_auto_config(struct hda_codec *codec)
9765{
9766        static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9767        static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
9768        return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
9769}
9770
9771/* Pin config fixes */
9772enum {
9773        ALC861_FIXUP_FSC_AMILO_PI1505,
9774        ALC861_FIXUP_AMP_VREF_0F,
9775        ALC861_FIXUP_NO_JACK_DETECT,
9776        ALC861_FIXUP_ASUS_A6RP,
9777        ALC660_FIXUP_ASUS_W7J,
9778};
9779
9780/* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
9781static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
9782                        const struct hda_fixup *fix, int action)
9783{
9784        struct alc_spec *spec = codec->spec;
9785        unsigned int val;
9786
9787        if (action != HDA_FIXUP_ACT_INIT)
9788                return;
9789        val = snd_hda_codec_get_pin_target(codec, 0x0f);
9790        if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
9791                val |= AC_PINCTL_IN_EN;
9792        val |= AC_PINCTL_VREF_50;
9793        snd_hda_set_pin_ctl(codec, 0x0f, val);
9794        spec->gen.keep_vref_in_automute = 1;
9795}
9796
9797/* suppress the jack-detection */
9798static void alc_fixup_no_jack_detect(struct hda_codec *codec,
9799                                     const struct hda_fixup *fix, int action)
9800{
9801        if (action == HDA_FIXUP_ACT_PRE_PROBE)
9802                codec->no_jack_detect = 1;
9803}
9804
9805static const struct hda_fixup alc861_fixups[] = {
9806        [ALC861_FIXUP_FSC_AMILO_PI1505] = {
9807                .type = HDA_FIXUP_PINS,
9808                .v.pins = (const struct hda_pintbl[]) {
9809                        { 0x0b, 0x0221101f }, /* HP */
9810                        { 0x0f, 0x90170310 }, /* speaker */
9811                        { }
9812                }
9813        },
9814        [ALC861_FIXUP_AMP_VREF_0F] = {
9815                .type = HDA_FIXUP_FUNC,
9816                .v.func = alc861_fixup_asus_amp_vref_0f,
9817        },
9818        [ALC861_FIXUP_NO_JACK_DETECT] = {
9819                .type = HDA_FIXUP_FUNC,
9820                .v.func = alc_fixup_no_jack_detect,
9821        },
9822        [ALC861_FIXUP_ASUS_A6RP] = {
9823                .type = HDA_FIXUP_FUNC,
9824                .v.func = alc861_fixup_asus_amp_vref_0f,
9825                .chained = true,
9826                .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
9827        },
9828        [ALC660_FIXUP_ASUS_W7J] = {
9829                .type = HDA_FIXUP_VERBS,
9830                .v.verbs = (const struct hda_verb[]) {
9831                        /* ASUS W7J needs a magic pin setup on unused NID 0x10
9832                         * for enabling outputs
9833                         */
9834                        {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9835                        { }
9836                },
9837        }
9838};
9839
9840static const struct snd_pci_quirk alc861_fixup_tbl[] = {
9841        SND_PCI_QUIRK(0x1043, 0x1253, "ASUS W7J", ALC660_FIXUP_ASUS_W7J),
9842        SND_PCI_QUIRK(0x1043, 0x1263, "ASUS Z35HL", ALC660_FIXUP_ASUS_W7J),
9843        SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
9844        SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
9845        SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
9846        SND_PCI_QUIRK_VENDOR(0x1584, "Haier/Uniwill", ALC861_FIXUP_AMP_VREF_0F),
9847        SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
9848        {}
9849};
9850
9851/*
9852 */
9853static int patch_alc861(struct hda_codec *codec)
9854{
9855        struct alc_spec *spec;
9856        int err;
9857
9858        err = alc_alloc_spec(codec, 0x15);
9859        if (err < 0)
9860                return err;
9861
9862        spec = codec->spec;
9863        if (has_cdefine_beep(codec))
9864                spec->gen.beep_nid = 0x23;
9865
9866#ifdef CONFIG_PM
9867        spec->power_hook = alc_power_eapd;
9868#endif
9869
9870        alc_pre_init(codec);
9871
9872        snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
9873        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9874
9875        /* automatic parse from the BIOS config */
9876        err = alc861_parse_auto_config(codec);
9877        if (err < 0)
9878                goto error;
9879
9880        if (!spec->gen.no_analog) {
9881                err = set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
9882                if (err < 0)
9883                        goto error;
9884        }
9885
9886        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
9887
9888        return 0;
9889
9890 error:
9891        alc_free(codec);
9892        return err;
9893}
9894
9895/*
9896 * ALC861-VD support
9897 *
9898 * Based on ALC882
9899 *
9900 * In addition, an independent DAC
9901 */
9902static int alc861vd_parse_auto_config(struct hda_codec *codec)
9903{
9904        static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
9905        static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
9906        return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
9907}
9908
9909enum {
9910        ALC660VD_FIX_ASUS_GPIO1,
9911        ALC861VD_FIX_DALLAS,
9912};
9913
9914/* exclude VREF80 */
9915static void alc861vd_fixup_dallas(struct hda_codec *codec,
9916                                  const struct hda_fixup *fix, int action)
9917{
9918        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
9919                snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
9920                snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
9921        }
9922}
9923
9924/* reset GPIO1 */
9925static void alc660vd_fixup_asus_gpio1(struct hda_codec *codec,
9926                                      const struct hda_fixup *fix, int action)
9927{
9928        struct alc_spec *spec = codec->spec;
9929
9930        if (action == HDA_FIXUP_ACT_PRE_PROBE)
9931                spec->gpio_mask |= 0x02;
9932        alc_fixup_gpio(codec, action, 0x01);
9933}
9934
9935static const struct hda_fixup alc861vd_fixups[] = {
9936        [ALC660VD_FIX_ASUS_GPIO1] = {
9937                .type = HDA_FIXUP_FUNC,
9938                .v.func = alc660vd_fixup_asus_gpio1,
9939        },
9940        [ALC861VD_FIX_DALLAS] = {
9941                .type = HDA_FIXUP_FUNC,
9942                .v.func = alc861vd_fixup_dallas,
9943        },
9944};
9945
9946static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
9947        SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
9948        SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
9949        SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
9950        {}
9951};
9952
9953/*
9954 */
9955static int patch_alc861vd(struct hda_codec *codec)
9956{
9957        struct alc_spec *spec;
9958        int err;
9959
9960        err = alc_alloc_spec(codec, 0x0b);
9961        if (err < 0)
9962                return err;
9963
9964        spec = codec->spec;
9965        if (has_cdefine_beep(codec))
9966                spec->gen.beep_nid = 0x23;
9967
9968        spec->shutup = alc_eapd_shutup;
9969
9970        alc_pre_init(codec);
9971
9972        snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
9973        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
9974
9975        /* automatic parse from the BIOS config */
9976        err = alc861vd_parse_auto_config(codec);
9977        if (err < 0)
9978                goto error;
9979
9980        if (!spec->gen.no_analog) {
9981                err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9982                if (err < 0)
9983                        goto error;
9984        }
9985
9986        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
9987
9988        return 0;
9989
9990 error:
9991        alc_free(codec);
9992        return err;
9993}
9994
9995/*
9996 * ALC662 support
9997 *
9998 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
9999 * configuration.  Each pin widget can choose any input DACs and a mixer.
10000 * Each ADC is connected from a mixer of all inputs.  This makes possible
10001 * 6-channel independent captures.
10002 *
10003 * In addition, an independent DAC for the multi-playback (not used in this
10004 * driver yet).
10005 */
10006
10007/*
10008 * BIOS auto configuration
10009 */
10010
10011static int alc662_parse_auto_config(struct hda_codec *codec)
10012{
10013        static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
10014        static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
10015        static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
10016        const hda_nid_t *ssids;
10017
10018        if (codec->core.vendor_id == 0x10ec0272 || codec->core.vendor_id == 0x10ec0663 ||
10019            codec->core.vendor_id == 0x10ec0665 || codec->core.vendor_id == 0x10ec0670 ||
10020            codec->core.vendor_id == 0x10ec0671)
10021                ssids = alc663_ssids;
10022        else
10023                ssids = alc662_ssids;
10024        return alc_parse_auto_config(codec, alc662_ignore, ssids);
10025}
10026
10027static void alc272_fixup_mario(struct hda_codec *codec,
10028                               const struct hda_fixup *fix, int action)
10029{
10030        if (action != HDA_FIXUP_ACT_PRE_PROBE)
10031                return;
10032        if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
10033                                      (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
10034                                      (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
10035                                      (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10036                                      (0 << AC_AMPCAP_MUTE_SHIFT)))
10037                codec_warn(codec, "failed to override amp caps for NID 0x2\n");
10038}
10039
10040static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
10041        { .channels = 2,
10042          .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
10043        { .channels = 4,
10044          .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
10045                   SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
10046        { }
10047};
10048
10049/* override the 2.1 chmap */
10050static void alc_fixup_bass_chmap(struct hda_codec *codec,
10051                                    const struct hda_fixup *fix, int action)
10052{
10053        if (action == HDA_FIXUP_ACT_BUILD) {
10054                struct alc_spec *spec = codec->spec;
10055                spec->gen.pcm_rec[0]->stream[0].chmap = asus_pcm_2_1_chmaps;
10056        }
10057}
10058
10059/* avoid D3 for keeping GPIO up */
10060static unsigned int gpio_led_power_filter(struct hda_codec *codec,
10061                                          hda_nid_t nid,
10062                                          unsigned int power_state)
10063{
10064        struct alc_spec *spec = codec->spec;
10065        if (nid == codec->core.afg && power_state == AC_PWRST_D3 && spec->gpio_data)
10066                return AC_PWRST_D0;
10067        return power_state;
10068}
10069
10070static void alc662_fixup_led_gpio1(struct hda_codec *codec,
10071                                   const struct hda_fixup *fix, int action)
10072{
10073        struct alc_spec *spec = codec->spec;
10074
10075        alc_fixup_hp_gpio_led(codec, action, 0x01, 0);
10076        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10077                spec->mute_led_polarity = 1;
10078                codec->power_filter = gpio_led_power_filter;
10079        }
10080}
10081
10082static void alc662_usi_automute_hook(struct hda_codec *codec,
10083                                         struct hda_jack_callback *jack)
10084{
10085        struct alc_spec *spec = codec->spec;
10086        int vref;
10087        msleep(200);
10088        snd_hda_gen_hp_automute(codec, jack);
10089
10090        vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
10091        msleep(100);
10092        snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10093                            vref);
10094}
10095
10096static void alc662_fixup_usi_headset_mic(struct hda_codec *codec,
10097                                     const struct hda_fixup *fix, int action)
10098{
10099        struct alc_spec *spec = codec->spec;
10100        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
10101                spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
10102                spec->gen.hp_automute_hook = alc662_usi_automute_hook;
10103        }
10104}
10105
10106static void alc662_aspire_ethos_mute_speakers(struct hda_codec *codec,
10107                                        struct hda_jack_callback *cb)
10108{
10109        /* surround speakers at 0x1b already get muted automatically when
10110         * headphones are plugged in, but we have to mute/unmute the remaining
10111         * channels manually:
10112         * 0x15 - front left/front right
10113         * 0x18 - front center/ LFE
10114         */
10115        if (snd_hda_jack_detect_state(codec, 0x1b) == HDA_JACK_PRESENT) {
10116                snd_hda_set_pin_ctl_cache(codec, 0x15, 0);
10117                snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
10118        } else {
10119                snd_hda_set_pin_ctl_cache(codec, 0x15, PIN_OUT);
10120                snd_hda_set_pin_ctl_cache(codec, 0x18, PIN_OUT);
10121        }
10122}
10123
10124static void alc662_fixup_aspire_ethos_hp(struct hda_codec *codec,
10125                                        const struct hda_fixup *fix, int action)
10126{
10127    /* Pin 0x1b: shared headphones jack and surround speakers */
10128        if (!is_jack_detectable(codec, 0x1b))
10129                return;
10130
10131        switch (action) {
10132        case HDA_FIXUP_ACT_PRE_PROBE:
10133                snd_hda_jack_detect_enable_callback(codec, 0x1b,
10134                                alc662_aspire_ethos_mute_speakers);
10135                /* subwoofer needs an extra GPIO setting to become audible */
10136                alc_setup_gpio(codec, 0x02);
10137                break;
10138        case HDA_FIXUP_ACT_INIT:
10139                /* Make sure to start in a correct state, i.e. if
10140                 * headphones have been plugged in before powering up the system
10141                 */
10142                alc662_aspire_ethos_mute_speakers(codec, NULL);
10143                break;
10144        }
10145}
10146
10147static void alc671_fixup_hp_headset_mic2(struct hda_codec *codec,
10148                                             const struct hda_fixup *fix, int action)
10149{
10150        struct alc_spec *spec = codec->spec;
10151
10152        static const struct hda_pintbl pincfgs[] = {
10153                { 0x19, 0x02a11040 }, /* use as headset mic, with its own jack detect */
10154                { 0x1b, 0x0181304f },
10155                { }
10156        };
10157
10158        switch (action) {
10159        case HDA_FIXUP_ACT_PRE_PROBE:
10160                spec->gen.mixer_nid = 0;
10161                spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
10162                snd_hda_apply_pincfgs(codec, pincfgs);
10163                break;
10164        case HDA_FIXUP_ACT_INIT:
10165                alc_write_coef_idx(codec, 0x19, 0xa054);
10166                break;
10167        }
10168}
10169
10170static const struct coef_fw alc668_coefs[] = {
10171        WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03,    0x0),
10172        WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06,    0x0), WRITE_COEF(0x07, 0x0f80),
10173        WRITE_COEF(0x08, 0x0031), WRITE_COEF(0x0a, 0x0060), WRITE_COEF(0x0b,    0x0),
10174        WRITE_COEF(0x0c, 0x7cf7), WRITE_COEF(0x0d, 0x1080), WRITE_COEF(0x0e, 0x7f7f),
10175        WRITE_COEF(0x0f, 0xcccc), WRITE_COEF(0x10, 0xddcc), WRITE_COEF(0x11, 0x0001),
10176        WRITE_COEF(0x13,    0x0), WRITE_COEF(0x14, 0x2aa0), WRITE_COEF(0x17, 0xa940),
10177        WRITE_COEF(0x19,    0x0), WRITE_COEF(0x1a,    0x0), WRITE_COEF(0x1b,    0x0),
10178        WRITE_COEF(0x1c,    0x0), WRITE_COEF(0x1d,    0x0), WRITE_COEF(0x1e, 0x7418),
10179        WRITE_COEF(0x1f, 0x0804), WRITE_COEF(0x20, 0x4200), WRITE_COEF(0x21, 0x0468),
10180        WRITE_COEF(0x22, 0x8ccc), WRITE_COEF(0x23, 0x0250), WRITE_COEF(0x24, 0x7418),
10181        WRITE_COEF(0x27,    0x0), WRITE_COEF(0x28, 0x8ccc), WRITE_COEF(0x2a, 0xff00),
10182        WRITE_COEF(0x2b, 0x8000), WRITE_COEF(0xa7, 0xff00), WRITE_COEF(0xa8, 0x8000),
10183        WRITE_COEF(0xaa, 0x2e17), WRITE_COEF(0xab, 0xa0c0), WRITE_COEF(0xac,    0x0),
10184        WRITE_COEF(0xad,    0x0), WRITE_COEF(0xae, 0x2ac6), WRITE_COEF(0xaf, 0xa480),
10185        WRITE_COEF(0xb0,    0x0), WRITE_COEF(0xb1,    0x0), WRITE_COEF(0xb2,    0x0),
10186        WRITE_COEF(0xb3,    0x0), WRITE_COEF(0xb4,    0x0), WRITE_COEF(0xb5, 0x1040),
10187        WRITE_COEF(0xb6, 0xd697), WRITE_COEF(0xb7, 0x902b), WRITE_COEF(0xb8, 0xd697),
10188        WRITE_COEF(0xb9, 0x902b), WRITE_COEF(0xba, 0xb8ba), WRITE_COEF(0xbb, 0xaaab),
10189        WRITE_COEF(0xbc, 0xaaaf), WRITE_COEF(0xbd, 0x6aaa), WRITE_COEF(0xbe, 0x1c02),
10190        WRITE_COEF(0xc0, 0x00ff), WRITE_COEF(0xc1, 0x0fa6),
10191        {}
10192};
10193
10194static void alc668_restore_default_value(struct hda_codec *codec)
10195{
10196        alc_process_coef_fw(codec, alc668_coefs);
10197}
10198
10199enum {
10200        ALC662_FIXUP_ASPIRE,
10201        ALC662_FIXUP_LED_GPIO1,
10202        ALC662_FIXUP_IDEAPAD,
10203        ALC272_FIXUP_MARIO,
10204        ALC662_FIXUP_CZC_ET26,
10205        ALC662_FIXUP_CZC_P10T,
10206        ALC662_FIXUP_SKU_IGNORE,
10207        ALC662_FIXUP_HP_RP5800,
10208        ALC662_FIXUP_ASUS_MODE1,
10209        ALC662_FIXUP_ASUS_MODE2,
10210        ALC662_FIXUP_ASUS_MODE3,
10211        ALC662_FIXUP_ASUS_MODE4,
10212        ALC662_FIXUP_ASUS_MODE5,
10213        ALC662_FIXUP_ASUS_MODE6,
10214        ALC662_FIXUP_ASUS_MODE7,
10215        ALC662_FIXUP_ASUS_MODE8,
10216        ALC662_FIXUP_NO_JACK_DETECT,
10217        ALC662_FIXUP_ZOTAC_Z68,
10218        ALC662_FIXUP_INV_DMIC,
10219        ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
10220        ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
10221        ALC662_FIXUP_HEADSET_MODE,
10222        ALC668_FIXUP_HEADSET_MODE,
10223        ALC662_FIXUP_BASS_MODE4_CHMAP,
10224        ALC662_FIXUP_BASS_16,
10225        ALC662_FIXUP_BASS_1A,
10226        ALC662_FIXUP_BASS_CHMAP,
10227        ALC668_FIXUP_AUTO_MUTE,
10228        ALC668_FIXUP_DELL_DISABLE_AAMIX,
10229        ALC668_FIXUP_DELL_XPS13,
10230        ALC662_FIXUP_ASUS_Nx50,
10231        ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
10232        ALC668_FIXUP_ASUS_Nx51,
10233        ALC668_FIXUP_MIC_COEF,
10234        ALC668_FIXUP_ASUS_G751,
10235        ALC891_FIXUP_HEADSET_MODE,
10236        ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
10237        ALC662_FIXUP_ACER_VERITON,
10238        ALC892_FIXUP_ASROCK_MOBO,
10239        ALC662_FIXUP_USI_FUNC,
10240        ALC662_FIXUP_USI_HEADSET_MODE,
10241        ALC662_FIXUP_LENOVO_MULTI_CODECS,
10242        ALC669_FIXUP_ACER_ASPIRE_ETHOS,
10243        ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET,
10244        ALC671_FIXUP_HP_HEADSET_MIC2,
10245        ALC662_FIXUP_ACER_X2660G_HEADSET_MODE,
10246        ALC662_FIXUP_ACER_NITRO_HEADSET_MODE,
10247        ALC668_FIXUP_ASUS_NO_HEADSET_MIC,
10248        ALC668_FIXUP_HEADSET_MIC,
10249        ALC668_FIXUP_MIC_DET_COEF,
10250};
10251
10252static const struct hda_fixup alc662_fixups[] = {
10253        [ALC662_FIXUP_ASPIRE] = {
10254                .type = HDA_FIXUP_PINS,
10255                .v.pins = (const struct hda_pintbl[]) {
10256                        { 0x15, 0x99130112 }, /* subwoofer */
10257                        { }
10258                }
10259        },
10260        [ALC662_FIXUP_LED_GPIO1] = {
10261                .type = HDA_FIXUP_FUNC,
10262                .v.func = alc662_fixup_led_gpio1,
10263        },
10264        [ALC662_FIXUP_IDEAPAD] = {
10265                .type = HDA_FIXUP_PINS,
10266                .v.pins = (const struct hda_pintbl[]) {
10267                        { 0x17, 0x99130112 }, /* subwoofer */
10268                        { }
10269                },
10270                .chained = true,
10271                .chain_id = ALC662_FIXUP_LED_GPIO1,
10272        },
10273        [ALC272_FIXUP_MARIO] = {
10274                .type = HDA_FIXUP_FUNC,
10275                .v.func = alc272_fixup_mario,
10276        },
10277        [ALC662_FIXUP_CZC_ET26] = {
10278                .type = HDA_FIXUP_PINS,
10279                .v.pins = (const struct hda_pintbl[]) {
10280                        {0x12, 0x403cc000},
10281                        {0x14, 0x90170110}, /* speaker */
10282                        {0x15, 0x411111f0},
10283                        {0x16, 0x411111f0},
10284                        {0x18, 0x01a19030}, /* mic */
10285                        {0x19, 0x90a7013f}, /* int-mic */
10286                        {0x1a, 0x01014020},
10287                        {0x1b, 0x0121401f},
10288                        {0x1c, 0x411111f0},
10289                        {0x1d, 0x411111f0},
10290                        {0x1e, 0x40478e35},
10291                        {}
10292                },
10293                .chained = true,
10294                .chain_id = ALC662_FIXUP_SKU_IGNORE
10295        },
10296        [ALC662_FIXUP_CZC_P10T] = {
10297                .type = HDA_FIXUP_VERBS,
10298                .v.verbs = (const struct hda_verb[]) {
10299                        {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
10300                        {}
10301                }
10302        },
10303        [ALC662_FIXUP_SKU_IGNORE] = {
10304                .type = HDA_FIXUP_FUNC,
10305                .v.func = alc_fixup_sku_ignore,
10306        },
10307        [ALC662_FIXUP_HP_RP5800] = {
10308                .type = HDA_FIXUP_PINS,
10309                .v.pins = (const struct hda_pintbl[]) {
10310                        { 0x14, 0x0221201f }, /* HP out */
10311                        { }
10312                },
10313                .chained = true,
10314                .chain_id = ALC662_FIXUP_SKU_IGNORE
10315        },
10316        [ALC662_FIXUP_ASUS_MODE1] = {
10317                .type = HDA_FIXUP_PINS,
10318                .v.pins = (const struct hda_pintbl[]) {
10319                        { 0x14, 0x99130110 }, /* speaker */
10320                        { 0x18, 0x01a19c20 }, /* mic */
10321                        { 0x19, 0x99a3092f }, /* int-mic */
10322                        { 0x21, 0x0121401f }, /* HP out */
10323                        { }
10324                },
10325                .chained = true,
10326                .chain_id = ALC662_FIXUP_SKU_IGNORE
10327        },
10328        [ALC662_FIXUP_ASUS_MODE2] = {
10329                .type = HDA_FIXUP_PINS,
10330                .v.pins = (const struct hda_pintbl[]) {
10331                        { 0x14, 0x99130110 }, /* speaker */
10332                        { 0x18, 0x01a19820 }, /* mic */
10333                        { 0x19, 0x99a3092f }, /* int-mic */
10334                        { 0x1b, 0x0121401f }, /* HP out */
10335                        { }
10336                },
10337                .chained = true,
10338                .chain_id = ALC662_FIXUP_SKU_IGNORE
10339        },
10340        [ALC662_FIXUP_ASUS_MODE3] = {
10341                .type = HDA_FIXUP_PINS,
10342                .v.pins = (const struct hda_pintbl[]) {
10343                        { 0x14, 0x99130110 }, /* speaker */
10344                        { 0x15, 0x0121441f }, /* HP */
10345                        { 0x18, 0x01a19840 }, /* mic */
10346                        { 0x19, 0x99a3094f }, /* int-mic */
10347                        { 0x21, 0x01211420 }, /* HP2 */
10348                        { }
10349                },
10350                .chained = true,
10351                .chain_id = ALC662_FIXUP_SKU_IGNORE
10352        },
10353        [ALC662_FIXUP_ASUS_MODE4] = {
10354                .type = HDA_FIXUP_PINS,
10355                .v.pins = (const struct hda_pintbl[]) {
10356                        { 0x14, 0x99130110 }, /* speaker */
10357                        { 0x16, 0x99130111 }, /* speaker */
10358                        { 0x18, 0x01a19840 }, /* mic */
10359                        { 0x19, 0x99a3094f }, /* int-mic */
10360                        { 0x21, 0x0121441f }, /* HP */
10361                        { }
10362                },
10363                .chained = true,
10364                .chain_id = ALC662_FIXUP_SKU_IGNORE
10365        },
10366        [ALC662_FIXUP_ASUS_MODE5] = {
10367                .type = HDA_FIXUP_PINS,
10368                .v.pins = (const struct hda_pintbl[]) {
10369                        { 0x14, 0x99130110 }, /* speaker */
10370                        { 0x15, 0x0121441f }, /* HP */
10371                        { 0x16, 0x99130111 }, /* speaker */
10372                        { 0x18, 0x01a19840 }, /* mic */
10373                        { 0x19, 0x99a3094f }, /* int-mic */
10374                        { }
10375                },
10376                .chained = true,
10377                .chain_id = ALC662_FIXUP_SKU_IGNORE
10378        },
10379        [ALC662_FIXUP_ASUS_MODE6] = {
10380                .type = HDA_FIXUP_PINS,
10381                .v.pins = (const struct hda_pintbl[]) {
10382                        { 0x14, 0x99130110 }, /* speaker */
10383                        { 0x15, 0x01211420 }, /* HP2 */
10384                        { 0x18, 0x01a19840 }, /* mic */
10385                        { 0x19, 0x99a3094f }, /* int-mic */
10386                        { 0x1b, 0x0121441f }, /* HP */
10387                        { }
10388                },
10389                .chained = true,
10390                .chain_id = ALC662_FIXUP_SKU_IGNORE
10391        },
10392        [ALC662_FIXUP_ASUS_MODE7] = {
10393                .type = HDA_FIXUP_PINS,
10394                .v.pins = (const struct hda_pintbl[]) {
10395                        { 0x14, 0x99130110 }, /* speaker */
10396                        { 0x17, 0x99130111 }, /* speaker */
10397                        { 0x18, 0x01a19840 }, /* mic */
10398                        { 0x19, 0x99a3094f }, /* int-mic */
10399                        { 0x1b, 0x01214020 }, /* HP */
10400                        { 0x21, 0x0121401f }, /* HP */
10401                        { }
10402                },
10403                .chained = true,
10404                .chain_id = ALC662_FIXUP_SKU_IGNORE
10405        },
10406        [ALC662_FIXUP_ASUS_MODE8] = {
10407                .type = HDA_FIXUP_PINS,
10408                .v.pins = (const struct hda_pintbl[]) {
10409                        { 0x14, 0x99130110 }, /* speaker */
10410                        { 0x12, 0x99a30970 }, /* int-mic */
10411                        { 0x15, 0x01214020 }, /* HP */
10412                        { 0x17, 0x99130111 }, /* speaker */
10413                        { 0x18, 0x01a19840 }, /* mic */
10414                        { 0x21, 0x0121401f }, /* HP */
10415                        { }
10416                },
10417                .chained = true,
10418                .chain_id = ALC662_FIXUP_SKU_IGNORE
10419        },
10420        [ALC662_FIXUP_NO_JACK_DETECT] = {
10421                .type = HDA_FIXUP_FUNC,
10422                .v.func = alc_fixup_no_jack_detect,
10423        },
10424        [ALC662_FIXUP_ZOTAC_Z68] = {
10425                .type = HDA_FIXUP_PINS,
10426                .v.pins = (const struct hda_pintbl[]) {
10427                        { 0x1b, 0x02214020 }, /* Front HP */
10428                        { }
10429                }
10430        },
10431        [ALC662_FIXUP_INV_DMIC] = {
10432                .type = HDA_FIXUP_FUNC,
10433                .v.func = alc_fixup_inv_dmic,
10434        },
10435        [ALC668_FIXUP_DELL_XPS13] = {
10436                .type = HDA_FIXUP_FUNC,
10437                .v.func = alc_fixup_dell_xps13,
10438                .chained = true,
10439                .chain_id = ALC668_FIXUP_DELL_DISABLE_AAMIX
10440        },
10441        [ALC668_FIXUP_DELL_DISABLE_AAMIX] = {
10442                .type = HDA_FIXUP_FUNC,
10443                .v.func = alc_fixup_disable_aamix,
10444                .chained = true,
10445                .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
10446        },
10447        [ALC668_FIXUP_AUTO_MUTE] = {
10448                .type = HDA_FIXUP_FUNC,
10449                .v.func = alc_fixup_auto_mute_via_amp,
10450                .chained = true,
10451                .chain_id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE
10452        },
10453        [ALC662_FIXUP_DELL_MIC_NO_PRESENCE] = {
10454                .type = HDA_FIXUP_PINS,
10455                .v.pins = (const struct hda_pintbl[]) {
10456                        { 0x19, 0x03a1113c }, /* use as headset mic, without its own jack detect */
10457                        /* headphone mic by setting pin control of 0x1b (headphone out) to in + vref_50 */
10458                        { }
10459                },
10460                .chained = true,
10461                .chain_id = ALC662_FIXUP_HEADSET_MODE
10462        },
10463        [ALC662_FIXUP_HEADSET_MODE] = {
10464                .type = HDA_FIXUP_FUNC,
10465                .v.func = alc_fixup_headset_mode_alc662,
10466        },
10467        [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
10468                .type = HDA_FIXUP_PINS,
10469                .v.pins = (const struct hda_pintbl[]) {
10470                        { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
10471                        { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
10472                        { }
10473                },
10474                .chained = true,
10475                .chain_id = ALC668_FIXUP_HEADSET_MODE
10476        },
10477        [ALC668_FIXUP_HEADSET_MODE] = {
10478                .type = HDA_FIXUP_FUNC,
10479                .v.func = alc_fixup_headset_mode_alc668,
10480        },
10481        [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
10482                .type = HDA_FIXUP_FUNC,
10483                .v.func = alc_fixup_bass_chmap,
10484                .chained = true,
10485                .chain_id = ALC662_FIXUP_ASUS_MODE4
10486        },
10487        [ALC662_FIXUP_BASS_16] = {
10488                .type = HDA_FIXUP_PINS,
10489                .v.pins = (const struct hda_pintbl[]) {
10490                        {0x16, 0x80106111}, /* bass speaker */
10491                        {}
10492                },
10493                .chained = true,
10494                .chain_id = ALC662_FIXUP_BASS_CHMAP,
10495        },
10496        [ALC662_FIXUP_BASS_1A] = {
10497                .type = HDA_FIXUP_PINS,
10498                .v.pins = (const struct hda_pintbl[]) {
10499                        {0x1a, 0x80106111}, /* bass speaker */
10500                        {}
10501                },
10502                .chained = true,
10503                .chain_id = ALC662_FIXUP_BASS_CHMAP,
10504        },
10505        [ALC662_FIXUP_BASS_CHMAP] = {
10506                .type = HDA_FIXUP_FUNC,
10507                .v.func = alc_fixup_bass_chmap,
10508        },
10509        [ALC662_FIXUP_ASUS_Nx50] = {
10510                .type = HDA_FIXUP_FUNC,
10511                .v.func = alc_fixup_auto_mute_via_amp,
10512                .chained = true,
10513                .chain_id = ALC662_FIXUP_BASS_1A
10514        },
10515        [ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE] = {
10516                .type = HDA_FIXUP_FUNC,
10517                .v.func = alc_fixup_headset_mode_alc668,
10518                .chain_id = ALC662_FIXUP_BASS_CHMAP
10519        },
10520        [ALC668_FIXUP_ASUS_Nx51] = {
10521                .type = HDA_FIXUP_PINS,
10522                .v.pins = (const struct hda_pintbl[]) {
10523                        { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
10524                        { 0x1a, 0x90170151 }, /* bass speaker */
10525                        { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
10526                        {}
10527                },
10528                .chained = true,
10529                .chain_id = ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
10530        },
10531        [ALC668_FIXUP_MIC_COEF] = {
10532                .type = HDA_FIXUP_VERBS,
10533                .v.verbs = (const struct hda_verb[]) {
10534                        { 0x20, AC_VERB_SET_COEF_INDEX, 0xc3 },
10535                        { 0x20, AC_VERB_SET_PROC_COEF, 0x4000 },
10536                        {}
10537                },
10538        },
10539        [ALC668_FIXUP_ASUS_G751] = {
10540                .type = HDA_FIXUP_PINS,
10541                .v.pins = (const struct hda_pintbl[]) {
10542                        { 0x16, 0x0421101f }, /* HP */
10543                        {}
10544                },
10545                .chained = true,
10546                .chain_id = ALC668_FIXUP_MIC_COEF
10547        },
10548        [ALC891_FIXUP_HEADSET_MODE] = {
10549                .type = HDA_FIXUP_FUNC,
10550                .v.func = alc_fixup_headset_mode,
10551        },
10552        [ALC891_FIXUP_DELL_MIC_NO_PRESENCE] = {
10553                .type = HDA_FIXUP_PINS,
10554                .v.pins = (const struct hda_pintbl[]) {
10555                        { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
10556                        { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
10557                        { }
10558                },
10559                .chained = true,
10560                .chain_id = ALC891_FIXUP_HEADSET_MODE
10561        },
10562        [ALC662_FIXUP_ACER_VERITON] = {
10563                .type = HDA_FIXUP_PINS,
10564                .v.pins = (const struct hda_pintbl[]) {
10565                        { 0x15, 0x50170120 }, /* no internal speaker */
10566                        { }
10567                }
10568        },
10569        [ALC892_FIXUP_ASROCK_MOBO] = {
10570                .type = HDA_FIXUP_PINS,
10571                .v.pins = (const struct hda_pintbl[]) {
10572                        { 0x15, 0x40f000f0 }, /* disabled */
10573                        { 0x16, 0x40f000f0 }, /* disabled */
10574                        { }
10575                }
10576        },
10577        [ALC662_FIXUP_USI_FUNC] = {
10578                .type = HDA_FIXUP_FUNC,
10579                .v.func = alc662_fixup_usi_headset_mic,
10580        },
10581        [ALC662_FIXUP_USI_HEADSET_MODE] = {
10582                .type = HDA_FIXUP_PINS,
10583                .v.pins = (const struct hda_pintbl[]) {
10584                        { 0x19, 0x02a1913c }, /* use as headset mic, without its own jack detect */
10585                        { 0x18, 0x01a1903d },
10586                        { }
10587                },
10588                .chained = true,
10589                .chain_id = ALC662_FIXUP_USI_FUNC
10590        },
10591        [ALC662_FIXUP_LENOVO_MULTI_CODECS] = {
10592                .type = HDA_FIXUP_FUNC,
10593                .v.func = alc233_alc662_fixup_lenovo_dual_codecs,
10594        },
10595        [ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET] = {
10596                .type = HDA_FIXUP_FUNC,
10597                .v.func = alc662_fixup_aspire_ethos_hp,
10598        },
10599        [ALC669_FIXUP_ACER_ASPIRE_ETHOS] = {
10600                .type = HDA_FIXUP_PINS,
10601                .v.pins = (const struct hda_pintbl[]) {
10602                        { 0x15, 0x92130110 }, /* front speakers */
10603                        { 0x18, 0x99130111 }, /* center/subwoofer */
10604                        { 0x1b, 0x11130012 }, /* surround plus jack for HP */
10605                        { }
10606                },
10607                .chained = true,
10608                .chain_id = ALC669_FIXUP_ACER_ASPIRE_ETHOS_HEADSET
10609        },
10610        [ALC671_FIXUP_HP_HEADSET_MIC2] = {
10611                .type = HDA_FIXUP_FUNC,
10612                .v.func = alc671_fixup_hp_headset_mic2,
10613        },
10614        [ALC662_FIXUP_ACER_X2660G_HEADSET_MODE] = {
10615                .type = HDA_FIXUP_PINS,
10616                .v.pins = (const struct hda_pintbl[]) {
10617                        { 0x1a, 0x02a1113c }, /* use as headset mic, without its own jack detect */
10618                        { }
10619                },
10620                .chained = true,
10621                .chain_id = ALC662_FIXUP_USI_FUNC
10622        },
10623        [ALC662_FIXUP_ACER_NITRO_HEADSET_MODE] = {
10624                .type = HDA_FIXUP_PINS,
10625                .v.pins = (const struct hda_pintbl[]) {
10626                        { 0x1a, 0x01a11140 }, /* use as headset mic, without its own jack detect */
10627                        { 0x1b, 0x0221144f },
10628                        { }
10629                },
10630                .chained = true,
10631                .chain_id = ALC662_FIXUP_USI_FUNC
10632        },
10633        [ALC668_FIXUP_ASUS_NO_HEADSET_MIC] = {
10634                .type = HDA_FIXUP_PINS,
10635                .v.pins = (const struct hda_pintbl[]) {
10636                        { 0x1b, 0x04a1112c },
10637                        { }
10638                },
10639                .chained = true,
10640                .chain_id = ALC668_FIXUP_HEADSET_MIC
10641        },
10642        [ALC668_FIXUP_HEADSET_MIC] = {
10643                .type = HDA_FIXUP_FUNC,
10644                .v.func = alc269_fixup_headset_mic,
10645                .chained = true,
10646                .chain_id = ALC668_FIXUP_MIC_DET_COEF
10647        },
10648        [ALC668_FIXUP_MIC_DET_COEF] = {
10649                .type = HDA_FIXUP_VERBS,
10650                .v.verbs = (const struct hda_verb[]) {
10651                        { 0x20, AC_VERB_SET_COEF_INDEX, 0x15 },
10652                        { 0x20, AC_VERB_SET_PROC_COEF, 0x0d60 },
10653                        {}
10654                },
10655        },
10656};
10657
10658static const struct snd_pci_quirk alc662_fixup_tbl[] = {
10659        SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
10660        SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
10661        SND_PCI_QUIRK(0x1025, 0x0241, "Packard Bell DOTS", ALC662_FIXUP_INV_DMIC),
10662        SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
10663        SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
10664        SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
10665        SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
10666        SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
10667        SND_PCI_QUIRK(0x1025, 0x0566, "Acer Aspire Ethos 8951G", ALC669_FIXUP_ACER_ASPIRE_ETHOS),
10668        SND_PCI_QUIRK(0x1025, 0x123c, "Acer Nitro N50-600", ALC662_FIXUP_ACER_NITRO_HEADSET_MODE),
10669        SND_PCI_QUIRK(0x1025, 0x124e, "Acer 2660G", ALC662_FIXUP_ACER_X2660G_HEADSET_MODE),
10670        SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10671        SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10672        SND_PCI_QUIRK(0x1028, 0x05fe, "Dell XPS 15", ALC668_FIXUP_DELL_XPS13),
10673        SND_PCI_QUIRK(0x1028, 0x060a, "Dell XPS 13", ALC668_FIXUP_DELL_XPS13),
10674        SND_PCI_QUIRK(0x1028, 0x060d, "Dell M3800", ALC668_FIXUP_DELL_XPS13),
10675        SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10676        SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10677        SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10678        SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10679        SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
10680        SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
10681        SND_PCI_QUIRK(0x103c, 0x873e, "HP", ALC671_FIXUP_HP_HEADSET_MIC2),
10682        SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE),
10683        SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
10684        SND_PCI_QUIRK(0x1043, 0x129d, "Asus N750", ALC662_FIXUP_ASUS_Nx50),
10685        SND_PCI_QUIRK(0x1043, 0x12ff, "ASUS G751", ALC668_FIXUP_ASUS_G751),
10686        SND_PCI_QUIRK(0x1043, 0x13df, "Asus N550JX", ALC662_FIXUP_BASS_1A),
10687        SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
10688        SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
10689        SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
10690        SND_PCI_QUIRK(0x1043, 0x17bd, "ASUS N751", ALC668_FIXUP_ASUS_Nx51),
10691        SND_PCI_QUIRK(0x1043, 0x185d, "ASUS G551JW", ALC668_FIXUP_ASUS_NO_HEADSET_MIC),
10692        SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71SL", ALC662_FIXUP_ASUS_MODE8),
10693        SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
10694        SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
10695        SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
10696        SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
10697        SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
10698        SND_PCI_QUIRK(0x14cd, 0x5003, "USI", ALC662_FIXUP_USI_HEADSET_MODE),
10699        SND_PCI_QUIRK(0x17aa, 0x1036, "Lenovo P520", ALC662_FIXUP_LENOVO_MULTI_CODECS),
10700        SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
10701        SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
10702        SND_PCI_QUIRK(0x1849, 0x5892, "ASRock B150M", ALC892_FIXUP_ASROCK_MOBO),
10703        SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
10704        SND_PCI_QUIRK(0x1b0a, 0x01b8, "ACER Veriton", ALC662_FIXUP_ACER_VERITON),
10705        SND_PCI_QUIRK(0x1b35, 0x1234, "CZC ET26", ALC662_FIXUP_CZC_ET26),
10706        SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
10707
10708#if 0
10709        /* Below is a quirk table taken from the old code.
10710         * Basically the device should work as is without the fixup table.
10711         * If BIOS doesn't give a proper info, enable the corresponding
10712         * fixup entry.
10713         */
10714        SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
10715        SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
10716        SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
10717        SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
10718        SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
10719        SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10720        SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
10721        SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
10722        SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
10723        SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10724        SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
10725        SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
10726        SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
10727        SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
10728        SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
10729        SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10730        SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
10731        SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
10732        SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10733        SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
10734        SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
10735        SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10736        SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
10737        SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
10738        SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
10739        SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10740        SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
10741        SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
10742        SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10743        SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
10744        SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10745        SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10746        SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
10747        SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
10748        SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
10749        SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
10750        SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
10751        SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
10752        SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
10753        SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
10754        SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
10755        SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
10756        SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
10757        SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
10758        SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
10759        SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
10760        SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
10761        SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
10762        SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
10763        SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
10764#endif
10765        {}
10766};
10767
10768static const struct hda_model_fixup alc662_fixup_models[] = {
10769        {.id = ALC662_FIXUP_ASPIRE, .name = "aspire"},
10770        {.id = ALC662_FIXUP_IDEAPAD, .name = "ideapad"},
10771        {.id = ALC272_FIXUP_MARIO, .name = "mario"},
10772        {.id = ALC662_FIXUP_HP_RP5800, .name = "hp-rp5800"},
10773        {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
10774        {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
10775        {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
10776        {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
10777        {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
10778        {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
10779        {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
10780        {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
10781        {.id = ALC662_FIXUP_ZOTAC_Z68, .name = "zotac-z68"},
10782        {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
10783        {.id = ALC662_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc662-headset-multi"},
10784        {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
10785        {.id = ALC662_FIXUP_HEADSET_MODE, .name = "alc662-headset"},
10786        {.id = ALC668_FIXUP_HEADSET_MODE, .name = "alc668-headset"},
10787        {.id = ALC662_FIXUP_BASS_16, .name = "bass16"},
10788        {.id = ALC662_FIXUP_BASS_1A, .name = "bass1a"},
10789        {.id = ALC668_FIXUP_AUTO_MUTE, .name = "automute"},
10790        {.id = ALC668_FIXUP_DELL_XPS13, .name = "dell-xps13"},
10791        {.id = ALC662_FIXUP_ASUS_Nx50, .name = "asus-nx50"},
10792        {.id = ALC668_FIXUP_ASUS_Nx51, .name = "asus-nx51"},
10793        {.id = ALC668_FIXUP_ASUS_G751, .name = "asus-g751"},
10794        {.id = ALC891_FIXUP_HEADSET_MODE, .name = "alc891-headset"},
10795        {.id = ALC891_FIXUP_DELL_MIC_NO_PRESENCE, .name = "alc891-headset-multi"},
10796        {.id = ALC662_FIXUP_ACER_VERITON, .name = "acer-veriton"},
10797        {.id = ALC892_FIXUP_ASROCK_MOBO, .name = "asrock-mobo"},
10798        {.id = ALC662_FIXUP_USI_HEADSET_MODE, .name = "usi-headset"},
10799        {.id = ALC662_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
10800        {.id = ALC669_FIXUP_ACER_ASPIRE_ETHOS, .name = "aspire-ethos"},
10801        {}
10802};
10803
10804static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
10805        SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
10806                {0x17, 0x02211010},
10807                {0x18, 0x01a19030},
10808                {0x1a, 0x01813040},
10809                {0x21, 0x01014020}),
10810        SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
10811                {0x16, 0x01813030},
10812                {0x17, 0x02211010},
10813                {0x18, 0x01a19040},
10814                {0x21, 0x01014020}),
10815        SND_HDA_PIN_QUIRK(0x10ec0662, 0x1028, "Dell", ALC662_FIXUP_DELL_MIC_NO_PRESENCE,
10816                {0x14, 0x01014010},
10817                {0x18, 0x01a19020},
10818                {0x1a, 0x0181302f},
10819                {0x1b, 0x0221401f}),
10820        SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
10821                {0x12, 0x99a30130},
10822                {0x14, 0x90170110},
10823                {0x15, 0x0321101f},
10824                {0x16, 0x03011020}),
10825        SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
10826                {0x12, 0x99a30140},
10827                {0x14, 0x90170110},
10828                {0x15, 0x0321101f},
10829                {0x16, 0x03011020}),
10830        SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
10831                {0x12, 0x99a30150},
10832                {0x14, 0x90170110},
10833                {0x15, 0x0321101f},
10834                {0x16, 0x03011020}),
10835        SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell", ALC668_FIXUP_AUTO_MUTE,
10836                {0x14, 0x90170110},
10837                {0x15, 0x0321101f},
10838                {0x16, 0x03011020}),
10839        SND_HDA_PIN_QUIRK(0x10ec0668, 0x1028, "Dell XPS 15", ALC668_FIXUP_AUTO_MUTE,
10840                {0x12, 0x90a60130},
10841                {0x14, 0x90170110},
10842                {0x15, 0x0321101f}),
10843        SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
10844                {0x14, 0x01014010},
10845                {0x17, 0x90170150},
10846                {0x19, 0x02a11060},
10847                {0x1b, 0x01813030},
10848                {0x21, 0x02211020}),
10849        SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
10850                {0x14, 0x01014010},
10851                {0x18, 0x01a19040},
10852                {0x1b, 0x01813030},
10853                {0x21, 0x02211020}),
10854        SND_HDA_PIN_QUIRK(0x10ec0671, 0x103c, "HP cPC", ALC671_FIXUP_HP_HEADSET_MIC2,
10855                {0x14, 0x01014020},
10856                {0x17, 0x90170110},
10857                {0x18, 0x01a19050},
10858                {0x1b, 0x01813040},
10859                {0x21, 0x02211030}),
10860        {}
10861};
10862
10863/*
10864 */
10865static int patch_alc662(struct hda_codec *codec)
10866{
10867        struct alc_spec *spec;
10868        int err;
10869
10870        err = alc_alloc_spec(codec, 0x0b);
10871        if (err < 0)
10872                return err;
10873
10874        spec = codec->spec;
10875
10876        spec->shutup = alc_eapd_shutup;
10877
10878        /* handle multiple HPs as is */
10879        spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
10880
10881        alc_fix_pll_init(codec, 0x20, 0x04, 15);
10882
10883        switch (codec->core.vendor_id) {
10884        case 0x10ec0668:
10885                spec->init_hook = alc668_restore_default_value;
10886                break;
10887        }
10888
10889        alc_pre_init(codec);
10890
10891        snd_hda_pick_fixup(codec, alc662_fixup_models,
10892                       alc662_fixup_tbl, alc662_fixups);
10893        snd_hda_pick_pin_fixup(codec, alc662_pin_fixup_tbl, alc662_fixups, true);
10894        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
10895
10896        alc_auto_parse_customize_define(codec);
10897
10898        if (has_cdefine_beep(codec))
10899                spec->gen.beep_nid = 0x01;
10900
10901        if ((alc_get_coef0(codec) & (1 << 14)) &&
10902            codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
10903            spec->cdefine.platform_type == 1) {
10904                err = alc_codec_rename(codec, "ALC272X");
10905                if (err < 0)
10906                        goto error;
10907        }
10908
10909        /* automatic parse from the BIOS config */
10910        err = alc662_parse_auto_config(codec);
10911        if (err < 0)
10912                goto error;
10913
10914        if (!spec->gen.no_analog && spec->gen.beep_nid) {
10915                switch (codec->core.vendor_id) {
10916                case 0x10ec0662:
10917                        err = set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
10918                        break;
10919                case 0x10ec0272:
10920                case 0x10ec0663:
10921                case 0x10ec0665:
10922                case 0x10ec0668:
10923                        err = set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
10924                        break;
10925                case 0x10ec0273:
10926                        err = set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
10927                        break;
10928                }
10929                if (err < 0)
10930                        goto error;
10931        }
10932
10933        snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
10934
10935        return 0;
10936
10937 error:
10938        alc_free(codec);
10939        return err;
10940}
10941
10942/*
10943 * ALC680 support
10944 */
10945
10946static int alc680_parse_auto_config(struct hda_codec *codec)
10947{
10948        return alc_parse_auto_config(codec, NULL, NULL);
10949}
10950
10951/*
10952 */
10953static int patch_alc680(struct hda_codec *codec)
10954{
10955        int err;
10956
10957        /* ALC680 has no aa-loopback mixer */
10958        err = alc_alloc_spec(codec, 0);
10959        if (err < 0)
10960                return err;
10961
10962        /* automatic parse from the BIOS config */
10963        err = alc680_parse_auto_config(codec);
10964        if (err < 0) {
10965                alc_free(codec);
10966                return err;
10967        }
10968
10969        return 0;
10970}
10971
10972/*
10973 * patch entries
10974 */
10975static const struct hda_device_id snd_hda_id_realtek[] = {
10976        HDA_CODEC_ENTRY(0x10ec0215, "ALC215", patch_alc269),
10977        HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
10978        HDA_CODEC_ENTRY(0x10ec0222, "ALC222", patch_alc269),
10979        HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
10980        HDA_CODEC_ENTRY(0x10ec0230, "ALC236", patch_alc269),
10981        HDA_CODEC_ENTRY(0x10ec0231, "ALC231", patch_alc269),
10982        HDA_CODEC_ENTRY(0x10ec0233, "ALC233", patch_alc269),
10983        HDA_CODEC_ENTRY(0x10ec0234, "ALC234", patch_alc269),
10984        HDA_CODEC_ENTRY(0x10ec0235, "ALC233", patch_alc269),
10985        HDA_CODEC_ENTRY(0x10ec0236, "ALC236", patch_alc269),
10986        HDA_CODEC_ENTRY(0x10ec0245, "ALC245", patch_alc269),
10987        HDA_CODEC_ENTRY(0x10ec0255, "ALC255", patch_alc269),
10988        HDA_CODEC_ENTRY(0x10ec0256, "ALC256", patch_alc269),
10989        HDA_CODEC_ENTRY(0x10ec0257, "ALC257", patch_alc269),
10990        HDA_CODEC_ENTRY(0x10ec0260, "ALC260", patch_alc260),
10991        HDA_CODEC_ENTRY(0x10ec0262, "ALC262", patch_alc262),
10992        HDA_CODEC_ENTRY(0x10ec0267, "ALC267", patch_alc268),
10993        HDA_CODEC_ENTRY(0x10ec0268, "ALC268", patch_alc268),
10994        HDA_CODEC_ENTRY(0x10ec0269, "ALC269", patch_alc269),
10995        HDA_CODEC_ENTRY(0x10ec0270, "ALC270", patch_alc269),
10996        HDA_CODEC_ENTRY(0x10ec0272, "ALC272", patch_alc662),
10997        HDA_CODEC_ENTRY(0x10ec0274, "ALC274", patch_alc269),
10998        HDA_CODEC_ENTRY(0x10ec0275, "ALC275", patch_alc269),
10999        HDA_CODEC_ENTRY(0x10ec0276, "ALC276", patch_alc269),
11000        HDA_CODEC_ENTRY(0x10ec0280, "ALC280", patch_alc269),
11001        HDA_CODEC_ENTRY(0x10ec0282, "ALC282", patch_alc269),
11002        HDA_CODEC_ENTRY(0x10ec0283, "ALC283", patch_alc269),
11003        HDA_CODEC_ENTRY(0x10ec0284, "ALC284", patch_alc269),
11004        HDA_CODEC_ENTRY(0x10ec0285, "ALC285", patch_alc269),
11005        HDA_CODEC_ENTRY(0x10ec0286, "ALC286", patch_alc269),
11006        HDA_CODEC_ENTRY(0x10ec0287, "ALC287", patch_alc269),
11007        HDA_CODEC_ENTRY(0x10ec0288, "ALC288", patch_alc269),
11008        HDA_CODEC_ENTRY(0x10ec0289, "ALC289", patch_alc269),
11009        HDA_CODEC_ENTRY(0x10ec0290, "ALC290", patch_alc269),
11010        HDA_CODEC_ENTRY(0x10ec0292, "ALC292", patch_alc269),
11011        HDA_CODEC_ENTRY(0x10ec0293, "ALC293", patch_alc269),
11012        HDA_CODEC_ENTRY(0x10ec0294, "ALC294", patch_alc269),
11013        HDA_CODEC_ENTRY(0x10ec0295, "ALC295", patch_alc269),
11014        HDA_CODEC_ENTRY(0x10ec0298, "ALC298", patch_alc269),
11015        HDA_CODEC_ENTRY(0x10ec0299, "ALC299", patch_alc269),
11016        HDA_CODEC_ENTRY(0x10ec0300, "ALC300", patch_alc269),
11017        HDA_CODEC_ENTRY(0x10ec0623, "ALC623", patch_alc269),
11018        HDA_CODEC_REV_ENTRY(0x10ec0861, 0x100340, "ALC660", patch_alc861),
11019        HDA_CODEC_ENTRY(0x10ec0660, "ALC660-VD", patch_alc861vd),
11020        HDA_CODEC_ENTRY(0x10ec0861, "ALC861", patch_alc861),
11021        HDA_CODEC_ENTRY(0x10ec0862, "ALC861-VD", patch_alc861vd),
11022        HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100002, "ALC662 rev2", patch_alc882),
11023        HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100101, "ALC662 rev1", patch_alc662),
11024        HDA_CODEC_REV_ENTRY(0x10ec0662, 0x100300, "ALC662 rev3", patch_alc662),
11025        HDA_CODEC_ENTRY(0x10ec0663, "ALC663", patch_alc662),
11026        HDA_CODEC_ENTRY(0x10ec0665, "ALC665", patch_alc662),
11027        HDA_CODEC_ENTRY(0x10ec0667, "ALC667", patch_alc662),
11028        HDA_CODEC_ENTRY(0x10ec0668, "ALC668", patch_alc662),
11029        HDA_CODEC_ENTRY(0x10ec0670, "ALC670", patch_alc662),
11030        HDA_CODEC_ENTRY(0x10ec0671, "ALC671", patch_alc662),
11031        HDA_CODEC_ENTRY(0x10ec0680, "ALC680", patch_alc680),
11032        HDA_CODEC_ENTRY(0x10ec0700, "ALC700", patch_alc269),
11033        HDA_CODEC_ENTRY(0x10ec0701, "ALC701", patch_alc269),
11034        HDA_CODEC_ENTRY(0x10ec0703, "ALC703", patch_alc269),
11035        HDA_CODEC_ENTRY(0x10ec0711, "ALC711", patch_alc269),
11036        HDA_CODEC_ENTRY(0x10ec0867, "ALC891", patch_alc662),
11037        HDA_CODEC_ENTRY(0x10ec0880, "ALC880", patch_alc880),
11038        HDA_CODEC_ENTRY(0x10ec0882, "ALC882", patch_alc882),
11039        HDA_CODEC_ENTRY(0x10ec0883, "ALC883", patch_alc882),
11040        HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100101, "ALC889A", patch_alc882),
11041        HDA_CODEC_REV_ENTRY(0x10ec0885, 0x100103, "ALC889A", patch_alc882),
11042        HDA_CODEC_ENTRY(0x10ec0885, "ALC885", patch_alc882),
11043        HDA_CODEC_ENTRY(0x10ec0887, "ALC887", patch_alc882),
11044        HDA_CODEC_REV_ENTRY(0x10ec0888, 0x100101, "ALC1200", patch_alc882),
11045        HDA_CODEC_ENTRY(0x10ec0888, "ALC888", patch_alc882),
11046        HDA_CODEC_ENTRY(0x10ec0889, "ALC889", patch_alc882),
11047        HDA_CODEC_ENTRY(0x10ec0892, "ALC892", patch_alc662),
11048        HDA_CODEC_ENTRY(0x10ec0897, "ALC897", patch_alc662),
11049        HDA_CODEC_ENTRY(0x10ec0899, "ALC898", patch_alc882),
11050        HDA_CODEC_ENTRY(0x10ec0900, "ALC1150", patch_alc882),
11051        HDA_CODEC_ENTRY(0x10ec0b00, "ALCS1200A", patch_alc882),
11052        HDA_CODEC_ENTRY(0x10ec1168, "ALC1220", patch_alc882),
11053        HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
11054        {} /* terminator */
11055};
11056MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_realtek);
11057
11058MODULE_LICENSE("GPL");
11059MODULE_DESCRIPTION("Realtek HD-audio codec");
11060
11061static struct hda_codec_driver realtek_driver = {
11062        .id = snd_hda_id_realtek,
11063};
11064
11065module_hda_codec_driver(realtek_driver);
11066