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
484 static hda_nid_t stac92hd71bxx_pin_nids[11] = {
485 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
486 0x0f, 0x14, 0x18, 0x19, 0x1e,
490 static hda_nid_t stac927x_pin_nids[14] = {
491 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
492 0x0f, 0x10, 0x11, 0x12, 0x13,
493 0x14, 0x21, 0x22, 0x23,
496 static hda_nid_t stac9205_pin_nids[12] = {
497 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
498 0x0f, 0x14, 0x16, 0x17, 0x18,
502 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
504 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
505 struct snd_ctl_elem_value *ucontrol)
507 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
508 struct sigmatel_spec *spec = codec->spec;
509 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
511 kcontrol->private_value ^= get_amp_nid(kcontrol);
512 kcontrol->private_value |= nid;
514 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
517 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
518 struct snd_ctl_elem_value *ucontrol)
520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
521 struct sigmatel_spec *spec = codec->spec;
522 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
524 kcontrol->private_value ^= get_amp_nid(kcontrol);
525 kcontrol->private_value |= nid;
527 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
530 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
531 struct snd_ctl_elem_info *uinfo)
533 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
534 struct sigmatel_spec *spec = codec->spec;
535 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
538 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_value *ucontrol)
541 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
542 struct sigmatel_spec *spec = codec->spec;
543 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
545 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
549 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
550 struct snd_ctl_elem_value *ucontrol)
552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
553 struct sigmatel_spec *spec = codec->spec;
554 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
556 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
557 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
560 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
561 struct snd_ctl_elem_info *uinfo)
563 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
564 struct sigmatel_spec *spec = codec->spec;
565 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
568 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
569 struct snd_ctl_elem_value *ucontrol)
571 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
572 struct sigmatel_spec *spec = codec->spec;
573 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
575 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
579 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
580 struct snd_ctl_elem_value *ucontrol)
582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
583 struct sigmatel_spec *spec = codec->spec;
584 struct hda_input_mux *smux = &spec->private_smux;
585 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
589 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
590 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
594 if (spec->spdif_mute) {
596 nid = spec->multiout.dig_out_nid;
598 nid = codec->slave_dig_outs[smux_idx - 1];
599 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
603 /* un/mute SPDIF out */
604 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
610 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
612 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
613 struct sigmatel_spec *spec = codec->spec;
614 return snd_hda_input_mux_info(spec->input_mux, uinfo);
617 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620 struct sigmatel_spec *spec = codec->spec;
621 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
623 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
627 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 struct sigmatel_spec *spec = codec->spec;
631 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
633 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
634 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
637 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
638 struct snd_ctl_elem_info *uinfo)
640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
641 struct sigmatel_spec *spec = codec->spec;
642 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
645 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
646 struct snd_ctl_elem_value *ucontrol)
648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
649 struct sigmatel_spec *spec = codec->spec;
651 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
655 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_value *ucontrol)
658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
659 struct sigmatel_spec *spec = codec->spec;
661 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
662 spec->mono_nid, &spec->cur_mmux);
665 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
666 struct snd_ctl_elem_info *uinfo)
668 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
669 struct sigmatel_spec *spec = codec->spec;
670 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
673 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
674 struct snd_ctl_elem_value *ucontrol)
676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
677 struct sigmatel_spec *spec = codec->spec;
679 ucontrol->value.enumerated.item[0] = spec->cur_amux;
683 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
684 struct snd_ctl_elem_value *ucontrol)
686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
687 struct sigmatel_spec *spec = codec->spec;
688 struct snd_kcontrol *ctl =
689 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
693 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
694 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
696 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
700 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
702 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
703 struct snd_ctl_elem_value *ucontrol)
705 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
706 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
707 struct sigmatel_spec *spec = codec->spec;
709 ucontrol->value.integer.value[0] = !!(spec->aloopback &
710 (spec->aloopback_mask << idx));
714 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
715 struct snd_ctl_elem_value *ucontrol)
717 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
718 struct sigmatel_spec *spec = codec->spec;
719 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
720 unsigned int dac_mode;
721 unsigned int val, idx_val;
723 idx_val = spec->aloopback_mask << idx;
724 if (ucontrol->value.integer.value[0])
725 val = spec->aloopback | idx_val;
727 val = spec->aloopback & ~idx_val;
728 if (spec->aloopback == val)
731 spec->aloopback = val;
733 /* Only return the bits defined by the shift value of the
734 * first two bytes of the mask
736 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
737 kcontrol->private_value & 0xFFFF, 0x0);
738 dac_mode >>= spec->aloopback_shift;
740 if (spec->aloopback & idx_val) {
741 snd_hda_power_up(codec);
744 snd_hda_power_down(codec);
745 dac_mode &= ~idx_val;
748 snd_hda_codec_write_cache(codec, codec->afg, 0,
749 kcontrol->private_value >> 16, dac_mode);
754 static struct hda_verb stac9200_core_init[] = {
755 /* set dac0mux for dac converter */
756 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
760 static struct hda_verb stac9200_eapd_init[] = {
761 /* set dac0mux for dac converter */
762 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
763 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
767 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
768 /* set master volume and direct control */
769 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
770 /* setup adcs to point to mixer */
771 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
772 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
773 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
774 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
775 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
776 /* setup import muxs */
777 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
778 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
779 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
780 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
784 static struct hda_verb dell_eq_core_init[] = {
785 /* set master volume to max value without distortion
786 * and direct control */
787 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
788 /* setup adcs to point to mixer */
789 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
790 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
791 /* setup import muxs */
792 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
793 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
794 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
795 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
799 static struct hda_verb dell_m6_core_init[] = {
800 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
801 /* setup adcs to point to mixer */
802 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
803 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
804 /* setup import muxs */
805 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
806 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
807 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
808 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
812 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
813 /* set master volume and direct control */
814 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
815 /* setup adcs to point to mixer */
816 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
817 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
818 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
819 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
820 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
821 /* setup import muxs */
822 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
823 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
824 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
825 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
829 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
830 /* set master volume and direct control */
831 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
832 /* dac3 is connected to import3 mux */
833 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
834 /* setup adcs to point to mixer */
835 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
836 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
837 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
838 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
839 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
840 /* setup import muxs */
841 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
842 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
843 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
844 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
848 static struct hda_verb stac92hd83xxx_core_init[] = {
849 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
850 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
851 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
853 /* power state controls amps */
854 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
858 static struct hda_verb stac92hd71bxx_core_init[] = {
859 /* set master volume and direct control */
860 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
861 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
862 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
863 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
864 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
868 #define HD_DISABLE_PORTF 2
869 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
870 /* start of config #1 */
872 /* connect port 0f to audio mixer */
873 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
874 /* unmute right and left channels for node 0x0f */
875 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
876 /* start of config #2 */
878 /* set master volume and direct control */
879 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
880 /* unmute right and left channels for nodes 0x0a, 0xd */
881 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
882 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
886 static struct hda_verb stac925x_core_init[] = {
887 /* set dac0mux for dac converter */
888 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
889 /* mute the master volume */
890 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
894 static struct hda_verb stac922x_core_init[] = {
895 /* set master volume and direct control */
896 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
900 static struct hda_verb d965_core_init[] = {
901 /* set master volume and direct control */
902 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
903 /* unmute node 0x1b */
904 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
905 /* select node 0x03 as DAC */
906 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
910 static struct hda_verb stac927x_core_init[] = {
911 /* set master volume and direct control */
912 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
913 /* enable analog pc beep path */
914 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
918 static struct hda_verb stac9205_core_init[] = {
919 /* set master volume and direct control */
920 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
921 /* enable analog pc beep path */
922 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
926 #define STAC_MONO_MUX \
928 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
929 .name = "Mono Mux", \
931 .info = stac92xx_mono_mux_enum_info, \
932 .get = stac92xx_mono_mux_enum_get, \
933 .put = stac92xx_mono_mux_enum_put, \
936 #define STAC_AMP_MUX \
938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
939 .name = "Amp Selector Capture Switch", \
941 .info = stac92xx_amp_mux_enum_info, \
942 .get = stac92xx_amp_mux_enum_get, \
943 .put = stac92xx_amp_mux_enum_put, \
946 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
951 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
952 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
953 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
954 .info = stac92xx_amp_volume_info, \
955 .get = stac92xx_amp_volume_get, \
956 .put = stac92xx_amp_volume_put, \
957 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
958 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
961 #define STAC_INPUT_SOURCE(cnt) \
963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
964 .name = "Input Source", \
966 .info = stac92xx_mux_enum_info, \
967 .get = stac92xx_mux_enum_get, \
968 .put = stac92xx_mux_enum_put, \
971 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
973 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
974 .name = "Analog Loopback", \
976 .info = stac92xx_aloopback_info, \
977 .get = stac92xx_aloopback_get, \
978 .put = stac92xx_aloopback_put, \
979 .private_value = verb_read | (verb_write << 16), \
982 static struct snd_kcontrol_new stac9200_mixer[] = {
983 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
984 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
985 STAC_INPUT_SOURCE(1),
986 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
987 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
991 #define DELL_M6_MIXER 6
992 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
993 /* start of config #1 */
994 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
995 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
997 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
998 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1000 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1001 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1003 /* start of config #2 */
1004 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1005 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1007 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1008 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1010 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1012 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1013 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1015 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1016 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1021 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1022 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1024 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1025 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1027 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1028 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1030 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1031 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1033 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1034 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1036 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1037 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1039 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1040 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1042 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1043 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1047 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1048 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1050 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1051 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1053 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1054 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1056 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1057 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1059 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1060 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1062 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1063 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1065 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1066 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1068 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1069 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1074 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1075 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1076 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1078 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1079 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1081 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1082 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
1084 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1085 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
1087 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1088 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
1090 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1091 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
1094 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1095 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
1100 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1101 STAC_INPUT_SOURCE(2),
1102 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1104 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1105 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1107 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1108 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1109 /* analog pc-beep replaced with digital beep support */
1111 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1112 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1115 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1116 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1118 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1119 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1121 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1122 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1124 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1125 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1129 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1130 STAC_INPUT_SOURCE(2),
1131 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1133 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1134 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1136 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1137 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1141 static struct snd_kcontrol_new stac925x_mixer[] = {
1142 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1143 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1144 STAC_INPUT_SOURCE(1),
1145 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1146 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1150 static struct snd_kcontrol_new stac9205_mixer[] = {
1151 STAC_INPUT_SOURCE(2),
1152 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1154 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1155 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1157 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1158 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1162 /* This needs to be generated dynamically based on sequence */
1163 static struct snd_kcontrol_new stac922x_mixer[] = {
1164 STAC_INPUT_SOURCE(2),
1165 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1166 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1168 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1169 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1174 static struct snd_kcontrol_new stac927x_mixer[] = {
1175 STAC_INPUT_SOURCE(3),
1176 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1178 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1179 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1181 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1182 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1184 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1185 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1189 static struct snd_kcontrol_new stac_dmux_mixer = {
1190 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1191 .name = "Digital Input Source",
1192 /* count set later */
1193 .info = stac92xx_dmux_enum_info,
1194 .get = stac92xx_dmux_enum_get,
1195 .put = stac92xx_dmux_enum_put,
1198 static struct snd_kcontrol_new stac_smux_mixer = {
1199 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1200 .name = "IEC958 Playback Source",
1201 /* count set later */
1202 .info = stac92xx_smux_enum_info,
1203 .get = stac92xx_smux_enum_get,
1204 .put = stac92xx_smux_enum_put,
1207 static const char *slave_vols[] = {
1208 "Front Playback Volume",
1209 "Surround Playback Volume",
1210 "Center Playback Volume",
1211 "LFE Playback Volume",
1212 "Side Playback Volume",
1213 "Headphone Playback Volume",
1214 "Headphone Playback Volume",
1215 "Speaker Playback Volume",
1216 "External Speaker Playback Volume",
1217 "Speaker2 Playback Volume",
1221 static const char *slave_sws[] = {
1222 "Front Playback Switch",
1223 "Surround Playback Switch",
1224 "Center Playback Switch",
1225 "LFE Playback Switch",
1226 "Side Playback Switch",
1227 "Headphone Playback Switch",
1228 "Headphone Playback Switch",
1229 "Speaker Playback Switch",
1230 "External Speaker Playback Switch",
1231 "Speaker2 Playback Switch",
1232 "IEC958 Playback Switch",
1236 static void stac92xx_free_kctls(struct hda_codec *codec);
1237 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1239 static int stac92xx_build_controls(struct hda_codec *codec)
1241 struct sigmatel_spec *spec = codec->spec;
1242 struct auto_pin_cfg *cfg = &spec->autocfg;
1247 err = snd_hda_add_new_ctls(codec, spec->mixer);
1251 for (i = 0; i < spec->num_mixers; i++) {
1252 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1256 if (spec->num_dmuxes > 0) {
1257 stac_dmux_mixer.count = spec->num_dmuxes;
1258 err = snd_hda_ctl_add(codec,
1259 snd_ctl_new1(&stac_dmux_mixer, codec));
1263 if (spec->num_smuxes > 0) {
1264 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1265 struct hda_input_mux *smux = &spec->private_smux;
1266 /* check for mute support on SPDIF out */
1267 if (wcaps & AC_WCAP_OUT_AMP) {
1268 smux->items[smux->num_items].label = "Off";
1269 smux->items[smux->num_items].index = 0;
1271 spec->spdif_mute = 1;
1273 stac_smux_mixer.count = spec->num_smuxes;
1274 err = snd_hda_ctl_add(codec,
1275 snd_ctl_new1(&stac_smux_mixer, codec));
1280 if (spec->multiout.dig_out_nid) {
1281 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1284 err = snd_hda_create_spdif_share_sw(codec,
1288 spec->multiout.share_spdif = 1;
1290 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1291 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1296 /* if we have no master control, let's create it */
1297 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1298 unsigned int vmaster_tlv[4];
1299 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1300 HDA_OUTPUT, vmaster_tlv);
1301 /* correct volume offset */
1302 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1303 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1304 vmaster_tlv, slave_vols);
1308 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1309 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1315 stac92xx_free_kctls(codec); /* no longer needed */
1317 /* create jack input elements */
1318 if (spec->hp_detect) {
1319 for (i = 0; i < cfg->hp_outs; i++) {
1320 int type = SND_JACK_HEADPHONE;
1321 nid = cfg->hp_pins[i];
1322 /* jack detection */
1323 if (cfg->hp_outs == i)
1324 type |= SND_JACK_LINEOUT;
1325 err = stac92xx_add_jack(codec, nid, type);
1330 for (i = 0; i < cfg->line_outs; i++) {
1331 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1336 for (i = 0; i < AUTO_PIN_LAST; i++) {
1337 nid = cfg->input_pins[i];
1339 err = stac92xx_add_jack(codec, nid,
1340 SND_JACK_MICROPHONE);
1349 static unsigned int ref9200_pin_configs[8] = {
1350 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1351 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1354 static unsigned int gateway9200_m4_pin_configs[8] = {
1355 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1356 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1358 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1359 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1360 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1364 STAC 9200 pin configs for
1369 static unsigned int dell9200_d21_pin_configs[8] = {
1370 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1371 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1375 STAC 9200 pin configs for
1379 static unsigned int dell9200_d22_pin_configs[8] = {
1380 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1381 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1385 STAC 9200 pin configs for
1386 102801C4 (Dell Dimension E310)
1393 static unsigned int dell9200_d23_pin_configs[8] = {
1394 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1395 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1400 STAC 9200-32 pin configs for
1401 102801B5 (Dell Inspiron 630m)
1402 102801D8 (Dell Inspiron 640m)
1404 static unsigned int dell9200_m21_pin_configs[8] = {
1405 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1406 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1410 STAC 9200-32 pin configs for
1411 102801C2 (Dell Latitude D620)
1413 102801CC (Dell Latitude D820)
1417 static unsigned int dell9200_m22_pin_configs[8] = {
1418 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1419 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1423 STAC 9200-32 pin configs for
1424 102801CE (Dell XPS M1710)
1425 102801CF (Dell Precision M90)
1427 static unsigned int dell9200_m23_pin_configs[8] = {
1428 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1429 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1433 STAC 9200-32 pin configs for
1436 102801CB (Dell Latitude 120L)
1439 static unsigned int dell9200_m24_pin_configs[8] = {
1440 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1441 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1445 STAC 9200-32 pin configs for
1446 102801BD (Dell Inspiron E1505n)
1450 static unsigned int dell9200_m25_pin_configs[8] = {
1451 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1452 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1456 STAC 9200-32 pin configs for
1457 102801F5 (Dell Inspiron 1501)
1460 static unsigned int dell9200_m26_pin_configs[8] = {
1461 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1462 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1467 102801CD (Dell Inspiron E1705/9400)
1469 static unsigned int dell9200_m27_pin_configs[8] = {
1470 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1471 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1474 static unsigned int oqo9200_pin_configs[8] = {
1475 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1476 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1480 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1481 [STAC_REF] = ref9200_pin_configs,
1482 [STAC_9200_OQO] = oqo9200_pin_configs,
1483 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1484 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1485 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1486 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1487 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1488 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1489 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1490 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1491 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1492 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1493 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1494 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1495 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1498 static const char *stac9200_models[STAC_9200_MODELS] = {
1500 [STAC_9200_OQO] = "oqo",
1501 [STAC_9200_DELL_D21] = "dell-d21",
1502 [STAC_9200_DELL_D22] = "dell-d22",
1503 [STAC_9200_DELL_D23] = "dell-d23",
1504 [STAC_9200_DELL_M21] = "dell-m21",
1505 [STAC_9200_DELL_M22] = "dell-m22",
1506 [STAC_9200_DELL_M23] = "dell-m23",
1507 [STAC_9200_DELL_M24] = "dell-m24",
1508 [STAC_9200_DELL_M25] = "dell-m25",
1509 [STAC_9200_DELL_M26] = "dell-m26",
1510 [STAC_9200_DELL_M27] = "dell-m27",
1511 [STAC_9200_M4] = "gateway-m4",
1512 [STAC_9200_M4_2] = "gateway-m4-2",
1513 [STAC_9200_PANASONIC] = "panasonic",
1516 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1517 /* SigmaTel reference board */
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1519 "DFI LanParty", STAC_REF),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1521 "DFI LanParty", STAC_REF),
1522 /* Dell laptops have BIOS problem */
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1524 "unknown Dell", STAC_9200_DELL_D21),
1525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1526 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1528 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1529 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1530 "unknown Dell", STAC_9200_DELL_D22),
1531 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1532 "unknown Dell", STAC_9200_DELL_D22),
1533 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1534 "Dell Latitude D620", STAC_9200_DELL_M22),
1535 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1536 "unknown Dell", STAC_9200_DELL_D23),
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1538 "unknown Dell", STAC_9200_DELL_D23),
1539 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1540 "unknown Dell", STAC_9200_DELL_M22),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1542 "unknown Dell", STAC_9200_DELL_M24),
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1544 "unknown Dell", STAC_9200_DELL_M24),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1546 "Dell Latitude 120L", STAC_9200_DELL_M24),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1548 "Dell Latitude D820", STAC_9200_DELL_M22),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1550 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1552 "Dell XPS M1710", STAC_9200_DELL_M23),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1554 "Dell Precision M90", STAC_9200_DELL_M23),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1556 "unknown Dell", STAC_9200_DELL_M22),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1558 "unknown Dell", STAC_9200_DELL_M22),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1560 "unknown Dell", STAC_9200_DELL_M22),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1562 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1564 "unknown Dell", STAC_9200_DELL_D23),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1566 "unknown Dell", STAC_9200_DELL_D23),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1568 "unknown Dell", STAC_9200_DELL_D21),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1570 "unknown Dell", STAC_9200_DELL_D23),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1572 "unknown Dell", STAC_9200_DELL_D21),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1574 "unknown Dell", STAC_9200_DELL_M25),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1576 "unknown Dell", STAC_9200_DELL_M25),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1578 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1580 "unknown Dell", STAC_9200_DELL_M26),
1582 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1583 /* Gateway machines needs EAPD to be set on resume */
1584 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1585 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1586 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1588 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1592 static unsigned int ref925x_pin_configs[8] = {
1593 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1594 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1597 static unsigned int stac925xM1_pin_configs[8] = {
1598 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1599 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1602 static unsigned int stac925xM1_2_pin_configs[8] = {
1603 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1604 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1607 static unsigned int stac925xM2_pin_configs[8] = {
1608 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1609 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1612 static unsigned int stac925xM2_2_pin_configs[8] = {
1613 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1614 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1617 static unsigned int stac925xM3_pin_configs[8] = {
1618 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1619 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1622 static unsigned int stac925xM5_pin_configs[8] = {
1623 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1624 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1627 static unsigned int stac925xM6_pin_configs[8] = {
1628 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1629 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1632 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1633 [STAC_REF] = ref925x_pin_configs,
1634 [STAC_M1] = stac925xM1_pin_configs,
1635 [STAC_M1_2] = stac925xM1_2_pin_configs,
1636 [STAC_M2] = stac925xM2_pin_configs,
1637 [STAC_M2_2] = stac925xM2_2_pin_configs,
1638 [STAC_M3] = stac925xM3_pin_configs,
1639 [STAC_M5] = stac925xM5_pin_configs,
1640 [STAC_M6] = stac925xM6_pin_configs,
1643 static const char *stac925x_models[STAC_925x_MODELS] = {
1646 [STAC_M1_2] = "m1-2",
1648 [STAC_M2_2] = "m2-2",
1654 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1655 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1656 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1657 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1658 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1659 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1660 /* Not sure about the brand name for those */
1661 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1662 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1663 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1664 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1668 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1669 /* SigmaTel reference board */
1670 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1672 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1674 /* Default table for unknown ID */
1675 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1680 static unsigned int ref92hd73xx_pin_configs[13] = {
1681 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1682 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1683 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1687 static unsigned int dell_m6_pin_configs[13] = {
1688 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1689 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1690 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1694 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1695 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1696 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1697 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1698 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1699 [STAC_DELL_EQ] = dell_m6_pin_configs,
1702 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1703 [STAC_92HD73XX_NO_JD] = "no-jd",
1704 [STAC_92HD73XX_REF] = "ref",
1705 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1706 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1707 [STAC_DELL_M6_BOTH] = "dell-m6",
1708 [STAC_DELL_EQ] = "dell-eq",
1711 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1712 /* SigmaTel reference board */
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1714 "DFI LanParty", STAC_92HD73XX_REF),
1715 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1716 "DFI LanParty", STAC_92HD73XX_REF),
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1718 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1719 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1720 "unknown Dell", STAC_DELL_M6_DMIC),
1721 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1722 "unknown Dell", STAC_DELL_M6_BOTH),
1723 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1724 "unknown Dell", STAC_DELL_M6_BOTH),
1725 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1726 "unknown Dell", STAC_DELL_M6_AMIC),
1727 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1728 "unknown Dell", STAC_DELL_M6_AMIC),
1729 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1730 "unknown Dell", STAC_DELL_M6_DMIC),
1731 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1732 "unknown Dell", STAC_DELL_M6_DMIC),
1733 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1734 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1735 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1736 "Dell Studio 17", STAC_DELL_M6_DMIC),
1740 static unsigned int ref92hd83xxx_pin_configs[14] = {
1741 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1742 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1743 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1744 0x01451160, 0x98560170,
1747 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1748 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1749 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1752 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1753 [STAC_92HD83XXX_REF] = "ref",
1754 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1757 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1758 /* SigmaTel reference board */
1759 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1760 "DFI LanParty", STAC_92HD83XXX_REF),
1761 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1762 "DFI LanParty", STAC_92HD83XXX_REF),
1766 static unsigned int ref92hd71bxx_pin_configs[11] = {
1767 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1768 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1769 0x90a000f0, 0x01452050, 0x01452050,
1772 static unsigned int dell_m4_1_pin_configs[11] = {
1773 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1774 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1775 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
1778 static unsigned int dell_m4_2_pin_configs[11] = {
1779 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1780 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1781 0x40f000f0, 0x044413b0, 0x044413b0,
1784 static unsigned int dell_m4_3_pin_configs[11] = {
1785 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1786 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1787 0x40f000f0, 0x044413b0, 0x044413b0,
1790 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1791 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1792 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1793 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1794 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1795 [STAC_HP_M4] = NULL,
1796 [STAC_HP_DV5] = NULL,
1799 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1800 [STAC_92HD71BXX_REF] = "ref",
1801 [STAC_DELL_M4_1] = "dell-m4-1",
1802 [STAC_DELL_M4_2] = "dell-m4-2",
1803 [STAC_DELL_M4_3] = "dell-m4-3",
1804 [STAC_HP_M4] = "hp-m4",
1805 [STAC_HP_DV5] = "hp-dv5",
1808 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1809 /* SigmaTel reference board */
1810 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1811 "DFI LanParty", STAC_92HD71BXX_REF),
1812 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1813 "DFI LanParty", STAC_92HD71BXX_REF),
1814 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1815 "HP dv5", STAC_HP_M4),
1816 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1817 "HP dv7", STAC_HP_M4),
1818 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f7,
1819 "HP dv4", STAC_HP_DV5),
1820 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc,
1821 "HP dv7", STAC_HP_M4),
1822 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603,
1823 "HP dv5", STAC_HP_DV5),
1824 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1825 "unknown HP", STAC_HP_M4),
1826 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1827 "unknown Dell", STAC_DELL_M4_1),
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1829 "unknown Dell", STAC_DELL_M4_1),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1831 "unknown Dell", STAC_DELL_M4_1),
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1833 "unknown Dell", STAC_DELL_M4_1),
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1835 "unknown Dell", STAC_DELL_M4_1),
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1837 "unknown Dell", STAC_DELL_M4_1),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1839 "unknown Dell", STAC_DELL_M4_1),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1841 "unknown Dell", STAC_DELL_M4_2),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1843 "unknown Dell", STAC_DELL_M4_2),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1845 "unknown Dell", STAC_DELL_M4_2),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1847 "unknown Dell", STAC_DELL_M4_2),
1848 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1849 "unknown Dell", STAC_DELL_M4_3),
1853 static unsigned int ref922x_pin_configs[10] = {
1854 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1855 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1856 0x40000100, 0x40000100,
1860 STAC 922X pin configs for
1867 static unsigned int dell_922x_d81_pin_configs[10] = {
1868 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1869 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1870 0x01813122, 0x400001f2,
1874 STAC 922X pin configs for
1878 static unsigned int dell_922x_d82_pin_configs[10] = {
1879 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1880 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1881 0x01813122, 0x400001f1,
1885 STAC 922X pin configs for
1888 static unsigned int dell_922x_m81_pin_configs[10] = {
1889 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1890 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1891 0x40C003f1, 0x405003f0,
1895 STAC 9221 A1 pin configs for
1896 102801D7 (Dell XPS M1210)
1898 static unsigned int dell_922x_m82_pin_configs[10] = {
1899 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1900 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1901 0x508003f3, 0x405003f4,
1904 static unsigned int d945gtp3_pin_configs[10] = {
1905 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1906 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1907 0x02a19120, 0x40000100,
1910 static unsigned int d945gtp5_pin_configs[10] = {
1911 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1912 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1913 0x02a19320, 0x40000100,
1916 static unsigned int intel_mac_v1_pin_configs[10] = {
1917 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1918 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1919 0x400000fc, 0x400000fb,
1922 static unsigned int intel_mac_v2_pin_configs[10] = {
1923 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1924 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1925 0x400000fc, 0x400000fb,
1928 static unsigned int intel_mac_v3_pin_configs[10] = {
1929 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1930 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1931 0x400000fc, 0x400000fb,
1934 static unsigned int intel_mac_v4_pin_configs[10] = {
1935 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1936 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1937 0x400000fc, 0x400000fb,
1940 static unsigned int intel_mac_v5_pin_configs[10] = {
1941 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1942 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1943 0x400000fc, 0x400000fb,
1946 static unsigned int ecs202_pin_configs[10] = {
1947 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1948 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1949 0x9037012e, 0x40e000f2,
1952 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1953 [STAC_D945_REF] = ref922x_pin_configs,
1954 [STAC_D945GTP3] = d945gtp3_pin_configs,
1955 [STAC_D945GTP5] = d945gtp5_pin_configs,
1956 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1957 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1958 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1959 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1960 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1961 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1962 /* for backward compatibility */
1963 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1964 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1965 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1966 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1967 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1968 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1969 [STAC_ECS_202] = ecs202_pin_configs,
1970 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1971 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1972 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1973 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1976 static const char *stac922x_models[STAC_922X_MODELS] = {
1977 [STAC_D945_REF] = "ref",
1978 [STAC_D945GTP5] = "5stack",
1979 [STAC_D945GTP3] = "3stack",
1980 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1981 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1982 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1983 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1984 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1985 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1986 /* for backward compatibility */
1987 [STAC_MACMINI] = "macmini",
1988 [STAC_MACBOOK] = "macbook",
1989 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1990 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1991 [STAC_IMAC_INTEL] = "imac-intel",
1992 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1993 [STAC_ECS_202] = "ecs202",
1994 [STAC_922X_DELL_D81] = "dell-d81",
1995 [STAC_922X_DELL_D82] = "dell-d82",
1996 [STAC_922X_DELL_M81] = "dell-m81",
1997 [STAC_922X_DELL_M82] = "dell-m82",
2000 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2001 /* SigmaTel reference board */
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2003 "DFI LanParty", STAC_D945_REF),
2004 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2005 "DFI LanParty", STAC_D945_REF),
2006 /* Intel 945G based systems */
2007 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2008 "Intel D945G", STAC_D945GTP3),
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2010 "Intel D945G", STAC_D945GTP3),
2011 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2012 "Intel D945G", STAC_D945GTP3),
2013 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2014 "Intel D945G", STAC_D945GTP3),
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2016 "Intel D945G", STAC_D945GTP3),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2018 "Intel D945G", STAC_D945GTP3),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2020 "Intel D945G", STAC_D945GTP3),
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2022 "Intel D945G", STAC_D945GTP3),
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2024 "Intel D945G", STAC_D945GTP3),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2026 "Intel D945G", STAC_D945GTP3),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2028 "Intel D945G", STAC_D945GTP3),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2030 "Intel D945G", STAC_D945GTP3),
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2032 "Intel D945G", STAC_D945GTP3),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2034 "Intel D945G", STAC_D945GTP3),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2036 "Intel D945G", STAC_D945GTP3),
2037 /* Intel D945G 5-stack systems */
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2039 "Intel D945G", STAC_D945GTP5),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2041 "Intel D945G", STAC_D945GTP5),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2043 "Intel D945G", STAC_D945GTP5),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2045 "Intel D945G", STAC_D945GTP5),
2046 /* Intel 945P based systems */
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2048 "Intel D945P", STAC_D945GTP3),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2050 "Intel D945P", STAC_D945GTP3),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2052 "Intel D945P", STAC_D945GTP3),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2054 "Intel D945P", STAC_D945GTP3),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2056 "Intel D945P", STAC_D945GTP3),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2058 "Intel D945P", STAC_D945GTP5),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2061 "Intel D945", STAC_D945_REF),
2063 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2064 SND_PCI_QUIRK(0x8384, 0x7680,
2065 "Mac", STAC_INTEL_MAC_AUTO),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2068 "unknown Dell", STAC_922X_DELL_D81),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2070 "unknown Dell", STAC_922X_DELL_D81),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2072 "unknown Dell", STAC_922X_DELL_D81),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2074 "unknown Dell", STAC_922X_DELL_D82),
2075 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2076 "unknown Dell", STAC_922X_DELL_M81),
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2078 "unknown Dell", STAC_922X_DELL_D82),
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2080 "unknown Dell", STAC_922X_DELL_D81),
2081 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2082 "unknown Dell", STAC_922X_DELL_D81),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2084 "Dell XPS M1210", STAC_922X_DELL_M82),
2085 /* ECS/PC Chips boards */
2086 SND_PCI_QUIRK(0x1019, 0x2144,
2087 "ECS/PC chips", STAC_ECS_202),
2088 SND_PCI_QUIRK(0x1019, 0x2608,
2089 "ECS/PC chips", STAC_ECS_202),
2090 SND_PCI_QUIRK(0x1019, 0x2633,
2091 "ECS/PC chips P17G/1333", STAC_ECS_202),
2092 SND_PCI_QUIRK(0x1019, 0x2811,
2093 "ECS/PC chips", STAC_ECS_202),
2094 SND_PCI_QUIRK(0x1019, 0x2812,
2095 "ECS/PC chips", STAC_ECS_202),
2096 SND_PCI_QUIRK(0x1019, 0x2813,
2097 "ECS/PC chips", STAC_ECS_202),
2098 SND_PCI_QUIRK(0x1019, 0x2814,
2099 "ECS/PC chips", STAC_ECS_202),
2100 SND_PCI_QUIRK(0x1019, 0x2815,
2101 "ECS/PC chips", STAC_ECS_202),
2102 SND_PCI_QUIRK(0x1019, 0x2816,
2103 "ECS/PC chips", STAC_ECS_202),
2104 SND_PCI_QUIRK(0x1019, 0x2817,
2105 "ECS/PC chips", STAC_ECS_202),
2106 SND_PCI_QUIRK(0x1019, 0x2818,
2107 "ECS/PC chips", STAC_ECS_202),
2108 SND_PCI_QUIRK(0x1019, 0x2819,
2109 "ECS/PC chips", STAC_ECS_202),
2110 SND_PCI_QUIRK(0x1019, 0x2820,
2111 "ECS/PC chips", STAC_ECS_202),
2115 static unsigned int ref927x_pin_configs[14] = {
2116 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2117 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2118 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2119 0x01c42190, 0x40000100,
2122 static unsigned int d965_3st_pin_configs[14] = {
2123 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2124 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2125 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2126 0x40000100, 0x40000100
2129 static unsigned int d965_5st_pin_configs[14] = {
2130 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2131 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2132 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2133 0x40000100, 0x40000100
2136 static unsigned int dell_3st_pin_configs[14] = {
2137 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2138 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2139 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2140 0x40c003fc, 0x40000100
2143 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2144 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2145 [STAC_D965_REF] = ref927x_pin_configs,
2146 [STAC_D965_3ST] = d965_3st_pin_configs,
2147 [STAC_D965_5ST] = d965_5st_pin_configs,
2148 [STAC_DELL_3ST] = dell_3st_pin_configs,
2149 [STAC_DELL_BIOS] = NULL,
2152 static const char *stac927x_models[STAC_927X_MODELS] = {
2153 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2154 [STAC_D965_REF] = "ref",
2155 [STAC_D965_3ST] = "3stack",
2156 [STAC_D965_5ST] = "5stack",
2157 [STAC_DELL_3ST] = "dell-3stack",
2158 [STAC_DELL_BIOS] = "dell-bios",
2161 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2162 /* SigmaTel reference board */
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2164 "DFI LanParty", STAC_D965_REF),
2165 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2166 "DFI LanParty", STAC_D965_REF),
2167 /* Intel 946 based systems */
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2170 /* 965 based 3 stack systems */
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2179 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2181 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2183 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2185 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
2187 /* Dell 3 stack systems */
2188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2189 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2191 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2192 /* Dell 3 stack systems with verb table in BIOS */
2193 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2195 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2196 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2197 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2198 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2199 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2200 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2201 /* 965 based 5 stack systems */
2202 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2203 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2204 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2205 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2206 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2207 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2208 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2209 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2210 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
2214 static unsigned int ref9205_pin_configs[12] = {
2215 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2216 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2217 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2221 STAC 9205 pin configs for
2228 10280228 (Dell Vostro 1500)
2230 static unsigned int dell_9205_m42_pin_configs[12] = {
2231 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2232 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2233 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2237 STAC 9205 pin configs for
2241 102801FF (Dell Precision M4300)
2246 static unsigned int dell_9205_m43_pin_configs[12] = {
2247 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2248 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2249 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2252 static unsigned int dell_9205_m44_pin_configs[12] = {
2253 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2254 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2255 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2258 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2259 [STAC_9205_REF] = ref9205_pin_configs,
2260 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2261 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2262 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2263 [STAC_9205_EAPD] = NULL,
2266 static const char *stac9205_models[STAC_9205_MODELS] = {
2267 [STAC_9205_REF] = "ref",
2268 [STAC_9205_DELL_M42] = "dell-m42",
2269 [STAC_9205_DELL_M43] = "dell-m43",
2270 [STAC_9205_DELL_M44] = "dell-m44",
2271 [STAC_9205_EAPD] = "eapd",
2274 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2275 /* SigmaTel reference board */
2276 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2277 "DFI LanParty", STAC_9205_REF),
2278 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2279 "DFI LanParty", STAC_9205_REF),
2281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2282 "unknown Dell", STAC_9205_DELL_M42),
2283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2284 "unknown Dell", STAC_9205_DELL_M42),
2285 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2286 "Dell Precision", STAC_9205_DELL_M43),
2287 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2288 "Dell Precision", STAC_9205_DELL_M43),
2289 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2290 "Dell Precision", STAC_9205_DELL_M43),
2291 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2292 "unknown Dell", STAC_9205_DELL_M42),
2293 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2294 "unknown Dell", STAC_9205_DELL_M42),
2295 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2296 "Dell Precision", STAC_9205_DELL_M43),
2297 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2298 "Dell Precision M4300", STAC_9205_DELL_M43),
2299 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2300 "unknown Dell", STAC_9205_DELL_M42),
2301 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2302 "Dell Precision", STAC_9205_DELL_M43),
2303 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2304 "Dell Precision", STAC_9205_DELL_M43),
2305 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2306 "Dell Precision", STAC_9205_DELL_M43),
2307 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2308 "Dell Inspiron", STAC_9205_DELL_M44),
2309 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2310 "Dell Vostro 1500", STAC_9205_DELL_M42),
2312 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2316 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2319 struct sigmatel_spec *spec = codec->spec;
2321 kfree(spec->pin_configs);
2322 spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs),
2324 if (!spec->pin_configs)
2327 for (i = 0; i < spec->num_pins; i++) {
2328 hda_nid_t nid = spec->pin_nids[i];
2329 unsigned int pin_cfg;
2331 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2332 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2333 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2335 spec->pin_configs[i] = pin_cfg;
2341 static void stac92xx_set_config_reg(struct hda_codec *codec,
2342 hda_nid_t pin_nid, unsigned int pin_config)
2345 snd_hda_codec_write(codec, pin_nid, 0,
2346 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2347 pin_config & 0x000000ff);
2348 snd_hda_codec_write(codec, pin_nid, 0,
2349 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2350 (pin_config & 0x0000ff00) >> 8);
2351 snd_hda_codec_write(codec, pin_nid, 0,
2352 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2353 (pin_config & 0x00ff0000) >> 16);
2354 snd_hda_codec_write(codec, pin_nid, 0,
2355 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2357 i = snd_hda_codec_read(codec, pin_nid, 0,
2358 AC_VERB_GET_CONFIG_DEFAULT,
2360 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2364 static void stac92xx_set_config_regs(struct hda_codec *codec)
2367 struct sigmatel_spec *spec = codec->spec;
2369 if (!spec->pin_configs)
2372 for (i = 0; i < spec->num_pins; i++)
2373 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2374 spec->pin_configs[i]);
2377 static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
2379 struct sigmatel_spec *spec = codec->spec;
2382 return stac92xx_save_bios_config_regs(codec);
2384 kfree(spec->pin_configs);
2385 spec->pin_configs = kmemdup(pins,
2386 spec->num_pins * sizeof(*pins),
2388 if (!spec->pin_configs)
2391 stac92xx_set_config_regs(codec);
2395 static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid,
2398 struct sigmatel_spec *spec = codec->spec;
2401 for (i = 0; i < spec->num_pins; i++) {
2402 if (spec->pin_nids[i] == nid) {
2403 spec->pin_configs[i] = cfg;
2404 stac92xx_set_config_reg(codec, nid, cfg);
2411 * Analog playback callbacks
2413 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2414 struct hda_codec *codec,
2415 struct snd_pcm_substream *substream)
2417 struct sigmatel_spec *spec = codec->spec;
2418 if (spec->stream_delay)
2419 msleep(spec->stream_delay);
2420 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2424 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2425 struct hda_codec *codec,
2426 unsigned int stream_tag,
2427 unsigned int format,
2428 struct snd_pcm_substream *substream)
2430 struct sigmatel_spec *spec = codec->spec;
2431 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2434 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2435 struct hda_codec *codec,
2436 struct snd_pcm_substream *substream)
2438 struct sigmatel_spec *spec = codec->spec;
2439 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2443 * Digital playback callbacks
2445 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2446 struct hda_codec *codec,
2447 struct snd_pcm_substream *substream)
2449 struct sigmatel_spec *spec = codec->spec;
2450 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2453 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2454 struct hda_codec *codec,
2455 struct snd_pcm_substream *substream)
2457 struct sigmatel_spec *spec = codec->spec;
2458 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2461 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2462 struct hda_codec *codec,
2463 unsigned int stream_tag,
2464 unsigned int format,
2465 struct snd_pcm_substream *substream)
2467 struct sigmatel_spec *spec = codec->spec;
2468 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2469 stream_tag, format, substream);
2474 * Analog capture callbacks
2476 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2477 struct hda_codec *codec,
2478 unsigned int stream_tag,
2479 unsigned int format,
2480 struct snd_pcm_substream *substream)
2482 struct sigmatel_spec *spec = codec->spec;
2483 hda_nid_t nid = spec->adc_nids[substream->number];
2485 if (spec->powerdown_adcs) {
2487 snd_hda_codec_write(codec, nid, 0,
2488 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2490 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2494 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2495 struct hda_codec *codec,
2496 struct snd_pcm_substream *substream)
2498 struct sigmatel_spec *spec = codec->spec;
2499 hda_nid_t nid = spec->adc_nids[substream->number];
2501 snd_hda_codec_cleanup_stream(codec, nid);
2502 if (spec->powerdown_adcs)
2503 snd_hda_codec_write(codec, nid, 0,
2504 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2508 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2512 /* NID is set in stac92xx_build_pcms */
2514 .open = stac92xx_dig_playback_pcm_open,
2515 .close = stac92xx_dig_playback_pcm_close,
2516 .prepare = stac92xx_dig_playback_pcm_prepare
2520 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2524 /* NID is set in stac92xx_build_pcms */
2527 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2531 .nid = 0x02, /* NID to query formats and rates */
2533 .open = stac92xx_playback_pcm_open,
2534 .prepare = stac92xx_playback_pcm_prepare,
2535 .cleanup = stac92xx_playback_pcm_cleanup
2539 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2543 .nid = 0x06, /* NID to query formats and rates */
2545 .open = stac92xx_playback_pcm_open,
2546 .prepare = stac92xx_playback_pcm_prepare,
2547 .cleanup = stac92xx_playback_pcm_cleanup
2551 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2554 /* NID + .substreams is set in stac92xx_build_pcms */
2556 .prepare = stac92xx_capture_pcm_prepare,
2557 .cleanup = stac92xx_capture_pcm_cleanup
2561 static int stac92xx_build_pcms(struct hda_codec *codec)
2563 struct sigmatel_spec *spec = codec->spec;
2564 struct hda_pcm *info = spec->pcm_rec;
2566 codec->num_pcms = 1;
2567 codec->pcm_info = info;
2569 info->name = "STAC92xx Analog";
2570 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2571 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2572 spec->multiout.dac_nids[0];
2573 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2574 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2575 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2577 if (spec->alt_switch) {
2580 info->name = "STAC92xx Analog Alt";
2581 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2584 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2587 info->name = "STAC92xx Digital";
2588 info->pcm_type = spec->autocfg.dig_out_type;
2589 if (spec->multiout.dig_out_nid) {
2590 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2591 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2593 if (spec->dig_in_nid) {
2594 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2595 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2602 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2604 unsigned int pincap = snd_hda_param_read(codec, nid,
2606 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2607 if (pincap & AC_PINCAP_VREF_100)
2608 return AC_PINCTL_VREF_100;
2609 if (pincap & AC_PINCAP_VREF_80)
2610 return AC_PINCTL_VREF_80;
2611 if (pincap & AC_PINCAP_VREF_50)
2612 return AC_PINCTL_VREF_50;
2613 if (pincap & AC_PINCAP_VREF_GRD)
2614 return AC_PINCTL_VREF_GRD;
2618 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2621 snd_hda_codec_write_cache(codec, nid, 0,
2622 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2625 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2627 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2628 struct snd_ctl_elem_value *ucontrol)
2630 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2631 struct sigmatel_spec *spec = codec->spec;
2633 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2637 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2638 unsigned char type);
2640 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2641 struct snd_ctl_elem_value *ucontrol)
2643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2644 struct sigmatel_spec *spec = codec->spec;
2645 int nid = kcontrol->private_value;
2647 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2649 /* check to be sure that the ports are upto date with
2652 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2657 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2659 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2661 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2662 struct sigmatel_spec *spec = codec->spec;
2663 int io_idx = kcontrol-> private_value & 0xff;
2665 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2669 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2671 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2672 struct sigmatel_spec *spec = codec->spec;
2673 hda_nid_t nid = kcontrol->private_value >> 8;
2674 int io_idx = kcontrol-> private_value & 0xff;
2675 unsigned short val = !!ucontrol->value.integer.value[0];
2677 spec->io_switch[io_idx] = val;
2680 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2682 unsigned int pinctl = AC_PINCTL_IN_EN;
2683 if (io_idx) /* set VREF for mic */
2684 pinctl |= stac92xx_get_vref(codec, nid);
2685 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2688 /* check the auto-mute again: we need to mute/unmute the speaker
2689 * appropriately according to the pin direction
2691 if (spec->hp_detect)
2692 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2697 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2699 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2700 struct snd_ctl_elem_value *ucontrol)
2702 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2703 struct sigmatel_spec *spec = codec->spec;
2705 ucontrol->value.integer.value[0] = spec->clfe_swap;
2709 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2710 struct snd_ctl_elem_value *ucontrol)
2712 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2713 struct sigmatel_spec *spec = codec->spec;
2714 hda_nid_t nid = kcontrol->private_value & 0xff;
2715 unsigned int val = !!ucontrol->value.integer.value[0];
2717 if (spec->clfe_swap == val)
2720 spec->clfe_swap = val;
2722 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2723 spec->clfe_swap ? 0x4 : 0x0);
2728 #define STAC_CODEC_HP_SWITCH(xname) \
2729 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2732 .info = stac92xx_hp_switch_info, \
2733 .get = stac92xx_hp_switch_get, \
2734 .put = stac92xx_hp_switch_put, \
2737 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2738 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2741 .info = stac92xx_io_switch_info, \
2742 .get = stac92xx_io_switch_get, \
2743 .put = stac92xx_io_switch_put, \
2744 .private_value = xpval, \
2747 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2748 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2751 .info = stac92xx_clfe_switch_info, \
2752 .get = stac92xx_clfe_switch_get, \
2753 .put = stac92xx_clfe_switch_put, \
2754 .private_value = xpval, \
2758 STAC_CTL_WIDGET_VOL,
2759 STAC_CTL_WIDGET_MUTE,
2760 STAC_CTL_WIDGET_MONO_MUX,
2761 STAC_CTL_WIDGET_AMP_MUX,
2762 STAC_CTL_WIDGET_AMP_VOL,
2763 STAC_CTL_WIDGET_HP_SWITCH,
2764 STAC_CTL_WIDGET_IO_SWITCH,
2765 STAC_CTL_WIDGET_CLFE_SWITCH
2768 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2769 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2770 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2773 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2774 STAC_CODEC_HP_SWITCH(NULL),
2775 STAC_CODEC_IO_SWITCH(NULL, 0),
2776 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2779 /* add dynamic controls */
2780 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2781 struct snd_kcontrol_new *ktemp,
2782 int idx, const char *name,
2785 struct snd_kcontrol_new *knew;
2787 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2788 knew = snd_array_new(&spec->kctls);
2793 knew->name = kstrdup(name, GFP_KERNEL);
2796 knew->private_value = val;
2800 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2801 int type, int idx, const char *name,
2804 return stac92xx_add_control_temp(spec,
2805 &stac92xx_control_templates[type],
2810 /* add dynamic controls */
2811 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2812 const char *name, unsigned long val)
2814 return stac92xx_add_control_idx(spec, type, 0, name, val);
2817 /* check whether the line-input can be used as line-out */
2818 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2820 struct sigmatel_spec *spec = codec->spec;
2821 struct auto_pin_cfg *cfg = &spec->autocfg;
2823 unsigned int pincap;
2825 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2827 nid = cfg->input_pins[AUTO_PIN_LINE];
2828 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2829 if (pincap & AC_PINCAP_OUT)
2834 /* check whether the mic-input can be used as line-out */
2835 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2837 struct sigmatel_spec *spec = codec->spec;
2838 struct auto_pin_cfg *cfg = &spec->autocfg;
2839 unsigned int def_conf, pincap;
2840 unsigned int mic_pin;
2842 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2844 mic_pin = AUTO_PIN_MIC;
2846 hda_nid_t nid = cfg->input_pins[mic_pin];
2847 def_conf = snd_hda_codec_read(codec, nid, 0,
2848 AC_VERB_GET_CONFIG_DEFAULT, 0);
2849 /* some laptops have an internal analog microphone
2850 * which can't be used as a output */
2851 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2852 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2853 if (pincap & AC_PINCAP_OUT)
2856 if (mic_pin == AUTO_PIN_MIC)
2857 mic_pin = AUTO_PIN_FRONT_MIC;
2864 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2868 for (i = 0; i < spec->multiout.num_dacs; i++) {
2869 if (spec->multiout.dac_nids[i] == nid)
2876 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2879 if (is_in_dac_nids(spec, nid))
2881 for (i = 0; i < spec->autocfg.hp_outs; i++)
2882 if (spec->hp_dacs[i] == nid)
2884 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2885 if (spec->speaker_dacs[i] == nid)
2890 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2892 struct sigmatel_spec *spec = codec->spec;
2894 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2895 unsigned int wcaps, wtype;
2897 conn_len = snd_hda_get_connections(codec, nid, conn,
2898 HDA_MAX_CONNECTIONS);
2899 for (j = 0; j < conn_len; j++) {
2900 wcaps = snd_hda_param_read(codec, conn[j],
2901 AC_PAR_AUDIO_WIDGET_CAP);
2902 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2903 /* we check only analog outputs */
2904 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2906 /* if this route has a free DAC, assign it */
2907 if (!check_all_dac_nids(spec, conn[j])) {
2909 /* select this DAC in the pin's input mux */
2910 snd_hda_codec_write_cache(codec, nid, 0,
2911 AC_VERB_SET_CONNECT_SEL, j);
2919 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2920 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2923 * Fill in the dac_nids table from the parsed pin configuration
2924 * This function only works when every pin in line_out_pins[]
2925 * contains atleast one DAC in its connection list. Some 92xx
2926 * codecs are not connected directly to a DAC, such as the 9200
2927 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2929 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2931 struct sigmatel_spec *spec = codec->spec;
2932 struct auto_pin_cfg *cfg = &spec->autocfg;
2936 for (i = 0; i < cfg->line_outs; i++) {
2937 nid = cfg->line_out_pins[i];
2938 dac = get_unassigned_dac(codec, nid);
2940 if (spec->multiout.num_dacs > 0) {
2941 /* we have already working output pins,
2942 * so let's drop the broken ones again
2944 cfg->line_outs = spec->multiout.num_dacs;
2947 /* error out, no available DAC found */
2949 "%s: No available DAC for pin 0x%x\n",
2953 add_spec_dacs(spec, dac);
2956 /* add line-in as output */
2957 nid = check_line_out_switch(codec);
2959 dac = get_unassigned_dac(codec, nid);
2961 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2962 nid, cfg->line_outs);
2963 cfg->line_out_pins[cfg->line_outs] = nid;
2965 spec->line_switch = nid;
2966 add_spec_dacs(spec, dac);
2969 /* add mic as output */
2970 nid = check_mic_out_switch(codec);
2972 dac = get_unassigned_dac(codec, nid);
2974 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2975 nid, cfg->line_outs);
2976 cfg->line_out_pins[cfg->line_outs] = nid;
2978 spec->mic_switch = nid;
2979 add_spec_dacs(spec, dac);
2983 for (i = 0; i < cfg->hp_outs; i++) {
2984 nid = cfg->hp_pins[i];
2985 dac = get_unassigned_dac(codec, nid);
2987 if (!spec->multiout.hp_nid)
2988 spec->multiout.hp_nid = dac;
2990 add_spec_extra_dacs(spec, dac);
2992 spec->hp_dacs[i] = dac;
2995 for (i = 0; i < cfg->speaker_outs; i++) {
2996 nid = cfg->speaker_pins[i];
2997 dac = get_unassigned_dac(codec, nid);
2999 add_spec_extra_dacs(spec, dac);
3000 spec->speaker_dacs[i] = dac;
3003 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3004 spec->multiout.num_dacs,
3005 spec->multiout.dac_nids[0],
3006 spec->multiout.dac_nids[1],
3007 spec->multiout.dac_nids[2],
3008 spec->multiout.dac_nids[3],
3009 spec->multiout.dac_nids[4]);
3014 /* create volume control/switch for the given prefx type */
3015 static int create_controls(struct hda_codec *codec, const char *pfx,
3016 hda_nid_t nid, int chs)
3018 struct sigmatel_spec *spec = codec->spec;
3022 if (!spec->check_volume_offset) {
3023 unsigned int caps, step, nums, db_scale;
3024 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3025 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3026 AC_AMPCAP_STEP_SIZE_SHIFT;
3027 step = (step + 1) * 25; /* in .01dB unit */
3028 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3029 AC_AMPCAP_NUM_STEPS_SHIFT;
3030 db_scale = nums * step;
3031 /* if dB scale is over -64dB, and finer enough,
3032 * let's reduce it to half
3034 if (db_scale > 6400 && nums >= 0x1f)
3035 spec->volume_offset = nums / 2;
3036 spec->check_volume_offset = 1;
3039 sprintf(name, "%s Playback Volume", pfx);
3040 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
3041 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3042 spec->volume_offset));
3045 sprintf(name, "%s Playback Switch", pfx);
3046 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
3047 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3053 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3055 if (spec->multiout.num_dacs > 4) {
3056 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3059 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3060 spec->multiout.num_dacs++;
3065 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3068 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3069 if (!spec->multiout.extra_out_nid[i]) {
3070 spec->multiout.extra_out_nid[i] = nid;
3074 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3078 static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid)
3082 if (spec->autocfg.line_outs != 1)
3084 if (spec->multiout.hp_nid == nid)
3086 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
3087 if (spec->multiout.extra_out_nid[i] == nid)
3092 /* add playback controls from the parsed DAC table */
3093 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3094 const struct auto_pin_cfg *cfg)
3096 struct sigmatel_spec *spec = codec->spec;
3097 static const char *chname[4] = {
3098 "Front", "Surround", NULL /*CLFE*/, "Side"
3102 unsigned int wid_caps;
3104 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) {
3105 nid = spec->multiout.dac_nids[i];
3108 err = create_controls(codec, "Center", nid, 1);
3111 err = create_controls(codec, "LFE", nid, 2);
3115 wid_caps = get_wcaps(codec, nid);
3117 if (wid_caps & AC_WCAP_LR_SWAP) {
3118 err = stac92xx_add_control(spec,
3119 STAC_CTL_WIDGET_CLFE_SWITCH,
3120 "Swap Center/LFE Playback Switch", nid);
3127 const char *name = chname[i];
3128 /* if it's a single DAC, assign a better name */
3129 if (!i && is_unique_dac(spec, nid)) {
3130 switch (cfg->line_out_type) {
3131 case AUTO_PIN_HP_OUT:
3134 case AUTO_PIN_SPEAKER_OUT:
3139 err = create_controls(codec, name, nid, 3);
3145 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3146 err = stac92xx_add_control(spec,
3147 STAC_CTL_WIDGET_HP_SWITCH,
3148 "Headphone as Line Out Switch",
3149 cfg->hp_pins[cfg->hp_outs - 1]);
3154 if (spec->line_switch) {
3155 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3156 "Line In as Output Switch",
3157 spec->line_switch << 8);
3162 if (spec->mic_switch) {
3163 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3164 "Mic as Output Switch",
3165 (spec->mic_switch << 8) | 1);
3173 /* add playback controls for Speaker and HP outputs */
3174 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3175 struct auto_pin_cfg *cfg)
3177 struct sigmatel_spec *spec = codec->spec;
3182 for (i = 0; i < cfg->hp_outs; i++) {
3183 static const char *pfxs[] = {
3184 "Headphone", "Headphone2", "Headphone3",
3186 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3187 if (wid_caps & AC_WCAP_UNSOL_CAP)
3188 spec->hp_detect = 1;
3189 if (nums >= ARRAY_SIZE(pfxs))
3191 nid = spec->hp_dacs[i];
3194 err = create_controls(codec, pfxs[nums++], nid, 3);
3199 for (i = 0; i < cfg->speaker_outs; i++) {
3200 static const char *pfxs[] = {
3201 "Speaker", "External Speaker", "Speaker2",
3203 if (nums >= ARRAY_SIZE(pfxs))
3205 nid = spec->speaker_dacs[i];
3208 err = create_controls(codec, pfxs[nums++], nid, 3);
3215 /* labels for mono mux outputs */
3216 static const char *stac92xx_mono_labels[4] = {
3217 "DAC0", "DAC1", "Mixer", "DAC2"
3220 /* create mono mux for mono out on capable codecs */
3221 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3223 struct sigmatel_spec *spec = codec->spec;
3224 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3226 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3228 num_cons = snd_hda_get_connections(codec,
3231 HDA_MAX_NUM_INPUTS);
3232 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3235 for (i = 0; i < num_cons; i++) {
3236 mono_mux->items[mono_mux->num_items].label =
3237 stac92xx_mono_labels[i];
3238 mono_mux->items[mono_mux->num_items].index = i;
3239 mono_mux->num_items++;
3242 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3243 "Mono Mux", spec->mono_nid);
3246 /* labels for amp mux outputs */
3247 static const char *stac92xx_amp_labels[3] = {
3248 "Front Microphone", "Microphone", "Line In",
3251 /* create amp out controls mux on capable codecs */
3252 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3254 struct sigmatel_spec *spec = codec->spec;
3255 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3258 for (i = 0; i < spec->num_amps; i++) {
3259 amp_mux->items[amp_mux->num_items].label =
3260 stac92xx_amp_labels[i];
3261 amp_mux->items[amp_mux->num_items].index = i;
3262 amp_mux->num_items++;
3265 if (spec->num_amps > 1) {
3266 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3267 "Amp Selector Capture Switch", 0);
3271 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3272 "Amp Capture Volume",
3273 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3277 /* create PC beep volume controls */
3278 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3281 struct sigmatel_spec *spec = codec->spec;
3282 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3285 /* check for mute support for the the amp */
3286 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3287 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3288 "PC Beep Playback Switch",
3289 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3294 /* check to see if there is volume support for the amp */
3295 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3296 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3297 "PC Beep Playback Volume",
3298 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3305 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3306 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3308 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3309 struct snd_ctl_elem_value *ucontrol)
3311 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3312 ucontrol->value.integer.value[0] = codec->beep->enabled;
3316 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3317 struct snd_ctl_elem_value *ucontrol)
3319 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3320 int enabled = !!ucontrol->value.integer.value[0];
3321 if (codec->beep->enabled != enabled) {
3322 codec->beep->enabled = enabled;
3328 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3329 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3330 .info = stac92xx_dig_beep_switch_info,
3331 .get = stac92xx_dig_beep_switch_get,
3332 .put = stac92xx_dig_beep_switch_put,
3335 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3337 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3338 0, "PC Beep Playback Switch", 0);
3342 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3344 struct sigmatel_spec *spec = codec->spec;
3345 int wcaps, nid, i, err = 0;
3347 for (i = 0; i < spec->num_muxes; i++) {
3348 nid = spec->mux_nids[i];
3349 wcaps = get_wcaps(codec, nid);
3351 if (wcaps & AC_WCAP_OUT_AMP) {
3352 err = stac92xx_add_control_idx(spec,
3353 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3354 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3362 static const char *stac92xx_spdif_labels[3] = {
3363 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3366 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3368 struct sigmatel_spec *spec = codec->spec;
3369 struct hda_input_mux *spdif_mux = &spec->private_smux;
3370 const char **labels = spec->spdif_labels;
3372 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3374 num_cons = snd_hda_get_connections(codec,
3377 HDA_MAX_NUM_INPUTS);
3382 labels = stac92xx_spdif_labels;
3384 for (i = 0; i < num_cons; i++) {
3385 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3386 spdif_mux->items[spdif_mux->num_items].index = i;
3387 spdif_mux->num_items++;
3393 /* labels for dmic mux inputs */
3394 static const char *stac92xx_dmic_labels[5] = {
3395 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3396 "Digital Mic 3", "Digital Mic 4"
3399 /* create playback/capture controls for input pins on dmic capable codecs */
3400 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3401 const struct auto_pin_cfg *cfg)
3403 struct sigmatel_spec *spec = codec->spec;
3404 struct hda_input_mux *dimux = &spec->private_dimux;
3405 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3409 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3410 dimux->items[dimux->num_items].index = 0;
3413 for (i = 0; i < spec->num_dmics; i++) {
3418 unsigned int def_conf;
3420 def_conf = snd_hda_codec_read(codec,
3423 AC_VERB_GET_CONFIG_DEFAULT,
3425 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3428 nid = spec->dmic_nids[i];
3429 num_cons = snd_hda_get_connections(codec,
3432 HDA_MAX_NUM_INPUTS);
3433 for (j = 0; j < num_cons; j++)
3434 if (con_lst[j] == nid) {
3440 wcaps = get_wcaps(codec, nid) &
3441 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3444 sprintf(name, "%s Capture Volume",
3445 stac92xx_dmic_labels[dimux->num_items]);
3447 err = stac92xx_add_control(spec,
3448 STAC_CTL_WIDGET_VOL,
3450 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3451 (wcaps & AC_WCAP_OUT_AMP) ?
3452 HDA_OUTPUT : HDA_INPUT));
3457 dimux->items[dimux->num_items].label =
3458 stac92xx_dmic_labels[dimux->num_items];
3459 dimux->items[dimux->num_items].index = index;
3466 /* create playback/capture controls for input pins */
3467 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3469 struct sigmatel_spec *spec = codec->spec;
3470 struct hda_input_mux *imux = &spec->private_imux;
3471 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3474 for (i = 0; i < AUTO_PIN_LAST; i++) {
3477 if (!cfg->input_pins[i])
3480 for (j = 0; j < spec->num_muxes; j++) {
3482 num_cons = snd_hda_get_connections(codec,
3485 HDA_MAX_NUM_INPUTS);
3486 for (k = 0; k < num_cons; k++)
3487 if (con_lst[k] == cfg->input_pins[i]) {
3494 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3495 imux->items[imux->num_items].index = index;
3499 if (imux->num_items) {
3501 * Set the current input for the muxes.
3502 * The STAC9221 has two input muxes with identical source
3503 * NID lists. Hopefully this won't get confused.
3505 for (i = 0; i < spec->num_muxes; i++) {
3506 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3507 AC_VERB_SET_CONNECT_SEL,
3508 imux->items[0].index);
3515 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3517 struct sigmatel_spec *spec = codec->spec;
3520 for (i = 0; i < spec->autocfg.line_outs; i++) {
3521 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3522 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3526 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3528 struct sigmatel_spec *spec = codec->spec;
3531 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3533 pin = spec->autocfg.hp_pins[i];
3534 if (pin) /* connect to front */
3535 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3537 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3539 pin = spec->autocfg.speaker_pins[i];
3540 if (pin) /* connect to front */
3541 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3545 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3547 struct sigmatel_spec *spec = codec->spec;
3550 if ((err = snd_hda_parse_pin_def_config(codec,
3552 spec->dmic_nids)) < 0)
3554 if (! spec->autocfg.line_outs)
3555 return 0; /* can't find valid pin config */
3557 /* If we have no real line-out pin and multiple hp-outs, HPs should
3558 * be set up as multi-channel outputs.
3560 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3561 spec->autocfg.hp_outs > 1) {
3562 /* Copy hp_outs to line_outs, backup line_outs in
3563 * speaker_outs so that the following routines can handle
3564 * HP pins as primary outputs.
3566 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3567 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3568 sizeof(spec->autocfg.line_out_pins));
3569 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3570 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3571 sizeof(spec->autocfg.hp_pins));
3572 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3573 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3574 spec->autocfg.hp_outs = 0;
3576 if (spec->autocfg.mono_out_pin) {
3577 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3578 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3579 u32 caps = query_amp_caps(codec,
3580 spec->autocfg.mono_out_pin, dir);
3581 hda_nid_t conn_list[1];
3583 /* get the mixer node and then the mono mux if it exists */
3584 if (snd_hda_get_connections(codec,
3585 spec->autocfg.mono_out_pin, conn_list, 1) &&
3586 snd_hda_get_connections(codec, conn_list[0],
3589 int wcaps = get_wcaps(codec, conn_list[0]);
3590 int wid_type = (wcaps & AC_WCAP_TYPE)
3591 >> AC_WCAP_TYPE_SHIFT;
3592 /* LR swap check, some stac925x have a mux that
3593 * changes the DACs output path instead of the
3596 if (wid_type == AC_WID_AUD_SEL &&
3597 !(wcaps & AC_WCAP_LR_SWAP))
3598 spec->mono_nid = conn_list[0];
3601 hda_nid_t nid = spec->autocfg.mono_out_pin;
3603 /* most mono outs have a least a mute/unmute switch */
3604 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3605 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3606 "Mono Playback Switch",
3607 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3610 /* check for volume support for the amp */
3611 if ((caps & AC_AMPCAP_NUM_STEPS)
3612 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3613 err = stac92xx_add_control(spec,
3614 STAC_CTL_WIDGET_VOL,
3615 "Mono Playback Volume",
3616 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3622 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3626 if (!spec->multiout.num_dacs) {
3627 err = stac92xx_auto_fill_dac_nids(codec);
3630 err = stac92xx_auto_create_multi_out_ctls(codec,
3636 /* setup analog beep controls */
3637 if (spec->anabeep_nid > 0) {
3638 err = stac92xx_auto_create_beep_ctls(codec,
3644 /* setup digital beep controls and input device */
3645 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3646 if (spec->digbeep_nid > 0) {
3647 hda_nid_t nid = spec->digbeep_nid;
3650 err = stac92xx_auto_create_beep_ctls(codec, nid);
3653 err = snd_hda_attach_beep_device(codec, nid);
3656 /* if no beep switch is available, make its own one */
3657 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3659 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3660 err = stac92xx_beep_switch_ctl(codec);
3667 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3672 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3677 if (spec->mono_nid > 0) {
3678 err = stac92xx_auto_create_mono_output_ctls(codec);
3682 if (spec->num_amps > 0) {
3683 err = stac92xx_auto_create_amp_output_ctls(codec);
3687 if (spec->num_dmics > 0 && !spec->dinput_mux)
3688 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3689 &spec->autocfg)) < 0)
3691 if (spec->num_muxes > 0) {
3692 err = stac92xx_auto_create_mux_input_ctls(codec);
3696 if (spec->num_smuxes > 0) {
3697 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3702 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3703 if (spec->multiout.max_channels > 2)
3704 spec->surr_switch = 1;
3706 if (spec->autocfg.dig_out_pin)
3707 spec->multiout.dig_out_nid = dig_out;
3708 if (dig_in && spec->autocfg.dig_in_pin)
3709 spec->dig_in_nid = dig_in;
3711 if (spec->kctls.list)
3712 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3714 spec->input_mux = &spec->private_imux;
3715 if (!spec->dinput_mux)
3716 spec->dinput_mux = &spec->private_dimux;
3717 spec->sinput_mux = &spec->private_smux;
3718 spec->mono_mux = &spec->private_mono_mux;
3719 spec->amp_mux = &spec->private_amp_mux;
3723 /* add playback controls for HP output */
3724 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3725 struct auto_pin_cfg *cfg)
3727 struct sigmatel_spec *spec = codec->spec;
3728 hda_nid_t pin = cfg->hp_pins[0];
3729 unsigned int wid_caps;
3734 wid_caps = get_wcaps(codec, pin);
3735 if (wid_caps & AC_WCAP_UNSOL_CAP)
3736 spec->hp_detect = 1;
3741 /* add playback controls for LFE output */
3742 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3743 struct auto_pin_cfg *cfg)
3745 struct sigmatel_spec *spec = codec->spec;
3747 hda_nid_t lfe_pin = 0x0;
3751 * search speaker outs and line outs for a mono speaker pin
3752 * with an amp. If one is found, add LFE controls
3755 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3756 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3757 unsigned int wcaps = get_wcaps(codec, pin);
3758 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3759 if (wcaps == AC_WCAP_OUT_AMP)
3760 /* found a mono speaker with an amp, must be lfe */
3764 /* if speaker_outs is 0, then speakers may be in line_outs */
3765 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3766 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3767 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3768 unsigned int defcfg;
3769 defcfg = snd_hda_codec_read(codec, pin, 0,
3770 AC_VERB_GET_CONFIG_DEFAULT,
3772 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3773 unsigned int wcaps = get_wcaps(codec, pin);
3774 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3775 if (wcaps == AC_WCAP_OUT_AMP)
3776 /* found a mono speaker with an amp,
3784 err = create_controls(codec, "LFE", lfe_pin, 1);
3792 static int stac9200_parse_auto_config(struct hda_codec *codec)
3794 struct sigmatel_spec *spec = codec->spec;
3797 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3800 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3803 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3806 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3809 if (spec->num_muxes > 0) {
3810 err = stac92xx_auto_create_mux_input_ctls(codec);
3815 if (spec->autocfg.dig_out_pin)
3816 spec->multiout.dig_out_nid = 0x05;
3817 if (spec->autocfg.dig_in_pin)
3818 spec->dig_in_nid = 0x04;
3820 if (spec->kctls.list)
3821 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3823 spec->input_mux = &spec->private_imux;
3824 spec->dinput_mux = &spec->private_dimux;
3830 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3831 * funky external mute control using GPIO pins.
3834 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3835 unsigned int dir_mask, unsigned int data)
3837 unsigned int gpiostate, gpiomask, gpiodir;
3839 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3840 AC_VERB_GET_GPIO_DATA, 0);
3841 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3843 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3844 AC_VERB_GET_GPIO_MASK, 0);
3847 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3848 AC_VERB_GET_GPIO_DIRECTION, 0);
3849 gpiodir |= dir_mask;
3851 /* Configure GPIOx as CMOS */
3852 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3854 snd_hda_codec_write(codec, codec->afg, 0,
3855 AC_VERB_SET_GPIO_MASK, gpiomask);
3856 snd_hda_codec_read(codec, codec->afg, 0,
3857 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3861 snd_hda_codec_read(codec, codec->afg, 0,
3862 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3865 static int stac92xx_add_jack(struct hda_codec *codec,
3866 hda_nid_t nid, int type)
3868 #ifdef CONFIG_SND_JACK
3869 struct sigmatel_spec *spec = codec->spec;
3870 struct sigmatel_jack *jack;
3871 int def_conf = snd_hda_codec_read(codec, nid,
3872 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3873 int connectivity = get_defcfg_connect(def_conf);
3876 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3879 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3880 jack = snd_array_new(&spec->jacks);
3886 sprintf(name, "%s at %s %s Jack",
3887 snd_hda_get_jack_type(def_conf),
3888 snd_hda_get_jack_connectivity(def_conf),
3889 snd_hda_get_jack_location(def_conf));
3891 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
3897 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3898 unsigned char type, int data)
3900 struct sigmatel_event *event;
3902 snd_array_init(&spec->events, sizeof(*event), 32);
3903 event = snd_array_new(&spec->events);
3908 event->tag = spec->events.used;
3914 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3915 hda_nid_t nid, unsigned char type)
3917 struct sigmatel_spec *spec = codec->spec;
3918 struct sigmatel_event *event = spec->events.list;
3921 for (i = 0; i < spec->events.used; i++, event++) {
3922 if (event->nid == nid && event->type == type)
3928 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3931 struct sigmatel_spec *spec = codec->spec;
3932 struct sigmatel_event *event = spec->events.list;
3935 for (i = 0; i < spec->events.used; i++, event++) {
3936 if (event->tag == tag)
3942 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3945 struct sigmatel_event *event;
3948 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3950 event = stac_get_event(codec, nid, type);
3954 tag = stac_add_event(codec->spec, nid, type, 0);
3957 snd_hda_codec_write_cache(codec, nid, 0,
3958 AC_VERB_SET_UNSOLICITED_ENABLE,
3962 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3965 for (i = 0; i < cfg->hp_outs; i++)
3966 if (cfg->hp_pins[i] == nid)
3967 return 1; /* nid is a HP-Out */
3969 return 0; /* nid is not a HP-Out */
3972 static void stac92xx_power_down(struct hda_codec *codec)
3974 struct sigmatel_spec *spec = codec->spec;
3976 /* power down inactive DACs */
3978 for (dac = spec->dac_list; *dac; dac++)
3979 if (!check_all_dac_nids(spec, *dac))
3980 snd_hda_codec_write(codec, *dac, 0,
3981 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3984 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3987 static int stac92xx_init(struct hda_codec *codec)
3989 struct sigmatel_spec *spec = codec->spec;
3990 struct auto_pin_cfg *cfg = &spec->autocfg;
3994 snd_hda_sequence_write(codec, spec->init);
3996 /* power down adcs initially */
3997 if (spec->powerdown_adcs)
3998 for (i = 0; i < spec->num_adcs; i++)
3999 snd_hda_codec_write(codec,
4000 spec->adc_nids[i], 0,
4001 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4004 gpio = spec->gpio_data;
4005 /* turn on EAPD statically when spec->eapd_switch isn't set.
4006 * otherwise, unsol event will turn it on/off dynamically
4008 if (!spec->eapd_switch)
4009 gpio |= spec->eapd_mask;
4010 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4013 if (spec->hp_detect) {
4014 /* Enable unsolicited responses on the HP widget */
4015 for (i = 0; i < cfg->hp_outs; i++) {
4016 hda_nid_t nid = cfg->hp_pins[i];
4017 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4019 /* force to enable the first line-out; the others are set up
4022 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4024 /* fake event to set up pins */
4025 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4028 stac92xx_auto_init_multi_out(codec);
4029 stac92xx_auto_init_hp_out(codec);
4030 for (i = 0; i < cfg->hp_outs; i++)
4031 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4033 for (i = 0; i < AUTO_PIN_LAST; i++) {
4034 hda_nid_t nid = cfg->input_pins[i];
4036 unsigned int pinctl, conf;
4037 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4038 /* for mic pins, force to initialize */
4039 pinctl = stac92xx_get_vref(codec, nid);
4040 pinctl |= AC_PINCTL_IN_EN;
4041 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4043 pinctl = snd_hda_codec_read(codec, nid, 0,
4044 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4045 /* if PINCTL already set then skip */
4046 if (!(pinctl & AC_PINCTL_IN_EN)) {
4047 pinctl |= AC_PINCTL_IN_EN;
4048 stac92xx_auto_set_pinctl(codec, nid,
4052 conf = snd_hda_codec_read(codec, nid, 0,
4053 AC_VERB_GET_CONFIG_DEFAULT, 0);
4054 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4055 enable_pin_detect(codec, nid,
4057 stac_issue_unsol_event(codec, nid,
4062 for (i = 0; i < spec->num_dmics; i++)
4063 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4065 if (cfg->dig_out_pin)
4066 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
4068 if (cfg->dig_in_pin)
4069 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4071 for (i = 0; i < spec->num_pwrs; i++) {
4072 hda_nid_t nid = spec->pwr_nids[i];
4073 int pinctl, def_conf;
4075 /* power on when no jack detection is available */
4076 if (!spec->hp_detect) {
4077 stac_toggle_power_map(codec, nid, 1);
4081 if (is_nid_hp_pin(cfg, nid))
4082 continue; /* already has an unsol event */
4084 pinctl = snd_hda_codec_read(codec, nid, 0,
4085 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4086 /* outputs are only ports capable of power management
4087 * any attempts on powering down a input port cause the
4088 * referenced VREF to act quirky.
4090 if (pinctl & AC_PINCTL_IN_EN) {
4091 stac_toggle_power_map(codec, nid, 1);
4094 def_conf = snd_hda_codec_read(codec, nid, 0,
4095 AC_VERB_GET_CONFIG_DEFAULT, 0);
4096 def_conf = get_defcfg_connect(def_conf);
4097 /* skip any ports that don't have jacks since presence
4098 * detection is useless */
4099 if (def_conf != AC_JACK_PORT_COMPLEX) {
4100 if (def_conf != AC_JACK_PORT_NONE)
4101 stac_toggle_power_map(codec, nid, 1);
4104 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4105 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4106 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4110 stac92xx_power_down(codec);
4114 static void stac92xx_free_jacks(struct hda_codec *codec)
4116 #ifdef CONFIG_SND_JACK
4117 /* free jack instances manually when clearing/reconfiguring */
4118 struct sigmatel_spec *spec = codec->spec;
4119 if (!codec->bus->shutdown && spec->jacks.list) {
4120 struct sigmatel_jack *jacks = spec->jacks.list;
4122 for (i = 0; i < spec->jacks.used; i++)
4123 snd_device_free(codec->bus->card, &jacks[i].jack);
4125 snd_array_free(&spec->jacks);
4129 static void stac92xx_free_kctls(struct hda_codec *codec)
4131 struct sigmatel_spec *spec = codec->spec;
4133 if (spec->kctls.list) {
4134 struct snd_kcontrol_new *kctl = spec->kctls.list;
4136 for (i = 0; i < spec->kctls.used; i++)
4137 kfree(kctl[i].name);
4139 snd_array_free(&spec->kctls);
4142 static void stac92xx_free(struct hda_codec *codec)
4144 struct sigmatel_spec *spec = codec->spec;
4149 kfree(spec->pin_configs);
4150 stac92xx_free_jacks(codec);
4151 snd_array_free(&spec->events);
4154 snd_hda_detach_beep_device(codec);
4157 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4160 unsigned int old_ctl, pin_ctl;
4162 pin_ctl = snd_hda_codec_read(codec, nid,
4163 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4165 if (pin_ctl & AC_PINCTL_IN_EN) {
4167 * we need to check the current set-up direction of
4168 * shared input pins since they can be switched via
4169 * "xxx as Output" mixer switch
4171 struct sigmatel_spec *spec = codec->spec;
4172 if (nid == spec->line_switch || nid == spec->mic_switch)
4177 /* if setting pin direction bits, clear the current
4178 direction bits first */
4179 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4180 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4183 if (old_ctl != pin_ctl)
4184 snd_hda_codec_write_cache(codec, nid, 0,
4185 AC_VERB_SET_PIN_WIDGET_CONTROL,
4189 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4192 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4193 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4195 snd_hda_codec_write_cache(codec, nid, 0,
4196 AC_VERB_SET_PIN_WIDGET_CONTROL,
4200 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4204 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
4210 /* return non-zero if the hp-pin of the given array index isn't
4211 * a jack-detection target
4213 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4215 struct auto_pin_cfg *cfg = &spec->autocfg;
4217 /* ignore sensing of shared line and mic jacks */
4218 if (cfg->hp_pins[i] == spec->line_switch)
4220 if (cfg->hp_pins[i] == spec->mic_switch)
4222 /* ignore if the pin is set as line-out */
4223 if (cfg->hp_pins[i] == spec->hp_switch)
4228 static void stac92xx_hp_detect(struct hda_codec *codec)
4230 struct sigmatel_spec *spec = codec->spec;
4231 struct auto_pin_cfg *cfg = &spec->autocfg;
4235 if (spec->gpio_mute)
4236 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4237 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4239 for (i = 0; i < cfg->hp_outs; i++) {
4242 if (no_hp_sensing(spec, i))
4244 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4246 unsigned int pinctl;
4247 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4248 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4249 if (pinctl & AC_PINCTL_IN_EN)
4250 presence = 0; /* mic- or line-input */
4255 /* disable lineouts */
4256 if (spec->hp_switch)
4257 stac92xx_reset_pinctl(codec, spec->hp_switch,
4259 for (i = 0; i < cfg->line_outs; i++)
4260 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4262 for (i = 0; i < cfg->speaker_outs; i++)
4263 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4265 if (spec->eapd_mask && spec->eapd_switch)
4266 stac_gpio_set(codec, spec->gpio_mask,
4267 spec->gpio_dir, spec->gpio_data &
4270 /* enable lineouts */
4271 if (spec->hp_switch)
4272 stac92xx_set_pinctl(codec, spec->hp_switch,
4274 for (i = 0; i < cfg->line_outs; i++)
4275 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4277 for (i = 0; i < cfg->speaker_outs; i++)
4278 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4280 if (spec->eapd_mask && spec->eapd_switch)
4281 stac_gpio_set(codec, spec->gpio_mask,
4282 spec->gpio_dir, spec->gpio_data |
4285 /* toggle hp outs */
4286 for (i = 0; i < cfg->hp_outs; i++) {
4287 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4288 if (no_hp_sensing(spec, i))
4291 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4293 /* Resetting the pinctl like below may lead to (a sort of) regressions
4294 * on some devices since they use the HP pin actually for line/speaker
4295 * outs although the default pin config shows a different pin (that is
4296 * wrong and useless).
4298 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4299 * But, disabling the code below just works around it, and I'm too tired of
4300 * bug reports with such devices...
4303 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4308 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4311 struct sigmatel_spec *spec = codec->spec;
4312 unsigned int idx, val;
4314 for (idx = 0; idx < spec->num_pwrs; idx++) {
4315 if (spec->pwr_nids[idx] == nid)
4318 if (idx >= spec->num_pwrs)
4321 /* several codecs have two power down bits */
4322 if (spec->pwr_mapping)
4323 idx = spec->pwr_mapping[idx];
4327 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4333 /* power down unused output ports */
4334 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4337 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4339 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4342 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4344 struct sigmatel_spec *spec = codec->spec;
4345 struct sigmatel_jack *jacks = spec->jacks.list;
4349 for (i = 0; i < spec->jacks.used; i++) {
4350 if (jacks->nid == nid) {
4351 unsigned int pin_ctl =
4352 snd_hda_codec_read(codec, nid,
4353 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4355 int type = jacks->type;
4356 if (type == (SND_JACK_LINEOUT
4357 | SND_JACK_HEADPHONE))
4358 type = (pin_ctl & AC_PINCTL_HP_EN)
4359 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4360 snd_jack_report(jacks->jack,
4361 get_pin_presence(codec, nid)
4369 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4372 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4375 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4378 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4380 struct sigmatel_spec *spec = codec->spec;
4381 struct sigmatel_event *event;
4384 tag = (res >> 26) & 0x7f;
4385 event = stac_get_event_from_tag(codec, tag);
4389 switch (event->type) {
4391 stac92xx_hp_detect(codec);
4393 case STAC_INSERT_EVENT:
4394 case STAC_PWR_EVENT:
4395 if (spec->num_pwrs > 0)
4396 stac92xx_pin_sense(codec, event->nid);
4397 stac92xx_report_jack(codec, event->nid);
4399 case STAC_VREF_EVENT:
4400 data = snd_hda_codec_read(codec, codec->afg, 0,
4401 AC_VERB_GET_GPIO_DATA, 0);
4402 /* toggle VREF state based on GPIOx status */
4403 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4404 !!(data & (1 << event->data)));
4409 #ifdef CONFIG_PROC_FS
4410 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4411 struct hda_codec *codec, hda_nid_t nid)
4413 if (nid == codec->afg)
4414 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4415 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4418 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4419 struct hda_codec *codec,
4422 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4423 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4426 /* stac92hd71bxx, stac92hd73xx */
4427 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4428 struct hda_codec *codec, hda_nid_t nid)
4430 stac92hd_proc_hook(buffer, codec, nid);
4431 if (nid == codec->afg)
4432 analog_loop_proc_hook(buffer, codec, 0xfa0);
4435 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4436 struct hda_codec *codec, hda_nid_t nid)
4438 if (nid == codec->afg)
4439 analog_loop_proc_hook(buffer, codec, 0xfe0);
4442 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4443 struct hda_codec *codec, hda_nid_t nid)
4445 if (nid == codec->afg)
4446 analog_loop_proc_hook(buffer, codec, 0xfeb);
4449 #define stac92hd_proc_hook NULL
4450 #define stac92hd7x_proc_hook NULL
4451 #define stac9205_proc_hook NULL
4452 #define stac927x_proc_hook NULL
4455 #ifdef SND_HDA_NEEDS_RESUME
4456 static int stac92xx_resume(struct hda_codec *codec)
4458 struct sigmatel_spec *spec = codec->spec;
4460 stac92xx_set_config_regs(codec);
4461 stac92xx_init(codec);
4462 snd_hda_codec_resume_amp(codec);
4463 snd_hda_codec_resume_cache(codec);
4464 /* fake event to set up pins again to override cached values */
4465 if (spec->hp_detect)
4466 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4471 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4473 struct sigmatel_spec *spec = codec->spec;
4474 if (spec->eapd_mask)
4475 stac_gpio_set(codec, spec->gpio_mask,
4476 spec->gpio_dir, spec->gpio_data &
4482 static struct hda_codec_ops stac92xx_patch_ops = {
4483 .build_controls = stac92xx_build_controls,
4484 .build_pcms = stac92xx_build_pcms,
4485 .init = stac92xx_init,
4486 .free = stac92xx_free,
4487 .unsol_event = stac92xx_unsol_event,
4488 #ifdef SND_HDA_NEEDS_RESUME
4489 .suspend = stac92xx_suspend,
4490 .resume = stac92xx_resume,
4494 static int patch_stac9200(struct hda_codec *codec)
4496 struct sigmatel_spec *spec;
4499 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4504 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4505 spec->pin_nids = stac9200_pin_nids;
4506 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4509 if (spec->board_config < 0) {
4510 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4511 err = stac92xx_save_bios_config_regs(codec);
4513 err = stac_save_pin_cfgs(codec,
4514 stac9200_brd_tbl[spec->board_config]);
4516 stac92xx_free(codec);
4520 spec->multiout.max_channels = 2;
4521 spec->multiout.num_dacs = 1;
4522 spec->multiout.dac_nids = stac9200_dac_nids;
4523 spec->adc_nids = stac9200_adc_nids;
4524 spec->mux_nids = stac9200_mux_nids;
4525 spec->num_muxes = 1;
4526 spec->num_dmics = 0;
4530 if (spec->board_config == STAC_9200_M4 ||
4531 spec->board_config == STAC_9200_M4_2 ||
4532 spec->board_config == STAC_9200_OQO)
4533 spec->init = stac9200_eapd_init;
4535 spec->init = stac9200_core_init;
4536 spec->mixer = stac9200_mixer;
4538 if (spec->board_config == STAC_9200_PANASONIC) {
4539 spec->gpio_mask = spec->gpio_dir = 0x09;
4540 spec->gpio_data = 0x00;
4543 err = stac9200_parse_auto_config(codec);
4545 stac92xx_free(codec);
4549 /* CF-74 has no headphone detection, and the driver should *NOT*
4550 * do detection and HP/speaker toggle because the hardware does it.
4552 if (spec->board_config == STAC_9200_PANASONIC)
4553 spec->hp_detect = 0;
4555 codec->patch_ops = stac92xx_patch_ops;
4560 static int patch_stac925x(struct hda_codec *codec)
4562 struct sigmatel_spec *spec;
4565 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4570 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4571 spec->pin_nids = stac925x_pin_nids;
4573 /* Check first for codec ID */
4574 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4577 stac925x_codec_id_cfg_tbl);
4579 /* Now checks for PCI ID, if codec ID is not found */
4580 if (spec->board_config < 0)
4581 spec->board_config = snd_hda_check_board_config(codec,
4586 if (spec->board_config < 0) {
4587 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4588 "using BIOS defaults\n");
4589 err = stac92xx_save_bios_config_regs(codec);
4591 err = stac_save_pin_cfgs(codec,
4592 stac925x_brd_tbl[spec->board_config]);
4594 stac92xx_free(codec);
4598 spec->multiout.max_channels = 2;
4599 spec->multiout.num_dacs = 1;
4600 spec->multiout.dac_nids = stac925x_dac_nids;
4601 spec->adc_nids = stac925x_adc_nids;
4602 spec->mux_nids = stac925x_mux_nids;
4603 spec->num_muxes = 1;
4606 switch (codec->vendor_id) {
4607 case 0x83847632: /* STAC9202 */
4608 case 0x83847633: /* STAC9202D */
4609 case 0x83847636: /* STAC9251 */
4610 case 0x83847637: /* STAC9251D */
4611 spec->num_dmics = STAC925X_NUM_DMICS;
4612 spec->dmic_nids = stac925x_dmic_nids;
4613 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4614 spec->dmux_nids = stac925x_dmux_nids;
4617 spec->num_dmics = 0;
4621 spec->init = stac925x_core_init;
4622 spec->mixer = stac925x_mixer;
4624 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4626 if (spec->board_config < 0) {
4627 printk(KERN_WARNING "hda_codec: No auto-config is "
4628 "available, default to model=ref\n");
4629 spec->board_config = STAC_925x_REF;
4635 stac92xx_free(codec);
4639 codec->patch_ops = stac92xx_patch_ops;
4644 static struct hda_input_mux stac92hd73xx_dmux = {
4647 { "Analog Inputs", 0x0b },
4648 { "Digital Mic 1", 0x09 },
4649 { "Digital Mic 2", 0x0a },
4654 static int patch_stac92hd73xx(struct hda_codec *codec)
4656 struct sigmatel_spec *spec;
4657 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4661 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4666 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4667 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4668 spec->pin_nids = stac92hd73xx_pin_nids;
4669 spec->board_config = snd_hda_check_board_config(codec,
4670 STAC_92HD73XX_MODELS,
4671 stac92hd73xx_models,
4672 stac92hd73xx_cfg_tbl);
4674 if (spec->board_config < 0) {
4675 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4676 " STAC92HD73XX, using BIOS defaults\n");
4677 err = stac92xx_save_bios_config_regs(codec);
4679 err = stac_save_pin_cfgs(codec,
4680 stac92hd73xx_brd_tbl[spec->board_config]);
4682 stac92xx_free(codec);
4686 num_dacs = snd_hda_get_connections(codec, 0x0a,
4687 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4689 if (num_dacs < 3 || num_dacs > 5) {
4690 printk(KERN_WARNING "hda_codec: Could not determine "
4691 "number of channels defaulting to DAC count\n");
4692 num_dacs = STAC92HD73_DAC_COUNT;
4695 case 0x3: /* 6 Channel */
4696 spec->mixer = stac92hd73xx_6ch_mixer;
4697 spec->init = stac92hd73xx_6ch_core_init;
4699 case 0x4: /* 8 Channel */
4700 spec->mixer = stac92hd73xx_8ch_mixer;
4701 spec->init = stac92hd73xx_8ch_core_init;
4703 case 0x5: /* 10 Channel */
4704 spec->mixer = stac92hd73xx_10ch_mixer;
4705 spec->init = stac92hd73xx_10ch_core_init;
4707 spec->multiout.dac_nids = spec->dac_nids;
4709 spec->aloopback_mask = 0x01;
4710 spec->aloopback_shift = 8;
4712 spec->digbeep_nid = 0x1c;
4713 spec->mux_nids = stac92hd73xx_mux_nids;
4714 spec->adc_nids = stac92hd73xx_adc_nids;
4715 spec->dmic_nids = stac92hd73xx_dmic_nids;
4716 spec->dmux_nids = stac92hd73xx_dmux_nids;
4717 spec->smux_nids = stac92hd73xx_smux_nids;
4718 spec->amp_nids = stac92hd73xx_amp_nids;
4719 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4721 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4722 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4723 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4724 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4725 sizeof(stac92hd73xx_dmux));
4727 switch (spec->board_config) {
4729 spec->init = dell_eq_core_init;
4731 case STAC_DELL_M6_AMIC:
4732 case STAC_DELL_M6_DMIC:
4733 case STAC_DELL_M6_BOTH:
4734 spec->num_smuxes = 0;
4735 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4736 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4737 spec->eapd_switch = 0;
4740 if (spec->board_config != STAC_DELL_EQ)
4741 spec->init = dell_m6_core_init;
4742 switch (spec->board_config) {
4743 case STAC_DELL_M6_AMIC: /* Analog Mics */
4744 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4745 spec->num_dmics = 0;
4746 spec->private_dimux.num_items = 1;
4748 case STAC_DELL_M6_DMIC: /* Digital Mics */
4749 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4750 spec->num_dmics = 1;
4751 spec->private_dimux.num_items = 2;
4753 case STAC_DELL_M6_BOTH: /* Both */
4754 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4755 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4756 spec->num_dmics = 1;
4757 spec->private_dimux.num_items = 2;
4762 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4763 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4764 spec->eapd_switch = 1;
4766 if (spec->board_config > STAC_92HD73XX_REF) {
4767 /* GPIO0 High = Enable EAPD */
4768 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4769 spec->gpio_data = 0x01;
4771 spec->dinput_mux = &spec->private_dimux;
4773 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4774 spec->pwr_nids = stac92hd73xx_pwr_nids;
4776 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
4779 if (spec->board_config < 0) {
4780 printk(KERN_WARNING "hda_codec: No auto-config is "
4781 "available, default to model=ref\n");
4782 spec->board_config = STAC_92HD73XX_REF;
4789 stac92xx_free(codec);
4793 if (spec->board_config == STAC_92HD73XX_NO_JD)
4794 spec->hp_detect = 0;
4796 codec->patch_ops = stac92xx_patch_ops;
4798 codec->proc_widget_hook = stac92hd7x_proc_hook;
4803 static struct hda_input_mux stac92hd83xxx_dmux = {
4806 { "Analog Inputs", 0x03 },
4807 { "Digital Mic 1", 0x04 },
4808 { "Digital Mic 2", 0x05 },
4812 static int patch_stac92hd83xxx(struct hda_codec *codec)
4814 struct sigmatel_spec *spec;
4815 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
4819 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4824 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
4825 spec->mono_nid = 0x19;
4826 spec->digbeep_nid = 0x21;
4827 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4828 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4829 spec->adc_nids = stac92hd83xxx_adc_nids;
4830 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4831 spec->amp_nids = stac92hd83xxx_amp_nids;
4832 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4833 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4834 spec->multiout.dac_nids = spec->dac_nids;
4837 /* set port 0xe to select the last DAC
4839 num_dacs = snd_hda_get_connections(codec, 0x0e,
4840 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4842 snd_hda_codec_write_cache(codec, 0xe, 0,
4843 AC_VERB_SET_CONNECT_SEL, num_dacs);
4845 spec->init = stac92hd83xxx_core_init;
4846 spec->mixer = stac92hd83xxx_mixer;
4847 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4848 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4849 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4850 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
4851 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4852 spec->dinput_mux = &stac92hd83xxx_dmux;
4853 spec->pin_nids = stac92hd83xxx_pin_nids;
4854 spec->board_config = snd_hda_check_board_config(codec,
4855 STAC_92HD83XXX_MODELS,
4856 stac92hd83xxx_models,
4857 stac92hd83xxx_cfg_tbl);
4859 if (spec->board_config < 0) {
4860 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4861 " STAC92HD83XXX, using BIOS defaults\n");
4862 err = stac92xx_save_bios_config_regs(codec);
4864 err = stac_save_pin_cfgs(codec,
4865 stac92hd83xxx_brd_tbl[spec->board_config]);
4867 stac92xx_free(codec);
4871 switch (codec->vendor_id) {
4874 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
4880 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4882 if (spec->board_config < 0) {
4883 printk(KERN_WARNING "hda_codec: No auto-config is "
4884 "available, default to model=ref\n");
4885 spec->board_config = STAC_92HD83XXX_REF;
4892 stac92xx_free(codec);
4896 codec->patch_ops = stac92xx_patch_ops;
4898 codec->proc_widget_hook = stac92hd_proc_hook;
4903 static struct hda_input_mux stac92hd71bxx_dmux = {
4906 { "Analog Inputs", 0x00 },
4908 { "Digital Mic 1", 0x02 },
4909 { "Digital Mic 2", 0x03 },
4913 static int patch_stac92hd71bxx(struct hda_codec *codec)
4915 struct sigmatel_spec *spec;
4918 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4923 codec->patch_ops = stac92xx_patch_ops;
4924 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
4925 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4926 spec->pin_nids = stac92hd71bxx_pin_nids;
4927 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4928 sizeof(stac92hd71bxx_dmux));
4929 spec->board_config = snd_hda_check_board_config(codec,
4930 STAC_92HD71BXX_MODELS,
4931 stac92hd71bxx_models,
4932 stac92hd71bxx_cfg_tbl);
4934 if (spec->board_config < 0) {
4935 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4936 " STAC92HD71BXX, using BIOS defaults\n");
4937 err = stac92xx_save_bios_config_regs(codec);
4939 err = stac_save_pin_cfgs(codec,
4940 stac92hd71bxx_brd_tbl[spec->board_config]);
4942 stac92xx_free(codec);
4946 if (spec->board_config > STAC_92HD71BXX_REF) {
4948 spec->gpio_mask = 0x01;
4949 spec->gpio_dir = 0x01;
4950 spec->gpio_data = 0x01;
4953 switch (codec->vendor_id) {
4954 case 0x111d76b6: /* 4 Port without Analog Mixer */
4956 case 0x111d76b4: /* 6 Port without Analog Mixer */
4958 spec->mixer = stac92hd71bxx_mixer;
4959 spec->init = stac92hd71bxx_core_init;
4960 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4962 case 0x111d7608: /* 5 Port with Analog Mixer */
4963 switch (spec->board_config) {
4965 /* Enable VREF power saving on GPIO1 detect */
4966 err = stac_add_event(spec, codec->afg,
4967 STAC_VREF_EVENT, 0x02);
4970 snd_hda_codec_write_cache(codec, codec->afg, 0,
4971 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4972 snd_hda_codec_write_cache(codec, codec->afg, 0,
4973 AC_VERB_SET_UNSOLICITED_ENABLE,
4975 spec->gpio_mask |= 0x02;
4978 if ((codec->revision_id & 0xf) == 0 ||
4979 (codec->revision_id & 0xf) == 1)
4980 spec->stream_delay = 40; /* 40 milliseconds */
4982 /* no output amps */
4984 spec->mixer = stac92hd71bxx_analog_mixer;
4985 spec->dinput_mux = &spec->private_dimux;
4988 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4989 stac_change_pin_config(codec, 0xf, 0x40f000f0);
4991 case 0x111d7603: /* 6 Port with Analog Mixer */
4992 if ((codec->revision_id & 0xf) == 1)
4993 spec->stream_delay = 40; /* 40 milliseconds */
4995 /* no output amps */
4999 spec->dinput_mux = &spec->private_dimux;
5000 spec->mixer = stac92hd71bxx_analog_mixer;
5001 spec->init = stac92hd71bxx_analog_core_init;
5002 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5005 spec->aloopback_mask = 0x50;
5006 spec->aloopback_shift = 0;
5008 spec->powerdown_adcs = 1;
5009 spec->digbeep_nid = 0x26;
5010 spec->mux_nids = stac92hd71bxx_mux_nids;
5011 spec->adc_nids = stac92hd71bxx_adc_nids;
5012 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5013 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5014 spec->smux_nids = stac92hd71bxx_smux_nids;
5015 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5017 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5018 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5020 switch (spec->board_config) {
5022 /* enable internal microphone */
5023 stac_change_pin_config(codec, 0x0e, 0x01813040);
5024 stac92xx_auto_set_pinctl(codec, 0x0e,
5025 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5027 case STAC_DELL_M4_2:
5028 spec->num_dmics = 0;
5029 spec->num_smuxes = 0;
5030 spec->num_dmuxes = 0;
5032 case STAC_DELL_M4_1:
5033 case STAC_DELL_M4_3:
5034 spec->num_dmics = 1;
5035 spec->num_smuxes = 0;
5036 spec->num_dmuxes = 0;
5039 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
5040 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
5041 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5044 spec->multiout.dac_nids = spec->dac_nids;
5045 if (spec->dinput_mux)
5046 spec->private_dimux.num_items +=
5048 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
5050 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
5052 if (spec->board_config < 0) {
5053 printk(KERN_WARNING "hda_codec: No auto-config is "
5054 "available, default to model=ref\n");
5055 spec->board_config = STAC_92HD71BXX_REF;
5062 stac92xx_free(codec);
5066 codec->proc_widget_hook = stac92hd7x_proc_hook;
5071 static int patch_stac922x(struct hda_codec *codec)
5073 struct sigmatel_spec *spec;
5076 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5081 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5082 spec->pin_nids = stac922x_pin_nids;
5083 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5086 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5087 spec->gpio_mask = spec->gpio_dir = 0x03;
5088 spec->gpio_data = 0x03;
5089 /* Intel Macs have all same PCI SSID, so we need to check
5090 * codec SSID to distinguish the exact models
5092 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5093 switch (codec->subsystem_id) {
5096 spec->board_config = STAC_INTEL_MAC_V1;
5100 spec->board_config = STAC_INTEL_MAC_V2;
5108 spec->board_config = STAC_INTEL_MAC_V3;
5112 spec->board_config = STAC_INTEL_MAC_V4;
5116 spec->board_config = STAC_INTEL_MAC_V5;
5119 spec->board_config = STAC_INTEL_MAC_V3;
5125 if (spec->board_config < 0) {
5126 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5127 "using BIOS defaults\n");
5128 err = stac92xx_save_bios_config_regs(codec);
5130 err = stac_save_pin_cfgs(codec,
5131 stac922x_brd_tbl[spec->board_config]);
5133 stac92xx_free(codec);
5137 spec->adc_nids = stac922x_adc_nids;
5138 spec->mux_nids = stac922x_mux_nids;
5139 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5140 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5141 spec->num_dmics = 0;
5144 spec->init = stac922x_core_init;
5145 spec->mixer = stac922x_mixer;
5147 spec->multiout.dac_nids = spec->dac_nids;
5149 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5151 if (spec->board_config < 0) {
5152 printk(KERN_WARNING "hda_codec: No auto-config is "
5153 "available, default to model=ref\n");
5154 spec->board_config = STAC_D945_REF;
5160 stac92xx_free(codec);
5164 codec->patch_ops = stac92xx_patch_ops;
5166 /* Fix Mux capture level; max to 2 */
5167 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5168 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5169 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5170 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5171 (0 << AC_AMPCAP_MUTE_SHIFT));
5176 static int patch_stac927x(struct hda_codec *codec)
5178 struct sigmatel_spec *spec;
5181 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5186 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5187 spec->pin_nids = stac927x_pin_nids;
5188 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5192 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
5193 if (spec->board_config < 0)
5194 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5195 "STAC927x, using BIOS defaults\n");
5196 err = stac92xx_save_bios_config_regs(codec);
5198 err = stac_save_pin_cfgs(codec,
5199 stac927x_brd_tbl[spec->board_config]);
5201 stac92xx_free(codec);
5205 spec->digbeep_nid = 0x23;
5206 spec->adc_nids = stac927x_adc_nids;
5207 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5208 spec->mux_nids = stac927x_mux_nids;
5209 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5210 spec->smux_nids = stac927x_smux_nids;
5211 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5212 spec->spdif_labels = stac927x_spdif_labels;
5213 spec->dac_list = stac927x_dac_nids;
5214 spec->multiout.dac_nids = spec->dac_nids;
5216 switch (spec->board_config) {
5219 /* GPIO0 High = Enable EAPD */
5220 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
5221 spec->gpio_data = 0x01;
5222 spec->num_dmics = 0;
5224 spec->init = d965_core_init;
5225 spec->mixer = stac927x_mixer;
5227 case STAC_DELL_BIOS:
5228 switch (codec->subsystem_id) {
5231 /* correct the device field to SPDIF out */
5232 stac_change_pin_config(codec, 0x21, 0x01442070);
5235 /* configure the analog microphone on some laptops */
5236 stac_change_pin_config(codec, 0x0c, 0x90a79130);
5237 /* correct the front output jack as a hp out */
5238 stac_change_pin_config(codec, 0x0f, 0x0227011f);
5239 /* correct the front input jack as a mic */
5240 stac_change_pin_config(codec, 0x0e, 0x02a79130);
5243 /* GPIO2 High = Enable EAPD */
5244 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
5245 spec->gpio_data = 0x04;
5246 spec->dmic_nids = stac927x_dmic_nids;
5247 spec->num_dmics = STAC927X_NUM_DMICS;
5249 spec->init = d965_core_init;
5250 spec->mixer = stac927x_mixer;
5251 spec->dmux_nids = stac927x_dmux_nids;
5252 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5255 if (spec->board_config > STAC_D965_REF) {
5256 /* GPIO0 High = Enable EAPD */
5257 spec->eapd_mask = spec->gpio_mask = 0x01;
5258 spec->gpio_dir = spec->gpio_data = 0x01;
5260 spec->num_dmics = 0;
5262 spec->init = stac927x_core_init;
5263 spec->mixer = stac927x_mixer;
5267 spec->aloopback_mask = 0x40;
5268 spec->aloopback_shift = 0;
5269 spec->eapd_switch = 1;
5271 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
5273 if (spec->board_config < 0) {
5274 printk(KERN_WARNING "hda_codec: No auto-config is "
5275 "available, default to model=ref\n");
5276 spec->board_config = STAC_D965_REF;
5282 stac92xx_free(codec);
5286 codec->patch_ops = stac92xx_patch_ops;
5288 codec->proc_widget_hook = stac927x_proc_hook;
5292 * The STAC927x seem to require fairly long delays for certain
5293 * command sequences. With too short delays (even if the answer
5294 * is set to RIRB properly), it results in the silence output
5295 * on some hardwares like Dell.
5297 * The below flag enables the longer delay (see get_response
5300 codec->bus->needs_damn_long_delay = 1;
5302 /* no jack detecion for ref-no-jd model */
5303 if (spec->board_config == STAC_D965_REF_NO_JD)
5304 spec->hp_detect = 0;
5309 static int patch_stac9205(struct hda_codec *codec)
5311 struct sigmatel_spec *spec;
5314 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5319 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
5320 spec->pin_nids = stac9205_pin_nids;
5321 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5325 if (spec->board_config < 0) {
5326 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5327 err = stac92xx_save_bios_config_regs(codec);
5329 err = stac_save_pin_cfgs(codec,
5330 stac9205_brd_tbl[spec->board_config]);
5332 stac92xx_free(codec);
5336 spec->digbeep_nid = 0x23;
5337 spec->adc_nids = stac9205_adc_nids;
5338 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
5339 spec->mux_nids = stac9205_mux_nids;
5340 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
5341 spec->smux_nids = stac9205_smux_nids;
5342 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
5343 spec->dmic_nids = stac9205_dmic_nids;
5344 spec->num_dmics = STAC9205_NUM_DMICS;
5345 spec->dmux_nids = stac9205_dmux_nids;
5346 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
5349 spec->init = stac9205_core_init;
5350 spec->mixer = stac9205_mixer;
5352 spec->aloopback_mask = 0x40;
5353 spec->aloopback_shift = 0;
5354 /* Turn on/off EAPD per HP plugging */
5355 if (spec->board_config != STAC_9205_EAPD)
5356 spec->eapd_switch = 1;
5357 spec->multiout.dac_nids = spec->dac_nids;
5359 switch (spec->board_config){
5360 case STAC_9205_DELL_M43:
5361 /* Enable SPDIF in/out */
5362 stac_change_pin_config(codec, 0x1f, 0x01441030);
5363 stac_change_pin_config(codec, 0x20, 0x1c410030);
5365 /* Enable unsol response for GPIO4/Dock HP connection */
5366 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5369 snd_hda_codec_write_cache(codec, codec->afg, 0,
5370 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5371 snd_hda_codec_write_cache(codec, codec->afg, 0,
5372 AC_VERB_SET_UNSOLICITED_ENABLE,
5375 spec->gpio_dir = 0x0b;
5376 spec->eapd_mask = 0x01;
5377 spec->gpio_mask = 0x1b;
5378 spec->gpio_mute = 0x10;
5379 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5382 spec->gpio_data = 0x01;
5385 /* SPDIF-In enabled */
5388 /* GPIO0 High = EAPD */
5389 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5390 spec->gpio_data = 0x01;
5394 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5396 if (spec->board_config < 0) {
5397 printk(KERN_WARNING "hda_codec: No auto-config is "
5398 "available, default to model=ref\n");
5399 spec->board_config = STAC_9205_REF;
5405 stac92xx_free(codec);
5409 codec->patch_ops = stac92xx_patch_ops;
5411 codec->proc_widget_hook = stac9205_proc_hook;
5420 static struct hda_verb stac9872_core_init[] = {
5421 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5426 static struct snd_kcontrol_new stac9872_mixer[] = {
5427 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5428 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5429 STAC_INPUT_SOURCE(1),
5433 static hda_nid_t stac9872_pin_nids[] = {
5434 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5438 static hda_nid_t stac9872_adc_nids[] = {
5442 static hda_nid_t stac9872_mux_nids[] = {
5446 static int patch_stac9872(struct hda_codec *codec)
5448 struct sigmatel_spec *spec;
5451 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5456 #if 0 /* no model right now */
5457 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5462 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5463 spec->pin_nids = stac9872_pin_nids;
5464 spec->multiout.dac_nids = spec->dac_nids;
5465 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5466 spec->adc_nids = stac9872_adc_nids;
5467 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5468 spec->mux_nids = stac9872_mux_nids;
5469 spec->mixer = stac9872_mixer;
5470 spec->init = stac9872_core_init;
5472 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5474 stac92xx_free(codec);
5477 spec->input_mux = &spec->private_imux;
5478 codec->patch_ops = stac92xx_patch_ops;
5486 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5487 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5488 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5489 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5490 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5491 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5492 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5493 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5494 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5495 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5496 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5497 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5498 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5499 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5500 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5501 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5502 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5503 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5504 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5505 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5506 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5507 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5508 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5509 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5510 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5511 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5512 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5513 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5514 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5515 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5516 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5517 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5518 /* The following does not take into account .id=0x83847661 when subsys =
5519 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5520 * currently not fully supported.
5522 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5523 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5524 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5525 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5526 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5527 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5528 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5529 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5530 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5531 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5532 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5533 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5534 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5535 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5536 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5537 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5538 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5539 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5540 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5541 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5542 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5543 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5544 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5545 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5546 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5547 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5551 MODULE_ALIAS("snd-hda-codec-id:8384*");
5552 MODULE_ALIAS("snd-hda-codec-id:111d*");
5554 MODULE_LICENSE("GPL");
5555 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5557 static struct hda_codec_preset_list sigmatel_list = {
5558 .preset = snd_hda_preset_sigmatel,
5559 .owner = THIS_MODULE,
5562 static int __init patch_sigmatel_init(void)
5564 return snd_hda_add_codec_preset(&sigmatel_list);
5567 static void __exit patch_sigmatel_exit(void)
5569 snd_hda_delete_codec_preset(&sigmatel_list);
5572 module_init(patch_sigmatel_init)
5573 module_exit(patch_sigmatel_exit)