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 <sound/core.h>
32 #include <sound/asoundef.h>
33 #include "hda_codec.h"
34 #include "hda_local.h"
35 #include "hda_patch.h"
38 #define NUM_CONTROL_ALLOC 32
39 #define STAC_PWR_EVENT 0x20
40 #define STAC_HP_EVENT 0x30
104 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
105 * is given, one of the above models will be
106 * chosen according to the subsystem id. */
107 /* for backward compatibility */
131 struct sigmatel_spec {
132 struct snd_kcontrol_new *mixers[4];
133 unsigned int num_mixers;
136 unsigned int surr_switch: 1;
137 unsigned int line_switch: 1;
138 unsigned int mic_switch: 1;
139 unsigned int alt_switch: 1;
140 unsigned int hp_detect: 1;
143 unsigned int eapd_mask;
144 unsigned int gpio_mask;
145 unsigned int gpio_dir;
146 unsigned int gpio_data;
147 unsigned int gpio_mute;
150 unsigned int stream_delay;
152 /* analog loopback */
153 unsigned char aloopback_mask;
154 unsigned char aloopback_shift;
156 /* power management */
157 unsigned int num_pwrs;
158 unsigned int *pwr_mapping;
163 struct hda_input_mux *mono_mux;
164 struct hda_input_mux *amp_mux;
165 unsigned int cur_mmux;
166 struct hda_multi_out multiout;
167 hda_nid_t dac_nids[5];
171 unsigned int num_adcs;
173 unsigned int num_muxes;
174 hda_nid_t *dmic_nids;
175 unsigned int num_dmics;
176 hda_nid_t *dmux_nids;
177 unsigned int num_dmuxes;
178 hda_nid_t *smux_nids;
179 unsigned int num_smuxes;
181 hda_nid_t dig_in_nid;
183 hda_nid_t anabeep_nid;
184 hda_nid_t digbeep_nid;
188 unsigned int num_pins;
189 unsigned int *pin_configs;
190 unsigned int *bios_pin_configs;
192 /* codec specific stuff */
193 struct hda_verb *init;
194 struct snd_kcontrol_new *mixer;
197 struct hda_input_mux *dinput_mux;
198 unsigned int cur_dmux[2];
199 struct hda_input_mux *input_mux;
200 unsigned int cur_mux[3];
201 struct hda_input_mux *sinput_mux;
202 unsigned int cur_smux[2];
203 unsigned int cur_amux;
205 unsigned int num_amps;
206 unsigned int powerdown_adcs;
209 unsigned int io_switch[2];
210 unsigned int clfe_swap;
211 unsigned int hp_switch;
212 unsigned int aloopback;
214 struct hda_pcm pcm_rec[2]; /* PCM information */
216 /* dynamic controls and input_mux */
217 struct auto_pin_cfg autocfg;
218 unsigned int num_kctl_alloc, num_kctl_used;
219 struct snd_kcontrol_new *kctl_alloc;
220 struct hda_input_mux private_dimux;
221 struct hda_input_mux private_imux;
222 struct hda_input_mux private_smux;
223 struct hda_input_mux private_amp_mux;
224 struct hda_input_mux private_mono_mux;
227 static hda_nid_t stac9200_adc_nids[1] = {
231 static hda_nid_t stac9200_mux_nids[1] = {
235 static hda_nid_t stac9200_dac_nids[1] = {
239 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
240 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
244 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
248 static hda_nid_t stac92hd73xx_adc_nids[2] = {
252 #define DELL_M6_AMP 2
253 static hda_nid_t stac92hd73xx_amp_nids[3] = {
257 #define STAC92HD73XX_NUM_DMICS 2
258 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
262 #define STAC92HD73_DAC_COUNT 5
263 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
264 0x15, 0x16, 0x17, 0x18, 0x19,
267 static hda_nid_t stac92hd73xx_mux_nids[4] = {
268 0x28, 0x29, 0x2a, 0x2b,
271 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
275 static hda_nid_t stac92hd73xx_smux_nids[2] = {
279 #define STAC92HD83XXX_NUM_DMICS 2
280 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
284 #define STAC92HD81_DAC_COUNT 2
285 #define STAC92HD83_DAC_COUNT 3
286 static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
290 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
294 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
298 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
302 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
306 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
307 0x03, 0x0c, 0x10, 0x40,
310 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
314 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
318 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
322 static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
326 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
330 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
334 #define STAC92HD71BXX_NUM_DMICS 2
335 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
339 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
343 static hda_nid_t stac925x_adc_nids[1] = {
347 static hda_nid_t stac925x_mux_nids[1] = {
351 static hda_nid_t stac925x_dac_nids[1] = {
355 #define STAC925X_NUM_DMICS 1
356 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
360 static hda_nid_t stac925x_dmux_nids[1] = {
364 static hda_nid_t stac922x_adc_nids[2] = {
368 static hda_nid_t stac922x_mux_nids[2] = {
372 static hda_nid_t stac927x_adc_nids[3] = {
376 static hda_nid_t stac927x_mux_nids[3] = {
380 static hda_nid_t stac927x_smux_nids[1] = {
384 static hda_nid_t stac927x_dac_nids[6] = {
385 0x02, 0x03, 0x04, 0x05, 0x06, 0
388 static hda_nid_t stac927x_dmux_nids[1] = {
392 #define STAC927X_NUM_DMICS 2
393 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
397 static hda_nid_t stac9205_adc_nids[2] = {
401 static hda_nid_t stac9205_mux_nids[2] = {
405 static hda_nid_t stac9205_dmux_nids[1] = {
409 static hda_nid_t stac9205_smux_nids[1] = {
413 #define STAC9205_NUM_DMICS 2
414 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
418 static hda_nid_t stac9200_pin_nids[8] = {
419 0x08, 0x09, 0x0d, 0x0e,
420 0x0f, 0x10, 0x11, 0x12,
423 static hda_nid_t stac925x_pin_nids[8] = {
424 0x07, 0x08, 0x0a, 0x0b,
425 0x0c, 0x0d, 0x10, 0x11,
428 static hda_nid_t stac922x_pin_nids[10] = {
429 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
430 0x0f, 0x10, 0x11, 0x15, 0x1b,
433 static hda_nid_t stac92hd73xx_pin_nids[13] = {
434 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
435 0x0f, 0x10, 0x11, 0x12, 0x13,
439 static hda_nid_t stac92hd83xxx_pin_nids[14] = {
440 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
441 0x0f, 0x10, 0x11, 0x12, 0x13,
442 0x1d, 0x1e, 0x1f, 0x20
444 static hda_nid_t stac92hd71bxx_pin_nids[11] = {
445 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
446 0x0f, 0x14, 0x18, 0x19, 0x1e,
450 static hda_nid_t stac927x_pin_nids[14] = {
451 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
452 0x0f, 0x10, 0x11, 0x12, 0x13,
453 0x14, 0x21, 0x22, 0x23,
456 static hda_nid_t stac9205_pin_nids[12] = {
457 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
458 0x0f, 0x14, 0x16, 0x17, 0x18,
462 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
464 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol)
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 struct sigmatel_spec *spec = codec->spec;
469 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
471 kcontrol->private_value ^= get_amp_nid(kcontrol);
472 kcontrol->private_value |= nid;
474 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
477 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct sigmatel_spec *spec = codec->spec;
482 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
484 kcontrol->private_value ^= get_amp_nid(kcontrol);
485 kcontrol->private_value |= nid;
487 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
490 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
491 struct snd_ctl_elem_info *uinfo)
493 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
494 struct sigmatel_spec *spec = codec->spec;
495 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
498 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
499 struct snd_ctl_elem_value *ucontrol)
501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
502 struct sigmatel_spec *spec = codec->spec;
503 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
505 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
509 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
510 struct snd_ctl_elem_value *ucontrol)
512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
513 struct sigmatel_spec *spec = codec->spec;
514 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
516 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
517 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
520 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
521 struct snd_ctl_elem_info *uinfo)
523 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
524 struct sigmatel_spec *spec = codec->spec;
525 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
528 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_value *ucontrol)
531 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
532 struct sigmatel_spec *spec = codec->spec;
533 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
535 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
539 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
540 struct snd_ctl_elem_value *ucontrol)
542 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
543 struct sigmatel_spec *spec = codec->spec;
544 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
546 return snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
547 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
550 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
553 struct sigmatel_spec *spec = codec->spec;
554 return snd_hda_input_mux_info(spec->input_mux, uinfo);
557 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
560 struct sigmatel_spec *spec = codec->spec;
561 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
563 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
567 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
569 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
570 struct sigmatel_spec *spec = codec->spec;
571 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
573 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
574 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
577 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
578 struct snd_ctl_elem_info *uinfo)
580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
581 struct sigmatel_spec *spec = codec->spec;
582 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
585 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
586 struct snd_ctl_elem_value *ucontrol)
588 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
589 struct sigmatel_spec *spec = codec->spec;
591 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
595 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
596 struct snd_ctl_elem_value *ucontrol)
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 struct sigmatel_spec *spec = codec->spec;
601 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
602 spec->mono_nid, &spec->cur_mmux);
605 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
606 struct snd_ctl_elem_info *uinfo)
608 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
609 struct sigmatel_spec *spec = codec->spec;
610 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
613 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
614 struct snd_ctl_elem_value *ucontrol)
616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
617 struct sigmatel_spec *spec = codec->spec;
619 ucontrol->value.enumerated.item[0] = spec->cur_amux;
623 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
624 struct snd_ctl_elem_value *ucontrol)
626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
627 struct sigmatel_spec *spec = codec->spec;
628 struct snd_kcontrol *ctl =
629 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
633 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
634 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
636 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
640 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
642 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
647 struct sigmatel_spec *spec = codec->spec;
649 ucontrol->value.integer.value[0] = !!(spec->aloopback &
650 (spec->aloopback_mask << idx));
654 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
655 struct snd_ctl_elem_value *ucontrol)
657 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
658 struct sigmatel_spec *spec = codec->spec;
659 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
660 unsigned int dac_mode;
661 unsigned int val, idx_val;
663 idx_val = spec->aloopback_mask << idx;
664 if (ucontrol->value.integer.value[0])
665 val = spec->aloopback | idx_val;
667 val = spec->aloopback & ~idx_val;
668 if (spec->aloopback == val)
671 spec->aloopback = val;
673 /* Only return the bits defined by the shift value of the
674 * first two bytes of the mask
676 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
677 kcontrol->private_value & 0xFFFF, 0x0);
678 dac_mode >>= spec->aloopback_shift;
680 if (spec->aloopback & idx_val) {
681 snd_hda_power_up(codec);
684 snd_hda_power_down(codec);
685 dac_mode &= ~idx_val;
688 snd_hda_codec_write_cache(codec, codec->afg, 0,
689 kcontrol->private_value >> 16, dac_mode);
694 static struct hda_verb stac9200_core_init[] = {
695 /* set dac0mux for dac converter */
696 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
700 static struct hda_verb stac9200_eapd_init[] = {
701 /* set dac0mux for dac converter */
702 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
703 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
707 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
708 /* set master volume and direct control */
709 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
710 /* setup audio connections */
711 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
712 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
713 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
714 /* setup adcs to point to mixer */
715 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
716 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
717 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
718 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
719 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
720 /* setup import muxs */
721 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
722 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
723 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
724 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
728 static struct hda_verb dell_eq_core_init[] = {
729 /* set master volume to max value without distortion
730 * and direct control */
731 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
732 /* setup audio connections */
733 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
734 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
735 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
736 /* setup adcs to point to mixer */
737 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
738 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
739 /* setup import muxs */
740 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
741 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
742 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
743 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
747 static struct hda_verb dell_m6_core_init[] = {
748 /* set master volume to max value without distortion
749 * and direct control */
750 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
751 /* setup audio connections */
752 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
753 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
754 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
755 /* setup adcs to point to mixer */
756 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
757 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
758 /* setup import muxs */
759 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
760 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
761 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
762 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
766 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
767 /* set master volume and direct control */
768 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
769 /* setup audio connections */
770 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
771 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
772 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
773 /* connect hp ports to dac3 */
774 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
775 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
776 /* setup adcs to point to mixer */
777 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
778 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
779 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
780 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
781 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
782 /* setup import muxs */
783 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
784 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
785 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
786 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
790 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
791 /* set master volume and direct control */
792 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
793 /* setup audio connections */
794 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
795 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
796 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
797 /* dac3 is connected to import3 mux */
798 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
799 /* connect hp ports to dac4 */
800 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
801 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
802 /* setup adcs to point to mixer */
803 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
804 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
805 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
806 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
807 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
808 /* setup import muxs */
809 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
810 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
811 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
812 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
816 static struct hda_verb stac92hd83xxx_core_init[] = {
817 /* start of config #1 */
818 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
820 /* start of config #2 */
821 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
822 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
823 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
825 /* power state controls amps */
826 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
829 static struct hda_verb stac92hd71bxx_core_init[] = {
830 /* set master volume and direct control */
831 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
832 /* connect headphone jack to dac1 */
833 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
834 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
835 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
836 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
837 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
838 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
841 #define HD_DISABLE_PORTF 3
842 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
843 /* start of config #1 */
845 /* connect port 0f to audio mixer */
846 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
847 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
848 /* unmute right and left channels for node 0x0f */
849 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
850 /* start of config #2 */
852 /* set master volume and direct control */
853 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
854 /* connect headphone jack to dac1 */
855 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
856 /* connect port 0d to audio mixer */
857 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
858 /* unmute dac0 input in audio mixer */
859 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
860 /* unmute right and left channels for nodes 0x0a, 0xd */
861 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
862 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
866 static struct hda_verb stac925x_core_init[] = {
867 /* set dac0mux for dac converter */
868 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
872 static struct hda_verb stac922x_core_init[] = {
873 /* set master volume and direct control */
874 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
878 static struct hda_verb d965_core_init[] = {
879 /* set master volume and direct control */
880 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
881 /* unmute node 0x1b */
882 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
883 /* select node 0x03 as DAC */
884 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
888 static struct hda_verb stac927x_core_init[] = {
889 /* set master volume and direct control */
890 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
891 /* enable analog pc beep path */
892 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
896 static struct hda_verb stac9205_core_init[] = {
897 /* set master volume and direct control */
898 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
899 /* enable analog pc beep path */
900 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
904 #define STAC_MONO_MUX \
906 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
907 .name = "Mono Mux", \
909 .info = stac92xx_mono_mux_enum_info, \
910 .get = stac92xx_mono_mux_enum_get, \
911 .put = stac92xx_mono_mux_enum_put, \
914 #define STAC_AMP_MUX \
916 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
917 .name = "Amp Selector Capture Switch", \
919 .info = stac92xx_amp_mux_enum_info, \
920 .get = stac92xx_amp_mux_enum_get, \
921 .put = stac92xx_amp_mux_enum_put, \
924 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
929 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
930 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
931 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
932 .info = stac92xx_amp_volume_info, \
933 .get = stac92xx_amp_volume_get, \
934 .put = stac92xx_amp_volume_put, \
935 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
936 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
939 #define STAC_INPUT_SOURCE(cnt) \
941 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
942 .name = "Input Source", \
944 .info = stac92xx_mux_enum_info, \
945 .get = stac92xx_mux_enum_get, \
946 .put = stac92xx_mux_enum_put, \
949 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
952 .name = "Analog Loopback", \
954 .info = stac92xx_aloopback_info, \
955 .get = stac92xx_aloopback_get, \
956 .put = stac92xx_aloopback_put, \
957 .private_value = verb_read | (verb_write << 16), \
960 static struct snd_kcontrol_new stac9200_mixer[] = {
961 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
962 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
963 STAC_INPUT_SOURCE(1),
964 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
965 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
969 #define DELL_M6_MIXER 6
970 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
971 /* start of config #1 */
972 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
973 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
975 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
976 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
978 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
979 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
981 /* start of config #2 */
982 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
983 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
985 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
986 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
988 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
990 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
991 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
993 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
994 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
999 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1000 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1002 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1003 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1005 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1006 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1008 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1009 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1011 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1012 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1014 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1015 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1017 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1018 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1020 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1021 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1025 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1026 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1028 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1029 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1031 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1032 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1034 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1035 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1037 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1038 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1040 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1041 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1043 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1044 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1046 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1047 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1052 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1053 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1054 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1056 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1057 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1059 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1060 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1062 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1063 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1065 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1066 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1068 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1069 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1072 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1073 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1078 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1079 STAC_INPUT_SOURCE(2),
1081 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1082 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1084 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1085 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1086 /* analog pc-beep replaced with digital beep support */
1088 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1089 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1092 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
1093 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
1097 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1098 STAC_INPUT_SOURCE(2),
1099 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1101 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1102 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1104 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1105 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1109 static struct snd_kcontrol_new stac925x_mixer[] = {
1110 STAC_INPUT_SOURCE(1),
1111 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1112 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1116 static struct snd_kcontrol_new stac9205_mixer[] = {
1117 STAC_INPUT_SOURCE(2),
1118 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1120 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1121 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1123 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1124 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1128 /* This needs to be generated dynamically based on sequence */
1129 static struct snd_kcontrol_new stac922x_mixer[] = {
1130 STAC_INPUT_SOURCE(2),
1131 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1132 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1134 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1135 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1140 static struct snd_kcontrol_new stac927x_mixer[] = {
1141 STAC_INPUT_SOURCE(3),
1142 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1144 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1145 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1147 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1148 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1150 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1151 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1155 static struct snd_kcontrol_new stac_dmux_mixer = {
1156 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1157 .name = "Digital Input Source",
1158 /* count set later */
1159 .info = stac92xx_dmux_enum_info,
1160 .get = stac92xx_dmux_enum_get,
1161 .put = stac92xx_dmux_enum_put,
1164 static struct snd_kcontrol_new stac_smux_mixer = {
1165 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1166 .name = "IEC958 Playback Source",
1167 /* count set later */
1168 .info = stac92xx_smux_enum_info,
1169 .get = stac92xx_smux_enum_get,
1170 .put = stac92xx_smux_enum_put,
1173 static const char *slave_vols[] = {
1174 "Front Playback Volume",
1175 "Surround Playback Volume",
1176 "Center Playback Volume",
1177 "LFE Playback Volume",
1178 "Side Playback Volume",
1179 "Headphone Playback Volume",
1180 "Headphone Playback Volume",
1181 "Speaker Playback Volume",
1182 "External Speaker Playback Volume",
1183 "Speaker2 Playback Volume",
1187 static const char *slave_sws[] = {
1188 "Front Playback Switch",
1189 "Surround Playback Switch",
1190 "Center Playback Switch",
1191 "LFE Playback Switch",
1192 "Side Playback Switch",
1193 "Headphone Playback Switch",
1194 "Headphone Playback Switch",
1195 "Speaker Playback Switch",
1196 "External Speaker Playback Switch",
1197 "Speaker2 Playback Switch",
1198 "IEC958 Playback Switch",
1202 static int stac92xx_build_controls(struct hda_codec *codec)
1204 struct sigmatel_spec *spec = codec->spec;
1208 err = snd_hda_add_new_ctls(codec, spec->mixer);
1212 for (i = 0; i < spec->num_mixers; i++) {
1213 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1217 if (spec->num_dmuxes > 0) {
1218 stac_dmux_mixer.count = spec->num_dmuxes;
1219 err = snd_ctl_add(codec->bus->card,
1220 snd_ctl_new1(&stac_dmux_mixer, codec));
1224 if (spec->num_smuxes > 0) {
1225 stac_smux_mixer.count = spec->num_smuxes;
1226 err = snd_ctl_add(codec->bus->card,
1227 snd_ctl_new1(&stac_smux_mixer, codec));
1232 if (spec->multiout.dig_out_nid) {
1233 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1236 err = snd_hda_create_spdif_share_sw(codec,
1240 spec->multiout.share_spdif = 1;
1242 if (spec->dig_in_nid) {
1243 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1248 /* if we have no master control, let's create it */
1249 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1250 unsigned int vmaster_tlv[4];
1251 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1252 HDA_OUTPUT, vmaster_tlv);
1253 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1254 vmaster_tlv, slave_vols);
1258 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1259 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1268 static unsigned int ref9200_pin_configs[8] = {
1269 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1270 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1274 STAC 9200 pin configs for
1279 static unsigned int dell9200_d21_pin_configs[8] = {
1280 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1281 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1285 STAC 9200 pin configs for
1289 static unsigned int dell9200_d22_pin_configs[8] = {
1290 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1291 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1295 STAC 9200 pin configs for
1296 102801C4 (Dell Dimension E310)
1303 static unsigned int dell9200_d23_pin_configs[8] = {
1304 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1305 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1310 STAC 9200-32 pin configs for
1311 102801B5 (Dell Inspiron 630m)
1312 102801D8 (Dell Inspiron 640m)
1314 static unsigned int dell9200_m21_pin_configs[8] = {
1315 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1316 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1320 STAC 9200-32 pin configs for
1321 102801C2 (Dell Latitude D620)
1323 102801CC (Dell Latitude D820)
1327 static unsigned int dell9200_m22_pin_configs[8] = {
1328 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1329 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1333 STAC 9200-32 pin configs for
1334 102801CE (Dell XPS M1710)
1335 102801CF (Dell Precision M90)
1337 static unsigned int dell9200_m23_pin_configs[8] = {
1338 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1339 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1343 STAC 9200-32 pin configs for
1346 102801CB (Dell Latitude 120L)
1349 static unsigned int dell9200_m24_pin_configs[8] = {
1350 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1351 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1355 STAC 9200-32 pin configs for
1356 102801BD (Dell Inspiron E1505n)
1360 static unsigned int dell9200_m25_pin_configs[8] = {
1361 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1362 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1366 STAC 9200-32 pin configs for
1367 102801F5 (Dell Inspiron 1501)
1370 static unsigned int dell9200_m26_pin_configs[8] = {
1371 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1372 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1377 102801CD (Dell Inspiron E1705/9400)
1379 static unsigned int dell9200_m27_pin_configs[8] = {
1380 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1381 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1384 static unsigned int oqo9200_pin_configs[8] = {
1385 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1386 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1390 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1391 [STAC_REF] = ref9200_pin_configs,
1392 [STAC_9200_OQO] = oqo9200_pin_configs,
1393 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1394 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1395 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1396 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1397 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1398 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1399 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1400 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1401 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1402 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1403 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1406 static const char *stac9200_models[STAC_9200_MODELS] = {
1408 [STAC_9200_OQO] = "oqo",
1409 [STAC_9200_DELL_D21] = "dell-d21",
1410 [STAC_9200_DELL_D22] = "dell-d22",
1411 [STAC_9200_DELL_D23] = "dell-d23",
1412 [STAC_9200_DELL_M21] = "dell-m21",
1413 [STAC_9200_DELL_M22] = "dell-m22",
1414 [STAC_9200_DELL_M23] = "dell-m23",
1415 [STAC_9200_DELL_M24] = "dell-m24",
1416 [STAC_9200_DELL_M25] = "dell-m25",
1417 [STAC_9200_DELL_M26] = "dell-m26",
1418 [STAC_9200_DELL_M27] = "dell-m27",
1419 [STAC_9200_GATEWAY] = "gateway",
1420 [STAC_9200_PANASONIC] = "panasonic",
1423 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1424 /* SigmaTel reference board */
1425 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1426 "DFI LanParty", STAC_REF),
1427 /* Dell laptops have BIOS problem */
1428 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1429 "unknown Dell", STAC_9200_DELL_D21),
1430 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1431 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1432 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1433 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1434 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1435 "unknown Dell", STAC_9200_DELL_D22),
1436 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1437 "unknown Dell", STAC_9200_DELL_D22),
1438 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1439 "Dell Latitude D620", STAC_9200_DELL_M22),
1440 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1441 "unknown Dell", STAC_9200_DELL_D23),
1442 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1443 "unknown Dell", STAC_9200_DELL_D23),
1444 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1445 "unknown Dell", STAC_9200_DELL_M22),
1446 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1447 "unknown Dell", STAC_9200_DELL_M24),
1448 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1449 "unknown Dell", STAC_9200_DELL_M24),
1450 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1451 "Dell Latitude 120L", STAC_9200_DELL_M24),
1452 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1453 "Dell Latitude D820", STAC_9200_DELL_M22),
1454 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1455 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1456 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1457 "Dell XPS M1710", STAC_9200_DELL_M23),
1458 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1459 "Dell Precision M90", STAC_9200_DELL_M23),
1460 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1461 "unknown Dell", STAC_9200_DELL_M22),
1462 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1463 "unknown Dell", STAC_9200_DELL_M22),
1464 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1465 "unknown Dell", STAC_9200_DELL_M22),
1466 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1467 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1468 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1469 "unknown Dell", STAC_9200_DELL_D23),
1470 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1471 "unknown Dell", STAC_9200_DELL_D23),
1472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1473 "unknown Dell", STAC_9200_DELL_D21),
1474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1475 "unknown Dell", STAC_9200_DELL_D23),
1476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1477 "unknown Dell", STAC_9200_DELL_D21),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1479 "unknown Dell", STAC_9200_DELL_M25),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1481 "unknown Dell", STAC_9200_DELL_M25),
1482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1483 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1485 "unknown Dell", STAC_9200_DELL_M26),
1487 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1488 /* Gateway machines needs EAPD to be set on resume */
1489 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1490 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1492 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1495 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1499 static unsigned int ref925x_pin_configs[8] = {
1500 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1501 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1504 static unsigned int stac925x_MA6_pin_configs[8] = {
1505 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1506 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1509 static unsigned int stac925x_PA6_pin_configs[8] = {
1510 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1511 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1514 static unsigned int stac925xM2_2_pin_configs[8] = {
1515 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1516 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1519 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1520 [STAC_REF] = ref925x_pin_configs,
1521 [STAC_M2_2] = stac925xM2_2_pin_configs,
1522 [STAC_MA6] = stac925x_MA6_pin_configs,
1523 [STAC_PA6] = stac925x_PA6_pin_configs,
1526 static const char *stac925x_models[STAC_925x_MODELS] = {
1528 [STAC_M2_2] = "m2-2",
1533 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1534 /* SigmaTel reference board */
1535 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1536 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1537 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1538 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1539 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1540 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1541 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1545 static unsigned int ref92hd73xx_pin_configs[13] = {
1546 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1547 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1548 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1552 static unsigned int dell_m6_pin_configs[13] = {
1553 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1554 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1555 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1559 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1560 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1561 [STAC_DELL_M6] = dell_m6_pin_configs,
1564 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1565 [STAC_92HD73XX_REF] = "ref",
1566 [STAC_DELL_M6] = "dell-m6",
1569 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1570 /* SigmaTel reference board */
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1572 "DFI LanParty", STAC_92HD73XX_REF),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1574 "unknown Dell", STAC_DELL_M6),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1576 "unknown Dell", STAC_DELL_M6),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1578 "unknown Dell", STAC_DELL_M6),
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1580 "unknown Dell", STAC_DELL_M6),
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1582 "unknown Dell", STAC_DELL_M6),
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1584 "unknown Dell", STAC_DELL_M6),
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1586 "unknown Dell", STAC_DELL_M6),
1590 static unsigned int ref92hd83xxx_pin_configs[14] = {
1591 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1592 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1593 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1594 0x01451160, 0x98560170,
1597 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1598 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1601 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1602 [STAC_92HD83XXX_REF] = "ref",
1605 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1606 /* SigmaTel reference board */
1607 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1608 "DFI LanParty", STAC_92HD71BXX_REF),
1611 static unsigned int ref92hd71bxx_pin_configs[11] = {
1612 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1613 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
1614 0x90a000f0, 0x01452050, 0x01452050,
1617 static unsigned int dell_m4_1_pin_configs[11] = {
1618 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1619 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1620 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
1623 static unsigned int dell_m4_2_pin_configs[11] = {
1624 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1625 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1626 0x40f000f0, 0x044413b0, 0x044413b0,
1629 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1630 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1631 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1632 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1633 [STAC_HP_M4] = NULL,
1636 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1637 [STAC_92HD71BXX_REF] = "ref",
1638 [STAC_DELL_M4_1] = "dell-m4-1",
1639 [STAC_DELL_M4_2] = "dell-m4-2",
1640 [STAC_HP_M4] = "hp-m4",
1643 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1644 /* SigmaTel reference board */
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1646 "DFI LanParty", STAC_92HD71BXX_REF),
1647 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1648 "unknown Dell", STAC_DELL_M4_1),
1649 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1650 "unknown Dell", STAC_DELL_M4_1),
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1652 "unknown Dell", STAC_DELL_M4_1),
1653 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1654 "unknown Dell", STAC_DELL_M4_1),
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1656 "unknown Dell", STAC_DELL_M4_1),
1657 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1658 "unknown Dell", STAC_DELL_M4_1),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1660 "unknown Dell", STAC_DELL_M4_1),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1662 "unknown Dell", STAC_DELL_M4_2),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1664 "unknown Dell", STAC_DELL_M4_2),
1665 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1666 "unknown Dell", STAC_DELL_M4_2),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1668 "unknown Dell", STAC_DELL_M4_2),
1672 static unsigned int ref922x_pin_configs[10] = {
1673 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1674 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1675 0x40000100, 0x40000100,
1679 STAC 922X pin configs for
1686 static unsigned int dell_922x_d81_pin_configs[10] = {
1687 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1688 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1689 0x01813122, 0x400001f2,
1693 STAC 922X pin configs for
1697 static unsigned int dell_922x_d82_pin_configs[10] = {
1698 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1699 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1700 0x01813122, 0x400001f1,
1704 STAC 922X pin configs for
1707 static unsigned int dell_922x_m81_pin_configs[10] = {
1708 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1709 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1710 0x40C003f1, 0x405003f0,
1714 STAC 9221 A1 pin configs for
1715 102801D7 (Dell XPS M1210)
1717 static unsigned int dell_922x_m82_pin_configs[10] = {
1718 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1719 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1720 0x508003f3, 0x405003f4,
1723 static unsigned int d945gtp3_pin_configs[10] = {
1724 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1725 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1726 0x02a19120, 0x40000100,
1729 static unsigned int d945gtp5_pin_configs[10] = {
1730 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1731 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1732 0x02a19320, 0x40000100,
1735 static unsigned int intel_mac_v1_pin_configs[10] = {
1736 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1737 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1738 0x400000fc, 0x400000fb,
1741 static unsigned int intel_mac_v2_pin_configs[10] = {
1742 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1743 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1744 0x400000fc, 0x400000fb,
1747 static unsigned int intel_mac_v3_pin_configs[10] = {
1748 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1749 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1750 0x400000fc, 0x400000fb,
1753 static unsigned int intel_mac_v4_pin_configs[10] = {
1754 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1755 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1756 0x400000fc, 0x400000fb,
1759 static unsigned int intel_mac_v5_pin_configs[10] = {
1760 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1761 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1762 0x400000fc, 0x400000fb,
1765 static unsigned int ecs202_pin_configs[10] = {
1766 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1767 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1768 0x9037012e, 0x40e000f2,
1771 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1772 [STAC_D945_REF] = ref922x_pin_configs,
1773 [STAC_D945GTP3] = d945gtp3_pin_configs,
1774 [STAC_D945GTP5] = d945gtp5_pin_configs,
1775 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1776 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1777 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1778 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1779 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1780 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1781 /* for backward compatibility */
1782 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1783 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1784 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1785 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1786 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1787 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1788 [STAC_ECS_202] = ecs202_pin_configs,
1789 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1790 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1791 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1792 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1795 static const char *stac922x_models[STAC_922X_MODELS] = {
1796 [STAC_D945_REF] = "ref",
1797 [STAC_D945GTP5] = "5stack",
1798 [STAC_D945GTP3] = "3stack",
1799 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1800 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1801 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1802 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1803 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1804 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1805 /* for backward compatibility */
1806 [STAC_MACMINI] = "macmini",
1807 [STAC_MACBOOK] = "macbook",
1808 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1809 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1810 [STAC_IMAC_INTEL] = "imac-intel",
1811 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1812 [STAC_ECS_202] = "ecs202",
1813 [STAC_922X_DELL_D81] = "dell-d81",
1814 [STAC_922X_DELL_D82] = "dell-d82",
1815 [STAC_922X_DELL_M81] = "dell-m81",
1816 [STAC_922X_DELL_M82] = "dell-m82",
1819 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1820 /* SigmaTel reference board */
1821 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1822 "DFI LanParty", STAC_D945_REF),
1823 /* Intel 945G based systems */
1824 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1825 "Intel D945G", STAC_D945GTP3),
1826 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1827 "Intel D945G", STAC_D945GTP3),
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1829 "Intel D945G", STAC_D945GTP3),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1831 "Intel D945G", STAC_D945GTP3),
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1833 "Intel D945G", STAC_D945GTP3),
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1835 "Intel D945G", STAC_D945GTP3),
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1837 "Intel D945G", STAC_D945GTP3),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1839 "Intel D945G", STAC_D945GTP3),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1841 "Intel D945G", STAC_D945GTP3),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1843 "Intel D945G", STAC_D945GTP3),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1845 "Intel D945G", STAC_D945GTP3),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1847 "Intel D945G", STAC_D945GTP3),
1848 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1849 "Intel D945G", STAC_D945GTP3),
1850 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1851 "Intel D945G", STAC_D945GTP3),
1852 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1853 "Intel D945G", STAC_D945GTP3),
1854 /* Intel D945G 5-stack systems */
1855 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1856 "Intel D945G", STAC_D945GTP5),
1857 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1858 "Intel D945G", STAC_D945GTP5),
1859 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1860 "Intel D945G", STAC_D945GTP5),
1861 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1862 "Intel D945G", STAC_D945GTP5),
1863 /* Intel 945P based systems */
1864 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1865 "Intel D945P", STAC_D945GTP3),
1866 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1867 "Intel D945P", STAC_D945GTP3),
1868 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1869 "Intel D945P", STAC_D945GTP3),
1870 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1871 "Intel D945P", STAC_D945GTP3),
1872 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1873 "Intel D945P", STAC_D945GTP3),
1874 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1875 "Intel D945P", STAC_D945GTP5),
1877 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1878 SND_PCI_QUIRK(0x8384, 0x7680,
1879 "Mac", STAC_INTEL_MAC_AUTO),
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1882 "unknown Dell", STAC_922X_DELL_D81),
1883 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1884 "unknown Dell", STAC_922X_DELL_D81),
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1886 "unknown Dell", STAC_922X_DELL_D81),
1887 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1888 "unknown Dell", STAC_922X_DELL_D82),
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1890 "unknown Dell", STAC_922X_DELL_M81),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1892 "unknown Dell", STAC_922X_DELL_D82),
1893 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1894 "unknown Dell", STAC_922X_DELL_D81),
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1896 "unknown Dell", STAC_922X_DELL_D81),
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1898 "Dell XPS M1210", STAC_922X_DELL_M82),
1899 /* ECS/PC Chips boards */
1900 SND_PCI_QUIRK(0x1019, 0x2144,
1901 "ECS/PC chips", STAC_ECS_202),
1902 SND_PCI_QUIRK(0x1019, 0x2608,
1903 "ECS/PC chips", STAC_ECS_202),
1904 SND_PCI_QUIRK(0x1019, 0x2633,
1905 "ECS/PC chips P17G/1333", STAC_ECS_202),
1906 SND_PCI_QUIRK(0x1019, 0x2811,
1907 "ECS/PC chips", STAC_ECS_202),
1908 SND_PCI_QUIRK(0x1019, 0x2812,
1909 "ECS/PC chips", STAC_ECS_202),
1910 SND_PCI_QUIRK(0x1019, 0x2813,
1911 "ECS/PC chips", STAC_ECS_202),
1912 SND_PCI_QUIRK(0x1019, 0x2814,
1913 "ECS/PC chips", STAC_ECS_202),
1914 SND_PCI_QUIRK(0x1019, 0x2815,
1915 "ECS/PC chips", STAC_ECS_202),
1916 SND_PCI_QUIRK(0x1019, 0x2816,
1917 "ECS/PC chips", STAC_ECS_202),
1918 SND_PCI_QUIRK(0x1019, 0x2817,
1919 "ECS/PC chips", STAC_ECS_202),
1920 SND_PCI_QUIRK(0x1019, 0x2818,
1921 "ECS/PC chips", STAC_ECS_202),
1922 SND_PCI_QUIRK(0x1019, 0x2819,
1923 "ECS/PC chips", STAC_ECS_202),
1924 SND_PCI_QUIRK(0x1019, 0x2820,
1925 "ECS/PC chips", STAC_ECS_202),
1929 static unsigned int ref927x_pin_configs[14] = {
1930 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1931 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1932 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1933 0x01c42190, 0x40000100,
1936 static unsigned int d965_3st_pin_configs[14] = {
1937 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1938 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1939 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1940 0x40000100, 0x40000100
1943 static unsigned int d965_5st_pin_configs[14] = {
1944 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1945 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1946 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1947 0x40000100, 0x40000100
1950 static unsigned int dell_3st_pin_configs[14] = {
1951 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1952 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1953 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1954 0x40c003fc, 0x40000100
1957 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1958 [STAC_D965_REF] = ref927x_pin_configs,
1959 [STAC_D965_3ST] = d965_3st_pin_configs,
1960 [STAC_D965_5ST] = d965_5st_pin_configs,
1961 [STAC_DELL_3ST] = dell_3st_pin_configs,
1962 [STAC_DELL_BIOS] = NULL,
1965 static const char *stac927x_models[STAC_927X_MODELS] = {
1966 [STAC_D965_REF] = "ref",
1967 [STAC_D965_3ST] = "3stack",
1968 [STAC_D965_5ST] = "5stack",
1969 [STAC_DELL_3ST] = "dell-3stack",
1970 [STAC_DELL_BIOS] = "dell-bios",
1973 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1974 /* SigmaTel reference board */
1975 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1976 "DFI LanParty", STAC_D965_REF),
1977 /* Intel 946 based systems */
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1979 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
1980 /* 965 based 3 stack systems */
1981 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1982 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1983 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1984 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1985 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1987 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1989 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1991 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1993 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1995 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
1997 /* Dell 3 stack systems */
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
1999 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2001 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2002 /* Dell 3 stack systems with verb table in BIOS */
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2007 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2011 /* 965 based 5 stack systems */
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2013 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
2024 static unsigned int ref9205_pin_configs[12] = {
2025 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2026 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2027 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2031 STAC 9205 pin configs for
2038 10280228 (Dell Vostro 1500)
2040 static unsigned int dell_9205_m42_pin_configs[12] = {
2041 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2042 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2043 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2047 STAC 9205 pin configs for
2051 102801FF (Dell Precision M4300)
2056 static unsigned int dell_9205_m43_pin_configs[12] = {
2057 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2058 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2059 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2062 static unsigned int dell_9205_m44_pin_configs[12] = {
2063 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2064 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2065 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2068 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2069 [STAC_9205_REF] = ref9205_pin_configs,
2070 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2071 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2072 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2075 static const char *stac9205_models[STAC_9205_MODELS] = {
2076 [STAC_9205_REF] = "ref",
2077 [STAC_9205_DELL_M42] = "dell-m42",
2078 [STAC_9205_DELL_M43] = "dell-m43",
2079 [STAC_9205_DELL_M44] = "dell-m44",
2082 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2083 /* SigmaTel reference board */
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2085 "DFI LanParty", STAC_9205_REF),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2087 "unknown Dell", STAC_9205_DELL_M42),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2089 "unknown Dell", STAC_9205_DELL_M42),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2091 "Dell Precision", STAC_9205_DELL_M43),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2093 "Dell Precision", STAC_9205_DELL_M43),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2095 "Dell Precision", STAC_9205_DELL_M43),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2097 "unknown Dell", STAC_9205_DELL_M42),
2098 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2099 "unknown Dell", STAC_9205_DELL_M42),
2100 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2101 "Dell Precision", STAC_9205_DELL_M43),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2103 "Dell Precision M4300", STAC_9205_DELL_M43),
2104 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2105 "unknown Dell", STAC_9205_DELL_M42),
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2107 "Dell Precision", STAC_9205_DELL_M43),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2109 "Dell Precision", STAC_9205_DELL_M43),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2111 "Dell Precision", STAC_9205_DELL_M43),
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2113 "Dell Inspiron", STAC_9205_DELL_M44),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2115 "Dell Vostro 1500", STAC_9205_DELL_M42),
2119 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2122 struct sigmatel_spec *spec = codec->spec;
2124 if (! spec->bios_pin_configs) {
2125 spec->bios_pin_configs = kcalloc(spec->num_pins,
2126 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2127 if (! spec->bios_pin_configs)
2131 for (i = 0; i < spec->num_pins; i++) {
2132 hda_nid_t nid = spec->pin_nids[i];
2133 unsigned int pin_cfg;
2135 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2136 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2137 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2139 spec->bios_pin_configs[i] = pin_cfg;
2145 static void stac92xx_set_config_reg(struct hda_codec *codec,
2146 hda_nid_t pin_nid, unsigned int pin_config)
2149 snd_hda_codec_write(codec, pin_nid, 0,
2150 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2151 pin_config & 0x000000ff);
2152 snd_hda_codec_write(codec, pin_nid, 0,
2153 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2154 (pin_config & 0x0000ff00) >> 8);
2155 snd_hda_codec_write(codec, pin_nid, 0,
2156 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2157 (pin_config & 0x00ff0000) >> 16);
2158 snd_hda_codec_write(codec, pin_nid, 0,
2159 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2161 i = snd_hda_codec_read(codec, pin_nid, 0,
2162 AC_VERB_GET_CONFIG_DEFAULT,
2164 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2168 static void stac92xx_set_config_regs(struct hda_codec *codec)
2171 struct sigmatel_spec *spec = codec->spec;
2173 if (!spec->pin_configs)
2176 for (i = 0; i < spec->num_pins; i++)
2177 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2178 spec->pin_configs[i]);
2182 * Analog playback callbacks
2184 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2185 struct hda_codec *codec,
2186 struct snd_pcm_substream *substream)
2188 struct sigmatel_spec *spec = codec->spec;
2189 if (spec->stream_delay)
2190 msleep(spec->stream_delay);
2191 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2195 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2196 struct hda_codec *codec,
2197 unsigned int stream_tag,
2198 unsigned int format,
2199 struct snd_pcm_substream *substream)
2201 struct sigmatel_spec *spec = codec->spec;
2202 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2205 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2206 struct hda_codec *codec,
2207 struct snd_pcm_substream *substream)
2209 struct sigmatel_spec *spec = codec->spec;
2210 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2214 * Digital playback callbacks
2216 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2217 struct hda_codec *codec,
2218 struct snd_pcm_substream *substream)
2220 struct sigmatel_spec *spec = codec->spec;
2221 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2224 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2225 struct hda_codec *codec,
2226 struct snd_pcm_substream *substream)
2228 struct sigmatel_spec *spec = codec->spec;
2229 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2232 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2233 struct hda_codec *codec,
2234 unsigned int stream_tag,
2235 unsigned int format,
2236 struct snd_pcm_substream *substream)
2238 struct sigmatel_spec *spec = codec->spec;
2239 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2240 stream_tag, format, substream);
2245 * Analog capture callbacks
2247 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2248 struct hda_codec *codec,
2249 unsigned int stream_tag,
2250 unsigned int format,
2251 struct snd_pcm_substream *substream)
2253 struct sigmatel_spec *spec = codec->spec;
2254 hda_nid_t nid = spec->adc_nids[substream->number];
2256 if (spec->powerdown_adcs) {
2258 snd_hda_codec_write_cache(codec, nid, 0,
2259 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2261 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2265 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2266 struct hda_codec *codec,
2267 struct snd_pcm_substream *substream)
2269 struct sigmatel_spec *spec = codec->spec;
2270 hda_nid_t nid = spec->adc_nids[substream->number];
2272 snd_hda_codec_cleanup_stream(codec, nid);
2273 if (spec->powerdown_adcs)
2274 snd_hda_codec_write_cache(codec, nid, 0,
2275 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2279 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2283 /* NID is set in stac92xx_build_pcms */
2285 .open = stac92xx_dig_playback_pcm_open,
2286 .close = stac92xx_dig_playback_pcm_close,
2287 .prepare = stac92xx_dig_playback_pcm_prepare
2291 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2295 /* NID is set in stac92xx_build_pcms */
2298 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2302 .nid = 0x02, /* NID to query formats and rates */
2304 .open = stac92xx_playback_pcm_open,
2305 .prepare = stac92xx_playback_pcm_prepare,
2306 .cleanup = stac92xx_playback_pcm_cleanup
2310 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2314 .nid = 0x06, /* NID to query formats and rates */
2316 .open = stac92xx_playback_pcm_open,
2317 .prepare = stac92xx_playback_pcm_prepare,
2318 .cleanup = stac92xx_playback_pcm_cleanup
2322 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2325 /* NID + .substreams is set in stac92xx_build_pcms */
2327 .prepare = stac92xx_capture_pcm_prepare,
2328 .cleanup = stac92xx_capture_pcm_cleanup
2332 static int stac92xx_build_pcms(struct hda_codec *codec)
2334 struct sigmatel_spec *spec = codec->spec;
2335 struct hda_pcm *info = spec->pcm_rec;
2337 codec->num_pcms = 1;
2338 codec->pcm_info = info;
2340 info->name = "STAC92xx Analog";
2341 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2342 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2343 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2344 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2346 if (spec->alt_switch) {
2349 info->name = "STAC92xx Analog Alt";
2350 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2353 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2356 info->name = "STAC92xx Digital";
2357 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2358 if (spec->multiout.dig_out_nid) {
2359 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2360 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2362 if (spec->dig_in_nid) {
2363 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2364 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2371 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2373 unsigned int pincap = snd_hda_param_read(codec, nid,
2375 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2376 if (pincap & AC_PINCAP_VREF_100)
2377 return AC_PINCTL_VREF_100;
2378 if (pincap & AC_PINCAP_VREF_80)
2379 return AC_PINCTL_VREF_80;
2380 if (pincap & AC_PINCAP_VREF_50)
2381 return AC_PINCTL_VREF_50;
2382 if (pincap & AC_PINCAP_VREF_GRD)
2383 return AC_PINCTL_VREF_GRD;
2387 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2390 snd_hda_codec_write_cache(codec, nid, 0,
2391 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2394 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2396 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2397 struct snd_ctl_elem_value *ucontrol)
2399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2400 struct sigmatel_spec *spec = codec->spec;
2402 ucontrol->value.integer.value[0] = spec->hp_switch;
2406 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2407 struct snd_ctl_elem_value *ucontrol)
2409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2410 struct sigmatel_spec *spec = codec->spec;
2412 spec->hp_switch = ucontrol->value.integer.value[0];
2414 /* check to be sure that the ports are upto date with
2417 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2422 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2424 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2426 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2427 struct sigmatel_spec *spec = codec->spec;
2428 int io_idx = kcontrol-> private_value & 0xff;
2430 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2434 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2436 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2437 struct sigmatel_spec *spec = codec->spec;
2438 hda_nid_t nid = kcontrol->private_value >> 8;
2439 int io_idx = kcontrol-> private_value & 0xff;
2440 unsigned short val = !!ucontrol->value.integer.value[0];
2442 spec->io_switch[io_idx] = val;
2445 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2447 unsigned int pinctl = AC_PINCTL_IN_EN;
2448 if (io_idx) /* set VREF for mic */
2449 pinctl |= stac92xx_get_vref(codec, nid);
2450 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2453 /* check the auto-mute again: we need to mute/unmute the speaker
2454 * appropriately according to the pin direction
2456 if (spec->hp_detect)
2457 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2462 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2464 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2465 struct snd_ctl_elem_value *ucontrol)
2467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2468 struct sigmatel_spec *spec = codec->spec;
2470 ucontrol->value.integer.value[0] = spec->clfe_swap;
2474 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2475 struct snd_ctl_elem_value *ucontrol)
2477 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2478 struct sigmatel_spec *spec = codec->spec;
2479 hda_nid_t nid = kcontrol->private_value & 0xff;
2480 unsigned int val = !!ucontrol->value.integer.value[0];
2482 if (spec->clfe_swap == val)
2485 spec->clfe_swap = val;
2487 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2488 spec->clfe_swap ? 0x4 : 0x0);
2493 #define STAC_CODEC_HP_SWITCH(xname) \
2494 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2497 .info = stac92xx_hp_switch_info, \
2498 .get = stac92xx_hp_switch_get, \
2499 .put = stac92xx_hp_switch_put, \
2502 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2503 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2506 .info = stac92xx_io_switch_info, \
2507 .get = stac92xx_io_switch_get, \
2508 .put = stac92xx_io_switch_put, \
2509 .private_value = xpval, \
2512 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2513 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2516 .info = stac92xx_clfe_switch_info, \
2517 .get = stac92xx_clfe_switch_get, \
2518 .put = stac92xx_clfe_switch_put, \
2519 .private_value = xpval, \
2523 STAC_CTL_WIDGET_VOL,
2524 STAC_CTL_WIDGET_MUTE,
2525 STAC_CTL_WIDGET_MONO_MUX,
2526 STAC_CTL_WIDGET_AMP_MUX,
2527 STAC_CTL_WIDGET_AMP_VOL,
2528 STAC_CTL_WIDGET_HP_SWITCH,
2529 STAC_CTL_WIDGET_IO_SWITCH,
2530 STAC_CTL_WIDGET_CLFE_SWITCH
2533 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2534 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2535 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2538 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2539 STAC_CODEC_HP_SWITCH(NULL),
2540 STAC_CODEC_IO_SWITCH(NULL, 0),
2541 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2544 /* add dynamic controls */
2545 static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2546 int idx, const char *name, unsigned long val)
2548 struct snd_kcontrol_new *knew;
2550 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2551 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2553 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2556 if (spec->kctl_alloc) {
2557 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2558 kfree(spec->kctl_alloc);
2560 spec->kctl_alloc = knew;
2561 spec->num_kctl_alloc = num;
2564 knew = &spec->kctl_alloc[spec->num_kctl_used];
2565 *knew = stac92xx_control_templates[type];
2567 knew->name = kstrdup(name, GFP_KERNEL);
2570 knew->private_value = val;
2571 spec->num_kctl_used++;
2576 /* add dynamic controls */
2577 static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2578 const char *name, unsigned long val)
2580 return stac92xx_add_control_idx(spec, type, 0, name, val);
2583 /* flag inputs as additional dynamic lineouts */
2584 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2586 struct sigmatel_spec *spec = codec->spec;
2587 unsigned int wcaps, wtype;
2588 int i, num_dacs = 0;
2590 /* use the wcaps cache to count all DACs available for line-outs */
2591 for (i = 0; i < codec->num_nodes; i++) {
2592 wcaps = codec->wcaps[i];
2593 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2595 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2599 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2601 switch (cfg->line_outs) {
2603 /* add line-in as side */
2604 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2605 cfg->line_out_pins[cfg->line_outs] =
2606 cfg->input_pins[AUTO_PIN_LINE];
2607 spec->line_switch = 1;
2612 /* add line-in as clfe and mic as side */
2613 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2614 cfg->line_out_pins[cfg->line_outs] =
2615 cfg->input_pins[AUTO_PIN_LINE];
2616 spec->line_switch = 1;
2619 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2620 cfg->line_out_pins[cfg->line_outs] =
2621 cfg->input_pins[AUTO_PIN_MIC];
2622 spec->mic_switch = 1;
2627 /* add line-in as surr and mic as clfe */
2628 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2629 cfg->line_out_pins[cfg->line_outs] =
2630 cfg->input_pins[AUTO_PIN_LINE];
2631 spec->line_switch = 1;
2634 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2635 cfg->line_out_pins[cfg->line_outs] =
2636 cfg->input_pins[AUTO_PIN_MIC];
2637 spec->mic_switch = 1;
2647 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2651 for (i = 0; i < spec->multiout.num_dacs; i++) {
2652 if (spec->multiout.dac_nids[i] == nid)
2660 * Fill in the dac_nids table from the parsed pin configuration
2661 * This function only works when every pin in line_out_pins[]
2662 * contains atleast one DAC in its connection list. Some 92xx
2663 * codecs are not connected directly to a DAC, such as the 9200
2664 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2666 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2667 struct auto_pin_cfg *cfg)
2669 struct sigmatel_spec *spec = codec->spec;
2670 int i, j, conn_len = 0;
2671 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2672 unsigned int wcaps, wtype;
2674 for (i = 0; i < cfg->line_outs; i++) {
2675 nid = cfg->line_out_pins[i];
2676 conn_len = snd_hda_get_connections(codec, nid, conn,
2677 HDA_MAX_CONNECTIONS);
2678 for (j = 0; j < conn_len; j++) {
2679 wcaps = snd_hda_param_read(codec, conn[j],
2680 AC_PAR_AUDIO_WIDGET_CAP);
2681 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2682 if (wtype != AC_WID_AUD_OUT ||
2683 (wcaps & AC_WCAP_DIGITAL))
2685 /* conn[j] is a DAC routed to this line-out */
2686 if (!is_in_dac_nids(spec, conn[j]))
2690 if (j == conn_len) {
2691 if (spec->multiout.num_dacs > 0) {
2692 /* we have already working output pins,
2693 * so let's drop the broken ones again
2695 cfg->line_outs = spec->multiout.num_dacs;
2698 /* error out, no available DAC found */
2700 "%s: No available DAC for pin 0x%x\n",
2705 spec->multiout.dac_nids[i] = conn[j];
2706 spec->multiout.num_dacs++;
2708 /* select this DAC in the pin's input mux */
2709 snd_hda_codec_write_cache(codec, nid, 0,
2710 AC_VERB_SET_CONNECT_SEL, j);
2715 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2716 spec->multiout.num_dacs,
2717 spec->multiout.dac_nids[0],
2718 spec->multiout.dac_nids[1],
2719 spec->multiout.dac_nids[2],
2720 spec->multiout.dac_nids[3],
2721 spec->multiout.dac_nids[4]);
2725 /* create volume control/switch for the given prefx type */
2726 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2731 sprintf(name, "%s Playback Volume", pfx);
2732 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2733 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2736 sprintf(name, "%s Playback Switch", pfx);
2737 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2738 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2744 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2746 if (!spec->multiout.hp_nid)
2747 spec->multiout.hp_nid = nid;
2748 else if (spec->multiout.num_dacs > 4) {
2749 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2752 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2753 spec->multiout.num_dacs++;
2758 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2760 if (is_in_dac_nids(spec, nid))
2762 if (spec->multiout.hp_nid == nid)
2767 /* add playback controls from the parsed DAC table */
2768 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2769 const struct auto_pin_cfg *cfg)
2771 static const char *chname[4] = {
2772 "Front", "Surround", NULL /*CLFE*/, "Side"
2777 struct sigmatel_spec *spec = codec->spec;
2778 unsigned int wid_caps, pincap;
2781 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2782 if (!spec->multiout.dac_nids[i])
2785 nid = spec->multiout.dac_nids[i];
2789 err = create_controls(spec, "Center", nid, 1);
2792 err = create_controls(spec, "LFE", nid, 2);
2796 wid_caps = get_wcaps(codec, nid);
2798 if (wid_caps & AC_WCAP_LR_SWAP) {
2799 err = stac92xx_add_control(spec,
2800 STAC_CTL_WIDGET_CLFE_SWITCH,
2801 "Swap Center/LFE Playback Switch", nid);
2808 err = create_controls(spec, chname[i], nid, 3);
2814 if (cfg->hp_outs > 1) {
2815 err = stac92xx_add_control(spec,
2816 STAC_CTL_WIDGET_HP_SWITCH,
2817 "Headphone as Line Out Switch", 0);
2822 if (spec->line_switch) {
2823 nid = cfg->input_pins[AUTO_PIN_LINE];
2824 pincap = snd_hda_param_read(codec, nid,
2826 if (pincap & AC_PINCAP_OUT) {
2827 err = stac92xx_add_control(spec,
2828 STAC_CTL_WIDGET_IO_SWITCH,
2829 "Line In as Output Switch", nid << 8);
2835 if (spec->mic_switch) {
2836 unsigned int def_conf;
2837 unsigned int mic_pin = AUTO_PIN_MIC;
2839 nid = cfg->input_pins[mic_pin];
2840 def_conf = snd_hda_codec_read(codec, nid, 0,
2841 AC_VERB_GET_CONFIG_DEFAULT, 0);
2842 /* some laptops have an internal analog microphone
2843 * which can't be used as a output */
2844 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2845 pincap = snd_hda_param_read(codec, nid,
2847 if (pincap & AC_PINCAP_OUT) {
2848 err = stac92xx_add_control(spec,
2849 STAC_CTL_WIDGET_IO_SWITCH,
2850 "Mic as Output Switch", (nid << 8) | 1);
2851 nid = snd_hda_codec_read(codec, nid, 0,
2852 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2853 if (!check_in_dac_nids(spec, nid))
2854 add_spec_dacs(spec, nid);
2858 } else if (mic_pin == AUTO_PIN_MIC) {
2859 mic_pin = AUTO_PIN_FRONT_MIC;
2867 /* add playback controls for Speaker and HP outputs */
2868 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2869 struct auto_pin_cfg *cfg)
2871 struct sigmatel_spec *spec = codec->spec;
2873 int i, old_num_dacs, err;
2875 old_num_dacs = spec->multiout.num_dacs;
2876 for (i = 0; i < cfg->hp_outs; i++) {
2877 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2878 if (wid_caps & AC_WCAP_UNSOL_CAP)
2879 spec->hp_detect = 1;
2880 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2881 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2882 if (check_in_dac_nids(spec, nid))
2886 add_spec_dacs(spec, nid);
2888 for (i = 0; i < cfg->speaker_outs; i++) {
2889 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2890 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2891 if (check_in_dac_nids(spec, nid))
2895 add_spec_dacs(spec, nid);
2897 for (i = 0; i < cfg->line_outs; i++) {
2898 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2899 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2900 if (check_in_dac_nids(spec, nid))
2904 add_spec_dacs(spec, nid);
2906 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2907 static const char *pfxs[] = {
2908 "Speaker", "External Speaker", "Speaker2",
2910 err = create_controls(spec, pfxs[i - old_num_dacs],
2911 spec->multiout.dac_nids[i], 3);
2915 if (spec->multiout.hp_nid) {
2916 err = create_controls(spec, "Headphone",
2917 spec->multiout.hp_nid, 3);
2925 /* labels for mono mux outputs */
2926 static const char *stac92xx_mono_labels[4] = {
2927 "DAC0", "DAC1", "Mixer", "DAC2"
2930 /* create mono mux for mono out on capable codecs */
2931 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2933 struct sigmatel_spec *spec = codec->spec;
2934 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2936 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2938 num_cons = snd_hda_get_connections(codec,
2941 HDA_MAX_NUM_INPUTS);
2942 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2945 for (i = 0; i < num_cons; i++) {
2946 mono_mux->items[mono_mux->num_items].label =
2947 stac92xx_mono_labels[i];
2948 mono_mux->items[mono_mux->num_items].index = i;
2949 mono_mux->num_items++;
2952 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2953 "Mono Mux", spec->mono_nid);
2956 /* labels for amp mux outputs */
2957 static const char *stac92xx_amp_labels[3] = {
2958 "Front Microphone", "Microphone", "Line In"
2961 /* create amp out controls mux on capable codecs */
2962 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
2964 struct sigmatel_spec *spec = codec->spec;
2965 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
2968 for (i = 0; i < spec->num_amps; i++) {
2969 amp_mux->items[amp_mux->num_items].label =
2970 stac92xx_amp_labels[i];
2971 amp_mux->items[amp_mux->num_items].index = i;
2972 amp_mux->num_items++;
2975 if (spec->num_amps > 1) {
2976 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
2977 "Amp Selector Capture Switch", 0);
2981 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
2982 "Amp Capture Volume",
2983 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
2987 /* create PC beep volume controls */
2988 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
2991 struct sigmatel_spec *spec = codec->spec;
2992 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2995 /* check for mute support for the the amp */
2996 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
2997 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2998 "PC Beep Playback Switch",
2999 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3004 /* check to see if there is volume support for the amp */
3005 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3006 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3007 "PC Beep Playback Volume",
3008 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3015 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3017 struct sigmatel_spec *spec = codec->spec;
3018 int wcaps, nid, i, err = 0;
3020 for (i = 0; i < spec->num_muxes; i++) {
3021 nid = spec->mux_nids[i];
3022 wcaps = get_wcaps(codec, nid);
3024 if (wcaps & AC_WCAP_OUT_AMP) {
3025 err = stac92xx_add_control_idx(spec,
3026 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3027 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3035 static const char *stac92xx_spdif_labels[3] = {
3036 "Digital Playback", "Analog Mux 1", "Analog Mux 2"
3039 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3041 struct sigmatel_spec *spec = codec->spec;
3042 struct hda_input_mux *spdif_mux = &spec->private_smux;
3044 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_spdif_labels)];
3046 num_cons = snd_hda_get_connections(codec,
3049 HDA_MAX_NUM_INPUTS);
3050 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_spdif_labels))
3053 for (i = 0; i < num_cons; i++) {
3054 spdif_mux->items[spdif_mux->num_items].label =
3055 stac92xx_spdif_labels[i];
3056 spdif_mux->items[spdif_mux->num_items].index = i;
3057 spdif_mux->num_items++;
3063 /* labels for dmic mux inputs */
3064 static const char *stac92xx_dmic_labels[5] = {
3065 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3066 "Digital Mic 3", "Digital Mic 4"
3069 /* create playback/capture controls for input pins on dmic capable codecs */
3070 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3071 const struct auto_pin_cfg *cfg)
3073 struct sigmatel_spec *spec = codec->spec;
3074 struct hda_input_mux *dimux = &spec->private_dimux;
3075 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3079 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3080 dimux->items[dimux->num_items].index = 0;
3083 for (i = 0; i < spec->num_dmics; i++) {
3088 unsigned int def_conf;
3090 def_conf = snd_hda_codec_read(codec,
3093 AC_VERB_GET_CONFIG_DEFAULT,
3095 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3098 nid = spec->dmic_nids[i];
3099 num_cons = snd_hda_get_connections(codec,
3102 HDA_MAX_NUM_INPUTS);
3103 for (j = 0; j < num_cons; j++)
3104 if (con_lst[j] == nid) {
3110 wcaps = get_wcaps(codec, nid) &
3111 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3114 sprintf(name, "%s Capture Volume",
3115 stac92xx_dmic_labels[dimux->num_items]);
3117 err = stac92xx_add_control(spec,
3118 STAC_CTL_WIDGET_VOL,
3120 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3121 (wcaps & AC_WCAP_OUT_AMP) ?
3122 HDA_OUTPUT : HDA_INPUT));
3127 dimux->items[dimux->num_items].label =
3128 stac92xx_dmic_labels[dimux->num_items];
3129 dimux->items[dimux->num_items].index = index;
3136 /* create playback/capture controls for input pins */
3137 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3139 struct sigmatel_spec *spec = codec->spec;
3140 struct hda_input_mux *imux = &spec->private_imux;
3141 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3144 for (i = 0; i < AUTO_PIN_LAST; i++) {
3147 if (!cfg->input_pins[i])
3150 for (j = 0; j < spec->num_muxes; j++) {
3152 num_cons = snd_hda_get_connections(codec,
3155 HDA_MAX_NUM_INPUTS);
3156 for (k = 0; k < num_cons; k++)
3157 if (con_lst[k] == cfg->input_pins[i]) {
3164 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3165 imux->items[imux->num_items].index = index;
3169 if (imux->num_items) {
3171 * Set the current input for the muxes.
3172 * The STAC9221 has two input muxes with identical source
3173 * NID lists. Hopefully this won't get confused.
3175 for (i = 0; i < spec->num_muxes; i++) {
3176 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3177 AC_VERB_SET_CONNECT_SEL,
3178 imux->items[0].index);
3185 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3187 struct sigmatel_spec *spec = codec->spec;
3190 for (i = 0; i < spec->autocfg.line_outs; i++) {
3191 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3192 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3196 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3198 struct sigmatel_spec *spec = codec->spec;
3201 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3203 pin = spec->autocfg.hp_pins[i];
3204 if (pin) /* connect to front */
3205 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3207 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3209 pin = spec->autocfg.speaker_pins[i];
3210 if (pin) /* connect to front */
3211 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3215 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3217 struct sigmatel_spec *spec = codec->spec;
3219 int hp_speaker_swap = 0;
3221 if ((err = snd_hda_parse_pin_def_config(codec,
3223 spec->dmic_nids)) < 0)
3225 if (! spec->autocfg.line_outs)
3226 return 0; /* can't find valid pin config */
3228 /* If we have no real line-out pin and multiple hp-outs, HPs should
3229 * be set up as multi-channel outputs.
3231 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3232 spec->autocfg.hp_outs > 1) {
3233 /* Copy hp_outs to line_outs, backup line_outs in
3234 * speaker_outs so that the following routines can handle
3235 * HP pins as primary outputs.
3237 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3238 sizeof(spec->autocfg.line_out_pins));
3239 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3240 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3241 sizeof(spec->autocfg.hp_pins));
3242 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3243 hp_speaker_swap = 1;
3245 if (spec->autocfg.mono_out_pin) {
3246 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3247 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3248 u32 caps = query_amp_caps(codec,
3249 spec->autocfg.mono_out_pin, dir);
3250 hda_nid_t conn_list[1];
3252 /* get the mixer node and then the mono mux if it exists */
3253 if (snd_hda_get_connections(codec,
3254 spec->autocfg.mono_out_pin, conn_list, 1) &&
3255 snd_hda_get_connections(codec, conn_list[0],
3258 int wcaps = get_wcaps(codec, conn_list[0]);
3259 int wid_type = (wcaps & AC_WCAP_TYPE)
3260 >> AC_WCAP_TYPE_SHIFT;
3261 /* LR swap check, some stac925x have a mux that
3262 * changes the DACs output path instead of the
3265 if (wid_type == AC_WID_AUD_SEL &&
3266 !(wcaps & AC_WCAP_LR_SWAP))
3267 spec->mono_nid = conn_list[0];
3270 hda_nid_t nid = spec->autocfg.mono_out_pin;
3272 /* most mono outs have a least a mute/unmute switch */
3273 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3274 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3275 "Mono Playback Switch",
3276 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3279 /* check for volume support for the amp */
3280 if ((caps & AC_AMPCAP_NUM_STEPS)
3281 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3282 err = stac92xx_add_control(spec,
3283 STAC_CTL_WIDGET_VOL,
3284 "Mono Playback Volume",
3285 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3291 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3295 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3297 if (spec->multiout.num_dacs == 0)
3298 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3301 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3306 /* setup analog beep controls */
3307 if (spec->anabeep_nid > 0) {
3308 err = stac92xx_auto_create_beep_ctls(codec,
3314 /* setup digital beep controls and input device */
3315 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3316 if (spec->digbeep_nid > 0) {
3317 hda_nid_t nid = spec->digbeep_nid;
3319 err = stac92xx_auto_create_beep_ctls(codec, nid);
3322 err = snd_hda_attach_beep_device(codec, nid);
3328 if (hp_speaker_swap == 1) {
3329 /* Restore the hp_outs and line_outs */
3330 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3331 sizeof(spec->autocfg.line_out_pins));
3332 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3333 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3334 sizeof(spec->autocfg.speaker_pins));
3335 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3336 memset(spec->autocfg.speaker_pins, 0,
3337 sizeof(spec->autocfg.speaker_pins));
3338 spec->autocfg.speaker_outs = 0;
3341 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3346 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3351 if (spec->mono_nid > 0) {
3352 err = stac92xx_auto_create_mono_output_ctls(codec);
3356 if (spec->num_amps > 0) {
3357 err = stac92xx_auto_create_amp_output_ctls(codec);
3361 if (spec->num_dmics > 0 && !spec->dinput_mux)
3362 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3363 &spec->autocfg)) < 0)
3365 if (spec->num_muxes > 0) {
3366 err = stac92xx_auto_create_mux_input_ctls(codec);
3370 if (spec->num_smuxes > 0) {
3371 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3376 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3377 if (spec->multiout.max_channels > 2)
3378 spec->surr_switch = 1;
3380 if (spec->autocfg.dig_out_pin)
3381 spec->multiout.dig_out_nid = dig_out;
3382 if (dig_in && spec->autocfg.dig_in_pin)
3383 spec->dig_in_nid = dig_in;
3385 if (spec->kctl_alloc)
3386 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3388 spec->input_mux = &spec->private_imux;
3389 spec->dinput_mux = &spec->private_dimux;
3390 spec->sinput_mux = &spec->private_smux;
3391 spec->mono_mux = &spec->private_mono_mux;
3392 spec->amp_mux = &spec->private_amp_mux;
3396 /* add playback controls for HP output */
3397 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3398 struct auto_pin_cfg *cfg)
3400 struct sigmatel_spec *spec = codec->spec;
3401 hda_nid_t pin = cfg->hp_pins[0];
3402 unsigned int wid_caps;
3407 wid_caps = get_wcaps(codec, pin);
3408 if (wid_caps & AC_WCAP_UNSOL_CAP)
3409 spec->hp_detect = 1;
3414 /* add playback controls for LFE output */
3415 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3416 struct auto_pin_cfg *cfg)
3418 struct sigmatel_spec *spec = codec->spec;
3420 hda_nid_t lfe_pin = 0x0;
3424 * search speaker outs and line outs for a mono speaker pin
3425 * with an amp. If one is found, add LFE controls
3428 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3429 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3430 unsigned int wcaps = get_wcaps(codec, pin);
3431 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3432 if (wcaps == AC_WCAP_OUT_AMP)
3433 /* found a mono speaker with an amp, must be lfe */
3437 /* if speaker_outs is 0, then speakers may be in line_outs */
3438 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3439 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3440 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3441 unsigned int defcfg;
3442 defcfg = snd_hda_codec_read(codec, pin, 0,
3443 AC_VERB_GET_CONFIG_DEFAULT,
3445 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3446 unsigned int wcaps = get_wcaps(codec, pin);
3447 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3448 if (wcaps == AC_WCAP_OUT_AMP)
3449 /* found a mono speaker with an amp,
3457 err = create_controls(spec, "LFE", lfe_pin, 1);
3465 static int stac9200_parse_auto_config(struct hda_codec *codec)
3467 struct sigmatel_spec *spec = codec->spec;
3470 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3473 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3476 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3479 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3482 if (spec->autocfg.dig_out_pin)
3483 spec->multiout.dig_out_nid = 0x05;
3484 if (spec->autocfg.dig_in_pin)
3485 spec->dig_in_nid = 0x04;
3487 if (spec->kctl_alloc)
3488 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3490 spec->input_mux = &spec->private_imux;
3491 spec->dinput_mux = &spec->private_dimux;
3497 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3498 * funky external mute control using GPIO pins.
3501 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3502 unsigned int dir_mask, unsigned int data)
3504 unsigned int gpiostate, gpiomask, gpiodir;
3506 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3507 AC_VERB_GET_GPIO_DATA, 0);
3508 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3510 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3511 AC_VERB_GET_GPIO_MASK, 0);
3514 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3515 AC_VERB_GET_GPIO_DIRECTION, 0);
3516 gpiodir |= dir_mask;
3518 /* Configure GPIOx as CMOS */
3519 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3521 snd_hda_codec_write(codec, codec->afg, 0,
3522 AC_VERB_SET_GPIO_MASK, gpiomask);
3523 snd_hda_codec_read(codec, codec->afg, 0,
3524 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3528 snd_hda_codec_read(codec, codec->afg, 0,
3529 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3532 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3535 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
3536 snd_hda_codec_write_cache(codec, nid, 0,
3537 AC_VERB_SET_UNSOLICITED_ENABLE,
3538 (AC_USRSP_EN | event));
3541 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3544 for (i = 0; i < cfg->hp_outs; i++)
3545 if (cfg->hp_pins[i] == nid)
3546 return 1; /* nid is a HP-Out */
3548 return 0; /* nid is not a HP-Out */
3551 static void stac92xx_power_down(struct hda_codec *codec)
3553 struct sigmatel_spec *spec = codec->spec;
3555 /* power down inactive DACs */
3557 for (dac = spec->dac_list; *dac; dac++)
3558 if (!is_in_dac_nids(spec, *dac) &&
3559 spec->multiout.hp_nid != *dac)
3560 snd_hda_codec_write_cache(codec, *dac, 0,
3561 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3564 static int stac92xx_init(struct hda_codec *codec)
3566 struct sigmatel_spec *spec = codec->spec;
3567 struct auto_pin_cfg *cfg = &spec->autocfg;
3570 snd_hda_sequence_write(codec, spec->init);
3572 /* power down adcs initially */
3573 if (spec->powerdown_adcs)
3574 for (i = 0; i < spec->num_adcs; i++)
3575 snd_hda_codec_write_cache(codec,
3576 spec->adc_nids[i], 0,
3577 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3579 if (spec->hp_detect) {
3580 /* Enable unsolicited responses on the HP widget */
3581 for (i = 0; i < cfg->hp_outs; i++)
3582 enable_pin_detect(codec, cfg->hp_pins[i],
3584 /* force to enable the first line-out; the others are set up
3587 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3589 stac92xx_auto_init_hp_out(codec);
3590 /* fake event to set up pins */
3591 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3593 stac92xx_auto_init_multi_out(codec);
3594 stac92xx_auto_init_hp_out(codec);
3596 for (i = 0; i < AUTO_PIN_LAST; i++) {
3597 hda_nid_t nid = cfg->input_pins[i];
3599 unsigned int pinctl = AC_PINCTL_IN_EN;
3600 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3601 pinctl |= stac92xx_get_vref(codec, nid);
3602 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3605 for (i = 0; i < spec->num_dmics; i++)
3606 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3608 for (i = 0; i < spec->num_pwrs; i++) {
3609 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3610 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3611 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3612 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3613 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3614 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3615 def_conf = get_defcfg_connect(def_conf);
3616 /* outputs are only ports capable of power management
3617 * any attempts on powering down a input port cause the
3618 * referenced VREF to act quirky.
3620 if (pinctl & AC_PINCTL_IN_EN)
3622 /* skip any ports that don't have jacks since presence
3623 * detection is useless */
3624 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
3626 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3627 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3630 stac92xx_power_down(codec);
3631 if (cfg->dig_out_pin)
3632 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3634 if (cfg->dig_in_pin)
3635 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3638 stac_gpio_set(codec, spec->gpio_mask,
3639 spec->gpio_dir, spec->gpio_data);
3644 static void stac92xx_free(struct hda_codec *codec)
3646 struct sigmatel_spec *spec = codec->spec;
3652 if (spec->kctl_alloc) {
3653 for (i = 0; i < spec->num_kctl_used; i++)
3654 kfree(spec->kctl_alloc[i].name);
3655 kfree(spec->kctl_alloc);
3658 if (spec->bios_pin_configs)
3659 kfree(spec->bios_pin_configs);
3662 snd_hda_detach_beep_device(codec);
3665 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3668 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3669 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3671 if (pin_ctl & AC_PINCTL_IN_EN) {
3673 * we need to check the current set-up direction of
3674 * shared input pins since they can be switched via
3675 * "xxx as Output" mixer switch
3677 struct sigmatel_spec *spec = codec->spec;
3678 struct auto_pin_cfg *cfg = &spec->autocfg;
3679 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3680 spec->line_switch) ||
3681 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3686 /* if setting pin direction bits, clear the current
3687 direction bits first */
3688 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3689 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3691 snd_hda_codec_write_cache(codec, nid, 0,
3692 AC_VERB_SET_PIN_WIDGET_CONTROL,
3696 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3699 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3700 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3701 snd_hda_codec_write_cache(codec, nid, 0,
3702 AC_VERB_SET_PIN_WIDGET_CONTROL,
3706 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3710 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3712 unsigned int pinctl;
3713 pinctl = snd_hda_codec_read(codec, nid, 0,
3714 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3715 if (pinctl & AC_PINCTL_IN_EN)
3716 return 0; /* mic- or line-input */
3718 return 1; /* HP-output */
3723 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3725 struct sigmatel_spec *spec = codec->spec;
3726 struct auto_pin_cfg *cfg = &spec->autocfg;
3727 int nid = cfg->hp_pins[cfg->hp_outs - 1];
3731 if (spec->gpio_mute)
3732 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3733 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3735 for (i = 0; i < cfg->hp_outs; i++) {
3738 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3740 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3744 /* disable lineouts, enable hp */
3745 if (spec->hp_switch)
3746 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3747 for (i = 0; i < cfg->line_outs; i++)
3748 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3750 for (i = 0; i < cfg->speaker_outs; i++)
3751 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3753 if (spec->eapd_mask)
3754 stac_gpio_set(codec, spec->gpio_mask,
3755 spec->gpio_dir, spec->gpio_data &
3758 /* enable lineouts, disable hp */
3759 if (spec->hp_switch)
3760 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3761 for (i = 0; i < cfg->line_outs; i++)
3762 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3764 for (i = 0; i < cfg->speaker_outs; i++)
3765 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3767 if (spec->eapd_mask)
3768 stac_gpio_set(codec, spec->gpio_mask,
3769 spec->gpio_dir, spec->gpio_data |
3772 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3773 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3776 static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3778 struct sigmatel_spec *spec = codec->spec;
3779 hda_nid_t nid = spec->pwr_nids[idx];
3781 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3783 presence = get_hp_pin_presence(codec, nid);
3785 /* several codecs have two power down bits */
3786 if (spec->pwr_mapping)
3787 idx = spec->pwr_mapping[idx];
3796 /* power down unused output ports */
3797 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3800 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3802 struct sigmatel_spec *spec = codec->spec;
3803 int idx = res >> 26 & 0x0f;
3805 switch ((res >> 26) & 0x30) {
3807 stac92xx_hp_detect(codec, res);
3809 case STAC_PWR_EVENT:
3810 if (spec->num_pwrs > 0)
3811 stac92xx_pin_sense(codec, idx);
3815 #ifdef SND_HDA_NEEDS_RESUME
3816 static int stac92xx_resume(struct hda_codec *codec)
3818 struct sigmatel_spec *spec = codec->spec;
3820 stac92xx_set_config_regs(codec);
3821 snd_hda_sequence_write(codec, spec->init);
3822 stac_gpio_set(codec, spec->gpio_mask,
3823 spec->gpio_dir, spec->gpio_data);
3824 snd_hda_codec_resume_amp(codec);
3825 snd_hda_codec_resume_cache(codec);
3826 /* power down inactive DACs */
3828 stac92xx_power_down(codec);
3829 /* invoke unsolicited event to reset the HP state */
3830 if (spec->hp_detect)
3831 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3836 static struct hda_codec_ops stac92xx_patch_ops = {
3837 .build_controls = stac92xx_build_controls,
3838 .build_pcms = stac92xx_build_pcms,
3839 .init = stac92xx_init,
3840 .free = stac92xx_free,
3841 .unsol_event = stac92xx_unsol_event,
3842 #ifdef SND_HDA_NEEDS_RESUME
3843 .resume = stac92xx_resume,
3847 static int patch_stac9200(struct hda_codec *codec)
3849 struct sigmatel_spec *spec;
3852 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3857 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
3858 spec->pin_nids = stac9200_pin_nids;
3859 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3862 if (spec->board_config < 0) {
3863 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3864 err = stac92xx_save_bios_config_regs(codec);
3866 stac92xx_free(codec);
3869 spec->pin_configs = spec->bios_pin_configs;
3871 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3872 stac92xx_set_config_regs(codec);
3875 spec->multiout.max_channels = 2;
3876 spec->multiout.num_dacs = 1;
3877 spec->multiout.dac_nids = stac9200_dac_nids;
3878 spec->adc_nids = stac9200_adc_nids;
3879 spec->mux_nids = stac9200_mux_nids;
3880 spec->num_muxes = 1;
3881 spec->num_dmics = 0;
3885 if (spec->board_config == STAC_9200_GATEWAY ||
3886 spec->board_config == STAC_9200_OQO)
3887 spec->init = stac9200_eapd_init;
3889 spec->init = stac9200_core_init;
3890 spec->mixer = stac9200_mixer;
3892 if (spec->board_config == STAC_9200_PANASONIC) {
3893 spec->gpio_mask = spec->gpio_dir = 0x09;
3894 spec->gpio_data = 0x00;
3897 err = stac9200_parse_auto_config(codec);
3899 stac92xx_free(codec);
3903 codec->patch_ops = stac92xx_patch_ops;
3908 static int patch_stac925x(struct hda_codec *codec)
3910 struct sigmatel_spec *spec;
3913 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3918 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
3919 spec->pin_nids = stac925x_pin_nids;
3920 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3924 if (spec->board_config < 0) {
3925 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3926 "using BIOS defaults\n");
3927 err = stac92xx_save_bios_config_regs(codec);
3929 stac92xx_free(codec);
3932 spec->pin_configs = spec->bios_pin_configs;
3933 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3934 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3935 stac92xx_set_config_regs(codec);
3938 spec->multiout.max_channels = 2;
3939 spec->multiout.num_dacs = 1;
3940 spec->multiout.dac_nids = stac925x_dac_nids;
3941 spec->adc_nids = stac925x_adc_nids;
3942 spec->mux_nids = stac925x_mux_nids;
3943 spec->num_muxes = 1;
3946 switch (codec->vendor_id) {
3947 case 0x83847632: /* STAC9202 */
3948 case 0x83847633: /* STAC9202D */
3949 case 0x83847636: /* STAC9251 */
3950 case 0x83847637: /* STAC9251D */
3951 spec->num_dmics = STAC925X_NUM_DMICS;
3952 spec->dmic_nids = stac925x_dmic_nids;
3953 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3954 spec->dmux_nids = stac925x_dmux_nids;
3957 spec->num_dmics = 0;
3961 spec->init = stac925x_core_init;
3962 spec->mixer = stac925x_mixer;
3964 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
3966 if (spec->board_config < 0) {
3967 printk(KERN_WARNING "hda_codec: No auto-config is "
3968 "available, default to model=ref\n");
3969 spec->board_config = STAC_925x_REF;
3975 stac92xx_free(codec);
3979 codec->patch_ops = stac92xx_patch_ops;
3984 static struct hda_input_mux stac92hd73xx_dmux = {
3987 { "Analog Inputs", 0x0b },
3988 { "Digital Mic 1", 0x09 },
3989 { "Digital Mic 2", 0x0a },
3994 static int patch_stac92hd73xx(struct hda_codec *codec)
3996 struct sigmatel_spec *spec;
3997 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4000 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4005 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4006 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4007 spec->pin_nids = stac92hd73xx_pin_nids;
4008 spec->board_config = snd_hda_check_board_config(codec,
4009 STAC_92HD73XX_MODELS,
4010 stac92hd73xx_models,
4011 stac92hd73xx_cfg_tbl);
4013 if (spec->board_config < 0) {
4014 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4015 " STAC92HD73XX, using BIOS defaults\n");
4016 err = stac92xx_save_bios_config_regs(codec);
4018 stac92xx_free(codec);
4021 spec->pin_configs = spec->bios_pin_configs;
4023 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4024 stac92xx_set_config_regs(codec);
4027 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4028 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4030 if (spec->multiout.num_dacs < 0) {
4031 printk(KERN_WARNING "hda_codec: Could not determine "
4032 "number of channels defaulting to DAC count\n");
4033 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4036 switch (spec->multiout.num_dacs) {
4037 case 0x3: /* 6 Channel */
4038 spec->mixer = stac92hd73xx_6ch_mixer;
4039 spec->init = stac92hd73xx_6ch_core_init;
4041 case 0x4: /* 8 Channel */
4042 spec->mixer = stac92hd73xx_8ch_mixer;
4043 spec->init = stac92hd73xx_8ch_core_init;
4045 case 0x5: /* 10 Channel */
4046 spec->mixer = stac92hd73xx_10ch_mixer;
4047 spec->init = stac92hd73xx_10ch_core_init;
4050 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4051 spec->aloopback_mask = 0x01;
4052 spec->aloopback_shift = 8;
4054 spec->digbeep_nid = 0x1c;
4055 spec->mux_nids = stac92hd73xx_mux_nids;
4056 spec->adc_nids = stac92hd73xx_adc_nids;
4057 spec->dmic_nids = stac92hd73xx_dmic_nids;
4058 spec->dmux_nids = stac92hd73xx_dmux_nids;
4059 spec->smux_nids = stac92hd73xx_smux_nids;
4060 spec->amp_nids = stac92hd73xx_amp_nids;
4061 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4063 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4064 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4065 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4066 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4067 sizeof(stac92hd73xx_dmux));
4069 /* GPIO0 High = Enable EAPD */
4070 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4071 spec->gpio_data = 0x01;
4073 switch (spec->board_config) {
4075 spec->init = dell_eq_core_init;
4076 spec->num_smuxes = 0;
4077 spec->multiout.hp_nid =
4078 spec->multiout.dac_nids[spec->multiout.num_dacs - 1];
4079 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4080 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4082 switch (codec->subsystem_id) {
4083 case 0x1028025e: /* Analog Mics */
4085 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4086 spec->num_dmics = 0;
4087 spec->private_dimux.num_items = 1;
4089 case 0x10280271: /* Digital Mics */
4091 spec->init = dell_m6_core_init;
4095 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4096 spec->num_dmics = 1;
4097 spec->private_dimux.num_items = 2;
4099 case 0x10280256: /* Both */
4101 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4102 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4103 spec->num_dmics = 1;
4104 spec->private_dimux.num_items = 2;
4109 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4110 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4112 spec->dinput_mux = &spec->private_dimux;
4114 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4115 spec->pwr_nids = stac92hd73xx_pwr_nids;
4117 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
4120 if (spec->board_config < 0) {
4121 printk(KERN_WARNING "hda_codec: No auto-config is "
4122 "available, default to model=ref\n");
4123 spec->board_config = STAC_92HD73XX_REF;
4130 stac92xx_free(codec);
4134 codec->patch_ops = stac92xx_patch_ops;
4139 static struct hda_input_mux stac92hd83xxx_dmux = {
4142 { "Analog Inputs", 0x03 },
4143 { "Digital Mic 1", 0x04 },
4144 { "Digital Mic 2", 0x05 },
4148 static int patch_stac92hd83xxx(struct hda_codec *codec)
4150 struct sigmatel_spec *spec;
4153 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4158 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
4159 spec->mono_nid = 0x19;
4160 spec->digbeep_nid = 0x21;
4161 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4162 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4163 spec->adc_nids = stac92hd83xxx_adc_nids;
4164 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4165 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4166 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4167 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4169 spec->init = stac92hd83xxx_core_init;
4170 switch (codec->vendor_id) {
4172 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4176 spec->init++; /* switch to config #2 */
4177 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4180 spec->mixer = stac92hd83xxx_mixer;
4181 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4182 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4183 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4184 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4185 spec->dinput_mux = &stac92hd83xxx_dmux;
4186 spec->pin_nids = stac92hd83xxx_pin_nids;
4187 spec->board_config = snd_hda_check_board_config(codec,
4188 STAC_92HD83XXX_MODELS,
4189 stac92hd83xxx_models,
4190 stac92hd83xxx_cfg_tbl);
4192 if (spec->board_config < 0) {
4193 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4194 " STAC92HD83XXX, using BIOS defaults\n");
4195 err = stac92xx_save_bios_config_regs(codec);
4197 stac92xx_free(codec);
4200 spec->pin_configs = spec->bios_pin_configs;
4202 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4203 stac92xx_set_config_regs(codec);
4206 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4208 if (spec->board_config < 0) {
4209 printk(KERN_WARNING "hda_codec: No auto-config is "
4210 "available, default to model=ref\n");
4211 spec->board_config = STAC_92HD83XXX_REF;
4218 stac92xx_free(codec);
4222 codec->patch_ops = stac92xx_patch_ops;
4227 #ifdef SND_HDA_NEEDS_RESUME
4228 static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4230 struct sigmatel_spec *spec = codec->spec;
4232 snd_hda_codec_write_cache(codec, codec->afg, 0,
4233 AC_VERB_SET_POWER_STATE, pwr);
4236 for (i = 0; i < spec->num_adcs; i++) {
4237 snd_hda_codec_write_cache(codec,
4238 spec->adc_nids[i], 0,
4239 AC_VERB_SET_POWER_STATE, pwr);
4243 static int stac92hd71xx_resume(struct hda_codec *codec)
4245 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4246 return stac92xx_resume(codec);
4249 static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4251 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4257 static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4258 .build_controls = stac92xx_build_controls,
4259 .build_pcms = stac92xx_build_pcms,
4260 .init = stac92xx_init,
4261 .free = stac92xx_free,
4262 .unsol_event = stac92xx_unsol_event,
4263 #ifdef SND_HDA_NEEDS_RESUME
4264 .resume = stac92hd71xx_resume,
4265 .suspend = stac92hd71xx_suspend,
4269 static int patch_stac92hd71bxx(struct hda_codec *codec)
4271 struct sigmatel_spec *spec;
4274 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4279 codec->patch_ops = stac92xx_patch_ops;
4280 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
4281 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4282 spec->pin_nids = stac92hd71bxx_pin_nids;
4283 spec->board_config = snd_hda_check_board_config(codec,
4284 STAC_92HD71BXX_MODELS,
4285 stac92hd71bxx_models,
4286 stac92hd71bxx_cfg_tbl);
4288 if (spec->board_config < 0) {
4289 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4290 " STAC92HD71BXX, using BIOS defaults\n");
4291 err = stac92xx_save_bios_config_regs(codec);
4293 stac92xx_free(codec);
4296 spec->pin_configs = spec->bios_pin_configs;
4298 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4299 stac92xx_set_config_regs(codec);
4302 switch (codec->vendor_id) {
4303 case 0x111d76b6: /* 4 Port without Analog Mixer */
4305 case 0x111d76b4: /* 6 Port without Analog Mixer */
4307 spec->mixer = stac92hd71bxx_mixer;
4308 spec->init = stac92hd71bxx_core_init;
4309 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4311 case 0x111d7608: /* 5 Port with Analog Mixer */
4312 if ((codec->revision_id & 0xf) == 0 ||
4313 (codec->revision_id & 0xf) == 1) {
4314 #ifdef SND_HDA_NEEDS_RESUME
4315 codec->patch_ops = stac92hd71bxx_patch_ops;
4317 spec->stream_delay = 40; /* 40 milliseconds */
4320 /* no output amps */
4322 spec->mixer = stac92hd71bxx_analog_mixer;
4325 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4326 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4328 case 0x111d7603: /* 6 Port with Analog Mixer */
4329 if ((codec->revision_id & 0xf) == 1) {
4330 #ifdef SND_HDA_NEEDS_RESUME
4331 codec->patch_ops = stac92hd71bxx_patch_ops;
4333 spec->stream_delay = 40; /* 40 milliseconds */
4336 /* no output amps */
4340 spec->mixer = stac92hd71bxx_analog_mixer;
4341 spec->init = stac92hd71bxx_analog_core_init;
4342 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4345 spec->aloopback_mask = 0x20;
4346 spec->aloopback_shift = 0;
4348 /* GPIO0 High = EAPD */
4349 spec->gpio_mask = 0x01;
4350 spec->gpio_dir = 0x01;
4351 spec->gpio_data = 0x01;
4353 spec->powerdown_adcs = 1;
4354 spec->digbeep_nid = 0x26;
4355 spec->mux_nids = stac92hd71bxx_mux_nids;
4356 spec->adc_nids = stac92hd71bxx_adc_nids;
4357 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4358 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4359 spec->smux_nids = stac92hd71bxx_smux_nids;
4360 spec->pwr_nids = stac92hd71bxx_pwr_nids;
4362 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4363 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
4364 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4366 switch (spec->board_config) {
4368 spec->num_dmics = 0;
4369 spec->num_smuxes = 1;
4370 spec->num_dmuxes = 0;
4372 /* enable internal microphone */
4373 snd_hda_codec_write_cache(codec, 0x0e, 0,
4374 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80);
4377 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4378 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4379 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4382 spec->multiout.num_dacs = 1;
4383 spec->multiout.hp_nid = 0x11;
4384 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4386 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4388 if (spec->board_config < 0) {
4389 printk(KERN_WARNING "hda_codec: No auto-config is "
4390 "available, default to model=ref\n");
4391 spec->board_config = STAC_92HD71BXX_REF;
4398 stac92xx_free(codec);
4405 static int patch_stac922x(struct hda_codec *codec)
4407 struct sigmatel_spec *spec;
4410 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4415 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
4416 spec->pin_nids = stac922x_pin_nids;
4417 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4420 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
4421 spec->gpio_mask = spec->gpio_dir = 0x03;
4422 spec->gpio_data = 0x03;
4423 /* Intel Macs have all same PCI SSID, so we need to check
4424 * codec SSID to distinguish the exact models
4426 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
4427 switch (codec->subsystem_id) {
4430 spec->board_config = STAC_INTEL_MAC_V1;
4434 spec->board_config = STAC_INTEL_MAC_V2;
4442 spec->board_config = STAC_INTEL_MAC_V3;
4446 spec->board_config = STAC_INTEL_MAC_V4;
4450 spec->board_config = STAC_INTEL_MAC_V5;
4453 spec->board_config = STAC_INTEL_MAC_V3;
4459 if (spec->board_config < 0) {
4460 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4461 "using BIOS defaults\n");
4462 err = stac92xx_save_bios_config_regs(codec);
4464 stac92xx_free(codec);
4467 spec->pin_configs = spec->bios_pin_configs;
4468 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
4469 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4470 stac92xx_set_config_regs(codec);
4473 spec->adc_nids = stac922x_adc_nids;
4474 spec->mux_nids = stac922x_mux_nids;
4475 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
4476 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
4477 spec->num_dmics = 0;
4480 spec->init = stac922x_core_init;
4481 spec->mixer = stac922x_mixer;
4483 spec->multiout.dac_nids = spec->dac_nids;
4485 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
4487 if (spec->board_config < 0) {
4488 printk(KERN_WARNING "hda_codec: No auto-config is "
4489 "available, default to model=ref\n");
4490 spec->board_config = STAC_D945_REF;
4496 stac92xx_free(codec);
4500 codec->patch_ops = stac92xx_patch_ops;
4502 /* Fix Mux capture level; max to 2 */
4503 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4504 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4505 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4506 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4507 (0 << AC_AMPCAP_MUTE_SHIFT));
4512 static int patch_stac927x(struct hda_codec *codec)
4514 struct sigmatel_spec *spec;
4517 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4522 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
4523 spec->pin_nids = stac927x_pin_nids;
4524 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4528 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4529 if (spec->board_config < 0)
4530 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4531 "STAC927x, using BIOS defaults\n");
4532 err = stac92xx_save_bios_config_regs(codec);
4534 stac92xx_free(codec);
4537 spec->pin_configs = spec->bios_pin_configs;
4539 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4540 stac92xx_set_config_regs(codec);
4543 spec->digbeep_nid = 0x23;
4544 spec->adc_nids = stac927x_adc_nids;
4545 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4546 spec->mux_nids = stac927x_mux_nids;
4547 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
4548 spec->smux_nids = stac927x_smux_nids;
4549 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
4550 spec->dac_list = stac927x_dac_nids;
4551 spec->multiout.dac_nids = spec->dac_nids;
4553 switch (spec->board_config) {
4556 /* GPIO0 High = Enable EAPD */
4557 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
4558 spec->gpio_data = 0x01;
4559 spec->num_dmics = 0;
4561 spec->init = d965_core_init;
4562 spec->mixer = stac927x_mixer;
4564 case STAC_DELL_BIOS:
4565 switch (codec->subsystem_id) {
4568 /* correct the device field to SPDIF out */
4569 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4572 /* configure the analog microphone on some laptops */
4573 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
4574 /* correct the front output jack as a hp out */
4575 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
4576 /* correct the front input jack as a mic */
4577 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4580 /* GPIO2 High = Enable EAPD */
4581 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
4582 spec->gpio_data = 0x04;
4583 spec->dmic_nids = stac927x_dmic_nids;
4584 spec->num_dmics = STAC927X_NUM_DMICS;
4586 spec->init = d965_core_init;
4587 spec->mixer = stac927x_mixer;
4588 spec->dmux_nids = stac927x_dmux_nids;
4589 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
4592 /* GPIO0 High = Enable EAPD */
4593 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4594 spec->gpio_data = 0x01;
4595 spec->num_dmics = 0;
4597 spec->init = stac927x_core_init;
4598 spec->mixer = stac927x_mixer;
4602 spec->aloopback_mask = 0x40;
4603 spec->aloopback_shift = 0;
4605 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
4607 if (spec->board_config < 0) {
4608 printk(KERN_WARNING "hda_codec: No auto-config is "
4609 "available, default to model=ref\n");
4610 spec->board_config = STAC_D965_REF;
4616 stac92xx_free(codec);
4620 codec->patch_ops = stac92xx_patch_ops;
4624 * The STAC927x seem to require fairly long delays for certain
4625 * command sequences. With too short delays (even if the answer
4626 * is set to RIRB properly), it results in the silence output
4627 * on some hardwares like Dell.
4629 * The below flag enables the longer delay (see get_response
4632 codec->bus->needs_damn_long_delay = 1;
4637 static int patch_stac9205(struct hda_codec *codec)
4639 struct sigmatel_spec *spec;
4642 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4647 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
4648 spec->pin_nids = stac9205_pin_nids;
4649 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4653 if (spec->board_config < 0) {
4654 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4655 err = stac92xx_save_bios_config_regs(codec);
4657 stac92xx_free(codec);
4660 spec->pin_configs = spec->bios_pin_configs;
4662 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4663 stac92xx_set_config_regs(codec);
4666 spec->digbeep_nid = 0x23;
4667 spec->adc_nids = stac9205_adc_nids;
4668 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
4669 spec->mux_nids = stac9205_mux_nids;
4670 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
4671 spec->smux_nids = stac9205_smux_nids;
4672 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
4673 spec->dmic_nids = stac9205_dmic_nids;
4674 spec->num_dmics = STAC9205_NUM_DMICS;
4675 spec->dmux_nids = stac9205_dmux_nids;
4676 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
4679 spec->init = stac9205_core_init;
4680 spec->mixer = stac9205_mixer;
4682 spec->aloopback_mask = 0x40;
4683 spec->aloopback_shift = 0;
4684 spec->multiout.dac_nids = spec->dac_nids;
4686 switch (spec->board_config){
4687 case STAC_9205_DELL_M43:
4688 /* Enable SPDIF in/out */
4689 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4690 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
4692 /* Enable unsol response for GPIO4/Dock HP connection */
4693 snd_hda_codec_write(codec, codec->afg, 0,
4694 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4695 snd_hda_codec_write_cache(codec, codec->afg, 0,
4696 AC_VERB_SET_UNSOLICITED_ENABLE,
4697 (AC_USRSP_EN | STAC_HP_EVENT));
4699 spec->gpio_dir = 0x0b;
4700 spec->eapd_mask = 0x01;
4701 spec->gpio_mask = 0x1b;
4702 spec->gpio_mute = 0x10;
4703 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
4706 spec->gpio_data = 0x01;
4709 /* GPIO0 High = EAPD */
4710 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4711 spec->gpio_data = 0x01;
4715 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
4717 if (spec->board_config < 0) {
4718 printk(KERN_WARNING "hda_codec: No auto-config is "
4719 "available, default to model=ref\n");
4720 spec->board_config = STAC_9205_REF;
4726 stac92xx_free(codec);
4730 codec->patch_ops = stac92xx_patch_ops;
4739 /* static config for Sony VAIO FE550G and Sony VAIO AR */
4740 static hda_nid_t vaio_dacs[] = { 0x2 };
4741 #define VAIO_HP_DAC 0x5
4742 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4743 static hda_nid_t vaio_mux_nids[] = { 0x15 };
4745 static struct hda_input_mux vaio_mux = {
4748 /* { "HP", 0x0 }, */
4749 { "Mic Jack", 0x1 },
4750 { "Internal Mic", 0x2 },
4755 static struct hda_verb vaio_init[] = {
4756 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4757 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
4758 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4759 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4760 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4761 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4762 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4763 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4764 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4765 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4766 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4771 static struct hda_verb vaio_ar_init[] = {
4772 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4773 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4774 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4775 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4776 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4777 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4778 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4779 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4780 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4781 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4782 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4784 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4788 /* bind volumes of both NID 0x02 and 0x05 */
4789 static struct hda_bind_ctls vaio_bind_master_vol = {
4790 .ops = &snd_hda_bind_vol,
4792 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4793 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4798 /* bind volumes of both NID 0x02 and 0x05 */
4799 static struct hda_bind_ctls vaio_bind_master_sw = {
4800 .ops = &snd_hda_bind_sw,
4802 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4803 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4808 static struct snd_kcontrol_new vaio_mixer[] = {
4809 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4810 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4811 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4812 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4813 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4816 .name = "Capture Source",
4818 .info = stac92xx_mux_enum_info,
4819 .get = stac92xx_mux_enum_get,
4820 .put = stac92xx_mux_enum_put,
4825 static struct snd_kcontrol_new vaio_ar_mixer[] = {
4826 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4827 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4828 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4829 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4830 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4831 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4832 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4835 .name = "Capture Source",
4837 .info = stac92xx_mux_enum_info,
4838 .get = stac92xx_mux_enum_get,
4839 .put = stac92xx_mux_enum_put,
4844 static struct hda_codec_ops stac9872_patch_ops = {
4845 .build_controls = stac92xx_build_controls,
4846 .build_pcms = stac92xx_build_pcms,
4847 .init = stac92xx_init,
4848 .free = stac92xx_free,
4849 #ifdef SND_HDA_NEEDS_RESUME
4850 .resume = stac92xx_resume,
4854 static int stac9872_vaio_init(struct hda_codec *codec)
4858 err = stac92xx_init(codec);
4861 if (codec->patch_ops.unsol_event)
4862 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4866 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4868 if (get_hp_pin_presence(codec, 0x0a)) {
4869 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4870 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4872 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4873 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4877 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4879 switch (res >> 26) {
4881 stac9872_vaio_hp_detect(codec, res);
4886 static struct hda_codec_ops stac9872_vaio_patch_ops = {
4887 .build_controls = stac92xx_build_controls,
4888 .build_pcms = stac92xx_build_pcms,
4889 .init = stac9872_vaio_init,
4890 .free = stac92xx_free,
4891 .unsol_event = stac9872_vaio_unsol_event,
4893 .resume = stac92xx_resume,
4897 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4899 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4901 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4903 /* AR Series. id=0x83847664 and subsys=104D1300 */
4908 static const char *stac9872_models[STAC_9872_MODELS] = {
4909 [CXD9872RD_VAIO] = "vaio",
4910 [CXD9872AKD_VAIO] = "vaio-ar",
4913 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4914 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4915 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4916 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
4917 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
4921 static int patch_stac9872(struct hda_codec *codec)
4923 struct sigmatel_spec *spec;
4926 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4929 if (board_config < 0)
4930 /* unknown config, let generic-parser do its job... */
4931 return snd_hda_parse_generic_codec(codec);
4933 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4938 switch (board_config) {
4939 case CXD9872RD_VAIO:
4940 case STAC9872AK_VAIO:
4941 case STAC9872K_VAIO:
4942 spec->mixer = vaio_mixer;
4943 spec->init = vaio_init;
4944 spec->multiout.max_channels = 2;
4945 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4946 spec->multiout.dac_nids = vaio_dacs;
4947 spec->multiout.hp_nid = VAIO_HP_DAC;
4948 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4949 spec->adc_nids = vaio_adcs;
4951 spec->input_mux = &vaio_mux;
4952 spec->mux_nids = vaio_mux_nids;
4953 codec->patch_ops = stac9872_vaio_patch_ops;
4956 case CXD9872AKD_VAIO:
4957 spec->mixer = vaio_ar_mixer;
4958 spec->init = vaio_ar_init;
4959 spec->multiout.max_channels = 2;
4960 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4961 spec->multiout.dac_nids = vaio_dacs;
4962 spec->multiout.hp_nid = VAIO_HP_DAC;
4963 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4965 spec->adc_nids = vaio_adcs;
4966 spec->input_mux = &vaio_mux;
4967 spec->mux_nids = vaio_mux_nids;
4968 codec->patch_ops = stac9872_patch_ops;
4979 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4980 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4981 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4982 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4983 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4984 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4985 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4986 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
4987 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4988 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4989 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4990 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4991 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4992 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
4993 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4994 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4995 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4996 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4997 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4998 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4999 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5000 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5001 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5002 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5003 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5004 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5005 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5006 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5007 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5008 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5009 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5010 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5011 /* The following does not take into account .id=0x83847661 when subsys =
5012 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5013 * currently not fully supported.
5015 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5016 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5017 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5018 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5019 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5020 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5021 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5022 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5023 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5024 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5025 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5026 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5027 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5028 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5029 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5030 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5031 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5032 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5033 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5034 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5035 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5036 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5037 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5038 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5039 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5040 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },