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 <sound/jack.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
74 STAC_92HD73XX_NO_JD, /* no jack-detection */
85 STAC_92HD83XXX_PWR_REF,
120 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
121 * is given, one of the above models will be
122 * chosen according to the subsystem id. */
123 /* for backward compatibility */
139 STAC_D965_REF_NO_JD, /* no jack-detection */
148 struct sigmatel_event {
155 struct sigmatel_jack {
158 struct snd_jack *jack;
161 struct sigmatel_spec {
162 struct snd_kcontrol_new *mixers[4];
163 unsigned int num_mixers;
166 unsigned int eapd_switch: 1;
167 unsigned int surr_switch: 1;
168 unsigned int alt_switch: 1;
169 unsigned int hp_detect: 1;
170 unsigned int spdif_mute: 1;
171 unsigned int check_volume_offset:1;
174 unsigned int eapd_mask;
175 unsigned int gpio_mask;
176 unsigned int gpio_dir;
177 unsigned int gpio_data;
178 unsigned int gpio_mute;
181 unsigned int stream_delay;
183 /* analog loopback */
184 unsigned char aloopback_mask;
185 unsigned char aloopback_shift;
187 /* power management */
188 unsigned int num_pwrs;
189 unsigned int *pwr_mapping;
194 struct snd_array jacks;
197 struct snd_array events;
200 struct hda_input_mux *mono_mux;
201 struct hda_input_mux *amp_mux;
202 unsigned int cur_mmux;
203 struct hda_multi_out multiout;
204 hda_nid_t dac_nids[5];
205 hda_nid_t hp_dacs[5];
206 hda_nid_t speaker_dacs[5];
212 unsigned int num_adcs;
214 unsigned int num_muxes;
215 hda_nid_t *dmic_nids;
216 unsigned int num_dmics;
217 hda_nid_t *dmux_nids;
218 unsigned int num_dmuxes;
219 hda_nid_t *smux_nids;
220 unsigned int num_smuxes;
221 const char **spdif_labels;
223 hda_nid_t dig_in_nid;
225 hda_nid_t anabeep_nid;
226 hda_nid_t digbeep_nid;
230 unsigned int num_pins;
231 unsigned int *pin_configs;
233 /* codec specific stuff */
234 struct hda_verb *init;
235 struct snd_kcontrol_new *mixer;
238 struct hda_input_mux *dinput_mux;
239 unsigned int cur_dmux[2];
240 struct hda_input_mux *input_mux;
241 unsigned int cur_mux[3];
242 struct hda_input_mux *sinput_mux;
243 unsigned int cur_smux[2];
244 unsigned int cur_amux;
246 unsigned int num_amps;
247 unsigned int powerdown_adcs;
250 unsigned int io_switch[2];
251 unsigned int clfe_swap;
252 hda_nid_t line_switch; /* shared line-in for input and output */
253 hda_nid_t mic_switch; /* shared mic-in for input and output */
254 hda_nid_t hp_switch; /* NID of HP as line-out */
255 unsigned int aloopback;
257 struct hda_pcm pcm_rec[2]; /* PCM information */
259 /* dynamic controls and input_mux */
260 struct auto_pin_cfg autocfg;
261 struct snd_array kctls;
262 struct hda_input_mux private_dimux;
263 struct hda_input_mux private_imux;
264 struct hda_input_mux private_smux;
265 struct hda_input_mux private_amp_mux;
266 struct hda_input_mux private_mono_mux;
269 static hda_nid_t stac9200_adc_nids[1] = {
273 static hda_nid_t stac9200_mux_nids[1] = {
277 static hda_nid_t stac9200_dac_nids[1] = {
281 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
282 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
286 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
290 static hda_nid_t stac92hd73xx_adc_nids[2] = {
294 #define DELL_M6_AMP 2
295 static hda_nid_t stac92hd73xx_amp_nids[3] = {
299 #define STAC92HD73XX_NUM_DMICS 2
300 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
304 #define STAC92HD73_DAC_COUNT 5
306 static hda_nid_t stac92hd73xx_mux_nids[4] = {
307 0x28, 0x29, 0x2a, 0x2b,
310 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
314 static hda_nid_t stac92hd73xx_smux_nids[2] = {
318 #define STAC92HD83XXX_NUM_DMICS 2
319 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
323 #define STAC92HD83_DAC_COUNT 3
325 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
329 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
333 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
337 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
341 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
342 0x03, 0x0c, 0x20, 0x40,
345 static hda_nid_t stac92hd83xxx_amp_nids[1] = {
349 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
353 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
357 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
361 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
365 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
369 #define STAC92HD71BXX_NUM_DMICS 2
370 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
374 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
378 static hda_nid_t stac925x_adc_nids[1] = {
382 static hda_nid_t stac925x_mux_nids[1] = {
386 static hda_nid_t stac925x_dac_nids[1] = {
390 #define STAC925X_NUM_DMICS 1
391 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
395 static hda_nid_t stac925x_dmux_nids[1] = {
399 static hda_nid_t stac922x_adc_nids[2] = {
403 static hda_nid_t stac922x_mux_nids[2] = {
407 static hda_nid_t stac927x_adc_nids[3] = {
411 static hda_nid_t stac927x_mux_nids[3] = {
415 static hda_nid_t stac927x_smux_nids[1] = {
419 static hda_nid_t stac927x_dac_nids[6] = {
420 0x02, 0x03, 0x04, 0x05, 0x06, 0
423 static hda_nid_t stac927x_dmux_nids[1] = {
427 #define STAC927X_NUM_DMICS 2
428 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
432 static const char *stac927x_spdif_labels[5] = {
433 "Digital Playback", "ADAT", "Analog Mux 1",
434 "Analog Mux 2", "Analog Mux 3"
437 static hda_nid_t stac9205_adc_nids[2] = {
441 static hda_nid_t stac9205_mux_nids[2] = {
445 static hda_nid_t stac9205_dmux_nids[1] = {
449 static hda_nid_t stac9205_smux_nids[1] = {
453 #define STAC9205_NUM_DMICS 2
454 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
458 static hda_nid_t stac9200_pin_nids[8] = {
459 0x08, 0x09, 0x0d, 0x0e,
460 0x0f, 0x10, 0x11, 0x12,
463 static hda_nid_t stac925x_pin_nids[8] = {
464 0x07, 0x08, 0x0a, 0x0b,
465 0x0c, 0x0d, 0x10, 0x11,
468 static hda_nid_t stac922x_pin_nids[10] = {
469 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
470 0x0f, 0x10, 0x11, 0x15, 0x1b,
473 static hda_nid_t stac92hd73xx_pin_nids[13] = {
474 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
475 0x0f, 0x10, 0x11, 0x12, 0x13,
479 static hda_nid_t stac92hd83xxx_pin_nids[14] = {
480 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
481 0x0f, 0x10, 0x11, 0x12, 0x13,
482 0x1d, 0x1e, 0x1f, 0x20
485 #define STAC92HD71BXX_NUM_PINS 13
486 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
487 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
488 0x00, 0x14, 0x18, 0x19, 0x1e,
491 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
492 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
493 0x0f, 0x14, 0x18, 0x19, 0x1e,
497 static hda_nid_t stac927x_pin_nids[14] = {
498 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
499 0x0f, 0x10, 0x11, 0x12, 0x13,
500 0x14, 0x21, 0x22, 0x23,
503 static hda_nid_t stac9205_pin_nids[12] = {
504 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
505 0x0f, 0x14, 0x16, 0x17, 0x18,
509 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
511 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
512 struct snd_ctl_elem_value *ucontrol)
514 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
515 struct sigmatel_spec *spec = codec->spec;
516 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
518 kcontrol->private_value ^= get_amp_nid(kcontrol);
519 kcontrol->private_value |= nid;
521 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
524 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 struct sigmatel_spec *spec = codec->spec;
529 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
531 kcontrol->private_value ^= get_amp_nid(kcontrol);
532 kcontrol->private_value |= nid;
534 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
537 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
538 struct snd_ctl_elem_info *uinfo)
540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
541 struct sigmatel_spec *spec = codec->spec;
542 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
545 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
546 struct snd_ctl_elem_value *ucontrol)
548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
549 struct sigmatel_spec *spec = codec->spec;
550 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
552 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
556 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
557 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 dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
563 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
564 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
567 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
568 struct snd_ctl_elem_info *uinfo)
570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
571 struct sigmatel_spec *spec = codec->spec;
572 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
575 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
576 struct snd_ctl_elem_value *ucontrol)
578 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
579 struct sigmatel_spec *spec = codec->spec;
580 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
582 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
586 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
587 struct snd_ctl_elem_value *ucontrol)
589 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
590 struct sigmatel_spec *spec = codec->spec;
591 struct hda_input_mux *smux = &spec->private_smux;
592 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
596 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
597 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
601 if (spec->spdif_mute) {
603 nid = spec->multiout.dig_out_nid;
605 nid = codec->slave_dig_outs[smux_idx - 1];
606 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
610 /* un/mute SPDIF out */
611 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
617 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620 struct sigmatel_spec *spec = codec->spec;
621 return snd_hda_input_mux_info(spec->input_mux, uinfo);
624 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
627 struct sigmatel_spec *spec = codec->spec;
628 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
630 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
634 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
636 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
637 struct sigmatel_spec *spec = codec->spec;
638 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
640 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
641 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
644 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
645 struct snd_ctl_elem_info *uinfo)
647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 struct sigmatel_spec *spec = codec->spec;
649 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
652 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_value *ucontrol)
655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
656 struct sigmatel_spec *spec = codec->spec;
658 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
662 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
663 struct snd_ctl_elem_value *ucontrol)
665 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
666 struct sigmatel_spec *spec = codec->spec;
668 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
669 spec->mono_nid, &spec->cur_mmux);
672 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_info *uinfo)
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 struct sigmatel_spec *spec = codec->spec;
677 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
680 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
681 struct snd_ctl_elem_value *ucontrol)
683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
684 struct sigmatel_spec *spec = codec->spec;
686 ucontrol->value.enumerated.item[0] = spec->cur_amux;
690 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
691 struct snd_ctl_elem_value *ucontrol)
693 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
694 struct sigmatel_spec *spec = codec->spec;
695 struct snd_kcontrol *ctl =
696 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
700 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
701 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
703 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
707 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
709 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
710 struct snd_ctl_elem_value *ucontrol)
712 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
713 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
714 struct sigmatel_spec *spec = codec->spec;
716 ucontrol->value.integer.value[0] = !!(spec->aloopback &
717 (spec->aloopback_mask << idx));
721 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
722 struct snd_ctl_elem_value *ucontrol)
724 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
725 struct sigmatel_spec *spec = codec->spec;
726 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
727 unsigned int dac_mode;
728 unsigned int val, idx_val;
730 idx_val = spec->aloopback_mask << idx;
731 if (ucontrol->value.integer.value[0])
732 val = spec->aloopback | idx_val;
734 val = spec->aloopback & ~idx_val;
735 if (spec->aloopback == val)
738 spec->aloopback = val;
740 /* Only return the bits defined by the shift value of the
741 * first two bytes of the mask
743 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
744 kcontrol->private_value & 0xFFFF, 0x0);
745 dac_mode >>= spec->aloopback_shift;
747 if (spec->aloopback & idx_val) {
748 snd_hda_power_up(codec);
751 snd_hda_power_down(codec);
752 dac_mode &= ~idx_val;
755 snd_hda_codec_write_cache(codec, codec->afg, 0,
756 kcontrol->private_value >> 16, dac_mode);
761 static struct hda_verb stac9200_core_init[] = {
762 /* set dac0mux for dac converter */
763 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
767 static struct hda_verb stac9200_eapd_init[] = {
768 /* set dac0mux for dac converter */
769 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
770 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
774 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
775 /* set master volume and direct control */
776 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
777 /* setup adcs to point to mixer */
778 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
779 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
780 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
781 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
782 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
783 /* setup import muxs */
784 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
785 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
786 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
787 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
791 static struct hda_verb dell_eq_core_init[] = {
792 /* set master volume to max value without distortion
793 * and direct control */
794 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
795 /* setup adcs to point to mixer */
796 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
797 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
798 /* setup import muxs */
799 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
800 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
801 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
802 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
806 static struct hda_verb dell_m6_core_init[] = {
807 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
808 /* setup adcs to point to mixer */
809 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
810 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
811 /* setup import muxs */
812 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
813 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
814 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
815 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
819 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
820 /* set master volume and direct control */
821 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
822 /* setup adcs to point to mixer */
823 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
824 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
825 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
826 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
827 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
828 /* setup import muxs */
829 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
830 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
831 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
832 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
836 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
837 /* set master volume and direct control */
838 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
839 /* dac3 is connected to import3 mux */
840 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
841 /* setup adcs to point to mixer */
842 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
843 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
844 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
845 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
846 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
847 /* setup import muxs */
848 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
849 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
850 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
851 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
855 static struct hda_verb stac92hd83xxx_core_init[] = {
856 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
857 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
858 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
860 /* power state controls amps */
861 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
865 static struct hda_verb stac92hd71bxx_core_init[] = {
866 /* set master volume and direct control */
867 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
871 #define HD_DISABLE_PORTF 1
872 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
873 /* start of config #1 */
875 /* connect port 0f to audio mixer */
876 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
877 /* start of config #2 */
879 /* set master volume and direct control */
880 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
884 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
885 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
886 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
887 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
888 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
892 static struct hda_verb stac925x_core_init[] = {
893 /* set dac0mux for dac converter */
894 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
895 /* mute the master volume */
896 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
900 static struct hda_verb stac922x_core_init[] = {
901 /* set master volume and direct control */
902 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
906 static struct hda_verb d965_core_init[] = {
907 /* set master volume and direct control */
908 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
909 /* unmute node 0x1b */
910 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
911 /* select node 0x03 as DAC */
912 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
916 static struct hda_verb stac927x_core_init[] = {
917 /* set master volume and direct control */
918 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
919 /* enable analog pc beep path */
920 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
924 static struct hda_verb stac9205_core_init[] = {
925 /* set master volume and direct control */
926 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
927 /* enable analog pc beep path */
928 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
932 #define STAC_MONO_MUX \
934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
935 .name = "Mono Mux", \
937 .info = stac92xx_mono_mux_enum_info, \
938 .get = stac92xx_mono_mux_enum_get, \
939 .put = stac92xx_mono_mux_enum_put, \
942 #define STAC_AMP_MUX \
944 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
945 .name = "Amp Selector Capture Switch", \
947 .info = stac92xx_amp_mux_enum_info, \
948 .get = stac92xx_amp_mux_enum_get, \
949 .put = stac92xx_amp_mux_enum_put, \
952 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
954 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
957 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
958 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
959 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
960 .info = stac92xx_amp_volume_info, \
961 .get = stac92xx_amp_volume_get, \
962 .put = stac92xx_amp_volume_put, \
963 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
964 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
967 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
970 .name = "Analog Loopback", \
972 .info = stac92xx_aloopback_info, \
973 .get = stac92xx_aloopback_get, \
974 .put = stac92xx_aloopback_put, \
975 .private_value = verb_read | (verb_write << 16), \
978 static struct snd_kcontrol_new stac9200_mixer[] = {
979 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
980 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
981 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
982 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
986 #define DELL_M6_MIXER 6
987 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
988 /* start of config #1 */
989 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
990 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
992 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
993 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
995 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
996 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
998 /* start of config #2 */
999 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1000 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1002 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1003 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1005 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1007 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1008 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1010 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1011 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1016 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1017 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1019 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1020 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1022 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1023 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1025 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1026 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1028 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1029 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1031 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1032 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1034 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1035 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1037 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1038 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1042 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1043 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1045 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1046 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1048 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1049 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1051 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1052 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1054 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1055 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1057 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1058 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1060 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1061 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1063 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1064 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1069 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1070 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1071 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1073 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1074 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1076 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1077 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
1079 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1080 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
1082 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1083 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
1085 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1086 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
1089 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1090 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
1095 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1096 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1098 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1099 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1101 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1102 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1103 /* analog pc-beep replaced with digital beep support */
1105 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1106 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1109 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1110 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1112 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1113 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1115 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1116 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1118 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1119 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1123 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1124 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1126 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1127 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1129 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1134 static struct snd_kcontrol_new stac925x_mixer[] = {
1135 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1136 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1137 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1138 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1142 static struct snd_kcontrol_new stac9205_mixer[] = {
1143 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1145 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1146 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1148 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1149 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1153 /* This needs to be generated dynamically based on sequence */
1154 static struct snd_kcontrol_new stac922x_mixer[] = {
1155 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1156 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1158 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1159 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1164 static struct snd_kcontrol_new stac927x_mixer[] = {
1165 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1167 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1168 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1170 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1171 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1173 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1174 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1178 static struct snd_kcontrol_new stac_dmux_mixer = {
1179 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1180 .name = "Digital Input Source",
1181 /* count set later */
1182 .info = stac92xx_dmux_enum_info,
1183 .get = stac92xx_dmux_enum_get,
1184 .put = stac92xx_dmux_enum_put,
1187 static struct snd_kcontrol_new stac_smux_mixer = {
1188 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1189 .name = "IEC958 Playback Source",
1190 /* count set later */
1191 .info = stac92xx_smux_enum_info,
1192 .get = stac92xx_smux_enum_get,
1193 .put = stac92xx_smux_enum_put,
1196 static const char *slave_vols[] = {
1197 "Front Playback Volume",
1198 "Surround Playback Volume",
1199 "Center Playback Volume",
1200 "LFE Playback Volume",
1201 "Side Playback Volume",
1202 "Headphone Playback Volume",
1203 "Headphone Playback Volume",
1204 "Speaker Playback Volume",
1205 "External Speaker Playback Volume",
1206 "Speaker2 Playback Volume",
1210 static const char *slave_sws[] = {
1211 "Front Playback Switch",
1212 "Surround Playback Switch",
1213 "Center Playback Switch",
1214 "LFE Playback Switch",
1215 "Side Playback Switch",
1216 "Headphone Playback Switch",
1217 "Headphone Playback Switch",
1218 "Speaker Playback Switch",
1219 "External Speaker Playback Switch",
1220 "Speaker2 Playback Switch",
1221 "IEC958 Playback Switch",
1225 static void stac92xx_free_kctls(struct hda_codec *codec);
1226 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1228 static int stac92xx_build_controls(struct hda_codec *codec)
1230 struct sigmatel_spec *spec = codec->spec;
1231 struct auto_pin_cfg *cfg = &spec->autocfg;
1236 err = snd_hda_add_new_ctls(codec, spec->mixer);
1240 for (i = 0; i < spec->num_mixers; i++) {
1241 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1245 if (spec->num_dmuxes > 0) {
1246 stac_dmux_mixer.count = spec->num_dmuxes;
1247 err = snd_hda_ctl_add(codec,
1248 snd_ctl_new1(&stac_dmux_mixer, codec));
1252 if (spec->num_smuxes > 0) {
1253 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1254 struct hda_input_mux *smux = &spec->private_smux;
1255 /* check for mute support on SPDIF out */
1256 if (wcaps & AC_WCAP_OUT_AMP) {
1257 smux->items[smux->num_items].label = "Off";
1258 smux->items[smux->num_items].index = 0;
1260 spec->spdif_mute = 1;
1262 stac_smux_mixer.count = spec->num_smuxes;
1263 err = snd_hda_ctl_add(codec,
1264 snd_ctl_new1(&stac_smux_mixer, codec));
1269 if (spec->multiout.dig_out_nid) {
1270 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1273 err = snd_hda_create_spdif_share_sw(codec,
1277 spec->multiout.share_spdif = 1;
1279 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1280 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1285 /* if we have no master control, let's create it */
1286 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1287 unsigned int vmaster_tlv[4];
1288 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1289 HDA_OUTPUT, vmaster_tlv);
1290 /* correct volume offset */
1291 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1292 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1293 vmaster_tlv, slave_vols);
1297 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1298 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1304 stac92xx_free_kctls(codec); /* no longer needed */
1306 /* create jack input elements */
1307 if (spec->hp_detect) {
1308 for (i = 0; i < cfg->hp_outs; i++) {
1309 int type = SND_JACK_HEADPHONE;
1310 nid = cfg->hp_pins[i];
1311 /* jack detection */
1312 if (cfg->hp_outs == i)
1313 type |= SND_JACK_LINEOUT;
1314 err = stac92xx_add_jack(codec, nid, type);
1319 for (i = 0; i < cfg->line_outs; i++) {
1320 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1325 for (i = 0; i < AUTO_PIN_LAST; i++) {
1326 nid = cfg->input_pins[i];
1328 err = stac92xx_add_jack(codec, nid,
1329 SND_JACK_MICROPHONE);
1338 static unsigned int ref9200_pin_configs[8] = {
1339 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1340 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1343 static unsigned int gateway9200_m4_pin_configs[8] = {
1344 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1345 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1347 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1348 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1349 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1353 STAC 9200 pin configs for
1358 static unsigned int dell9200_d21_pin_configs[8] = {
1359 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1360 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1364 STAC 9200 pin configs for
1368 static unsigned int dell9200_d22_pin_configs[8] = {
1369 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1370 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1374 STAC 9200 pin configs for
1375 102801C4 (Dell Dimension E310)
1382 static unsigned int dell9200_d23_pin_configs[8] = {
1383 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1384 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1389 STAC 9200-32 pin configs for
1390 102801B5 (Dell Inspiron 630m)
1391 102801D8 (Dell Inspiron 640m)
1393 static unsigned int dell9200_m21_pin_configs[8] = {
1394 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1395 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1399 STAC 9200-32 pin configs for
1400 102801C2 (Dell Latitude D620)
1402 102801CC (Dell Latitude D820)
1406 static unsigned int dell9200_m22_pin_configs[8] = {
1407 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1408 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1412 STAC 9200-32 pin configs for
1413 102801CE (Dell XPS M1710)
1414 102801CF (Dell Precision M90)
1416 static unsigned int dell9200_m23_pin_configs[8] = {
1417 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1418 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1422 STAC 9200-32 pin configs for
1425 102801CB (Dell Latitude 120L)
1428 static unsigned int dell9200_m24_pin_configs[8] = {
1429 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1430 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1434 STAC 9200-32 pin configs for
1435 102801BD (Dell Inspiron E1505n)
1439 static unsigned int dell9200_m25_pin_configs[8] = {
1440 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1441 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1445 STAC 9200-32 pin configs for
1446 102801F5 (Dell Inspiron 1501)
1449 static unsigned int dell9200_m26_pin_configs[8] = {
1450 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1451 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1456 102801CD (Dell Inspiron E1705/9400)
1458 static unsigned int dell9200_m27_pin_configs[8] = {
1459 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1460 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1463 static unsigned int oqo9200_pin_configs[8] = {
1464 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1465 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1469 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1470 [STAC_REF] = ref9200_pin_configs,
1471 [STAC_9200_OQO] = oqo9200_pin_configs,
1472 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1473 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1474 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1475 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1476 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1477 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1478 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1479 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1480 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1481 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1482 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1483 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1484 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1487 static const char *stac9200_models[STAC_9200_MODELS] = {
1489 [STAC_9200_OQO] = "oqo",
1490 [STAC_9200_DELL_D21] = "dell-d21",
1491 [STAC_9200_DELL_D22] = "dell-d22",
1492 [STAC_9200_DELL_D23] = "dell-d23",
1493 [STAC_9200_DELL_M21] = "dell-m21",
1494 [STAC_9200_DELL_M22] = "dell-m22",
1495 [STAC_9200_DELL_M23] = "dell-m23",
1496 [STAC_9200_DELL_M24] = "dell-m24",
1497 [STAC_9200_DELL_M25] = "dell-m25",
1498 [STAC_9200_DELL_M26] = "dell-m26",
1499 [STAC_9200_DELL_M27] = "dell-m27",
1500 [STAC_9200_M4] = "gateway-m4",
1501 [STAC_9200_M4_2] = "gateway-m4-2",
1502 [STAC_9200_PANASONIC] = "panasonic",
1505 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1506 /* SigmaTel reference board */
1507 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1508 "DFI LanParty", STAC_REF),
1509 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1510 "DFI LanParty", STAC_REF),
1511 /* Dell laptops have BIOS problem */
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1513 "unknown Dell", STAC_9200_DELL_D21),
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1515 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1517 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1519 "unknown Dell", STAC_9200_DELL_D22),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1521 "unknown Dell", STAC_9200_DELL_D22),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1523 "Dell Latitude D620", STAC_9200_DELL_M22),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1525 "unknown Dell", STAC_9200_DELL_D23),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1527 "unknown Dell", STAC_9200_DELL_D23),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1529 "unknown Dell", STAC_9200_DELL_M22),
1530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1531 "unknown Dell", STAC_9200_DELL_M24),
1532 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1533 "unknown Dell", STAC_9200_DELL_M24),
1534 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1535 "Dell Latitude 120L", STAC_9200_DELL_M24),
1536 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1537 "Dell Latitude D820", STAC_9200_DELL_M22),
1538 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1539 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1540 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1541 "Dell XPS M1710", STAC_9200_DELL_M23),
1542 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1543 "Dell Precision M90", STAC_9200_DELL_M23),
1544 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1545 "unknown Dell", STAC_9200_DELL_M22),
1546 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1547 "unknown Dell", STAC_9200_DELL_M22),
1548 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1549 "unknown Dell", STAC_9200_DELL_M22),
1550 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1551 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1552 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1553 "unknown Dell", STAC_9200_DELL_D23),
1554 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1555 "unknown Dell", STAC_9200_DELL_D23),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1557 "unknown Dell", STAC_9200_DELL_D21),
1558 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1559 "unknown Dell", STAC_9200_DELL_D23),
1560 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1561 "unknown Dell", STAC_9200_DELL_D21),
1562 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1563 "unknown Dell", STAC_9200_DELL_M25),
1564 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1565 "unknown Dell", STAC_9200_DELL_M25),
1566 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1567 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1568 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1569 "unknown Dell", STAC_9200_DELL_M26),
1571 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1572 /* Gateway machines needs EAPD to be set on resume */
1573 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1574 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1575 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1577 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1581 static unsigned int ref925x_pin_configs[8] = {
1582 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1583 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1586 static unsigned int stac925xM1_pin_configs[8] = {
1587 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1588 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1591 static unsigned int stac925xM1_2_pin_configs[8] = {
1592 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1593 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1596 static unsigned int stac925xM2_pin_configs[8] = {
1597 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1598 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1601 static unsigned int stac925xM2_2_pin_configs[8] = {
1602 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1603 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1606 static unsigned int stac925xM3_pin_configs[8] = {
1607 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1608 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1611 static unsigned int stac925xM5_pin_configs[8] = {
1612 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1613 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1616 static unsigned int stac925xM6_pin_configs[8] = {
1617 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1618 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1621 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1622 [STAC_REF] = ref925x_pin_configs,
1623 [STAC_M1] = stac925xM1_pin_configs,
1624 [STAC_M1_2] = stac925xM1_2_pin_configs,
1625 [STAC_M2] = stac925xM2_pin_configs,
1626 [STAC_M2_2] = stac925xM2_2_pin_configs,
1627 [STAC_M3] = stac925xM3_pin_configs,
1628 [STAC_M5] = stac925xM5_pin_configs,
1629 [STAC_M6] = stac925xM6_pin_configs,
1632 static const char *stac925x_models[STAC_925x_MODELS] = {
1635 [STAC_M1_2] = "m1-2",
1637 [STAC_M2_2] = "m2-2",
1643 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1644 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1645 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1646 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1647 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1648 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1649 /* Not sure about the brand name for those */
1650 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1651 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1652 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1653 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1657 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1658 /* SigmaTel reference board */
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1660 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1661 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1663 /* Default table for unknown ID */
1664 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1669 static unsigned int ref92hd73xx_pin_configs[13] = {
1670 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1671 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1672 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1676 static unsigned int dell_m6_pin_configs[13] = {
1677 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1678 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1679 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1683 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1684 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1685 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1686 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1687 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1688 [STAC_DELL_EQ] = dell_m6_pin_configs,
1691 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1692 [STAC_92HD73XX_NO_JD] = "no-jd",
1693 [STAC_92HD73XX_REF] = "ref",
1694 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1695 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1696 [STAC_DELL_M6_BOTH] = "dell-m6",
1697 [STAC_DELL_EQ] = "dell-eq",
1700 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1701 /* SigmaTel reference board */
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1703 "DFI LanParty", STAC_92HD73XX_REF),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1705 "DFI LanParty", STAC_92HD73XX_REF),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1707 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1709 "unknown Dell", STAC_DELL_M6_DMIC),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1711 "unknown Dell", STAC_DELL_M6_BOTH),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1713 "unknown Dell", STAC_DELL_M6_BOTH),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1715 "unknown Dell", STAC_DELL_M6_AMIC),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1717 "unknown Dell", STAC_DELL_M6_AMIC),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1719 "unknown Dell", STAC_DELL_M6_DMIC),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1721 "unknown Dell", STAC_DELL_M6_DMIC),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1723 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1725 "Dell Studio 17", STAC_DELL_M6_DMIC),
1729 static unsigned int ref92hd83xxx_pin_configs[14] = {
1730 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1731 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1732 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1733 0x01451160, 0x98560170,
1736 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1737 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1738 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1741 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1742 [STAC_92HD83XXX_REF] = "ref",
1743 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1746 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1747 /* SigmaTel reference board */
1748 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1749 "DFI LanParty", STAC_92HD83XXX_REF),
1750 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1751 "DFI LanParty", STAC_92HD83XXX_REF),
1755 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1756 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1757 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1758 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1762 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1763 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1764 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1765 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1769 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1770 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1771 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1772 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1776 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1777 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1778 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1779 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1783 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1784 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1785 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1786 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1787 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1788 [STAC_HP_M4] = NULL,
1789 [STAC_HP_DV5] = NULL,
1792 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1793 [STAC_92HD71BXX_REF] = "ref",
1794 [STAC_DELL_M4_1] = "dell-m4-1",
1795 [STAC_DELL_M4_2] = "dell-m4-2",
1796 [STAC_DELL_M4_3] = "dell-m4-3",
1797 [STAC_HP_M4] = "hp-m4",
1798 [STAC_HP_DV5] = "hp-dv5",
1801 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1802 /* SigmaTel reference board */
1803 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1804 "DFI LanParty", STAC_92HD71BXX_REF),
1805 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1806 "DFI LanParty", STAC_92HD71BXX_REF),
1807 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1808 "HP dv5", STAC_HP_M4),
1809 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1810 "HP dv7", STAC_HP_M4),
1811 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f7,
1812 "HP dv4", STAC_HP_DV5),
1813 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc,
1814 "HP dv7", STAC_HP_M4),
1815 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3600,
1816 "HP dv5", STAC_HP_DV5),
1817 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603,
1818 "HP dv5", STAC_HP_DV5),
1819 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1820 "unknown HP", STAC_HP_M4),
1821 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1822 "unknown Dell", STAC_DELL_M4_1),
1823 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1824 "unknown Dell", STAC_DELL_M4_1),
1825 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1826 "unknown Dell", STAC_DELL_M4_1),
1827 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1828 "unknown Dell", STAC_DELL_M4_1),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1830 "unknown Dell", STAC_DELL_M4_1),
1831 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1832 "unknown Dell", STAC_DELL_M4_1),
1833 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1834 "unknown Dell", STAC_DELL_M4_1),
1835 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1836 "unknown Dell", STAC_DELL_M4_2),
1837 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1838 "unknown Dell", STAC_DELL_M4_2),
1839 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1840 "unknown Dell", STAC_DELL_M4_2),
1841 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1842 "unknown Dell", STAC_DELL_M4_2),
1843 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1844 "unknown Dell", STAC_DELL_M4_3),
1848 static unsigned int ref922x_pin_configs[10] = {
1849 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1850 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1851 0x40000100, 0x40000100,
1855 STAC 922X pin configs for
1862 static unsigned int dell_922x_d81_pin_configs[10] = {
1863 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1864 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1865 0x01813122, 0x400001f2,
1869 STAC 922X pin configs for
1873 static unsigned int dell_922x_d82_pin_configs[10] = {
1874 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1875 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1876 0x01813122, 0x400001f1,
1880 STAC 922X pin configs for
1883 static unsigned int dell_922x_m81_pin_configs[10] = {
1884 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1885 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1886 0x40C003f1, 0x405003f0,
1890 STAC 9221 A1 pin configs for
1891 102801D7 (Dell XPS M1210)
1893 static unsigned int dell_922x_m82_pin_configs[10] = {
1894 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1895 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1896 0x508003f3, 0x405003f4,
1899 static unsigned int d945gtp3_pin_configs[10] = {
1900 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1901 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1902 0x02a19120, 0x40000100,
1905 static unsigned int d945gtp5_pin_configs[10] = {
1906 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1907 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1908 0x02a19320, 0x40000100,
1911 static unsigned int intel_mac_v1_pin_configs[10] = {
1912 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1913 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1914 0x400000fc, 0x400000fb,
1917 static unsigned int intel_mac_v2_pin_configs[10] = {
1918 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1919 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1920 0x400000fc, 0x400000fb,
1923 static unsigned int intel_mac_v3_pin_configs[10] = {
1924 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1925 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1926 0x400000fc, 0x400000fb,
1929 static unsigned int intel_mac_v4_pin_configs[10] = {
1930 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1931 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1932 0x400000fc, 0x400000fb,
1935 static unsigned int intel_mac_v5_pin_configs[10] = {
1936 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1937 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1938 0x400000fc, 0x400000fb,
1941 static unsigned int ecs202_pin_configs[10] = {
1942 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1943 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1944 0x9037012e, 0x40e000f2,
1947 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1948 [STAC_D945_REF] = ref922x_pin_configs,
1949 [STAC_D945GTP3] = d945gtp3_pin_configs,
1950 [STAC_D945GTP5] = d945gtp5_pin_configs,
1951 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1952 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1953 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1954 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1955 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1956 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1957 /* for backward compatibility */
1958 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1959 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1960 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1961 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1962 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1963 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1964 [STAC_ECS_202] = ecs202_pin_configs,
1965 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1966 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1967 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1968 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1971 static const char *stac922x_models[STAC_922X_MODELS] = {
1972 [STAC_D945_REF] = "ref",
1973 [STAC_D945GTP5] = "5stack",
1974 [STAC_D945GTP3] = "3stack",
1975 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1976 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1977 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1978 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1979 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1980 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1981 /* for backward compatibility */
1982 [STAC_MACMINI] = "macmini",
1983 [STAC_MACBOOK] = "macbook",
1984 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1985 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1986 [STAC_IMAC_INTEL] = "imac-intel",
1987 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1988 [STAC_ECS_202] = "ecs202",
1989 [STAC_922X_DELL_D81] = "dell-d81",
1990 [STAC_922X_DELL_D82] = "dell-d82",
1991 [STAC_922X_DELL_M81] = "dell-m81",
1992 [STAC_922X_DELL_M82] = "dell-m82",
1995 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1996 /* SigmaTel reference board */
1997 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1998 "DFI LanParty", STAC_D945_REF),
1999 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2000 "DFI LanParty", STAC_D945_REF),
2001 /* Intel 945G based systems */
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2003 "Intel D945G", STAC_D945GTP3),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2005 "Intel D945G", STAC_D945GTP3),
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2007 "Intel D945G", STAC_D945GTP3),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2009 "Intel D945G", STAC_D945GTP3),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2011 "Intel D945G", STAC_D945GTP3),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2013 "Intel D945G", STAC_D945GTP3),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2015 "Intel D945G", STAC_D945GTP3),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2017 "Intel D945G", STAC_D945GTP3),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2019 "Intel D945G", STAC_D945GTP3),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2021 "Intel D945G", STAC_D945GTP3),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2023 "Intel D945G", STAC_D945GTP3),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2025 "Intel D945G", STAC_D945GTP3),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2027 "Intel D945G", STAC_D945GTP3),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2029 "Intel D945G", STAC_D945GTP3),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2031 "Intel D945G", STAC_D945GTP3),
2032 /* Intel D945G 5-stack systems */
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2034 "Intel D945G", STAC_D945GTP5),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2036 "Intel D945G", STAC_D945GTP5),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2038 "Intel D945G", STAC_D945GTP5),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2040 "Intel D945G", STAC_D945GTP5),
2041 /* Intel 945P based systems */
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2043 "Intel D945P", STAC_D945GTP3),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2045 "Intel D945P", STAC_D945GTP3),
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2047 "Intel D945P", STAC_D945GTP3),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2049 "Intel D945P", STAC_D945GTP3),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2051 "Intel D945P", STAC_D945GTP3),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2053 "Intel D945P", STAC_D945GTP5),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2056 "Intel D945", STAC_D945_REF),
2058 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2059 SND_PCI_QUIRK(0x8384, 0x7680,
2060 "Mac", STAC_INTEL_MAC_AUTO),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2063 "unknown Dell", STAC_922X_DELL_D81),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2065 "unknown Dell", STAC_922X_DELL_D81),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2067 "unknown Dell", STAC_922X_DELL_D81),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2069 "unknown Dell", STAC_922X_DELL_D82),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2071 "unknown Dell", STAC_922X_DELL_M81),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2073 "unknown Dell", STAC_922X_DELL_D82),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2075 "unknown Dell", STAC_922X_DELL_D81),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2077 "unknown Dell", STAC_922X_DELL_D81),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2079 "Dell XPS M1210", STAC_922X_DELL_M82),
2080 /* ECS/PC Chips boards */
2081 SND_PCI_QUIRK(0x1019, 0x2144,
2082 "ECS/PC chips", STAC_ECS_202),
2083 SND_PCI_QUIRK(0x1019, 0x2608,
2084 "ECS/PC chips", STAC_ECS_202),
2085 SND_PCI_QUIRK(0x1019, 0x2633,
2086 "ECS/PC chips P17G/1333", STAC_ECS_202),
2087 SND_PCI_QUIRK(0x1019, 0x2811,
2088 "ECS/PC chips", STAC_ECS_202),
2089 SND_PCI_QUIRK(0x1019, 0x2812,
2090 "ECS/PC chips", STAC_ECS_202),
2091 SND_PCI_QUIRK(0x1019, 0x2813,
2092 "ECS/PC chips", STAC_ECS_202),
2093 SND_PCI_QUIRK(0x1019, 0x2814,
2094 "ECS/PC chips", STAC_ECS_202),
2095 SND_PCI_QUIRK(0x1019, 0x2815,
2096 "ECS/PC chips", STAC_ECS_202),
2097 SND_PCI_QUIRK(0x1019, 0x2816,
2098 "ECS/PC chips", STAC_ECS_202),
2099 SND_PCI_QUIRK(0x1019, 0x2817,
2100 "ECS/PC chips", STAC_ECS_202),
2101 SND_PCI_QUIRK(0x1019, 0x2818,
2102 "ECS/PC chips", STAC_ECS_202),
2103 SND_PCI_QUIRK(0x1019, 0x2819,
2104 "ECS/PC chips", STAC_ECS_202),
2105 SND_PCI_QUIRK(0x1019, 0x2820,
2106 "ECS/PC chips", STAC_ECS_202),
2110 static unsigned int ref927x_pin_configs[14] = {
2111 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2112 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2113 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2114 0x01c42190, 0x40000100,
2117 static unsigned int d965_3st_pin_configs[14] = {
2118 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2119 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2120 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2121 0x40000100, 0x40000100
2124 static unsigned int d965_5st_pin_configs[14] = {
2125 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2126 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2127 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2128 0x40000100, 0x40000100
2131 static unsigned int dell_3st_pin_configs[14] = {
2132 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2133 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2134 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2135 0x40c003fc, 0x40000100
2138 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2139 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2140 [STAC_D965_REF] = ref927x_pin_configs,
2141 [STAC_D965_3ST] = d965_3st_pin_configs,
2142 [STAC_D965_5ST] = d965_5st_pin_configs,
2143 [STAC_DELL_3ST] = dell_3st_pin_configs,
2144 [STAC_DELL_BIOS] = NULL,
2147 static const char *stac927x_models[STAC_927X_MODELS] = {
2148 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2149 [STAC_D965_REF] = "ref",
2150 [STAC_D965_3ST] = "3stack",
2151 [STAC_D965_5ST] = "5stack",
2152 [STAC_DELL_3ST] = "dell-3stack",
2153 [STAC_DELL_BIOS] = "dell-bios",
2156 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2157 /* SigmaTel reference board */
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2159 "DFI LanParty", STAC_D965_REF),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2161 "DFI LanParty", STAC_D965_REF),
2162 /* Intel 946 based systems */
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2165 /* 965 based 3 stack systems */
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2179 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2181 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
2182 /* Dell 3 stack systems */
2183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2185 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2187 /* Dell 3 stack systems with verb table in BIOS */
2188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2189 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2191 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2192 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2193 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2195 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2196 /* 965 based 5 stack systems */
2197 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2198 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2199 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2200 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2201 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2202 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2203 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2204 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2205 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
2209 static unsigned int ref9205_pin_configs[12] = {
2210 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2211 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2212 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2216 STAC 9205 pin configs for
2223 10280228 (Dell Vostro 1500)
2225 static unsigned int dell_9205_m42_pin_configs[12] = {
2226 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2227 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2228 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2232 STAC 9205 pin configs for
2236 102801FF (Dell Precision M4300)
2241 static unsigned int dell_9205_m43_pin_configs[12] = {
2242 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2243 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2244 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2247 static unsigned int dell_9205_m44_pin_configs[12] = {
2248 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2249 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2250 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2253 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2254 [STAC_9205_REF] = ref9205_pin_configs,
2255 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2256 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2257 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2258 [STAC_9205_EAPD] = NULL,
2261 static const char *stac9205_models[STAC_9205_MODELS] = {
2262 [STAC_9205_REF] = "ref",
2263 [STAC_9205_DELL_M42] = "dell-m42",
2264 [STAC_9205_DELL_M43] = "dell-m43",
2265 [STAC_9205_DELL_M44] = "dell-m44",
2266 [STAC_9205_EAPD] = "eapd",
2269 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2270 /* SigmaTel reference board */
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2272 "DFI LanParty", STAC_9205_REF),
2273 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2274 "DFI LanParty", STAC_9205_REF),
2276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2277 "unknown Dell", STAC_9205_DELL_M42),
2278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2279 "unknown Dell", STAC_9205_DELL_M42),
2280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2281 "Dell Precision", STAC_9205_DELL_M43),
2282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2283 "Dell Precision", STAC_9205_DELL_M43),
2284 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2285 "Dell Precision", STAC_9205_DELL_M43),
2286 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2287 "unknown Dell", STAC_9205_DELL_M42),
2288 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2289 "unknown Dell", STAC_9205_DELL_M42),
2290 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2291 "Dell Precision", STAC_9205_DELL_M43),
2292 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2293 "Dell Precision M4300", STAC_9205_DELL_M43),
2294 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2295 "unknown Dell", STAC_9205_DELL_M42),
2296 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2297 "Dell Precision", STAC_9205_DELL_M43),
2298 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2299 "Dell Precision", STAC_9205_DELL_M43),
2300 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2301 "Dell Precision", STAC_9205_DELL_M43),
2302 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2303 "Dell Inspiron", STAC_9205_DELL_M44),
2304 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2305 "Dell Vostro 1500", STAC_9205_DELL_M42),
2307 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2311 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2314 struct sigmatel_spec *spec = codec->spec;
2316 kfree(spec->pin_configs);
2317 spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs),
2319 if (!spec->pin_configs)
2322 for (i = 0; i < spec->num_pins; i++) {
2323 hda_nid_t nid = spec->pin_nids[i];
2324 unsigned int pin_cfg;
2328 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2329 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2330 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2332 spec->pin_configs[i] = pin_cfg;
2338 static void stac92xx_set_config_reg(struct hda_codec *codec,
2339 hda_nid_t pin_nid, unsigned int pin_config)
2342 snd_hda_codec_write(codec, pin_nid, 0,
2343 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2344 pin_config & 0x000000ff);
2345 snd_hda_codec_write(codec, pin_nid, 0,
2346 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2347 (pin_config & 0x0000ff00) >> 8);
2348 snd_hda_codec_write(codec, pin_nid, 0,
2349 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2350 (pin_config & 0x00ff0000) >> 16);
2351 snd_hda_codec_write(codec, pin_nid, 0,
2352 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2354 i = snd_hda_codec_read(codec, pin_nid, 0,
2355 AC_VERB_GET_CONFIG_DEFAULT,
2357 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2361 static void stac92xx_set_config_regs(struct hda_codec *codec)
2364 struct sigmatel_spec *spec = codec->spec;
2366 if (!spec->pin_configs)
2369 for (i = 0; i < spec->num_pins; i++)
2370 if (spec->pin_nids[i] && spec->pin_configs[i])
2371 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2372 spec->pin_configs[i]);
2375 static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
2377 struct sigmatel_spec *spec = codec->spec;
2380 return stac92xx_save_bios_config_regs(codec);
2382 kfree(spec->pin_configs);
2383 spec->pin_configs = kmemdup(pins,
2384 spec->num_pins * sizeof(*pins),
2386 if (!spec->pin_configs)
2389 stac92xx_set_config_regs(codec);
2393 static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid,
2396 struct sigmatel_spec *spec = codec->spec;
2399 for (i = 0; i < spec->num_pins; i++) {
2400 if (spec->pin_nids[i] == nid) {
2401 spec->pin_configs[i] = cfg;
2402 stac92xx_set_config_reg(codec, nid, cfg);
2409 * Analog playback callbacks
2411 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2412 struct hda_codec *codec,
2413 struct snd_pcm_substream *substream)
2415 struct sigmatel_spec *spec = codec->spec;
2416 if (spec->stream_delay)
2417 msleep(spec->stream_delay);
2418 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2422 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2423 struct hda_codec *codec,
2424 unsigned int stream_tag,
2425 unsigned int format,
2426 struct snd_pcm_substream *substream)
2428 struct sigmatel_spec *spec = codec->spec;
2429 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2432 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2433 struct hda_codec *codec,
2434 struct snd_pcm_substream *substream)
2436 struct sigmatel_spec *spec = codec->spec;
2437 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2441 * Digital playback callbacks
2443 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2444 struct hda_codec *codec,
2445 struct snd_pcm_substream *substream)
2447 struct sigmatel_spec *spec = codec->spec;
2448 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2451 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2452 struct hda_codec *codec,
2453 struct snd_pcm_substream *substream)
2455 struct sigmatel_spec *spec = codec->spec;
2456 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2459 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2460 struct hda_codec *codec,
2461 unsigned int stream_tag,
2462 unsigned int format,
2463 struct snd_pcm_substream *substream)
2465 struct sigmatel_spec *spec = codec->spec;
2466 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2467 stream_tag, format, substream);
2472 * Analog capture callbacks
2474 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2475 struct hda_codec *codec,
2476 unsigned int stream_tag,
2477 unsigned int format,
2478 struct snd_pcm_substream *substream)
2480 struct sigmatel_spec *spec = codec->spec;
2481 hda_nid_t nid = spec->adc_nids[substream->number];
2483 if (spec->powerdown_adcs) {
2485 snd_hda_codec_write(codec, nid, 0,
2486 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2488 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2492 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2493 struct hda_codec *codec,
2494 struct snd_pcm_substream *substream)
2496 struct sigmatel_spec *spec = codec->spec;
2497 hda_nid_t nid = spec->adc_nids[substream->number];
2499 snd_hda_codec_cleanup_stream(codec, nid);
2500 if (spec->powerdown_adcs)
2501 snd_hda_codec_write(codec, nid, 0,
2502 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2506 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2510 /* NID is set in stac92xx_build_pcms */
2512 .open = stac92xx_dig_playback_pcm_open,
2513 .close = stac92xx_dig_playback_pcm_close,
2514 .prepare = stac92xx_dig_playback_pcm_prepare
2518 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2522 /* NID is set in stac92xx_build_pcms */
2525 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2529 .nid = 0x02, /* NID to query formats and rates */
2531 .open = stac92xx_playback_pcm_open,
2532 .prepare = stac92xx_playback_pcm_prepare,
2533 .cleanup = stac92xx_playback_pcm_cleanup
2537 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2541 .nid = 0x06, /* NID to query formats and rates */
2543 .open = stac92xx_playback_pcm_open,
2544 .prepare = stac92xx_playback_pcm_prepare,
2545 .cleanup = stac92xx_playback_pcm_cleanup
2549 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2552 /* NID + .substreams is set in stac92xx_build_pcms */
2554 .prepare = stac92xx_capture_pcm_prepare,
2555 .cleanup = stac92xx_capture_pcm_cleanup
2559 static int stac92xx_build_pcms(struct hda_codec *codec)
2561 struct sigmatel_spec *spec = codec->spec;
2562 struct hda_pcm *info = spec->pcm_rec;
2564 codec->num_pcms = 1;
2565 codec->pcm_info = info;
2567 info->name = "STAC92xx Analog";
2568 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2569 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2570 spec->multiout.dac_nids[0];
2571 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2572 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2573 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2575 if (spec->alt_switch) {
2578 info->name = "STAC92xx Analog Alt";
2579 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2582 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2585 info->name = "STAC92xx Digital";
2586 info->pcm_type = spec->autocfg.dig_out_type;
2587 if (spec->multiout.dig_out_nid) {
2588 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2589 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2591 if (spec->dig_in_nid) {
2592 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2593 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2600 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2602 unsigned int pincap = snd_hda_param_read(codec, nid,
2604 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2605 if (pincap & AC_PINCAP_VREF_100)
2606 return AC_PINCTL_VREF_100;
2607 if (pincap & AC_PINCAP_VREF_80)
2608 return AC_PINCTL_VREF_80;
2609 if (pincap & AC_PINCAP_VREF_50)
2610 return AC_PINCTL_VREF_50;
2611 if (pincap & AC_PINCAP_VREF_GRD)
2612 return AC_PINCTL_VREF_GRD;
2616 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2619 snd_hda_codec_write_cache(codec, nid, 0,
2620 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2623 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2625 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2626 struct snd_ctl_elem_value *ucontrol)
2628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2629 struct sigmatel_spec *spec = codec->spec;
2631 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2635 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2636 unsigned char type);
2638 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2639 struct snd_ctl_elem_value *ucontrol)
2641 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2642 struct sigmatel_spec *spec = codec->spec;
2643 int nid = kcontrol->private_value;
2645 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2647 /* check to be sure that the ports are upto date with
2650 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2655 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2657 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2660 struct sigmatel_spec *spec = codec->spec;
2661 int io_idx = kcontrol-> private_value & 0xff;
2663 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2667 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2669 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2670 struct sigmatel_spec *spec = codec->spec;
2671 hda_nid_t nid = kcontrol->private_value >> 8;
2672 int io_idx = kcontrol-> private_value & 0xff;
2673 unsigned short val = !!ucontrol->value.integer.value[0];
2675 spec->io_switch[io_idx] = val;
2678 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2680 unsigned int pinctl = AC_PINCTL_IN_EN;
2681 if (io_idx) /* set VREF for mic */
2682 pinctl |= stac92xx_get_vref(codec, nid);
2683 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2686 /* check the auto-mute again: we need to mute/unmute the speaker
2687 * appropriately according to the pin direction
2689 if (spec->hp_detect)
2690 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2695 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2697 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2698 struct snd_ctl_elem_value *ucontrol)
2700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2701 struct sigmatel_spec *spec = codec->spec;
2703 ucontrol->value.integer.value[0] = spec->clfe_swap;
2707 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2708 struct snd_ctl_elem_value *ucontrol)
2710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2711 struct sigmatel_spec *spec = codec->spec;
2712 hda_nid_t nid = kcontrol->private_value & 0xff;
2713 unsigned int val = !!ucontrol->value.integer.value[0];
2715 if (spec->clfe_swap == val)
2718 spec->clfe_swap = val;
2720 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2721 spec->clfe_swap ? 0x4 : 0x0);
2726 #define STAC_CODEC_HP_SWITCH(xname) \
2727 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2730 .info = stac92xx_hp_switch_info, \
2731 .get = stac92xx_hp_switch_get, \
2732 .put = stac92xx_hp_switch_put, \
2735 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2736 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2739 .info = stac92xx_io_switch_info, \
2740 .get = stac92xx_io_switch_get, \
2741 .put = stac92xx_io_switch_put, \
2742 .private_value = xpval, \
2745 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2746 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2749 .info = stac92xx_clfe_switch_info, \
2750 .get = stac92xx_clfe_switch_get, \
2751 .put = stac92xx_clfe_switch_put, \
2752 .private_value = xpval, \
2756 STAC_CTL_WIDGET_VOL,
2757 STAC_CTL_WIDGET_MUTE,
2758 STAC_CTL_WIDGET_MONO_MUX,
2759 STAC_CTL_WIDGET_AMP_MUX,
2760 STAC_CTL_WIDGET_AMP_VOL,
2761 STAC_CTL_WIDGET_HP_SWITCH,
2762 STAC_CTL_WIDGET_IO_SWITCH,
2763 STAC_CTL_WIDGET_CLFE_SWITCH
2766 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2767 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2768 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2771 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2772 STAC_CODEC_HP_SWITCH(NULL),
2773 STAC_CODEC_IO_SWITCH(NULL, 0),
2774 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2777 /* add dynamic controls */
2778 static struct snd_kcontrol_new *
2779 stac_control_new(struct sigmatel_spec *spec,
2780 struct snd_kcontrol_new *ktemp,
2783 struct snd_kcontrol_new *knew;
2785 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2786 knew = snd_array_new(&spec->kctls);
2790 knew->name = kstrdup(name, GFP_KERNEL);
2793 memset(knew, 0, sizeof(*knew));
2794 spec->kctls.alloced--;
2800 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2801 struct snd_kcontrol_new *ktemp,
2802 int idx, const char *name,
2805 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2809 knew->private_value = val;
2813 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2814 int type, int idx, const char *name,
2817 return stac92xx_add_control_temp(spec,
2818 &stac92xx_control_templates[type],
2823 /* add dynamic controls */
2824 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2825 const char *name, unsigned long val)
2827 return stac92xx_add_control_idx(spec, type, 0, name, val);
2830 static struct snd_kcontrol_new stac_input_src_temp = {
2831 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2832 .name = "Input Source",
2833 .info = stac92xx_mux_enum_info,
2834 .get = stac92xx_mux_enum_get,
2835 .put = stac92xx_mux_enum_put,
2838 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2840 struct snd_kcontrol_new *knew;
2841 struct hda_input_mux *imux = &spec->private_imux;
2843 if (!spec->num_adcs || imux->num_items <= 1)
2844 return 0; /* no need for input source control */
2845 knew = stac_control_new(spec, &stac_input_src_temp,
2846 stac_input_src_temp.name);
2849 knew->count = spec->num_adcs;
2853 /* check whether the line-input can be used as line-out */
2854 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2856 struct sigmatel_spec *spec = codec->spec;
2857 struct auto_pin_cfg *cfg = &spec->autocfg;
2859 unsigned int pincap;
2861 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2863 nid = cfg->input_pins[AUTO_PIN_LINE];
2864 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2865 if (pincap & AC_PINCAP_OUT)
2870 /* check whether the mic-input can be used as line-out */
2871 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2873 struct sigmatel_spec *spec = codec->spec;
2874 struct auto_pin_cfg *cfg = &spec->autocfg;
2875 unsigned int def_conf, pincap;
2876 unsigned int mic_pin;
2878 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2880 mic_pin = AUTO_PIN_MIC;
2882 hda_nid_t nid = cfg->input_pins[mic_pin];
2883 def_conf = snd_hda_codec_read(codec, nid, 0,
2884 AC_VERB_GET_CONFIG_DEFAULT, 0);
2885 /* some laptops have an internal analog microphone
2886 * which can't be used as a output */
2887 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2888 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2889 if (pincap & AC_PINCAP_OUT)
2892 if (mic_pin == AUTO_PIN_MIC)
2893 mic_pin = AUTO_PIN_FRONT_MIC;
2900 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2904 for (i = 0; i < spec->multiout.num_dacs; i++) {
2905 if (spec->multiout.dac_nids[i] == nid)
2912 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2915 if (is_in_dac_nids(spec, nid))
2917 for (i = 0; i < spec->autocfg.hp_outs; i++)
2918 if (spec->hp_dacs[i] == nid)
2920 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2921 if (spec->speaker_dacs[i] == nid)
2926 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2928 struct sigmatel_spec *spec = codec->spec;
2930 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2931 unsigned int wcaps, wtype;
2933 conn_len = snd_hda_get_connections(codec, nid, conn,
2934 HDA_MAX_CONNECTIONS);
2935 for (j = 0; j < conn_len; j++) {
2936 wcaps = snd_hda_param_read(codec, conn[j],
2937 AC_PAR_AUDIO_WIDGET_CAP);
2938 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2939 /* we check only analog outputs */
2940 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2942 /* if this route has a free DAC, assign it */
2943 if (!check_all_dac_nids(spec, conn[j])) {
2945 /* select this DAC in the pin's input mux */
2946 snd_hda_codec_write_cache(codec, nid, 0,
2947 AC_VERB_SET_CONNECT_SEL, j);
2955 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2956 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2959 * Fill in the dac_nids table from the parsed pin configuration
2960 * This function only works when every pin in line_out_pins[]
2961 * contains atleast one DAC in its connection list. Some 92xx
2962 * codecs are not connected directly to a DAC, such as the 9200
2963 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2965 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2967 struct sigmatel_spec *spec = codec->spec;
2968 struct auto_pin_cfg *cfg = &spec->autocfg;
2972 for (i = 0; i < cfg->line_outs; i++) {
2973 nid = cfg->line_out_pins[i];
2974 dac = get_unassigned_dac(codec, nid);
2976 if (spec->multiout.num_dacs > 0) {
2977 /* we have already working output pins,
2978 * so let's drop the broken ones again
2980 cfg->line_outs = spec->multiout.num_dacs;
2983 /* error out, no available DAC found */
2985 "%s: No available DAC for pin 0x%x\n",
2989 add_spec_dacs(spec, dac);
2992 /* add line-in as output */
2993 nid = check_line_out_switch(codec);
2995 dac = get_unassigned_dac(codec, nid);
2997 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2998 nid, cfg->line_outs);
2999 cfg->line_out_pins[cfg->line_outs] = nid;
3001 spec->line_switch = nid;
3002 add_spec_dacs(spec, dac);
3005 /* add mic as output */
3006 nid = check_mic_out_switch(codec);
3008 dac = get_unassigned_dac(codec, nid);
3010 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3011 nid, cfg->line_outs);
3012 cfg->line_out_pins[cfg->line_outs] = nid;
3014 spec->mic_switch = nid;
3015 add_spec_dacs(spec, dac);
3019 for (i = 0; i < cfg->hp_outs; i++) {
3020 nid = cfg->hp_pins[i];
3021 dac = get_unassigned_dac(codec, nid);
3023 if (!spec->multiout.hp_nid)
3024 spec->multiout.hp_nid = dac;
3026 add_spec_extra_dacs(spec, dac);
3028 spec->hp_dacs[i] = dac;
3031 for (i = 0; i < cfg->speaker_outs; i++) {
3032 nid = cfg->speaker_pins[i];
3033 dac = get_unassigned_dac(codec, nid);
3035 add_spec_extra_dacs(spec, dac);
3036 spec->speaker_dacs[i] = dac;
3039 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3040 spec->multiout.num_dacs,
3041 spec->multiout.dac_nids[0],
3042 spec->multiout.dac_nids[1],
3043 spec->multiout.dac_nids[2],
3044 spec->multiout.dac_nids[3],
3045 spec->multiout.dac_nids[4]);
3050 /* create volume control/switch for the given prefx type */
3051 static int create_controls(struct hda_codec *codec, const char *pfx,
3052 hda_nid_t nid, int chs)
3054 struct sigmatel_spec *spec = codec->spec;
3058 if (!spec->check_volume_offset) {
3059 unsigned int caps, step, nums, db_scale;
3060 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3061 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3062 AC_AMPCAP_STEP_SIZE_SHIFT;
3063 step = (step + 1) * 25; /* in .01dB unit */
3064 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3065 AC_AMPCAP_NUM_STEPS_SHIFT;
3066 db_scale = nums * step;
3067 /* if dB scale is over -64dB, and finer enough,
3068 * let's reduce it to half
3070 if (db_scale > 6400 && nums >= 0x1f)
3071 spec->volume_offset = nums / 2;
3072 spec->check_volume_offset = 1;
3075 sprintf(name, "%s Playback Volume", pfx);
3076 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
3077 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3078 spec->volume_offset));
3081 sprintf(name, "%s Playback Switch", pfx);
3082 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
3083 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3089 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3091 if (spec->multiout.num_dacs > 4) {
3092 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3095 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3096 spec->multiout.num_dacs++;
3101 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3104 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3105 if (!spec->multiout.extra_out_nid[i]) {
3106 spec->multiout.extra_out_nid[i] = nid;
3110 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3114 static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid)
3118 if (spec->autocfg.line_outs != 1)
3120 if (spec->multiout.hp_nid == nid)
3122 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
3123 if (spec->multiout.extra_out_nid[i] == nid)
3128 /* add playback controls from the parsed DAC table */
3129 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3130 const struct auto_pin_cfg *cfg)
3132 struct sigmatel_spec *spec = codec->spec;
3133 static const char *chname[4] = {
3134 "Front", "Surround", NULL /*CLFE*/, "Side"
3138 unsigned int wid_caps;
3140 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) {
3141 nid = spec->multiout.dac_nids[i];
3144 err = create_controls(codec, "Center", nid, 1);
3147 err = create_controls(codec, "LFE", nid, 2);
3151 wid_caps = get_wcaps(codec, nid);
3153 if (wid_caps & AC_WCAP_LR_SWAP) {
3154 err = stac92xx_add_control(spec,
3155 STAC_CTL_WIDGET_CLFE_SWITCH,
3156 "Swap Center/LFE Playback Switch", nid);
3163 const char *name = chname[i];
3164 /* if it's a single DAC, assign a better name */
3165 if (!i && is_unique_dac(spec, nid)) {
3166 switch (cfg->line_out_type) {
3167 case AUTO_PIN_HP_OUT:
3170 case AUTO_PIN_SPEAKER_OUT:
3175 err = create_controls(codec, name, nid, 3);
3181 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3182 err = stac92xx_add_control(spec,
3183 STAC_CTL_WIDGET_HP_SWITCH,
3184 "Headphone as Line Out Switch",
3185 cfg->hp_pins[cfg->hp_outs - 1]);
3190 if (spec->line_switch) {
3191 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3192 "Line In as Output Switch",
3193 spec->line_switch << 8);
3198 if (spec->mic_switch) {
3199 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3200 "Mic as Output Switch",
3201 (spec->mic_switch << 8) | 1);
3209 /* add playback controls for Speaker and HP outputs */
3210 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3211 struct auto_pin_cfg *cfg)
3213 struct sigmatel_spec *spec = codec->spec;
3218 for (i = 0; i < cfg->hp_outs; i++) {
3219 static const char *pfxs[] = {
3220 "Headphone", "Headphone2", "Headphone3",
3222 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3223 if (wid_caps & AC_WCAP_UNSOL_CAP)
3224 spec->hp_detect = 1;
3225 if (nums >= ARRAY_SIZE(pfxs))
3227 nid = spec->hp_dacs[i];
3230 err = create_controls(codec, pfxs[nums++], nid, 3);
3235 for (i = 0; i < cfg->speaker_outs; i++) {
3236 static const char *pfxs[] = {
3237 "Speaker", "External Speaker", "Speaker2",
3239 if (nums >= ARRAY_SIZE(pfxs))
3241 nid = spec->speaker_dacs[i];
3244 err = create_controls(codec, pfxs[nums++], nid, 3);
3251 /* labels for mono mux outputs */
3252 static const char *stac92xx_mono_labels[4] = {
3253 "DAC0", "DAC1", "Mixer", "DAC2"
3256 /* create mono mux for mono out on capable codecs */
3257 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3259 struct sigmatel_spec *spec = codec->spec;
3260 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3262 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3264 num_cons = snd_hda_get_connections(codec,
3267 HDA_MAX_NUM_INPUTS);
3268 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3271 for (i = 0; i < num_cons; i++) {
3272 mono_mux->items[mono_mux->num_items].label =
3273 stac92xx_mono_labels[i];
3274 mono_mux->items[mono_mux->num_items].index = i;
3275 mono_mux->num_items++;
3278 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3279 "Mono Mux", spec->mono_nid);
3282 /* labels for amp mux outputs */
3283 static const char *stac92xx_amp_labels[3] = {
3284 "Front Microphone", "Microphone", "Line In",
3287 /* create amp out controls mux on capable codecs */
3288 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3290 struct sigmatel_spec *spec = codec->spec;
3291 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3294 for (i = 0; i < spec->num_amps; i++) {
3295 amp_mux->items[amp_mux->num_items].label =
3296 stac92xx_amp_labels[i];
3297 amp_mux->items[amp_mux->num_items].index = i;
3298 amp_mux->num_items++;
3301 if (spec->num_amps > 1) {
3302 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3303 "Amp Selector Capture Switch", 0);
3307 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3308 "Amp Capture Volume",
3309 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3313 /* create PC beep volume controls */
3314 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3317 struct sigmatel_spec *spec = codec->spec;
3318 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3321 /* check for mute support for the the amp */
3322 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3323 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3324 "PC Beep Playback Switch",
3325 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3330 /* check to see if there is volume support for the amp */
3331 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3332 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3333 "PC Beep Playback Volume",
3334 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3341 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3342 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3344 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3345 struct snd_ctl_elem_value *ucontrol)
3347 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3348 ucontrol->value.integer.value[0] = codec->beep->enabled;
3352 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3353 struct snd_ctl_elem_value *ucontrol)
3355 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3356 int enabled = !!ucontrol->value.integer.value[0];
3357 if (codec->beep->enabled != enabled) {
3358 codec->beep->enabled = enabled;
3364 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3365 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3366 .info = stac92xx_dig_beep_switch_info,
3367 .get = stac92xx_dig_beep_switch_get,
3368 .put = stac92xx_dig_beep_switch_put,
3371 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3373 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3374 0, "PC Beep Playback Switch", 0);
3378 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3380 struct sigmatel_spec *spec = codec->spec;
3381 int wcaps, nid, i, err = 0;
3383 for (i = 0; i < spec->num_muxes; i++) {
3384 nid = spec->mux_nids[i];
3385 wcaps = get_wcaps(codec, nid);
3387 if (wcaps & AC_WCAP_OUT_AMP) {
3388 err = stac92xx_add_control_idx(spec,
3389 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3390 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3398 static const char *stac92xx_spdif_labels[3] = {
3399 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3402 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3404 struct sigmatel_spec *spec = codec->spec;
3405 struct hda_input_mux *spdif_mux = &spec->private_smux;
3406 const char **labels = spec->spdif_labels;
3408 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3410 num_cons = snd_hda_get_connections(codec,
3413 HDA_MAX_NUM_INPUTS);
3418 labels = stac92xx_spdif_labels;
3420 for (i = 0; i < num_cons; i++) {
3421 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3422 spdif_mux->items[spdif_mux->num_items].index = i;
3423 spdif_mux->num_items++;
3429 /* labels for dmic mux inputs */
3430 static const char *stac92xx_dmic_labels[5] = {
3431 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3432 "Digital Mic 3", "Digital Mic 4"
3435 /* create playback/capture controls for input pins on dmic capable codecs */
3436 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3437 const struct auto_pin_cfg *cfg)
3439 struct sigmatel_spec *spec = codec->spec;
3440 struct hda_input_mux *dimux = &spec->private_dimux;
3441 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3445 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3446 dimux->items[dimux->num_items].index = 0;
3449 for (i = 0; i < spec->num_dmics; i++) {
3454 unsigned int def_conf;
3456 def_conf = snd_hda_codec_read(codec,
3459 AC_VERB_GET_CONFIG_DEFAULT,
3461 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3464 nid = spec->dmic_nids[i];
3465 num_cons = snd_hda_get_connections(codec,
3468 HDA_MAX_NUM_INPUTS);
3469 for (j = 0; j < num_cons; j++)
3470 if (con_lst[j] == nid) {
3476 wcaps = get_wcaps(codec, nid) &
3477 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3480 sprintf(name, "%s Capture Volume",
3481 stac92xx_dmic_labels[dimux->num_items]);
3483 err = stac92xx_add_control(spec,
3484 STAC_CTL_WIDGET_VOL,
3486 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3487 (wcaps & AC_WCAP_OUT_AMP) ?
3488 HDA_OUTPUT : HDA_INPUT));
3493 dimux->items[dimux->num_items].label =
3494 stac92xx_dmic_labels[dimux->num_items];
3495 dimux->items[dimux->num_items].index = index;
3502 /* create playback/capture controls for input pins */
3503 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3505 struct sigmatel_spec *spec = codec->spec;
3506 struct hda_input_mux *imux = &spec->private_imux;
3507 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3510 for (i = 0; i < AUTO_PIN_LAST; i++) {
3513 if (!cfg->input_pins[i])
3516 for (j = 0; j < spec->num_muxes; j++) {
3518 num_cons = snd_hda_get_connections(codec,
3521 HDA_MAX_NUM_INPUTS);
3522 for (k = 0; k < num_cons; k++)
3523 if (con_lst[k] == cfg->input_pins[i]) {
3530 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3531 imux->items[imux->num_items].index = index;
3535 if (imux->num_items) {
3537 * Set the current input for the muxes.
3538 * The STAC9221 has two input muxes with identical source
3539 * NID lists. Hopefully this won't get confused.
3541 for (i = 0; i < spec->num_muxes; i++) {
3542 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3543 AC_VERB_SET_CONNECT_SEL,
3544 imux->items[0].index);
3551 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3553 struct sigmatel_spec *spec = codec->spec;
3556 for (i = 0; i < spec->autocfg.line_outs; i++) {
3557 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3558 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3562 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3564 struct sigmatel_spec *spec = codec->spec;
3567 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3569 pin = spec->autocfg.hp_pins[i];
3570 if (pin) /* connect to front */
3571 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3573 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3575 pin = spec->autocfg.speaker_pins[i];
3576 if (pin) /* connect to front */
3577 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3581 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3583 struct sigmatel_spec *spec = codec->spec;
3586 if ((err = snd_hda_parse_pin_def_config(codec,
3588 spec->dmic_nids)) < 0)
3590 if (! spec->autocfg.line_outs)
3591 return 0; /* can't find valid pin config */
3593 /* If we have no real line-out pin and multiple hp-outs, HPs should
3594 * be set up as multi-channel outputs.
3596 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3597 spec->autocfg.hp_outs > 1) {
3598 /* Copy hp_outs to line_outs, backup line_outs in
3599 * speaker_outs so that the following routines can handle
3600 * HP pins as primary outputs.
3602 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3603 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3604 sizeof(spec->autocfg.line_out_pins));
3605 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3606 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3607 sizeof(spec->autocfg.hp_pins));
3608 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3609 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3610 spec->autocfg.hp_outs = 0;
3612 if (spec->autocfg.mono_out_pin) {
3613 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3614 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3615 u32 caps = query_amp_caps(codec,
3616 spec->autocfg.mono_out_pin, dir);
3617 hda_nid_t conn_list[1];
3619 /* get the mixer node and then the mono mux if it exists */
3620 if (snd_hda_get_connections(codec,
3621 spec->autocfg.mono_out_pin, conn_list, 1) &&
3622 snd_hda_get_connections(codec, conn_list[0],
3625 int wcaps = get_wcaps(codec, conn_list[0]);
3626 int wid_type = (wcaps & AC_WCAP_TYPE)
3627 >> AC_WCAP_TYPE_SHIFT;
3628 /* LR swap check, some stac925x have a mux that
3629 * changes the DACs output path instead of the
3632 if (wid_type == AC_WID_AUD_SEL &&
3633 !(wcaps & AC_WCAP_LR_SWAP))
3634 spec->mono_nid = conn_list[0];
3637 hda_nid_t nid = spec->autocfg.mono_out_pin;
3639 /* most mono outs have a least a mute/unmute switch */
3640 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3641 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3642 "Mono Playback Switch",
3643 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3646 /* check for volume support for the amp */
3647 if ((caps & AC_AMPCAP_NUM_STEPS)
3648 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3649 err = stac92xx_add_control(spec,
3650 STAC_CTL_WIDGET_VOL,
3651 "Mono Playback Volume",
3652 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3658 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3662 if (!spec->multiout.num_dacs) {
3663 err = stac92xx_auto_fill_dac_nids(codec);
3666 err = stac92xx_auto_create_multi_out_ctls(codec,
3672 /* setup analog beep controls */
3673 if (spec->anabeep_nid > 0) {
3674 err = stac92xx_auto_create_beep_ctls(codec,
3680 /* setup digital beep controls and input device */
3681 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3682 if (spec->digbeep_nid > 0) {
3683 hda_nid_t nid = spec->digbeep_nid;
3686 err = stac92xx_auto_create_beep_ctls(codec, nid);
3689 err = snd_hda_attach_beep_device(codec, nid);
3692 /* if no beep switch is available, make its own one */
3693 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3695 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3696 err = stac92xx_beep_switch_ctl(codec);
3703 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3708 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3713 if (spec->mono_nid > 0) {
3714 err = stac92xx_auto_create_mono_output_ctls(codec);
3718 if (spec->num_amps > 0) {
3719 err = stac92xx_auto_create_amp_output_ctls(codec);
3723 if (spec->num_dmics > 0 && !spec->dinput_mux)
3724 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3725 &spec->autocfg)) < 0)
3727 if (spec->num_muxes > 0) {
3728 err = stac92xx_auto_create_mux_input_ctls(codec);
3732 if (spec->num_smuxes > 0) {
3733 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3738 err = stac92xx_add_input_source(spec);
3742 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3743 if (spec->multiout.max_channels > 2)
3744 spec->surr_switch = 1;
3746 if (spec->autocfg.dig_out_pin)
3747 spec->multiout.dig_out_nid = dig_out;
3748 if (dig_in && spec->autocfg.dig_in_pin)
3749 spec->dig_in_nid = dig_in;
3751 if (spec->kctls.list)
3752 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3754 spec->input_mux = &spec->private_imux;
3755 if (!spec->dinput_mux)
3756 spec->dinput_mux = &spec->private_dimux;
3757 spec->sinput_mux = &spec->private_smux;
3758 spec->mono_mux = &spec->private_mono_mux;
3759 spec->amp_mux = &spec->private_amp_mux;
3763 /* add playback controls for HP output */
3764 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3765 struct auto_pin_cfg *cfg)
3767 struct sigmatel_spec *spec = codec->spec;
3768 hda_nid_t pin = cfg->hp_pins[0];
3769 unsigned int wid_caps;
3774 wid_caps = get_wcaps(codec, pin);
3775 if (wid_caps & AC_WCAP_UNSOL_CAP)
3776 spec->hp_detect = 1;
3781 /* add playback controls for LFE output */
3782 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3783 struct auto_pin_cfg *cfg)
3785 struct sigmatel_spec *spec = codec->spec;
3787 hda_nid_t lfe_pin = 0x0;
3791 * search speaker outs and line outs for a mono speaker pin
3792 * with an amp. If one is found, add LFE controls
3795 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3796 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3797 unsigned int wcaps = get_wcaps(codec, pin);
3798 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3799 if (wcaps == AC_WCAP_OUT_AMP)
3800 /* found a mono speaker with an amp, must be lfe */
3804 /* if speaker_outs is 0, then speakers may be in line_outs */
3805 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3806 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3807 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3808 unsigned int defcfg;
3809 defcfg = snd_hda_codec_read(codec, pin, 0,
3810 AC_VERB_GET_CONFIG_DEFAULT,
3812 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3813 unsigned int wcaps = get_wcaps(codec, pin);
3814 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3815 if (wcaps == AC_WCAP_OUT_AMP)
3816 /* found a mono speaker with an amp,
3824 err = create_controls(codec, "LFE", lfe_pin, 1);
3832 static int stac9200_parse_auto_config(struct hda_codec *codec)
3834 struct sigmatel_spec *spec = codec->spec;
3837 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3840 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3843 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3846 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3849 if (spec->num_muxes > 0) {
3850 err = stac92xx_auto_create_mux_input_ctls(codec);
3855 err = stac92xx_add_input_source(spec);
3859 if (spec->autocfg.dig_out_pin)
3860 spec->multiout.dig_out_nid = 0x05;
3861 if (spec->autocfg.dig_in_pin)
3862 spec->dig_in_nid = 0x04;
3864 if (spec->kctls.list)
3865 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3867 spec->input_mux = &spec->private_imux;
3868 spec->dinput_mux = &spec->private_dimux;
3874 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3875 * funky external mute control using GPIO pins.
3878 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3879 unsigned int dir_mask, unsigned int data)
3881 unsigned int gpiostate, gpiomask, gpiodir;
3883 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3884 AC_VERB_GET_GPIO_DATA, 0);
3885 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3887 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3888 AC_VERB_GET_GPIO_MASK, 0);
3891 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3892 AC_VERB_GET_GPIO_DIRECTION, 0);
3893 gpiodir |= dir_mask;
3895 /* Configure GPIOx as CMOS */
3896 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3898 snd_hda_codec_write(codec, codec->afg, 0,
3899 AC_VERB_SET_GPIO_MASK, gpiomask);
3900 snd_hda_codec_read(codec, codec->afg, 0,
3901 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3905 snd_hda_codec_read(codec, codec->afg, 0,
3906 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3909 static int stac92xx_add_jack(struct hda_codec *codec,
3910 hda_nid_t nid, int type)
3912 #ifdef CONFIG_SND_JACK
3913 struct sigmatel_spec *spec = codec->spec;
3914 struct sigmatel_jack *jack;
3915 int def_conf = snd_hda_codec_read(codec, nid,
3916 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3917 int connectivity = get_defcfg_connect(def_conf);
3920 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3923 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3924 jack = snd_array_new(&spec->jacks);
3930 sprintf(name, "%s at %s %s Jack",
3931 snd_hda_get_jack_type(def_conf),
3932 snd_hda_get_jack_connectivity(def_conf),
3933 snd_hda_get_jack_location(def_conf));
3935 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
3941 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3942 unsigned char type, int data)
3944 struct sigmatel_event *event;
3946 snd_array_init(&spec->events, sizeof(*event), 32);
3947 event = snd_array_new(&spec->events);
3952 event->tag = spec->events.used;
3958 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3959 hda_nid_t nid, unsigned char type)
3961 struct sigmatel_spec *spec = codec->spec;
3962 struct sigmatel_event *event = spec->events.list;
3965 for (i = 0; i < spec->events.used; i++, event++) {
3966 if (event->nid == nid && event->type == type)
3972 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3975 struct sigmatel_spec *spec = codec->spec;
3976 struct sigmatel_event *event = spec->events.list;
3979 for (i = 0; i < spec->events.used; i++, event++) {
3980 if (event->tag == tag)
3986 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3989 struct sigmatel_event *event;
3992 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3994 event = stac_get_event(codec, nid, type);
3998 tag = stac_add_event(codec->spec, nid, type, 0);
4001 snd_hda_codec_write_cache(codec, nid, 0,
4002 AC_VERB_SET_UNSOLICITED_ENABLE,
4006 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4009 for (i = 0; i < cfg->hp_outs; i++)
4010 if (cfg->hp_pins[i] == nid)
4011 return 1; /* nid is a HP-Out */
4013 return 0; /* nid is not a HP-Out */
4016 static void stac92xx_power_down(struct hda_codec *codec)
4018 struct sigmatel_spec *spec = codec->spec;
4020 /* power down inactive DACs */
4022 for (dac = spec->dac_list; *dac; dac++)
4023 if (!check_all_dac_nids(spec, *dac))
4024 snd_hda_codec_write(codec, *dac, 0,
4025 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4028 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4031 static int stac92xx_init(struct hda_codec *codec)
4033 struct sigmatel_spec *spec = codec->spec;
4034 struct auto_pin_cfg *cfg = &spec->autocfg;
4038 snd_hda_sequence_write(codec, spec->init);
4040 /* power down adcs initially */
4041 if (spec->powerdown_adcs)
4042 for (i = 0; i < spec->num_adcs; i++)
4043 snd_hda_codec_write(codec,
4044 spec->adc_nids[i], 0,
4045 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4048 gpio = spec->gpio_data;
4049 /* turn on EAPD statically when spec->eapd_switch isn't set.
4050 * otherwise, unsol event will turn it on/off dynamically
4052 if (!spec->eapd_switch)
4053 gpio |= spec->eapd_mask;
4054 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4057 if (spec->hp_detect) {
4058 /* Enable unsolicited responses on the HP widget */
4059 for (i = 0; i < cfg->hp_outs; i++) {
4060 hda_nid_t nid = cfg->hp_pins[i];
4061 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4063 /* force to enable the first line-out; the others are set up
4066 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4068 /* fake event to set up pins */
4069 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4072 stac92xx_auto_init_multi_out(codec);
4073 stac92xx_auto_init_hp_out(codec);
4074 for (i = 0; i < cfg->hp_outs; i++)
4075 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4077 for (i = 0; i < AUTO_PIN_LAST; i++) {
4078 hda_nid_t nid = cfg->input_pins[i];
4080 unsigned int pinctl, conf;
4081 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4082 /* for mic pins, force to initialize */
4083 pinctl = stac92xx_get_vref(codec, nid);
4084 pinctl |= AC_PINCTL_IN_EN;
4085 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4087 pinctl = snd_hda_codec_read(codec, nid, 0,
4088 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4089 /* if PINCTL already set then skip */
4090 if (!(pinctl & AC_PINCTL_IN_EN)) {
4091 pinctl |= AC_PINCTL_IN_EN;
4092 stac92xx_auto_set_pinctl(codec, nid,
4096 conf = snd_hda_codec_read(codec, nid, 0,
4097 AC_VERB_GET_CONFIG_DEFAULT, 0);
4098 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4099 enable_pin_detect(codec, nid,
4101 stac_issue_unsol_event(codec, nid,
4106 for (i = 0; i < spec->num_dmics; i++)
4107 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4109 if (cfg->dig_out_pin)
4110 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
4112 if (cfg->dig_in_pin)
4113 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4115 for (i = 0; i < spec->num_pwrs; i++) {
4116 hda_nid_t nid = spec->pwr_nids[i];
4117 int pinctl, def_conf;
4119 /* power on when no jack detection is available */
4120 if (!spec->hp_detect) {
4121 stac_toggle_power_map(codec, nid, 1);
4125 if (is_nid_hp_pin(cfg, nid))
4126 continue; /* already has an unsol event */
4128 pinctl = snd_hda_codec_read(codec, nid, 0,
4129 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4130 /* outputs are only ports capable of power management
4131 * any attempts on powering down a input port cause the
4132 * referenced VREF to act quirky.
4134 if (pinctl & AC_PINCTL_IN_EN) {
4135 stac_toggle_power_map(codec, nid, 1);
4138 def_conf = snd_hda_codec_read(codec, nid, 0,
4139 AC_VERB_GET_CONFIG_DEFAULT, 0);
4140 def_conf = get_defcfg_connect(def_conf);
4141 /* skip any ports that don't have jacks since presence
4142 * detection is useless */
4143 if (def_conf != AC_JACK_PORT_COMPLEX) {
4144 if (def_conf != AC_JACK_PORT_NONE)
4145 stac_toggle_power_map(codec, nid, 1);
4148 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4149 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4150 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4154 stac92xx_power_down(codec);
4158 static void stac92xx_free_jacks(struct hda_codec *codec)
4160 #ifdef CONFIG_SND_JACK
4161 /* free jack instances manually when clearing/reconfiguring */
4162 struct sigmatel_spec *spec = codec->spec;
4163 if (!codec->bus->shutdown && spec->jacks.list) {
4164 struct sigmatel_jack *jacks = spec->jacks.list;
4166 for (i = 0; i < spec->jacks.used; i++)
4167 snd_device_free(codec->bus->card, &jacks[i].jack);
4169 snd_array_free(&spec->jacks);
4173 static void stac92xx_free_kctls(struct hda_codec *codec)
4175 struct sigmatel_spec *spec = codec->spec;
4177 if (spec->kctls.list) {
4178 struct snd_kcontrol_new *kctl = spec->kctls.list;
4180 for (i = 0; i < spec->kctls.used; i++)
4181 kfree(kctl[i].name);
4183 snd_array_free(&spec->kctls);
4186 static void stac92xx_free(struct hda_codec *codec)
4188 struct sigmatel_spec *spec = codec->spec;
4193 kfree(spec->pin_configs);
4194 stac92xx_free_jacks(codec);
4195 snd_array_free(&spec->events);
4198 snd_hda_detach_beep_device(codec);
4201 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4204 unsigned int old_ctl, pin_ctl;
4206 pin_ctl = snd_hda_codec_read(codec, nid,
4207 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4209 if (pin_ctl & AC_PINCTL_IN_EN) {
4211 * we need to check the current set-up direction of
4212 * shared input pins since they can be switched via
4213 * "xxx as Output" mixer switch
4215 struct sigmatel_spec *spec = codec->spec;
4216 if (nid == spec->line_switch || nid == spec->mic_switch)
4221 /* if setting pin direction bits, clear the current
4222 direction bits first */
4223 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4224 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4227 if (old_ctl != pin_ctl)
4228 snd_hda_codec_write_cache(codec, nid, 0,
4229 AC_VERB_SET_PIN_WIDGET_CONTROL,
4233 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4236 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4237 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4239 snd_hda_codec_write_cache(codec, nid, 0,
4240 AC_VERB_SET_PIN_WIDGET_CONTROL,
4244 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4248 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
4254 /* return non-zero if the hp-pin of the given array index isn't
4255 * a jack-detection target
4257 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4259 struct auto_pin_cfg *cfg = &spec->autocfg;
4261 /* ignore sensing of shared line and mic jacks */
4262 if (cfg->hp_pins[i] == spec->line_switch)
4264 if (cfg->hp_pins[i] == spec->mic_switch)
4266 /* ignore if the pin is set as line-out */
4267 if (cfg->hp_pins[i] == spec->hp_switch)
4272 static void stac92xx_hp_detect(struct hda_codec *codec)
4274 struct sigmatel_spec *spec = codec->spec;
4275 struct auto_pin_cfg *cfg = &spec->autocfg;
4279 if (spec->gpio_mute)
4280 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4281 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4283 for (i = 0; i < cfg->hp_outs; i++) {
4286 if (no_hp_sensing(spec, i))
4288 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4290 unsigned int pinctl;
4291 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4292 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4293 if (pinctl & AC_PINCTL_IN_EN)
4294 presence = 0; /* mic- or line-input */
4299 /* disable lineouts */
4300 if (spec->hp_switch)
4301 stac92xx_reset_pinctl(codec, spec->hp_switch,
4303 for (i = 0; i < cfg->line_outs; i++)
4304 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4306 for (i = 0; i < cfg->speaker_outs; i++)
4307 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4309 if (spec->eapd_mask && spec->eapd_switch)
4310 stac_gpio_set(codec, spec->gpio_mask,
4311 spec->gpio_dir, spec->gpio_data &
4314 /* enable lineouts */
4315 if (spec->hp_switch)
4316 stac92xx_set_pinctl(codec, spec->hp_switch,
4318 for (i = 0; i < cfg->line_outs; i++)
4319 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4321 for (i = 0; i < cfg->speaker_outs; i++)
4322 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4324 if (spec->eapd_mask && spec->eapd_switch)
4325 stac_gpio_set(codec, spec->gpio_mask,
4326 spec->gpio_dir, spec->gpio_data |
4329 /* toggle hp outs */
4330 for (i = 0; i < cfg->hp_outs; i++) {
4331 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4332 if (no_hp_sensing(spec, i))
4335 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4337 /* Resetting the pinctl like below may lead to (a sort of) regressions
4338 * on some devices since they use the HP pin actually for line/speaker
4339 * outs although the default pin config shows a different pin (that is
4340 * wrong and useless).
4342 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4343 * But, disabling the code below just works around it, and I'm too tired of
4344 * bug reports with such devices...
4347 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4352 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4355 struct sigmatel_spec *spec = codec->spec;
4356 unsigned int idx, val;
4358 for (idx = 0; idx < spec->num_pwrs; idx++) {
4359 if (spec->pwr_nids[idx] == nid)
4362 if (idx >= spec->num_pwrs)
4365 /* several codecs have two power down bits */
4366 if (spec->pwr_mapping)
4367 idx = spec->pwr_mapping[idx];
4371 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4377 /* power down unused output ports */
4378 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4381 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4383 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4386 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4388 struct sigmatel_spec *spec = codec->spec;
4389 struct sigmatel_jack *jacks = spec->jacks.list;
4393 for (i = 0; i < spec->jacks.used; i++) {
4394 if (jacks->nid == nid) {
4395 unsigned int pin_ctl =
4396 snd_hda_codec_read(codec, nid,
4397 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4399 int type = jacks->type;
4400 if (type == (SND_JACK_LINEOUT
4401 | SND_JACK_HEADPHONE))
4402 type = (pin_ctl & AC_PINCTL_HP_EN)
4403 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4404 snd_jack_report(jacks->jack,
4405 get_pin_presence(codec, nid)
4413 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4416 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4419 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4422 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4424 struct sigmatel_spec *spec = codec->spec;
4425 struct sigmatel_event *event;
4428 tag = (res >> 26) & 0x7f;
4429 event = stac_get_event_from_tag(codec, tag);
4433 switch (event->type) {
4435 stac92xx_hp_detect(codec);
4437 case STAC_INSERT_EVENT:
4438 case STAC_PWR_EVENT:
4439 if (spec->num_pwrs > 0)
4440 stac92xx_pin_sense(codec, event->nid);
4441 stac92xx_report_jack(codec, event->nid);
4443 case STAC_VREF_EVENT:
4444 data = snd_hda_codec_read(codec, codec->afg, 0,
4445 AC_VERB_GET_GPIO_DATA, 0);
4446 /* toggle VREF state based on GPIOx status */
4447 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4448 !!(data & (1 << event->data)));
4453 #ifdef CONFIG_PROC_FS
4454 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4455 struct hda_codec *codec, hda_nid_t nid)
4457 if (nid == codec->afg)
4458 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4459 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4462 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4463 struct hda_codec *codec,
4466 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4467 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4470 /* stac92hd71bxx, stac92hd73xx */
4471 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4472 struct hda_codec *codec, hda_nid_t nid)
4474 stac92hd_proc_hook(buffer, codec, nid);
4475 if (nid == codec->afg)
4476 analog_loop_proc_hook(buffer, codec, 0xfa0);
4479 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4480 struct hda_codec *codec, hda_nid_t nid)
4482 if (nid == codec->afg)
4483 analog_loop_proc_hook(buffer, codec, 0xfe0);
4486 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4487 struct hda_codec *codec, hda_nid_t nid)
4489 if (nid == codec->afg)
4490 analog_loop_proc_hook(buffer, codec, 0xfeb);
4493 #define stac92hd_proc_hook NULL
4494 #define stac92hd7x_proc_hook NULL
4495 #define stac9205_proc_hook NULL
4496 #define stac927x_proc_hook NULL
4499 #ifdef SND_HDA_NEEDS_RESUME
4500 static int stac92xx_resume(struct hda_codec *codec)
4502 struct sigmatel_spec *spec = codec->spec;
4504 stac92xx_set_config_regs(codec);
4505 stac92xx_init(codec);
4506 snd_hda_codec_resume_amp(codec);
4507 snd_hda_codec_resume_cache(codec);
4508 /* fake event to set up pins again to override cached values */
4509 if (spec->hp_detect)
4510 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4515 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4517 struct sigmatel_spec *spec = codec->spec;
4518 if (spec->eapd_mask)
4519 stac_gpio_set(codec, spec->gpio_mask,
4520 spec->gpio_dir, spec->gpio_data &
4526 static struct hda_codec_ops stac92xx_patch_ops = {
4527 .build_controls = stac92xx_build_controls,
4528 .build_pcms = stac92xx_build_pcms,
4529 .init = stac92xx_init,
4530 .free = stac92xx_free,
4531 .unsol_event = stac92xx_unsol_event,
4532 #ifdef SND_HDA_NEEDS_RESUME
4533 .suspend = stac92xx_suspend,
4534 .resume = stac92xx_resume,
4538 static int patch_stac9200(struct hda_codec *codec)
4540 struct sigmatel_spec *spec;
4543 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4548 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4549 spec->pin_nids = stac9200_pin_nids;
4550 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4553 if (spec->board_config < 0) {
4554 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4555 err = stac92xx_save_bios_config_regs(codec);
4557 err = stac_save_pin_cfgs(codec,
4558 stac9200_brd_tbl[spec->board_config]);
4560 stac92xx_free(codec);
4564 spec->multiout.max_channels = 2;
4565 spec->multiout.num_dacs = 1;
4566 spec->multiout.dac_nids = stac9200_dac_nids;
4567 spec->adc_nids = stac9200_adc_nids;
4568 spec->mux_nids = stac9200_mux_nids;
4569 spec->num_muxes = 1;
4570 spec->num_dmics = 0;
4574 if (spec->board_config == STAC_9200_M4 ||
4575 spec->board_config == STAC_9200_M4_2 ||
4576 spec->board_config == STAC_9200_OQO)
4577 spec->init = stac9200_eapd_init;
4579 spec->init = stac9200_core_init;
4580 spec->mixer = stac9200_mixer;
4582 if (spec->board_config == STAC_9200_PANASONIC) {
4583 spec->gpio_mask = spec->gpio_dir = 0x09;
4584 spec->gpio_data = 0x00;
4587 err = stac9200_parse_auto_config(codec);
4589 stac92xx_free(codec);
4593 /* CF-74 has no headphone detection, and the driver should *NOT*
4594 * do detection and HP/speaker toggle because the hardware does it.
4596 if (spec->board_config == STAC_9200_PANASONIC)
4597 spec->hp_detect = 0;
4599 codec->patch_ops = stac92xx_patch_ops;
4604 static int patch_stac925x(struct hda_codec *codec)
4606 struct sigmatel_spec *spec;
4609 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4614 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4615 spec->pin_nids = stac925x_pin_nids;
4617 /* Check first for codec ID */
4618 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4621 stac925x_codec_id_cfg_tbl);
4623 /* Now checks for PCI ID, if codec ID is not found */
4624 if (spec->board_config < 0)
4625 spec->board_config = snd_hda_check_board_config(codec,
4630 if (spec->board_config < 0) {
4631 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4632 "using BIOS defaults\n");
4633 err = stac92xx_save_bios_config_regs(codec);
4635 err = stac_save_pin_cfgs(codec,
4636 stac925x_brd_tbl[spec->board_config]);
4638 stac92xx_free(codec);
4642 spec->multiout.max_channels = 2;
4643 spec->multiout.num_dacs = 1;
4644 spec->multiout.dac_nids = stac925x_dac_nids;
4645 spec->adc_nids = stac925x_adc_nids;
4646 spec->mux_nids = stac925x_mux_nids;
4647 spec->num_muxes = 1;
4650 switch (codec->vendor_id) {
4651 case 0x83847632: /* STAC9202 */
4652 case 0x83847633: /* STAC9202D */
4653 case 0x83847636: /* STAC9251 */
4654 case 0x83847637: /* STAC9251D */
4655 spec->num_dmics = STAC925X_NUM_DMICS;
4656 spec->dmic_nids = stac925x_dmic_nids;
4657 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4658 spec->dmux_nids = stac925x_dmux_nids;
4661 spec->num_dmics = 0;
4665 spec->init = stac925x_core_init;
4666 spec->mixer = stac925x_mixer;
4668 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4670 if (spec->board_config < 0) {
4671 printk(KERN_WARNING "hda_codec: No auto-config is "
4672 "available, default to model=ref\n");
4673 spec->board_config = STAC_925x_REF;
4679 stac92xx_free(codec);
4683 codec->patch_ops = stac92xx_patch_ops;
4688 static struct hda_input_mux stac92hd73xx_dmux = {
4691 { "Analog Inputs", 0x0b },
4692 { "Digital Mic 1", 0x09 },
4693 { "Digital Mic 2", 0x0a },
4698 static int patch_stac92hd73xx(struct hda_codec *codec)
4700 struct sigmatel_spec *spec;
4701 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4705 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4710 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4711 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4712 spec->pin_nids = stac92hd73xx_pin_nids;
4713 spec->board_config = snd_hda_check_board_config(codec,
4714 STAC_92HD73XX_MODELS,
4715 stac92hd73xx_models,
4716 stac92hd73xx_cfg_tbl);
4718 if (spec->board_config < 0) {
4719 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4720 " STAC92HD73XX, using BIOS defaults\n");
4721 err = stac92xx_save_bios_config_regs(codec);
4723 err = stac_save_pin_cfgs(codec,
4724 stac92hd73xx_brd_tbl[spec->board_config]);
4726 stac92xx_free(codec);
4730 num_dacs = snd_hda_get_connections(codec, 0x0a,
4731 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4733 if (num_dacs < 3 || num_dacs > 5) {
4734 printk(KERN_WARNING "hda_codec: Could not determine "
4735 "number of channels defaulting to DAC count\n");
4736 num_dacs = STAC92HD73_DAC_COUNT;
4739 case 0x3: /* 6 Channel */
4740 spec->mixer = stac92hd73xx_6ch_mixer;
4741 spec->init = stac92hd73xx_6ch_core_init;
4743 case 0x4: /* 8 Channel */
4744 spec->mixer = stac92hd73xx_8ch_mixer;
4745 spec->init = stac92hd73xx_8ch_core_init;
4747 case 0x5: /* 10 Channel */
4748 spec->mixer = stac92hd73xx_10ch_mixer;
4749 spec->init = stac92hd73xx_10ch_core_init;
4751 spec->multiout.dac_nids = spec->dac_nids;
4753 spec->aloopback_mask = 0x01;
4754 spec->aloopback_shift = 8;
4756 spec->digbeep_nid = 0x1c;
4757 spec->mux_nids = stac92hd73xx_mux_nids;
4758 spec->adc_nids = stac92hd73xx_adc_nids;
4759 spec->dmic_nids = stac92hd73xx_dmic_nids;
4760 spec->dmux_nids = stac92hd73xx_dmux_nids;
4761 spec->smux_nids = stac92hd73xx_smux_nids;
4762 spec->amp_nids = stac92hd73xx_amp_nids;
4763 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4765 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4766 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4767 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4768 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4769 sizeof(stac92hd73xx_dmux));
4771 switch (spec->board_config) {
4773 spec->init = dell_eq_core_init;
4775 case STAC_DELL_M6_AMIC:
4776 case STAC_DELL_M6_DMIC:
4777 case STAC_DELL_M6_BOTH:
4778 spec->num_smuxes = 0;
4779 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4780 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4781 spec->eapd_switch = 0;
4784 if (spec->board_config != STAC_DELL_EQ)
4785 spec->init = dell_m6_core_init;
4786 switch (spec->board_config) {
4787 case STAC_DELL_M6_AMIC: /* Analog Mics */
4788 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4789 spec->num_dmics = 0;
4790 spec->private_dimux.num_items = 1;
4792 case STAC_DELL_M6_DMIC: /* Digital Mics */
4793 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4794 spec->num_dmics = 1;
4795 spec->private_dimux.num_items = 2;
4797 case STAC_DELL_M6_BOTH: /* Both */
4798 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4799 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4800 spec->num_dmics = 1;
4801 spec->private_dimux.num_items = 2;
4806 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4807 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4808 spec->eapd_switch = 1;
4810 if (spec->board_config > STAC_92HD73XX_REF) {
4811 /* GPIO0 High = Enable EAPD */
4812 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4813 spec->gpio_data = 0x01;
4815 spec->dinput_mux = &spec->private_dimux;
4817 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4818 spec->pwr_nids = stac92hd73xx_pwr_nids;
4820 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
4823 if (spec->board_config < 0) {
4824 printk(KERN_WARNING "hda_codec: No auto-config is "
4825 "available, default to model=ref\n");
4826 spec->board_config = STAC_92HD73XX_REF;
4833 stac92xx_free(codec);
4837 if (spec->board_config == STAC_92HD73XX_NO_JD)
4838 spec->hp_detect = 0;
4840 codec->patch_ops = stac92xx_patch_ops;
4842 codec->proc_widget_hook = stac92hd7x_proc_hook;
4847 static struct hda_input_mux stac92hd83xxx_dmux = {
4850 { "Analog Inputs", 0x03 },
4851 { "Digital Mic 1", 0x04 },
4852 { "Digital Mic 2", 0x05 },
4856 static int patch_stac92hd83xxx(struct hda_codec *codec)
4858 struct sigmatel_spec *spec;
4859 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
4863 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4868 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
4869 spec->mono_nid = 0x19;
4870 spec->digbeep_nid = 0x21;
4871 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4872 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4873 spec->adc_nids = stac92hd83xxx_adc_nids;
4874 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4875 spec->amp_nids = stac92hd83xxx_amp_nids;
4876 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4877 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4878 spec->multiout.dac_nids = spec->dac_nids;
4881 /* set port 0xe to select the last DAC
4883 num_dacs = snd_hda_get_connections(codec, 0x0e,
4884 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4886 snd_hda_codec_write_cache(codec, 0xe, 0,
4887 AC_VERB_SET_CONNECT_SEL, num_dacs);
4889 spec->init = stac92hd83xxx_core_init;
4890 spec->mixer = stac92hd83xxx_mixer;
4891 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4892 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4893 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4894 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
4895 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4896 spec->dinput_mux = &stac92hd83xxx_dmux;
4897 spec->pin_nids = stac92hd83xxx_pin_nids;
4898 spec->board_config = snd_hda_check_board_config(codec,
4899 STAC_92HD83XXX_MODELS,
4900 stac92hd83xxx_models,
4901 stac92hd83xxx_cfg_tbl);
4903 if (spec->board_config < 0) {
4904 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4905 " STAC92HD83XXX, using BIOS defaults\n");
4906 err = stac92xx_save_bios_config_regs(codec);
4908 err = stac_save_pin_cfgs(codec,
4909 stac92hd83xxx_brd_tbl[spec->board_config]);
4911 stac92xx_free(codec);
4915 switch (codec->vendor_id) {
4918 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
4924 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4926 if (spec->board_config < 0) {
4927 printk(KERN_WARNING "hda_codec: No auto-config is "
4928 "available, default to model=ref\n");
4929 spec->board_config = STAC_92HD83XXX_REF;
4936 stac92xx_free(codec);
4940 codec->patch_ops = stac92xx_patch_ops;
4942 codec->proc_widget_hook = stac92hd_proc_hook;
4947 static struct hda_input_mux stac92hd71bxx_dmux = {
4950 { "Analog Inputs", 0x00 },
4952 { "Digital Mic 1", 0x02 },
4953 { "Digital Mic 2", 0x03 },
4957 static int patch_stac92hd71bxx(struct hda_codec *codec)
4959 struct sigmatel_spec *spec;
4960 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
4963 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4968 codec->patch_ops = stac92xx_patch_ops;
4969 spec->num_pins = STAC92HD71BXX_NUM_PINS;
4970 switch (codec->vendor_id) {
4973 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
4977 /* On 92HD75Bx 0x27 isn't a pin nid */
4981 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
4983 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4984 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4985 sizeof(stac92hd71bxx_dmux));
4986 spec->board_config = snd_hda_check_board_config(codec,
4987 STAC_92HD71BXX_MODELS,
4988 stac92hd71bxx_models,
4989 stac92hd71bxx_cfg_tbl);
4991 if (spec->board_config < 0) {
4992 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4993 " STAC92HD71BXX, using BIOS defaults\n");
4994 err = stac92xx_save_bios_config_regs(codec);
4996 err = stac_save_pin_cfgs(codec,
4997 stac92hd71bxx_brd_tbl[spec->board_config]);
4999 stac92xx_free(codec);
5003 if (spec->board_config > STAC_92HD71BXX_REF) {
5005 spec->gpio_mask = 0x01;
5006 spec->gpio_dir = 0x01;
5007 spec->gpio_data = 0x01;
5010 switch (codec->vendor_id) {
5011 case 0x111d76b6: /* 4 Port without Analog Mixer */
5013 case 0x111d76b4: /* 6 Port without Analog Mixer */
5015 spec->mixer = stac92hd71bxx_mixer;
5016 spec->init = stac92hd71bxx_core_init;
5017 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5019 case 0x111d7608: /* 5 Port with Analog Mixer */
5020 switch (spec->board_config) {
5022 /* Enable VREF power saving on GPIO1 detect */
5023 err = stac_add_event(spec, codec->afg,
5024 STAC_VREF_EVENT, 0x02);
5027 snd_hda_codec_write_cache(codec, codec->afg, 0,
5028 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5029 snd_hda_codec_write_cache(codec, codec->afg, 0,
5030 AC_VERB_SET_UNSOLICITED_ENABLE,
5032 spec->gpio_mask |= 0x02;
5035 if ((codec->revision_id & 0xf) == 0 ||
5036 (codec->revision_id & 0xf) == 1)
5037 spec->stream_delay = 40; /* 40 milliseconds */
5039 /* no output amps */
5041 spec->mixer = stac92hd71bxx_analog_mixer;
5042 spec->dinput_mux = &spec->private_dimux;
5045 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
5047 stac_change_pin_config(codec, 0x0f, 0x40f000f0);
5048 stac_change_pin_config(codec, 0x19, 0x40f000f3);
5050 case 0x111d7603: /* 6 Port with Analog Mixer */
5051 if ((codec->revision_id & 0xf) == 1)
5052 spec->stream_delay = 40; /* 40 milliseconds */
5054 /* no output amps */
5058 spec->dinput_mux = &spec->private_dimux;
5059 spec->mixer = stac92hd71bxx_analog_mixer;
5060 spec->init = stac92hd71bxx_analog_core_init;
5061 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5064 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5065 snd_hda_sequence_write_cache(codec, unmute_init);
5067 spec->aloopback_mask = 0x50;
5068 spec->aloopback_shift = 0;
5070 spec->powerdown_adcs = 1;
5071 spec->digbeep_nid = 0x26;
5072 spec->mux_nids = stac92hd71bxx_mux_nids;
5073 spec->adc_nids = stac92hd71bxx_adc_nids;
5074 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5075 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5076 spec->smux_nids = stac92hd71bxx_smux_nids;
5077 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5079 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5080 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5082 switch (spec->board_config) {
5084 /* enable internal microphone */
5085 stac_change_pin_config(codec, 0x0e, 0x01813040);
5086 stac92xx_auto_set_pinctl(codec, 0x0e,
5087 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5089 case STAC_DELL_M4_2:
5090 spec->num_dmics = 0;
5091 spec->num_smuxes = 0;
5092 spec->num_dmuxes = 0;
5094 case STAC_DELL_M4_1:
5095 case STAC_DELL_M4_3:
5096 spec->num_dmics = 1;
5097 spec->num_smuxes = 0;
5098 spec->num_dmuxes = 0;
5101 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
5102 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
5103 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5106 spec->multiout.dac_nids = spec->dac_nids;
5107 if (spec->dinput_mux)
5108 spec->private_dimux.num_items +=
5110 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
5112 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
5114 if (spec->board_config < 0) {
5115 printk(KERN_WARNING "hda_codec: No auto-config is "
5116 "available, default to model=ref\n");
5117 spec->board_config = STAC_92HD71BXX_REF;
5124 stac92xx_free(codec);
5128 codec->proc_widget_hook = stac92hd7x_proc_hook;
5133 static int patch_stac922x(struct hda_codec *codec)
5135 struct sigmatel_spec *spec;
5138 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5143 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5144 spec->pin_nids = stac922x_pin_nids;
5145 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5148 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5149 spec->gpio_mask = spec->gpio_dir = 0x03;
5150 spec->gpio_data = 0x03;
5151 /* Intel Macs have all same PCI SSID, so we need to check
5152 * codec SSID to distinguish the exact models
5154 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5155 switch (codec->subsystem_id) {
5158 spec->board_config = STAC_INTEL_MAC_V1;
5162 spec->board_config = STAC_INTEL_MAC_V2;
5170 spec->board_config = STAC_INTEL_MAC_V3;
5174 spec->board_config = STAC_INTEL_MAC_V4;
5178 spec->board_config = STAC_INTEL_MAC_V5;
5181 spec->board_config = STAC_INTEL_MAC_V3;
5187 if (spec->board_config < 0) {
5188 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5189 "using BIOS defaults\n");
5190 err = stac92xx_save_bios_config_regs(codec);
5192 err = stac_save_pin_cfgs(codec,
5193 stac922x_brd_tbl[spec->board_config]);
5195 stac92xx_free(codec);
5199 spec->adc_nids = stac922x_adc_nids;
5200 spec->mux_nids = stac922x_mux_nids;
5201 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5202 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5203 spec->num_dmics = 0;
5206 spec->init = stac922x_core_init;
5207 spec->mixer = stac922x_mixer;
5209 spec->multiout.dac_nids = spec->dac_nids;
5211 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5213 if (spec->board_config < 0) {
5214 printk(KERN_WARNING "hda_codec: No auto-config is "
5215 "available, default to model=ref\n");
5216 spec->board_config = STAC_D945_REF;
5222 stac92xx_free(codec);
5226 codec->patch_ops = stac92xx_patch_ops;
5228 /* Fix Mux capture level; max to 2 */
5229 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5230 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5231 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5232 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5233 (0 << AC_AMPCAP_MUTE_SHIFT));
5238 static int patch_stac927x(struct hda_codec *codec)
5240 struct sigmatel_spec *spec;
5243 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5248 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5249 spec->pin_nids = stac927x_pin_nids;
5250 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5254 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
5255 if (spec->board_config < 0)
5256 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5257 "STAC927x, using BIOS defaults\n");
5258 err = stac92xx_save_bios_config_regs(codec);
5260 err = stac_save_pin_cfgs(codec,
5261 stac927x_brd_tbl[spec->board_config]);
5263 stac92xx_free(codec);
5267 spec->digbeep_nid = 0x23;
5268 spec->adc_nids = stac927x_adc_nids;
5269 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5270 spec->mux_nids = stac927x_mux_nids;
5271 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5272 spec->smux_nids = stac927x_smux_nids;
5273 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5274 spec->spdif_labels = stac927x_spdif_labels;
5275 spec->dac_list = stac927x_dac_nids;
5276 spec->multiout.dac_nids = spec->dac_nids;
5278 switch (spec->board_config) {
5281 /* GPIO0 High = Enable EAPD */
5282 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
5283 spec->gpio_data = 0x01;
5284 spec->num_dmics = 0;
5286 spec->init = d965_core_init;
5287 spec->mixer = stac927x_mixer;
5289 case STAC_DELL_BIOS:
5290 switch (codec->subsystem_id) {
5293 /* correct the device field to SPDIF out */
5294 stac_change_pin_config(codec, 0x21, 0x01442070);
5297 /* configure the analog microphone on some laptops */
5298 stac_change_pin_config(codec, 0x0c, 0x90a79130);
5299 /* correct the front output jack as a hp out */
5300 stac_change_pin_config(codec, 0x0f, 0x0227011f);
5301 /* correct the front input jack as a mic */
5302 stac_change_pin_config(codec, 0x0e, 0x02a79130);
5305 /* GPIO2 High = Enable EAPD */
5306 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
5307 spec->gpio_data = 0x04;
5308 spec->dmic_nids = stac927x_dmic_nids;
5309 spec->num_dmics = STAC927X_NUM_DMICS;
5311 spec->init = d965_core_init;
5312 spec->mixer = stac927x_mixer;
5313 spec->dmux_nids = stac927x_dmux_nids;
5314 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5317 if (spec->board_config > STAC_D965_REF) {
5318 /* GPIO0 High = Enable EAPD */
5319 spec->eapd_mask = spec->gpio_mask = 0x01;
5320 spec->gpio_dir = spec->gpio_data = 0x01;
5322 spec->num_dmics = 0;
5324 spec->init = stac927x_core_init;
5325 spec->mixer = stac927x_mixer;
5329 spec->aloopback_mask = 0x40;
5330 spec->aloopback_shift = 0;
5331 spec->eapd_switch = 1;
5333 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
5335 if (spec->board_config < 0) {
5336 printk(KERN_WARNING "hda_codec: No auto-config is "
5337 "available, default to model=ref\n");
5338 spec->board_config = STAC_D965_REF;
5344 stac92xx_free(codec);
5348 codec->patch_ops = stac92xx_patch_ops;
5350 codec->proc_widget_hook = stac927x_proc_hook;
5354 * The STAC927x seem to require fairly long delays for certain
5355 * command sequences. With too short delays (even if the answer
5356 * is set to RIRB properly), it results in the silence output
5357 * on some hardwares like Dell.
5359 * The below flag enables the longer delay (see get_response
5362 codec->bus->needs_damn_long_delay = 1;
5364 /* no jack detecion for ref-no-jd model */
5365 if (spec->board_config == STAC_D965_REF_NO_JD)
5366 spec->hp_detect = 0;
5371 static int patch_stac9205(struct hda_codec *codec)
5373 struct sigmatel_spec *spec;
5376 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5381 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
5382 spec->pin_nids = stac9205_pin_nids;
5383 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5387 if (spec->board_config < 0) {
5388 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5389 err = stac92xx_save_bios_config_regs(codec);
5391 err = stac_save_pin_cfgs(codec,
5392 stac9205_brd_tbl[spec->board_config]);
5394 stac92xx_free(codec);
5398 spec->digbeep_nid = 0x23;
5399 spec->adc_nids = stac9205_adc_nids;
5400 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
5401 spec->mux_nids = stac9205_mux_nids;
5402 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
5403 spec->smux_nids = stac9205_smux_nids;
5404 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
5405 spec->dmic_nids = stac9205_dmic_nids;
5406 spec->num_dmics = STAC9205_NUM_DMICS;
5407 spec->dmux_nids = stac9205_dmux_nids;
5408 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
5411 spec->init = stac9205_core_init;
5412 spec->mixer = stac9205_mixer;
5414 spec->aloopback_mask = 0x40;
5415 spec->aloopback_shift = 0;
5416 /* Turn on/off EAPD per HP plugging */
5417 if (spec->board_config != STAC_9205_EAPD)
5418 spec->eapd_switch = 1;
5419 spec->multiout.dac_nids = spec->dac_nids;
5421 switch (spec->board_config){
5422 case STAC_9205_DELL_M43:
5423 /* Enable SPDIF in/out */
5424 stac_change_pin_config(codec, 0x1f, 0x01441030);
5425 stac_change_pin_config(codec, 0x20, 0x1c410030);
5427 /* Enable unsol response for GPIO4/Dock HP connection */
5428 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5431 snd_hda_codec_write_cache(codec, codec->afg, 0,
5432 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5433 snd_hda_codec_write_cache(codec, codec->afg, 0,
5434 AC_VERB_SET_UNSOLICITED_ENABLE,
5437 spec->gpio_dir = 0x0b;
5438 spec->eapd_mask = 0x01;
5439 spec->gpio_mask = 0x1b;
5440 spec->gpio_mute = 0x10;
5441 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5444 spec->gpio_data = 0x01;
5447 /* SPDIF-In enabled */
5450 /* GPIO0 High = EAPD */
5451 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5452 spec->gpio_data = 0x01;
5456 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5458 if (spec->board_config < 0) {
5459 printk(KERN_WARNING "hda_codec: No auto-config is "
5460 "available, default to model=ref\n");
5461 spec->board_config = STAC_9205_REF;
5467 stac92xx_free(codec);
5471 codec->patch_ops = stac92xx_patch_ops;
5473 codec->proc_widget_hook = stac9205_proc_hook;
5482 static struct hda_verb stac9872_core_init[] = {
5483 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5484 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5488 static struct snd_kcontrol_new stac9872_mixer[] = {
5489 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5490 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5494 static hda_nid_t stac9872_pin_nids[] = {
5495 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5499 static hda_nid_t stac9872_adc_nids[] = {
5503 static hda_nid_t stac9872_mux_nids[] = {
5507 static int patch_stac9872(struct hda_codec *codec)
5509 struct sigmatel_spec *spec;
5512 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5517 #if 0 /* no model right now */
5518 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5523 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5524 spec->pin_nids = stac9872_pin_nids;
5525 spec->multiout.dac_nids = spec->dac_nids;
5526 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5527 spec->adc_nids = stac9872_adc_nids;
5528 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5529 spec->mux_nids = stac9872_mux_nids;
5530 spec->mixer = stac9872_mixer;
5531 spec->init = stac9872_core_init;
5533 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5535 stac92xx_free(codec);
5538 spec->input_mux = &spec->private_imux;
5539 codec->patch_ops = stac92xx_patch_ops;
5547 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5548 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5549 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5550 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5551 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5552 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5553 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5554 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5555 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5556 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5557 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5558 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5559 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5560 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5561 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5562 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5563 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5564 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5565 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5566 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5567 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5568 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5569 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5570 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5571 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5572 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5573 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5574 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5575 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5576 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5577 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5578 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5579 /* The following does not take into account .id=0x83847661 when subsys =
5580 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5581 * currently not fully supported.
5583 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5584 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5585 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5586 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5587 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5588 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5589 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5590 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5591 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5592 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5593 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5594 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5595 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5596 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5597 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5598 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5599 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5600 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5601 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5602 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5603 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5604 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5605 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5606 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5607 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5608 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5612 MODULE_ALIAS("snd-hda-codec-id:8384*");
5613 MODULE_ALIAS("snd-hda-codec-id:111d*");
5615 MODULE_LICENSE("GPL");
5616 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5618 static struct hda_codec_preset_list sigmatel_list = {
5619 .preset = snd_hda_preset_sigmatel,
5620 .owner = THIS_MODULE,
5623 static int __init patch_sigmatel_init(void)
5625 return snd_hda_add_codec_preset(&sigmatel_list);
5628 static void __exit patch_sigmatel_exit(void)
5630 snd_hda_delete_codec_preset(&sigmatel_list);
5633 module_init(patch_sigmatel_init)
5634 module_exit(patch_sigmatel_exit)