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