spi: Do not require a completion
[cascardo/linux.git] / sound / pci / hda / patch_sigmatel.c
1 /*
2  * Universal Interface for Intel High Definition Audio Codec
3  *
4  * HD audio interface patch for SigmaTel STAC92xx
5  *
6  * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7  * Matt Porter <mporter@embeddedalley.com>
8  *
9  * Based on patch_cmedia.c and patch_realtek.c
10  * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11  *
12  *  This driver is free software; you can redistribute it and/or modify
13  *  it under the terms of the GNU General Public License as published by
14  *  the Free Software Foundation; either version 2 of the License, or
15  *  (at your option) any later version.
16  *
17  *  This driver is distributed in the hope that it will be useful,
18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  *  GNU General Public License for more details.
21  *
22  *  You should have received a copy of the GNU General Public License
23  *  along with this program; if not, write to the Free Software
24  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
25  */
26
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <linux/dmi.h>
32 #include <linux/module.h>
33 #include <sound/core.h>
34 #include <sound/jack.h>
35 #include <sound/tlv.h>
36 #include "hda_codec.h"
37 #include "hda_local.h"
38 #include "hda_auto_parser.h"
39 #include "hda_beep.h"
40 #include "hda_jack.h"
41 #include "hda_generic.h"
42
43 enum {
44         STAC_VREF_EVENT = 8,
45         STAC_PWR_EVENT,
46 };
47
48 enum {
49         STAC_REF,
50         STAC_9200_OQO,
51         STAC_9200_DELL_D21,
52         STAC_9200_DELL_D22,
53         STAC_9200_DELL_D23,
54         STAC_9200_DELL_M21,
55         STAC_9200_DELL_M22,
56         STAC_9200_DELL_M23,
57         STAC_9200_DELL_M24,
58         STAC_9200_DELL_M25,
59         STAC_9200_DELL_M26,
60         STAC_9200_DELL_M27,
61         STAC_9200_M4,
62         STAC_9200_M4_2,
63         STAC_9200_PANASONIC,
64         STAC_9200_EAPD_INIT,
65         STAC_9200_MODELS
66 };
67
68 enum {
69         STAC_9205_REF,
70         STAC_9205_DELL_M42,
71         STAC_9205_DELL_M43,
72         STAC_9205_DELL_M44,
73         STAC_9205_EAPD,
74         STAC_9205_MODELS
75 };
76
77 enum {
78         STAC_92HD73XX_NO_JD, /* no jack-detection */
79         STAC_92HD73XX_REF,
80         STAC_92HD73XX_INTEL,
81         STAC_DELL_M6_AMIC,
82         STAC_DELL_M6_DMIC,
83         STAC_DELL_M6_BOTH,
84         STAC_DELL_EQ,
85         STAC_ALIENWARE_M17X,
86         STAC_92HD73XX_MODELS
87 };
88
89 enum {
90         STAC_92HD83XXX_REF,
91         STAC_92HD83XXX_PWR_REF,
92         STAC_DELL_S14,
93         STAC_DELL_VOSTRO_3500,
94         STAC_92HD83XXX_HP_cNB11_INTQUAD,
95         STAC_HP_DV7_4000,
96         STAC_HP_ZEPHYR,
97         STAC_92HD83XXX_HP_LED,
98         STAC_92HD83XXX_HP_INV_LED,
99         STAC_92HD83XXX_HP_MIC_LED,
100         STAC_92HD83XXX_HEADSET_JACK,
101         STAC_92HD83XXX_HP,
102         STAC_HP_ENVY_BASS,
103         STAC_HP_BNB13_EQ,
104         STAC_92HD83XXX_MODELS
105 };
106
107 enum {
108         STAC_92HD71BXX_REF,
109         STAC_DELL_M4_1,
110         STAC_DELL_M4_2,
111         STAC_DELL_M4_3,
112         STAC_HP_M4,
113         STAC_HP_DV4,
114         STAC_HP_DV5,
115         STAC_HP_HDX,
116         STAC_92HD71BXX_HP,
117         STAC_92HD71BXX_NO_DMIC,
118         STAC_92HD71BXX_NO_SMUX,
119         STAC_92HD71BXX_MODELS
120 };
121
122 enum {
123         STAC_925x_REF,
124         STAC_M1,
125         STAC_M1_2,
126         STAC_M2,
127         STAC_M2_2,
128         STAC_M3,
129         STAC_M5,
130         STAC_M6,
131         STAC_925x_MODELS
132 };
133
134 enum {
135         STAC_D945_REF,
136         STAC_D945GTP3,
137         STAC_D945GTP5,
138         STAC_INTEL_MAC_V1,
139         STAC_INTEL_MAC_V2,
140         STAC_INTEL_MAC_V3,
141         STAC_INTEL_MAC_V4,
142         STAC_INTEL_MAC_V5,
143         STAC_INTEL_MAC_AUTO,
144         STAC_ECS_202,
145         STAC_922X_DELL_D81,
146         STAC_922X_DELL_D82,
147         STAC_922X_DELL_M81,
148         STAC_922X_DELL_M82,
149         STAC_922X_INTEL_MAC_GPIO,
150         STAC_922X_MODELS
151 };
152
153 enum {
154         STAC_D965_REF_NO_JD, /* no jack-detection */
155         STAC_D965_REF,
156         STAC_D965_3ST,
157         STAC_D965_5ST,
158         STAC_D965_5ST_NO_FP,
159         STAC_D965_VERBS,
160         STAC_DELL_3ST,
161         STAC_DELL_BIOS,
162         STAC_DELL_BIOS_AMIC,
163         STAC_DELL_BIOS_SPDIF,
164         STAC_927X_DELL_DMIC,
165         STAC_927X_VOLKNOB,
166         STAC_927X_MODELS
167 };
168
169 enum {
170         STAC_9872_VAIO,
171         STAC_9872_MODELS
172 };
173
174 struct sigmatel_spec {
175         struct hda_gen_spec gen;
176
177         unsigned int eapd_switch: 1;
178         unsigned int linear_tone_beep:1;
179         unsigned int headset_jack:1; /* 4-pin headset jack (hp + mono mic) */
180         unsigned int volknob_init:1; /* special volume-knob initialization */
181         unsigned int powerdown_adcs:1;
182         unsigned int have_spdif_mux:1;
183
184         /* gpio lines */
185         unsigned int eapd_mask;
186         unsigned int gpio_mask;
187         unsigned int gpio_dir;
188         unsigned int gpio_data;
189         unsigned int gpio_mute;
190         unsigned int gpio_led;
191         unsigned int gpio_led_polarity;
192         unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
193         unsigned int vref_led;
194         int default_polarity;
195
196         unsigned int mic_mute_led_gpio; /* capture mute LED GPIO */
197         bool mic_mute_led_on; /* current mic mute state */
198
199         /* stream */
200         unsigned int stream_delay;
201
202         /* analog loopback */
203         const struct snd_kcontrol_new *aloopback_ctl;
204         unsigned int aloopback;
205         unsigned char aloopback_mask;
206         unsigned char aloopback_shift;
207
208         /* power management */
209         unsigned int power_map_bits;
210         unsigned int num_pwrs;
211         const hda_nid_t *pwr_nids;
212         unsigned int active_adcs;
213
214         /* beep widgets */
215         hda_nid_t anabeep_nid;
216
217         /* SPDIF-out mux */
218         const char * const *spdif_labels;
219         struct hda_input_mux spdif_mux;
220         unsigned int cur_smux[2];
221 };
222
223 #define AC_VERB_IDT_SET_POWER_MAP       0x7ec
224 #define AC_VERB_IDT_GET_POWER_MAP       0xfec
225
226 static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
227         0x0a, 0x0b, 0x0c, 0xd, 0x0e,
228         0x0f, 0x10, 0x11
229 };
230
231 static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
232         0x0a, 0x0b, 0x0c, 0xd, 0x0e,
233         0x0f, 0x10
234 };
235
236 static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
237         0x0a, 0x0d, 0x0f
238 };
239
240
241 /*
242  * PCM hooks
243  */
244 static void stac_playback_pcm_hook(struct hda_pcm_stream *hinfo,
245                                    struct hda_codec *codec,
246                                    struct snd_pcm_substream *substream,
247                                    int action)
248 {
249         struct sigmatel_spec *spec = codec->spec;
250         if (action == HDA_GEN_PCM_ACT_OPEN && spec->stream_delay)
251                 msleep(spec->stream_delay);
252 }
253
254 static void stac_capture_pcm_hook(struct hda_pcm_stream *hinfo,
255                                   struct hda_codec *codec,
256                                   struct snd_pcm_substream *substream,
257                                   int action)
258 {
259         struct sigmatel_spec *spec = codec->spec;
260         int i, idx = 0;
261
262         if (!spec->powerdown_adcs)
263                 return;
264
265         for (i = 0; i < spec->gen.num_all_adcs; i++) {
266                 if (spec->gen.all_adcs[i] == hinfo->nid) {
267                         idx = i;
268                         break;
269                 }
270         }
271
272         switch (action) {
273         case HDA_GEN_PCM_ACT_OPEN:
274                 msleep(40);
275                 snd_hda_codec_write(codec, hinfo->nid, 0,
276                                     AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
277                 spec->active_adcs |= (1 << idx);
278                 break;
279         case HDA_GEN_PCM_ACT_CLOSE:
280                 snd_hda_codec_write(codec, hinfo->nid, 0,
281                                     AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
282                 spec->active_adcs &= ~(1 << idx);
283                 break;
284         }
285 }
286
287 /*
288  * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
289  * funky external mute control using GPIO pins.
290  */
291
292 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
293                           unsigned int dir_mask, unsigned int data)
294 {
295         unsigned int gpiostate, gpiomask, gpiodir;
296
297         snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
298
299         gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
300                                        AC_VERB_GET_GPIO_DATA, 0);
301         gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
302
303         gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
304                                       AC_VERB_GET_GPIO_MASK, 0);
305         gpiomask |= mask;
306
307         gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
308                                      AC_VERB_GET_GPIO_DIRECTION, 0);
309         gpiodir |= dir_mask;
310
311         /* Configure GPIOx as CMOS */
312         snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
313
314         snd_hda_codec_write(codec, codec->afg, 0,
315                             AC_VERB_SET_GPIO_MASK, gpiomask);
316         snd_hda_codec_read(codec, codec->afg, 0,
317                            AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
318
319         msleep(1);
320
321         snd_hda_codec_read(codec, codec->afg, 0,
322                            AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
323 }
324
325 /* hook for controlling mic-mute LED GPIO */
326 static void stac_capture_led_hook(struct hda_codec *codec,
327                                struct snd_ctl_elem_value *ucontrol)
328 {
329         struct sigmatel_spec *spec = codec->spec;
330         bool mute;
331
332         if (!ucontrol)
333                 return;
334
335         mute = !(ucontrol->value.integer.value[0] ||
336                  ucontrol->value.integer.value[1]);
337         if (spec->mic_mute_led_on != mute) {
338                 spec->mic_mute_led_on = mute;
339                 if (mute)
340                         spec->gpio_data |= spec->mic_mute_led_gpio;
341                 else
342                         spec->gpio_data &= ~spec->mic_mute_led_gpio;
343                 stac_gpio_set(codec, spec->gpio_mask,
344                               spec->gpio_dir, spec->gpio_data);
345         }
346 }
347
348 static int stac_vrefout_set(struct hda_codec *codec,
349                                         hda_nid_t nid, unsigned int new_vref)
350 {
351         int error, pinctl;
352
353         snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
354         pinctl = snd_hda_codec_read(codec, nid, 0,
355                                 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
356
357         if (pinctl < 0)
358                 return pinctl;
359
360         pinctl &= 0xff;
361         pinctl &= ~AC_PINCTL_VREFEN;
362         pinctl |= (new_vref & AC_PINCTL_VREFEN);
363
364         error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
365         if (error < 0)
366                 return error;
367
368         return 1;
369 }
370
371 /* prevent codec AFG to D3 state when vref-out pin is used for mute LED */
372 /* this hook is set in stac_setup_gpio() */
373 static unsigned int stac_vref_led_power_filter(struct hda_codec *codec,
374                                                hda_nid_t nid,
375                                                unsigned int power_state)
376 {
377         if (nid == codec->afg && power_state == AC_PWRST_D3)
378                 return AC_PWRST_D1;
379         return snd_hda_gen_path_power_filter(codec, nid, power_state);
380 }
381
382 /* update mute-LED accoring to the master switch */
383 static void stac_update_led_status(struct hda_codec *codec, int enabled)
384 {
385         struct sigmatel_spec *spec = codec->spec;
386         int muted = !enabled;
387
388         if (!spec->gpio_led)
389                 return;
390
391         /* LED state is inverted on these systems */
392         if (spec->gpio_led_polarity)
393                 muted = !muted;
394
395         if (!spec->vref_mute_led_nid) {
396                 if (muted)
397                         spec->gpio_data |= spec->gpio_led;
398                 else
399                         spec->gpio_data &= ~spec->gpio_led;
400                 stac_gpio_set(codec, spec->gpio_mask,
401                                 spec->gpio_dir, spec->gpio_data);
402         } else {
403                 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
404                 stac_vrefout_set(codec, spec->vref_mute_led_nid,
405                                  spec->vref_led);
406         }
407 }
408
409 /* vmaster hook to update mute LED */
410 static void stac_vmaster_hook(void *private_data, int val)
411 {
412         stac_update_led_status(private_data, val);
413 }
414
415 /* automute hook to handle GPIO mute and EAPD updates */
416 static void stac_update_outputs(struct hda_codec *codec)
417 {
418         struct sigmatel_spec *spec = codec->spec;
419
420         if (spec->gpio_mute)
421                 spec->gen.master_mute =
422                         !(snd_hda_codec_read(codec, codec->afg, 0,
423                                 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
424
425         snd_hda_gen_update_outputs(codec);
426
427         if (spec->eapd_mask && spec->eapd_switch) {
428                 unsigned int val = spec->gpio_data;
429                 if (spec->gen.speaker_muted)
430                         val &= ~spec->eapd_mask;
431                 else
432                         val |= spec->eapd_mask;
433                 if (spec->gpio_data != val) {
434                         spec->gpio_data = val;
435                         stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir,
436                                       val);
437                 }
438         }
439 }
440
441 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
442                                   bool enable, bool do_write)
443 {
444         struct sigmatel_spec *spec = codec->spec;
445         unsigned int idx, val;
446
447         for (idx = 0; idx < spec->num_pwrs; idx++) {
448                 if (spec->pwr_nids[idx] == nid)
449                         break;
450         }
451         if (idx >= spec->num_pwrs)
452                 return;
453
454         idx = 1 << idx;
455
456         val = spec->power_map_bits;
457         if (enable)
458                 val &= ~idx;
459         else
460                 val |= idx;
461
462         /* power down unused output ports */
463         if (val != spec->power_map_bits) {
464                 spec->power_map_bits = val;
465                 if (do_write)
466                         snd_hda_codec_write(codec, codec->afg, 0,
467                                             AC_VERB_IDT_SET_POWER_MAP, val);
468         }
469 }
470
471 /* update power bit per jack plug/unplug */
472 static void jack_update_power(struct hda_codec *codec,
473                               struct hda_jack_tbl *jack)
474 {
475         struct sigmatel_spec *spec = codec->spec;
476         int i;
477
478         if (!spec->num_pwrs)
479                 return;
480
481         if (jack && jack->nid) {
482                 stac_toggle_power_map(codec, jack->nid,
483                                       snd_hda_jack_detect(codec, jack->nid),
484                                       true);
485                 return;
486         }
487
488         /* update all jacks */
489         for (i = 0; i < spec->num_pwrs; i++) {
490                 hda_nid_t nid = spec->pwr_nids[i];
491                 jack = snd_hda_jack_tbl_get(codec, nid);
492                 if (!jack || !jack->action)
493                         continue;
494                 if (jack->action == STAC_PWR_EVENT ||
495                     jack->action <= HDA_GEN_LAST_EVENT)
496                         stac_toggle_power_map(codec, nid,
497                                               snd_hda_jack_detect(codec, nid),
498                                               false);
499         }
500
501         snd_hda_codec_write(codec, codec->afg, 0, AC_VERB_IDT_SET_POWER_MAP,
502                             spec->power_map_bits);
503 }
504
505 static void stac_hp_automute(struct hda_codec *codec,
506                                  struct hda_jack_tbl *jack)
507 {
508         snd_hda_gen_hp_automute(codec, jack);
509         jack_update_power(codec, jack);
510 }
511
512 static void stac_line_automute(struct hda_codec *codec,
513                                    struct hda_jack_tbl *jack)
514 {
515         snd_hda_gen_line_automute(codec, jack);
516         jack_update_power(codec, jack);
517 }
518
519 static void stac_mic_autoswitch(struct hda_codec *codec,
520                                 struct hda_jack_tbl *jack)
521 {
522         snd_hda_gen_mic_autoswitch(codec, jack);
523         jack_update_power(codec, jack);
524 }
525
526 static void stac_vref_event(struct hda_codec *codec, struct hda_jack_tbl *event)
527 {
528         unsigned int data;
529
530         data = snd_hda_codec_read(codec, codec->afg, 0,
531                                   AC_VERB_GET_GPIO_DATA, 0);
532         /* toggle VREF state based on GPIOx status */
533         snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
534                             !!(data & (1 << event->private_data)));
535 }
536
537 /* initialize the power map and enable the power event to jacks that
538  * haven't been assigned to automute
539  */
540 static void stac_init_power_map(struct hda_codec *codec)
541 {
542         struct sigmatel_spec *spec = codec->spec;
543         int i;
544
545         for (i = 0; i < spec->num_pwrs; i++)  {
546                 hda_nid_t nid = spec->pwr_nids[i];
547                 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
548                 def_conf = get_defcfg_connect(def_conf);
549                 if (snd_hda_jack_tbl_get(codec, nid))
550                         continue;
551                 if (def_conf == AC_JACK_PORT_COMPLEX &&
552                     !(spec->vref_mute_led_nid == nid ||
553                       is_jack_detectable(codec, nid))) {
554                         snd_hda_jack_detect_enable_callback(codec, nid,
555                                                             STAC_PWR_EVENT,
556                                                             jack_update_power);
557                 } else {
558                         if (def_conf == AC_JACK_PORT_NONE)
559                                 stac_toggle_power_map(codec, nid, false, false);
560                         else
561                                 stac_toggle_power_map(codec, nid, true, false);
562                 }
563         }
564 }
565
566 /*
567  */
568
569 static inline bool get_int_hint(struct hda_codec *codec, const char *key,
570                                 int *valp)
571 {
572         return !snd_hda_get_int_hint(codec, key, valp);
573 }
574
575 /* override some hints from the hwdep entry */
576 static void stac_store_hints(struct hda_codec *codec)
577 {
578         struct sigmatel_spec *spec = codec->spec;
579         int val;
580
581         if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
582                 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
583                         spec->gpio_mask;
584         }
585         if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
586                 spec->gpio_mask &= spec->gpio_mask;
587         if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
588                 spec->gpio_dir &= spec->gpio_mask;
589         if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
590                 spec->eapd_mask &= spec->gpio_mask;
591         if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
592                 spec->gpio_mute &= spec->gpio_mask;
593         val = snd_hda_get_bool_hint(codec, "eapd_switch");
594         if (val >= 0)
595                 spec->eapd_switch = val;
596 }
597
598 /*
599  * loopback controls
600  */
601
602 #define stac_aloopback_info snd_ctl_boolean_mono_info
603
604 static int stac_aloopback_get(struct snd_kcontrol *kcontrol,
605                               struct snd_ctl_elem_value *ucontrol)
606 {
607         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
608         unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
609         struct sigmatel_spec *spec = codec->spec;
610
611         ucontrol->value.integer.value[0] = !!(spec->aloopback &
612                                               (spec->aloopback_mask << idx));
613         return 0;
614 }
615
616 static int stac_aloopback_put(struct snd_kcontrol *kcontrol,
617                               struct snd_ctl_elem_value *ucontrol)
618 {
619         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620         struct sigmatel_spec *spec = codec->spec;
621         unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
622         unsigned int dac_mode;
623         unsigned int val, idx_val;
624
625         idx_val = spec->aloopback_mask << idx;
626         if (ucontrol->value.integer.value[0])
627                 val = spec->aloopback | idx_val;
628         else
629                 val = spec->aloopback & ~idx_val;
630         if (spec->aloopback == val)
631                 return 0;
632
633         spec->aloopback = val;
634
635         /* Only return the bits defined by the shift value of the
636          * first two bytes of the mask
637          */
638         dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
639                                       kcontrol->private_value & 0xFFFF, 0x0);
640         dac_mode >>= spec->aloopback_shift;
641
642         if (spec->aloopback & idx_val) {
643                 snd_hda_power_up(codec);
644                 dac_mode |= idx_val;
645         } else {
646                 snd_hda_power_down(codec);
647                 dac_mode &= ~idx_val;
648         }
649
650         snd_hda_codec_write_cache(codec, codec->afg, 0,
651                 kcontrol->private_value >> 16, dac_mode);
652
653         return 1;
654 }
655
656 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
657         { \
658                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
659                 .name  = "Analog Loopback", \
660                 .count = cnt, \
661                 .info  = stac_aloopback_info, \
662                 .get   = stac_aloopback_get, \
663                 .put   = stac_aloopback_put, \
664                 .private_value = verb_read | (verb_write << 16), \
665         }
666
667 /*
668  * Mute LED handling on HP laptops
669  */
670
671 /* check whether it's a HP laptop with a docking port */
672 static bool hp_bnb2011_with_dock(struct hda_codec *codec)
673 {
674         if (codec->vendor_id != 0x111d7605 &&
675             codec->vendor_id != 0x111d76d1)
676                 return false;
677
678         switch (codec->subsystem_id) {
679         case 0x103c1618:
680         case 0x103c1619:
681         case 0x103c161a:
682         case 0x103c161b:
683         case 0x103c161c:
684         case 0x103c161d:
685         case 0x103c161e:
686         case 0x103c161f:
687
688         case 0x103c162a:
689         case 0x103c162b:
690
691         case 0x103c1630:
692         case 0x103c1631:
693
694         case 0x103c1633:
695         case 0x103c1634:
696         case 0x103c1635:
697
698         case 0x103c3587:
699         case 0x103c3588:
700         case 0x103c3589:
701         case 0x103c358a:
702
703         case 0x103c3667:
704         case 0x103c3668:
705         case 0x103c3669:
706
707                 return true;
708         }
709         return false;
710 }
711
712 static bool hp_blike_system(u32 subsystem_id)
713 {
714         switch (subsystem_id) {
715         case 0x103c1520:
716         case 0x103c1521:
717         case 0x103c1523:
718         case 0x103c1524:
719         case 0x103c1525:
720         case 0x103c1722:
721         case 0x103c1723:
722         case 0x103c1724:
723         case 0x103c1725:
724         case 0x103c1726:
725         case 0x103c1727:
726         case 0x103c1728:
727         case 0x103c1729:
728         case 0x103c172a:
729         case 0x103c172b:
730         case 0x103c307e:
731         case 0x103c307f:
732         case 0x103c3080:
733         case 0x103c3081:
734         case 0x103c7007:
735         case 0x103c7008:
736                 return true;
737         }
738         return false;
739 }
740
741 static void set_hp_led_gpio(struct hda_codec *codec)
742 {
743         struct sigmatel_spec *spec = codec->spec;
744         unsigned int gpio;
745
746         if (spec->gpio_led)
747                 return;
748
749         gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
750         gpio &= AC_GPIO_IO_COUNT;
751         if (gpio > 3)
752                 spec->gpio_led = 0x08; /* GPIO 3 */
753         else
754                 spec->gpio_led = 0x01; /* GPIO 0 */
755 }
756
757 /*
758  * This method searches for the mute LED GPIO configuration
759  * provided as OEM string in SMBIOS. The format of that string
760  * is HP_Mute_LED_P_G or HP_Mute_LED_P
761  * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
762  * that corresponds to the NOT muted state of the master volume
763  * and G is the index of the GPIO to use as the mute LED control (0..9)
764  * If _G portion is missing it is assigned based on the codec ID
765  *
766  * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
767  * or  HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
768  *
769  *
770  * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
771  * SMBIOS - at least the ones I have seen do not have them - which include
772  * my own system (HP Pavilion dv6-1110ax) and my cousin's
773  * HP Pavilion dv9500t CTO.
774  * Need more information on whether it is true across the entire series.
775  * -- kunal
776  */
777 static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
778 {
779         struct sigmatel_spec *spec = codec->spec;
780         const struct dmi_device *dev = NULL;
781
782         if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
783                 get_int_hint(codec, "gpio_led_polarity",
784                              &spec->gpio_led_polarity);
785                 return 1;
786         }
787
788         while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
789                 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
790                            &spec->gpio_led_polarity,
791                            &spec->gpio_led) == 2) {
792                         unsigned int max_gpio;
793                         max_gpio = snd_hda_param_read(codec, codec->afg,
794                                                       AC_PAR_GPIO_CAP);
795                         max_gpio &= AC_GPIO_IO_COUNT;
796                         if (spec->gpio_led < max_gpio)
797                                 spec->gpio_led = 1 << spec->gpio_led;
798                         else
799                                 spec->vref_mute_led_nid = spec->gpio_led;
800                         return 1;
801                 }
802                 if (sscanf(dev->name, "HP_Mute_LED_%d",
803                            &spec->gpio_led_polarity) == 1) {
804                         set_hp_led_gpio(codec);
805                         return 1;
806                 }
807                 /* BIOS bug: unfilled OEM string */
808                 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
809                         set_hp_led_gpio(codec);
810                         if (default_polarity >= 0)
811                                 spec->gpio_led_polarity = default_polarity;
812                         else
813                                 spec->gpio_led_polarity = 1;
814                         return 1;
815                 }
816         }
817
818         /*
819          * Fallback case - if we don't find the DMI strings,
820          * we statically set the GPIO - if not a B-series system
821          * and default polarity is provided
822          */
823         if (!hp_blike_system(codec->subsystem_id) &&
824             (default_polarity == 0 || default_polarity == 1)) {
825                 set_hp_led_gpio(codec);
826                 spec->gpio_led_polarity = default_polarity;
827                 return 1;
828         }
829         return 0;
830 }
831
832 /* check whether a built-in speaker is included in parsed pins */
833 static bool has_builtin_speaker(struct hda_codec *codec)
834 {
835         struct sigmatel_spec *spec = codec->spec;
836         hda_nid_t *nid_pin;
837         int nids, i;
838
839         if (spec->gen.autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) {
840                 nid_pin = spec->gen.autocfg.line_out_pins;
841                 nids = spec->gen.autocfg.line_outs;
842         } else {
843                 nid_pin = spec->gen.autocfg.speaker_pins;
844                 nids = spec->gen.autocfg.speaker_outs;
845         }
846
847         for (i = 0; i < nids; i++) {
848                 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid_pin[i]);
849                 if (snd_hda_get_input_pin_attr(def_conf) == INPUT_PIN_ATTR_INT)
850                         return true;
851         }
852         return false;
853 }
854
855 /*
856  * PC beep controls
857  */
858
859 /* create PC beep volume controls */
860 static int stac_auto_create_beep_ctls(struct hda_codec *codec,
861                                                 hda_nid_t nid)
862 {
863         struct sigmatel_spec *spec = codec->spec;
864         u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
865         struct snd_kcontrol_new *knew;
866         static struct snd_kcontrol_new abeep_mute_ctl =
867                 HDA_CODEC_MUTE(NULL, 0, 0, 0);
868         static struct snd_kcontrol_new dbeep_mute_ctl =
869                 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0);
870         static struct snd_kcontrol_new beep_vol_ctl =
871                 HDA_CODEC_VOLUME(NULL, 0, 0, 0);
872
873         /* check for mute support for the the amp */
874         if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
875                 const struct snd_kcontrol_new *temp;
876                 if (spec->anabeep_nid == nid)
877                         temp = &abeep_mute_ctl;
878                 else
879                         temp = &dbeep_mute_ctl;
880                 knew = snd_hda_gen_add_kctl(&spec->gen,
881                                             "Beep Playback Switch", temp);
882                 if (!knew)
883                         return -ENOMEM;
884                 knew->private_value =
885                         HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT);
886         }
887
888         /* check to see if there is volume support for the amp */
889         if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
890                 knew = snd_hda_gen_add_kctl(&spec->gen,
891                                             "Beep Playback Volume",
892                                             &beep_vol_ctl);
893                 if (!knew)
894                         return -ENOMEM;
895                 knew->private_value =
896                         HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT);
897         }
898         return 0;
899 }
900
901 #ifdef CONFIG_SND_HDA_INPUT_BEEP
902 #define stac_dig_beep_switch_info snd_ctl_boolean_mono_info
903
904 static int stac_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
905                                     struct snd_ctl_elem_value *ucontrol)
906 {
907         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
908         ucontrol->value.integer.value[0] = codec->beep->enabled;
909         return 0;
910 }
911
912 static int stac_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
913                                     struct snd_ctl_elem_value *ucontrol)
914 {
915         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
916         return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
917 }
918
919 static const struct snd_kcontrol_new stac_dig_beep_ctrl = {
920         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
921         .name = "Beep Playback Switch",
922         .info = stac_dig_beep_switch_info,
923         .get = stac_dig_beep_switch_get,
924         .put = stac_dig_beep_switch_put,
925 };
926
927 static int stac_beep_switch_ctl(struct hda_codec *codec)
928 {
929         struct sigmatel_spec *spec = codec->spec;
930
931         if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &stac_dig_beep_ctrl))
932                 return -ENOMEM;
933         return 0;
934 }
935 #endif
936
937 /*
938  * SPDIF-out mux controls
939  */
940
941 static int stac_smux_enum_info(struct snd_kcontrol *kcontrol,
942                                struct snd_ctl_elem_info *uinfo)
943 {
944         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
945         struct sigmatel_spec *spec = codec->spec;
946         return snd_hda_input_mux_info(&spec->spdif_mux, uinfo);
947 }
948
949 static int stac_smux_enum_get(struct snd_kcontrol *kcontrol,
950                               struct snd_ctl_elem_value *ucontrol)
951 {
952         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
953         struct sigmatel_spec *spec = codec->spec;
954         unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
955
956         ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
957         return 0;
958 }
959
960 static int stac_smux_enum_put(struct snd_kcontrol *kcontrol,
961                               struct snd_ctl_elem_value *ucontrol)
962 {
963         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
964         struct sigmatel_spec *spec = codec->spec;
965         unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
966
967         return snd_hda_input_mux_put(codec, &spec->spdif_mux, ucontrol,
968                                      spec->gen.autocfg.dig_out_pins[smux_idx],
969                                      &spec->cur_smux[smux_idx]);
970 }
971
972 static struct snd_kcontrol_new stac_smux_mixer = {
973         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
974         .name = "IEC958 Playback Source",
975         /* count set later */
976         .info = stac_smux_enum_info,
977         .get = stac_smux_enum_get,
978         .put = stac_smux_enum_put,
979 };
980
981 static const char * const stac_spdif_labels[] = {
982         "Digital Playback", "Analog Mux 1", "Analog Mux 2", NULL
983 };
984
985 static int stac_create_spdif_mux_ctls(struct hda_codec *codec)
986 {
987         struct sigmatel_spec *spec = codec->spec;
988         struct auto_pin_cfg *cfg = &spec->gen.autocfg;
989         const char * const *labels = spec->spdif_labels;
990         struct snd_kcontrol_new *kctl;
991         int i, num_cons;
992
993         if (cfg->dig_outs < 1)
994                 return 0;
995
996         num_cons = snd_hda_get_num_conns(codec, cfg->dig_out_pins[0]);
997         if (num_cons <= 1)
998                 return 0;
999
1000         if (!labels)
1001                 labels = stac_spdif_labels;
1002         for (i = 0; i < num_cons; i++) {
1003                 if (snd_BUG_ON(!labels[i]))
1004                         return -EINVAL;
1005                 snd_hda_add_imux_item(&spec->spdif_mux, labels[i], i, NULL);
1006         }
1007
1008         kctl = snd_hda_gen_add_kctl(&spec->gen, NULL, &stac_smux_mixer);
1009         if (!kctl)
1010                 return -ENOMEM;
1011         kctl->count = cfg->dig_outs;
1012
1013         return 0;
1014 }
1015
1016 /*
1017  */
1018
1019 static const struct hda_verb stac9200_core_init[] = {
1020         /* set dac0mux for dac converter */
1021         { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1022         {}
1023 };
1024
1025 static const struct hda_verb stac9200_eapd_init[] = {
1026         /* set dac0mux for dac converter */
1027         {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1028         {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1029         {}
1030 };
1031
1032 static const struct hda_verb dell_eq_core_init[] = {
1033         /* set master volume to max value without distortion
1034          * and direct control */
1035         { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
1036         {}
1037 };
1038
1039 static const struct hda_verb stac92hd73xx_core_init[] = {
1040         /* set master volume and direct control */
1041         { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1042         {}
1043 };
1044
1045 static const struct hda_verb stac92hd83xxx_core_init[] = {
1046         /* power state controls amps */
1047         { 0x01, AC_VERB_SET_EAPD, 1 << 2},
1048         {}
1049 };
1050
1051 static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
1052         { 0x22, 0x785, 0x43 },
1053         { 0x22, 0x782, 0xe0 },
1054         { 0x22, 0x795, 0x00 },
1055         {}
1056 };
1057
1058 static const struct hda_verb stac92hd71bxx_core_init[] = {
1059         /* set master volume and direct control */
1060         { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1061         {}
1062 };
1063
1064 static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
1065         /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
1066         { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1067         { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1068         { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1069         {}
1070 };
1071
1072 static const struct hda_verb stac925x_core_init[] = {
1073         /* set dac0mux for dac converter */
1074         { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
1075         /* mute the master volume */
1076         { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1077         {}
1078 };
1079
1080 static const struct hda_verb stac922x_core_init[] = {
1081         /* set master volume and direct control */
1082         { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1083         {}
1084 };
1085
1086 static const struct hda_verb d965_core_init[] = {
1087         /* unmute node 0x1b */
1088         { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1089         /* select node 0x03 as DAC */
1090         { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
1091         {}
1092 };
1093
1094 static const struct hda_verb dell_3st_core_init[] = {
1095         /* don't set delta bit */
1096         {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
1097         /* unmute node 0x1b */
1098         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1099         /* select node 0x03 as DAC */
1100         {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
1101         {}
1102 };
1103
1104 static const struct hda_verb stac927x_core_init[] = {
1105         /* set master volume and direct control */
1106         { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1107         /* enable analog pc beep path */
1108         { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
1109         {}
1110 };
1111
1112 static const struct hda_verb stac927x_volknob_core_init[] = {
1113         /* don't set delta bit */
1114         {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
1115         /* enable analog pc beep path */
1116         {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
1117         {}
1118 };
1119
1120 static const struct hda_verb stac9205_core_init[] = {
1121         /* set master volume and direct control */
1122         { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1123         /* enable analog pc beep path */
1124         { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
1125         {}
1126 };
1127
1128 static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback =
1129         STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3);
1130
1131 static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback =
1132         STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4);
1133
1134 static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback =
1135         STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5);
1136
1137 static const struct snd_kcontrol_new stac92hd71bxx_loopback =
1138         STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2);
1139
1140 static const struct snd_kcontrol_new stac9205_loopback =
1141         STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1);
1142
1143 static const struct snd_kcontrol_new stac927x_loopback =
1144         STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1);
1145
1146 static const struct hda_pintbl ref9200_pin_configs[] = {
1147         { 0x08, 0x01c47010 },
1148         { 0x09, 0x01447010 },
1149         { 0x0d, 0x0221401f },
1150         { 0x0e, 0x01114010 },
1151         { 0x0f, 0x02a19020 },
1152         { 0x10, 0x01a19021 },
1153         { 0x11, 0x90100140 },
1154         { 0x12, 0x01813122 },
1155         {}
1156 };
1157
1158 static const struct hda_pintbl gateway9200_m4_pin_configs[] = {
1159         { 0x08, 0x400000fe },
1160         { 0x09, 0x404500f4 },
1161         { 0x0d, 0x400100f0 },
1162         { 0x0e, 0x90110010 },
1163         { 0x0f, 0x400100f1 },
1164         { 0x10, 0x02a1902e },
1165         { 0x11, 0x500000f2 },
1166         { 0x12, 0x500000f3 },
1167         {}
1168 };
1169
1170 static const struct hda_pintbl gateway9200_m4_2_pin_configs[] = {
1171         { 0x08, 0x400000fe },
1172         { 0x09, 0x404500f4 },
1173         { 0x0d, 0x400100f0 },
1174         { 0x0e, 0x90110010 },
1175         { 0x0f, 0x400100f1 },
1176         { 0x10, 0x02a1902e },
1177         { 0x11, 0x500000f2 },
1178         { 0x12, 0x500000f3 },
1179         {}
1180 };
1181
1182 /*
1183     STAC 9200 pin configs for
1184     102801A8
1185     102801DE
1186     102801E8
1187 */
1188 static const struct hda_pintbl dell9200_d21_pin_configs[] = {
1189         { 0x08, 0x400001f0 },
1190         { 0x09, 0x400001f1 },
1191         { 0x0d, 0x02214030 },
1192         { 0x0e, 0x01014010 },
1193         { 0x0f, 0x02a19020 },
1194         { 0x10, 0x01a19021 },
1195         { 0x11, 0x90100140 },
1196         { 0x12, 0x01813122 },
1197         {}
1198 };
1199
1200 /*
1201     STAC 9200 pin configs for
1202     102801C0
1203     102801C1
1204 */
1205 static const struct hda_pintbl dell9200_d22_pin_configs[] = {
1206         { 0x08, 0x400001f0 },
1207         { 0x09, 0x400001f1 },
1208         { 0x0d, 0x0221401f },
1209         { 0x0e, 0x01014010 },
1210         { 0x0f, 0x01813020 },
1211         { 0x10, 0x02a19021 },
1212         { 0x11, 0x90100140 },
1213         { 0x12, 0x400001f2 },
1214         {}
1215 };
1216
1217 /*
1218     STAC 9200 pin configs for
1219     102801C4 (Dell Dimension E310)
1220     102801C5
1221     102801C7
1222     102801D9
1223     102801DA
1224     102801E3
1225 */
1226 static const struct hda_pintbl dell9200_d23_pin_configs[] = {
1227         { 0x08, 0x400001f0 },
1228         { 0x09, 0x400001f1 },
1229         { 0x0d, 0x0221401f },
1230         { 0x0e, 0x01014010 },
1231         { 0x0f, 0x01813020 },
1232         { 0x10, 0x01a19021 },
1233         { 0x11, 0x90100140 },
1234         { 0x12, 0x400001f2 },
1235         {}
1236 };
1237
1238
1239 /* 
1240     STAC 9200-32 pin configs for
1241     102801B5 (Dell Inspiron 630m)
1242     102801D8 (Dell Inspiron 640m)
1243 */
1244 static const struct hda_pintbl dell9200_m21_pin_configs[] = {
1245         { 0x08, 0x40c003fa },
1246         { 0x09, 0x03441340 },
1247         { 0x0d, 0x0321121f },
1248         { 0x0e, 0x90170310 },
1249         { 0x0f, 0x408003fb },
1250         { 0x10, 0x03a11020 },
1251         { 0x11, 0x401003fc },
1252         { 0x12, 0x403003fd },
1253         {}
1254 };
1255
1256 /* 
1257     STAC 9200-32 pin configs for
1258     102801C2 (Dell Latitude D620)
1259     102801C8 
1260     102801CC (Dell Latitude D820)
1261     102801D4 
1262     102801D6 
1263 */
1264 static const struct hda_pintbl dell9200_m22_pin_configs[] = {
1265         { 0x08, 0x40c003fa },
1266         { 0x09, 0x0144131f },
1267         { 0x0d, 0x0321121f },
1268         { 0x0e, 0x90170310 },
1269         { 0x0f, 0x90a70321 },
1270         { 0x10, 0x03a11020 },
1271         { 0x11, 0x401003fb },
1272         { 0x12, 0x40f000fc },
1273         {}
1274 };
1275
1276 /* 
1277     STAC 9200-32 pin configs for
1278     102801CE (Dell XPS M1710)
1279     102801CF (Dell Precision M90)
1280 */
1281 static const struct hda_pintbl dell9200_m23_pin_configs[] = {
1282         { 0x08, 0x40c003fa },
1283         { 0x09, 0x01441340 },
1284         { 0x0d, 0x0421421f },
1285         { 0x0e, 0x90170310 },
1286         { 0x0f, 0x408003fb },
1287         { 0x10, 0x04a1102e },
1288         { 0x11, 0x90170311 },
1289         { 0x12, 0x403003fc },
1290         {}
1291 };
1292
1293 /*
1294     STAC 9200-32 pin configs for 
1295     102801C9
1296     102801CA
1297     102801CB (Dell Latitude 120L)
1298     102801D3
1299 */
1300 static const struct hda_pintbl dell9200_m24_pin_configs[] = {
1301         { 0x08, 0x40c003fa },
1302         { 0x09, 0x404003fb },
1303         { 0x0d, 0x0321121f },
1304         { 0x0e, 0x90170310 },
1305         { 0x0f, 0x408003fc },
1306         { 0x10, 0x03a11020 },
1307         { 0x11, 0x401003fd },
1308         { 0x12, 0x403003fe },
1309         {}
1310 };
1311
1312 /*
1313     STAC 9200-32 pin configs for
1314     102801BD (Dell Inspiron E1505n)
1315     102801EE
1316     102801EF
1317 */
1318 static const struct hda_pintbl dell9200_m25_pin_configs[] = {
1319         { 0x08, 0x40c003fa },
1320         { 0x09, 0x01441340 },
1321         { 0x0d, 0x0421121f },
1322         { 0x0e, 0x90170310 },
1323         { 0x0f, 0x408003fb },
1324         { 0x10, 0x04a11020 },
1325         { 0x11, 0x401003fc },
1326         { 0x12, 0x403003fd },
1327         {}
1328 };
1329
1330 /*
1331     STAC 9200-32 pin configs for
1332     102801F5 (Dell Inspiron 1501)
1333     102801F6
1334 */
1335 static const struct hda_pintbl dell9200_m26_pin_configs[] = {
1336         { 0x08, 0x40c003fa },
1337         { 0x09, 0x404003fb },
1338         { 0x0d, 0x0421121f },
1339         { 0x0e, 0x90170310 },
1340         { 0x0f, 0x408003fc },
1341         { 0x10, 0x04a11020 },
1342         { 0x11, 0x401003fd },
1343         { 0x12, 0x403003fe },
1344         {}
1345 };
1346
1347 /*
1348     STAC 9200-32
1349     102801CD (Dell Inspiron E1705/9400)
1350 */
1351 static const struct hda_pintbl dell9200_m27_pin_configs[] = {
1352         { 0x08, 0x40c003fa },
1353         { 0x09, 0x01441340 },
1354         { 0x0d, 0x0421121f },
1355         { 0x0e, 0x90170310 },
1356         { 0x0f, 0x90170310 },
1357         { 0x10, 0x04a11020 },
1358         { 0x11, 0x90170310 },
1359         { 0x12, 0x40f003fc },
1360         {}
1361 };
1362
1363 static const struct hda_pintbl oqo9200_pin_configs[] = {
1364         { 0x08, 0x40c000f0 },
1365         { 0x09, 0x404000f1 },
1366         { 0x0d, 0x0221121f },
1367         { 0x0e, 0x02211210 },
1368         { 0x0f, 0x90170111 },
1369         { 0x10, 0x90a70120 },
1370         { 0x11, 0x400000f2 },
1371         { 0x12, 0x400000f3 },
1372         {}
1373 };
1374
1375
1376 static void stac9200_fixup_panasonic(struct hda_codec *codec,
1377                                      const struct hda_fixup *fix, int action)
1378 {
1379         struct sigmatel_spec *spec = codec->spec;
1380
1381         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
1382                 spec->gpio_mask = spec->gpio_dir = 0x09;
1383                 spec->gpio_data = 0x00;
1384                 /* CF-74 has no headphone detection, and the driver should *NOT*
1385                  * do detection and HP/speaker toggle because the hardware does it.
1386                  */
1387                 spec->gen.suppress_auto_mute = 1;
1388         }
1389 }
1390
1391
1392 static const struct hda_fixup stac9200_fixups[] = {
1393         [STAC_REF] = {
1394                 .type = HDA_FIXUP_PINS,
1395                 .v.pins = ref9200_pin_configs,
1396         },
1397         [STAC_9200_OQO] = {
1398                 .type = HDA_FIXUP_PINS,
1399                 .v.pins = oqo9200_pin_configs,
1400                 .chained = true,
1401                 .chain_id = STAC_9200_EAPD_INIT,
1402         },
1403         [STAC_9200_DELL_D21] = {
1404                 .type = HDA_FIXUP_PINS,
1405                 .v.pins = dell9200_d21_pin_configs,
1406         },
1407         [STAC_9200_DELL_D22] = {
1408                 .type = HDA_FIXUP_PINS,
1409                 .v.pins = dell9200_d22_pin_configs,
1410         },
1411         [STAC_9200_DELL_D23] = {
1412                 .type = HDA_FIXUP_PINS,
1413                 .v.pins = dell9200_d23_pin_configs,
1414         },
1415         [STAC_9200_DELL_M21] = {
1416                 .type = HDA_FIXUP_PINS,
1417                 .v.pins = dell9200_m21_pin_configs,
1418         },
1419         [STAC_9200_DELL_M22] = {
1420                 .type = HDA_FIXUP_PINS,
1421                 .v.pins = dell9200_m22_pin_configs,
1422         },
1423         [STAC_9200_DELL_M23] = {
1424                 .type = HDA_FIXUP_PINS,
1425                 .v.pins = dell9200_m23_pin_configs,
1426         },
1427         [STAC_9200_DELL_M24] = {
1428                 .type = HDA_FIXUP_PINS,
1429                 .v.pins = dell9200_m24_pin_configs,
1430         },
1431         [STAC_9200_DELL_M25] = {
1432                 .type = HDA_FIXUP_PINS,
1433                 .v.pins = dell9200_m25_pin_configs,
1434         },
1435         [STAC_9200_DELL_M26] = {
1436                 .type = HDA_FIXUP_PINS,
1437                 .v.pins = dell9200_m26_pin_configs,
1438         },
1439         [STAC_9200_DELL_M27] = {
1440                 .type = HDA_FIXUP_PINS,
1441                 .v.pins = dell9200_m27_pin_configs,
1442         },
1443         [STAC_9200_M4] = {
1444                 .type = HDA_FIXUP_PINS,
1445                 .v.pins = gateway9200_m4_pin_configs,
1446                 .chained = true,
1447                 .chain_id = STAC_9200_EAPD_INIT,
1448         },
1449         [STAC_9200_M4_2] = {
1450                 .type = HDA_FIXUP_PINS,
1451                 .v.pins = gateway9200_m4_2_pin_configs,
1452                 .chained = true,
1453                 .chain_id = STAC_9200_EAPD_INIT,
1454         },
1455         [STAC_9200_PANASONIC] = {
1456                 .type = HDA_FIXUP_FUNC,
1457                 .v.func = stac9200_fixup_panasonic,
1458         },
1459         [STAC_9200_EAPD_INIT] = {
1460                 .type = HDA_FIXUP_VERBS,
1461                 .v.verbs = (const struct hda_verb[]) {
1462                         {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1463                         {}
1464                 },
1465         },
1466 };
1467
1468 static const struct hda_model_fixup stac9200_models[] = {
1469         { .id = STAC_REF, .name = "ref" },
1470         { .id = STAC_9200_OQO, .name = "oqo" },
1471         { .id = STAC_9200_DELL_D21, .name = "dell-d21" },
1472         { .id = STAC_9200_DELL_D22, .name = "dell-d22" },
1473         { .id = STAC_9200_DELL_D23, .name = "dell-d23" },
1474         { .id = STAC_9200_DELL_M21, .name = "dell-m21" },
1475         { .id = STAC_9200_DELL_M22, .name = "dell-m22" },
1476         { .id = STAC_9200_DELL_M23, .name = "dell-m23" },
1477         { .id = STAC_9200_DELL_M24, .name = "dell-m24" },
1478         { .id = STAC_9200_DELL_M25, .name = "dell-m25" },
1479         { .id = STAC_9200_DELL_M26, .name = "dell-m26" },
1480         { .id = STAC_9200_DELL_M27, .name = "dell-m27" },
1481         { .id = STAC_9200_M4, .name = "gateway-m4" },
1482         { .id = STAC_9200_M4_2, .name = "gateway-m4-2" },
1483         { .id = STAC_9200_PANASONIC, .name = "panasonic" },
1484         {}
1485 };
1486
1487 static const struct snd_pci_quirk stac9200_fixup_tbl[] = {
1488         /* SigmaTel reference board */
1489         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1490                       "DFI LanParty", STAC_REF),
1491         SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1492                       "DFI LanParty", STAC_REF),
1493         /* Dell laptops have BIOS problem */
1494         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1495                       "unknown Dell", STAC_9200_DELL_D21),
1496         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1497                       "Dell Inspiron 630m", STAC_9200_DELL_M21),
1498         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1499                       "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1500         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1501                       "unknown Dell", STAC_9200_DELL_D22),
1502         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1503                       "unknown Dell", STAC_9200_DELL_D22),
1504         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1505                       "Dell Latitude D620", STAC_9200_DELL_M22),
1506         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1507                       "unknown Dell", STAC_9200_DELL_D23),
1508         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1509                       "unknown Dell", STAC_9200_DELL_D23),
1510         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1511                       "unknown Dell", STAC_9200_DELL_M22),
1512         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1513                       "unknown Dell", STAC_9200_DELL_M24),
1514         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1515                       "unknown Dell", STAC_9200_DELL_M24),
1516         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1517                       "Dell Latitude 120L", STAC_9200_DELL_M24),
1518         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1519                       "Dell Latitude D820", STAC_9200_DELL_M22),
1520         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1521                       "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1522         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1523                       "Dell XPS M1710", STAC_9200_DELL_M23),
1524         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1525                       "Dell Precision M90", STAC_9200_DELL_M23),
1526         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1527                       "unknown Dell", STAC_9200_DELL_M22),
1528         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1529                       "unknown Dell", STAC_9200_DELL_M22),
1530         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1531                       "unknown Dell", STAC_9200_DELL_M22),
1532         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1533                       "Dell Inspiron 640m", STAC_9200_DELL_M21),
1534         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1535                       "unknown Dell", STAC_9200_DELL_D23),
1536         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1537                       "unknown Dell", STAC_9200_DELL_D23),
1538         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1539                       "unknown Dell", STAC_9200_DELL_D21),
1540         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1541                       "unknown Dell", STAC_9200_DELL_D23),
1542         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1543                       "unknown Dell", STAC_9200_DELL_D21),
1544         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1545                       "unknown Dell", STAC_9200_DELL_M25),
1546         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1547                       "unknown Dell", STAC_9200_DELL_M25),
1548         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1549                       "Dell Inspiron 1501", STAC_9200_DELL_M26),
1550         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1551                       "unknown Dell", STAC_9200_DELL_M26),
1552         /* Panasonic */
1553         SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1554         /* Gateway machines needs EAPD to be set on resume */
1555         SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1556         SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1557         SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1558         /* OQO Mobile */
1559         SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1560         {} /* terminator */
1561 };
1562
1563 static const struct hda_pintbl ref925x_pin_configs[] = {
1564         { 0x07, 0x40c003f0 },
1565         { 0x08, 0x424503f2 },
1566         { 0x0a, 0x01813022 },
1567         { 0x0b, 0x02a19021 },
1568         { 0x0c, 0x90a70320 },
1569         { 0x0d, 0x02214210 },
1570         { 0x10, 0x01019020 },
1571         { 0x11, 0x9033032e },
1572         {}
1573 };
1574
1575 static const struct hda_pintbl stac925xM1_pin_configs[] = {
1576         { 0x07, 0x40c003f4 },
1577         { 0x08, 0x424503f2 },
1578         { 0x0a, 0x400000f3 },
1579         { 0x0b, 0x02a19020 },
1580         { 0x0c, 0x40a000f0 },
1581         { 0x0d, 0x90100210 },
1582         { 0x10, 0x400003f1 },
1583         { 0x11, 0x9033032e },
1584         {}
1585 };
1586
1587 static const struct hda_pintbl stac925xM1_2_pin_configs[] = {
1588         { 0x07, 0x40c003f4 },
1589         { 0x08, 0x424503f2 },
1590         { 0x0a, 0x400000f3 },
1591         { 0x0b, 0x02a19020 },
1592         { 0x0c, 0x40a000f0 },
1593         { 0x0d, 0x90100210 },
1594         { 0x10, 0x400003f1 },
1595         { 0x11, 0x9033032e },
1596         {}
1597 };
1598
1599 static const struct hda_pintbl stac925xM2_pin_configs[] = {
1600         { 0x07, 0x40c003f4 },
1601         { 0x08, 0x424503f2 },
1602         { 0x0a, 0x400000f3 },
1603         { 0x0b, 0x02a19020 },
1604         { 0x0c, 0x40a000f0 },
1605         { 0x0d, 0x90100210 },
1606         { 0x10, 0x400003f1 },
1607         { 0x11, 0x9033032e },
1608         {}
1609 };
1610
1611 static const struct hda_pintbl stac925xM2_2_pin_configs[] = {
1612         { 0x07, 0x40c003f4 },
1613         { 0x08, 0x424503f2 },
1614         { 0x0a, 0x400000f3 },
1615         { 0x0b, 0x02a19020 },
1616         { 0x0c, 0x40a000f0 },
1617         { 0x0d, 0x90100210 },
1618         { 0x10, 0x400003f1 },
1619         { 0x11, 0x9033032e },
1620         {}
1621 };
1622
1623 static const struct hda_pintbl stac925xM3_pin_configs[] = {
1624         { 0x07, 0x40c003f4 },
1625         { 0x08, 0x424503f2 },
1626         { 0x0a, 0x400000f3 },
1627         { 0x0b, 0x02a19020 },
1628         { 0x0c, 0x40a000f0 },
1629         { 0x0d, 0x90100210 },
1630         { 0x10, 0x400003f1 },
1631         { 0x11, 0x503303f3 },
1632         {}
1633 };
1634
1635 static const struct hda_pintbl stac925xM5_pin_configs[] = {
1636         { 0x07, 0x40c003f4 },
1637         { 0x08, 0x424503f2 },
1638         { 0x0a, 0x400000f3 },
1639         { 0x0b, 0x02a19020 },
1640         { 0x0c, 0x40a000f0 },
1641         { 0x0d, 0x90100210 },
1642         { 0x10, 0x400003f1 },
1643         { 0x11, 0x9033032e },
1644         {}
1645 };
1646
1647 static const struct hda_pintbl stac925xM6_pin_configs[] = {
1648         { 0x07, 0x40c003f4 },
1649         { 0x08, 0x424503f2 },
1650         { 0x0a, 0x400000f3 },
1651         { 0x0b, 0x02a19020 },
1652         { 0x0c, 0x40a000f0 },
1653         { 0x0d, 0x90100210 },
1654         { 0x10, 0x400003f1 },
1655         { 0x11, 0x90330320 },
1656         {}
1657 };
1658
1659 static const struct hda_fixup stac925x_fixups[] = {
1660         [STAC_REF] = {
1661                 .type = HDA_FIXUP_PINS,
1662                 .v.pins = ref925x_pin_configs,
1663         },
1664         [STAC_M1] = {
1665                 .type = HDA_FIXUP_PINS,
1666                 .v.pins = stac925xM1_pin_configs,
1667         },
1668         [STAC_M1_2] = {
1669                 .type = HDA_FIXUP_PINS,
1670                 .v.pins = stac925xM1_2_pin_configs,
1671         },
1672         [STAC_M2] = {
1673                 .type = HDA_FIXUP_PINS,
1674                 .v.pins = stac925xM2_pin_configs,
1675         },
1676         [STAC_M2_2] = {
1677                 .type = HDA_FIXUP_PINS,
1678                 .v.pins = stac925xM2_2_pin_configs,
1679         },
1680         [STAC_M3] = {
1681                 .type = HDA_FIXUP_PINS,
1682                 .v.pins = stac925xM3_pin_configs,
1683         },
1684         [STAC_M5] = {
1685                 .type = HDA_FIXUP_PINS,
1686                 .v.pins = stac925xM5_pin_configs,
1687         },
1688         [STAC_M6] = {
1689                 .type = HDA_FIXUP_PINS,
1690                 .v.pins = stac925xM6_pin_configs,
1691         },
1692 };
1693
1694 static const struct hda_model_fixup stac925x_models[] = {
1695         { .id = STAC_REF, .name = "ref" },
1696         { .id = STAC_M1, .name = "m1" },
1697         { .id = STAC_M1_2, .name = "m1-2" },
1698         { .id = STAC_M2, .name = "m2" },
1699         { .id = STAC_M2_2, .name = "m2-2" },
1700         { .id = STAC_M3, .name = "m3" },
1701         { .id = STAC_M5, .name = "m5" },
1702         { .id = STAC_M6, .name = "m6" },
1703         {}
1704 };
1705
1706 static const struct snd_pci_quirk stac925x_fixup_tbl[] = {
1707         /* SigmaTel reference board */
1708         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1709         SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1710         SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1711
1712         /* Default table for unknown ID */
1713         SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1714
1715         /* gateway machines are checked via codec ssid */
1716         SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1717         SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1718         SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1719         SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1720         SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1721         /* Not sure about the brand name for those */
1722         SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1723         SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1724         SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1725         SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1726         {} /* terminator */
1727 };
1728
1729 static const struct hda_pintbl ref92hd73xx_pin_configs[] = {
1730         { 0x0a, 0x02214030 },
1731         { 0x0b, 0x02a19040 },
1732         { 0x0c, 0x01a19020 },
1733         { 0x0d, 0x02214030 },
1734         { 0x0e, 0x0181302e },
1735         { 0x0f, 0x01014010 },
1736         { 0x10, 0x01014020 },
1737         { 0x11, 0x01014030 },
1738         { 0x12, 0x02319040 },
1739         { 0x13, 0x90a000f0 },
1740         { 0x14, 0x90a000f0 },
1741         { 0x22, 0x01452050 },
1742         { 0x23, 0x01452050 },
1743         {}
1744 };
1745
1746 static const struct hda_pintbl dell_m6_pin_configs[] = {
1747         { 0x0a, 0x0321101f },
1748         { 0x0b, 0x4f00000f },
1749         { 0x0c, 0x4f0000f0 },
1750         { 0x0d, 0x90170110 },
1751         { 0x0e, 0x03a11020 },
1752         { 0x0f, 0x0321101f },
1753         { 0x10, 0x4f0000f0 },
1754         { 0x11, 0x4f0000f0 },
1755         { 0x12, 0x4f0000f0 },
1756         { 0x13, 0x90a60160 },
1757         { 0x14, 0x4f0000f0 },
1758         { 0x22, 0x4f0000f0 },
1759         { 0x23, 0x4f0000f0 },
1760         {}
1761 };
1762
1763 static const struct hda_pintbl alienware_m17x_pin_configs[] = {
1764         { 0x0a, 0x0321101f },
1765         { 0x0b, 0x0321101f },
1766         { 0x0c, 0x03a11020 },
1767         { 0x0d, 0x03014020 },
1768         { 0x0e, 0x90170110 },
1769         { 0x0f, 0x4f0000f0 },
1770         { 0x10, 0x4f0000f0 },
1771         { 0x11, 0x4f0000f0 },
1772         { 0x12, 0x4f0000f0 },
1773         { 0x13, 0x90a60160 },
1774         { 0x14, 0x4f0000f0 },
1775         { 0x22, 0x4f0000f0 },
1776         { 0x23, 0x904601b0 },
1777         {}
1778 };
1779
1780 static const struct hda_pintbl intel_dg45id_pin_configs[] = {
1781         { 0x0a, 0x02214230 },
1782         { 0x0b, 0x02A19240 },
1783         { 0x0c, 0x01013214 },
1784         { 0x0d, 0x01014210 },
1785         { 0x0e, 0x01A19250 },
1786         { 0x0f, 0x01011212 },
1787         { 0x10, 0x01016211 },
1788         {}
1789 };
1790
1791 static void stac92hd73xx_fixup_ref(struct hda_codec *codec,
1792                                    const struct hda_fixup *fix, int action)
1793 {
1794         struct sigmatel_spec *spec = codec->spec;
1795
1796         if (action != HDA_FIXUP_ACT_PRE_PROBE)
1797                 return;
1798
1799         snd_hda_apply_pincfgs(codec, ref92hd73xx_pin_configs);
1800         spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
1801 }
1802
1803 static void stac92hd73xx_fixup_dell(struct hda_codec *codec)
1804 {
1805         struct sigmatel_spec *spec = codec->spec;
1806
1807         snd_hda_apply_pincfgs(codec, dell_m6_pin_configs);
1808         spec->eapd_switch = 0;
1809 }
1810
1811 static void stac92hd73xx_fixup_dell_eq(struct hda_codec *codec,
1812                                        const struct hda_fixup *fix, int action)
1813 {
1814         struct sigmatel_spec *spec = codec->spec;
1815
1816         if (action != HDA_FIXUP_ACT_PRE_PROBE)
1817                 return;
1818
1819         stac92hd73xx_fixup_dell(codec);
1820         snd_hda_add_verbs(codec, dell_eq_core_init);
1821         spec->volknob_init = 1;
1822 }
1823
1824 /* Analog Mics */
1825 static void stac92hd73xx_fixup_dell_m6_amic(struct hda_codec *codec,
1826                                     const struct hda_fixup *fix, int action)
1827 {
1828         if (action != HDA_FIXUP_ACT_PRE_PROBE)
1829                 return;
1830
1831         stac92hd73xx_fixup_dell(codec);
1832         snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
1833 }
1834
1835 /* Digital Mics */
1836 static void stac92hd73xx_fixup_dell_m6_dmic(struct hda_codec *codec,
1837                                     const struct hda_fixup *fix, int action)
1838 {
1839         if (action != HDA_FIXUP_ACT_PRE_PROBE)
1840                 return;
1841
1842         stac92hd73xx_fixup_dell(codec);
1843         snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
1844 }
1845
1846 /* Both */
1847 static void stac92hd73xx_fixup_dell_m6_both(struct hda_codec *codec,
1848                                     const struct hda_fixup *fix, int action)
1849 {
1850         if (action != HDA_FIXUP_ACT_PRE_PROBE)
1851                 return;
1852
1853         stac92hd73xx_fixup_dell(codec);
1854         snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
1855         snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
1856 }
1857
1858 static void stac92hd73xx_fixup_alienware_m17x(struct hda_codec *codec,
1859                                     const struct hda_fixup *fix, int action)
1860 {
1861         struct sigmatel_spec *spec = codec->spec;
1862
1863         if (action != HDA_FIXUP_ACT_PRE_PROBE)
1864                 return;
1865
1866         snd_hda_apply_pincfgs(codec, alienware_m17x_pin_configs);
1867         spec->eapd_switch = 0;
1868 }
1869
1870 static void stac92hd73xx_fixup_no_jd(struct hda_codec *codec,
1871                                      const struct hda_fixup *fix, int action)
1872 {
1873         if (action == HDA_FIXUP_ACT_PRE_PROBE)
1874                 codec->no_jack_detect = 1;
1875 }
1876
1877 static const struct hda_fixup stac92hd73xx_fixups[] = {
1878         [STAC_92HD73XX_REF] = {
1879                 .type = HDA_FIXUP_FUNC,
1880                 .v.func = stac92hd73xx_fixup_ref,
1881         },
1882         [STAC_DELL_M6_AMIC] = {
1883                 .type = HDA_FIXUP_FUNC,
1884                 .v.func = stac92hd73xx_fixup_dell_m6_amic,
1885         },
1886         [STAC_DELL_M6_DMIC] = {
1887                 .type = HDA_FIXUP_FUNC,
1888                 .v.func = stac92hd73xx_fixup_dell_m6_dmic,
1889         },
1890         [STAC_DELL_M6_BOTH] = {
1891                 .type = HDA_FIXUP_FUNC,
1892                 .v.func = stac92hd73xx_fixup_dell_m6_both,
1893         },
1894         [STAC_DELL_EQ]  = {
1895                 .type = HDA_FIXUP_FUNC,
1896                 .v.func = stac92hd73xx_fixup_dell_eq,
1897         },
1898         [STAC_ALIENWARE_M17X] = {
1899                 .type = HDA_FIXUP_FUNC,
1900                 .v.func = stac92hd73xx_fixup_alienware_m17x,
1901         },
1902         [STAC_92HD73XX_INTEL] = {
1903                 .type = HDA_FIXUP_PINS,
1904                 .v.pins = intel_dg45id_pin_configs,
1905         },
1906         [STAC_92HD73XX_NO_JD] = {
1907                 .type = HDA_FIXUP_FUNC,
1908                 .v.func = stac92hd73xx_fixup_no_jd,
1909         }
1910 };
1911
1912 static const struct hda_model_fixup stac92hd73xx_models[] = {
1913         { .id = STAC_92HD73XX_NO_JD, .name = "no-jd" },
1914         { .id = STAC_92HD73XX_REF, .name = "ref" },
1915         { .id = STAC_92HD73XX_INTEL, .name = "intel" },
1916         { .id = STAC_DELL_M6_AMIC, .name = "dell-m6-amic" },
1917         { .id = STAC_DELL_M6_DMIC, .name = "dell-m6-dmic" },
1918         { .id = STAC_DELL_M6_BOTH, .name = "dell-m6" },
1919         { .id = STAC_DELL_EQ, .name = "dell-eq" },
1920         { .id = STAC_ALIENWARE_M17X, .name = "alienware" },
1921         {}
1922 };
1923
1924 static const struct snd_pci_quirk stac92hd73xx_fixup_tbl[] = {
1925         /* SigmaTel reference board */
1926         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1927                                 "DFI LanParty", STAC_92HD73XX_REF),
1928         SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1929                                 "DFI LanParty", STAC_92HD73XX_REF),
1930         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1931                                 "Intel DG45ID", STAC_92HD73XX_INTEL),
1932         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1933                                 "Intel DG45FC", STAC_92HD73XX_INTEL),
1934         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1935                                 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1936         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1937                                 "unknown Dell", STAC_DELL_M6_DMIC),
1938         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1939                                 "unknown Dell", STAC_DELL_M6_BOTH),
1940         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1941                                 "unknown Dell", STAC_DELL_M6_BOTH),
1942         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1943                                 "unknown Dell", STAC_DELL_M6_AMIC),
1944         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1945                                 "unknown Dell", STAC_DELL_M6_AMIC),
1946         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1947                                 "unknown Dell", STAC_DELL_M6_DMIC),
1948         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1949                                 "unknown Dell", STAC_DELL_M6_DMIC),
1950         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1951                                 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1952         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1953                                 "Dell Studio 17", STAC_DELL_M6_DMIC),
1954         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1955                                 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1956         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1957                                 "Dell Studio 1557", STAC_DELL_M6_DMIC),
1958         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
1959                                 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
1960         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
1961                                 "Dell Studio 1558", STAC_DELL_M6_DMIC),
1962         /* codec SSID matching */
1963         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1964                       "Alienware M17x", STAC_ALIENWARE_M17X),
1965         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1966                       "Alienware M17x", STAC_ALIENWARE_M17X),
1967         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
1968                       "Alienware M17x R3", STAC_DELL_EQ),
1969         {} /* terminator */
1970 };
1971
1972 static const struct hda_pintbl ref92hd83xxx_pin_configs[] = {
1973         { 0x0a, 0x02214030 },
1974         { 0x0b, 0x02211010 },
1975         { 0x0c, 0x02a19020 },
1976         { 0x0d, 0x02170130 },
1977         { 0x0e, 0x01014050 },
1978         { 0x0f, 0x01819040 },
1979         { 0x10, 0x01014020 },
1980         { 0x11, 0x90a3014e },
1981         { 0x1f, 0x01451160 },
1982         { 0x20, 0x98560170 },
1983         {}
1984 };
1985
1986 static const struct hda_pintbl dell_s14_pin_configs[] = {
1987         { 0x0a, 0x0221403f },
1988         { 0x0b, 0x0221101f },
1989         { 0x0c, 0x02a19020 },
1990         { 0x0d, 0x90170110 },
1991         { 0x0e, 0x40f000f0 },
1992         { 0x0f, 0x40f000f0 },
1993         { 0x10, 0x40f000f0 },
1994         { 0x11, 0x90a60160 },
1995         { 0x1f, 0x40f000f0 },
1996         { 0x20, 0x40f000f0 },
1997         {}
1998 };
1999
2000 static const struct hda_pintbl dell_vostro_3500_pin_configs[] = {
2001         { 0x0a, 0x02a11020 },
2002         { 0x0b, 0x0221101f },
2003         { 0x0c, 0x400000f0 },
2004         { 0x0d, 0x90170110 },
2005         { 0x0e, 0x400000f1 },
2006         { 0x0f, 0x400000f2 },
2007         { 0x10, 0x400000f3 },
2008         { 0x11, 0x90a60160 },
2009         { 0x1f, 0x400000f4 },
2010         { 0x20, 0x400000f5 },
2011         {}
2012 };
2013
2014 static const struct hda_pintbl hp_dv7_4000_pin_configs[] = {
2015         { 0x0a, 0x03a12050 },
2016         { 0x0b, 0x0321201f },
2017         { 0x0c, 0x40f000f0 },
2018         { 0x0d, 0x90170110 },
2019         { 0x0e, 0x40f000f0 },
2020         { 0x0f, 0x40f000f0 },
2021         { 0x10, 0x90170110 },
2022         { 0x11, 0xd5a30140 },
2023         { 0x1f, 0x40f000f0 },
2024         { 0x20, 0x40f000f0 },
2025         {}
2026 };
2027
2028 static const struct hda_pintbl hp_zephyr_pin_configs[] = {
2029         { 0x0a, 0x01813050 },
2030         { 0x0b, 0x0421201f },
2031         { 0x0c, 0x04a1205e },
2032         { 0x0d, 0x96130310 },
2033         { 0x0e, 0x96130310 },
2034         { 0x0f, 0x0101401f },
2035         { 0x10, 0x1111611f },
2036         { 0x11, 0xd5a30130 },
2037         {}
2038 };
2039
2040 static const struct hda_pintbl hp_cNB11_intquad_pin_configs[] = {
2041         { 0x0a, 0x40f000f0 },
2042         { 0x0b, 0x0221101f },
2043         { 0x0c, 0x02a11020 },
2044         { 0x0d, 0x92170110 },
2045         { 0x0e, 0x40f000f0 },
2046         { 0x0f, 0x92170110 },
2047         { 0x10, 0x40f000f0 },
2048         { 0x11, 0xd5a30130 },
2049         { 0x1f, 0x40f000f0 },
2050         { 0x20, 0x40f000f0 },
2051         {}
2052 };
2053
2054 static void stac92hd83xxx_fixup_hp(struct hda_codec *codec,
2055                                    const struct hda_fixup *fix, int action)
2056 {
2057         struct sigmatel_spec *spec = codec->spec;
2058
2059         if (action != HDA_FIXUP_ACT_PRE_PROBE)
2060                 return;
2061
2062         if (hp_bnb2011_with_dock(codec)) {
2063                 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
2064                 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
2065         }
2066
2067         if (find_mute_led_cfg(codec, spec->default_polarity))
2068                 snd_printd("mute LED gpio %d polarity %d\n",
2069                                 spec->gpio_led,
2070                                 spec->gpio_led_polarity);
2071 }
2072
2073 static void stac92hd83xxx_fixup_hp_zephyr(struct hda_codec *codec,
2074                                    const struct hda_fixup *fix, int action)
2075 {
2076         if (action != HDA_FIXUP_ACT_PRE_PROBE)
2077                 return;
2078
2079         snd_hda_apply_pincfgs(codec, hp_zephyr_pin_configs);
2080         snd_hda_add_verbs(codec, stac92hd83xxx_hp_zephyr_init);
2081 }
2082
2083 static void stac92hd83xxx_fixup_hp_led(struct hda_codec *codec,
2084                                    const struct hda_fixup *fix, int action)
2085 {
2086         struct sigmatel_spec *spec = codec->spec;
2087
2088         if (action == HDA_FIXUP_ACT_PRE_PROBE)
2089                 spec->default_polarity = 0;
2090 }
2091
2092 static void stac92hd83xxx_fixup_hp_inv_led(struct hda_codec *codec,
2093                                    const struct hda_fixup *fix, int action)
2094 {
2095         struct sigmatel_spec *spec = codec->spec;
2096
2097         if (action == HDA_FIXUP_ACT_PRE_PROBE)
2098                 spec->default_polarity = 1;
2099 }
2100
2101 static void stac92hd83xxx_fixup_hp_mic_led(struct hda_codec *codec,
2102                                    const struct hda_fixup *fix, int action)
2103 {
2104         struct sigmatel_spec *spec = codec->spec;
2105
2106         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2107                 spec->mic_mute_led_gpio = 0x08; /* GPIO3 */
2108                 /* resetting controller clears GPIO, so we need to keep on */
2109                 codec->bus->power_keep_link_on = 1;
2110         }
2111 }
2112
2113 static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec,
2114                                    const struct hda_fixup *fix, int action)
2115 {
2116         struct sigmatel_spec *spec = codec->spec;
2117
2118         if (action == HDA_FIXUP_ACT_PRE_PROBE)
2119                 spec->headset_jack = 1;
2120 }
2121
2122 static const struct hda_verb hp_bnb13_eq_verbs[] = {
2123         /* 44.1KHz base */
2124         { 0x22, 0x7A6, 0x3E },
2125         { 0x22, 0x7A7, 0x68 },
2126         { 0x22, 0x7A8, 0x17 },
2127         { 0x22, 0x7A9, 0x3E },
2128         { 0x22, 0x7AA, 0x68 },
2129         { 0x22, 0x7AB, 0x17 },
2130         { 0x22, 0x7AC, 0x00 },
2131         { 0x22, 0x7AD, 0x80 },
2132         { 0x22, 0x7A6, 0x83 },
2133         { 0x22, 0x7A7, 0x2F },
2134         { 0x22, 0x7A8, 0xD1 },
2135         { 0x22, 0x7A9, 0x83 },
2136         { 0x22, 0x7AA, 0x2F },
2137         { 0x22, 0x7AB, 0xD1 },
2138         { 0x22, 0x7AC, 0x01 },
2139         { 0x22, 0x7AD, 0x80 },
2140         { 0x22, 0x7A6, 0x3E },
2141         { 0x22, 0x7A7, 0x68 },
2142         { 0x22, 0x7A8, 0x17 },
2143         { 0x22, 0x7A9, 0x3E },
2144         { 0x22, 0x7AA, 0x68 },
2145         { 0x22, 0x7AB, 0x17 },
2146         { 0x22, 0x7AC, 0x02 },
2147         { 0x22, 0x7AD, 0x80 },
2148         { 0x22, 0x7A6, 0x7C },
2149         { 0x22, 0x7A7, 0xC6 },
2150         { 0x22, 0x7A8, 0x0C },
2151         { 0x22, 0x7A9, 0x7C },
2152         { 0x22, 0x7AA, 0xC6 },
2153         { 0x22, 0x7AB, 0x0C },
2154         { 0x22, 0x7AC, 0x03 },
2155         { 0x22, 0x7AD, 0x80 },
2156         { 0x22, 0x7A6, 0xC3 },
2157         { 0x22, 0x7A7, 0x25 },
2158         { 0x22, 0x7A8, 0xAF },
2159         { 0x22, 0x7A9, 0xC3 },
2160         { 0x22, 0x7AA, 0x25 },
2161         { 0x22, 0x7AB, 0xAF },
2162         { 0x22, 0x7AC, 0x04 },
2163         { 0x22, 0x7AD, 0x80 },
2164         { 0x22, 0x7A6, 0x3E },
2165         { 0x22, 0x7A7, 0x85 },
2166         { 0x22, 0x7A8, 0x73 },
2167         { 0x22, 0x7A9, 0x3E },
2168         { 0x22, 0x7AA, 0x85 },
2169         { 0x22, 0x7AB, 0x73 },
2170         { 0x22, 0x7AC, 0x05 },
2171         { 0x22, 0x7AD, 0x80 },
2172         { 0x22, 0x7A6, 0x85 },
2173         { 0x22, 0x7A7, 0x39 },
2174         { 0x22, 0x7A8, 0xC7 },
2175         { 0x22, 0x7A9, 0x85 },
2176         { 0x22, 0x7AA, 0x39 },
2177         { 0x22, 0x7AB, 0xC7 },
2178         { 0x22, 0x7AC, 0x06 },
2179         { 0x22, 0x7AD, 0x80 },
2180         { 0x22, 0x7A6, 0x3C },
2181         { 0x22, 0x7A7, 0x90 },
2182         { 0x22, 0x7A8, 0xB0 },
2183         { 0x22, 0x7A9, 0x3C },
2184         { 0x22, 0x7AA, 0x90 },
2185         { 0x22, 0x7AB, 0xB0 },
2186         { 0x22, 0x7AC, 0x07 },
2187         { 0x22, 0x7AD, 0x80 },
2188         { 0x22, 0x7A6, 0x7A },
2189         { 0x22, 0x7A7, 0xC6 },
2190         { 0x22, 0x7A8, 0x39 },
2191         { 0x22, 0x7A9, 0x7A },
2192         { 0x22, 0x7AA, 0xC6 },
2193         { 0x22, 0x7AB, 0x39 },
2194         { 0x22, 0x7AC, 0x08 },
2195         { 0x22, 0x7AD, 0x80 },
2196         { 0x22, 0x7A6, 0xC4 },
2197         { 0x22, 0x7A7, 0xE9 },
2198         { 0x22, 0x7A8, 0xDC },
2199         { 0x22, 0x7A9, 0xC4 },
2200         { 0x22, 0x7AA, 0xE9 },
2201         { 0x22, 0x7AB, 0xDC },
2202         { 0x22, 0x7AC, 0x09 },
2203         { 0x22, 0x7AD, 0x80 },
2204         { 0x22, 0x7A6, 0x3D },
2205         { 0x22, 0x7A7, 0xE1 },
2206         { 0x22, 0x7A8, 0x0D },
2207         { 0x22, 0x7A9, 0x3D },
2208         { 0x22, 0x7AA, 0xE1 },
2209         { 0x22, 0x7AB, 0x0D },
2210         { 0x22, 0x7AC, 0x0A },
2211         { 0x22, 0x7AD, 0x80 },
2212         { 0x22, 0x7A6, 0x89 },
2213         { 0x22, 0x7A7, 0xB6 },
2214         { 0x22, 0x7A8, 0xEB },
2215         { 0x22, 0x7A9, 0x89 },
2216         { 0x22, 0x7AA, 0xB6 },
2217         { 0x22, 0x7AB, 0xEB },
2218         { 0x22, 0x7AC, 0x0B },
2219         { 0x22, 0x7AD, 0x80 },
2220         { 0x22, 0x7A6, 0x39 },
2221         { 0x22, 0x7A7, 0x9D },
2222         { 0x22, 0x7A8, 0xFE },
2223         { 0x22, 0x7A9, 0x39 },
2224         { 0x22, 0x7AA, 0x9D },
2225         { 0x22, 0x7AB, 0xFE },
2226         { 0x22, 0x7AC, 0x0C },
2227         { 0x22, 0x7AD, 0x80 },
2228         { 0x22, 0x7A6, 0x76 },
2229         { 0x22, 0x7A7, 0x49 },
2230         { 0x22, 0x7A8, 0x15 },
2231         { 0x22, 0x7A9, 0x76 },
2232         { 0x22, 0x7AA, 0x49 },
2233         { 0x22, 0x7AB, 0x15 },
2234         { 0x22, 0x7AC, 0x0D },
2235         { 0x22, 0x7AD, 0x80 },
2236         { 0x22, 0x7A6, 0xC8 },
2237         { 0x22, 0x7A7, 0x80 },
2238         { 0x22, 0x7A8, 0xF5 },
2239         { 0x22, 0x7A9, 0xC8 },
2240         { 0x22, 0x7AA, 0x80 },
2241         { 0x22, 0x7AB, 0xF5 },
2242         { 0x22, 0x7AC, 0x0E },
2243         { 0x22, 0x7AD, 0x80 },
2244         { 0x22, 0x7A6, 0x40 },
2245         { 0x22, 0x7A7, 0x00 },
2246         { 0x22, 0x7A8, 0x00 },
2247         { 0x22, 0x7A9, 0x40 },
2248         { 0x22, 0x7AA, 0x00 },
2249         { 0x22, 0x7AB, 0x00 },
2250         { 0x22, 0x7AC, 0x0F },
2251         { 0x22, 0x7AD, 0x80 },
2252         { 0x22, 0x7A6, 0x90 },
2253         { 0x22, 0x7A7, 0x68 },
2254         { 0x22, 0x7A8, 0xF1 },
2255         { 0x22, 0x7A9, 0x90 },
2256         { 0x22, 0x7AA, 0x68 },
2257         { 0x22, 0x7AB, 0xF1 },
2258         { 0x22, 0x7AC, 0x10 },
2259         { 0x22, 0x7AD, 0x80 },
2260         { 0x22, 0x7A6, 0x34 },
2261         { 0x22, 0x7A7, 0x47 },
2262         { 0x22, 0x7A8, 0x6C },
2263         { 0x22, 0x7A9, 0x34 },
2264         { 0x22, 0x7AA, 0x47 },
2265         { 0x22, 0x7AB, 0x6C },
2266         { 0x22, 0x7AC, 0x11 },
2267         { 0x22, 0x7AD, 0x80 },
2268         { 0x22, 0x7A6, 0x6F },
2269         { 0x22, 0x7A7, 0x97 },
2270         { 0x22, 0x7A8, 0x0F },
2271         { 0x22, 0x7A9, 0x6F },
2272         { 0x22, 0x7AA, 0x97 },
2273         { 0x22, 0x7AB, 0x0F },
2274         { 0x22, 0x7AC, 0x12 },
2275         { 0x22, 0x7AD, 0x80 },
2276         { 0x22, 0x7A6, 0xCB },
2277         { 0x22, 0x7A7, 0xB8 },
2278         { 0x22, 0x7A8, 0x94 },
2279         { 0x22, 0x7A9, 0xCB },
2280         { 0x22, 0x7AA, 0xB8 },
2281         { 0x22, 0x7AB, 0x94 },
2282         { 0x22, 0x7AC, 0x13 },
2283         { 0x22, 0x7AD, 0x80 },
2284         { 0x22, 0x7A6, 0x40 },
2285         { 0x22, 0x7A7, 0x00 },
2286         { 0x22, 0x7A8, 0x00 },
2287         { 0x22, 0x7A9, 0x40 },
2288         { 0x22, 0x7AA, 0x00 },
2289         { 0x22, 0x7AB, 0x00 },
2290         { 0x22, 0x7AC, 0x14 },
2291         { 0x22, 0x7AD, 0x80 },
2292         { 0x22, 0x7A6, 0x95 },
2293         { 0x22, 0x7A7, 0x76 },
2294         { 0x22, 0x7A8, 0x5B },
2295         { 0x22, 0x7A9, 0x95 },
2296         { 0x22, 0x7AA, 0x76 },
2297         { 0x22, 0x7AB, 0x5B },
2298         { 0x22, 0x7AC, 0x15 },
2299         { 0x22, 0x7AD, 0x80 },
2300         { 0x22, 0x7A6, 0x31 },
2301         { 0x22, 0x7A7, 0xAC },
2302         { 0x22, 0x7A8, 0x31 },
2303         { 0x22, 0x7A9, 0x31 },
2304         { 0x22, 0x7AA, 0xAC },
2305         { 0x22, 0x7AB, 0x31 },
2306         { 0x22, 0x7AC, 0x16 },
2307         { 0x22, 0x7AD, 0x80 },
2308         { 0x22, 0x7A6, 0x6A },
2309         { 0x22, 0x7A7, 0x89 },
2310         { 0x22, 0x7A8, 0xA5 },
2311         { 0x22, 0x7A9, 0x6A },
2312         { 0x22, 0x7AA, 0x89 },
2313         { 0x22, 0x7AB, 0xA5 },
2314         { 0x22, 0x7AC, 0x17 },
2315         { 0x22, 0x7AD, 0x80 },
2316         { 0x22, 0x7A6, 0xCE },
2317         { 0x22, 0x7A7, 0x53 },
2318         { 0x22, 0x7A8, 0xCF },
2319         { 0x22, 0x7A9, 0xCE },
2320         { 0x22, 0x7AA, 0x53 },
2321         { 0x22, 0x7AB, 0xCF },
2322         { 0x22, 0x7AC, 0x18 },
2323         { 0x22, 0x7AD, 0x80 },
2324         { 0x22, 0x7A6, 0x40 },
2325         { 0x22, 0x7A7, 0x00 },
2326         { 0x22, 0x7A8, 0x00 },
2327         { 0x22, 0x7A9, 0x40 },
2328         { 0x22, 0x7AA, 0x00 },
2329         { 0x22, 0x7AB, 0x00 },
2330         { 0x22, 0x7AC, 0x19 },
2331         { 0x22, 0x7AD, 0x80 },
2332         /* 48KHz base */
2333         { 0x22, 0x7A6, 0x3E },
2334         { 0x22, 0x7A7, 0x88 },
2335         { 0x22, 0x7A8, 0xDC },
2336         { 0x22, 0x7A9, 0x3E },
2337         { 0x22, 0x7AA, 0x88 },
2338         { 0x22, 0x7AB, 0xDC },
2339         { 0x22, 0x7AC, 0x1A },
2340         { 0x22, 0x7AD, 0x80 },
2341         { 0x22, 0x7A6, 0x82 },
2342         { 0x22, 0x7A7, 0xEE },
2343         { 0x22, 0x7A8, 0x46 },
2344         { 0x22, 0x7A9, 0x82 },
2345         { 0x22, 0x7AA, 0xEE },
2346         { 0x22, 0x7AB, 0x46 },
2347         { 0x22, 0x7AC, 0x1B },
2348         { 0x22, 0x7AD, 0x80 },
2349         { 0x22, 0x7A6, 0x3E },
2350         { 0x22, 0x7A7, 0x88 },
2351         { 0x22, 0x7A8, 0xDC },
2352         { 0x22, 0x7A9, 0x3E },
2353         { 0x22, 0x7AA, 0x88 },
2354         { 0x22, 0x7AB, 0xDC },
2355         { 0x22, 0x7AC, 0x1C },
2356         { 0x22, 0x7AD, 0x80 },
2357         { 0x22, 0x7A6, 0x7D },
2358         { 0x22, 0x7A7, 0x09 },
2359         { 0x22, 0x7A8, 0x28 },
2360         { 0x22, 0x7A9, 0x7D },
2361         { 0x22, 0x7AA, 0x09 },
2362         { 0x22, 0x7AB, 0x28 },
2363         { 0x22, 0x7AC, 0x1D },
2364         { 0x22, 0x7AD, 0x80 },
2365         { 0x22, 0x7A6, 0xC2 },
2366         { 0x22, 0x7A7, 0xE5 },
2367         { 0x22, 0x7A8, 0xB4 },
2368         { 0x22, 0x7A9, 0xC2 },
2369         { 0x22, 0x7AA, 0xE5 },
2370         { 0x22, 0x7AB, 0xB4 },
2371         { 0x22, 0x7AC, 0x1E },
2372         { 0x22, 0x7AD, 0x80 },
2373         { 0x22, 0x7A6, 0x3E },
2374         { 0x22, 0x7A7, 0xA3 },
2375         { 0x22, 0x7A8, 0x1F },
2376         { 0x22, 0x7A9, 0x3E },
2377         { 0x22, 0x7AA, 0xA3 },
2378         { 0x22, 0x7AB, 0x1F },
2379         { 0x22, 0x7AC, 0x1F },
2380         { 0x22, 0x7AD, 0x80 },
2381         { 0x22, 0x7A6, 0x84 },
2382         { 0x22, 0x7A7, 0xCA },
2383         { 0x22, 0x7A8, 0xF1 },
2384         { 0x22, 0x7A9, 0x84 },
2385         { 0x22, 0x7AA, 0xCA },
2386         { 0x22, 0x7AB, 0xF1 },
2387         { 0x22, 0x7AC, 0x20 },
2388         { 0x22, 0x7AD, 0x80 },
2389         { 0x22, 0x7A6, 0x3C },
2390         { 0x22, 0x7A7, 0xD5 },
2391         { 0x22, 0x7A8, 0x9C },
2392         { 0x22, 0x7A9, 0x3C },
2393         { 0x22, 0x7AA, 0xD5 },
2394         { 0x22, 0x7AB, 0x9C },
2395         { 0x22, 0x7AC, 0x21 },
2396         { 0x22, 0x7AD, 0x80 },
2397         { 0x22, 0x7A6, 0x7B },
2398         { 0x22, 0x7A7, 0x35 },
2399         { 0x22, 0x7A8, 0x0F },
2400         { 0x22, 0x7A9, 0x7B },
2401         { 0x22, 0x7AA, 0x35 },
2402         { 0x22, 0x7AB, 0x0F },
2403         { 0x22, 0x7AC, 0x22 },
2404         { 0x22, 0x7AD, 0x80 },
2405         { 0x22, 0x7A6, 0xC4 },
2406         { 0x22, 0x7A7, 0x87 },
2407         { 0x22, 0x7A8, 0x45 },
2408         { 0x22, 0x7A9, 0xC4 },
2409         { 0x22, 0x7AA, 0x87 },
2410         { 0x22, 0x7AB, 0x45 },
2411         { 0x22, 0x7AC, 0x23 },
2412         { 0x22, 0x7AD, 0x80 },
2413         { 0x22, 0x7A6, 0x3E },
2414         { 0x22, 0x7A7, 0x0A },
2415         { 0x22, 0x7A8, 0x78 },
2416         { 0x22, 0x7A9, 0x3E },
2417         { 0x22, 0x7AA, 0x0A },
2418         { 0x22, 0x7AB, 0x78 },
2419         { 0x22, 0x7AC, 0x24 },
2420         { 0x22, 0x7AD, 0x80 },
2421         { 0x22, 0x7A6, 0x88 },
2422         { 0x22, 0x7A7, 0xE2 },
2423         { 0x22, 0x7A8, 0x05 },
2424         { 0x22, 0x7A9, 0x88 },
2425         { 0x22, 0x7AA, 0xE2 },
2426         { 0x22, 0x7AB, 0x05 },
2427         { 0x22, 0x7AC, 0x25 },
2428         { 0x22, 0x7AD, 0x80 },
2429         { 0x22, 0x7A6, 0x3A },
2430         { 0x22, 0x7A7, 0x1A },
2431         { 0x22, 0x7A8, 0xA3 },
2432         { 0x22, 0x7A9, 0x3A },
2433         { 0x22, 0x7AA, 0x1A },
2434         { 0x22, 0x7AB, 0xA3 },
2435         { 0x22, 0x7AC, 0x26 },
2436         { 0x22, 0x7AD, 0x80 },
2437         { 0x22, 0x7A6, 0x77 },
2438         { 0x22, 0x7A7, 0x1D },
2439         { 0x22, 0x7A8, 0xFB },
2440         { 0x22, 0x7A9, 0x77 },
2441         { 0x22, 0x7AA, 0x1D },
2442         { 0x22, 0x7AB, 0xFB },
2443         { 0x22, 0x7AC, 0x27 },
2444         { 0x22, 0x7AD, 0x80 },
2445         { 0x22, 0x7A6, 0xC7 },
2446         { 0x22, 0x7A7, 0xDA },
2447         { 0x22, 0x7A8, 0xE5 },
2448         { 0x22, 0x7A9, 0xC7 },
2449         { 0x22, 0x7AA, 0xDA },
2450         { 0x22, 0x7AB, 0xE5 },
2451         { 0x22, 0x7AC, 0x28 },
2452         { 0x22, 0x7AD, 0x80 },
2453         { 0x22, 0x7A6, 0x40 },
2454         { 0x22, 0x7A7, 0x00 },
2455         { 0x22, 0x7A8, 0x00 },
2456         { 0x22, 0x7A9, 0x40 },
2457         { 0x22, 0x7AA, 0x00 },
2458         { 0x22, 0x7AB, 0x00 },
2459         { 0x22, 0x7AC, 0x29 },
2460         { 0x22, 0x7AD, 0x80 },
2461         { 0x22, 0x7A6, 0x8E },
2462         { 0x22, 0x7A7, 0xD7 },
2463         { 0x22, 0x7A8, 0x22 },
2464         { 0x22, 0x7A9, 0x8E },
2465         { 0x22, 0x7AA, 0xD7 },
2466         { 0x22, 0x7AB, 0x22 },
2467         { 0x22, 0x7AC, 0x2A },
2468         { 0x22, 0x7AD, 0x80 },
2469         { 0x22, 0x7A6, 0x35 },
2470         { 0x22, 0x7A7, 0x26 },
2471         { 0x22, 0x7A8, 0xC6 },
2472         { 0x22, 0x7A9, 0x35 },
2473         { 0x22, 0x7AA, 0x26 },
2474         { 0x22, 0x7AB, 0xC6 },
2475         { 0x22, 0x7AC, 0x2B },
2476         { 0x22, 0x7AD, 0x80 },
2477         { 0x22, 0x7A6, 0x71 },
2478         { 0x22, 0x7A7, 0x28 },
2479         { 0x22, 0x7A8, 0xDE },
2480         { 0x22, 0x7A9, 0x71 },
2481         { 0x22, 0x7AA, 0x28 },
2482         { 0x22, 0x7AB, 0xDE },
2483         { 0x22, 0x7AC, 0x2C },
2484         { 0x22, 0x7AD, 0x80 },
2485         { 0x22, 0x7A6, 0xCA },
2486         { 0x22, 0x7A7, 0xD9 },
2487         { 0x22, 0x7A8, 0x3A },
2488         { 0x22, 0x7A9, 0xCA },
2489         { 0x22, 0x7AA, 0xD9 },
2490         { 0x22, 0x7AB, 0x3A },
2491         { 0x22, 0x7AC, 0x2D },
2492         { 0x22, 0x7AD, 0x80 },
2493         { 0x22, 0x7A6, 0x40 },
2494         { 0x22, 0x7A7, 0x00 },
2495         { 0x22, 0x7A8, 0x00 },
2496         { 0x22, 0x7A9, 0x40 },
2497         { 0x22, 0x7AA, 0x00 },
2498         { 0x22, 0x7AB, 0x00 },
2499         { 0x22, 0x7AC, 0x2E },
2500         { 0x22, 0x7AD, 0x80 },
2501         { 0x22, 0x7A6, 0x93 },
2502         { 0x22, 0x7A7, 0x5E },
2503         { 0x22, 0x7A8, 0xD8 },
2504         { 0x22, 0x7A9, 0x93 },
2505         { 0x22, 0x7AA, 0x5E },
2506         { 0x22, 0x7AB, 0xD8 },
2507         { 0x22, 0x7AC, 0x2F },
2508         { 0x22, 0x7AD, 0x80 },
2509         { 0x22, 0x7A6, 0x32 },
2510         { 0x22, 0x7A7, 0xB7 },
2511         { 0x22, 0x7A8, 0xB1 },
2512         { 0x22, 0x7A9, 0x32 },
2513         { 0x22, 0x7AA, 0xB7 },
2514         { 0x22, 0x7AB, 0xB1 },
2515         { 0x22, 0x7AC, 0x30 },
2516         { 0x22, 0x7AD, 0x80 },
2517         { 0x22, 0x7A6, 0x6C },
2518         { 0x22, 0x7A7, 0xA1 },
2519         { 0x22, 0x7A8, 0x28 },
2520         { 0x22, 0x7A9, 0x6C },
2521         { 0x22, 0x7AA, 0xA1 },
2522         { 0x22, 0x7AB, 0x28 },
2523         { 0x22, 0x7AC, 0x31 },
2524         { 0x22, 0x7AD, 0x80 },
2525         { 0x22, 0x7A6, 0xCD },
2526         { 0x22, 0x7A7, 0x48 },
2527         { 0x22, 0x7A8, 0x4F },
2528         { 0x22, 0x7A9, 0xCD },
2529         { 0x22, 0x7AA, 0x48 },
2530         { 0x22, 0x7AB, 0x4F },
2531         { 0x22, 0x7AC, 0x32 },
2532         { 0x22, 0x7AD, 0x80 },
2533         { 0x22, 0x7A6, 0x40 },
2534         { 0x22, 0x7A7, 0x00 },
2535         { 0x22, 0x7A8, 0x00 },
2536         { 0x22, 0x7A9, 0x40 },
2537         { 0x22, 0x7AA, 0x00 },
2538         { 0x22, 0x7AB, 0x00 },
2539         { 0x22, 0x7AC, 0x33 },
2540         { 0x22, 0x7AD, 0x80 },
2541         /* common */
2542         { 0x22, 0x782, 0xC1 },
2543         { 0x22, 0x771, 0x2C },
2544         { 0x22, 0x772, 0x2C },
2545         { 0x22, 0x788, 0x04 },
2546         { 0x01, 0x7B0, 0x08 },
2547         {}
2548 };
2549
2550 static const struct hda_fixup stac92hd83xxx_fixups[] = {
2551         [STAC_92HD83XXX_REF] = {
2552                 .type = HDA_FIXUP_PINS,
2553                 .v.pins = ref92hd83xxx_pin_configs,
2554         },
2555         [STAC_92HD83XXX_PWR_REF] = {
2556                 .type = HDA_FIXUP_PINS,
2557                 .v.pins = ref92hd83xxx_pin_configs,
2558         },
2559         [STAC_DELL_S14] = {
2560                 .type = HDA_FIXUP_PINS,
2561                 .v.pins = dell_s14_pin_configs,
2562         },
2563         [STAC_DELL_VOSTRO_3500] = {
2564                 .type = HDA_FIXUP_PINS,
2565                 .v.pins = dell_vostro_3500_pin_configs,
2566         },
2567         [STAC_92HD83XXX_HP_cNB11_INTQUAD] = {
2568                 .type = HDA_FIXUP_PINS,
2569                 .v.pins = hp_cNB11_intquad_pin_configs,
2570                 .chained = true,
2571                 .chain_id = STAC_92HD83XXX_HP,
2572         },
2573         [STAC_92HD83XXX_HP] = {
2574                 .type = HDA_FIXUP_FUNC,
2575                 .v.func = stac92hd83xxx_fixup_hp,
2576         },
2577         [STAC_HP_DV7_4000] = {
2578                 .type = HDA_FIXUP_PINS,
2579                 .v.pins = hp_dv7_4000_pin_configs,
2580                 .chained = true,
2581                 .chain_id = STAC_92HD83XXX_HP,
2582         },
2583         [STAC_HP_ZEPHYR] = {
2584                 .type = HDA_FIXUP_FUNC,
2585                 .v.func = stac92hd83xxx_fixup_hp_zephyr,
2586                 .chained = true,
2587                 .chain_id = STAC_92HD83XXX_HP,
2588         },
2589         [STAC_92HD83XXX_HP_LED] = {
2590                 .type = HDA_FIXUP_FUNC,
2591                 .v.func = stac92hd83xxx_fixup_hp_led,
2592                 .chained = true,
2593                 .chain_id = STAC_92HD83XXX_HP,
2594         },
2595         [STAC_92HD83XXX_HP_INV_LED] = {
2596                 .type = HDA_FIXUP_FUNC,
2597                 .v.func = stac92hd83xxx_fixup_hp_inv_led,
2598                 .chained = true,
2599                 .chain_id = STAC_92HD83XXX_HP,
2600         },
2601         [STAC_92HD83XXX_HP_MIC_LED] = {
2602                 .type = HDA_FIXUP_FUNC,
2603                 .v.func = stac92hd83xxx_fixup_hp_mic_led,
2604                 .chained = true,
2605                 .chain_id = STAC_92HD83XXX_HP,
2606         },
2607         [STAC_92HD83XXX_HEADSET_JACK] = {
2608                 .type = HDA_FIXUP_FUNC,
2609                 .v.func = stac92hd83xxx_fixup_headset_jack,
2610         },
2611         [STAC_HP_ENVY_BASS] = {
2612                 .type = HDA_FIXUP_PINS,
2613                 .v.pins = (const struct hda_pintbl[]) {
2614                         { 0x0f, 0x90170111 },
2615                         {}
2616                 },
2617         },
2618         [STAC_HP_BNB13_EQ] = {
2619                 .type = HDA_FIXUP_VERBS,
2620                 .v.verbs = hp_bnb13_eq_verbs,
2621                 .chained = true,
2622                 .chain_id = STAC_92HD83XXX_HP_MIC_LED,
2623         },
2624 };
2625
2626 static const struct hda_model_fixup stac92hd83xxx_models[] = {
2627         { .id = STAC_92HD83XXX_REF, .name = "ref" },
2628         { .id = STAC_92HD83XXX_PWR_REF, .name = "mic-ref" },
2629         { .id = STAC_DELL_S14, .name = "dell-s14" },
2630         { .id = STAC_DELL_VOSTRO_3500, .name = "dell-vostro-3500" },
2631         { .id = STAC_92HD83XXX_HP_cNB11_INTQUAD, .name = "hp_cNB11_intquad" },
2632         { .id = STAC_HP_DV7_4000, .name = "hp-dv7-4000" },
2633         { .id = STAC_HP_ZEPHYR, .name = "hp-zephyr" },
2634         { .id = STAC_92HD83XXX_HP_LED, .name = "hp-led" },
2635         { .id = STAC_92HD83XXX_HP_INV_LED, .name = "hp-inv-led" },
2636         { .id = STAC_92HD83XXX_HP_MIC_LED, .name = "hp-mic-led" },
2637         { .id = STAC_92HD83XXX_HEADSET_JACK, .name = "headset-jack" },
2638         { .id = STAC_HP_ENVY_BASS, .name = "hp-envy-bass" },
2639         { .id = STAC_HP_BNB13_EQ, .name = "hp-bnb13-eq" },
2640         {}
2641 };
2642
2643 static const struct snd_pci_quirk stac92hd83xxx_fixup_tbl[] = {
2644         /* SigmaTel reference board */
2645         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2646                       "DFI LanParty", STAC_92HD83XXX_REF),
2647         SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2648                       "DFI LanParty", STAC_92HD83XXX_REF),
2649         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
2650                       "unknown Dell", STAC_DELL_S14),
2651         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0532,
2652                       "Dell Latitude E6230", STAC_92HD83XXX_HEADSET_JACK),
2653         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0533,
2654                       "Dell Latitude E6330", STAC_92HD83XXX_HEADSET_JACK),
2655         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0534,
2656                       "Dell Latitude E6430", STAC_92HD83XXX_HEADSET_JACK),
2657         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0535,
2658                       "Dell Latitude E6530", STAC_92HD83XXX_HEADSET_JACK),
2659         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053c,
2660                       "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
2661         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053d,
2662                       "Dell Latitude E5530", STAC_92HD83XXX_HEADSET_JACK),
2663         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0549,
2664                       "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
2665         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x057d,
2666                       "Dell Latitude E6430s", STAC_92HD83XXX_HEADSET_JACK),
2667         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0584,
2668                       "Dell Latitude E6430U", STAC_92HD83XXX_HEADSET_JACK),
2669         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
2670                       "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
2671         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
2672                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2673         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
2674                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2675         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
2676                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2677         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
2678                           "HP Pavilion dv7", STAC_HP_DV7_4000),
2679         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
2680                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2681         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
2682                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2683         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1888,
2684                           "HP Envy Spectre", STAC_HP_ENVY_BASS),
2685         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df,
2686                           "HP Folio", STAC_HP_BNB13_EQ),
2687         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18F8,
2688                           "HP bNB13", STAC_HP_BNB13_EQ),
2689         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1909,
2690                           "HP bNB13", STAC_HP_BNB13_EQ),
2691         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x190A,
2692                           "HP bNB13", STAC_HP_BNB13_EQ),
2693         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1940,
2694                           "HP bNB13", STAC_HP_BNB13_EQ),
2695         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1941,
2696                           "HP bNB13", STAC_HP_BNB13_EQ),
2697         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1942,
2698                           "HP bNB13", STAC_HP_BNB13_EQ),
2699         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1943,
2700                           "HP bNB13", STAC_HP_BNB13_EQ),
2701         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1944,
2702                           "HP bNB13", STAC_HP_BNB13_EQ),
2703         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1945,
2704                           "HP bNB13", STAC_HP_BNB13_EQ),
2705         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1946,
2706                           "HP bNB13", STAC_HP_BNB13_EQ),
2707         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1948,
2708                           "HP bNB13", STAC_HP_BNB13_EQ),
2709         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1949,
2710                           "HP bNB13", STAC_HP_BNB13_EQ),
2711         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194A,
2712                           "HP bNB13", STAC_HP_BNB13_EQ),
2713         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194B,
2714                           "HP bNB13", STAC_HP_BNB13_EQ),
2715         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194C,
2716                           "HP bNB13", STAC_HP_BNB13_EQ),
2717         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194E,
2718                           "HP bNB13", STAC_HP_BNB13_EQ),
2719         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x194F,
2720                           "HP bNB13", STAC_HP_BNB13_EQ),
2721         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1950,
2722                           "HP bNB13", STAC_HP_BNB13_EQ),
2723         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1951,
2724                           "HP bNB13", STAC_HP_BNB13_EQ),
2725         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x195A,
2726                           "HP bNB13", STAC_HP_BNB13_EQ),
2727         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x195B,
2728                           "HP bNB13", STAC_HP_BNB13_EQ),
2729         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x195C,
2730                           "HP bNB13", STAC_HP_BNB13_EQ),
2731         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1991,
2732                           "HP bNB13", STAC_HP_BNB13_EQ),
2733         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2103,
2734                           "HP bNB13", STAC_HP_BNB13_EQ),
2735         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2104,
2736                           "HP bNB13", STAC_HP_BNB13_EQ),
2737         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2105,
2738                           "HP bNB13", STAC_HP_BNB13_EQ),
2739         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2106,
2740                           "HP bNB13", STAC_HP_BNB13_EQ),
2741         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2107,
2742                           "HP bNB13", STAC_HP_BNB13_EQ),
2743         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2108,
2744                           "HP bNB13", STAC_HP_BNB13_EQ),
2745         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2109,
2746                           "HP bNB13", STAC_HP_BNB13_EQ),
2747         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x210A,
2748                           "HP bNB13", STAC_HP_BNB13_EQ),
2749         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x210B,
2750                           "HP bNB13", STAC_HP_BNB13_EQ),
2751         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x211C,
2752                           "HP bNB13", STAC_HP_BNB13_EQ),
2753         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x211D,
2754                           "HP bNB13", STAC_HP_BNB13_EQ),
2755         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x211E,
2756                           "HP bNB13", STAC_HP_BNB13_EQ),
2757         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x211F,
2758                           "HP bNB13", STAC_HP_BNB13_EQ),
2759         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2120,
2760                           "HP bNB13", STAC_HP_BNB13_EQ),
2761         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2121,
2762                           "HP bNB13", STAC_HP_BNB13_EQ),
2763         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2122,
2764                           "HP bNB13", STAC_HP_BNB13_EQ),
2765         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2123,
2766                           "HP bNB13", STAC_HP_BNB13_EQ),
2767         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x213E,
2768                           "HP bNB13", STAC_HP_BNB13_EQ),
2769         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x213F,
2770                           "HP bNB13", STAC_HP_BNB13_EQ),
2771         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2140,
2772                           "HP bNB13", STAC_HP_BNB13_EQ),
2773         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x21B2,
2774                           "HP bNB13", STAC_HP_BNB13_EQ),
2775         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x21B3,
2776                           "HP bNB13", STAC_HP_BNB13_EQ),
2777         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x21B5,
2778                           "HP bNB13", STAC_HP_BNB13_EQ),
2779         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x21B6,
2780                           "HP bNB13", STAC_HP_BNB13_EQ),
2781         SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x1900,
2782                           "HP", STAC_92HD83XXX_HP_MIC_LED),
2783         SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x2000,
2784                           "HP", STAC_92HD83XXX_HP_MIC_LED),
2785         SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x2100,
2786                           "HP", STAC_92HD83XXX_HP_MIC_LED),
2787         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
2788                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2789         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
2790                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2791         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
2792                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2793         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
2794                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2795         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
2796                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2797         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
2798                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2799         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
2800                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2801         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
2802                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2803         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
2804                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2805         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
2806                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2807         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
2808                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2809         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
2810                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2811         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
2812                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2813         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
2814                           "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2815         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
2816                           "HP", STAC_HP_ZEPHYR),
2817         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660,
2818                           "HP Mini", STAC_92HD83XXX_HP_LED),
2819         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x144E,
2820                           "HP Pavilion dv5", STAC_92HD83XXX_HP_INV_LED),
2821         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x148a,
2822                       "HP Mini", STAC_92HD83XXX_HP_LED),
2823         SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD83XXX_HP),
2824         {} /* terminator */
2825 };
2826
2827 /* HP dv7 bass switch - GPIO5 */
2828 #define stac_hp_bass_gpio_info  snd_ctl_boolean_mono_info
2829 static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
2830                                  struct snd_ctl_elem_value *ucontrol)
2831 {
2832         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2833         struct sigmatel_spec *spec = codec->spec;
2834         ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
2835         return 0;
2836 }
2837
2838 static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
2839                                  struct snd_ctl_elem_value *ucontrol)
2840 {
2841         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2842         struct sigmatel_spec *spec = codec->spec;
2843         unsigned int gpio_data;
2844
2845         gpio_data = (spec->gpio_data & ~0x20) |
2846                 (ucontrol->value.integer.value[0] ? 0x20 : 0);
2847         if (gpio_data == spec->gpio_data)
2848                 return 0;
2849         spec->gpio_data = gpio_data;
2850         stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
2851         return 1;
2852 }
2853
2854 static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
2855         .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2856         .info = stac_hp_bass_gpio_info,
2857         .get = stac_hp_bass_gpio_get,
2858         .put = stac_hp_bass_gpio_put,
2859 };
2860
2861 static int stac_add_hp_bass_switch(struct hda_codec *codec)
2862 {
2863         struct sigmatel_spec *spec = codec->spec;
2864
2865         if (!snd_hda_gen_add_kctl(&spec->gen, "Bass Speaker Playback Switch",
2866                                   &stac_hp_bass_sw_ctrl))
2867                 return -ENOMEM;
2868
2869         spec->gpio_mask |= 0x20;
2870         spec->gpio_dir |= 0x20;
2871         spec->gpio_data |= 0x20;
2872         return 0;
2873 }
2874
2875 static const struct hda_pintbl ref92hd71bxx_pin_configs[] = {
2876         { 0x0a, 0x02214030 },
2877         { 0x0b, 0x02a19040 },
2878         { 0x0c, 0x01a19020 },
2879         { 0x0d, 0x01014010 },
2880         { 0x0e, 0x0181302e },
2881         { 0x0f, 0x01014010 },
2882         { 0x14, 0x01019020 },
2883         { 0x18, 0x90a000f0 },
2884         { 0x19, 0x90a000f0 },
2885         { 0x1e, 0x01452050 },
2886         { 0x1f, 0x01452050 },
2887         {}
2888 };
2889
2890 static const struct hda_pintbl dell_m4_1_pin_configs[] = {
2891         { 0x0a, 0x0421101f },
2892         { 0x0b, 0x04a11221 },
2893         { 0x0c, 0x40f000f0 },
2894         { 0x0d, 0x90170110 },
2895         { 0x0e, 0x23a1902e },
2896         { 0x0f, 0x23014250 },
2897         { 0x14, 0x40f000f0 },
2898         { 0x18, 0x90a000f0 },
2899         { 0x19, 0x40f000f0 },
2900         { 0x1e, 0x4f0000f0 },
2901         { 0x1f, 0x4f0000f0 },
2902         {}
2903 };
2904
2905 static const struct hda_pintbl dell_m4_2_pin_configs[] = {
2906         { 0x0a, 0x0421101f },
2907         { 0x0b, 0x04a11221 },
2908         { 0x0c, 0x90a70330 },
2909         { 0x0d, 0x90170110 },
2910         { 0x0e, 0x23a1902e },
2911         { 0x0f, 0x23014250 },
2912         { 0x14, 0x40f000f0 },
2913         { 0x18, 0x40f000f0 },
2914         { 0x19, 0x40f000f0 },
2915         { 0x1e, 0x044413b0 },
2916         { 0x1f, 0x044413b0 },
2917         {}
2918 };
2919
2920 static const struct hda_pintbl dell_m4_3_pin_configs[] = {
2921         { 0x0a, 0x0421101f },
2922         { 0x0b, 0x04a11221 },
2923         { 0x0c, 0x90a70330 },
2924         { 0x0d, 0x90170110 },
2925         { 0x0e, 0x40f000f0 },
2926         { 0x0f, 0x40f000f0 },
2927         { 0x14, 0x40f000f0 },
2928         { 0x18, 0x90a000f0 },
2929         { 0x19, 0x40f000f0 },
2930         { 0x1e, 0x044413b0 },
2931         { 0x1f, 0x044413b0 },
2932         {}
2933 };
2934
2935 static void stac92hd71bxx_fixup_ref(struct hda_codec *codec,
2936                                     const struct hda_fixup *fix, int action)
2937 {
2938         struct sigmatel_spec *spec = codec->spec;
2939
2940         if (action != HDA_FIXUP_ACT_PRE_PROBE)
2941                 return;
2942
2943         snd_hda_apply_pincfgs(codec, ref92hd71bxx_pin_configs);
2944         spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
2945 }
2946
2947 static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec,
2948                                       const struct hda_fixup *fix, int action)
2949 {
2950         struct sigmatel_spec *spec = codec->spec;
2951         struct hda_jack_tbl *jack;
2952
2953         if (action != HDA_FIXUP_ACT_PRE_PROBE)
2954                 return;
2955
2956         /* Enable VREF power saving on GPIO1 detect */
2957         snd_hda_codec_write_cache(codec, codec->afg, 0,
2958                                   AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
2959         snd_hda_jack_detect_enable_callback(codec, codec->afg,
2960                                             STAC_VREF_EVENT,
2961                                             stac_vref_event);
2962         jack = snd_hda_jack_tbl_get(codec, codec->afg);
2963         if (jack)
2964                 jack->private_data = 0x02;
2965
2966         spec->gpio_mask |= 0x02;
2967
2968         /* enable internal microphone */
2969         snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
2970 }
2971
2972 static void stac92hd71bxx_fixup_hp_dv4(struct hda_codec *codec,
2973                                        const struct hda_fixup *fix, int action)
2974 {
2975         struct sigmatel_spec *spec = codec->spec;
2976
2977         if (action != HDA_FIXUP_ACT_PRE_PROBE)
2978                 return;
2979         spec->gpio_led = 0x01;
2980 }
2981
2982 static void stac92hd71bxx_fixup_hp_dv5(struct hda_codec *codec,
2983                                        const struct hda_fixup *fix, int action)
2984 {
2985         unsigned int cap;
2986
2987         switch (action) {
2988         case HDA_FIXUP_ACT_PRE_PROBE:
2989                 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
2990                 break;
2991
2992         case HDA_FIXUP_ACT_PROBE:
2993                 /* enable bass on HP dv7 */
2994                 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
2995                 cap &= AC_GPIO_IO_COUNT;
2996                 if (cap >= 6)
2997                         stac_add_hp_bass_switch(codec);
2998                 break;
2999         }
3000 }
3001
3002 static void stac92hd71bxx_fixup_hp_hdx(struct hda_codec *codec,
3003                                        const struct hda_fixup *fix, int action)
3004 {
3005         struct sigmatel_spec *spec = codec->spec;
3006
3007         if (action != HDA_FIXUP_ACT_PRE_PROBE)
3008                 return;
3009         spec->gpio_led = 0x08;
3010 }
3011
3012
3013 static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,
3014                                    const struct hda_fixup *fix, int action)
3015 {
3016         struct sigmatel_spec *spec = codec->spec;
3017
3018         if (action != HDA_FIXUP_ACT_PRE_PROBE)
3019                 return;
3020
3021         if (hp_blike_system(codec->subsystem_id)) {
3022                 unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
3023                 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
3024                         get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER  ||
3025                         get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
3026                         /* It was changed in the BIOS to just satisfy MS DTM.
3027                          * Lets turn it back into slaved HP
3028                          */
3029                         pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
3030                                         | (AC_JACK_HP_OUT <<
3031                                                 AC_DEFCFG_DEVICE_SHIFT);
3032                         pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
3033                                                         | AC_DEFCFG_SEQUENCE)))
3034                                                                 | 0x1f;
3035                         snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
3036                 }
3037         }
3038
3039         if (find_mute_led_cfg(codec, 1))
3040                 snd_printd("mute LED gpio %d polarity %d\n",
3041                                 spec->gpio_led,
3042                                 spec->gpio_led_polarity);
3043
3044 }
3045
3046 static const struct hda_fixup stac92hd71bxx_fixups[] = {
3047         [STAC_92HD71BXX_REF] = {
3048                 .type = HDA_FIXUP_FUNC,
3049                 .v.func = stac92hd71bxx_fixup_ref,
3050         },
3051         [STAC_DELL_M4_1] = {
3052                 .type = HDA_FIXUP_PINS,
3053                 .v.pins = dell_m4_1_pin_configs,
3054         },
3055         [STAC_DELL_M4_2] = {
3056                 .type = HDA_FIXUP_PINS,
3057                 .v.pins = dell_m4_2_pin_configs,
3058         },
3059         [STAC_DELL_M4_3] = {
3060                 .type = HDA_FIXUP_PINS,
3061                 .v.pins = dell_m4_3_pin_configs,
3062         },
3063         [STAC_HP_M4] = {
3064                 .type = HDA_FIXUP_FUNC,
3065                 .v.func = stac92hd71bxx_fixup_hp_m4,
3066                 .chained = true,
3067                 .chain_id = STAC_92HD71BXX_HP,
3068         },
3069         [STAC_HP_DV4] = {
3070                 .type = HDA_FIXUP_FUNC,
3071                 .v.func = stac92hd71bxx_fixup_hp_dv4,
3072                 .chained = true,
3073                 .chain_id = STAC_HP_DV5,
3074         },
3075         [STAC_HP_DV5] = {
3076                 .type = HDA_FIXUP_FUNC,
3077                 .v.func = stac92hd71bxx_fixup_hp_dv5,
3078                 .chained = true,
3079                 .chain_id = STAC_92HD71BXX_HP,
3080         },
3081         [STAC_HP_HDX] = {
3082                 .type = HDA_FIXUP_FUNC,
3083                 .v.func = stac92hd71bxx_fixup_hp_hdx,
3084                 .chained = true,
3085                 .chain_id = STAC_92HD71BXX_HP,
3086         },
3087         [STAC_92HD71BXX_HP] = {
3088                 .type = HDA_FIXUP_FUNC,
3089                 .v.func = stac92hd71bxx_fixup_hp,
3090         },
3091 };
3092
3093 static const struct hda_model_fixup stac92hd71bxx_models[] = {
3094         { .id = STAC_92HD71BXX_REF, .name = "ref" },
3095         { .id = STAC_DELL_M4_1, .name = "dell-m4-1" },
3096         { .id = STAC_DELL_M4_2, .name = "dell-m4-2" },
3097         { .id = STAC_DELL_M4_3, .name = "dell-m4-3" },
3098         { .id = STAC_HP_M4, .name = "hp-m4" },
3099         { .id = STAC_HP_DV4, .name = "hp-dv4" },
3100         { .id = STAC_HP_DV5, .name = "hp-dv5" },
3101         { .id = STAC_HP_HDX, .name = "hp-hdx" },
3102         { .id = STAC_HP_DV4, .name = "hp-dv4-1222nr" },
3103         {}
3104 };
3105
3106 static const struct snd_pci_quirk stac92hd71bxx_fixup_tbl[] = {
3107         /* SigmaTel reference board */
3108         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3109                       "DFI LanParty", STAC_92HD71BXX_REF),
3110         SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3111                       "DFI LanParty", STAC_92HD71BXX_REF),
3112         SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
3113                           "HP", STAC_HP_DV5),
3114         SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
3115                       "HP", STAC_HP_DV5),
3116         SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
3117                       "HP dv4-7", STAC_HP_DV4),
3118         SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
3119                       "HP dv4-7", STAC_HP_DV5),
3120         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
3121                       "HP HDX", STAC_HP_HDX),  /* HDX18 */
3122         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
3123                       "HP mini 1000", STAC_HP_M4),
3124         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
3125                       "HP HDX", STAC_HP_HDX),  /* HDX16 */
3126         SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
3127                       "HP dv6", STAC_HP_DV5),
3128         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
3129                       "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
3130         SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
3131                       "HP DV6", STAC_HP_DV5),
3132         SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
3133                       "HP", STAC_HP_DV5),
3134         SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD71BXX_HP),
3135         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
3136                                 "unknown Dell", STAC_DELL_M4_1),
3137         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
3138                                 "unknown Dell", STAC_DELL_M4_1),
3139         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
3140                                 "unknown Dell", STAC_DELL_M4_1),
3141         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
3142                                 "unknown Dell", STAC_DELL_M4_1),
3143         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
3144                                 "unknown Dell", STAC_DELL_M4_1),
3145         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
3146                                 "unknown Dell", STAC_DELL_M4_1),
3147         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
3148                                 "unknown Dell", STAC_DELL_M4_1),
3149         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
3150                                 "unknown Dell", STAC_DELL_M4_2),
3151         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
3152                                 "unknown Dell", STAC_DELL_M4_2),
3153         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
3154                                 "unknown Dell", STAC_DELL_M4_2),
3155         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
3156                                 "unknown Dell", STAC_DELL_M4_2),
3157         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
3158                                 "unknown Dell", STAC_DELL_M4_3),
3159         {} /* terminator */
3160 };
3161
3162 static const struct hda_pintbl ref922x_pin_configs[] = {
3163         { 0x0a, 0x01014010 },
3164         { 0x0b, 0x01016011 },
3165         { 0x0c, 0x01012012 },
3166         { 0x0d, 0x0221401f },
3167         { 0x0e, 0x01813122 },
3168         { 0x0f, 0x01011014 },
3169         { 0x10, 0x01441030 },
3170         { 0x11, 0x01c41030 },
3171         { 0x15, 0x40000100 },
3172         { 0x1b, 0x40000100 },
3173         {}
3174 };
3175
3176 /*
3177     STAC 922X pin configs for
3178     102801A7
3179     102801AB
3180     102801A9
3181     102801D1
3182     102801D2
3183 */
3184 static const struct hda_pintbl dell_922x_d81_pin_configs[] = {
3185         { 0x0a, 0x02214030 },
3186         { 0x0b, 0x01a19021 },
3187         { 0x0c, 0x01111012 },
3188         { 0x0d, 0x01114010 },
3189         { 0x0e, 0x02a19020 },
3190         { 0x0f, 0x01117011 },
3191         { 0x10, 0x400001f0 },
3192         { 0x11, 0x400001f1 },
3193         { 0x15, 0x01813122 },
3194         { 0x1b, 0x400001f2 },
3195         {}
3196 };
3197
3198 /*
3199     STAC 922X pin configs for
3200     102801AC
3201     102801D0
3202 */
3203 static const struct hda_pintbl dell_922x_d82_pin_configs[] = {
3204         { 0x0a, 0x02214030 },
3205         { 0x0b, 0x01a19021 },
3206         { 0x0c, 0x01111012 },
3207         { 0x0d, 0x01114010 },
3208         { 0x0e, 0x02a19020 },
3209         { 0x0f, 0x01117011 },
3210         { 0x10, 0x01451140 },
3211         { 0x11, 0x400001f0 },
3212         { 0x15, 0x01813122 },
3213         { 0x1b, 0x400001f1 },
3214         {}
3215 };
3216
3217 /*
3218     STAC 922X pin configs for
3219     102801BF
3220 */
3221 static const struct hda_pintbl dell_922x_m81_pin_configs[] = {
3222         { 0x0a, 0x0321101f },
3223         { 0x0b, 0x01112024 },
3224         { 0x0c, 0x01111222 },
3225         { 0x0d, 0x91174220 },
3226         { 0x0e, 0x03a11050 },
3227         { 0x0f, 0x01116221 },
3228         { 0x10, 0x90a70330 },
3229         { 0x11, 0x01452340 },
3230         { 0x15, 0x40C003f1 },
3231         { 0x1b, 0x405003f0 },
3232         {}
3233 };
3234
3235 /*
3236     STAC 9221 A1 pin configs for
3237     102801D7 (Dell XPS M1210)
3238 */
3239 static const struct hda_pintbl dell_922x_m82_pin_configs[] = {
3240         { 0x0a, 0x02211211 },
3241         { 0x0b, 0x408103ff },
3242         { 0x0c, 0x02a1123e },
3243         { 0x0d, 0x90100310 },
3244         { 0x0e, 0x408003f1 },
3245         { 0x0f, 0x0221121f },
3246         { 0x10, 0x03451340 },
3247         { 0x11, 0x40c003f2 },
3248         { 0x15, 0x508003f3 },
3249         { 0x1b, 0x405003f4 },
3250         {}
3251 };
3252
3253 static const struct hda_pintbl d945gtp3_pin_configs[] = {
3254         { 0x0a, 0x0221401f },
3255         { 0x0b, 0x01a19022 },
3256         { 0x0c, 0x01813021 },
3257         { 0x0d, 0x01014010 },
3258         { 0x0e, 0x40000100 },
3259         { 0x0f, 0x40000100 },
3260         { 0x10, 0x40000100 },
3261         { 0x11, 0x40000100 },
3262         { 0x15, 0x02a19120 },
3263         { 0x1b, 0x40000100 },
3264         {}
3265 };
3266
3267 static const struct hda_pintbl d945gtp5_pin_configs[] = {
3268         { 0x0a, 0x0221401f },
3269         { 0x0b, 0x01011012 },
3270         { 0x0c, 0x01813024 },
3271         { 0x0d, 0x01014010 },
3272         { 0x0e, 0x01a19021 },
3273         { 0x0f, 0x01016011 },
3274         { 0x10, 0x01452130 },
3275         { 0x11, 0x40000100 },
3276         { 0x15, 0x02a19320 },
3277         { 0x1b, 0x40000100 },
3278         {}
3279 };
3280
3281 static const struct hda_pintbl intel_mac_v1_pin_configs[] = {
3282         { 0x0a, 0x0121e21f },
3283         { 0x0b, 0x400000ff },
3284         { 0x0c, 0x9017e110 },
3285         { 0x0d, 0x400000fd },
3286         { 0x0e, 0x400000fe },
3287         { 0x0f, 0x0181e020 },
3288         { 0x10, 0x1145e030 },
3289         { 0x11, 0x11c5e240 },
3290         { 0x15, 0x400000fc },
3291         { 0x1b, 0x400000fb },
3292         {}
3293 };
3294
3295 static const struct hda_pintbl intel_mac_v2_pin_configs[] = {
3296         { 0x0a, 0x0121e21f },
3297         { 0x0b, 0x90a7012e },
3298         { 0x0c, 0x9017e110 },
3299         { 0x0d, 0x400000fd },
3300         { 0x0e, 0x400000fe },
3301         { 0x0f, 0x0181e020 },
3302         { 0x10, 0x1145e230 },
3303         { 0x11, 0x500000fa },
3304         { 0x15, 0x400000fc },
3305         { 0x1b, 0x400000fb },
3306         {}
3307 };
3308
3309 static const struct hda_pintbl intel_mac_v3_pin_configs[] = {
3310         { 0x0a, 0x0121e21f },
3311         { 0x0b, 0x90a7012e },
3312         { 0x0c, 0x9017e110 },
3313         { 0x0d, 0x400000fd },
3314         { 0x0e, 0x400000fe },
3315         { 0x0f, 0x0181e020 },
3316         { 0x10, 0x1145e230 },
3317         { 0x11, 0x11c5e240 },
3318         { 0x15, 0x400000fc },
3319         { 0x1b, 0x400000fb },
3320         {}
3321 };
3322
3323 static const struct hda_pintbl intel_mac_v4_pin_configs[] = {
3324         { 0x0a, 0x0321e21f },
3325         { 0x0b, 0x03a1e02e },
3326         { 0x0c, 0x9017e110 },
3327         { 0x0d, 0x9017e11f },
3328         { 0x0e, 0x400000fe },
3329         { 0x0f, 0x0381e020 },
3330         { 0x10, 0x1345e230 },
3331         { 0x11, 0x13c5e240 },
3332         { 0x15, 0x400000fc },
3333         { 0x1b, 0x400000fb },
3334         {}
3335 };
3336
3337 static const struct hda_pintbl intel_mac_v5_pin_configs[] = {
3338         { 0x0a, 0x0321e21f },
3339         { 0x0b, 0x03a1e02e },
3340         { 0x0c, 0x9017e110 },
3341         { 0x0d, 0x9017e11f },
3342         { 0x0e, 0x400000fe },
3343         { 0x0f, 0x0381e020 },
3344         { 0x10, 0x1345e230 },
3345         { 0x11, 0x13c5e240 },
3346         { 0x15, 0x400000fc },
3347         { 0x1b, 0x400000fb },
3348         {}
3349 };
3350
3351 static const struct hda_pintbl ecs202_pin_configs[] = {
3352         { 0x0a, 0x0221401f },
3353         { 0x0b, 0x02a19020 },
3354         { 0x0c, 0x01a19020 },
3355         { 0x0d, 0x01114010 },
3356         { 0x0e, 0x408000f0 },
3357         { 0x0f, 0x01813022 },
3358         { 0x10, 0x074510a0 },
3359         { 0x11, 0x40c400f1 },
3360         { 0x15, 0x9037012e },
3361         { 0x1b, 0x40e000f2 },
3362         {}
3363 };
3364
3365 /* codec SSIDs for Intel Mac sharing the same PCI SSID 8384:7680 */
3366 static const struct snd_pci_quirk stac922x_intel_mac_fixup_tbl[] = {
3367         SND_PCI_QUIRK(0x0000, 0x0100, "Mac Mini", STAC_INTEL_MAC_V3),
3368         SND_PCI_QUIRK(0x106b, 0x0800, "Mac", STAC_INTEL_MAC_V1),
3369         SND_PCI_QUIRK(0x106b, 0x0600, "Mac", STAC_INTEL_MAC_V2),
3370         SND_PCI_QUIRK(0x106b, 0x0700, "Mac", STAC_INTEL_MAC_V2),
3371         SND_PCI_QUIRK(0x106b, 0x0e00, "Mac", STAC_INTEL_MAC_V3),
3372         SND_PCI_QUIRK(0x106b, 0x0f00, "Mac", STAC_INTEL_MAC_V3),
3373         SND_PCI_QUIRK(0x106b, 0x1600, "Mac", STAC_INTEL_MAC_V3),
3374         SND_PCI_QUIRK(0x106b, 0x1700, "Mac", STAC_INTEL_MAC_V3),
3375         SND_PCI_QUIRK(0x106b, 0x0200, "Mac", STAC_INTEL_MAC_V3),
3376         SND_PCI_QUIRK(0x106b, 0x1e00, "Mac", STAC_INTEL_MAC_V3),
3377         SND_PCI_QUIRK(0x106b, 0x1a00, "Mac", STAC_INTEL_MAC_V4),
3378         SND_PCI_QUIRK(0x106b, 0x0a00, "Mac", STAC_INTEL_MAC_V5),
3379         SND_PCI_QUIRK(0x106b, 0x2200, "Mac", STAC_INTEL_MAC_V5),
3380         {}
3381 };
3382
3383 static const struct hda_fixup stac922x_fixups[];
3384
3385 /* remap the fixup from codec SSID and apply it */
3386 static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec,
3387                                           const struct hda_fixup *fix,
3388                                           int action)
3389 {
3390         if (action != HDA_FIXUP_ACT_PRE_PROBE)
3391                 return;
3392         snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl,
3393                            stac922x_fixups);
3394         if (codec->fixup_id != STAC_INTEL_MAC_AUTO)
3395                 snd_hda_apply_fixup(codec, action);
3396 }
3397
3398 static void stac922x_fixup_intel_mac_gpio(struct hda_codec *codec,
3399                                           const struct hda_fixup *fix,
3400                                           int action)
3401 {
3402         struct sigmatel_spec *spec = codec->spec;
3403
3404         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3405                 spec->gpio_mask = spec->gpio_dir = 0x03;
3406                 spec->gpio_data = 0x03;
3407         }
3408 }
3409
3410 static const struct hda_fixup stac922x_fixups[] = {
3411         [STAC_D945_REF] = {
3412                 .type = HDA_FIXUP_PINS,
3413                 .v.pins = ref922x_pin_configs,
3414         },
3415         [STAC_D945GTP3] = {
3416                 .type = HDA_FIXUP_PINS,
3417                 .v.pins = d945gtp3_pin_configs,
3418         },
3419         [STAC_D945GTP5] = {
3420                 .type = HDA_FIXUP_PINS,
3421                 .v.pins = d945gtp5_pin_configs,
3422         },
3423         [STAC_INTEL_MAC_AUTO] = {
3424                 .type = HDA_FIXUP_FUNC,
3425                 .v.func = stac922x_fixup_intel_mac_auto,
3426         },
3427         [STAC_INTEL_MAC_V1] = {
3428                 .type = HDA_FIXUP_PINS,
3429                 .v.pins = intel_mac_v1_pin_configs,
3430                 .chained = true,
3431                 .chain_id = STAC_922X_INTEL_MAC_GPIO,
3432         },
3433         [STAC_INTEL_MAC_V2] = {
3434                 .type = HDA_FIXUP_PINS,
3435                 .v.pins = intel_mac_v2_pin_configs,
3436                 .chained = true,
3437                 .chain_id = STAC_922X_INTEL_MAC_GPIO,
3438         },
3439         [STAC_INTEL_MAC_V3] = {
3440                 .type = HDA_FIXUP_PINS,
3441                 .v.pins = intel_mac_v3_pin_configs,
3442                 .chained = true,
3443                 .chain_id = STAC_922X_INTEL_MAC_GPIO,
3444         },
3445         [STAC_INTEL_MAC_V4] = {
3446                 .type = HDA_FIXUP_PINS,
3447                 .v.pins = intel_mac_v4_pin_configs,
3448                 .chained = true,
3449                 .chain_id = STAC_922X_INTEL_MAC_GPIO,
3450         },
3451         [STAC_INTEL_MAC_V5] = {
3452                 .type = HDA_FIXUP_PINS,
3453                 .v.pins = intel_mac_v5_pin_configs,
3454                 .chained = true,
3455                 .chain_id = STAC_922X_INTEL_MAC_GPIO,
3456         },
3457         [STAC_922X_INTEL_MAC_GPIO] = {
3458                 .type = HDA_FIXUP_FUNC,
3459                 .v.func = stac922x_fixup_intel_mac_gpio,
3460         },
3461         [STAC_ECS_202] = {
3462                 .type = HDA_FIXUP_PINS,
3463                 .v.pins = ecs202_pin_configs,
3464         },
3465         [STAC_922X_DELL_D81] = {
3466                 .type = HDA_FIXUP_PINS,
3467                 .v.pins = dell_922x_d81_pin_configs,
3468         },
3469         [STAC_922X_DELL_D82] = {
3470                 .type = HDA_FIXUP_PINS,
3471                 .v.pins = dell_922x_d82_pin_configs,
3472         },
3473         [STAC_922X_DELL_M81] = {
3474                 .type = HDA_FIXUP_PINS,
3475                 .v.pins = dell_922x_m81_pin_configs,
3476         },
3477         [STAC_922X_DELL_M82] = {
3478                 .type = HDA_FIXUP_PINS,
3479                 .v.pins = dell_922x_m82_pin_configs,
3480         },
3481 };
3482
3483 static const struct hda_model_fixup stac922x_models[] = {
3484         { .id = STAC_D945_REF, .name = "ref" },
3485         { .id = STAC_D945GTP5, .name = "5stack" },
3486         { .id = STAC_D945GTP3, .name = "3stack" },
3487         { .id = STAC_INTEL_MAC_V1, .name = "intel-mac-v1" },
3488         { .id = STAC_INTEL_MAC_V2, .name = "intel-mac-v2" },
3489         { .id = STAC_INTEL_MAC_V3, .name = "intel-mac-v3" },
3490         { .id = STAC_INTEL_MAC_V4, .name = "intel-mac-v4" },
3491         { .id = STAC_INTEL_MAC_V5, .name = "intel-mac-v5" },
3492         { .id = STAC_INTEL_MAC_AUTO, .name = "intel-mac-auto" },
3493         { .id = STAC_ECS_202, .name = "ecs202" },
3494         { .id = STAC_922X_DELL_D81, .name = "dell-d81" },
3495         { .id = STAC_922X_DELL_D82, .name = "dell-d82" },
3496         { .id = STAC_922X_DELL_M81, .name = "dell-m81" },
3497         { .id = STAC_922X_DELL_M82, .name = "dell-m82" },
3498         /* for backward compatibility */
3499         { .id = STAC_INTEL_MAC_V3, .name = "macmini" },
3500         { .id = STAC_INTEL_MAC_V5, .name = "macbook" },
3501         { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro-v1" },
3502         { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro" },
3503         { .id = STAC_INTEL_MAC_V2, .name = "imac-intel" },
3504         { .id = STAC_INTEL_MAC_V3, .name = "imac-intel-20" },
3505         {}
3506 };
3507
3508 static const struct snd_pci_quirk stac922x_fixup_tbl[] = {
3509         /* SigmaTel reference board */
3510         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3511                       "DFI LanParty", STAC_D945_REF),
3512         SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3513                       "DFI LanParty", STAC_D945_REF),
3514         /* Intel 945G based systems */
3515         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
3516                       "Intel D945G", STAC_D945GTP3),
3517         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
3518                       "Intel D945G", STAC_D945GTP3),
3519         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
3520                       "Intel D945G", STAC_D945GTP3),
3521         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
3522                       "Intel D945G", STAC_D945GTP3),
3523         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
3524                       "Intel D945G", STAC_D945GTP3),
3525         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
3526                       "Intel D945G", STAC_D945GTP3),
3527         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
3528                       "Intel D945G", STAC_D945GTP3),
3529         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
3530                       "Intel D945G", STAC_D945GTP3),
3531         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
3532                       "Intel D945G", STAC_D945GTP3),
3533         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
3534                       "Intel D945G", STAC_D945GTP3),
3535         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
3536                       "Intel D945G", STAC_D945GTP3),
3537         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
3538                       "Intel D945G", STAC_D945GTP3),
3539         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
3540                       "Intel D945G", STAC_D945GTP3),
3541         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
3542                       "Intel D945G", STAC_D945GTP3),
3543         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
3544                       "Intel D945G", STAC_D945GTP3),
3545         /* Intel D945G 5-stack systems */
3546         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
3547                       "Intel D945G", STAC_D945GTP5),
3548         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
3549                       "Intel D945G", STAC_D945GTP5),
3550         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
3551                       "Intel D945G", STAC_D945GTP5),
3552         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
3553                       "Intel D945G", STAC_D945GTP5),
3554         /* Intel 945P based systems */
3555         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
3556                       "Intel D945P", STAC_D945GTP3),
3557         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
3558                       "Intel D945P", STAC_D945GTP3),
3559         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
3560                       "Intel D945P", STAC_D945GTP3),
3561         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
3562                       "Intel D945P", STAC_D945GTP3),
3563         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
3564                       "Intel D945P", STAC_D945GTP3),
3565         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
3566                       "Intel D945P", STAC_D945GTP5),
3567         /* other intel */
3568         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
3569                       "Intel D945", STAC_D945_REF),
3570         /* other systems  */
3571
3572         /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
3573         SND_PCI_QUIRK(0x8384, 0x7680, "Mac", STAC_INTEL_MAC_AUTO),
3574
3575         /* Dell systems  */
3576         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
3577                       "unknown Dell", STAC_922X_DELL_D81),
3578         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
3579                       "unknown Dell", STAC_922X_DELL_D81),
3580         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
3581                       "unknown Dell", STAC_922X_DELL_D81),
3582         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
3583                       "unknown Dell", STAC_922X_DELL_D82),
3584         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
3585                       "unknown Dell", STAC_922X_DELL_M81),
3586         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
3587                       "unknown Dell", STAC_922X_DELL_D82),
3588         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
3589                       "unknown Dell", STAC_922X_DELL_D81),
3590         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
3591                       "unknown Dell", STAC_922X_DELL_D81),
3592         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
3593                       "Dell XPS M1210", STAC_922X_DELL_M82),
3594         /* ECS/PC Chips boards */
3595         SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
3596                       "ECS/PC chips", STAC_ECS_202),
3597         {} /* terminator */
3598 };
3599
3600 static const struct hda_pintbl ref927x_pin_configs[] = {
3601         { 0x0a, 0x02214020 },
3602         { 0x0b, 0x02a19080 },
3603         { 0x0c, 0x0181304e },
3604         { 0x0d, 0x01014010 },
3605         { 0x0e, 0x01a19040 },
3606         { 0x0f, 0x01011012 },
3607         { 0x10, 0x01016011 },
3608         { 0x11, 0x0101201f },
3609         { 0x12, 0x183301f0 },
3610         { 0x13, 0x18a001f0 },
3611         { 0x14, 0x18a001f0 },
3612         { 0x21, 0x01442070 },
3613         { 0x22, 0x01c42190 },
3614         { 0x23, 0x40000100 },
3615         {}
3616 };
3617
3618 static const struct hda_pintbl d965_3st_pin_configs[] = {
3619         { 0x0a, 0x0221401f },
3620         { 0x0b, 0x02a19120 },
3621         { 0x0c, 0x40000100 },
3622         { 0x0d, 0x01014011 },
3623         { 0x0e, 0x01a19021 },
3624         { 0x0f, 0x01813024 },
3625         { 0x10, 0x40000100 },
3626         { 0x11, 0x40000100 },
3627         { 0x12, 0x40000100 },
3628         { 0x13, 0x40000100 },
3629         { 0x14, 0x40000100 },
3630         { 0x21, 0x40000100 },
3631         { 0x22, 0x40000100 },
3632         { 0x23, 0x40000100 },
3633         {}
3634 };
3635
3636 static const struct hda_pintbl d965_5st_pin_configs[] = {
3637         { 0x0a, 0x02214020 },
3638         { 0x0b, 0x02a19080 },
3639         { 0x0c, 0x0181304e },
3640         { 0x0d, 0x01014010 },
3641         { 0x0e, 0x01a19040 },
3642         { 0x0f, 0x01011012 },
3643         { 0x10, 0x01016011 },
3644         { 0x11, 0x40000100 },
3645         { 0x12, 0x40000100 },
3646         { 0x13, 0x40000100 },
3647         { 0x14, 0x40000100 },
3648         { 0x21, 0x01442070 },
3649         { 0x22, 0x40000100 },
3650         { 0x23, 0x40000100 },
3651         {}
3652 };
3653
3654 static const struct hda_pintbl d965_5st_no_fp_pin_configs[] = {
3655         { 0x0a, 0x40000100 },
3656         { 0x0b, 0x40000100 },
3657         { 0x0c, 0x0181304e },
3658         { 0x0d, 0x01014010 },
3659         { 0x0e, 0x01a19040 },
3660         { 0x0f, 0x01011012 },
3661         { 0x10, 0x01016011 },
3662         { 0x11, 0x40000100 },
3663         { 0x12, 0x40000100 },
3664         { 0x13, 0x40000100 },
3665         { 0x14, 0x40000100 },
3666         { 0x21, 0x01442070 },
3667         { 0x22, 0x40000100 },
3668         { 0x23, 0x40000100 },
3669         {}
3670 };
3671
3672 static const struct hda_pintbl dell_3st_pin_configs[] = {
3673         { 0x0a, 0x02211230 },
3674         { 0x0b, 0x02a11220 },
3675         { 0x0c, 0x01a19040 },
3676         { 0x0d, 0x01114210 },
3677         { 0x0e, 0x01111212 },
3678         { 0x0f, 0x01116211 },
3679         { 0x10, 0x01813050 },
3680         { 0x11, 0x01112214 },
3681         { 0x12, 0x403003fa },
3682         { 0x13, 0x90a60040 },
3683         { 0x14, 0x90a60040 },
3684         { 0x21, 0x404003fb },
3685         { 0x22, 0x40c003fc },
3686         { 0x23, 0x40000100 },
3687         {}
3688 };
3689
3690 static void stac927x_fixup_ref_no_jd(struct hda_codec *codec,
3691                                      const struct hda_fixup *fix, int action)
3692 {
3693         /* no jack detecion for ref-no-jd model */
3694         if (action == HDA_FIXUP_ACT_PRE_PROBE)
3695                 codec->no_jack_detect = 1;
3696 }
3697
3698 static void stac927x_fixup_ref(struct hda_codec *codec,
3699                                const struct hda_fixup *fix, int action)
3700 {
3701         struct sigmatel_spec *spec = codec->spec;
3702
3703         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3704                 snd_hda_apply_pincfgs(codec, ref927x_pin_configs);
3705                 spec->eapd_mask = spec->gpio_mask = 0;
3706                 spec->gpio_dir = spec->gpio_data = 0;
3707         }
3708 }
3709
3710 static void stac927x_fixup_dell_dmic(struct hda_codec *codec,
3711                                      const struct hda_fixup *fix, int action)
3712 {
3713         struct sigmatel_spec *spec = codec->spec;
3714
3715         if (action != HDA_FIXUP_ACT_PRE_PROBE)
3716                 return;
3717
3718         if (codec->subsystem_id != 0x1028022f) {
3719                 /* GPIO2 High = Enable EAPD */
3720                 spec->eapd_mask = spec->gpio_mask = 0x04;
3721                 spec->gpio_dir = spec->gpio_data = 0x04;
3722         }
3723
3724         snd_hda_add_verbs(codec, dell_3st_core_init);
3725         spec->volknob_init = 1;
3726 }
3727
3728 static void stac927x_fixup_volknob(struct hda_codec *codec,
3729                                    const struct hda_fixup *fix, int action)
3730 {
3731         struct sigmatel_spec *spec = codec->spec;
3732
3733         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3734                 snd_hda_add_verbs(codec, stac927x_volknob_core_init);
3735                 spec->volknob_init = 1;
3736         }
3737 }
3738
3739 static const struct hda_fixup stac927x_fixups[] = {
3740         [STAC_D965_REF_NO_JD] = {
3741                 .type = HDA_FIXUP_FUNC,
3742                 .v.func = stac927x_fixup_ref_no_jd,
3743                 .chained = true,
3744                 .chain_id = STAC_D965_REF,
3745         },
3746         [STAC_D965_REF] = {
3747                 .type = HDA_FIXUP_FUNC,
3748                 .v.func = stac927x_fixup_ref,
3749         },
3750         [STAC_D965_3ST] = {
3751                 .type = HDA_FIXUP_PINS,
3752                 .v.pins = d965_3st_pin_configs,
3753                 .chained = true,
3754                 .chain_id = STAC_D965_VERBS,
3755         },
3756         [STAC_D965_5ST] = {
3757                 .type = HDA_FIXUP_PINS,
3758                 .v.pins = d965_5st_pin_configs,
3759                 .chained = true,
3760                 .chain_id = STAC_D965_VERBS,
3761         },
3762         [STAC_D965_VERBS] = {
3763                 .type = HDA_FIXUP_VERBS,
3764                 .v.verbs = d965_core_init,
3765         },
3766         [STAC_D965_5ST_NO_FP] = {
3767                 .type = HDA_FIXUP_PINS,
3768                 .v.pins = d965_5st_no_fp_pin_configs,
3769         },
3770         [STAC_DELL_3ST] = {
3771                 .type = HDA_FIXUP_PINS,
3772                 .v.pins = dell_3st_pin_configs,
3773                 .chained = true,
3774                 .chain_id = STAC_927X_DELL_DMIC,
3775         },
3776         [STAC_DELL_BIOS] = {
3777                 .type = HDA_FIXUP_PINS,
3778                 .v.pins = (const struct hda_pintbl[]) {
3779                         /* correct the front output jack as a hp out */
3780                         { 0x0f, 0x0221101f },
3781                         /* correct the front input jack as a mic */
3782                         { 0x0e, 0x02a79130 },
3783                         {}
3784                 },
3785                 .chained = true,
3786                 .chain_id = STAC_927X_DELL_DMIC,
3787         },
3788         [STAC_DELL_BIOS_AMIC] = {
3789                 .type = HDA_FIXUP_PINS,
3790                 .v.pins = (const struct hda_pintbl[]) {
3791                         /* configure the analog microphone on some laptops */
3792                         { 0x0c, 0x90a79130 },
3793                         {}
3794                 },
3795                 .chained = true,
3796                 .chain_id = STAC_DELL_BIOS,
3797         },
3798         [STAC_DELL_BIOS_SPDIF] = {
3799                 .type = HDA_FIXUP_PINS,
3800                 .v.pins = (const struct hda_pintbl[]) {
3801                         /* correct the device field to SPDIF out */
3802                         { 0x21, 0x01442070 },
3803                         {}
3804                 },
3805                 .chained = true,
3806                 .chain_id = STAC_DELL_BIOS,
3807         },
3808         [STAC_927X_DELL_DMIC] = {
3809                 .type = HDA_FIXUP_FUNC,
3810                 .v.func = stac927x_fixup_dell_dmic,
3811         },
3812         [STAC_927X_VOLKNOB] = {
3813                 .type = HDA_FIXUP_FUNC,
3814                 .v.func = stac927x_fixup_volknob,
3815         },
3816 };
3817
3818 static const struct hda_model_fixup stac927x_models[] = {
3819         { .id = STAC_D965_REF_NO_JD, .name = "ref-no-jd" },
3820         { .id = STAC_D965_REF, .name = "ref" },
3821         { .id = STAC_D965_3ST, .name = "3stack" },
3822         { .id = STAC_D965_5ST, .name = "5stack" },
3823         { .id = STAC_D965_5ST_NO_FP, .name = "5stack-no-fp" },
3824         { .id = STAC_DELL_3ST, .name = "dell-3stack" },
3825         { .id = STAC_DELL_BIOS, .name = "dell-bios" },
3826         { .id = STAC_DELL_BIOS_AMIC, .name = "dell-bios-amic" },
3827         { .id = STAC_927X_VOLKNOB, .name = "volknob" },
3828         {}
3829 };
3830
3831 static const struct snd_pci_quirk stac927x_fixup_tbl[] = {
3832         /* SigmaTel reference board */
3833         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3834                       "DFI LanParty", STAC_D965_REF),
3835         SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3836                       "DFI LanParty", STAC_D965_REF),
3837          /* Intel 946 based systems */
3838         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
3839         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
3840         /* 965 based 3 stack systems */
3841         SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
3842                            "Intel D965", STAC_D965_3ST),
3843         SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
3844                            "Intel D965", STAC_D965_3ST),
3845         /* Dell 3 stack systems */
3846         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
3847         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01ed, "Dell     ", STAC_DELL_3ST),
3848         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01f4, "Dell     ", STAC_DELL_3ST),
3849         /* Dell 3 stack systems with verb table in BIOS */
3850         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
3851         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
3852         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0227, "Dell Vostro 1400  ", STAC_DELL_BIOS),
3853         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x022e, "Dell     ", STAC_DELL_BIOS_SPDIF),
3854         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
3855         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0242, "Dell     ", STAC_DELL_BIOS),
3856         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0243, "Dell     ", STAC_DELL_BIOS),
3857         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x02ff, "Dell     ", STAC_DELL_BIOS),
3858         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0209, "Dell XPS 1330", STAC_DELL_BIOS_SPDIF),
3859         /* 965 based 5 stack systems */
3860         SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
3861                            "Intel D965", STAC_D965_5ST),
3862         SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
3863                            "Intel D965", STAC_D965_5ST),
3864         /* volume-knob fixes */
3865         SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
3866         {} /* terminator */
3867 };
3868
3869 static const struct hda_pintbl ref9205_pin_configs[] = {
3870         { 0x0a, 0x40000100 },
3871         { 0x0b, 0x40000100 },
3872         { 0x0c, 0x01016011 },
3873         { 0x0d, 0x01014010 },
3874         { 0x0e, 0x01813122 },
3875         { 0x0f, 0x01a19021 },
3876         { 0x14, 0x01019020 },
3877         { 0x16, 0x40000100 },
3878         { 0x17, 0x90a000f0 },
3879         { 0x18, 0x90a000f0 },
3880         { 0x21, 0x01441030 },
3881         { 0x22, 0x01c41030 },
3882         {}
3883 };
3884
3885 /*
3886     STAC 9205 pin configs for
3887     102801F1
3888     102801F2
3889     102801FC
3890     102801FD
3891     10280204
3892     1028021F
3893     10280228 (Dell Vostro 1500)
3894     10280229 (Dell Vostro 1700)
3895 */
3896 static const struct hda_pintbl dell_9205_m42_pin_configs[] = {
3897         { 0x0a, 0x0321101F },
3898         { 0x0b, 0x03A11020 },
3899         { 0x0c, 0x400003FA },
3900         { 0x0d, 0x90170310 },
3901         { 0x0e, 0x400003FB },
3902         { 0x0f, 0x400003FC },
3903         { 0x14, 0x400003FD },
3904         { 0x16, 0x40F000F9 },
3905         { 0x17, 0x90A60330 },
3906         { 0x18, 0x400003FF },
3907         { 0x21, 0x0144131F },
3908         { 0x22, 0x40C003FE },
3909         {}
3910 };
3911
3912 /*
3913     STAC 9205 pin configs for
3914     102801F9
3915     102801FA
3916     102801FE
3917     102801FF (Dell Precision M4300)
3918     10280206
3919     10280200
3920     10280201
3921 */
3922 static const struct hda_pintbl dell_9205_m43_pin_configs[] = {
3923         { 0x0a, 0x0321101f },
3924         { 0x0b, 0x03a11020 },
3925         { 0x0c, 0x90a70330 },
3926         { 0x0d, 0x90170310 },
3927         { 0x0e, 0x400000fe },
3928         { 0x0f, 0x400000ff },
3929         { 0x14, 0x400000fd },
3930         { 0x16, 0x40f000f9 },
3931         { 0x17, 0x400000fa },
3932         { 0x18, 0x400000fc },
3933         { 0x21, 0x0144131f },
3934         { 0x22, 0x40c003f8 },
3935         /* Enable SPDIF in/out */
3936         { 0x1f, 0x01441030 },
3937         { 0x20, 0x1c410030 },
3938         {}
3939 };
3940
3941 static const struct hda_pintbl dell_9205_m44_pin_configs[] = {
3942         { 0x0a, 0x0421101f },
3943         { 0x0b, 0x04a11020 },
3944         { 0x0c, 0x400003fa },
3945         { 0x0d, 0x90170310 },
3946         { 0x0e, 0x400003fb },
3947         { 0x0f, 0x400003fc },
3948         { 0x14, 0x400003fd },
3949         { 0x16, 0x400003f9 },
3950         { 0x17, 0x90a60330 },
3951         { 0x18, 0x400003ff },
3952         { 0x21, 0x01441340 },
3953         { 0x22, 0x40c003fe },
3954         {}
3955 };
3956
3957 static void stac9205_fixup_ref(struct hda_codec *codec,
3958                                const struct hda_fixup *fix, int action)
3959 {
3960         struct sigmatel_spec *spec = codec->spec;
3961
3962         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3963                 snd_hda_apply_pincfgs(codec, ref9205_pin_configs);
3964                 /* SPDIF-In enabled */
3965                 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0;
3966         }
3967 }
3968
3969 static void stac9205_fixup_dell_m43(struct hda_codec *codec,
3970                                     const struct hda_fixup *fix, int action)
3971 {
3972         struct sigmatel_spec *spec = codec->spec;
3973         struct hda_jack_tbl *jack;
3974
3975         if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3976                 snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs);
3977
3978                 /* Enable unsol response for GPIO4/Dock HP connection */
3979                 snd_hda_codec_write_cache(codec, codec->afg, 0,
3980                         AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
3981                 snd_hda_jack_detect_enable_callback(codec, codec->afg,
3982                                                     STAC_VREF_EVENT,
3983                                                     stac_vref_event);
3984                 jack = snd_hda_jack_tbl_get(codec, codec->afg);
3985                 if (jack)
3986                         jack->private_data = 0x01;
3987
3988                 spec->gpio_dir = 0x0b;
3989                 spec->eapd_mask = 0x01;
3990                 spec->gpio_mask = 0x1b;
3991                 spec->gpio_mute = 0x10;
3992                 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
3993                  * GPIO3 Low = DRM
3994                  */
3995                 spec->gpio_data = 0x01;
3996         }
3997 }
3998
3999 static void stac9205_fixup_eapd(struct hda_codec *codec,
4000                                 const struct hda_fixup *fix, int action)
4001 {
4002         struct sigmatel_spec *spec = codec->spec;
4003
4004         if (action == HDA_FIXUP_ACT_PRE_PROBE)
4005                 spec->eapd_switch = 0;
4006 }
4007
4008 static const struct hda_fixup stac9205_fixups[] = {
4009         [STAC_9205_REF] = {
4010                 .type = HDA_FIXUP_FUNC,
4011                 .v.func = stac9205_fixup_ref,
4012         },
4013         [STAC_9205_DELL_M42] = {
4014                 .type = HDA_FIXUP_PINS,
4015                 .v.pins = dell_9205_m42_pin_configs,
4016         },
4017         [STAC_9205_DELL_M43] = {
4018                 .type = HDA_FIXUP_FUNC,
4019                 .v.func = stac9205_fixup_dell_m43,
4020         },
4021         [STAC_9205_DELL_M44] = {
4022                 .type = HDA_FIXUP_PINS,
4023                 .v.pins = dell_9205_m44_pin_configs,
4024         },
4025         [STAC_9205_EAPD] = {
4026                 .type = HDA_FIXUP_FUNC,
4027                 .v.func = stac9205_fixup_eapd,
4028         },
4029         {}
4030 };
4031
4032 static const struct hda_model_fixup stac9205_models[] = {
4033         { .id = STAC_9205_REF, .name = "ref" },
4034         { .id = STAC_9205_DELL_M42, .name = "dell-m42" },
4035         { .id = STAC_9205_DELL_M43, .name = "dell-m43" },
4036         { .id = STAC_9205_DELL_M44, .name = "dell-m44" },
4037         { .id = STAC_9205_EAPD, .name = "eapd" },
4038         {}
4039 };
4040
4041 static const struct snd_pci_quirk stac9205_fixup_tbl[] = {
4042         /* SigmaTel reference board */
4043         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
4044                       "DFI LanParty", STAC_9205_REF),
4045         SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
4046                       "SigmaTel", STAC_9205_REF),
4047         SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
4048                       "DFI LanParty", STAC_9205_REF),
4049         /* Dell */
4050         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
4051                       "unknown Dell", STAC_9205_DELL_M42),
4052         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
4053                       "unknown Dell", STAC_9205_DELL_M42),
4054         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
4055                       "Dell Precision", STAC_9205_DELL_M43),
4056         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
4057                       "Dell Precision", STAC_9205_DELL_M43),
4058         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
4059                       "Dell Precision", STAC_9205_DELL_M43),
4060         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
4061                       "unknown Dell", STAC_9205_DELL_M42),
4062         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
4063                       "unknown Dell", STAC_9205_DELL_M42),
4064         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
4065                       "Dell Precision", STAC_9205_DELL_M43),
4066         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
4067                       "Dell Precision M4300", STAC_9205_DELL_M43),
4068         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
4069                       "unknown Dell", STAC_9205_DELL_M42),
4070         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
4071                       "Dell Precision", STAC_9205_DELL_M43),
4072         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
4073                       "Dell Precision", STAC_9205_DELL_M43),
4074         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
4075                       "Dell Precision", STAC_9205_DELL_M43),
4076         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
4077                       "Dell Inspiron", STAC_9205_DELL_M44),
4078         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
4079                       "Dell Vostro 1500", STAC_9205_DELL_M42),
4080         SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
4081                       "Dell Vostro 1700", STAC_9205_DELL_M42),
4082         /* Gateway */
4083         SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
4084         SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
4085         {} /* terminator */
4086 };
4087
4088 static int stac_parse_auto_config(struct hda_codec *codec)
4089 {
4090         struct sigmatel_spec *spec = codec->spec;
4091         int err;
4092         int flags = 0;
4093
4094         if (spec->headset_jack)
4095                 flags |= HDA_PINCFG_HEADSET_MIC;
4096
4097         err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, flags);
4098         if (err < 0)
4099                 return err;
4100
4101         /* add hooks */
4102         spec->gen.pcm_playback_hook = stac_playback_pcm_hook;
4103         spec->gen.pcm_capture_hook = stac_capture_pcm_hook;
4104
4105         spec->gen.automute_hook = stac_update_outputs;
4106         spec->gen.hp_automute_hook = stac_hp_automute;
4107         spec->gen.line_automute_hook = stac_line_automute;
4108         spec->gen.mic_autoswitch_hook = stac_mic_autoswitch;
4109
4110         err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
4111         if (err < 0)
4112                 return err;
4113
4114         /* minimum value is actually mute */
4115         spec->gen.vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
4116
4117         /* setup analog beep controls */
4118         if (spec->anabeep_nid > 0) {
4119                 err = stac_auto_create_beep_ctls(codec,
4120                                                  spec->anabeep_nid);
4121                 if (err < 0)
4122                         return err;
4123         }
4124
4125         /* setup digital beep controls and input device */
4126 #ifdef CONFIG_SND_HDA_INPUT_BEEP
4127         if (spec->gen.beep_nid) {
4128                 hda_nid_t nid = spec->gen.beep_nid;
4129                 unsigned int caps;
4130
4131                 err = stac_auto_create_beep_ctls(codec, nid);
4132                 if (err < 0)
4133                         return err;
4134                 if (codec->beep) {
4135                         /* IDT/STAC codecs have linear beep tone parameter */
4136                         codec->beep->linear_tone = spec->linear_tone_beep;
4137                         /* if no beep switch is available, make its own one */
4138                         caps = query_amp_caps(codec, nid, HDA_OUTPUT);
4139                         if (!(caps & AC_AMPCAP_MUTE)) {
4140                                 err = stac_beep_switch_ctl(codec);
4141                                 if (err < 0)
4142                                         return err;
4143                         }
4144                 }
4145         }
4146 #endif
4147
4148         if (spec->gpio_led)
4149                 spec->gen.vmaster_mute.hook = stac_vmaster_hook;
4150
4151         if (spec->aloopback_ctl &&
4152             snd_hda_get_bool_hint(codec, "loopback") == 1) {
4153                 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, spec->aloopback_ctl))
4154                         return -ENOMEM;
4155         }
4156
4157         if (spec->have_spdif_mux) {
4158                 err = stac_create_spdif_mux_ctls(codec);
4159                 if (err < 0)
4160                         return err;
4161         }
4162
4163         stac_init_power_map(codec);
4164
4165         return 0;
4166 }
4167
4168
4169 static int stac_init(struct hda_codec *codec)
4170 {
4171         struct sigmatel_spec *spec = codec->spec;
4172         int i;
4173
4174         /* override some hints */
4175         stac_store_hints(codec);
4176
4177         /* set up GPIO */
4178         /* turn on EAPD statically when spec->eapd_switch isn't set.
4179          * otherwise, unsol event will turn it on/off dynamically
4180          */
4181         if (!spec->eapd_switch)
4182                 spec->gpio_data |= spec->eapd_mask;
4183         stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
4184
4185         snd_hda_gen_init(codec);
4186
4187         /* sync the power-map */
4188         if (spec->num_pwrs)
4189                 snd_hda_codec_write(codec, codec->afg, 0,
4190                                     AC_VERB_IDT_SET_POWER_MAP,
4191                                     spec->power_map_bits);
4192
4193         /* power down inactive ADCs */
4194         if (spec->powerdown_adcs) {
4195                 for (i = 0; i < spec->gen.num_all_adcs; i++) {
4196                         if (spec->active_adcs & (1 << i))
4197                                 continue;
4198                         snd_hda_codec_write(codec, spec->gen.all_adcs[i], 0,
4199                                             AC_VERB_SET_POWER_STATE,
4200                                             AC_PWRST_D3);
4201                 }
4202         }
4203
4204         return 0;
4205 }
4206
4207 static void stac_shutup(struct hda_codec *codec)
4208 {
4209         struct sigmatel_spec *spec = codec->spec;
4210
4211         snd_hda_shutup_pins(codec);
4212
4213         if (spec->eapd_mask)
4214                 stac_gpio_set(codec, spec->gpio_mask,
4215                                 spec->gpio_dir, spec->gpio_data &
4216                                 ~spec->eapd_mask);
4217 }
4218
4219 #define stac_free       snd_hda_gen_free
4220
4221 #ifdef CONFIG_PROC_FS
4222 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4223                                struct hda_codec *codec, hda_nid_t nid)
4224 {
4225         if (nid == codec->afg)
4226                 snd_iprintf(buffer, "Power-Map: 0x%02x\n", 
4227                             snd_hda_codec_read(codec, nid, 0,
4228                                                AC_VERB_IDT_GET_POWER_MAP, 0));
4229 }
4230
4231 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4232                                   struct hda_codec *codec,
4233                                   unsigned int verb)
4234 {
4235         snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4236                     snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4237 }
4238
4239 /* stac92hd71bxx, stac92hd73xx */
4240 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4241                                  struct hda_codec *codec, hda_nid_t nid)
4242 {
4243         stac92hd_proc_hook(buffer, codec, nid);
4244         if (nid == codec->afg)
4245                 analog_loop_proc_hook(buffer, codec, 0xfa0);
4246 }
4247
4248 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4249                                struct hda_codec *codec, hda_nid_t nid)
4250 {
4251         if (nid == codec->afg)
4252                 analog_loop_proc_hook(buffer, codec, 0xfe0);
4253 }
4254
4255 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4256                                struct hda_codec *codec, hda_nid_t nid)
4257 {
4258         if (nid == codec->afg)
4259                 analog_loop_proc_hook(buffer, codec, 0xfeb);
4260 }
4261 #else
4262 #define stac92hd_proc_hook      NULL
4263 #define stac92hd7x_proc_hook    NULL
4264 #define stac9205_proc_hook      NULL
4265 #define stac927x_proc_hook      NULL
4266 #endif
4267
4268 #ifdef CONFIG_PM
4269 static int stac_suspend(struct hda_codec *codec)
4270 {
4271         stac_shutup(codec);
4272         return 0;
4273 }
4274 #else
4275 #define stac_suspend            NULL
4276 #endif /* CONFIG_PM */
4277
4278 static const struct hda_codec_ops stac_patch_ops = {
4279         .build_controls = snd_hda_gen_build_controls,
4280         .build_pcms = snd_hda_gen_build_pcms,
4281         .init = stac_init,
4282         .free = stac_free,
4283         .unsol_event = snd_hda_jack_unsol_event,
4284 #ifdef CONFIG_PM
4285         .suspend = stac_suspend,
4286 #endif
4287         .reboot_notify = stac_shutup,
4288 };
4289
4290 static int alloc_stac_spec(struct hda_codec *codec)
4291 {
4292         struct sigmatel_spec *spec;
4293
4294         spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4295         if (!spec)
4296                 return -ENOMEM;
4297         snd_hda_gen_spec_init(&spec->gen);
4298         codec->spec = spec;
4299         codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */
4300         return 0;
4301 }
4302
4303 static int patch_stac9200(struct hda_codec *codec)
4304 {
4305         struct sigmatel_spec *spec;
4306         int err;
4307
4308         err = alloc_stac_spec(codec);
4309         if (err < 0)
4310                 return err;
4311
4312         spec = codec->spec;
4313         spec->linear_tone_beep = 1;
4314         spec->gen.own_eapd_ctl = 1;
4315
4316         codec->patch_ops = stac_patch_ops;
4317         codec->power_filter = snd_hda_codec_eapd_power_filter;
4318
4319         snd_hda_add_verbs(codec, stac9200_eapd_init);
4320
4321         snd_hda_pick_fixup(codec, stac9200_models, stac9200_fixup_tbl,
4322                            stac9200_fixups);
4323         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4324
4325         err = stac_parse_auto_config(codec);
4326         if (err < 0) {
4327                 stac_free(codec);
4328                 return err;
4329         }
4330
4331         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4332
4333         return 0;
4334 }
4335
4336 static int patch_stac925x(struct hda_codec *codec)
4337 {
4338         struct sigmatel_spec *spec;
4339         int err;
4340
4341         err = alloc_stac_spec(codec);
4342         if (err < 0)
4343                 return err;
4344
4345         spec = codec->spec;
4346         spec->linear_tone_beep = 1;
4347         spec->gen.own_eapd_ctl = 1;
4348
4349         codec->patch_ops = stac_patch_ops;
4350
4351         snd_hda_add_verbs(codec, stac925x_core_init);
4352
4353         snd_hda_pick_fixup(codec, stac925x_models, stac925x_fixup_tbl,
4354                            stac925x_fixups);
4355         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4356
4357         err = stac_parse_auto_config(codec);
4358         if (err < 0) {
4359                 stac_free(codec);
4360                 return err;
4361         }
4362
4363         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4364
4365         return 0;
4366 }
4367
4368 static int patch_stac92hd73xx(struct hda_codec *codec)
4369 {
4370         struct sigmatel_spec *spec;
4371         int err;
4372         int num_dacs;
4373
4374         err = alloc_stac_spec(codec);
4375         if (err < 0)
4376                 return err;
4377
4378         spec = codec->spec;
4379         spec->linear_tone_beep = 0;
4380         spec->gen.mixer_nid = 0x1d;
4381         spec->have_spdif_mux = 1;
4382
4383         num_dacs = snd_hda_get_num_conns(codec, 0x0a) - 1;
4384         if (num_dacs < 3 || num_dacs > 5) {
4385                 printk(KERN_WARNING "hda_codec: Could not determine "
4386                        "number of channels defaulting to DAC count\n");
4387                 num_dacs = 5;
4388         }
4389
4390         switch (num_dacs) {
4391         case 0x3: /* 6 Channel */
4392                 spec->aloopback_ctl = &stac92hd73xx_6ch_loopback;
4393                 break;
4394         case 0x4: /* 8 Channel */
4395                 spec->aloopback_ctl = &stac92hd73xx_8ch_loopback;
4396                 break;
4397         case 0x5: /* 10 Channel */
4398                 spec->aloopback_ctl = &stac92hd73xx_10ch_loopback;
4399                 break;
4400         }
4401
4402         spec->aloopback_mask = 0x01;
4403         spec->aloopback_shift = 8;
4404
4405         spec->gen.beep_nid = 0x1c; /* digital beep */
4406
4407         /* GPIO0 High = Enable EAPD */
4408         spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4409         spec->gpio_data = 0x01;
4410
4411         spec->eapd_switch = 1;
4412
4413         spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4414         spec->pwr_nids = stac92hd73xx_pwr_nids;
4415
4416         spec->gen.own_eapd_ctl = 1;
4417         spec->gen.power_down_unused = 1;
4418
4419         codec->patch_ops = stac_patch_ops;
4420
4421         snd_hda_pick_fixup(codec, stac92hd73xx_models, stac92hd73xx_fixup_tbl,
4422                            stac92hd73xx_fixups);
4423         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4424
4425         if (!spec->volknob_init)
4426                 snd_hda_add_verbs(codec, stac92hd73xx_core_init);
4427
4428         err = stac_parse_auto_config(codec);
4429         if (err < 0) {
4430                 stac_free(codec);
4431                 return err;
4432         }
4433
4434         /* Don't GPIO-mute speakers if there are no internal speakers, because
4435          * the GPIO might be necessary for Headphone
4436          */
4437         if (spec->eapd_switch && !has_builtin_speaker(codec))
4438                 spec->eapd_switch = 0;
4439
4440         codec->proc_widget_hook = stac92hd7x_proc_hook;
4441
4442         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4443
4444         return 0;
4445 }
4446
4447 static void stac_setup_gpio(struct hda_codec *codec)
4448 {
4449         struct sigmatel_spec *spec = codec->spec;
4450
4451         spec->gpio_mask |= spec->eapd_mask;
4452         if (spec->gpio_led) {
4453                 if (!spec->vref_mute_led_nid) {
4454                         spec->gpio_mask |= spec->gpio_led;
4455                         spec->gpio_dir |= spec->gpio_led;
4456                         spec->gpio_data |= spec->gpio_led;
4457                 } else {
4458                         codec->power_filter = stac_vref_led_power_filter;
4459                 }
4460         }
4461
4462         if (spec->mic_mute_led_gpio) {
4463                 spec->gpio_mask |= spec->mic_mute_led_gpio;
4464                 spec->gpio_dir |= spec->mic_mute_led_gpio;
4465                 spec->mic_mute_led_on = true;
4466                 spec->gpio_data |= spec->mic_mute_led_gpio;
4467
4468                 spec->gen.cap_sync_hook = stac_capture_led_hook;
4469         }
4470 }
4471
4472 static int patch_stac92hd83xxx(struct hda_codec *codec)
4473 {
4474         struct sigmatel_spec *spec;
4475         int err;
4476
4477         err = alloc_stac_spec(codec);
4478         if (err < 0)
4479                 return err;
4480
4481         codec->epss = 0; /* longer delay needed for D3 */
4482
4483         spec = codec->spec;
4484         spec->linear_tone_beep = 0;
4485         spec->gen.own_eapd_ctl = 1;
4486         spec->gen.power_down_unused = 1;
4487         spec->gen.mixer_nid = 0x1b;
4488
4489         spec->gen.beep_nid = 0x21; /* digital beep */
4490         spec->pwr_nids = stac92hd83xxx_pwr_nids;
4491         spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4492         spec->default_polarity = -1; /* no default cfg */
4493
4494         codec->patch_ops = stac_patch_ops;
4495
4496         snd_hda_add_verbs(codec, stac92hd83xxx_core_init);
4497
4498         snd_hda_pick_fixup(codec, stac92hd83xxx_models, stac92hd83xxx_fixup_tbl,
4499                            stac92hd83xxx_fixups);
4500         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4501
4502         stac_setup_gpio(codec);
4503
4504         err = stac_parse_auto_config(codec);
4505         if (err < 0) {
4506                 stac_free(codec);
4507                 return err;
4508         }
4509
4510         codec->proc_widget_hook = stac92hd_proc_hook;
4511
4512         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4513
4514         return 0;
4515 }
4516
4517 static const hda_nid_t stac92hd95_pwr_nids[] = {
4518         0x0a, 0x0b, 0x0c, 0x0d
4519 };
4520
4521 static int patch_stac92hd95(struct hda_codec *codec)
4522 {
4523         struct sigmatel_spec *spec;
4524         int err;
4525
4526         err = alloc_stac_spec(codec);
4527         if (err < 0)
4528                 return err;
4529
4530         codec->epss = 0; /* longer delay needed for D3 */
4531
4532         spec = codec->spec;
4533         spec->linear_tone_beep = 0;
4534         spec->gen.own_eapd_ctl = 1;
4535         spec->gen.power_down_unused = 1;
4536
4537         spec->gen.beep_nid = 0x19; /* digital beep */
4538         spec->pwr_nids = stac92hd95_pwr_nids;
4539         spec->num_pwrs = ARRAY_SIZE(stac92hd95_pwr_nids);
4540         spec->default_polarity = -1; /* no default cfg */
4541
4542         codec->patch_ops = stac_patch_ops;
4543
4544         err = stac_parse_auto_config(codec);
4545         if (err < 0) {
4546                 stac_free(codec);
4547                 return err;
4548         }
4549
4550         codec->proc_widget_hook = stac92hd_proc_hook;
4551
4552         return 0;
4553 }
4554
4555 static int patch_stac92hd71bxx(struct hda_codec *codec)
4556 {
4557         struct sigmatel_spec *spec;
4558         const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
4559         int err;
4560
4561         err = alloc_stac_spec(codec);
4562         if (err < 0)
4563                 return err;
4564
4565         spec = codec->spec;
4566         spec->linear_tone_beep = 0;
4567         spec->gen.own_eapd_ctl = 1;
4568         spec->gen.power_down_unused = 1;
4569         spec->gen.mixer_nid = 0x17;
4570         spec->have_spdif_mux = 1;
4571
4572         codec->patch_ops = stac_patch_ops;
4573
4574         /* GPIO0 = EAPD */
4575         spec->gpio_mask = 0x01;
4576         spec->gpio_dir = 0x01;
4577         spec->gpio_data = 0x01;
4578
4579         switch (codec->vendor_id) {
4580         case 0x111d76b6: /* 4 Port without Analog Mixer */
4581         case 0x111d76b7:
4582                 unmute_init++;
4583                 break;
4584         case 0x111d7608: /* 5 Port with Analog Mixer */
4585                 if ((codec->revision_id & 0xf) == 0 ||
4586                     (codec->revision_id & 0xf) == 1)
4587                         spec->stream_delay = 40; /* 40 milliseconds */
4588
4589                 /* disable VSW */
4590                 unmute_init++;
4591                 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
4592                 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
4593                 break;
4594         case 0x111d7603: /* 6 Port with Analog Mixer */
4595                 if ((codec->revision_id & 0xf) == 1)
4596                         spec->stream_delay = 40; /* 40 milliseconds */
4597
4598                 break;
4599         }
4600
4601         if (get_wcaps_type(get_wcaps(codec, 0x28)) == AC_WID_VOL_KNB)
4602                 snd_hda_add_verbs(codec, stac92hd71bxx_core_init);
4603
4604         if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
4605                 snd_hda_sequence_write_cache(codec, unmute_init);
4606
4607         spec->aloopback_ctl = &stac92hd71bxx_loopback;
4608         spec->aloopback_mask = 0x50;
4609         spec->aloopback_shift = 0;
4610
4611         spec->powerdown_adcs = 1;
4612         spec->gen.beep_nid = 0x26; /* digital beep */
4613         spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4614         spec->pwr_nids = stac92hd71bxx_pwr_nids;
4615
4616         snd_hda_pick_fixup(codec, stac92hd71bxx_models, stac92hd71bxx_fixup_tbl,
4617                            stac92hd71bxx_fixups);
4618         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4619
4620         stac_setup_gpio(codec);
4621
4622         err = stac_parse_auto_config(codec);
4623         if (err < 0) {
4624                 stac_free(codec);
4625                 return err;
4626         }
4627
4628         codec->proc_widget_hook = stac92hd7x_proc_hook;
4629
4630         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4631
4632         return 0;
4633 }
4634
4635 static int patch_stac922x(struct hda_codec *codec)
4636 {
4637         struct sigmatel_spec *spec;
4638         int err;
4639
4640         err = alloc_stac_spec(codec);
4641         if (err < 0)
4642                 return err;
4643
4644         spec = codec->spec;
4645         spec->linear_tone_beep = 1;
4646         spec->gen.own_eapd_ctl = 1;
4647
4648         codec->patch_ops = stac_patch_ops;
4649
4650         snd_hda_add_verbs(codec, stac922x_core_init);
4651
4652         /* Fix Mux capture level; max to 2 */
4653         snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4654                                   (0 << AC_AMPCAP_OFFSET_SHIFT) |
4655                                   (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4656                                   (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4657                                   (0 << AC_AMPCAP_MUTE_SHIFT));
4658
4659         snd_hda_pick_fixup(codec, stac922x_models, stac922x_fixup_tbl,
4660                            stac922x_fixups);
4661         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4662
4663         err = stac_parse_auto_config(codec);
4664         if (err < 0) {
4665                 stac_free(codec);
4666                 return err;
4667         }
4668
4669         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4670
4671         return 0;
4672 }
4673
4674 static const char * const stac927x_spdif_labels[] = {
4675         "Digital Playback", "ADAT", "Analog Mux 1",
4676         "Analog Mux 2", "Analog Mux 3", NULL
4677 };
4678
4679 static int patch_stac927x(struct hda_codec *codec)
4680 {
4681         struct sigmatel_spec *spec;
4682         int err;
4683
4684         err = alloc_stac_spec(codec);
4685         if (err < 0)
4686                 return err;
4687
4688         spec = codec->spec;
4689         spec->linear_tone_beep = 1;
4690         spec->gen.own_eapd_ctl = 1;
4691         spec->have_spdif_mux = 1;
4692         spec->spdif_labels = stac927x_spdif_labels;
4693
4694         spec->gen.beep_nid = 0x23; /* digital beep */
4695
4696         /* GPIO0 High = Enable EAPD */
4697         spec->eapd_mask = spec->gpio_mask = 0x01;
4698         spec->gpio_dir = spec->gpio_data = 0x01;
4699
4700         spec->aloopback_ctl = &stac927x_loopback;
4701         spec->aloopback_mask = 0x40;
4702         spec->aloopback_shift = 0;
4703         spec->eapd_switch = 1;
4704
4705         codec->patch_ops = stac_patch_ops;
4706
4707         snd_hda_pick_fixup(codec, stac927x_models, stac927x_fixup_tbl,
4708                            stac927x_fixups);
4709         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4710
4711         if (!spec->volknob_init)
4712                 snd_hda_add_verbs(codec, stac927x_core_init);
4713
4714         err = stac_parse_auto_config(codec);
4715         if (err < 0) {
4716                 stac_free(codec);
4717                 return err;
4718         }
4719
4720         codec->proc_widget_hook = stac927x_proc_hook;
4721
4722         /*
4723          * !!FIXME!!
4724          * The STAC927x seem to require fairly long delays for certain
4725          * command sequences.  With too short delays (even if the answer
4726          * is set to RIRB properly), it results in the silence output
4727          * on some hardwares like Dell.
4728          *
4729          * The below flag enables the longer delay (see get_response
4730          * in hda_intel.c).
4731          */
4732         codec->bus->needs_damn_long_delay = 1;
4733
4734         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4735
4736         return 0;
4737 }
4738
4739 static int patch_stac9205(struct hda_codec *codec)
4740 {
4741         struct sigmatel_spec *spec;
4742         int err;
4743
4744         err = alloc_stac_spec(codec);
4745         if (err < 0)
4746                 return err;
4747
4748         spec = codec->spec;
4749         spec->linear_tone_beep = 1;
4750         spec->gen.own_eapd_ctl = 1;
4751         spec->have_spdif_mux = 1;
4752
4753         spec->gen.beep_nid = 0x23; /* digital beep */
4754
4755         snd_hda_add_verbs(codec, stac9205_core_init);
4756         spec->aloopback_ctl = &stac9205_loopback;
4757
4758         spec->aloopback_mask = 0x40;
4759         spec->aloopback_shift = 0;
4760         
4761         /* GPIO0 High = EAPD */
4762         spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4763         spec->gpio_data = 0x01;
4764
4765         /* Turn on/off EAPD per HP plugging */
4766         spec->eapd_switch = 1;
4767
4768         codec->patch_ops = stac_patch_ops;
4769
4770         snd_hda_pick_fixup(codec, stac9205_models, stac9205_fixup_tbl,
4771                            stac9205_fixups);
4772         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4773
4774         err = stac_parse_auto_config(codec);
4775         if (err < 0) {
4776                 stac_free(codec);
4777                 return err;
4778         }
4779
4780         codec->proc_widget_hook = stac9205_proc_hook;
4781
4782         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4783
4784         return 0;
4785 }
4786
4787 /*
4788  * STAC9872 hack
4789  */
4790
4791 static const struct hda_verb stac9872_core_init[] = {
4792         {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4793         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4794         {}
4795 };
4796
4797 static const struct hda_pintbl stac9872_vaio_pin_configs[] = {
4798         { 0x0a, 0x03211020 },
4799         { 0x0b, 0x411111f0 },
4800         { 0x0c, 0x411111f0 },
4801         { 0x0d, 0x03a15030 },
4802         { 0x0e, 0x411111f0 },
4803         { 0x0f, 0x90170110 },
4804         { 0x11, 0x411111f0 },
4805         { 0x13, 0x411111f0 },
4806         { 0x14, 0x90a7013e },
4807         {}
4808 };
4809
4810 static const struct hda_model_fixup stac9872_models[] = {
4811         { .id = STAC_9872_VAIO, .name = "vaio" },
4812         {}
4813 };
4814
4815 static const struct hda_fixup stac9872_fixups[] = {
4816         [STAC_9872_VAIO] = {
4817                 .type = HDA_FIXUP_PINS,
4818                 .v.pins = stac9872_vaio_pin_configs,
4819         },
4820 };
4821
4822 static const struct snd_pci_quirk stac9872_fixup_tbl[] = {
4823         SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
4824                            "Sony VAIO F/S", STAC_9872_VAIO),
4825         {} /* terminator */
4826 };
4827
4828 static int patch_stac9872(struct hda_codec *codec)
4829 {
4830         struct sigmatel_spec *spec;
4831         int err;
4832
4833         err = alloc_stac_spec(codec);
4834         if (err < 0)
4835                 return err;
4836
4837         spec = codec->spec;
4838         spec->linear_tone_beep = 1;
4839         spec->gen.own_eapd_ctl = 1;
4840
4841         codec->patch_ops = stac_patch_ops;
4842
4843         snd_hda_add_verbs(codec, stac9872_core_init);
4844
4845         snd_hda_pick_fixup(codec, stac9872_models, stac9872_fixup_tbl,
4846                            stac9872_fixups);
4847         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
4848
4849         err = stac_parse_auto_config(codec);
4850         if (err < 0) {
4851                 stac_free(codec);
4852                 return -EINVAL;
4853         }
4854
4855         snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
4856
4857         return 0;
4858 }
4859
4860
4861 /*
4862  * patch entries
4863  */
4864 static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4865         { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4866         { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4867         { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4868         { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4869         { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4870         { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4871         { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
4872         { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4873         { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4874         { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4875         { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4876         { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4877         { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
4878         { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4879         { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4880         { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4881         { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4882         { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4883         { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4884         { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4885         { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4886         { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4887         { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
4888         { .id = 0x83847632, .name = "STAC9202",  .patch = patch_stac925x },
4889         { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4890         { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4891         { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4892         { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4893         { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
4894         { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4895         { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
4896         /* The following does not take into account .id=0x83847661 when subsys =
4897          * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4898          * currently not fully supported.
4899          */
4900         { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4901         { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4902         { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
4903         { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
4904         { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4905         { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4906         { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4907         { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4908         { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4909         { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4910         { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4911         { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
4912         { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
4913         { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
4914         { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
4915         { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
4916         { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
4917         { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
4918         { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
4919         { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
4920         { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
4921         { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
4922         { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
4923         { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
4924         { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4925         { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
4926         { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
4927         { .id = 0x111d7695, .name = "92HD95", .patch = patch_stac92hd95 },
4928         { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4929         { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4930         { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4931         { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4932         { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4933         { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4934         { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4935         { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4936         { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
4937         { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
4938         { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
4939         { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
4940         { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
4941         { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
4942         { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
4943         { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
4944         { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
4945         { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
4946         { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
4947         { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
4948         { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
4949         { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
4950         { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
4951         { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
4952         { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
4953         { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
4954         { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
4955         { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
4956         { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
4957         { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
4958         { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
4959         { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
4960         { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
4961         { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
4962         { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
4963         { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
4964         { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
4965         { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
4966         { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
4967         { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
4968         {} /* terminator */
4969 };
4970
4971 MODULE_ALIAS("snd-hda-codec-id:8384*");
4972 MODULE_ALIAS("snd-hda-codec-id:111d*");
4973
4974 MODULE_LICENSE("GPL");
4975 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
4976
4977 static struct hda_codec_preset_list sigmatel_list = {
4978         .preset = snd_hda_preset_sigmatel,
4979         .owner = THIS_MODULE,
4980 };
4981
4982 static int __init patch_sigmatel_init(void)
4983 {
4984         return snd_hda_add_codec_preset(&sigmatel_list);
4985 }
4986
4987 static void __exit patch_sigmatel_exit(void)
4988 {
4989         snd_hda_delete_codec_preset(&sigmatel_list);
4990 }
4991
4992 module_init(patch_sigmatel_init)
4993 module_exit(patch_sigmatel_exit)