2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
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.
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.
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
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/asoundef.h>
35 #include <sound/jack.h>
36 #include <sound/tlv.h>
37 #include "hda_codec.h"
38 #include "hda_local.h"
39 #include "hda_auto_parser.h"
83 STAC_92HD73XX_NO_JD, /* no jack-detection */
97 STAC_92HD83XXX_PWR_REF,
99 STAC_DELL_VOSTRO_3500,
100 STAC_92HD83XXX_HP_cNB11_INTQUAD,
103 STAC_92HD83XXX_HP_LED,
104 STAC_92HD83XXX_HP_INV_LED,
105 STAC_92HD83XXX_HP_MIC_LED,
106 STAC_92HD83XXX_HEADSET_JACK,
107 STAC_92HD83XXX_MODELS
121 STAC_92HD71BXX_NO_DMIC,
122 STAC_92HD71BXX_NO_SMUX,
123 STAC_92HD71BXX_MODELS
153 STAC_922X_INTEL_MAC_GPIO,
158 STAC_D965_REF_NO_JD, /* no jack-detection */
166 STAC_DELL_BIOS_SPDIF,
177 struct sigmatel_mic_route {
180 signed char dmux_idx;
183 #define MAX_PINS_NUM 16
184 #define MAX_ADCS_NUM 4
185 #define MAX_DMICS_NUM 4
187 struct sigmatel_spec {
188 struct snd_kcontrol_new *mixers[4];
189 unsigned int num_mixers;
192 unsigned int eapd_switch: 1;
193 unsigned int surr_switch: 1;
194 unsigned int alt_switch: 1;
195 unsigned int hp_detect: 1;
196 unsigned int spdif_mute: 1;
197 unsigned int check_volume_offset:1;
198 unsigned int auto_mic:1;
199 unsigned int linear_tone_beep:1;
200 unsigned int headset_jack:1; /* 4-pin headset jack (hp + mono mic) */
201 unsigned int volknob_init:1; /* special volume-knob initialization */
204 unsigned int eapd_mask;
205 unsigned int gpio_mask;
206 unsigned int gpio_dir;
207 unsigned int gpio_data;
208 unsigned int gpio_mute;
209 unsigned int gpio_led;
210 unsigned int gpio_led_polarity;
211 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
212 unsigned int vref_led;
214 unsigned int mic_mute_led_gpio; /* capture mute LED GPIO */
215 bool mic_mute_led_on; /* current mic mute state */
218 unsigned int stream_delay;
220 /* analog loopback */
221 const struct snd_kcontrol_new *aloopback_ctl;
222 unsigned char aloopback_mask;
223 unsigned char aloopback_shift;
225 /* power management */
226 unsigned int power_map_bits;
227 unsigned int num_pwrs;
228 const hda_nid_t *pwr_nids;
229 const hda_nid_t *dac_list;
232 struct hda_input_mux *mono_mux;
233 unsigned int cur_mmux;
234 struct hda_multi_out multiout;
235 hda_nid_t dac_nids[5];
236 hda_nid_t hp_dacs[5];
237 hda_nid_t speaker_dacs[5];
242 const hda_nid_t *adc_nids;
243 unsigned int num_adcs;
244 const hda_nid_t *mux_nids;
245 unsigned int num_muxes;
246 const hda_nid_t *dmic_nids;
247 unsigned int num_dmics;
248 const hda_nid_t *dmux_nids;
249 unsigned int num_dmuxes;
250 const hda_nid_t *smux_nids;
251 unsigned int num_smuxes;
252 unsigned int num_analog_muxes;
254 const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
255 const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
256 unsigned int num_caps; /* number of capture volume/switch elements */
258 struct sigmatel_mic_route ext_mic;
259 struct sigmatel_mic_route int_mic;
260 struct sigmatel_mic_route dock_mic;
262 const char * const *spdif_labels;
264 hda_nid_t dig_in_nid;
266 hda_nid_t anabeep_nid;
267 hda_nid_t digbeep_nid;
270 const hda_nid_t *pin_nids;
271 unsigned int num_pins;
273 /* codec specific stuff */
274 const struct hda_verb *init;
275 const struct snd_kcontrol_new *mixer;
278 struct hda_input_mux *dinput_mux;
279 unsigned int cur_dmux[2];
280 struct hda_input_mux *input_mux;
281 unsigned int cur_mux[3];
282 struct hda_input_mux *sinput_mux;
283 unsigned int cur_smux[2];
284 unsigned int cur_amux;
286 unsigned int powerdown_adcs;
289 unsigned int io_switch[2];
290 unsigned int clfe_swap;
291 hda_nid_t line_switch; /* shared line-in for input and output */
292 hda_nid_t mic_switch; /* shared mic-in for input and output */
293 hda_nid_t hp_switch; /* NID of HP as line-out */
294 unsigned int aloopback;
296 struct hda_pcm pcm_rec[2]; /* PCM information */
298 /* dynamic controls and input_mux */
299 struct auto_pin_cfg autocfg;
300 struct snd_array kctls;
301 struct hda_input_mux private_dimux;
302 struct hda_input_mux private_imux;
303 struct hda_input_mux private_smux;
304 struct hda_input_mux private_mono_mux;
307 unsigned auto_pin_cnt;
308 hda_nid_t auto_pin_nids[MAX_PINS_NUM];
309 unsigned auto_adc_cnt;
310 hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
311 hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
312 hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
313 unsigned long auto_capvols[MAX_ADCS_NUM];
314 unsigned auto_dmic_cnt;
315 hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
317 struct hda_vmaster_mute_hook vmaster_mute;
320 #define AC_VERB_IDT_SET_POWER_MAP 0x7ec
321 #define AC_VERB_IDT_GET_POWER_MAP 0xfec
323 static const hda_nid_t stac9200_adc_nids[1] = {
327 static const hda_nid_t stac9200_mux_nids[1] = {
331 static const hda_nid_t stac9200_dac_nids[1] = {
335 static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
336 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
340 static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
344 static const hda_nid_t stac92hd73xx_adc_nids[2] = {
348 #define STAC92HD73XX_NUM_DMICS 2
349 static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
353 #define STAC92HD73_DAC_COUNT 5
355 static const hda_nid_t stac92hd73xx_mux_nids[2] = {
359 static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
363 static const hda_nid_t stac92hd73xx_smux_nids[2] = {
367 #define STAC92HD73XX_NUM_CAPS 2
368 static const unsigned long stac92hd73xx_capvols[] = {
369 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
370 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
372 #define stac92hd73xx_capsws stac92hd73xx_capvols
374 #define STAC92HD83_DAC_COUNT 3
376 static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
377 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
381 static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
385 static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
389 static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
393 static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
397 static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
401 static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
405 static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
409 #define STAC92HD71BXX_NUM_DMICS 2
410 static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
414 static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
418 static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
422 #define STAC92HD71BXX_NUM_CAPS 2
423 static const unsigned long stac92hd71bxx_capvols[] = {
424 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
425 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
427 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
429 static const hda_nid_t stac925x_adc_nids[1] = {
433 static const hda_nid_t stac925x_mux_nids[1] = {
437 static const hda_nid_t stac925x_dac_nids[1] = {
441 #define STAC925X_NUM_DMICS 1
442 static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
446 static const hda_nid_t stac925x_dmux_nids[1] = {
450 static const unsigned long stac925x_capvols[] = {
451 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
453 static const unsigned long stac925x_capsws[] = {
454 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
457 static const hda_nid_t stac922x_adc_nids[2] = {
461 static const hda_nid_t stac922x_mux_nids[2] = {
465 #define STAC922X_NUM_CAPS 2
466 static const unsigned long stac922x_capvols[] = {
467 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
468 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
470 #define stac922x_capsws stac922x_capvols
472 static const hda_nid_t stac927x_slave_dig_outs[2] = {
476 static const hda_nid_t stac927x_adc_nids[3] = {
480 static const hda_nid_t stac927x_mux_nids[3] = {
484 static const hda_nid_t stac927x_smux_nids[1] = {
488 static const hda_nid_t stac927x_dac_nids[6] = {
489 0x02, 0x03, 0x04, 0x05, 0x06, 0
492 static const hda_nid_t stac927x_dmux_nids[1] = {
496 #define STAC927X_NUM_DMICS 2
497 static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
501 #define STAC927X_NUM_CAPS 3
502 static const unsigned long stac927x_capvols[] = {
503 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
504 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
505 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
507 static const unsigned long stac927x_capsws[] = {
508 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
509 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
510 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
513 static const char * const stac927x_spdif_labels[5] = {
514 "Digital Playback", "ADAT", "Analog Mux 1",
515 "Analog Mux 2", "Analog Mux 3"
518 static const hda_nid_t stac9205_adc_nids[2] = {
522 static const hda_nid_t stac9205_mux_nids[2] = {
526 static const hda_nid_t stac9205_dmux_nids[1] = {
530 static const hda_nid_t stac9205_smux_nids[1] = {
534 #define STAC9205_NUM_DMICS 2
535 static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
539 #define STAC9205_NUM_CAPS 2
540 static const unsigned long stac9205_capvols[] = {
541 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
542 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
544 static const unsigned long stac9205_capsws[] = {
545 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
546 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
549 static const hda_nid_t stac9200_pin_nids[8] = {
550 0x08, 0x09, 0x0d, 0x0e,
551 0x0f, 0x10, 0x11, 0x12,
554 static const hda_nid_t stac925x_pin_nids[8] = {
555 0x07, 0x08, 0x0a, 0x0b,
556 0x0c, 0x0d, 0x10, 0x11,
559 static const hda_nid_t stac922x_pin_nids[10] = {
560 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
561 0x0f, 0x10, 0x11, 0x15, 0x1b,
564 static const hda_nid_t stac92hd73xx_pin_nids[13] = {
565 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
566 0x0f, 0x10, 0x11, 0x12, 0x13,
570 #define STAC92HD71BXX_NUM_PINS 13
571 static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
572 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
573 0x00, 0x14, 0x18, 0x19, 0x1e,
576 static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
577 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
578 0x0f, 0x14, 0x18, 0x19, 0x1e,
582 static const hda_nid_t stac927x_pin_nids[14] = {
583 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
584 0x0f, 0x10, 0x11, 0x12, 0x13,
585 0x14, 0x21, 0x22, 0x23,
588 static const hda_nid_t stac9205_pin_nids[12] = {
589 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
590 0x0f, 0x14, 0x16, 0x17, 0x18,
594 static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
595 unsigned char type, int data);
596 static int stac_add_hp_bass_switch(struct hda_codec *codec);
597 static void stac92xx_auto_set_pinctl(struct hda_codec *codec,
598 hda_nid_t nid, int pin_type);
599 static int hp_blike_system(u32 subsystem_id);
600 static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity);
602 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
603 struct snd_ctl_elem_info *uinfo)
605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
606 struct sigmatel_spec *spec = codec->spec;
607 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
610 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
611 struct snd_ctl_elem_value *ucontrol)
613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
614 struct sigmatel_spec *spec = codec->spec;
615 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
617 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
621 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_value *ucontrol)
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct sigmatel_spec *spec = codec->spec;
626 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
628 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
629 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
632 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_info *uinfo)
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 struct sigmatel_spec *spec = codec->spec;
637 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
640 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 struct sigmatel_spec *spec = codec->spec;
645 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
647 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
651 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_value *ucontrol)
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
656 struct hda_input_mux *smux = &spec->private_smux;
657 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
661 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
662 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
666 if (spec->spdif_mute) {
668 nid = spec->multiout.dig_out_nid;
670 nid = codec->slave_dig_outs[smux_idx - 1];
671 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
675 /* un/mute SPDIF out */
676 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
682 static int stac_vrefout_set(struct hda_codec *codec,
683 hda_nid_t nid, unsigned int new_vref)
687 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
688 pinctl = snd_hda_codec_read(codec, nid, 0,
689 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
695 pinctl &= ~AC_PINCTL_VREFEN;
696 pinctl |= (new_vref & AC_PINCTL_VREFEN);
698 error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
705 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
706 hda_nid_t nid, unsigned int new_vref)
710 pincfg = snd_hda_codec_read(codec, nid, 0,
711 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
714 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
717 if (new_vref == AC_PINCTL_VREF_HIZ)
718 pincfg |= AC_PINCTL_OUT_EN;
720 pincfg |= AC_PINCTL_IN_EN;
722 error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg);
729 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
732 vref = snd_hda_codec_read(codec, nid, 0,
733 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
734 vref &= AC_PINCTL_VREFEN;
738 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
740 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
741 struct sigmatel_spec *spec = codec->spec;
742 return snd_hda_input_mux_info(spec->input_mux, uinfo);
745 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
748 struct sigmatel_spec *spec = codec->spec;
749 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
751 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
755 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
758 struct sigmatel_spec *spec = codec->spec;
759 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
760 const struct hda_input_mux *imux = spec->input_mux;
761 unsigned int idx, prev_idx, didx;
763 idx = ucontrol->value.enumerated.item[0];
764 if (idx >= imux->num_items)
765 idx = imux->num_items - 1;
766 prev_idx = spec->cur_mux[adc_idx];
769 if (idx < spec->num_analog_muxes) {
770 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
771 AC_VERB_SET_CONNECT_SEL,
772 imux->items[idx].index);
773 if (prev_idx >= spec->num_analog_muxes &&
774 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
775 imux = spec->dinput_mux;
777 snd_hda_codec_write_cache(codec,
778 spec->dmux_nids[adc_idx], 0,
779 AC_VERB_SET_CONNECT_SEL,
780 imux->items[0].index);
783 imux = spec->dinput_mux;
784 /* first dimux item is hardcoded to select analog imux,
787 didx = idx - spec->num_analog_muxes + 1;
788 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
789 AC_VERB_SET_CONNECT_SEL,
790 imux->items[didx].index);
792 spec->cur_mux[adc_idx] = idx;
796 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
797 struct snd_ctl_elem_info *uinfo)
799 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
800 struct sigmatel_spec *spec = codec->spec;
801 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
804 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
805 struct snd_ctl_elem_value *ucontrol)
807 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
808 struct sigmatel_spec *spec = codec->spec;
810 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
814 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
815 struct snd_ctl_elem_value *ucontrol)
817 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
818 struct sigmatel_spec *spec = codec->spec;
820 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
821 spec->mono_nid, &spec->cur_mmux);
824 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
826 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
827 struct snd_ctl_elem_value *ucontrol)
829 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
830 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
831 struct sigmatel_spec *spec = codec->spec;
833 ucontrol->value.integer.value[0] = !!(spec->aloopback &
834 (spec->aloopback_mask << idx));
838 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
839 struct snd_ctl_elem_value *ucontrol)
841 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
842 struct sigmatel_spec *spec = codec->spec;
843 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
844 unsigned int dac_mode;
845 unsigned int val, idx_val;
847 idx_val = spec->aloopback_mask << idx;
848 if (ucontrol->value.integer.value[0])
849 val = spec->aloopback | idx_val;
851 val = spec->aloopback & ~idx_val;
852 if (spec->aloopback == val)
855 spec->aloopback = val;
857 /* Only return the bits defined by the shift value of the
858 * first two bytes of the mask
860 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
861 kcontrol->private_value & 0xFFFF, 0x0);
862 dac_mode >>= spec->aloopback_shift;
864 if (spec->aloopback & idx_val) {
865 snd_hda_power_up(codec);
868 snd_hda_power_down(codec);
869 dac_mode &= ~idx_val;
872 snd_hda_codec_write_cache(codec, codec->afg, 0,
873 kcontrol->private_value >> 16, dac_mode);
878 static const struct hda_verb stac9200_core_init[] = {
879 /* set dac0mux for dac converter */
880 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
884 static const struct hda_verb stac9200_eapd_init[] = {
885 /* set dac0mux for dac converter */
886 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
887 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
891 static const struct hda_verb dell_eq_core_init[] = {
892 /* set master volume to max value without distortion
893 * and direct control */
894 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
898 static const struct hda_verb stac92hd73xx_core_init[] = {
899 /* set master volume and direct control */
900 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
904 static const struct hda_verb stac92hd83xxx_core_init[] = {
905 /* power state controls amps */
906 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
910 static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
911 { 0x22, 0x785, 0x43 },
912 { 0x22, 0x782, 0xe0 },
913 { 0x22, 0x795, 0x00 },
917 static const struct hda_verb stac92hd71bxx_core_init[] = {
918 /* set master volume and direct control */
919 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
923 static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
924 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
925 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
926 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
927 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
931 static const struct hda_verb stac925x_core_init[] = {
932 /* set dac0mux for dac converter */
933 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
934 /* mute the master volume */
935 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
939 static const struct hda_verb stac922x_core_init[] = {
940 /* set master volume and direct control */
941 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
945 static const struct hda_verb d965_core_init[] = {
946 /* unmute node 0x1b */
947 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
948 /* select node 0x03 as DAC */
949 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
953 static const struct hda_verb dell_3st_core_init[] = {
954 /* don't set delta bit */
955 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
956 /* unmute node 0x1b */
957 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
958 /* select node 0x03 as DAC */
959 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
963 static const struct hda_verb stac927x_core_init[] = {
964 /* set master volume and direct control */
965 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
966 /* enable analog pc beep path */
967 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
971 static const struct hda_verb stac927x_volknob_core_init[] = {
972 /* don't set delta bit */
973 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
974 /* enable analog pc beep path */
975 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
979 static const struct hda_verb stac9205_core_init[] = {
980 /* set master volume and direct control */
981 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
982 /* enable analog pc beep path */
983 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
987 #define STAC_MONO_MUX \
989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
990 .name = "Mono Mux", \
992 .info = stac92xx_mono_mux_enum_info, \
993 .get = stac92xx_mono_mux_enum_get, \
994 .put = stac92xx_mono_mux_enum_put, \
997 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1000 .name = "Analog Loopback", \
1002 .info = stac92xx_aloopback_info, \
1003 .get = stac92xx_aloopback_get, \
1004 .put = stac92xx_aloopback_put, \
1005 .private_value = verb_read | (verb_write << 16), \
1008 #define DC_BIAS(xname, idx, nid) \
1010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1013 .info = stac92xx_dc_bias_info, \
1014 .get = stac92xx_dc_bias_get, \
1015 .put = stac92xx_dc_bias_put, \
1016 .private_value = nid, \
1019 static const struct snd_kcontrol_new stac9200_mixer[] = {
1020 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
1021 HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
1022 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1023 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1027 static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1028 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1032 static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1033 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1037 static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1038 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1043 static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1044 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1047 static const struct snd_kcontrol_new stac925x_mixer[] = {
1048 HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
1049 HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
1053 static const struct snd_kcontrol_new stac9205_loopback[] = {
1054 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1058 static const struct snd_kcontrol_new stac927x_loopback[] = {
1059 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1063 static struct snd_kcontrol_new stac_dmux_mixer = {
1064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1065 .name = "Digital Input Source",
1066 /* count set later */
1067 .info = stac92xx_dmux_enum_info,
1068 .get = stac92xx_dmux_enum_get,
1069 .put = stac92xx_dmux_enum_put,
1072 static struct snd_kcontrol_new stac_smux_mixer = {
1073 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1074 .name = "IEC958 Playback Source",
1075 /* count set later */
1076 .info = stac92xx_smux_enum_info,
1077 .get = stac92xx_smux_enum_get,
1078 .put = stac92xx_smux_enum_put,
1081 static const char * const slave_pfxs[] = {
1082 "Front", "Surround", "Center", "LFE", "Side",
1083 "Headphone", "Speaker", "Bass Speaker", "IEC958", "PCM",
1087 static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
1089 static void stac92xx_vmaster_hook(void *private_data, int val)
1091 stac92xx_update_led_status(private_data, val);
1094 static void stac92xx_free_kctls(struct hda_codec *codec);
1096 static int stac92xx_build_controls(struct hda_codec *codec)
1098 struct sigmatel_spec *spec = codec->spec;
1099 unsigned int vmaster_tlv[4];
1104 err = snd_hda_add_new_ctls(codec, spec->mixer);
1109 for (i = 0; i < spec->num_mixers; i++) {
1110 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1114 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1115 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1116 stac_dmux_mixer.count = spec->num_dmuxes;
1117 err = snd_hda_ctl_add(codec, 0,
1118 snd_ctl_new1(&stac_dmux_mixer, codec));
1122 if (spec->num_smuxes > 0) {
1123 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1124 struct hda_input_mux *smux = &spec->private_smux;
1125 /* check for mute support on SPDIF out */
1126 if (wcaps & AC_WCAP_OUT_AMP) {
1127 snd_hda_add_imux_item(smux, "Off", 0, NULL);
1128 spec->spdif_mute = 1;
1130 stac_smux_mixer.count = spec->num_smuxes;
1131 err = snd_hda_ctl_add(codec, 0,
1132 snd_ctl_new1(&stac_smux_mixer, codec));
1137 if (spec->multiout.dig_out_nid) {
1138 err = snd_hda_create_dig_out_ctls(codec,
1139 spec->multiout.dig_out_nid,
1140 spec->multiout.dig_out_nid,
1141 spec->autocfg.dig_out_type[0]);
1144 err = snd_hda_create_spdif_share_sw(codec,
1148 spec->multiout.share_spdif = 1;
1150 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1151 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1156 /* if we have no master control, let's create it */
1157 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1158 HDA_OUTPUT, vmaster_tlv);
1159 /* correct volume offset */
1160 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1161 /* minimum value is actually mute */
1162 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1163 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1164 vmaster_tlv, slave_pfxs,
1169 err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
1171 "Playback Switch", true,
1172 &spec->vmaster_mute.sw_kctl);
1176 if (spec->gpio_led) {
1177 spec->vmaster_mute.hook = stac92xx_vmaster_hook;
1178 err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
1183 if (spec->aloopback_ctl &&
1184 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1185 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1190 stac92xx_free_kctls(codec); /* no longer needed */
1192 err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
1199 static const struct hda_pintbl ref9200_pin_configs[] = {
1200 { 0x08, 0x01c47010 },
1201 { 0x09, 0x01447010 },
1202 { 0x0d, 0x0221401f },
1203 { 0x0e, 0x01114010 },
1204 { 0x0f, 0x02a19020 },
1205 { 0x10, 0x01a19021 },
1206 { 0x11, 0x90100140 },
1207 { 0x12, 0x01813122 },
1211 static const struct hda_pintbl gateway9200_m4_pin_configs[] = {
1212 { 0x08, 0x400000fe },
1213 { 0x09, 0x404500f4 },
1214 { 0x0d, 0x400100f0 },
1215 { 0x0e, 0x90110010 },
1216 { 0x0f, 0x400100f1 },
1217 { 0x10, 0x02a1902e },
1218 { 0x11, 0x500000f2 },
1219 { 0x12, 0x500000f3 },
1223 static const struct hda_pintbl gateway9200_m4_2_pin_configs[] = {
1224 { 0x08, 0x400000fe },
1225 { 0x09, 0x404500f4 },
1226 { 0x0d, 0x400100f0 },
1227 { 0x0e, 0x90110010 },
1228 { 0x0f, 0x400100f1 },
1229 { 0x10, 0x02a1902e },
1230 { 0x11, 0x500000f2 },
1231 { 0x12, 0x500000f3 },
1236 STAC 9200 pin configs for
1241 static const struct hda_pintbl dell9200_d21_pin_configs[] = {
1242 { 0x08, 0x400001f0 },
1243 { 0x09, 0x400001f1 },
1244 { 0x0d, 0x02214030 },
1245 { 0x0e, 0x01014010 },
1246 { 0x0f, 0x02a19020 },
1247 { 0x10, 0x01a19021 },
1248 { 0x11, 0x90100140 },
1249 { 0x12, 0x01813122 },
1254 STAC 9200 pin configs for
1258 static const struct hda_pintbl dell9200_d22_pin_configs[] = {
1259 { 0x08, 0x400001f0 },
1260 { 0x09, 0x400001f1 },
1261 { 0x0d, 0x0221401f },
1262 { 0x0e, 0x01014010 },
1263 { 0x0f, 0x01813020 },
1264 { 0x10, 0x02a19021 },
1265 { 0x11, 0x90100140 },
1266 { 0x12, 0x400001f2 },
1271 STAC 9200 pin configs for
1272 102801C4 (Dell Dimension E310)
1279 static const struct hda_pintbl dell9200_d23_pin_configs[] = {
1280 { 0x08, 0x400001f0 },
1281 { 0x09, 0x400001f1 },
1282 { 0x0d, 0x0221401f },
1283 { 0x0e, 0x01014010 },
1284 { 0x0f, 0x01813020 },
1285 { 0x10, 0x01a19021 },
1286 { 0x11, 0x90100140 },
1287 { 0x12, 0x400001f2 },
1293 STAC 9200-32 pin configs for
1294 102801B5 (Dell Inspiron 630m)
1295 102801D8 (Dell Inspiron 640m)
1297 static const struct hda_pintbl dell9200_m21_pin_configs[] = {
1298 { 0x08, 0x40c003fa },
1299 { 0x09, 0x03441340 },
1300 { 0x0d, 0x0321121f },
1301 { 0x0e, 0x90170310 },
1302 { 0x0f, 0x408003fb },
1303 { 0x10, 0x03a11020 },
1304 { 0x11, 0x401003fc },
1305 { 0x12, 0x403003fd },
1310 STAC 9200-32 pin configs for
1311 102801C2 (Dell Latitude D620)
1313 102801CC (Dell Latitude D820)
1317 static const struct hda_pintbl dell9200_m22_pin_configs[] = {
1318 { 0x08, 0x40c003fa },
1319 { 0x09, 0x0144131f },
1320 { 0x0d, 0x0321121f },
1321 { 0x0e, 0x90170310 },
1322 { 0x0f, 0x90a70321 },
1323 { 0x10, 0x03a11020 },
1324 { 0x11, 0x401003fb },
1325 { 0x12, 0x40f000fc },
1330 STAC 9200-32 pin configs for
1331 102801CE (Dell XPS M1710)
1332 102801CF (Dell Precision M90)
1334 static const struct hda_pintbl dell9200_m23_pin_configs[] = {
1335 { 0x08, 0x40c003fa },
1336 { 0x09, 0x01441340 },
1337 { 0x0d, 0x0421421f },
1338 { 0x0e, 0x90170310 },
1339 { 0x0f, 0x408003fb },
1340 { 0x10, 0x04a1102e },
1341 { 0x11, 0x90170311 },
1342 { 0x12, 0x403003fc },
1347 STAC 9200-32 pin configs for
1350 102801CB (Dell Latitude 120L)
1353 static const struct hda_pintbl dell9200_m24_pin_configs[] = {
1354 { 0x08, 0x40c003fa },
1355 { 0x09, 0x404003fb },
1356 { 0x0d, 0x0321121f },
1357 { 0x0e, 0x90170310 },
1358 { 0x0f, 0x408003fc },
1359 { 0x10, 0x03a11020 },
1360 { 0x11, 0x401003fd },
1361 { 0x12, 0x403003fe },
1366 STAC 9200-32 pin configs for
1367 102801BD (Dell Inspiron E1505n)
1371 static const struct hda_pintbl dell9200_m25_pin_configs[] = {
1372 { 0x08, 0x40c003fa },
1373 { 0x09, 0x01441340 },
1374 { 0x0d, 0x0421121f },
1375 { 0x0e, 0x90170310 },
1376 { 0x0f, 0x408003fb },
1377 { 0x10, 0x04a11020 },
1378 { 0x11, 0x401003fc },
1379 { 0x12, 0x403003fd },
1384 STAC 9200-32 pin configs for
1385 102801F5 (Dell Inspiron 1501)
1388 static const struct hda_pintbl dell9200_m26_pin_configs[] = {
1389 { 0x08, 0x40c003fa },
1390 { 0x09, 0x404003fb },
1391 { 0x0d, 0x0421121f },
1392 { 0x0e, 0x90170310 },
1393 { 0x0f, 0x408003fc },
1394 { 0x10, 0x04a11020 },
1395 { 0x11, 0x401003fd },
1396 { 0x12, 0x403003fe },
1402 102801CD (Dell Inspiron E1705/9400)
1404 static const struct hda_pintbl dell9200_m27_pin_configs[] = {
1405 { 0x08, 0x40c003fa },
1406 { 0x09, 0x01441340 },
1407 { 0x0d, 0x0421121f },
1408 { 0x0e, 0x90170310 },
1409 { 0x0f, 0x90170310 },
1410 { 0x10, 0x04a11020 },
1411 { 0x11, 0x90170310 },
1412 { 0x12, 0x40f003fc },
1416 static const struct hda_pintbl oqo9200_pin_configs[] = {
1417 { 0x08, 0x40c000f0 },
1418 { 0x09, 0x404000f1 },
1419 { 0x0d, 0x0221121f },
1420 { 0x0e, 0x02211210 },
1421 { 0x0f, 0x90170111 },
1422 { 0x10, 0x90a70120 },
1423 { 0x11, 0x400000f2 },
1424 { 0x12, 0x400000f3 },
1429 static void stac9200_fixup_panasonic(struct hda_codec *codec,
1430 const struct hda_fixup *fix, int action)
1432 struct sigmatel_spec *spec = codec->spec;
1435 case HDA_FIXUP_ACT_PRE_PROBE:
1436 spec->gpio_mask = spec->gpio_dir = 0x09;
1437 spec->gpio_data = 0x00;
1439 case HDA_FIXUP_ACT_PROBE:
1440 /* CF-74 has no headphone detection, and the driver should *NOT*
1441 * do detection and HP/speaker toggle because the hardware does it.
1443 spec->hp_detect = 0;
1449 static const struct hda_fixup stac9200_fixups[] = {
1451 .type = HDA_FIXUP_PINS,
1452 .v.pins = ref9200_pin_configs,
1455 .type = HDA_FIXUP_PINS,
1456 .v.pins = oqo9200_pin_configs,
1458 .chain_id = STAC_9200_EAPD_INIT,
1460 [STAC_9200_DELL_D21] = {
1461 .type = HDA_FIXUP_PINS,
1462 .v.pins = dell9200_d21_pin_configs,
1464 [STAC_9200_DELL_D22] = {
1465 .type = HDA_FIXUP_PINS,
1466 .v.pins = dell9200_d22_pin_configs,
1468 [STAC_9200_DELL_D23] = {
1469 .type = HDA_FIXUP_PINS,
1470 .v.pins = dell9200_d23_pin_configs,
1472 [STAC_9200_DELL_M21] = {
1473 .type = HDA_FIXUP_PINS,
1474 .v.pins = dell9200_m21_pin_configs,
1476 [STAC_9200_DELL_M22] = {
1477 .type = HDA_FIXUP_PINS,
1478 .v.pins = dell9200_m22_pin_configs,
1480 [STAC_9200_DELL_M23] = {
1481 .type = HDA_FIXUP_PINS,
1482 .v.pins = dell9200_m23_pin_configs,
1484 [STAC_9200_DELL_M24] = {
1485 .type = HDA_FIXUP_PINS,
1486 .v.pins = dell9200_m24_pin_configs,
1488 [STAC_9200_DELL_M25] = {
1489 .type = HDA_FIXUP_PINS,
1490 .v.pins = dell9200_m25_pin_configs,
1492 [STAC_9200_DELL_M26] = {
1493 .type = HDA_FIXUP_PINS,
1494 .v.pins = dell9200_m26_pin_configs,
1496 [STAC_9200_DELL_M27] = {
1497 .type = HDA_FIXUP_PINS,
1498 .v.pins = dell9200_m27_pin_configs,
1501 .type = HDA_FIXUP_PINS,
1502 .v.pins = gateway9200_m4_pin_configs,
1504 .chain_id = STAC_9200_EAPD_INIT,
1506 [STAC_9200_M4_2] = {
1507 .type = HDA_FIXUP_PINS,
1508 .v.pins = gateway9200_m4_2_pin_configs,
1510 .chain_id = STAC_9200_EAPD_INIT,
1512 [STAC_9200_PANASONIC] = {
1513 .type = HDA_FIXUP_FUNC,
1514 .v.func = stac9200_fixup_panasonic,
1516 [STAC_9200_EAPD_INIT] = {
1517 .type = HDA_FIXUP_VERBS,
1518 .v.verbs = (const struct hda_verb[]) {
1519 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1525 static const struct hda_model_fixup stac9200_models[] = {
1526 { .id = STAC_REF, .name = "ref" },
1527 { .id = STAC_9200_OQO, .name = "oqo" },
1528 { .id = STAC_9200_DELL_D21, .name = "dell-d21" },
1529 { .id = STAC_9200_DELL_D22, .name = "dell-d22" },
1530 { .id = STAC_9200_DELL_D23, .name = "dell-d23" },
1531 { .id = STAC_9200_DELL_M21, .name = "dell-m21" },
1532 { .id = STAC_9200_DELL_M22, .name = "dell-m22" },
1533 { .id = STAC_9200_DELL_M23, .name = "dell-m23" },
1534 { .id = STAC_9200_DELL_M24, .name = "dell-m24" },
1535 { .id = STAC_9200_DELL_M25, .name = "dell-m25" },
1536 { .id = STAC_9200_DELL_M26, .name = "dell-m26" },
1537 { .id = STAC_9200_DELL_M27, .name = "dell-m27" },
1538 { .id = STAC_9200_M4, .name = "gateway-m4" },
1539 { .id = STAC_9200_M4_2, .name = "gateway-m4-2" },
1540 { .id = STAC_9200_PANASONIC, .name = "panasonic" },
1544 static const struct snd_pci_quirk stac9200_fixup_tbl[] = {
1545 /* SigmaTel reference board */
1546 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1547 "DFI LanParty", STAC_REF),
1548 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1549 "DFI LanParty", STAC_REF),
1550 /* Dell laptops have BIOS problem */
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1552 "unknown Dell", STAC_9200_DELL_D21),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1554 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1556 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1558 "unknown Dell", STAC_9200_DELL_D22),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1560 "unknown Dell", STAC_9200_DELL_D22),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1562 "Dell Latitude D620", STAC_9200_DELL_M22),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1564 "unknown Dell", STAC_9200_DELL_D23),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1566 "unknown Dell", STAC_9200_DELL_D23),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1568 "unknown Dell", STAC_9200_DELL_M22),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1570 "unknown Dell", STAC_9200_DELL_M24),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1572 "unknown Dell", STAC_9200_DELL_M24),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1574 "Dell Latitude 120L", STAC_9200_DELL_M24),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1576 "Dell Latitude D820", STAC_9200_DELL_M22),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1578 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1580 "Dell XPS M1710", STAC_9200_DELL_M23),
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1582 "Dell Precision M90", STAC_9200_DELL_M23),
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1584 "unknown Dell", STAC_9200_DELL_M22),
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1586 "unknown Dell", STAC_9200_DELL_M22),
1587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1588 "unknown Dell", STAC_9200_DELL_M22),
1589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1590 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1592 "unknown Dell", STAC_9200_DELL_D23),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1594 "unknown Dell", STAC_9200_DELL_D23),
1595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1596 "unknown Dell", STAC_9200_DELL_D21),
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1598 "unknown Dell", STAC_9200_DELL_D23),
1599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1600 "unknown Dell", STAC_9200_DELL_D21),
1601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1602 "unknown Dell", STAC_9200_DELL_M25),
1603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1604 "unknown Dell", STAC_9200_DELL_M25),
1605 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1606 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1607 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1608 "unknown Dell", STAC_9200_DELL_M26),
1610 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1611 /* Gateway machines needs EAPD to be set on resume */
1612 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1613 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1614 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1616 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1620 static const struct hda_pintbl ref925x_pin_configs[] = {
1621 { 0x07, 0x40c003f0 },
1622 { 0x08, 0x424503f2 },
1623 { 0x0a, 0x01813022 },
1624 { 0x0b, 0x02a19021 },
1625 { 0x0c, 0x90a70320 },
1626 { 0x0d, 0x02214210 },
1627 { 0x10, 0x01019020 },
1628 { 0x11, 0x9033032e },
1632 static const struct hda_pintbl stac925xM1_pin_configs[] = {
1633 { 0x07, 0x40c003f4 },
1634 { 0x08, 0x424503f2 },
1635 { 0x0a, 0x400000f3 },
1636 { 0x0b, 0x02a19020 },
1637 { 0x0c, 0x40a000f0 },
1638 { 0x0d, 0x90100210 },
1639 { 0x10, 0x400003f1 },
1640 { 0x11, 0x9033032e },
1644 static const struct hda_pintbl stac925xM1_2_pin_configs[] = {
1645 { 0x07, 0x40c003f4 },
1646 { 0x08, 0x424503f2 },
1647 { 0x0a, 0x400000f3 },
1648 { 0x0b, 0x02a19020 },
1649 { 0x0c, 0x40a000f0 },
1650 { 0x0d, 0x90100210 },
1651 { 0x10, 0x400003f1 },
1652 { 0x11, 0x9033032e },
1656 static const struct hda_pintbl stac925xM2_pin_configs[] = {
1657 { 0x07, 0x40c003f4 },
1658 { 0x08, 0x424503f2 },
1659 { 0x0a, 0x400000f3 },
1660 { 0x0b, 0x02a19020 },
1661 { 0x0c, 0x40a000f0 },
1662 { 0x0d, 0x90100210 },
1663 { 0x10, 0x400003f1 },
1664 { 0x11, 0x9033032e },
1668 static const struct hda_pintbl stac925xM2_2_pin_configs[] = {
1669 { 0x07, 0x40c003f4 },
1670 { 0x08, 0x424503f2 },
1671 { 0x0a, 0x400000f3 },
1672 { 0x0b, 0x02a19020 },
1673 { 0x0c, 0x40a000f0 },
1674 { 0x0d, 0x90100210 },
1675 { 0x10, 0x400003f1 },
1676 { 0x11, 0x9033032e },
1680 static const struct hda_pintbl stac925xM3_pin_configs[] = {
1681 { 0x07, 0x40c003f4 },
1682 { 0x08, 0x424503f2 },
1683 { 0x0a, 0x400000f3 },
1684 { 0x0b, 0x02a19020 },
1685 { 0x0c, 0x40a000f0 },
1686 { 0x0d, 0x90100210 },
1687 { 0x10, 0x400003f1 },
1688 { 0x11, 0x503303f3 },
1692 static const struct hda_pintbl stac925xM5_pin_configs[] = {
1693 { 0x07, 0x40c003f4 },
1694 { 0x08, 0x424503f2 },
1695 { 0x0a, 0x400000f3 },
1696 { 0x0b, 0x02a19020 },
1697 { 0x0c, 0x40a000f0 },
1698 { 0x0d, 0x90100210 },
1699 { 0x10, 0x400003f1 },
1700 { 0x11, 0x9033032e },
1704 static const struct hda_pintbl stac925xM6_pin_configs[] = {
1705 { 0x07, 0x40c003f4 },
1706 { 0x08, 0x424503f2 },
1707 { 0x0a, 0x400000f3 },
1708 { 0x0b, 0x02a19020 },
1709 { 0x0c, 0x40a000f0 },
1710 { 0x0d, 0x90100210 },
1711 { 0x10, 0x400003f1 },
1712 { 0x11, 0x90330320 },
1716 static const struct hda_fixup stac925x_fixups[] = {
1718 .type = HDA_FIXUP_PINS,
1719 .v.pins = ref925x_pin_configs,
1722 .type = HDA_FIXUP_PINS,
1723 .v.pins = stac925xM1_pin_configs,
1726 .type = HDA_FIXUP_PINS,
1727 .v.pins = stac925xM1_2_pin_configs,
1730 .type = HDA_FIXUP_PINS,
1731 .v.pins = stac925xM2_pin_configs,
1734 .type = HDA_FIXUP_PINS,
1735 .v.pins = stac925xM2_2_pin_configs,
1738 .type = HDA_FIXUP_PINS,
1739 .v.pins = stac925xM3_pin_configs,
1742 .type = HDA_FIXUP_PINS,
1743 .v.pins = stac925xM5_pin_configs,
1746 .type = HDA_FIXUP_PINS,
1747 .v.pins = stac925xM6_pin_configs,
1751 static const struct hda_model_fixup stac925x_models[] = {
1752 { .id = STAC_REF, .name = "ref" },
1753 { .id = STAC_M1, .name = "m1" },
1754 { .id = STAC_M1_2, .name = "m1-2" },
1755 { .id = STAC_M2, .name = "m2" },
1756 { .id = STAC_M2_2, .name = "m2-2" },
1757 { .id = STAC_M3, .name = "m3" },
1758 { .id = STAC_M5, .name = "m5" },
1759 { .id = STAC_M6, .name = "m6" },
1763 static const struct snd_pci_quirk stac925x_fixup_tbl[] = {
1764 /* SigmaTel reference board */
1765 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1766 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1767 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1769 /* Default table for unknown ID */
1770 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1772 /* gateway machines are checked via codec ssid */
1773 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1774 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1775 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1776 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1777 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1778 /* Not sure about the brand name for those */
1779 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1780 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1781 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1782 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1786 static const unsigned int ref92hd73xx_pin_configs[13] = {
1787 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1788 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1789 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1793 static const unsigned int dell_m6_pin_configs[13] = {
1794 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1795 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1796 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1800 static const unsigned int alienware_m17x_pin_configs[13] = {
1801 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1802 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1803 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1807 static const unsigned int intel_dg45id_pin_configs[13] = {
1808 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
1809 0x01A19250, 0x01011212, 0x01016211
1812 static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1813 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1814 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1815 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1816 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1817 [STAC_DELL_EQ] = dell_m6_pin_configs,
1818 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
1819 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
1822 static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1823 [STAC_92HD73XX_AUTO] = "auto",
1824 [STAC_92HD73XX_NO_JD] = "no-jd",
1825 [STAC_92HD73XX_REF] = "ref",
1826 [STAC_92HD73XX_INTEL] = "intel",
1827 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1828 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1829 [STAC_DELL_M6_BOTH] = "dell-m6",
1830 [STAC_DELL_EQ] = "dell-eq",
1831 [STAC_ALIENWARE_M17X] = "alienware",
1834 static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1835 /* SigmaTel reference board */
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1837 "DFI LanParty", STAC_92HD73XX_REF),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1839 "DFI LanParty", STAC_92HD73XX_REF),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1841 "Intel DG45ID", STAC_92HD73XX_INTEL),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1843 "Intel DG45FC", STAC_92HD73XX_INTEL),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1845 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1847 "unknown Dell", STAC_DELL_M6_DMIC),
1848 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1849 "unknown Dell", STAC_DELL_M6_BOTH),
1850 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1851 "unknown Dell", STAC_DELL_M6_BOTH),
1852 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1853 "unknown Dell", STAC_DELL_M6_AMIC),
1854 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1855 "unknown Dell", STAC_DELL_M6_AMIC),
1856 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1857 "unknown Dell", STAC_DELL_M6_DMIC),
1858 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1859 "unknown Dell", STAC_DELL_M6_DMIC),
1860 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1861 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1862 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1863 "Dell Studio 17", STAC_DELL_M6_DMIC),
1864 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1865 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1866 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1867 "Dell Studio 1557", STAC_DELL_M6_DMIC),
1868 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
1869 "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
1870 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
1871 "Dell Studio 1558", STAC_DELL_M6_DMIC),
1875 static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1876 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1877 "Alienware M17x", STAC_ALIENWARE_M17X),
1878 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1879 "Alienware M17x", STAC_ALIENWARE_M17X),
1880 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
1881 "Alienware M17x R3", STAC_DELL_EQ),
1885 static const unsigned int ref92hd83xxx_pin_configs[10] = {
1886 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1887 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1888 0x01451160, 0x98560170,
1891 static const unsigned int dell_s14_pin_configs[10] = {
1892 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1893 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
1894 0x40f000f0, 0x40f000f0,
1897 static const unsigned int dell_vostro_3500_pin_configs[10] = {
1898 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
1899 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
1900 0x400000f4, 0x400000f5,
1903 static const unsigned int hp_dv7_4000_pin_configs[10] = {
1904 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1905 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1906 0x40f000f0, 0x40f000f0,
1909 static const unsigned int hp_zephyr_pin_configs[10] = {
1910 0x01813050, 0x0421201f, 0x04a1205e, 0x96130310,
1911 0x96130310, 0x0101401f, 0x1111611f, 0xd5a30130,
1915 static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
1916 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1917 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1918 0x40f000f0, 0x40f000f0,
1921 static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1922 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1923 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1924 [STAC_DELL_S14] = dell_s14_pin_configs,
1925 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
1926 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
1927 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
1928 [STAC_HP_ZEPHYR] = hp_zephyr_pin_configs,
1931 static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1932 [STAC_92HD83XXX_AUTO] = "auto",
1933 [STAC_92HD83XXX_REF] = "ref",
1934 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1935 [STAC_DELL_S14] = "dell-s14",
1936 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
1937 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
1938 [STAC_HP_DV7_4000] = "hp-dv7-4000",
1939 [STAC_HP_ZEPHYR] = "hp-zephyr",
1940 [STAC_92HD83XXX_HP_LED] = "hp-led",
1941 [STAC_92HD83XXX_HP_INV_LED] = "hp-inv-led",
1942 [STAC_92HD83XXX_HP_MIC_LED] = "hp-mic-led",
1943 [STAC_92HD83XXX_HEADSET_JACK] = "headset-jack",
1946 static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1947 /* SigmaTel reference board */
1948 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1949 "DFI LanParty", STAC_92HD83XXX_REF),
1950 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1951 "DFI LanParty", STAC_92HD83XXX_REF),
1952 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1953 "unknown Dell", STAC_DELL_S14),
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0532,
1955 "Dell Latitude E6230", STAC_92HD83XXX_HEADSET_JACK),
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0533,
1957 "Dell Latitude E6330", STAC_92HD83XXX_HEADSET_JACK),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0534,
1959 "Dell Latitude E6430", STAC_92HD83XXX_HEADSET_JACK),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0535,
1961 "Dell Latitude E6530", STAC_92HD83XXX_HEADSET_JACK),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053c,
1963 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
1964 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053d,
1965 "Dell Latitude E5530", STAC_92HD83XXX_HEADSET_JACK),
1966 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0549,
1967 "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
1968 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x057d,
1969 "Dell Latitude E6430s", STAC_92HD83XXX_HEADSET_JACK),
1970 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0584,
1971 "Dell Latitude E6430U", STAC_92HD83XXX_HEADSET_JACK),
1972 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1973 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
1974 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1975 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1976 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
1977 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
1979 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
1981 "HP Pavilion dv7", STAC_HP_DV7_4000),
1982 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
1983 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
1985 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df,
1987 "HP Folio", STAC_92HD83XXX_HP_MIC_LED),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
1989 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
1991 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
1993 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
1995 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
1997 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
1999 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
2001 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
2003 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
2005 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
2007 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
2009 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
2011 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
2013 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
2015 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
2017 "HP", STAC_HP_ZEPHYR),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660,
2019 "HP Mini", STAC_92HD83XXX_HP_LED),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x144E,
2021 "HP Pavilion dv5", STAC_92HD83XXX_HP_INV_LED),
2025 static const struct snd_pci_quirk stac92hd83xxx_codec_id_cfg_tbl[] = {
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
2027 "HP", STAC_HP_ZEPHYR),
2031 static const struct hda_pintbl ref92hd71bxx_pin_configs[] = {
2032 { 0x0a, 0x02214030 },
2033 { 0x0b, 0x02a19040 },
2034 { 0x0c, 0x01a19020 },
2035 { 0x0d, 0x01014010 },
2036 { 0x0e, 0x0181302e },
2037 { 0x0f, 0x01014010 },
2038 { 0x14, 0x01019020 },
2039 { 0x18, 0x90a000f0 },
2040 { 0x19, 0x90a000f0 },
2041 { 0x1e, 0x01452050 },
2042 { 0x1f, 0x01452050 },
2046 static const struct hda_pintbl dell_m4_1_pin_configs[] = {
2047 { 0x0a, 0x0421101f },
2048 { 0x0b, 0x04a11221 },
2049 { 0x0c, 0x40f000f0 },
2050 { 0x0d, 0x90170110 },
2051 { 0x0e, 0x23a1902e },
2052 { 0x0f, 0x23014250 },
2053 { 0x14, 0x40f000f0 },
2054 { 0x18, 0x90a000f0 },
2055 { 0x19, 0x40f000f0 },
2056 { 0x1e, 0x4f0000f0 },
2057 { 0x1f, 0x4f0000f0 },
2061 static const struct hda_pintbl dell_m4_2_pin_configs[] = {
2062 { 0x0a, 0x0421101f },
2063 { 0x0b, 0x04a11221 },
2064 { 0x0c, 0x90a70330 },
2065 { 0x0d, 0x90170110 },
2066 { 0x0e, 0x23a1902e },
2067 { 0x0f, 0x23014250 },
2068 { 0x14, 0x40f000f0 },
2069 { 0x18, 0x40f000f0 },
2070 { 0x19, 0x40f000f0 },
2071 { 0x1e, 0x044413b0 },
2072 { 0x1f, 0x044413b0 },
2076 static const struct hda_pintbl dell_m4_3_pin_configs[] = {
2077 { 0x0a, 0x0421101f },
2078 { 0x0b, 0x04a11221 },
2079 { 0x0c, 0x90a70330 },
2080 { 0x0d, 0x90170110 },
2081 { 0x0e, 0x40f000f0 },
2082 { 0x0f, 0x40f000f0 },
2083 { 0x14, 0x40f000f0 },
2084 { 0x18, 0x90a000f0 },
2085 { 0x19, 0x40f000f0 },
2086 { 0x1e, 0x044413b0 },
2087 { 0x1f, 0x044413b0 },
2091 static void stac92hd71bxx_fixup_ref(struct hda_codec *codec,
2092 const struct hda_fixup *fix, int action)
2094 struct sigmatel_spec *spec = codec->spec;
2096 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2099 snd_hda_apply_pincfgs(codec, ref92hd71bxx_pin_configs);
2100 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
2103 static void stac92hd71bxx_fixup_no_dmic(struct hda_codec *codec,
2104 const struct hda_fixup *fix, int action)
2106 struct sigmatel_spec *spec = codec->spec;
2108 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2110 spec->num_dmics = 0;
2111 spec->num_smuxes = 0;
2112 spec->num_dmuxes = 0;
2115 static void stac92hd71bxx_fixup_no_smux(struct hda_codec *codec,
2116 const struct hda_fixup *fix, int action)
2118 struct sigmatel_spec *spec = codec->spec;
2120 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2122 spec->num_dmics = 1;
2123 spec->num_smuxes = 0;
2124 spec->num_dmuxes = 1;
2127 static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec,
2128 const struct hda_fixup *fix, int action)
2130 struct sigmatel_spec *spec = codec->spec;
2132 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2135 /* Enable VREF power saving on GPIO1 detect */
2136 stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x02);
2137 snd_hda_codec_write_cache(codec, codec->afg, 0,
2138 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
2139 snd_hda_jack_detect_enable(codec, codec->afg, 0);
2140 spec->gpio_mask |= 0x02;
2142 /* enable internal microphone */
2143 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
2144 stac92xx_auto_set_pinctl(codec, 0x0e,
2145 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
2147 stac92hd71bxx_fixup_no_dmic(codec, fix, action);
2150 static void stac92hd71bxx_fixup_hp_dv4_1222nr(struct hda_codec *codec,
2151 const struct hda_fixup *fix, int action)
2153 struct sigmatel_spec *spec = codec->spec;
2155 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2157 spec->num_dmics = 1;
2158 /* I don't know if it needs 1 or 2 smuxes - will wait for
2159 * bug reports to fix if needed
2161 spec->num_smuxes = 1;
2162 spec->num_dmuxes = 1;
2165 static void stac92hd71bxx_fixup_hp_dv4(struct hda_codec *codec,
2166 const struct hda_fixup *fix, int action)
2168 struct sigmatel_spec *spec = codec->spec;
2170 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2172 spec->gpio_led = 0x01;
2175 static void stac92hd71bxx_fixup_hp_dv5(struct hda_codec *codec,
2176 const struct hda_fixup *fix, int action)
2178 struct sigmatel_spec *spec = codec->spec;
2182 case HDA_FIXUP_ACT_PRE_PROBE:
2183 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
2184 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
2185 /* HP dv6 gives the headphone pin as a line-out. Thus we
2186 * need to set hp_detect flag here to force to enable HP
2189 spec->hp_detect = 1;
2192 case HDA_FIXUP_ACT_PROBE:
2193 /* enable bass on HP dv7 */
2194 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
2195 cap &= AC_GPIO_IO_COUNT;
2197 stac_add_hp_bass_switch(codec);
2202 static void stac92hd71bxx_fixup_hp_hdx(struct hda_codec *codec,
2203 const struct hda_fixup *fix, int action)
2205 struct sigmatel_spec *spec = codec->spec;
2207 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2209 spec->gpio_led = 0x08;
2210 spec->num_dmics = 1;
2211 spec->num_smuxes = 1;
2212 spec->num_dmuxes = 1;
2216 static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,
2217 const struct hda_fixup *fix, int action)
2219 struct sigmatel_spec *spec = codec->spec;
2221 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2224 if (hp_blike_system(codec->subsystem_id)) {
2225 unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
2226 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
2227 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
2228 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
2229 /* It was changed in the BIOS to just satisfy MS DTM.
2230 * Lets turn it back into slaved HP
2232 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
2233 | (AC_JACK_HP_OUT <<
2234 AC_DEFCFG_DEVICE_SHIFT);
2235 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
2236 | AC_DEFCFG_SEQUENCE)))
2238 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
2242 if (find_mute_led_cfg(codec, 1))
2243 snd_printd("mute LED gpio %d polarity %d\n",
2245 spec->gpio_led_polarity);
2249 static const struct hda_fixup stac92hd71bxx_fixups[] = {
2250 [STAC_92HD71BXX_REF] = {
2251 .type = HDA_FIXUP_FUNC,
2252 .v.func = stac92hd71bxx_fixup_ref,
2254 [STAC_DELL_M4_1] = {
2255 .type = HDA_FIXUP_PINS,
2256 .v.pins = dell_m4_1_pin_configs,
2258 .chain_id = STAC_92HD71BXX_NO_SMUX,
2260 [STAC_DELL_M4_2] = {
2261 .type = HDA_FIXUP_PINS,
2262 .v.pins = dell_m4_2_pin_configs,
2264 .chain_id = STAC_92HD71BXX_NO_DMIC,
2266 [STAC_DELL_M4_3] = {
2267 .type = HDA_FIXUP_PINS,
2268 .v.pins = dell_m4_3_pin_configs,
2270 .chain_id = STAC_92HD71BXX_NO_SMUX,
2273 .type = HDA_FIXUP_FUNC,
2274 .v.func = stac92hd71bxx_fixup_hp_m4,
2276 .chain_id = STAC_92HD71BXX_HP,
2279 .type = HDA_FIXUP_FUNC,
2280 .v.func = stac92hd71bxx_fixup_hp_dv4,
2282 .chain_id = STAC_HP_DV5,
2285 .type = HDA_FIXUP_FUNC,
2286 .v.func = stac92hd71bxx_fixup_hp_dv5,
2288 .chain_id = STAC_92HD71BXX_HP,
2291 .type = HDA_FIXUP_FUNC,
2292 .v.func = stac92hd71bxx_fixup_hp_hdx,
2294 .chain_id = STAC_92HD71BXX_HP,
2296 [STAC_HP_DV4_1222NR] = {
2297 .type = HDA_FIXUP_FUNC,
2298 .v.func = stac92hd71bxx_fixup_hp_dv4_1222nr,
2300 .chain_id = STAC_HP_DV4,
2302 [STAC_92HD71BXX_NO_DMIC] = {
2303 .type = HDA_FIXUP_FUNC,
2304 .v.func = stac92hd71bxx_fixup_no_dmic,
2306 [STAC_92HD71BXX_NO_SMUX] = {
2307 .type = HDA_FIXUP_FUNC,
2308 .v.func = stac92hd71bxx_fixup_no_smux,
2310 [STAC_92HD71BXX_HP] = {
2311 .type = HDA_FIXUP_FUNC,
2312 .v.func = stac92hd71bxx_fixup_hp,
2316 static const struct hda_model_fixup stac92hd71bxx_models[] = {
2317 { .id = STAC_92HD71BXX_REF, .name = "ref" },
2318 { .id = STAC_DELL_M4_1, .name = "dell-m4-1" },
2319 { .id = STAC_DELL_M4_2, .name = "dell-m4-2" },
2320 { .id = STAC_DELL_M4_3, .name = "dell-m4-3" },
2321 { .id = STAC_HP_M4, .name = "hp-m4" },
2322 { .id = STAC_HP_DV4, .name = "hp-dv4" },
2323 { .id = STAC_HP_DV5, .name = "hp-dv5" },
2324 { .id = STAC_HP_HDX, .name = "hp-hdx" },
2325 { .id = STAC_HP_DV4_1222NR, .name = "hp-dv4-1222nr" },
2329 static const struct snd_pci_quirk stac92hd71bxx_fixup_tbl[] = {
2330 /* SigmaTel reference board */
2331 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2332 "DFI LanParty", STAC_92HD71BXX_REF),
2333 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2334 "DFI LanParty", STAC_92HD71BXX_REF),
2335 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
2336 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
2337 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
2339 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
2341 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
2342 "HP dv4-7", STAC_HP_DV4),
2343 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
2344 "HP dv4-7", STAC_HP_DV5),
2345 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
2346 "HP HDX", STAC_HP_HDX), /* HDX18 */
2347 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
2348 "HP mini 1000", STAC_HP_M4),
2349 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
2350 "HP HDX", STAC_HP_HDX), /* HDX16 */
2351 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
2352 "HP dv6", STAC_HP_DV5),
2353 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
2354 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
2355 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
2356 "HP DV6", STAC_HP_DV5),
2357 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
2359 SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD71BXX_HP),
2360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
2361 "unknown Dell", STAC_DELL_M4_1),
2362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
2363 "unknown Dell", STAC_DELL_M4_1),
2364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
2365 "unknown Dell", STAC_DELL_M4_1),
2366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
2367 "unknown Dell", STAC_DELL_M4_1),
2368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
2369 "unknown Dell", STAC_DELL_M4_1),
2370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
2371 "unknown Dell", STAC_DELL_M4_1),
2372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
2373 "unknown Dell", STAC_DELL_M4_1),
2374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
2375 "unknown Dell", STAC_DELL_M4_2),
2376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
2377 "unknown Dell", STAC_DELL_M4_2),
2378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
2379 "unknown Dell", STAC_DELL_M4_2),
2380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
2381 "unknown Dell", STAC_DELL_M4_2),
2382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
2383 "unknown Dell", STAC_DELL_M4_3),
2387 static const struct hda_pintbl ref922x_pin_configs[] = {
2388 { 0x0a, 0x01014010 },
2389 { 0x0b, 0x01016011 },
2390 { 0x0c, 0x01012012 },
2391 { 0x0d, 0x0221401f },
2392 { 0x0e, 0x01813122 },
2393 { 0x0f, 0x01011014 },
2394 { 0x10, 0x01441030 },
2395 { 0x11, 0x01c41030 },
2396 { 0x15, 0x40000100 },
2397 { 0x1b, 0x40000100 },
2402 STAC 922X pin configs for
2409 static const struct hda_pintbl dell_922x_d81_pin_configs[] = {
2410 { 0x0a, 0x02214030 },
2411 { 0x0b, 0x01a19021 },
2412 { 0x0c, 0x01111012 },
2413 { 0x0d, 0x01114010 },
2414 { 0x0e, 0x02a19020 },
2415 { 0x0f, 0x01117011 },
2416 { 0x10, 0x400001f0 },
2417 { 0x11, 0x400001f1 },
2418 { 0x15, 0x01813122 },
2419 { 0x1b, 0x400001f2 },
2424 STAC 922X pin configs for
2428 static const struct hda_pintbl dell_922x_d82_pin_configs[] = {
2429 { 0x0a, 0x02214030 },
2430 { 0x0b, 0x01a19021 },
2431 { 0x0c, 0x01111012 },
2432 { 0x0d, 0x01114010 },
2433 { 0x0e, 0x02a19020 },
2434 { 0x0f, 0x01117011 },
2435 { 0x10, 0x01451140 },
2436 { 0x11, 0x400001f0 },
2437 { 0x15, 0x01813122 },
2438 { 0x1b, 0x400001f1 },
2443 STAC 922X pin configs for
2446 static const struct hda_pintbl dell_922x_m81_pin_configs[] = {
2447 { 0x0a, 0x0321101f },
2448 { 0x0b, 0x01112024 },
2449 { 0x0c, 0x01111222 },
2450 { 0x0d, 0x91174220 },
2451 { 0x0e, 0x03a11050 },
2452 { 0x0f, 0x01116221 },
2453 { 0x10, 0x90a70330 },
2454 { 0x11, 0x01452340 },
2455 { 0x15, 0x40C003f1 },
2456 { 0x1b, 0x405003f0 },
2461 STAC 9221 A1 pin configs for
2462 102801D7 (Dell XPS M1210)
2464 static const struct hda_pintbl dell_922x_m82_pin_configs[] = {
2465 { 0x0a, 0x02211211 },
2466 { 0x0b, 0x408103ff },
2467 { 0x0c, 0x02a1123e },
2468 { 0x0d, 0x90100310 },
2469 { 0x0e, 0x408003f1 },
2470 { 0x0f, 0x0221121f },
2471 { 0x10, 0x03451340 },
2472 { 0x11, 0x40c003f2 },
2473 { 0x15, 0x508003f3 },
2474 { 0x1b, 0x405003f4 },
2478 static const struct hda_pintbl d945gtp3_pin_configs[] = {
2479 { 0x0a, 0x0221401f },
2480 { 0x0b, 0x01a19022 },
2481 { 0x0c, 0x01813021 },
2482 { 0x0d, 0x01014010 },
2483 { 0x0e, 0x40000100 },
2484 { 0x0f, 0x40000100 },
2485 { 0x10, 0x40000100 },
2486 { 0x11, 0x40000100 },
2487 { 0x15, 0x02a19120 },
2488 { 0x1b, 0x40000100 },
2492 static const struct hda_pintbl d945gtp5_pin_configs[] = {
2493 { 0x0a, 0x0221401f },
2494 { 0x0b, 0x01011012 },
2495 { 0x0c, 0x01813024 },
2496 { 0x0d, 0x01014010 },
2497 { 0x0e, 0x01a19021 },
2498 { 0x0f, 0x01016011 },
2499 { 0x10, 0x01452130 },
2500 { 0x11, 0x40000100 },
2501 { 0x15, 0x02a19320 },
2502 { 0x1b, 0x40000100 },
2506 static const struct hda_pintbl intel_mac_v1_pin_configs[] = {
2507 { 0x0a, 0x0121e21f },
2508 { 0x0b, 0x400000ff },
2509 { 0x0c, 0x9017e110 },
2510 { 0x0d, 0x400000fd },
2511 { 0x0e, 0x400000fe },
2512 { 0x0f, 0x0181e020 },
2513 { 0x10, 0x1145e030 },
2514 { 0x11, 0x11c5e240 },
2515 { 0x15, 0x400000fc },
2516 { 0x1b, 0x400000fb },
2520 static const struct hda_pintbl intel_mac_v2_pin_configs[] = {
2521 { 0x0a, 0x0121e21f },
2522 { 0x0b, 0x90a7012e },
2523 { 0x0c, 0x9017e110 },
2524 { 0x0d, 0x400000fd },
2525 { 0x0e, 0x400000fe },
2526 { 0x0f, 0x0181e020 },
2527 { 0x10, 0x1145e230 },
2528 { 0x11, 0x500000fa },
2529 { 0x15, 0x400000fc },
2530 { 0x1b, 0x400000fb },
2534 static const struct hda_pintbl intel_mac_v3_pin_configs[] = {
2535 { 0x0a, 0x0121e21f },
2536 { 0x0b, 0x90a7012e },
2537 { 0x0c, 0x9017e110 },
2538 { 0x0d, 0x400000fd },
2539 { 0x0e, 0x400000fe },
2540 { 0x0f, 0x0181e020 },
2541 { 0x10, 0x1145e230 },
2542 { 0x11, 0x11c5e240 },
2543 { 0x15, 0x400000fc },
2544 { 0x1b, 0x400000fb },
2548 static const struct hda_pintbl intel_mac_v4_pin_configs[] = {
2549 { 0x0a, 0x0321e21f },
2550 { 0x0b, 0x03a1e02e },
2551 { 0x0c, 0x9017e110 },
2552 { 0x0d, 0x9017e11f },
2553 { 0x0e, 0x400000fe },
2554 { 0x0f, 0x0381e020 },
2555 { 0x10, 0x1345e230 },
2556 { 0x11, 0x13c5e240 },
2557 { 0x15, 0x400000fc },
2558 { 0x1b, 0x400000fb },
2562 static const struct hda_pintbl intel_mac_v5_pin_configs[] = {
2563 { 0x0a, 0x0321e21f },
2564 { 0x0b, 0x03a1e02e },
2565 { 0x0c, 0x9017e110 },
2566 { 0x0d, 0x9017e11f },
2567 { 0x0e, 0x400000fe },
2568 { 0x0f, 0x0381e020 },
2569 { 0x10, 0x1345e230 },
2570 { 0x11, 0x13c5e240 },
2571 { 0x15, 0x400000fc },
2572 { 0x1b, 0x400000fb },
2576 static const struct hda_pintbl ecs202_pin_configs[] = {
2577 { 0x0a, 0x0221401f },
2578 { 0x0b, 0x02a19020 },
2579 { 0x0c, 0x01a19020 },
2580 { 0x0d, 0x01114010 },
2581 { 0x0e, 0x408000f0 },
2582 { 0x0f, 0x01813022 },
2583 { 0x10, 0x074510a0 },
2584 { 0x11, 0x40c400f1 },
2585 { 0x15, 0x9037012e },
2586 { 0x1b, 0x40e000f2 },
2590 /* codec SSIDs for Intel Mac sharing the same PCI SSID 8384:7680 */
2591 static const struct snd_pci_quirk stac922x_intel_mac_fixup_tbl[] = {
2592 SND_PCI_QUIRK(0x106b, 0x0800, "Mac", STAC_INTEL_MAC_V1),
2593 SND_PCI_QUIRK(0x106b, 0x0600, "Mac", STAC_INTEL_MAC_V2),
2594 SND_PCI_QUIRK(0x106b, 0x0700, "Mac", STAC_INTEL_MAC_V2),
2595 SND_PCI_QUIRK(0x106b, 0x0e00, "Mac", STAC_INTEL_MAC_V3),
2596 SND_PCI_QUIRK(0x106b, 0x0f00, "Mac", STAC_INTEL_MAC_V3),
2597 SND_PCI_QUIRK(0x106b, 0x1600, "Mac", STAC_INTEL_MAC_V3),
2598 SND_PCI_QUIRK(0x106b, 0x1700, "Mac", STAC_INTEL_MAC_V3),
2599 SND_PCI_QUIRK(0x106b, 0x0200, "Mac", STAC_INTEL_MAC_V3),
2600 SND_PCI_QUIRK(0x106b, 0x1e00, "Mac", STAC_INTEL_MAC_V3),
2601 SND_PCI_QUIRK(0x106b, 0x1a00, "Mac", STAC_INTEL_MAC_V4),
2602 SND_PCI_QUIRK(0x106b, 0x0a00, "Mac", STAC_INTEL_MAC_V5),
2603 SND_PCI_QUIRK(0x106b, 0x2200, "Mac", STAC_INTEL_MAC_V5),
2607 static const struct hda_fixup stac922x_fixups[];
2609 /* remap the fixup from codec SSID and apply it */
2610 static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec,
2611 const struct hda_fixup *fix,
2614 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2616 snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl,
2618 if (codec->fixup_id != STAC_INTEL_MAC_AUTO)
2619 snd_hda_apply_fixup(codec, action);
2622 static void stac922x_fixup_intel_mac_gpio(struct hda_codec *codec,
2623 const struct hda_fixup *fix,
2626 struct sigmatel_spec *spec = codec->spec;
2628 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2629 spec->gpio_mask = spec->gpio_dir = 0x03;
2630 spec->gpio_data = 0x03;
2634 static const struct hda_fixup stac922x_fixups[] = {
2636 .type = HDA_FIXUP_PINS,
2637 .v.pins = ref922x_pin_configs,
2640 .type = HDA_FIXUP_PINS,
2641 .v.pins = d945gtp3_pin_configs,
2644 .type = HDA_FIXUP_PINS,
2645 .v.pins = d945gtp5_pin_configs,
2647 [STAC_INTEL_MAC_AUTO] = {
2648 .type = HDA_FIXUP_FUNC,
2649 .v.func = stac922x_fixup_intel_mac_auto,
2651 [STAC_INTEL_MAC_V1] = {
2652 .type = HDA_FIXUP_PINS,
2653 .v.pins = intel_mac_v1_pin_configs,
2655 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2657 [STAC_INTEL_MAC_V2] = {
2658 .type = HDA_FIXUP_PINS,
2659 .v.pins = intel_mac_v2_pin_configs,
2661 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2663 [STAC_INTEL_MAC_V3] = {
2664 .type = HDA_FIXUP_PINS,
2665 .v.pins = intel_mac_v3_pin_configs,
2667 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2669 [STAC_INTEL_MAC_V4] = {
2670 .type = HDA_FIXUP_PINS,
2671 .v.pins = intel_mac_v4_pin_configs,
2673 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2675 [STAC_INTEL_MAC_V5] = {
2676 .type = HDA_FIXUP_PINS,
2677 .v.pins = intel_mac_v5_pin_configs,
2679 .chain_id = STAC_922X_INTEL_MAC_GPIO,
2681 [STAC_922X_INTEL_MAC_GPIO] = {
2682 .type = HDA_FIXUP_FUNC,
2683 .v.func = stac922x_fixup_intel_mac_gpio,
2686 .type = HDA_FIXUP_PINS,
2687 .v.pins = ecs202_pin_configs,
2689 [STAC_922X_DELL_D81] = {
2690 .type = HDA_FIXUP_PINS,
2691 .v.pins = dell_922x_d81_pin_configs,
2693 [STAC_922X_DELL_D82] = {
2694 .type = HDA_FIXUP_PINS,
2695 .v.pins = dell_922x_d82_pin_configs,
2697 [STAC_922X_DELL_M81] = {
2698 .type = HDA_FIXUP_PINS,
2699 .v.pins = dell_922x_m81_pin_configs,
2701 [STAC_922X_DELL_M82] = {
2702 .type = HDA_FIXUP_PINS,
2703 .v.pins = dell_922x_m82_pin_configs,
2707 static const struct hda_model_fixup stac922x_models[] = {
2708 { .id = STAC_D945_REF, .name = "ref" },
2709 { .id = STAC_D945GTP5, .name = "5stack" },
2710 { .id = STAC_D945GTP3, .name = "3stack" },
2711 { .id = STAC_INTEL_MAC_V1, .name = "intel-mac-v1" },
2712 { .id = STAC_INTEL_MAC_V2, .name = "intel-mac-v2" },
2713 { .id = STAC_INTEL_MAC_V3, .name = "intel-mac-v3" },
2714 { .id = STAC_INTEL_MAC_V4, .name = "intel-mac-v4" },
2715 { .id = STAC_INTEL_MAC_V5, .name = "intel-mac-v5" },
2716 { .id = STAC_INTEL_MAC_AUTO, .name = "intel-mac-auto" },
2717 { .id = STAC_ECS_202, .name = "ecs202" },
2718 { .id = STAC_922X_DELL_D81, .name = "dell-d81" },
2719 { .id = STAC_922X_DELL_D82, .name = "dell-d82" },
2720 { .id = STAC_922X_DELL_M81, .name = "dell-m81" },
2721 { .id = STAC_922X_DELL_M82, .name = "dell-m82" },
2722 /* for backward compatibility */
2723 { .id = STAC_INTEL_MAC_V3, .name = "macmini" },
2724 { .id = STAC_INTEL_MAC_V5, .name = "macbook" },
2725 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro-v1" },
2726 { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro" },
2727 { .id = STAC_INTEL_MAC_V2, .name = "imac-intel" },
2728 { .id = STAC_INTEL_MAC_V3, .name = "imac-intel-20" },
2732 static const struct snd_pci_quirk stac922x_fixup_tbl[] = {
2733 /* SigmaTel reference board */
2734 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2735 "DFI LanParty", STAC_D945_REF),
2736 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2737 "DFI LanParty", STAC_D945_REF),
2738 /* Intel 945G based systems */
2739 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2740 "Intel D945G", STAC_D945GTP3),
2741 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2742 "Intel D945G", STAC_D945GTP3),
2743 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2744 "Intel D945G", STAC_D945GTP3),
2745 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2746 "Intel D945G", STAC_D945GTP3),
2747 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2748 "Intel D945G", STAC_D945GTP3),
2749 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2750 "Intel D945G", STAC_D945GTP3),
2751 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2752 "Intel D945G", STAC_D945GTP3),
2753 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2754 "Intel D945G", STAC_D945GTP3),
2755 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2756 "Intel D945G", STAC_D945GTP3),
2757 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2758 "Intel D945G", STAC_D945GTP3),
2759 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2760 "Intel D945G", STAC_D945GTP3),
2761 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2762 "Intel D945G", STAC_D945GTP3),
2763 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2764 "Intel D945G", STAC_D945GTP3),
2765 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2766 "Intel D945G", STAC_D945GTP3),
2767 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2768 "Intel D945G", STAC_D945GTP3),
2769 /* Intel D945G 5-stack systems */
2770 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2771 "Intel D945G", STAC_D945GTP5),
2772 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2773 "Intel D945G", STAC_D945GTP5),
2774 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2775 "Intel D945G", STAC_D945GTP5),
2776 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2777 "Intel D945G", STAC_D945GTP5),
2778 /* Intel 945P based systems */
2779 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2780 "Intel D945P", STAC_D945GTP3),
2781 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2782 "Intel D945P", STAC_D945GTP3),
2783 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2784 "Intel D945P", STAC_D945GTP3),
2785 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2786 "Intel D945P", STAC_D945GTP3),
2787 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2788 "Intel D945P", STAC_D945GTP3),
2789 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2790 "Intel D945P", STAC_D945GTP5),
2792 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2793 "Intel D945", STAC_D945_REF),
2796 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2797 SND_PCI_QUIRK(0x8384, 0x7680, "Mac", STAC_INTEL_MAC_AUTO),
2800 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2801 "unknown Dell", STAC_922X_DELL_D81),
2802 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2803 "unknown Dell", STAC_922X_DELL_D81),
2804 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2805 "unknown Dell", STAC_922X_DELL_D81),
2806 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2807 "unknown Dell", STAC_922X_DELL_D82),
2808 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2809 "unknown Dell", STAC_922X_DELL_M81),
2810 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2811 "unknown Dell", STAC_922X_DELL_D82),
2812 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2813 "unknown Dell", STAC_922X_DELL_D81),
2814 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2815 "unknown Dell", STAC_922X_DELL_D81),
2816 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2817 "Dell XPS M1210", STAC_922X_DELL_M82),
2818 /* ECS/PC Chips boards */
2819 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2820 "ECS/PC chips", STAC_ECS_202),
2824 static const struct hda_pintbl ref927x_pin_configs[] = {
2825 { 0x0a, 0x02214020 },
2826 { 0x0b, 0x02a19080 },
2827 { 0x0c, 0x0181304e },
2828 { 0x0d, 0x01014010 },
2829 { 0x0e, 0x01a19040 },
2830 { 0x0f, 0x01011012 },
2831 { 0x10, 0x01016011 },
2832 { 0x11, 0x0101201f },
2833 { 0x12, 0x183301f0 },
2834 { 0x13, 0x18a001f0 },
2835 { 0x14, 0x18a001f0 },
2836 { 0x21, 0x01442070 },
2837 { 0x22, 0x01c42190 },
2838 { 0x23, 0x40000100 },
2842 static const struct hda_pintbl d965_3st_pin_configs[] = {
2843 { 0x0a, 0x0221401f },
2844 { 0x0b, 0x02a19120 },
2845 { 0x0c, 0x40000100 },
2846 { 0x0d, 0x01014011 },
2847 { 0x0e, 0x01a19021 },
2848 { 0x0f, 0x01813024 },
2849 { 0x10, 0x40000100 },
2850 { 0x11, 0x40000100 },
2851 { 0x12, 0x40000100 },
2852 { 0x13, 0x40000100 },
2853 { 0x14, 0x40000100 },
2854 { 0x21, 0x40000100 },
2855 { 0x22, 0x40000100 },
2856 { 0x23, 0x40000100 },
2860 static const struct hda_pintbl d965_5st_pin_configs[] = {
2861 { 0x0a, 0x02214020 },
2862 { 0x0b, 0x02a19080 },
2863 { 0x0c, 0x0181304e },
2864 { 0x0d, 0x01014010 },
2865 { 0x0e, 0x01a19040 },
2866 { 0x0f, 0x01011012 },
2867 { 0x10, 0x01016011 },
2868 { 0x11, 0x40000100 },
2869 { 0x12, 0x40000100 },
2870 { 0x13, 0x40000100 },
2871 { 0x14, 0x40000100 },
2872 { 0x21, 0x01442070 },
2873 { 0x22, 0x40000100 },
2874 { 0x23, 0x40000100 },
2878 static const struct hda_pintbl d965_5st_no_fp_pin_configs[] = {
2879 { 0x0a, 0x40000100 },
2880 { 0x0b, 0x40000100 },
2881 { 0x0c, 0x0181304e },
2882 { 0x0d, 0x01014010 },
2883 { 0x0e, 0x01a19040 },
2884 { 0x0f, 0x01011012 },
2885 { 0x10, 0x01016011 },
2886 { 0x11, 0x40000100 },
2887 { 0x12, 0x40000100 },
2888 { 0x13, 0x40000100 },
2889 { 0x14, 0x40000100 },
2890 { 0x21, 0x01442070 },
2891 { 0x22, 0x40000100 },
2892 { 0x23, 0x40000100 },
2896 static const struct hda_pintbl dell_3st_pin_configs[] = {
2897 { 0x0a, 0x02211230 },
2898 { 0x0b, 0x02a11220 },
2899 { 0x0c, 0x01a19040 },
2900 { 0x0d, 0x01114210 },
2901 { 0x0e, 0x01111212 },
2902 { 0x0f, 0x01116211 },
2903 { 0x10, 0x01813050 },
2904 { 0x11, 0x01112214 },
2905 { 0x12, 0x403003fa },
2906 { 0x13, 0x90a60040 },
2907 { 0x14, 0x90a60040 },
2908 { 0x21, 0x404003fb },
2909 { 0x22, 0x40c003fc },
2910 { 0x23, 0x40000100 },
2914 static void stac927x_fixup_ref_no_jd(struct hda_codec *codec,
2915 const struct hda_fixup *fix, int action)
2917 struct sigmatel_spec *spec = codec->spec;
2919 /* no jack detecion for ref-no-jd model */
2920 if (action == HDA_FIXUP_ACT_PROBE)
2921 spec->hp_detect = 0;
2924 static void stac927x_fixup_ref(struct hda_codec *codec,
2925 const struct hda_fixup *fix, int action)
2927 struct sigmatel_spec *spec = codec->spec;
2929 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2930 snd_hda_apply_pincfgs(codec, ref927x_pin_configs);
2931 spec->eapd_mask = spec->gpio_mask = 0;
2932 spec->gpio_dir = spec->gpio_data = 0;
2936 static void stac927x_fixup_dell_dmic(struct hda_codec *codec,
2937 const struct hda_fixup *fix, int action)
2939 struct sigmatel_spec *spec = codec->spec;
2941 if (action != HDA_FIXUP_ACT_PRE_PROBE)
2944 if (codec->subsystem_id != 0x1028022f) {
2945 /* GPIO2 High = Enable EAPD */
2946 spec->eapd_mask = spec->gpio_mask = 0x04;
2947 spec->gpio_dir = spec->gpio_data = 0x04;
2949 spec->dmic_nids = stac927x_dmic_nids;
2950 spec->num_dmics = STAC927X_NUM_DMICS;
2952 snd_hda_add_verbs(codec, dell_3st_core_init);
2953 spec->volknob_init = 1;
2954 spec->dmux_nids = stac927x_dmux_nids;
2955 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
2958 static void stac927x_fixup_volknob(struct hda_codec *codec,
2959 const struct hda_fixup *fix, int action)
2961 struct sigmatel_spec *spec = codec->spec;
2963 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2964 snd_hda_add_verbs(codec, stac927x_volknob_core_init);
2965 spec->volknob_init = 1;
2969 static const struct hda_fixup stac927x_fixups[] = {
2970 [STAC_D965_REF_NO_JD] = {
2971 .type = HDA_FIXUP_FUNC,
2972 .v.func = stac927x_fixup_ref_no_jd,
2974 .chain_id = STAC_D965_REF,
2977 .type = HDA_FIXUP_FUNC,
2978 .v.func = stac927x_fixup_ref,
2981 .type = HDA_FIXUP_PINS,
2982 .v.pins = d965_3st_pin_configs,
2984 .chain_id = STAC_D965_VERBS,
2987 .type = HDA_FIXUP_PINS,
2988 .v.pins = d965_5st_pin_configs,
2990 .chain_id = STAC_D965_VERBS,
2992 [STAC_D965_VERBS] = {
2993 .type = HDA_FIXUP_VERBS,
2994 .v.verbs = d965_core_init,
2996 [STAC_D965_5ST_NO_FP] = {
2997 .type = HDA_FIXUP_PINS,
2998 .v.pins = d965_5st_no_fp_pin_configs,
3001 .type = HDA_FIXUP_PINS,
3002 .v.pins = dell_3st_pin_configs,
3004 .chain_id = STAC_927X_DELL_DMIC,
3006 [STAC_DELL_BIOS] = {
3007 .type = HDA_FIXUP_PINS,
3008 .v.pins = (const struct hda_pintbl[]) {
3009 /* configure the analog microphone on some laptops */
3010 { 0x0c, 0x90a79130 },
3011 /* correct the front output jack as a hp out */
3012 { 0x0f, 0x0227011f },
3013 /* correct the front input jack as a mic */
3014 { 0x0e, 0x02a79130 },
3018 .chain_id = STAC_927X_DELL_DMIC,
3020 [STAC_DELL_BIOS_SPDIF] = {
3021 .type = HDA_FIXUP_PINS,
3022 .v.pins = (const struct hda_pintbl[]) {
3023 /* correct the device field to SPDIF out */
3024 { 0x21, 0x01442070 },
3028 .chain_id = STAC_DELL_BIOS,
3030 [STAC_927X_DELL_DMIC] = {
3031 .type = HDA_FIXUP_FUNC,
3032 .v.func = stac927x_fixup_dell_dmic,
3034 [STAC_927X_VOLKNOB] = {
3035 .type = HDA_FIXUP_FUNC,
3036 .v.func = stac927x_fixup_volknob,
3040 static const struct hda_model_fixup stac927x_models[] = {
3041 { .id = STAC_D965_REF_NO_JD, .name = "ref-no-jd" },
3042 { .id = STAC_D965_REF, .name = "ref" },
3043 { .id = STAC_D965_3ST, .name = "3stack" },
3044 { .id = STAC_D965_5ST, .name = "5stack" },
3045 { .id = STAC_D965_5ST_NO_FP, .name = "5stack-no-fp" },
3046 { .id = STAC_DELL_3ST, .name = "dell-3stack" },
3047 { .id = STAC_DELL_BIOS, .name = "dell-bios" },
3048 { .id = STAC_927X_VOLKNOB, .name = "volknob" },
3052 static const struct snd_pci_quirk stac927x_fixup_tbl[] = {
3053 /* SigmaTel reference board */
3054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3055 "DFI LanParty", STAC_D965_REF),
3056 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3057 "DFI LanParty", STAC_D965_REF),
3058 /* Intel 946 based systems */
3059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
3060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
3061 /* 965 based 3 stack systems */
3062 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
3063 "Intel D965", STAC_D965_3ST),
3064 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
3065 "Intel D965", STAC_D965_3ST),
3066 /* Dell 3 stack systems */
3067 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
3068 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
3069 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
3070 /* Dell 3 stack systems with verb table in BIOS */
3071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
3072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
3073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
3074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS_SPDIF),
3075 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
3076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
3077 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
3078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
3079 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS_SPDIF),
3080 /* 965 based 5 stack systems */
3081 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
3082 "Intel D965", STAC_D965_5ST),
3083 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
3084 "Intel D965", STAC_D965_5ST),
3085 /* volume-knob fixes */
3086 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
3090 static const struct hda_pintbl ref9205_pin_configs[] = {
3091 { 0x0a, 0x40000100 },
3092 { 0x0b, 0x40000100 },
3093 { 0x0c, 0x01016011 },
3094 { 0x0d, 0x01014010 },
3095 { 0x0e, 0x01813122 },
3096 { 0x0f, 0x01a19021 },
3097 { 0x14, 0x01019020 },
3098 { 0x16, 0x40000100 },
3099 { 0x17, 0x90a000f0 },
3100 { 0x18, 0x90a000f0 },
3101 { 0x21, 0x01441030 },
3102 { 0x22, 0x01c41030 },
3107 STAC 9205 pin configs for
3114 10280228 (Dell Vostro 1500)
3115 10280229 (Dell Vostro 1700)
3117 static const struct hda_pintbl dell_9205_m42_pin_configs[] = {
3118 { 0x0a, 0x0321101F },
3119 { 0x0b, 0x03A11020 },
3120 { 0x0c, 0x400003FA },
3121 { 0x0d, 0x90170310 },
3122 { 0x0e, 0x400003FB },
3123 { 0x0f, 0x400003FC },
3124 { 0x14, 0x400003FD },
3125 { 0x16, 0x40F000F9 },
3126 { 0x17, 0x90A60330 },
3127 { 0x18, 0x400003FF },
3128 { 0x21, 0x0144131F },
3129 { 0x22, 0x40C003FE },
3134 STAC 9205 pin configs for
3138 102801FF (Dell Precision M4300)
3143 static const struct hda_pintbl dell_9205_m43_pin_configs[] = {
3144 { 0x0a, 0x0321101f },
3145 { 0x0b, 0x03a11020 },
3146 { 0x0c, 0x90a70330 },
3147 { 0x0d, 0x90170310 },
3148 { 0x0e, 0x400000fe },
3149 { 0x0f, 0x400000ff },
3150 { 0x14, 0x400000fd },
3151 { 0x16, 0x40f000f9 },
3152 { 0x17, 0x400000fa },
3153 { 0x18, 0x400000fc },
3154 { 0x21, 0x0144131f },
3155 { 0x22, 0x40c003f8 },
3156 /* Enable SPDIF in/out */
3157 { 0x1f, 0x01441030 },
3158 { 0x20, 0x1c410030 },
3162 static const struct hda_pintbl dell_9205_m44_pin_configs[] = {
3163 { 0x0a, 0x0421101f },
3164 { 0x0b, 0x04a11020 },
3165 { 0x0c, 0x400003fa },
3166 { 0x0d, 0x90170310 },
3167 { 0x0e, 0x400003fb },
3168 { 0x0f, 0x400003fc },
3169 { 0x14, 0x400003fd },
3170 { 0x16, 0x400003f9 },
3171 { 0x17, 0x90a60330 },
3172 { 0x18, 0x400003ff },
3173 { 0x21, 0x01441340 },
3174 { 0x22, 0x40c003fe },
3178 static void stac9205_fixup_ref(struct hda_codec *codec,
3179 const struct hda_fixup *fix, int action)
3181 struct sigmatel_spec *spec = codec->spec;
3183 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3184 snd_hda_apply_pincfgs(codec, ref9205_pin_configs);
3185 /* SPDIF-In enabled */
3186 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0;
3190 static void stac9205_fixup_dell_m43(struct hda_codec *codec,
3191 const struct hda_fixup *fix, int action)
3193 struct sigmatel_spec *spec = codec->spec;
3196 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3197 snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs);
3199 /* Enable unsol response for GPIO4/Dock HP connection */
3200 err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
3203 snd_hda_codec_write_cache(codec, codec->afg, 0,
3204 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
3205 snd_hda_jack_detect_enable(codec, codec->afg, 0);
3207 spec->gpio_dir = 0x0b;
3208 spec->eapd_mask = 0x01;
3209 spec->gpio_mask = 0x1b;
3210 spec->gpio_mute = 0x10;
3211 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
3214 spec->gpio_data = 0x01;
3218 static void stac9205_fixup_eapd(struct hda_codec *codec,
3219 const struct hda_fixup *fix, int action)
3221 struct sigmatel_spec *spec = codec->spec;
3223 if (action == HDA_FIXUP_ACT_PRE_PROBE)
3224 spec->eapd_switch = 0;
3227 static const struct hda_fixup stac9205_fixups[] = {
3229 .type = HDA_FIXUP_FUNC,
3230 .v.func = stac9205_fixup_ref,
3232 [STAC_9205_DELL_M42] = {
3233 .type = HDA_FIXUP_PINS,
3234 .v.pins = dell_9205_m42_pin_configs,
3236 [STAC_9205_DELL_M43] = {
3237 .type = HDA_FIXUP_FUNC,
3238 .v.func = stac9205_fixup_dell_m43,
3240 [STAC_9205_DELL_M44] = {
3241 .type = HDA_FIXUP_PINS,
3242 .v.pins = dell_9205_m44_pin_configs,
3244 [STAC_9205_EAPD] = {
3245 .type = HDA_FIXUP_FUNC,
3246 .v.func = stac9205_fixup_eapd,
3251 static const struct hda_model_fixup stac9205_models[] = {
3252 { .id = STAC_9205_REF, .name = "ref" },
3253 { .id = STAC_9205_DELL_M42, .name = "dell-m42" },
3254 { .id = STAC_9205_DELL_M43, .name = "dell-m43" },
3255 { .id = STAC_9205_DELL_M44, .name = "dell-m44" },
3256 { .id = STAC_9205_EAPD, .name = "eapd" },
3260 static const struct snd_pci_quirk stac9205_fixup_tbl[] = {
3261 /* SigmaTel reference board */
3262 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
3263 "DFI LanParty", STAC_9205_REF),
3264 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
3265 "SigmaTel", STAC_9205_REF),
3266 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
3267 "DFI LanParty", STAC_9205_REF),
3269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
3270 "unknown Dell", STAC_9205_DELL_M42),
3271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
3272 "unknown Dell", STAC_9205_DELL_M42),
3273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
3274 "Dell Precision", STAC_9205_DELL_M43),
3275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
3276 "Dell Precision", STAC_9205_DELL_M43),
3277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
3278 "Dell Precision", STAC_9205_DELL_M43),
3279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
3280 "unknown Dell", STAC_9205_DELL_M42),
3281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
3282 "unknown Dell", STAC_9205_DELL_M42),
3283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
3284 "Dell Precision", STAC_9205_DELL_M43),
3285 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
3286 "Dell Precision M4300", STAC_9205_DELL_M43),
3287 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
3288 "unknown Dell", STAC_9205_DELL_M42),
3289 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
3290 "Dell Precision", STAC_9205_DELL_M43),
3291 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
3292 "Dell Precision", STAC_9205_DELL_M43),
3293 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
3294 "Dell Precision", STAC_9205_DELL_M43),
3295 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
3296 "Dell Inspiron", STAC_9205_DELL_M44),
3297 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
3298 "Dell Vostro 1500", STAC_9205_DELL_M42),
3299 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
3300 "Dell Vostro 1700", STAC_9205_DELL_M42),
3302 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
3303 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
3307 static void stac92xx_set_config_regs(struct hda_codec *codec,
3308 const unsigned int *pincfgs)
3311 struct sigmatel_spec *spec = codec->spec;
3316 for (i = 0; i < spec->num_pins; i++)
3317 if (spec->pin_nids[i] && pincfgs[i])
3318 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
3323 * Analog playback callbacks
3325 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
3326 struct hda_codec *codec,
3327 struct snd_pcm_substream *substream)
3329 struct sigmatel_spec *spec = codec->spec;
3330 if (spec->stream_delay)
3331 msleep(spec->stream_delay);
3332 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3336 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3337 struct hda_codec *codec,
3338 unsigned int stream_tag,
3339 unsigned int format,
3340 struct snd_pcm_substream *substream)
3342 struct sigmatel_spec *spec = codec->spec;
3343 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
3346 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3347 struct hda_codec *codec,
3348 struct snd_pcm_substream *substream)
3350 struct sigmatel_spec *spec = codec->spec;
3351 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3355 * Digital playback callbacks
3357 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3358 struct hda_codec *codec,
3359 struct snd_pcm_substream *substream)
3361 struct sigmatel_spec *spec = codec->spec;
3362 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3365 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3366 struct hda_codec *codec,
3367 struct snd_pcm_substream *substream)
3369 struct sigmatel_spec *spec = codec->spec;
3370 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3373 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3374 struct hda_codec *codec,
3375 unsigned int stream_tag,
3376 unsigned int format,
3377 struct snd_pcm_substream *substream)
3379 struct sigmatel_spec *spec = codec->spec;
3380 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3381 stream_tag, format, substream);
3384 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3385 struct hda_codec *codec,
3386 struct snd_pcm_substream *substream)
3388 struct sigmatel_spec *spec = codec->spec;
3389 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3394 * Analog capture callbacks
3396 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3397 struct hda_codec *codec,
3398 unsigned int stream_tag,
3399 unsigned int format,
3400 struct snd_pcm_substream *substream)
3402 struct sigmatel_spec *spec = codec->spec;
3403 hda_nid_t nid = spec->adc_nids[substream->number];
3405 if (spec->powerdown_adcs) {
3407 snd_hda_codec_write(codec, nid, 0,
3408 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
3410 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
3414 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3415 struct hda_codec *codec,
3416 struct snd_pcm_substream *substream)
3418 struct sigmatel_spec *spec = codec->spec;
3419 hda_nid_t nid = spec->adc_nids[substream->number];
3421 snd_hda_codec_cleanup_stream(codec, nid);
3422 if (spec->powerdown_adcs)
3423 snd_hda_codec_write(codec, nid, 0,
3424 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3428 static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
3432 /* NID is set in stac92xx_build_pcms */
3434 .open = stac92xx_dig_playback_pcm_open,
3435 .close = stac92xx_dig_playback_pcm_close,
3436 .prepare = stac92xx_dig_playback_pcm_prepare,
3437 .cleanup = stac92xx_dig_playback_pcm_cleanup
3441 static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
3445 /* NID is set in stac92xx_build_pcms */
3448 static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
3452 .nid = 0x02, /* NID to query formats and rates */
3454 .open = stac92xx_playback_pcm_open,
3455 .prepare = stac92xx_playback_pcm_prepare,
3456 .cleanup = stac92xx_playback_pcm_cleanup
3460 static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
3464 .nid = 0x06, /* NID to query formats and rates */
3466 .open = stac92xx_playback_pcm_open,
3467 .prepare = stac92xx_playback_pcm_prepare,
3468 .cleanup = stac92xx_playback_pcm_cleanup
3472 static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
3475 /* NID + .substreams is set in stac92xx_build_pcms */
3477 .prepare = stac92xx_capture_pcm_prepare,
3478 .cleanup = stac92xx_capture_pcm_cleanup
3482 static int stac92xx_build_pcms(struct hda_codec *codec)
3484 struct sigmatel_spec *spec = codec->spec;
3485 struct hda_pcm *info = spec->pcm_rec;
3487 codec->num_pcms = 1;
3488 codec->pcm_info = info;
3490 info->name = "STAC92xx Analog";
3491 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
3492 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3493 spec->multiout.dac_nids[0];
3494 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3495 spec->autocfg.line_outs == 2)
3496 info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap =
3499 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
3500 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3501 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
3503 if (spec->alt_switch) {
3506 info->name = "STAC92xx Analog Alt";
3507 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
3510 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3513 info->name = "STAC92xx Digital";
3514 info->pcm_type = spec->autocfg.dig_out_type[0];
3515 if (spec->multiout.dig_out_nid) {
3516 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
3517 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3519 if (spec->dig_in_nid) {
3520 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
3521 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3528 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
3531 snd_hda_set_pin_ctl_cache(codec, nid, pin_type);
3534 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
3536 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
3537 struct snd_ctl_elem_value *ucontrol)
3539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3540 struct sigmatel_spec *spec = codec->spec;
3542 ucontrol->value.integer.value[0] = !!spec->hp_switch;
3546 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
3548 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
3549 struct snd_ctl_elem_value *ucontrol)
3551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3552 struct sigmatel_spec *spec = codec->spec;
3553 int nid = kcontrol->private_value;
3555 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
3557 /* check to be sure that the ports are up to date with
3560 stac_issue_unsol_event(codec, nid);
3565 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
3566 struct snd_ctl_elem_info *uinfo)
3569 static const char * const texts[] = {
3570 "Mic In", "Line In", "Line Out"
3573 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3574 struct sigmatel_spec *spec = codec->spec;
3575 hda_nid_t nid = kcontrol->private_value;
3577 if (nid == spec->mic_switch || nid == spec->line_switch)
3582 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3583 uinfo->value.enumerated.items = i;
3585 if (uinfo->value.enumerated.item >= i)
3586 uinfo->value.enumerated.item = i-1;
3587 strcpy(uinfo->value.enumerated.name,
3588 texts[uinfo->value.enumerated.item]);
3593 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
3594 struct snd_ctl_elem_value *ucontrol)
3596 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3597 hda_nid_t nid = kcontrol->private_value;
3598 unsigned int vref = stac92xx_vref_get(codec, nid);
3600 if (vref == snd_hda_get_default_vref(codec, nid))
3601 ucontrol->value.enumerated.item[0] = 0;
3602 else if (vref == AC_PINCTL_VREF_GRD)
3603 ucontrol->value.enumerated.item[0] = 1;
3604 else if (vref == AC_PINCTL_VREF_HIZ)
3605 ucontrol->value.enumerated.item[0] = 2;
3610 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
3611 struct snd_ctl_elem_value *ucontrol)
3613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3614 unsigned int new_vref = 0;
3616 hda_nid_t nid = kcontrol->private_value;
3618 if (ucontrol->value.enumerated.item[0] == 0)
3619 new_vref = snd_hda_get_default_vref(codec, nid);
3620 else if (ucontrol->value.enumerated.item[0] == 1)
3621 new_vref = AC_PINCTL_VREF_GRD;
3622 else if (ucontrol->value.enumerated.item[0] == 2)
3623 new_vref = AC_PINCTL_VREF_HIZ;
3627 if (new_vref != stac92xx_vref_get(codec, nid)) {
3628 error = stac92xx_vref_set(codec, nid, new_vref);
3635 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
3636 struct snd_ctl_elem_info *uinfo)
3639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3640 struct sigmatel_spec *spec = codec->spec;
3642 if (kcontrol->private_value == spec->line_switch)
3643 texts[0] = "Line In";
3645 texts[0] = "Mic In";
3646 texts[1] = "Line Out";
3647 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3648 uinfo->value.enumerated.items = 2;
3651 if (uinfo->value.enumerated.item >= 2)
3652 uinfo->value.enumerated.item = 1;
3653 strcpy(uinfo->value.enumerated.name,
3654 texts[uinfo->value.enumerated.item]);
3659 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3661 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3662 struct sigmatel_spec *spec = codec->spec;
3663 hda_nid_t nid = kcontrol->private_value;
3664 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
3666 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
3670 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3673 struct sigmatel_spec *spec = codec->spec;
3674 hda_nid_t nid = kcontrol->private_value;
3675 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
3676 unsigned short val = !!ucontrol->value.enumerated.item[0];
3678 spec->io_switch[io_idx] = val;
3681 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3683 unsigned int pinctl = AC_PINCTL_IN_EN;
3684 if (io_idx) /* set VREF for mic */
3685 pinctl |= snd_hda_get_default_vref(codec, nid);
3686 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3689 /* check the auto-mute again: we need to mute/unmute the speaker
3690 * appropriately according to the pin direction
3692 if (spec->hp_detect)
3693 stac_issue_unsol_event(codec, nid);
3698 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
3700 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
3701 struct snd_ctl_elem_value *ucontrol)
3703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3704 struct sigmatel_spec *spec = codec->spec;
3706 ucontrol->value.integer.value[0] = spec->clfe_swap;
3710 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
3711 struct snd_ctl_elem_value *ucontrol)
3713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3714 struct sigmatel_spec *spec = codec->spec;
3715 hda_nid_t nid = kcontrol->private_value & 0xff;
3716 unsigned int val = !!ucontrol->value.integer.value[0];
3718 if (spec->clfe_swap == val)
3721 spec->clfe_swap = val;
3723 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
3724 spec->clfe_swap ? 0x4 : 0x0);
3729 #define STAC_CODEC_HP_SWITCH(xname) \
3730 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3733 .info = stac92xx_hp_switch_info, \
3734 .get = stac92xx_hp_switch_get, \
3735 .put = stac92xx_hp_switch_put, \
3738 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
3739 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3742 .info = stac92xx_io_switch_info, \
3743 .get = stac92xx_io_switch_get, \
3744 .put = stac92xx_io_switch_put, \
3745 .private_value = xpval, \
3748 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
3749 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3752 .info = stac92xx_clfe_switch_info, \
3753 .get = stac92xx_clfe_switch_get, \
3754 .put = stac92xx_clfe_switch_put, \
3755 .private_value = xpval, \
3759 STAC_CTL_WIDGET_VOL,
3760 STAC_CTL_WIDGET_MUTE,
3761 STAC_CTL_WIDGET_MUTE_BEEP,
3762 STAC_CTL_WIDGET_MONO_MUX,
3763 STAC_CTL_WIDGET_HP_SWITCH,
3764 STAC_CTL_WIDGET_IO_SWITCH,
3765 STAC_CTL_WIDGET_CLFE_SWITCH,
3766 STAC_CTL_WIDGET_DC_BIAS
3769 static const struct snd_kcontrol_new stac92xx_control_templates[] = {
3770 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3771 HDA_CODEC_MUTE(NULL, 0, 0, 0),
3772 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
3774 STAC_CODEC_HP_SWITCH(NULL),
3775 STAC_CODEC_IO_SWITCH(NULL, 0),
3776 STAC_CODEC_CLFE_SWITCH(NULL, 0),
3777 DC_BIAS(NULL, 0, 0),
3780 /* add dynamic controls */
3781 static struct snd_kcontrol_new *
3782 stac_control_new(struct sigmatel_spec *spec,
3783 const struct snd_kcontrol_new *ktemp,
3785 unsigned int subdev)
3787 struct snd_kcontrol_new *knew;
3789 knew = snd_array_new(&spec->kctls);
3793 knew->name = kstrdup(name, GFP_KERNEL);
3796 memset(knew, 0, sizeof(*knew));
3797 spec->kctls.alloced--;
3800 knew->subdevice = subdev;
3804 static struct snd_kcontrol_new *
3805 add_control_temp(struct sigmatel_spec *spec,
3806 const struct snd_kcontrol_new *ktemp,
3807 int idx, const char *name,
3810 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
3811 HDA_SUBDEV_AMP_FLAG);
3815 knew->private_value = val;
3819 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
3820 const struct snd_kcontrol_new *ktemp,
3821 int idx, const char *name,
3824 return add_control_temp(spec, ktemp, idx, name, val) ? 0 : -ENOMEM;
3827 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
3828 int type, int idx, const char *name,
3831 return stac92xx_add_control_temp(spec,
3832 &stac92xx_control_templates[type],
3837 /* add dynamic controls */
3838 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
3839 const char *name, unsigned long val)
3841 return stac92xx_add_control_idx(spec, type, 0, name, val);
3844 static const struct snd_kcontrol_new stac_input_src_temp = {
3845 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3846 .name = "Input Source",
3847 .info = stac92xx_mux_enum_info,
3848 .get = stac92xx_mux_enum_get,
3849 .put = stac92xx_mux_enum_put,
3852 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
3853 hda_nid_t nid, int idx)
3855 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
3857 struct sigmatel_spec *spec = codec->spec;
3860 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
3861 if (spec->headset_jack && snd_hda_get_input_pin_attr(def_conf)
3862 != INPUT_PIN_ATTR_DOCK)
3864 if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
3865 && nid == spec->line_switch)
3866 control = STAC_CTL_WIDGET_IO_SWITCH;
3867 else if (snd_hda_query_pin_caps(codec, nid)
3868 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
3869 control = STAC_CTL_WIDGET_DC_BIAS;
3870 else if (nid == spec->mic_switch)
3871 control = STAC_CTL_WIDGET_IO_SWITCH;
3875 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
3876 name, sizeof(name), NULL);
3877 return stac92xx_add_control(codec->spec, control,
3878 strcat(name, " Jack Mode"), nid);
3884 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
3886 struct snd_kcontrol_new *knew;
3887 struct hda_input_mux *imux = &spec->private_imux;
3890 return 0; /* no need for input source */
3891 if (!spec->num_adcs || imux->num_items <= 1)
3892 return 0; /* no need for input source control */
3893 knew = stac_control_new(spec, &stac_input_src_temp,
3894 stac_input_src_temp.name, 0);
3897 knew->count = spec->num_adcs;
3901 /* check whether the line-input can be used as line-out */
3902 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
3904 struct sigmatel_spec *spec = codec->spec;
3905 struct auto_pin_cfg *cfg = &spec->autocfg;
3907 unsigned int pincap;
3910 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
3912 for (i = 0; i < cfg->num_inputs; i++) {
3913 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
3914 nid = cfg->inputs[i].pin;
3915 pincap = snd_hda_query_pin_caps(codec, nid);
3916 if (pincap & AC_PINCAP_OUT)
3923 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
3925 /* check whether the mic-input can be used as line-out */
3926 static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
3928 struct sigmatel_spec *spec = codec->spec;
3929 struct auto_pin_cfg *cfg = &spec->autocfg;
3930 unsigned int def_conf, pincap;
3934 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
3936 for (i = 0; i < cfg->num_inputs; i++) {
3937 hda_nid_t nid = cfg->inputs[i].pin;
3938 if (cfg->inputs[i].type != AUTO_PIN_MIC)
3940 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3941 /* some laptops have an internal analog microphone
3942 * which can't be used as a output */
3943 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
3944 pincap = snd_hda_query_pin_caps(codec, nid);
3945 if (pincap & AC_PINCAP_OUT) {
3946 *dac = get_unassigned_dac(codec, nid);
3955 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3959 for (i = 0; i < spec->multiout.num_dacs; i++) {
3960 if (spec->multiout.dac_nids[i] == nid)
3967 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3970 if (is_in_dac_nids(spec, nid))
3972 for (i = 0; i < spec->autocfg.hp_outs; i++)
3973 if (spec->hp_dacs[i] == nid)
3975 for (i = 0; i < spec->autocfg.speaker_outs; i++)
3976 if (spec->speaker_dacs[i] == nid)
3981 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
3983 struct sigmatel_spec *spec = codec->spec;
3984 struct auto_pin_cfg *cfg = &spec->autocfg;
3986 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
3987 unsigned int wcaps, wtype;
3989 conn_len = snd_hda_get_connections(codec, nid, conn,
3990 HDA_MAX_CONNECTIONS);
3991 /* 92HD88: trace back up the link of nids to find the DAC */
3992 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
3993 != AC_WID_AUD_OUT)) {
3995 conn_len = snd_hda_get_connections(codec, nid, conn,
3996 HDA_MAX_CONNECTIONS);
3998 for (j = 0; j < conn_len; j++) {
3999 wcaps = get_wcaps(codec, conn[j]);
4000 wtype = get_wcaps_type(wcaps);
4001 /* we check only analog outputs */
4002 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
4004 /* if this route has a free DAC, assign it */
4005 if (!check_all_dac_nids(spec, conn[j])) {
4007 /* select this DAC in the pin's input mux */
4008 snd_hda_codec_write_cache(codec, nid, 0,
4009 AC_VERB_SET_CONNECT_SEL, j);
4015 /* if all DACs are already assigned, connect to the primary DAC,
4016 unless we're assigning a secondary headphone */
4017 fallback_dac = spec->multiout.dac_nids[0];
4018 if (spec->multiout.hp_nid) {
4019 for (j = 0; j < cfg->hp_outs; j++)
4020 if (cfg->hp_pins[j] == nid) {
4021 fallback_dac = spec->multiout.hp_nid;
4027 for (j = 0; j < conn_len; j++) {
4028 if (conn[j] == fallback_dac) {
4029 snd_hda_codec_write_cache(codec, nid, 0,
4030 AC_VERB_SET_CONNECT_SEL, j);
4038 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
4039 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
4042 * Fill in the dac_nids table from the parsed pin configuration
4043 * This function only works when every pin in line_out_pins[]
4044 * contains atleast one DAC in its connection list. Some 92xx
4045 * codecs are not connected directly to a DAC, such as the 9200
4046 * and 9202/925x. For those, dac_nids[] must be hard-coded.
4048 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
4050 struct sigmatel_spec *spec = codec->spec;
4051 struct auto_pin_cfg *cfg = &spec->autocfg;
4055 for (i = 0; i < cfg->line_outs; i++) {
4056 nid = cfg->line_out_pins[i];
4057 dac = get_unassigned_dac(codec, nid);
4059 if (spec->multiout.num_dacs > 0) {
4060 /* we have already working output pins,
4061 * so let's drop the broken ones again
4063 cfg->line_outs = spec->multiout.num_dacs;
4066 /* error out, no available DAC found */
4068 "%s: No available DAC for pin 0x%x\n",
4072 add_spec_dacs(spec, dac);
4075 for (i = 0; i < cfg->hp_outs; i++) {
4076 nid = cfg->hp_pins[i];
4077 dac = get_unassigned_dac(codec, nid);
4079 if (!spec->multiout.hp_nid)
4080 spec->multiout.hp_nid = dac;
4082 add_spec_extra_dacs(spec, dac);
4084 spec->hp_dacs[i] = dac;
4087 for (i = 0; i < cfg->speaker_outs; i++) {
4088 nid = cfg->speaker_pins[i];
4089 dac = get_unassigned_dac(codec, nid);
4091 add_spec_extra_dacs(spec, dac);
4092 spec->speaker_dacs[i] = dac;
4095 /* add line-in as output */
4096 nid = check_line_out_switch(codec);
4098 dac = get_unassigned_dac(codec, nid);
4100 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
4101 nid, cfg->line_outs);
4102 cfg->line_out_pins[cfg->line_outs] = nid;
4104 spec->line_switch = nid;
4105 add_spec_dacs(spec, dac);
4108 /* add mic as output */
4109 nid = check_mic_out_switch(codec, &dac);
4111 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
4112 nid, cfg->line_outs);
4113 cfg->line_out_pins[cfg->line_outs] = nid;
4115 spec->mic_switch = nid;
4116 add_spec_dacs(spec, dac);
4119 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
4120 spec->multiout.num_dacs,
4121 spec->multiout.dac_nids[0],
4122 spec->multiout.dac_nids[1],
4123 spec->multiout.dac_nids[2],
4124 spec->multiout.dac_nids[3],
4125 spec->multiout.dac_nids[4]);
4130 /* create volume control/switch for the given prefx type */
4131 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
4132 int idx, hda_nid_t nid, int chs)
4134 struct sigmatel_spec *spec = codec->spec;
4138 if (!spec->check_volume_offset) {
4139 unsigned int caps, step, nums, db_scale;
4140 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
4141 step = (caps & AC_AMPCAP_STEP_SIZE) >>
4142 AC_AMPCAP_STEP_SIZE_SHIFT;
4143 step = (step + 1) * 25; /* in .01dB unit */
4144 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
4145 AC_AMPCAP_NUM_STEPS_SHIFT;
4146 db_scale = nums * step;
4147 /* if dB scale is over -64dB, and finer enough,
4148 * let's reduce it to half
4150 if (db_scale > 6400 && nums >= 0x1f)
4151 spec->volume_offset = nums / 2;
4152 spec->check_volume_offset = 1;
4155 sprintf(name, "%s Playback Volume", pfx);
4156 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
4157 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
4158 spec->volume_offset));
4161 sprintf(name, "%s Playback Switch", pfx);
4162 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
4163 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
4169 #define create_controls(codec, pfx, nid, chs) \
4170 create_controls_idx(codec, pfx, 0, nid, chs)
4172 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
4174 if (spec->multiout.num_dacs > 4) {
4175 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
4178 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
4179 spec->dac_nids[spec->multiout.num_dacs] = nid;
4180 spec->multiout.num_dacs++;
4185 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
4188 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
4189 if (!spec->multiout.extra_out_nid[i]) {
4190 spec->multiout.extra_out_nid[i] = nid;
4194 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
4198 /* Create output controls
4199 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
4201 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
4202 const hda_nid_t *pins,
4203 const hda_nid_t *dac_nids,
4206 struct sigmatel_spec *spec = codec->spec;
4207 static const char * const chname[4] = {
4208 "Front", "Surround", NULL /*CLFE*/, "Side"
4212 unsigned int wid_caps;
4214 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
4215 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
4216 if (is_jack_detectable(codec, pins[i]))
4217 spec->hp_detect = 1;
4222 if (type != AUTO_PIN_HP_OUT && i == 2) {
4224 err = create_controls(codec, "Center", nid, 1);
4227 err = create_controls(codec, "LFE", nid, 2);
4231 wid_caps = get_wcaps(codec, nid);
4233 if (wid_caps & AC_WCAP_LR_SWAP) {
4234 err = stac92xx_add_control(spec,
4235 STAC_CTL_WIDGET_CLFE_SWITCH,
4236 "Swap Center/LFE Playback Switch", nid);
4246 case AUTO_PIN_HP_OUT:
4250 case AUTO_PIN_SPEAKER_OUT:
4251 if (num_outs <= 2) {
4252 name = i ? "Bass Speaker" : "Speaker";
4256 /* Fall through in case of multi speaker outs */
4262 err = create_controls_idx(codec, name, idx, nid, 3);
4270 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4271 unsigned int dir_mask, unsigned int data);
4273 /* hook for controlling mic-mute LED GPIO */
4274 static int stac92xx_capture_sw_put_led(struct snd_kcontrol *kcontrol,
4275 struct snd_ctl_elem_value *ucontrol)
4277 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4278 struct sigmatel_spec *spec = codec->spec;
4282 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
4285 mute = !(ucontrol->value.integer.value[0] &&
4286 ucontrol->value.integer.value[1]);
4287 if (spec->mic_mute_led_on != mute) {
4288 spec->mic_mute_led_on = mute;
4290 spec->gpio_data |= spec->mic_mute_led_gpio;
4292 spec->gpio_data &= ~spec->mic_mute_led_gpio;
4293 stac_gpio_set(codec, spec->gpio_mask,
4294 spec->gpio_dir, spec->gpio_data);
4299 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
4300 unsigned long sw, int idx)
4302 struct sigmatel_spec *spec = codec->spec;
4303 struct snd_kcontrol_new *knew;
4306 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
4307 "Capture Volume", vol);
4311 knew = add_control_temp(spec,
4312 &stac92xx_control_templates[STAC_CTL_WIDGET_MUTE],
4313 idx, "Capture Switch", sw);
4316 /* add a LED hook for some HP laptops */
4317 if (spec->mic_mute_led_gpio)
4318 knew->put = stac92xx_capture_sw_put_led;
4323 /* add playback controls from the parsed DAC table */
4324 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
4325 const struct auto_pin_cfg *cfg)
4327 struct sigmatel_spec *spec = codec->spec;
4332 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
4333 spec->multiout.dac_nids,
4334 cfg->line_out_type);
4338 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
4339 err = stac92xx_add_control(spec,
4340 STAC_CTL_WIDGET_HP_SWITCH,
4341 "Headphone as Line Out Switch",
4342 cfg->hp_pins[cfg->hp_outs - 1]);
4347 for (idx = 0; idx < cfg->num_inputs; idx++) {
4348 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
4350 nid = cfg->inputs[idx].pin;
4351 err = stac92xx_add_jack_mode_control(codec, nid, idx);
4359 /* add playback controls for Speaker and HP outputs */
4360 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
4361 struct auto_pin_cfg *cfg)
4363 struct sigmatel_spec *spec = codec->spec;
4366 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
4367 spec->hp_dacs, AUTO_PIN_HP_OUT);
4371 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
4372 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
4379 /* labels for mono mux outputs */
4380 static const char * const stac92xx_mono_labels[4] = {
4381 "DAC0", "DAC1", "Mixer", "DAC2"
4384 /* create mono mux for mono out on capable codecs */
4385 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
4387 struct sigmatel_spec *spec = codec->spec;
4388 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
4390 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
4392 num_cons = snd_hda_get_connections(codec,
4395 HDA_MAX_NUM_INPUTS);
4396 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
4399 for (i = 0; i < num_cons; i++)
4400 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
4403 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
4404 "Mono Mux", spec->mono_nid);
4407 /* create PC beep volume controls */
4408 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
4411 struct sigmatel_spec *spec = codec->spec;
4412 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
4413 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
4415 if (spec->anabeep_nid == nid)
4416 type = STAC_CTL_WIDGET_MUTE;
4418 /* check for mute support for the the amp */
4419 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
4420 err = stac92xx_add_control(spec, type,
4421 "Beep Playback Switch",
4422 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4427 /* check to see if there is volume support for the amp */
4428 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
4429 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
4430 "Beep Playback Volume",
4431 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
4438 #ifdef CONFIG_SND_HDA_INPUT_BEEP
4439 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
4441 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
4442 struct snd_ctl_elem_value *ucontrol)
4444 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4445 ucontrol->value.integer.value[0] = codec->beep->enabled;
4449 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
4450 struct snd_ctl_elem_value *ucontrol)
4452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4453 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
4456 static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
4457 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4458 .info = stac92xx_dig_beep_switch_info,
4459 .get = stac92xx_dig_beep_switch_get,
4460 .put = stac92xx_dig_beep_switch_put,
4463 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
4465 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
4466 0, "Beep Playback Switch", 0);
4470 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
4472 struct sigmatel_spec *spec = codec->spec;
4475 for (i = 0; i < spec->num_muxes; i++) {
4480 nid = spec->mux_nids[i];
4481 wcaps = get_wcaps(codec, nid);
4482 if (!(wcaps & AC_WCAP_OUT_AMP))
4485 /* check whether already the same control was created as
4486 * normal Capture Volume.
4488 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4489 for (j = 0; j < spec->num_caps; j++) {
4490 if (spec->capvols[j] == val)
4493 if (j < spec->num_caps)
4496 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
4497 "Mux Capture Volume", val);
4504 static const char * const stac92xx_spdif_labels[3] = {
4505 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
4508 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
4510 struct sigmatel_spec *spec = codec->spec;
4511 struct hda_input_mux *spdif_mux = &spec->private_smux;
4512 const char * const *labels = spec->spdif_labels;
4514 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
4516 num_cons = snd_hda_get_connections(codec,
4519 HDA_MAX_NUM_INPUTS);
4524 labels = stac92xx_spdif_labels;
4526 for (i = 0; i < num_cons; i++)
4527 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
4532 /* labels for dmic mux inputs */
4533 static const char * const stac92xx_dmic_labels[5] = {
4534 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
4535 "Digital Mic 3", "Digital Mic 4"
4538 static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
4541 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
4543 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
4544 if (idx >= 0 && idx < nums)
4549 /* look for NID recursively */
4550 #define get_connection_index(codec, mux, nid) \
4551 snd_hda_get_conn_index(codec, mux, nid, 1)
4553 /* create a volume assigned to the given pin (only if supported) */
4554 /* return 1 if the volume control is created */
4555 static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
4556 const char *label, int idx, int direction)
4558 unsigned int caps, nums;
4562 if (direction == HDA_OUTPUT)
4563 caps = AC_WCAP_OUT_AMP;
4565 caps = AC_WCAP_IN_AMP;
4566 if (!(get_wcaps(codec, nid) & caps))
4568 caps = query_amp_caps(codec, nid, direction);
4569 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
4572 snprintf(name, sizeof(name), "%s Capture Volume", label);
4573 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
4574 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
4580 /* create playback/capture controls for input pins on dmic capable codecs */
4581 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
4582 const struct auto_pin_cfg *cfg)
4584 struct sigmatel_spec *spec = codec->spec;
4585 struct hda_input_mux *imux = &spec->private_imux;
4586 struct hda_input_mux *dimux = &spec->private_dimux;
4588 unsigned int def_conf;
4590 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
4592 for (i = 0; i < spec->num_dmics; i++) {
4594 int index, type_idx;
4597 nid = spec->dmic_nids[i];
4598 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
4600 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4601 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
4604 index = get_connection_index(codec, spec->dmux_nids[0], nid);
4608 snd_hda_get_pin_label(codec, nid, &spec->autocfg,
4609 label, sizeof(label), NULL);
4610 snd_hda_add_imux_item(dimux, label, index, &type_idx);
4611 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
4612 snd_hda_add_imux_item(imux, label, index, &type_idx);
4614 err = create_elem_capture_vol(codec, nid, label, type_idx,
4619 err = create_elem_capture_vol(codec, nid, label,
4620 type_idx, HDA_OUTPUT);
4624 nid = get_connected_node(codec,
4625 spec->dmux_nids[0], index);
4627 err = create_elem_capture_vol(codec,
4629 type_idx, HDA_INPUT);
4639 static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
4640 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
4647 cfg = snd_hda_codec_get_pincfg(codec, nid);
4648 type = get_defcfg_device(cfg);
4649 switch (snd_hda_get_input_pin_attr(cfg)) {
4650 case INPUT_PIN_ATTR_INT:
4652 return 1; /* already occupied */
4653 if (type != AC_JACK_MIC_IN)
4654 return 1; /* invalid type */
4657 case INPUT_PIN_ATTR_UNUSED:
4659 case INPUT_PIN_ATTR_DOCK:
4661 return 1; /* already occupied */
4662 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
4663 return 1; /* invalid type */
4668 return 1; /* already occupied */
4669 if (type != AC_JACK_MIC_IN)
4670 return 1; /* invalid type */
4677 static int set_mic_route(struct hda_codec *codec,
4678 struct sigmatel_mic_route *mic,
4681 struct sigmatel_spec *spec = codec->spec;
4682 struct auto_pin_cfg *cfg = &spec->autocfg;
4688 for (i = 0; i < cfg->num_inputs; i++) {
4689 if (pin == cfg->inputs[i].pin)
4692 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
4694 i = get_connection_index(codec, spec->mux_nids[0], pin);
4699 if (spec->dmux_nids)
4700 mic->dmux_idx = get_connection_index(codec,
4703 } else if (spec->dmux_nids) {
4705 i = get_connection_index(codec, spec->dmux_nids[0], pin);
4711 mic->mux_idx = get_connection_index(codec,
4713 spec->dmux_nids[0]);
4718 /* return non-zero if the device is for automatic mic switch */
4719 static int stac_check_auto_mic(struct hda_codec *codec)
4721 struct sigmatel_spec *spec = codec->spec;
4722 struct auto_pin_cfg *cfg = &spec->autocfg;
4723 hda_nid_t fixed, ext, dock;
4726 fixed = ext = dock = 0;
4727 for (i = 0; i < cfg->num_inputs; i++)
4728 if (check_mic_pin(codec, cfg->inputs[i].pin,
4729 &fixed, &ext, &dock))
4731 for (i = 0; i < spec->num_dmics; i++)
4732 if (check_mic_pin(codec, spec->dmic_nids[i],
4733 &fixed, &ext, &dock))
4735 if (!fixed || (!ext && !dock))
4736 return 0; /* no input to switch */
4737 if (!is_jack_detectable(codec, ext))
4738 return 0; /* no unsol support */
4739 if (set_mic_route(codec, &spec->ext_mic, ext) ||
4740 set_mic_route(codec, &spec->int_mic, fixed) ||
4741 set_mic_route(codec, &spec->dock_mic, dock))
4742 return 0; /* something is wrong */
4746 /* create playback/capture controls for input pins */
4747 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
4749 struct sigmatel_spec *spec = codec->spec;
4750 struct hda_input_mux *imux = &spec->private_imux;
4754 for (i = 0; i < cfg->num_inputs; i++) {
4755 hda_nid_t nid = cfg->inputs[i].pin;
4756 int index, err, type_idx;
4759 for (j = 0; j < spec->num_muxes; j++) {
4760 index = get_connection_index(codec, spec->mux_nids[j],
4768 label = hda_get_autocfg_input_label(codec, cfg, i);
4769 snd_hda_add_imux_item(imux, label, index, &type_idx);
4771 err = create_elem_capture_vol(codec, nid,
4777 spec->num_analog_muxes = imux->num_items;
4779 if (imux->num_items) {
4781 * Set the current input for the muxes.
4782 * The STAC9221 has two input muxes with identical source
4783 * NID lists. Hopefully this won't get confused.
4785 for (i = 0; i < spec->num_muxes; i++) {
4786 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
4787 AC_VERB_SET_CONNECT_SEL,
4788 imux->items[0].index);
4795 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
4797 struct sigmatel_spec *spec = codec->spec;
4800 for (i = 0; i < spec->autocfg.line_outs; i++) {
4801 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4802 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
4806 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
4808 struct sigmatel_spec *spec = codec->spec;
4811 for (i = 0; i < spec->autocfg.hp_outs; i++) {
4813 pin = spec->autocfg.hp_pins[i];
4814 if (pin) /* connect to front */
4815 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
4817 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
4819 pin = spec->autocfg.speaker_pins[i];
4820 if (pin) /* connect to front */
4821 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
4825 static int is_dual_headphones(struct hda_codec *codec)
4827 struct sigmatel_spec *spec = codec->spec;
4830 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
4831 spec->autocfg.hp_outs <= 1)
4834 for (i = 0; i < spec->autocfg.hp_outs; i++) {
4835 hda_nid_t nid = spec->autocfg.hp_pins[i];
4836 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
4837 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
4841 return (valid_hps > 1);
4845 static int stac92xx_parse_auto_config(struct hda_codec *codec)
4847 struct sigmatel_spec *spec = codec->spec;
4848 hda_nid_t dig_out = 0, dig_in = 0;
4852 if ((err = snd_hda_parse_pin_def_config(codec,
4854 spec->dmic_nids)) < 0)
4856 if (! spec->autocfg.line_outs)
4857 return 0; /* can't find valid pin config */
4859 /* If we have no real line-out pin and multiple hp-outs, HPs should
4860 * be set up as multi-channel outputs.
4862 if (is_dual_headphones(codec)) {
4863 /* Copy hp_outs to line_outs, backup line_outs in
4864 * speaker_outs so that the following routines can handle
4865 * HP pins as primary outputs.
4867 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
4868 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
4869 sizeof(spec->autocfg.line_out_pins));
4870 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
4871 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
4872 sizeof(spec->autocfg.hp_pins));
4873 spec->autocfg.line_outs = spec->autocfg.hp_outs;
4874 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
4875 spec->autocfg.hp_outs = 0;
4878 if (spec->autocfg.mono_out_pin) {
4879 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
4880 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
4881 u32 caps = query_amp_caps(codec,
4882 spec->autocfg.mono_out_pin, dir);
4883 hda_nid_t conn_list[1];
4885 /* get the mixer node and then the mono mux if it exists */
4886 if (snd_hda_get_connections(codec,
4887 spec->autocfg.mono_out_pin, conn_list, 1) &&
4888 snd_hda_get_connections(codec, conn_list[0],
4889 conn_list, 1) > 0) {
4891 int wcaps = get_wcaps(codec, conn_list[0]);
4892 int wid_type = get_wcaps_type(wcaps);
4893 /* LR swap check, some stac925x have a mux that
4894 * changes the DACs output path instead of the
4897 if (wid_type == AC_WID_AUD_SEL &&
4898 !(wcaps & AC_WCAP_LR_SWAP))
4899 spec->mono_nid = conn_list[0];
4902 hda_nid_t nid = spec->autocfg.mono_out_pin;
4904 /* most mono outs have a least a mute/unmute switch */
4905 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
4906 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
4907 "Mono Playback Switch",
4908 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
4911 /* check for volume support for the amp */
4912 if ((caps & AC_AMPCAP_NUM_STEPS)
4913 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
4914 err = stac92xx_add_control(spec,
4915 STAC_CTL_WIDGET_VOL,
4916 "Mono Playback Volume",
4917 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
4923 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
4927 if (!spec->multiout.num_dacs) {
4928 err = stac92xx_auto_fill_dac_nids(codec);
4931 err = stac92xx_auto_create_multi_out_ctls(codec,
4937 /* setup analog beep controls */
4938 if (spec->anabeep_nid > 0) {
4939 err = stac92xx_auto_create_beep_ctls(codec,
4945 /* setup digital beep controls and input device */
4946 #ifdef CONFIG_SND_HDA_INPUT_BEEP
4947 if (spec->digbeep_nid > 0) {
4948 hda_nid_t nid = spec->digbeep_nid;
4951 err = stac92xx_auto_create_beep_ctls(codec, nid);
4954 err = snd_hda_attach_beep_device(codec, nid);
4958 /* IDT/STAC codecs have linear beep tone parameter */
4959 codec->beep->linear_tone = spec->linear_tone_beep;
4960 /* if no beep switch is available, make its own one */
4961 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
4962 if (!(caps & AC_AMPCAP_MUTE)) {
4963 err = stac92xx_beep_switch_ctl(codec);
4971 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
4975 /* All output parsing done, now restore the swapped hp pins */
4977 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
4978 sizeof(spec->autocfg.hp_pins));
4979 spec->autocfg.hp_outs = spec->autocfg.line_outs;
4980 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
4981 spec->autocfg.line_outs = 0;
4984 if (stac_check_auto_mic(codec)) {
4986 /* only one capture for auto-mic */
4989 spec->num_muxes = 1;
4992 for (i = 0; i < spec->num_caps; i++) {
4993 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
4994 spec->capsws[i], i);
4999 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
5003 if (spec->mono_nid > 0) {
5004 err = stac92xx_auto_create_mono_output_ctls(codec);
5008 if (spec->num_dmics > 0 && !spec->dinput_mux)
5009 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
5010 &spec->autocfg)) < 0)
5012 if (spec->num_muxes > 0) {
5013 err = stac92xx_auto_create_mux_input_ctls(codec);
5017 if (spec->num_smuxes > 0) {
5018 err = stac92xx_auto_create_spdif_mux_ctls(codec);
5023 err = stac92xx_add_input_source(spec);
5027 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5028 if (spec->multiout.max_channels > 2)
5029 spec->surr_switch = 1;
5031 /* find digital out and in converters */
5032 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
5033 unsigned int wid_caps = get_wcaps(codec, i);
5034 if (wid_caps & AC_WCAP_DIGITAL) {
5035 switch (get_wcaps_type(wid_caps)) {
5036 case AC_WID_AUD_OUT:
5047 if (spec->autocfg.dig_outs)
5048 spec->multiout.dig_out_nid = dig_out;
5049 if (dig_in && spec->autocfg.dig_in_pin)
5050 spec->dig_in_nid = dig_in;
5052 if (spec->kctls.list)
5053 spec->mixers[spec->num_mixers++] = spec->kctls.list;
5055 spec->input_mux = &spec->private_imux;
5056 if (!spec->dinput_mux)
5057 spec->dinput_mux = &spec->private_dimux;
5058 spec->sinput_mux = &spec->private_smux;
5059 spec->mono_mux = &spec->private_mono_mux;
5063 /* add playback controls for HP output */
5064 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
5065 struct auto_pin_cfg *cfg)
5067 struct sigmatel_spec *spec = codec->spec;
5068 hda_nid_t pin = cfg->hp_pins[0];
5073 if (is_jack_detectable(codec, pin))
5074 spec->hp_detect = 1;
5079 /* add playback controls for LFE output */
5080 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
5081 struct auto_pin_cfg *cfg)
5083 struct sigmatel_spec *spec = codec->spec;
5085 hda_nid_t lfe_pin = 0x0;
5089 * search speaker outs and line outs for a mono speaker pin
5090 * with an amp. If one is found, add LFE controls
5093 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
5094 hda_nid_t pin = spec->autocfg.speaker_pins[i];
5095 unsigned int wcaps = get_wcaps(codec, pin);
5096 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
5097 if (wcaps == AC_WCAP_OUT_AMP)
5098 /* found a mono speaker with an amp, must be lfe */
5102 /* if speaker_outs is 0, then speakers may be in line_outs */
5103 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
5104 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
5105 hda_nid_t pin = spec->autocfg.line_out_pins[i];
5106 unsigned int defcfg;
5107 defcfg = snd_hda_codec_get_pincfg(codec, pin);
5108 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
5109 unsigned int wcaps = get_wcaps(codec, pin);
5110 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
5111 if (wcaps == AC_WCAP_OUT_AMP)
5112 /* found a mono speaker with an amp,
5120 err = create_controls(codec, "LFE", lfe_pin, 1);
5128 static int stac9200_parse_auto_config(struct hda_codec *codec)
5130 struct sigmatel_spec *spec = codec->spec;
5133 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
5136 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
5139 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
5142 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
5145 if (spec->num_muxes > 0) {
5146 err = stac92xx_auto_create_mux_input_ctls(codec);
5151 err = stac92xx_add_input_source(spec);
5155 if (spec->autocfg.dig_outs)
5156 spec->multiout.dig_out_nid = 0x05;
5157 if (spec->autocfg.dig_in_pin)
5158 spec->dig_in_nid = 0x04;
5160 if (spec->kctls.list)
5161 spec->mixers[spec->num_mixers++] = spec->kctls.list;
5163 spec->input_mux = &spec->private_imux;
5164 spec->dinput_mux = &spec->private_dimux;
5170 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
5171 * funky external mute control using GPIO pins.
5174 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
5175 unsigned int dir_mask, unsigned int data)
5177 unsigned int gpiostate, gpiomask, gpiodir;
5179 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
5181 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5182 AC_VERB_GET_GPIO_DATA, 0);
5183 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
5185 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5186 AC_VERB_GET_GPIO_MASK, 0);
5189 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5190 AC_VERB_GET_GPIO_DIRECTION, 0);
5191 gpiodir |= dir_mask;
5193 /* Configure GPIOx as CMOS */
5194 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
5196 snd_hda_codec_write(codec, codec->afg, 0,
5197 AC_VERB_SET_GPIO_MASK, gpiomask);
5198 snd_hda_codec_read(codec, codec->afg, 0,
5199 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
5203 snd_hda_codec_read(codec, codec->afg, 0,
5204 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
5207 static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
5208 unsigned char type, int data)
5210 struct hda_jack_tbl *event;
5212 event = snd_hda_jack_tbl_new(codec, nid);
5215 event->action = type;
5216 event->private_data = data;
5221 static void handle_unsol_event(struct hda_codec *codec,
5222 struct hda_jack_tbl *event);
5224 /* check if given nid is a valid pin and no other events are assigned
5225 * to it. If OK, assign the event, set the unsol flag, and returns 1.
5226 * Otherwise, returns zero.
5228 static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
5231 struct hda_jack_tbl *event;
5233 if (!is_jack_detectable(codec, nid))
5235 event = snd_hda_jack_tbl_new(codec, nid);
5238 if (event->action && event->action != type)
5240 event->action = type;
5241 event->callback = handle_unsol_event;
5242 snd_hda_jack_detect_enable(codec, nid, 0);
5246 static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
5249 for (i = 0; i < cfg->hp_outs; i++)
5250 if (cfg->hp_pins[i] == nid)
5251 return 1; /* nid is a HP-Out */
5252 for (i = 0; i < cfg->line_outs; i++)
5253 if (cfg->line_out_pins[i] == nid)
5254 return 1; /* nid is a line-Out */
5255 return 0; /* nid is not a HP-Out */
5258 static void stac92xx_power_down(struct hda_codec *codec)
5260 struct sigmatel_spec *spec = codec->spec;
5262 /* power down inactive DACs */
5263 const hda_nid_t *dac;
5264 for (dac = spec->dac_list; *dac; dac++)
5265 if (!check_all_dac_nids(spec, *dac))
5266 snd_hda_codec_write(codec, *dac, 0,
5267 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
5270 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
5273 static inline bool get_int_hint(struct hda_codec *codec, const char *key,
5276 return !snd_hda_get_int_hint(codec, key, valp);
5279 /* override some hints from the hwdep entry */
5280 static void stac_store_hints(struct hda_codec *codec)
5282 struct sigmatel_spec *spec = codec->spec;
5285 val = snd_hda_get_bool_hint(codec, "hp_detect");
5287 spec->hp_detect = val;
5288 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
5289 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
5292 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
5293 spec->gpio_mask &= spec->gpio_mask;
5294 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
5295 spec->gpio_dir &= spec->gpio_mask;
5296 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
5297 spec->eapd_mask &= spec->gpio_mask;
5298 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
5299 spec->gpio_mute &= spec->gpio_mask;
5300 val = snd_hda_get_bool_hint(codec, "eapd_switch");
5302 spec->eapd_switch = val;
5305 static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
5306 const hda_nid_t *pins)
5309 stac_issue_unsol_event(codec, *pins++);
5312 /* fake event to set up pins */
5313 static void stac_fake_hp_events(struct hda_codec *codec)
5315 struct sigmatel_spec *spec = codec->spec;
5317 if (spec->autocfg.hp_outs)
5318 stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
5319 spec->autocfg.hp_pins);
5320 if (spec->autocfg.line_outs &&
5321 spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
5322 stac_issue_unsol_events(codec, spec->autocfg.line_outs,
5323 spec->autocfg.line_out_pins);
5326 static int stac92xx_init(struct hda_codec *codec)
5328 struct sigmatel_spec *spec = codec->spec;
5329 struct auto_pin_cfg *cfg = &spec->autocfg;
5334 snd_hda_sequence_write(codec, spec->init);
5336 snd_hda_apply_verbs(codec);
5338 /* power down adcs initially */
5339 if (spec->powerdown_adcs)
5340 for (i = 0; i < spec->num_adcs; i++)
5341 snd_hda_codec_write(codec,
5342 spec->adc_nids[i], 0,
5343 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
5345 /* override some hints */
5346 stac_store_hints(codec);
5349 gpio = spec->gpio_data;
5350 /* turn on EAPD statically when spec->eapd_switch isn't set.
5351 * otherwise, unsol event will turn it on/off dynamically
5353 if (!spec->eapd_switch)
5354 gpio |= spec->eapd_mask;
5355 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
5358 if (spec->hp_detect) {
5359 /* Enable unsolicited responses on the HP widget */
5360 for (i = 0; i < cfg->hp_outs; i++) {
5361 hda_nid_t nid = cfg->hp_pins[i];
5362 enable_pin_detect(codec, nid, STAC_HP_EVENT);
5364 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
5365 cfg->speaker_outs > 0) {
5366 /* enable pin-detect for line-outs as well */
5367 for (i = 0; i < cfg->line_outs; i++) {
5368 hda_nid_t nid = cfg->line_out_pins[i];
5369 enable_pin_detect(codec, nid, STAC_LO_EVENT);
5373 /* force to enable the first line-out; the others are set up
5376 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
5378 /* fake event to set up pins */
5379 stac_fake_hp_events(codec);
5381 stac92xx_auto_init_multi_out(codec);
5382 stac92xx_auto_init_hp_out(codec);
5383 for (i = 0; i < cfg->hp_outs; i++)
5384 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
5386 if (spec->auto_mic) {
5387 /* initialize connection to analog input */
5388 if (spec->dmux_nids)
5389 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
5390 AC_VERB_SET_CONNECT_SEL, 0);
5391 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
5392 stac_issue_unsol_event(codec, spec->ext_mic.pin);
5393 if (enable_pin_detect(codec, spec->dock_mic.pin,
5395 stac_issue_unsol_event(codec, spec->dock_mic.pin);
5397 for (i = 0; i < cfg->num_inputs; i++) {
5398 hda_nid_t nid = cfg->inputs[i].pin;
5399 int type = cfg->inputs[i].type;
5400 unsigned int pinctl, conf;
5401 if (type == AUTO_PIN_MIC) {
5402 /* for mic pins, force to initialize */
5403 pinctl = snd_hda_get_default_vref(codec, nid);
5404 pinctl |= AC_PINCTL_IN_EN;
5405 stac92xx_auto_set_pinctl(codec, nid, pinctl);
5407 pinctl = snd_hda_codec_read(codec, nid, 0,
5408 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5409 /* if PINCTL already set then skip */
5410 /* Also, if both INPUT and OUTPUT are set,
5411 * it must be a BIOS bug; need to override, too
5413 if (!(pinctl & AC_PINCTL_IN_EN) ||
5414 (pinctl & AC_PINCTL_OUT_EN)) {
5415 pinctl &= ~AC_PINCTL_OUT_EN;
5416 pinctl |= AC_PINCTL_IN_EN;
5417 stac92xx_auto_set_pinctl(codec, nid, pinctl);
5420 conf = snd_hda_codec_get_pincfg(codec, nid);
5421 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
5422 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
5423 stac_issue_unsol_event(codec, nid);
5426 for (i = 0; i < spec->num_dmics; i++)
5427 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
5429 if (cfg->dig_out_pins[0])
5430 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
5432 if (cfg->dig_in_pin)
5433 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
5435 for (i = 0; i < spec->num_pwrs; i++) {
5436 hda_nid_t nid = spec->pwr_nids[i];
5437 unsigned int pinctl, def_conf;
5439 def_conf = snd_hda_codec_get_pincfg(codec, nid);
5440 def_conf = get_defcfg_connect(def_conf);
5441 if (def_conf == AC_JACK_PORT_NONE) {
5442 /* power off unused ports */
5443 stac_toggle_power_map(codec, nid, 0);
5446 if (def_conf == AC_JACK_PORT_FIXED) {
5447 /* no need for jack detection for fixed pins */
5448 stac_toggle_power_map(codec, nid, 1);
5451 /* power on when no jack detection is available */
5452 /* or when the VREF is used for controlling LED */
5453 if (!spec->hp_detect ||
5454 spec->vref_mute_led_nid == nid ||
5455 !is_jack_detectable(codec, nid)) {
5456 stac_toggle_power_map(codec, nid, 1);
5460 if (is_nid_out_jack_pin(cfg, nid))
5461 continue; /* already has an unsol event */
5463 pinctl = snd_hda_codec_read(codec, nid, 0,
5464 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5465 /* outputs are only ports capable of power management
5466 * any attempts on powering down a input port cause the
5467 * referenced VREF to act quirky.
5469 if (pinctl & AC_PINCTL_IN_EN) {
5470 stac_toggle_power_map(codec, nid, 1);
5473 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
5474 stac_issue_unsol_event(codec, nid);
5477 /* none of the above, turn the port OFF */
5478 stac_toggle_power_map(codec, nid, 0);
5482 if (spec->gpio_led) {
5483 if (spec->vmaster_mute.hook)
5484 snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
5485 else /* the very first init call doesn't have vmaster yet */
5486 stac92xx_update_led_status(codec, false);
5489 /* sync the power-map */
5491 snd_hda_codec_write(codec, codec->afg, 0,
5492 AC_VERB_IDT_SET_POWER_MAP,
5493 spec->power_map_bits);
5495 stac92xx_power_down(codec);
5499 static void stac92xx_free_kctls(struct hda_codec *codec)
5501 struct sigmatel_spec *spec = codec->spec;
5503 if (spec->kctls.list) {
5504 struct snd_kcontrol_new *kctl = spec->kctls.list;
5506 for (i = 0; i < spec->kctls.used; i++)
5507 kfree(kctl[i].name);
5509 snd_array_free(&spec->kctls);
5512 static void stac92xx_shutup_pins(struct hda_codec *codec)
5514 unsigned int i, def_conf;
5516 if (codec->bus->shutdown)
5518 for (i = 0; i < codec->init_pins.used; i++) {
5519 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
5520 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
5521 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
5522 snd_hda_set_pin_ctl(codec, pin->nid, 0);
5526 static void stac92xx_shutup(struct hda_codec *codec)
5528 struct sigmatel_spec *spec = codec->spec;
5530 stac92xx_shutup_pins(codec);
5532 if (spec->eapd_mask)
5533 stac_gpio_set(codec, spec->gpio_mask,
5534 spec->gpio_dir, spec->gpio_data &
5538 static void stac92xx_free(struct hda_codec *codec)
5540 struct sigmatel_spec *spec = codec->spec;
5546 snd_hda_detach_beep_device(codec);
5549 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
5552 unsigned int old_ctl, pin_ctl;
5554 pin_ctl = snd_hda_codec_read(codec, nid,
5555 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
5557 if (pin_ctl & AC_PINCTL_IN_EN) {
5559 * we need to check the current set-up direction of
5560 * shared input pins since they can be switched via
5561 * "xxx as Output" mixer switch
5563 struct sigmatel_spec *spec = codec->spec;
5564 if (nid == spec->line_switch || nid == spec->mic_switch)
5569 /* if setting pin direction bits, clear the current
5570 direction bits first */
5571 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
5572 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
5575 if (old_ctl != pin_ctl)
5576 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl);
5579 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
5582 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
5583 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
5585 snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag);
5588 static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
5592 return snd_hda_jack_detect(codec, nid);
5595 static void stac92xx_line_out_detect(struct hda_codec *codec,
5598 struct sigmatel_spec *spec = codec->spec;
5599 struct auto_pin_cfg *cfg = &spec->autocfg;
5602 if (cfg->speaker_outs == 0)
5605 for (i = 0; i < cfg->line_outs; i++) {
5608 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
5610 unsigned int pinctl;
5611 pinctl = snd_hda_codec_read(codec,
5612 cfg->line_out_pins[i], 0,
5613 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5614 if (pinctl & AC_PINCTL_IN_EN)
5615 presence = 0; /* mic- or line-input */
5620 /* disable speakers */
5621 for (i = 0; i < cfg->speaker_outs; i++)
5622 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
5624 if (spec->eapd_mask && spec->eapd_switch)
5625 stac_gpio_set(codec, spec->gpio_mask,
5626 spec->gpio_dir, spec->gpio_data &
5629 /* enable speakers */
5630 for (i = 0; i < cfg->speaker_outs; i++)
5631 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
5633 if (spec->eapd_mask && spec->eapd_switch)
5634 stac_gpio_set(codec, spec->gpio_mask,
5635 spec->gpio_dir, spec->gpio_data |
5640 /* return non-zero if the hp-pin of the given array index isn't
5641 * a jack-detection target
5643 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
5645 struct auto_pin_cfg *cfg = &spec->autocfg;
5647 /* ignore sensing of shared line and mic jacks */
5648 if (cfg->hp_pins[i] == spec->line_switch)
5650 if (cfg->hp_pins[i] == spec->mic_switch)
5652 /* ignore if the pin is set as line-out */
5653 if (cfg->hp_pins[i] == spec->hp_switch)
5658 static void stac92xx_hp_detect(struct hda_codec *codec)
5660 struct sigmatel_spec *spec = codec->spec;
5661 struct auto_pin_cfg *cfg = &spec->autocfg;
5665 if (spec->gpio_mute)
5666 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
5667 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
5669 for (i = 0; i < cfg->hp_outs; i++) {
5672 if (no_hp_sensing(spec, i))
5674 presence = get_pin_presence(codec, cfg->hp_pins[i]);
5676 unsigned int pinctl;
5677 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
5678 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5679 if (pinctl & AC_PINCTL_IN_EN)
5680 presence = 0; /* mic- or line-input */
5685 /* disable lineouts */
5686 if (spec->hp_switch)
5687 stac92xx_reset_pinctl(codec, spec->hp_switch,
5689 for (i = 0; i < cfg->line_outs; i++)
5690 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
5693 /* enable lineouts */
5694 if (spec->hp_switch)
5695 stac92xx_set_pinctl(codec, spec->hp_switch,
5697 for (i = 0; i < cfg->line_outs; i++)
5698 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
5701 stac92xx_line_out_detect(codec, presence);
5702 /* toggle hp outs */
5703 for (i = 0; i < cfg->hp_outs; i++) {
5704 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
5705 if (no_hp_sensing(spec, i))
5708 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
5710 /* Resetting the pinctl like below may lead to (a sort of) regressions
5711 * on some devices since they use the HP pin actually for line/speaker
5712 * outs although the default pin config shows a different pin (that is
5713 * wrong and useless).
5715 * So, it's basically a problem of default pin configs, likely a BIOS issue.
5716 * But, disabling the code below just works around it, and I'm too tired of
5717 * bug reports with such devices...
5720 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
5725 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
5728 struct sigmatel_spec *spec = codec->spec;
5729 unsigned int idx, val;
5731 for (idx = 0; idx < spec->num_pwrs; idx++) {
5732 if (spec->pwr_nids[idx] == nid)
5735 if (idx >= spec->num_pwrs)
5740 val = spec->power_map_bits;
5746 /* power down unused output ports */
5747 if (val != spec->power_map_bits) {
5748 spec->power_map_bits = val;
5749 snd_hda_codec_write(codec, codec->afg, 0,
5750 AC_VERB_IDT_SET_POWER_MAP, val);
5754 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
5756 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
5759 /* get the pin connection (fixed, none, etc) */
5760 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5762 struct sigmatel_spec *spec = codec->spec;
5765 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5766 return get_defcfg_connect(cfg);
5769 static int stac92xx_connected_ports(struct hda_codec *codec,
5770 const hda_nid_t *nids, int num_nids)
5772 struct sigmatel_spec *spec = codec->spec;
5774 unsigned int def_conf;
5776 for (num = 0; num < num_nids; num++) {
5777 for (idx = 0; idx < spec->num_pins; idx++)
5778 if (spec->pin_nids[idx] == nids[num])
5780 if (idx >= spec->num_pins)
5782 def_conf = stac_get_defcfg_connect(codec, idx);
5783 if (def_conf == AC_JACK_PORT_NONE)
5789 static void stac92xx_mic_detect(struct hda_codec *codec)
5791 struct sigmatel_spec *spec = codec->spec;
5792 struct sigmatel_mic_route *mic;
5794 if (get_pin_presence(codec, spec->ext_mic.pin))
5795 mic = &spec->ext_mic;
5796 else if (get_pin_presence(codec, spec->dock_mic.pin))
5797 mic = &spec->dock_mic;
5799 mic = &spec->int_mic;
5800 if (mic->dmux_idx >= 0)
5801 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
5802 AC_VERB_SET_CONNECT_SEL,
5804 if (mic->mux_idx >= 0)
5805 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
5806 AC_VERB_SET_CONNECT_SEL,
5810 static void handle_unsol_event(struct hda_codec *codec,
5811 struct hda_jack_tbl *event)
5813 struct sigmatel_spec *spec = codec->spec;
5816 switch (event->action) {
5819 stac92xx_hp_detect(codec);
5821 case STAC_MIC_EVENT:
5822 stac92xx_mic_detect(codec);
5826 switch (event->action) {
5829 case STAC_MIC_EVENT:
5830 case STAC_INSERT_EVENT:
5831 case STAC_PWR_EVENT:
5832 if (spec->num_pwrs > 0)
5833 stac92xx_pin_sense(codec, event->nid);
5835 switch (codec->subsystem_id) {
5837 if (event->nid == 0xb) {
5838 int pin = AC_PINCTL_IN_EN;
5840 if (get_pin_presence(codec, 0xa)
5841 && get_pin_presence(codec, 0xb))
5842 pin |= AC_PINCTL_VREF_80;
5843 if (!get_pin_presence(codec, 0xb))
5844 pin |= AC_PINCTL_VREF_80;
5846 /* toggle VREF state based on mic + hp pin
5849 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
5853 case STAC_VREF_EVENT:
5854 data = snd_hda_codec_read(codec, codec->afg, 0,
5855 AC_VERB_GET_GPIO_DATA, 0);
5856 /* toggle VREF state based on GPIOx status */
5857 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
5858 !!(data & (1 << event->private_data)));
5863 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
5865 struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
5868 handle_unsol_event(codec, event);
5871 static void set_hp_led_gpio(struct hda_codec *codec)
5873 struct sigmatel_spec *spec = codec->spec;
5879 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
5880 gpio &= AC_GPIO_IO_COUNT;
5882 spec->gpio_led = 0x08; /* GPIO 3 */
5884 spec->gpio_led = 0x01; /* GPIO 0 */
5888 * This method searches for the mute LED GPIO configuration
5889 * provided as OEM string in SMBIOS. The format of that string
5890 * is HP_Mute_LED_P_G or HP_Mute_LED_P
5891 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
5892 * that corresponds to the NOT muted state of the master volume
5893 * and G is the index of the GPIO to use as the mute LED control (0..9)
5894 * If _G portion is missing it is assigned based on the codec ID
5896 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
5897 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
5900 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
5901 * SMBIOS - at least the ones I have seen do not have them - which include
5902 * my own system (HP Pavilion dv6-1110ax) and my cousin's
5903 * HP Pavilion dv9500t CTO.
5904 * Need more information on whether it is true across the entire series.
5907 static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
5909 struct sigmatel_spec *spec = codec->spec;
5910 const struct dmi_device *dev = NULL;
5912 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
5913 get_int_hint(codec, "gpio_led_polarity",
5914 &spec->gpio_led_polarity);
5918 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
5919 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
5921 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
5922 &spec->gpio_led_polarity,
5923 &spec->gpio_led) == 2) {
5924 unsigned int max_gpio;
5925 max_gpio = snd_hda_param_read(codec, codec->afg,
5927 max_gpio &= AC_GPIO_IO_COUNT;
5928 if (spec->gpio_led < max_gpio)
5929 spec->gpio_led = 1 << spec->gpio_led;
5931 spec->vref_mute_led_nid = spec->gpio_led;
5934 if (sscanf(dev->name, "HP_Mute_LED_%d",
5935 &spec->gpio_led_polarity) == 1) {
5936 set_hp_led_gpio(codec);
5939 /* BIOS bug: unfilled OEM string */
5940 if (strstr(dev->name, "HP_Mute_LED_P_G")) {
5941 set_hp_led_gpio(codec);
5942 switch (codec->subsystem_id) {
5944 spec->gpio_led_polarity = 0;
5947 spec->gpio_led_polarity = 1;
5955 * Fallback case - if we don't find the DMI strings,
5956 * we statically set the GPIO - if not a B-series system
5957 * and default polarity is provided
5959 if (!hp_blike_system(codec->subsystem_id) &&
5960 (default_polarity == 0 || default_polarity == 1)) {
5961 set_hp_led_gpio(codec);
5962 spec->gpio_led_polarity = default_polarity;
5969 static int hp_blike_system(u32 subsystem_id)
5971 switch (subsystem_id) {
5998 #ifdef CONFIG_PROC_FS
5999 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
6000 struct hda_codec *codec, hda_nid_t nid)
6002 if (nid == codec->afg)
6003 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
6004 snd_hda_codec_read(codec, nid, 0,
6005 AC_VERB_IDT_GET_POWER_MAP, 0));
6008 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
6009 struct hda_codec *codec,
6012 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
6013 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
6016 /* stac92hd71bxx, stac92hd73xx */
6017 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
6018 struct hda_codec *codec, hda_nid_t nid)
6020 stac92hd_proc_hook(buffer, codec, nid);
6021 if (nid == codec->afg)
6022 analog_loop_proc_hook(buffer, codec, 0xfa0);
6025 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
6026 struct hda_codec *codec, hda_nid_t nid)
6028 if (nid == codec->afg)
6029 analog_loop_proc_hook(buffer, codec, 0xfe0);
6032 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
6033 struct hda_codec *codec, hda_nid_t nid)
6035 if (nid == codec->afg)
6036 analog_loop_proc_hook(buffer, codec, 0xfeb);
6039 #define stac92hd_proc_hook NULL
6040 #define stac92hd7x_proc_hook NULL
6041 #define stac9205_proc_hook NULL
6042 #define stac927x_proc_hook NULL
6046 static int stac92xx_resume(struct hda_codec *codec)
6048 stac92xx_init(codec);
6049 snd_hda_codec_resume_amp(codec);
6050 snd_hda_codec_resume_cache(codec);
6051 /* fake event to set up pins again to override cached values */
6052 stac_fake_hp_events(codec);
6056 static int stac92xx_suspend(struct hda_codec *codec)
6058 stac92xx_shutup(codec);
6062 static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
6063 unsigned int power_state)
6065 unsigned int afg_power_state = power_state;
6066 struct sigmatel_spec *spec = codec->spec;
6068 if (power_state == AC_PWRST_D3) {
6069 if (spec->vref_mute_led_nid) {
6070 /* with vref-out pin used for mute led control
6071 * codec AFG is prevented from D3 state
6073 afg_power_state = AC_PWRST_D1;
6075 /* this delay seems necessary to avoid click noise at power-down */
6078 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
6080 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
6083 #define stac92xx_suspend NULL
6084 #define stac92xx_resume NULL
6085 #define stac92xx_set_power_state NULL
6086 #endif /* CONFIG_PM */
6088 /* update mute-LED accoring to the master switch */
6089 static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
6091 struct sigmatel_spec *spec = codec->spec;
6092 int muted = !enabled;
6094 if (!spec->gpio_led)
6097 /* LED state is inverted on these systems */
6098 if (spec->gpio_led_polarity)
6101 if (!spec->vref_mute_led_nid) {
6103 spec->gpio_data |= spec->gpio_led;
6105 spec->gpio_data &= ~spec->gpio_led;
6106 stac_gpio_set(codec, spec->gpio_mask,
6107 spec->gpio_dir, spec->gpio_data);
6109 spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
6110 stac_vrefout_set(codec, spec->vref_mute_led_nid,
6115 static const struct hda_codec_ops stac92xx_patch_ops = {
6116 .build_controls = stac92xx_build_controls,
6117 .build_pcms = stac92xx_build_pcms,
6118 .init = stac92xx_init,
6119 .free = stac92xx_free,
6120 .unsol_event = snd_hda_jack_unsol_event,
6122 .suspend = stac92xx_suspend,
6123 .resume = stac92xx_resume,
6125 .reboot_notify = stac92xx_shutup,
6128 static int alloc_stac_spec(struct hda_codec *codec, int num_pins,
6129 const hda_nid_t *pin_nids)
6131 struct sigmatel_spec *spec;
6133 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6137 codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */
6138 spec->num_pins = num_pins;
6139 spec->pin_nids = pin_nids;
6140 snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32);
6144 static int patch_stac9200(struct hda_codec *codec)
6146 struct sigmatel_spec *spec;
6149 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9200_pin_nids),
6155 spec->linear_tone_beep = 1;
6157 snd_hda_pick_fixup(codec, stac9200_models, stac9200_fixup_tbl,
6160 spec->multiout.max_channels = 2;
6161 spec->multiout.num_dacs = 1;
6162 spec->multiout.dac_nids = stac9200_dac_nids;
6163 spec->adc_nids = stac9200_adc_nids;
6164 spec->mux_nids = stac9200_mux_nids;
6165 spec->num_muxes = 1;
6166 spec->num_dmics = 0;
6169 snd_hda_add_verbs(codec, stac9200_eapd_init);
6171 spec->mixer = stac9200_mixer;
6173 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6175 err = stac9200_parse_auto_config(codec);
6177 stac92xx_free(codec);
6181 codec->patch_ops = stac92xx_patch_ops;
6183 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6188 static int patch_stac925x(struct hda_codec *codec)
6190 struct sigmatel_spec *spec;
6193 err = alloc_stac_spec(codec, ARRAY_SIZE(stac925x_pin_nids),
6199 spec->linear_tone_beep = 1;
6201 snd_hda_pick_fixup(codec, stac925x_models, stac925x_fixup_tbl,
6204 spec->multiout.max_channels = 2;
6205 spec->multiout.num_dacs = 1;
6206 spec->multiout.dac_nids = stac925x_dac_nids;
6207 spec->adc_nids = stac925x_adc_nids;
6208 spec->mux_nids = stac925x_mux_nids;
6209 spec->num_muxes = 1;
6212 switch (codec->vendor_id) {
6213 case 0x83847632: /* STAC9202 */
6214 case 0x83847633: /* STAC9202D */
6215 case 0x83847636: /* STAC9251 */
6216 case 0x83847637: /* STAC9251D */
6217 spec->num_dmics = STAC925X_NUM_DMICS;
6218 spec->dmic_nids = stac925x_dmic_nids;
6219 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
6220 spec->dmux_nids = stac925x_dmux_nids;
6223 spec->num_dmics = 0;
6227 snd_hda_add_verbs(codec, stac925x_core_init);
6228 spec->mixer = stac925x_mixer;
6230 spec->capvols = stac925x_capvols;
6231 spec->capsws = stac925x_capsws;
6233 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6235 err = stac92xx_parse_auto_config(codec);
6239 stac92xx_free(codec);
6243 codec->patch_ops = stac92xx_patch_ops;
6245 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6250 static int patch_stac92hd73xx(struct hda_codec *codec)
6252 struct sigmatel_spec *spec;
6253 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
6257 err = alloc_stac_spec(codec, ARRAY_SIZE(stac92hd73xx_pin_nids),
6258 stac92hd73xx_pin_nids);
6263 spec->linear_tone_beep = 0;
6264 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
6265 spec->board_config = snd_hda_check_board_config(codec,
6266 STAC_92HD73XX_MODELS,
6267 stac92hd73xx_models,
6268 stac92hd73xx_cfg_tbl);
6269 /* check codec subsystem id if not found */
6270 if (spec->board_config < 0)
6271 spec->board_config =
6272 snd_hda_check_board_codec_sid_config(codec,
6273 STAC_92HD73XX_MODELS, stac92hd73xx_models,
6274 stac92hd73xx_codec_id_cfg_tbl);
6276 if (spec->board_config < 0)
6277 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6280 stac92xx_set_config_regs(codec,
6281 stac92hd73xx_brd_tbl[spec->board_config]);
6283 num_dacs = snd_hda_get_connections(codec, 0x0a,
6284 conn, STAC92HD73_DAC_COUNT + 2) - 1;
6286 if (num_dacs < 3 || num_dacs > 5) {
6287 printk(KERN_WARNING "hda_codec: Could not determine "
6288 "number of channels defaulting to DAC count\n");
6289 num_dacs = STAC92HD73_DAC_COUNT;
6291 spec->init = stac92hd73xx_core_init;
6293 case 0x3: /* 6 Channel */
6294 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
6296 case 0x4: /* 8 Channel */
6297 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
6299 case 0x5: /* 10 Channel */
6300 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
6303 spec->multiout.dac_nids = spec->dac_nids;
6305 spec->aloopback_mask = 0x01;
6306 spec->aloopback_shift = 8;
6308 spec->digbeep_nid = 0x1c;
6309 spec->mux_nids = stac92hd73xx_mux_nids;
6310 spec->adc_nids = stac92hd73xx_adc_nids;
6311 spec->dmic_nids = stac92hd73xx_dmic_nids;
6312 spec->dmux_nids = stac92hd73xx_dmux_nids;
6313 spec->smux_nids = stac92hd73xx_smux_nids;
6315 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
6316 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
6317 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
6319 spec->num_caps = STAC92HD73XX_NUM_CAPS;
6320 spec->capvols = stac92hd73xx_capvols;
6321 spec->capsws = stac92hd73xx_capsws;
6323 switch (spec->board_config) {
6325 spec->init = dell_eq_core_init;
6327 case STAC_DELL_M6_AMIC:
6328 case STAC_DELL_M6_DMIC:
6329 case STAC_DELL_M6_BOTH:
6330 spec->num_smuxes = 0;
6331 spec->eapd_switch = 0;
6333 switch (spec->board_config) {
6334 case STAC_DELL_M6_AMIC: /* Analog Mics */
6335 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
6336 spec->num_dmics = 0;
6338 case STAC_DELL_M6_DMIC: /* Digital Mics */
6339 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
6340 spec->num_dmics = 1;
6342 case STAC_DELL_M6_BOTH: /* Both */
6343 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
6344 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
6345 spec->num_dmics = 1;
6349 case STAC_ALIENWARE_M17X:
6350 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
6351 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
6352 spec->eapd_switch = 0;
6355 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
6356 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
6357 spec->eapd_switch = 1;
6360 if (spec->board_config != STAC_92HD73XX_REF) {
6361 /* GPIO0 High = Enable EAPD */
6362 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6363 spec->gpio_data = 0x01;
6366 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
6367 spec->pwr_nids = stac92hd73xx_pwr_nids;
6369 err = stac92xx_parse_auto_config(codec);
6372 if (spec->board_config < 0) {
6373 printk(KERN_WARNING "hda_codec: No auto-config is "
6374 "available, default to model=ref\n");
6375 spec->board_config = STAC_92HD73XX_REF;
6382 stac92xx_free(codec);
6386 if (spec->board_config == STAC_92HD73XX_NO_JD)
6387 spec->hp_detect = 0;
6389 codec->patch_ops = stac92xx_patch_ops;
6391 codec->proc_widget_hook = stac92hd7x_proc_hook;
6396 static int hp_bnb2011_with_dock(struct hda_codec *codec)
6398 if (codec->vendor_id != 0x111d7605 &&
6399 codec->vendor_id != 0x111d76d1)
6402 switch (codec->subsystem_id) {
6436 static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
6438 struct sigmatel_spec *spec = codec->spec;
6439 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
6442 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
6443 spec->auto_pin_cnt++;
6445 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
6446 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
6447 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
6448 if (nid == stac92hd83xxx_dmic_nids[i]) {
6449 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
6450 spec->auto_dmic_cnt++;
6456 static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
6458 struct sigmatel_spec *spec = codec->spec;
6460 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
6461 spec->auto_adc_cnt++;
6464 static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
6467 struct sigmatel_spec *spec = codec->spec;
6469 for (i = 0; i < spec->auto_adc_cnt; i++) {
6470 if (get_connection_index(codec,
6471 spec->auto_adc_nids[i], nid) >= 0) {
6472 /* mux and volume for adc_nids[i] */
6473 if (!spec->auto_mux_nids[i]) {
6474 spec->auto_mux_nids[i] = nid;
6475 /* 92hd codecs capture volume is in mux */
6476 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
6479 for (j = 0; j < spec->auto_dmic_cnt; j++) {
6480 if (get_connection_index(codec, nid,
6481 spec->auto_dmic_nids[j]) >= 0) {
6482 /* dmux for adc_nids[i] */
6483 if (!spec->auto_dmux_nids[i])
6484 spec->auto_dmux_nids[i] = nid;
6493 static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
6495 hda_nid_t nid, end_nid;
6496 unsigned int wid_caps, wid_type;
6497 struct sigmatel_spec *spec = codec->spec;
6499 end_nid = codec->start_nid + codec->num_nodes;
6501 for (nid = codec->start_nid; nid < end_nid; nid++) {
6502 wid_caps = get_wcaps(codec, nid);
6503 wid_type = get_wcaps_type(wid_caps);
6505 if (wid_type == AC_WID_PIN)
6506 stac92hd8x_add_pin(codec, nid);
6508 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
6509 stac92hd8x_add_adc(codec, nid);
6512 for (nid = codec->start_nid; nid < end_nid; nid++) {
6513 wid_caps = get_wcaps(codec, nid);
6514 wid_type = get_wcaps_type(wid_caps);
6516 if (wid_type == AC_WID_AUD_SEL)
6517 stac92hd8x_add_mux(codec, nid);
6520 spec->pin_nids = spec->auto_pin_nids;
6521 spec->num_pins = spec->auto_pin_cnt;
6522 spec->adc_nids = spec->auto_adc_nids;
6523 spec->num_adcs = spec->auto_adc_cnt;
6524 spec->capvols = spec->auto_capvols;
6525 spec->capsws = spec->auto_capvols;
6526 spec->num_caps = spec->auto_adc_cnt;
6527 spec->mux_nids = spec->auto_mux_nids;
6528 spec->num_muxes = spec->auto_adc_cnt;
6529 spec->dmux_nids = spec->auto_dmux_nids;
6530 spec->num_dmuxes = spec->auto_adc_cnt;
6531 spec->dmic_nids = spec->auto_dmic_nids;
6532 spec->num_dmics = spec->auto_dmic_cnt;
6535 static int patch_stac92hd83xxx(struct hda_codec *codec)
6537 struct sigmatel_spec *spec;
6538 int default_polarity = -1; /* no default cfg */
6541 err = alloc_stac_spec(codec, 0, NULL); /* pins filled later */
6545 if (hp_bnb2011_with_dock(codec)) {
6546 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
6547 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
6550 codec->epss = 0; /* longer delay needed for D3 */
6551 stac92hd8x_fill_auto_spec(codec);
6554 spec->linear_tone_beep = 0;
6555 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
6556 spec->digbeep_nid = 0x21;
6557 spec->pwr_nids = stac92hd83xxx_pwr_nids;
6558 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
6559 spec->multiout.dac_nids = spec->dac_nids;
6560 spec->init = stac92hd83xxx_core_init;
6562 spec->board_config = snd_hda_check_board_config(codec,
6563 STAC_92HD83XXX_MODELS,
6564 stac92hd83xxx_models,
6565 stac92hd83xxx_cfg_tbl);
6566 /* check codec subsystem id if not found */
6567 if (spec->board_config < 0)
6568 spec->board_config =
6569 snd_hda_check_board_codec_sid_config(codec,
6570 STAC_92HD83XXX_MODELS, stac92hd83xxx_models,
6571 stac92hd83xxx_codec_id_cfg_tbl);
6573 if (spec->board_config < 0)
6574 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6577 stac92xx_set_config_regs(codec,
6578 stac92hd83xxx_brd_tbl[spec->board_config]);
6580 codec->patch_ops = stac92xx_patch_ops;
6582 switch (spec->board_config) {
6583 case STAC_HP_ZEPHYR:
6584 spec->init = stac92hd83xxx_hp_zephyr_init;
6586 case STAC_92HD83XXX_HP_LED:
6587 default_polarity = 0;
6589 case STAC_92HD83XXX_HP_INV_LED:
6590 default_polarity = 1;
6592 case STAC_92HD83XXX_HP_MIC_LED:
6593 spec->mic_mute_led_gpio = 0x08; /* GPIO3 */
6595 case STAC_92HD83XXX_HEADSET_JACK:
6596 spec->headset_jack = 1;
6600 if (find_mute_led_cfg(codec, default_polarity))
6601 snd_printd("mute LED gpio %d polarity %d\n",
6603 spec->gpio_led_polarity);
6605 if (spec->gpio_led) {
6606 if (!spec->vref_mute_led_nid) {
6607 spec->gpio_mask |= spec->gpio_led;
6608 spec->gpio_dir |= spec->gpio_led;
6609 spec->gpio_data |= spec->gpio_led;
6611 codec->patch_ops.set_power_state =
6612 stac92xx_set_power_state;
6616 if (spec->mic_mute_led_gpio) {
6617 spec->gpio_mask |= spec->mic_mute_led_gpio;
6618 spec->gpio_dir |= spec->mic_mute_led_gpio;
6619 spec->mic_mute_led_on = true;
6620 spec->gpio_data |= spec->mic_mute_led_gpio;
6623 err = stac92xx_parse_auto_config(codec);
6625 if (spec->board_config < 0) {
6626 printk(KERN_WARNING "hda_codec: No auto-config is "
6627 "available, default to model=ref\n");
6628 spec->board_config = STAC_92HD83XXX_REF;
6635 stac92xx_free(codec);
6639 codec->proc_widget_hook = stac92hd_proc_hook;
6644 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
6647 struct sigmatel_spec *spec = codec->spec;
6650 for (idx = 0; idx < spec->num_pins; idx++)
6651 if (spec->pin_nids[idx] == dig0pin)
6653 if ((idx + 2) >= spec->num_pins)
6657 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
6660 /* dig0pin + dig2pin case */
6661 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
6663 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
6669 /* HP dv7 bass switch - GPIO5 */
6670 #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
6671 static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
6672 struct snd_ctl_elem_value *ucontrol)
6674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6675 struct sigmatel_spec *spec = codec->spec;
6676 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
6680 static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
6681 struct snd_ctl_elem_value *ucontrol)
6683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6684 struct sigmatel_spec *spec = codec->spec;
6685 unsigned int gpio_data;
6687 gpio_data = (spec->gpio_data & ~0x20) |
6688 (ucontrol->value.integer.value[0] ? 0x20 : 0);
6689 if (gpio_data == spec->gpio_data)
6691 spec->gpio_data = gpio_data;
6692 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
6696 static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
6697 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6698 .info = stac_hp_bass_gpio_info,
6699 .get = stac_hp_bass_gpio_get,
6700 .put = stac_hp_bass_gpio_put,
6703 static int stac_add_hp_bass_switch(struct hda_codec *codec)
6705 struct sigmatel_spec *spec = codec->spec;
6707 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
6708 "Bass Speaker Playback Switch", 0))
6711 spec->gpio_mask |= 0x20;
6712 spec->gpio_dir |= 0x20;
6713 spec->gpio_data |= 0x20;
6717 static int patch_stac92hd71bxx(struct hda_codec *codec)
6719 struct sigmatel_spec *spec;
6720 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
6723 err = alloc_stac_spec(codec, STAC92HD71BXX_NUM_PINS,
6724 stac92hd71bxx_pin_nids_4port);
6729 spec->linear_tone_beep = 0;
6730 codec->patch_ops = stac92xx_patch_ops;
6731 switch (codec->vendor_id) {
6737 /* On 92HD75Bx 0x27 isn't a pin nid */
6741 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
6743 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
6745 snd_hda_pick_fixup(codec, stac92hd71bxx_models, stac92hd71bxx_fixup_tbl,
6746 stac92hd71bxx_fixups);
6749 spec->gpio_mask = 0x01;
6750 spec->gpio_dir = 0x01;
6751 spec->gpio_data = 0x01;
6753 spec->dmic_nids = stac92hd71bxx_dmic_nids;
6754 spec->dmux_nids = stac92hd71bxx_dmux_nids;
6756 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
6757 spec->capvols = stac92hd71bxx_capvols;
6758 spec->capsws = stac92hd71bxx_capsws;
6760 switch (codec->vendor_id) {
6761 case 0x111d76b6: /* 4 Port without Analog Mixer */
6765 case 0x111d76b4: /* 6 Port without Analog Mixer */
6767 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
6768 spec->num_dmics = stac92xx_connected_ports(codec,
6769 stac92hd71bxx_dmic_nids,
6770 STAC92HD71BXX_NUM_DMICS);
6772 case 0x111d7608: /* 5 Port with Analog Mixer */
6773 if ((codec->revision_id & 0xf) == 0 ||
6774 (codec->revision_id & 0xf) == 1)
6775 spec->stream_delay = 40; /* 40 milliseconds */
6779 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
6780 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
6781 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
6782 spec->num_dmics = stac92xx_connected_ports(codec,
6783 stac92hd71bxx_dmic_5port_nids,
6784 STAC92HD71BXX_NUM_DMICS - 1);
6786 case 0x111d7603: /* 6 Port with Analog Mixer */
6787 if ((codec->revision_id & 0xf) == 1)
6788 spec->stream_delay = 40; /* 40 milliseconds */
6792 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
6793 spec->num_dmics = stac92xx_connected_ports(codec,
6794 stac92hd71bxx_dmic_nids,
6795 STAC92HD71BXX_NUM_DMICS);
6799 if (get_wcaps_type(get_wcaps(codec, 0x28)) == AC_WID_VOL_KNB)
6800 snd_hda_add_verbs(codec, stac92hd71bxx_core_init);
6802 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
6803 snd_hda_sequence_write_cache(codec, unmute_init);
6805 spec->aloopback_ctl = stac92hd71bxx_loopback;
6806 spec->aloopback_mask = 0x50;
6807 spec->aloopback_shift = 0;
6809 spec->powerdown_adcs = 1;
6810 spec->digbeep_nid = 0x26;
6811 spec->mux_nids = stac92hd71bxx_mux_nids;
6812 spec->adc_nids = stac92hd71bxx_adc_nids;
6813 spec->smux_nids = stac92hd71bxx_smux_nids;
6814 spec->pwr_nids = stac92hd71bxx_pwr_nids;
6816 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
6817 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
6818 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
6819 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
6821 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6823 if (spec->gpio_led) {
6824 if (!spec->vref_mute_led_nid) {
6825 spec->gpio_mask |= spec->gpio_led;
6826 spec->gpio_dir |= spec->gpio_led;
6827 spec->gpio_data |= spec->gpio_led;
6829 codec->patch_ops.set_power_state =
6830 stac92xx_set_power_state;
6834 spec->multiout.dac_nids = spec->dac_nids;
6836 err = stac92xx_parse_auto_config(codec);
6840 stac92xx_free(codec);
6844 codec->proc_widget_hook = stac92hd7x_proc_hook;
6846 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6851 static int patch_stac922x(struct hda_codec *codec)
6853 struct sigmatel_spec *spec;
6856 err = alloc_stac_spec(codec, ARRAY_SIZE(stac922x_pin_nids),
6862 spec->linear_tone_beep = 1;
6864 snd_hda_pick_fixup(codec, stac922x_models, stac922x_fixup_tbl,
6867 spec->adc_nids = stac922x_adc_nids;
6868 spec->mux_nids = stac922x_mux_nids;
6869 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
6870 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
6871 spec->num_dmics = 0;
6874 spec->num_caps = STAC922X_NUM_CAPS;
6875 spec->capvols = stac922x_capvols;
6876 spec->capsws = stac922x_capsws;
6878 spec->multiout.dac_nids = spec->dac_nids;
6880 snd_hda_add_verbs(codec, stac922x_core_init);
6882 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6884 err = stac92xx_parse_auto_config(codec);
6888 stac92xx_free(codec);
6892 codec->patch_ops = stac92xx_patch_ops;
6894 /* Fix Mux capture level; max to 2 */
6895 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
6896 (0 << AC_AMPCAP_OFFSET_SHIFT) |
6897 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6898 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6899 (0 << AC_AMPCAP_MUTE_SHIFT));
6901 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6906 static int patch_stac927x(struct hda_codec *codec)
6908 struct sigmatel_spec *spec;
6911 err = alloc_stac_spec(codec, ARRAY_SIZE(stac927x_pin_nids),
6917 spec->linear_tone_beep = 1;
6918 codec->slave_dig_outs = stac927x_slave_dig_outs;
6920 snd_hda_pick_fixup(codec, stac927x_models, stac927x_fixup_tbl,
6923 spec->digbeep_nid = 0x23;
6924 spec->adc_nids = stac927x_adc_nids;
6925 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
6926 spec->mux_nids = stac927x_mux_nids;
6927 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
6928 spec->smux_nids = stac927x_smux_nids;
6929 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
6930 spec->spdif_labels = stac927x_spdif_labels;
6931 spec->dac_list = stac927x_dac_nids;
6932 spec->multiout.dac_nids = spec->dac_nids;
6934 /* GPIO0 High = Enable EAPD */
6935 spec->eapd_mask = spec->gpio_mask = 0x01;
6936 spec->gpio_dir = spec->gpio_data = 0x01;
6938 spec->num_dmics = 0;
6940 spec->num_caps = STAC927X_NUM_CAPS;
6941 spec->capvols = stac927x_capvols;
6942 spec->capsws = stac927x_capsws;
6945 spec->aloopback_ctl = stac927x_loopback;
6946 spec->aloopback_mask = 0x40;
6947 spec->aloopback_shift = 0;
6948 spec->eapd_switch = 1;
6950 if (!spec->volknob_init)
6951 snd_hda_add_verbs(codec, stac927x_core_init);
6953 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
6955 err = stac92xx_parse_auto_config(codec);
6959 stac92xx_free(codec);
6963 codec->patch_ops = stac92xx_patch_ops;
6965 codec->proc_widget_hook = stac927x_proc_hook;
6969 * The STAC927x seem to require fairly long delays for certain
6970 * command sequences. With too short delays (even if the answer
6971 * is set to RIRB properly), it results in the silence output
6972 * on some hardwares like Dell.
6974 * The below flag enables the longer delay (see get_response
6977 codec->bus->needs_damn_long_delay = 1;
6979 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
6984 static int patch_stac9205(struct hda_codec *codec)
6986 struct sigmatel_spec *spec;
6989 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9205_pin_nids),
6995 spec->linear_tone_beep = 1;
6997 snd_hda_pick_fixup(codec, stac9205_models, stac9205_fixup_tbl,
7000 spec->digbeep_nid = 0x23;
7001 spec->adc_nids = stac9205_adc_nids;
7002 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
7003 spec->mux_nids = stac9205_mux_nids;
7004 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
7005 spec->smux_nids = stac9205_smux_nids;
7006 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
7007 spec->dmic_nids = stac9205_dmic_nids;
7008 spec->num_dmics = STAC9205_NUM_DMICS;
7009 spec->dmux_nids = stac9205_dmux_nids;
7010 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
7013 snd_hda_add_verbs(codec, stac9205_core_init);
7014 spec->aloopback_ctl = stac9205_loopback;
7016 spec->num_caps = STAC9205_NUM_CAPS;
7017 spec->capvols = stac9205_capvols;
7018 spec->capsws = stac9205_capsws;
7020 spec->aloopback_mask = 0x40;
7021 spec->aloopback_shift = 0;
7022 spec->multiout.dac_nids = spec->dac_nids;
7024 /* GPIO0 High = EAPD */
7025 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
7026 spec->gpio_data = 0x01;
7028 /* Turn on/off EAPD per HP plugging */
7029 spec->eapd_switch = 1;
7031 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
7033 err = stac92xx_parse_auto_config(codec);
7037 stac92xx_free(codec);
7041 codec->patch_ops = stac92xx_patch_ops;
7043 codec->proc_widget_hook = stac9205_proc_hook;
7045 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7054 static const struct hda_verb stac9872_core_init[] = {
7055 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
7056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
7060 static const hda_nid_t stac9872_pin_nids[] = {
7061 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
7065 static const hda_nid_t stac9872_adc_nids[] = {
7069 static const hda_nid_t stac9872_mux_nids[] = {
7073 static const unsigned long stac9872_capvols[] = {
7074 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7076 #define stac9872_capsws stac9872_capvols
7078 static const struct hda_pintbl stac9872_vaio_pin_configs[] = {
7079 { 0x0a, 0x03211020 },
7080 { 0x0b, 0x411111f0 },
7081 { 0x0c, 0x411111f0 },
7082 { 0x0d, 0x03a15030 },
7083 { 0x0e, 0x411111f0 },
7084 { 0x0f, 0x90170110 },
7085 { 0x11, 0x411111f0 },
7086 { 0x13, 0x411111f0 },
7087 { 0x14, 0x90a7013e },
7091 static const struct hda_model_fixup stac9872_models[] = {
7092 { .id = STAC_9872_VAIO, .name = "vaio" },
7096 static const struct hda_fixup stac9872_fixups[] = {
7097 [STAC_9872_VAIO] = {
7098 .type = HDA_FIXUP_PINS,
7099 .v.pins = stac9872_vaio_pin_configs,
7103 static const struct snd_pci_quirk stac9872_fixup_tbl[] = {
7104 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
7105 "Sony VAIO F/S", STAC_9872_VAIO),
7109 static int patch_stac9872(struct hda_codec *codec)
7111 struct sigmatel_spec *spec;
7114 err = alloc_stac_spec(codec, ARRAY_SIZE(stac9872_pin_nids),
7120 spec->linear_tone_beep = 1;
7122 snd_hda_pick_fixup(codec, stac9872_models, stac9872_fixup_tbl,
7125 spec->multiout.dac_nids = spec->dac_nids;
7126 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
7127 spec->adc_nids = stac9872_adc_nids;
7128 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
7129 spec->mux_nids = stac9872_mux_nids;
7131 spec->capvols = stac9872_capvols;
7132 spec->capsws = stac9872_capsws;
7133 snd_hda_add_verbs(codec, stac9872_core_init);
7135 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
7137 err = stac92xx_parse_auto_config(codec);
7139 stac92xx_free(codec);
7142 spec->input_mux = &spec->private_imux;
7143 codec->patch_ops = stac92xx_patch_ops;
7145 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
7154 static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
7155 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
7156 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
7157 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
7158 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
7159 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
7160 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
7161 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
7162 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
7163 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
7164 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
7165 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
7166 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
7167 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
7168 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
7169 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
7170 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
7171 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
7172 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
7173 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
7174 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
7175 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
7176 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
7177 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
7178 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
7179 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
7180 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
7181 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
7182 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
7183 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
7184 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
7185 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
7186 /* The following does not take into account .id=0x83847661 when subsys =
7187 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
7188 * currently not fully supported.
7190 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
7191 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
7192 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
7193 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
7194 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
7195 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
7196 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
7197 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
7198 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
7199 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
7200 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
7201 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
7202 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
7203 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
7204 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
7205 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
7206 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
7207 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
7208 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
7209 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
7210 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
7211 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
7212 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
7213 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
7214 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
7215 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
7216 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
7217 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7218 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
7219 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7220 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
7221 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7222 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
7223 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
7224 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
7225 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
7226 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
7227 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
7228 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
7229 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
7230 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
7231 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
7232 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
7233 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
7234 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
7235 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
7236 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
7237 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
7238 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
7239 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
7240 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
7241 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
7242 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
7243 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
7244 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
7245 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
7246 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
7247 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
7248 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
7249 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
7250 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
7251 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
7252 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
7253 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
7254 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
7255 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
7256 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
7260 MODULE_ALIAS("snd-hda-codec-id:8384*");
7261 MODULE_ALIAS("snd-hda-codec-id:111d*");
7263 MODULE_LICENSE("GPL");
7264 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
7266 static struct hda_codec_preset_list sigmatel_list = {
7267 .preset = snd_hda_preset_sigmatel,
7268 .owner = THIS_MODULE,
7271 static int __init patch_sigmatel_init(void)
7273 return snd_hda_add_codec_preset(&sigmatel_list);
7276 static void __exit patch_sigmatel_exit(void)
7278 snd_hda_delete_codec_preset(&sigmatel_list);
7281 module_init(patch_sigmatel_init)
7282 module_exit(patch_sigmatel_exit)