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"
77 STAC_92HD73XX_NO_JD, /* no jack-detection */
89 STAC_92HD83XXX_PWR_REF,
102 STAC_92HD71BXX_MODELS
128 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
129 * is given, one of the above models will be
130 * chosen according to the subsystem id. */
131 /* for backward compatibility */
148 STAC_D965_REF_NO_JD, /* no jack-detection */
157 struct sigmatel_event {
164 struct sigmatel_jack {
167 struct snd_jack *jack;
170 struct sigmatel_spec {
171 struct snd_kcontrol_new *mixers[4];
172 unsigned int num_mixers;
175 unsigned int eapd_switch: 1;
176 unsigned int surr_switch: 1;
177 unsigned int alt_switch: 1;
178 unsigned int hp_detect: 1;
179 unsigned int spdif_mute: 1;
180 unsigned int check_volume_offset:1;
183 unsigned int eapd_mask;
184 unsigned int gpio_mask;
185 unsigned int gpio_dir;
186 unsigned int gpio_data;
187 unsigned int gpio_mute;
190 unsigned int stream_delay;
192 /* analog loopback */
193 unsigned char aloopback_mask;
194 unsigned char aloopback_shift;
196 /* power management */
197 unsigned int num_pwrs;
198 unsigned int *pwr_mapping;
203 struct snd_array jacks;
206 struct snd_array events;
209 struct hda_input_mux *mono_mux;
210 struct hda_input_mux *amp_mux;
211 unsigned int cur_mmux;
212 struct hda_multi_out multiout;
213 hda_nid_t dac_nids[5];
214 hda_nid_t hp_dacs[5];
215 hda_nid_t speaker_dacs[5];
221 unsigned int num_adcs;
223 unsigned int num_muxes;
224 hda_nid_t *dmic_nids;
225 unsigned int num_dmics;
226 hda_nid_t *dmux_nids;
227 unsigned int num_dmuxes;
228 hda_nid_t *smux_nids;
229 unsigned int num_smuxes;
230 const char **spdif_labels;
232 hda_nid_t dig_in_nid;
234 hda_nid_t anabeep_nid;
235 hda_nid_t digbeep_nid;
239 unsigned int num_pins;
241 /* codec specific stuff */
242 struct hda_verb *init;
243 struct snd_kcontrol_new *mixer;
246 struct hda_input_mux *dinput_mux;
247 unsigned int cur_dmux[2];
248 struct hda_input_mux *input_mux;
249 unsigned int cur_mux[3];
250 struct hda_input_mux *sinput_mux;
251 unsigned int cur_smux[2];
252 unsigned int cur_amux;
254 unsigned int num_amps;
255 unsigned int powerdown_adcs;
258 unsigned int io_switch[2];
259 unsigned int clfe_swap;
260 hda_nid_t line_switch; /* shared line-in for input and output */
261 hda_nid_t mic_switch; /* shared mic-in for input and output */
262 hda_nid_t hp_switch; /* NID of HP as line-out */
263 unsigned int aloopback;
265 struct hda_pcm pcm_rec[2]; /* PCM information */
267 /* dynamic controls and input_mux */
268 struct auto_pin_cfg autocfg;
269 struct snd_array kctls;
270 struct hda_input_mux private_dimux;
271 struct hda_input_mux private_imux;
272 struct hda_input_mux private_smux;
273 struct hda_input_mux private_amp_mux;
274 struct hda_input_mux private_mono_mux;
277 static hda_nid_t stac9200_adc_nids[1] = {
281 static hda_nid_t stac9200_mux_nids[1] = {
285 static hda_nid_t stac9200_dac_nids[1] = {
289 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
290 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
294 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
298 static hda_nid_t stac92hd73xx_adc_nids[2] = {
302 #define DELL_M6_AMP 2
303 static hda_nid_t stac92hd73xx_amp_nids[3] = {
307 #define STAC92HD73XX_NUM_DMICS 2
308 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
312 #define STAC92HD73_DAC_COUNT 5
314 static hda_nid_t stac92hd73xx_mux_nids[4] = {
315 0x28, 0x29, 0x2a, 0x2b,
318 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
322 static hda_nid_t stac92hd73xx_smux_nids[2] = {
326 #define STAC92HD83XXX_NUM_DMICS 2
327 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
331 #define STAC92HD83_DAC_COUNT 3
333 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
337 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
341 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
345 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
349 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
350 0x03, 0x0c, 0x20, 0x40,
353 static hda_nid_t stac92hd83xxx_amp_nids[1] = {
357 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
361 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
365 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
369 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
373 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
377 #define STAC92HD71BXX_NUM_DMICS 2
378 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
382 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
386 static hda_nid_t stac925x_adc_nids[1] = {
390 static hda_nid_t stac925x_mux_nids[1] = {
394 static hda_nid_t stac925x_dac_nids[1] = {
398 #define STAC925X_NUM_DMICS 1
399 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
403 static hda_nid_t stac925x_dmux_nids[1] = {
407 static hda_nid_t stac922x_adc_nids[2] = {
411 static hda_nid_t stac922x_mux_nids[2] = {
415 static hda_nid_t stac927x_slave_dig_outs[2] = {
419 static hda_nid_t stac927x_adc_nids[3] = {
423 static hda_nid_t stac927x_mux_nids[3] = {
427 static hda_nid_t stac927x_smux_nids[1] = {
431 static hda_nid_t stac927x_dac_nids[6] = {
432 0x02, 0x03, 0x04, 0x05, 0x06, 0
435 static hda_nid_t stac927x_dmux_nids[1] = {
439 #define STAC927X_NUM_DMICS 2
440 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
444 static const char *stac927x_spdif_labels[5] = {
445 "Digital Playback", "ADAT", "Analog Mux 1",
446 "Analog Mux 2", "Analog Mux 3"
449 static hda_nid_t stac9205_adc_nids[2] = {
453 static hda_nid_t stac9205_mux_nids[2] = {
457 static hda_nid_t stac9205_dmux_nids[1] = {
461 static hda_nid_t stac9205_smux_nids[1] = {
465 #define STAC9205_NUM_DMICS 2
466 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
470 static hda_nid_t stac9200_pin_nids[8] = {
471 0x08, 0x09, 0x0d, 0x0e,
472 0x0f, 0x10, 0x11, 0x12,
475 static hda_nid_t stac925x_pin_nids[8] = {
476 0x07, 0x08, 0x0a, 0x0b,
477 0x0c, 0x0d, 0x10, 0x11,
480 static hda_nid_t stac922x_pin_nids[10] = {
481 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
482 0x0f, 0x10, 0x11, 0x15, 0x1b,
485 static hda_nid_t stac92hd73xx_pin_nids[13] = {
486 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
487 0x0f, 0x10, 0x11, 0x12, 0x13,
491 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
492 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
493 0x0f, 0x10, 0x11, 0x1f, 0x20,
496 #define STAC92HD71BXX_NUM_PINS 13
497 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
498 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
499 0x00, 0x14, 0x18, 0x19, 0x1e,
502 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
503 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
504 0x0f, 0x14, 0x18, 0x19, 0x1e,
508 static hda_nid_t stac927x_pin_nids[14] = {
509 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
510 0x0f, 0x10, 0x11, 0x12, 0x13,
511 0x14, 0x21, 0x22, 0x23,
514 static hda_nid_t stac9205_pin_nids[12] = {
515 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
516 0x0f, 0x14, 0x16, 0x17, 0x18,
520 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
522 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
523 struct snd_ctl_elem_value *ucontrol)
525 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
526 struct sigmatel_spec *spec = codec->spec;
527 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
529 kcontrol->private_value ^= get_amp_nid(kcontrol);
530 kcontrol->private_value |= nid;
532 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
535 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_value *ucontrol)
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 struct sigmatel_spec *spec = codec->spec;
540 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
542 kcontrol->private_value ^= get_amp_nid(kcontrol);
543 kcontrol->private_value |= nid;
545 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
548 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_info *uinfo)
551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
552 struct sigmatel_spec *spec = codec->spec;
553 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
556 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
557 struct snd_ctl_elem_value *ucontrol)
559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
560 struct sigmatel_spec *spec = codec->spec;
561 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
563 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
567 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
568 struct snd_ctl_elem_value *ucontrol)
570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
571 struct sigmatel_spec *spec = codec->spec;
572 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
574 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
575 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
578 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
579 struct snd_ctl_elem_info *uinfo)
581 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
582 struct sigmatel_spec *spec = codec->spec;
583 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
586 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
587 struct snd_ctl_elem_value *ucontrol)
589 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
590 struct sigmatel_spec *spec = codec->spec;
591 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
593 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
597 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
598 struct snd_ctl_elem_value *ucontrol)
600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
601 struct sigmatel_spec *spec = codec->spec;
602 struct hda_input_mux *smux = &spec->private_smux;
603 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
607 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
608 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
612 if (spec->spdif_mute) {
614 nid = spec->multiout.dig_out_nid;
616 nid = codec->slave_dig_outs[smux_idx - 1];
617 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
621 /* un/mute SPDIF out */
622 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
628 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
630 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
631 struct sigmatel_spec *spec = codec->spec;
632 return snd_hda_input_mux_info(spec->input_mux, uinfo);
635 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
638 struct sigmatel_spec *spec = codec->spec;
639 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
641 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
645 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 struct sigmatel_spec *spec = codec->spec;
649 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
651 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
652 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
655 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_info *uinfo)
658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
659 struct sigmatel_spec *spec = codec->spec;
660 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
663 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
664 struct snd_ctl_elem_value *ucontrol)
666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
667 struct sigmatel_spec *spec = codec->spec;
669 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
673 static int stac92xx_mono_mux_enum_put(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 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
680 spec->mono_nid, &spec->cur_mmux);
683 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
684 struct snd_ctl_elem_info *uinfo)
686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
687 struct sigmatel_spec *spec = codec->spec;
688 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
691 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
692 struct snd_ctl_elem_value *ucontrol)
694 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
695 struct sigmatel_spec *spec = codec->spec;
697 ucontrol->value.enumerated.item[0] = spec->cur_amux;
701 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
702 struct snd_ctl_elem_value *ucontrol)
704 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
705 struct sigmatel_spec *spec = codec->spec;
706 struct snd_kcontrol *ctl =
707 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
711 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
712 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
714 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
718 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
720 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
721 struct snd_ctl_elem_value *ucontrol)
723 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
724 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
725 struct sigmatel_spec *spec = codec->spec;
727 ucontrol->value.integer.value[0] = !!(spec->aloopback &
728 (spec->aloopback_mask << idx));
732 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
733 struct snd_ctl_elem_value *ucontrol)
735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
736 struct sigmatel_spec *spec = codec->spec;
737 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
738 unsigned int dac_mode;
739 unsigned int val, idx_val;
741 idx_val = spec->aloopback_mask << idx;
742 if (ucontrol->value.integer.value[0])
743 val = spec->aloopback | idx_val;
745 val = spec->aloopback & ~idx_val;
746 if (spec->aloopback == val)
749 spec->aloopback = val;
751 /* Only return the bits defined by the shift value of the
752 * first two bytes of the mask
754 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
755 kcontrol->private_value & 0xFFFF, 0x0);
756 dac_mode >>= spec->aloopback_shift;
758 if (spec->aloopback & idx_val) {
759 snd_hda_power_up(codec);
762 snd_hda_power_down(codec);
763 dac_mode &= ~idx_val;
766 snd_hda_codec_write_cache(codec, codec->afg, 0,
767 kcontrol->private_value >> 16, dac_mode);
772 static struct hda_verb stac9200_core_init[] = {
773 /* set dac0mux for dac converter */
774 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
778 static struct hda_verb stac9200_eapd_init[] = {
779 /* set dac0mux for dac converter */
780 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
781 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
785 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
786 /* set master volume and direct control */
787 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
788 /* setup adcs to point to mixer */
789 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
790 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
791 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
792 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
793 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
794 /* setup import muxs */
795 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
796 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
797 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
798 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
802 static struct hda_verb dell_eq_core_init[] = {
803 /* set master volume to max value without distortion
804 * and direct control */
805 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
806 /* setup adcs to point to mixer */
807 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
808 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
809 /* setup import muxs */
810 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
811 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
812 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
813 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
817 static struct hda_verb dell_m6_core_init[] = {
818 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
819 /* setup adcs to point to mixer */
820 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
821 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
822 /* setup import muxs */
823 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
824 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
825 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
826 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
830 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
831 /* set master volume and direct control */
832 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
833 /* setup adcs to point to mixer */
834 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
835 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
836 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
838 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
839 /* setup import muxs */
840 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
841 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
842 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
843 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
847 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
848 /* set master volume and direct control */
849 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
850 /* dac3 is connected to import3 mux */
851 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
852 /* setup adcs to point to mixer */
853 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
854 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
855 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
856 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
857 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
858 /* setup import muxs */
859 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
860 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
861 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
862 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
866 static struct hda_verb stac92hd83xxx_core_init[] = {
867 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
868 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
869 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
871 /* power state controls amps */
872 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
876 static struct hda_verb stac92hd71bxx_core_init[] = {
877 /* set master volume and direct control */
878 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
882 #define HD_DISABLE_PORTF 1
883 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
884 /* start of config #1 */
886 /* connect port 0f to audio mixer */
887 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
888 /* start of config #2 */
890 /* set master volume and direct control */
891 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
895 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
896 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
897 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
898 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
899 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
903 static struct hda_verb stac925x_core_init[] = {
904 /* set dac0mux for dac converter */
905 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
906 /* mute the master volume */
907 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
911 static struct hda_verb stac922x_core_init[] = {
912 /* set master volume and direct control */
913 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
917 static struct hda_verb d965_core_init[] = {
918 /* set master volume and direct control */
919 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
920 /* unmute node 0x1b */
921 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
922 /* select node 0x03 as DAC */
923 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
927 static struct hda_verb stac927x_core_init[] = {
928 /* set master volume and direct control */
929 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
930 /* enable analog pc beep path */
931 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
935 static struct hda_verb stac9205_core_init[] = {
936 /* set master volume and direct control */
937 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
938 /* enable analog pc beep path */
939 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
943 #define STAC_MONO_MUX \
945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
946 .name = "Mono Mux", \
948 .info = stac92xx_mono_mux_enum_info, \
949 .get = stac92xx_mono_mux_enum_get, \
950 .put = stac92xx_mono_mux_enum_put, \
953 #define STAC_AMP_MUX \
955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
956 .name = "Amp Selector Capture Switch", \
958 .info = stac92xx_amp_mux_enum_info, \
959 .get = stac92xx_amp_mux_enum_get, \
960 .put = stac92xx_amp_mux_enum_put, \
963 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
968 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
969 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
970 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
971 .info = stac92xx_amp_volume_info, \
972 .get = stac92xx_amp_volume_get, \
973 .put = stac92xx_amp_volume_put, \
974 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
975 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
978 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
981 .name = "Analog Loopback", \
983 .info = stac92xx_aloopback_info, \
984 .get = stac92xx_aloopback_get, \
985 .put = stac92xx_aloopback_put, \
986 .private_value = verb_read | (verb_write << 16), \
989 static struct snd_kcontrol_new stac9200_mixer[] = {
990 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
991 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
992 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
993 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
997 #define DELL_M6_MIXER 6
998 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
999 /* start of config #1 */
1000 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1001 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1003 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1004 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1006 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1007 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1009 /* start of config #2 */
1010 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1011 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1013 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1014 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1016 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1018 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1019 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1021 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1022 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1027 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1028 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1030 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1031 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1033 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1034 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1036 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1037 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1039 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1040 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1042 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1043 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1045 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1046 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1048 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1049 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1053 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1054 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1056 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1057 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1059 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1060 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1062 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1063 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1065 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1066 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1068 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1069 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1071 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1072 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1074 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1075 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1080 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1081 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1082 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1084 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1085 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1087 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1088 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
1090 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1091 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
1093 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1094 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
1096 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1097 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
1100 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1101 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
1106 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1107 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1109 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1110 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1112 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1113 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1114 /* analog pc-beep replaced with digital beep support */
1116 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1117 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1120 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1121 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1123 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1124 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1126 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1127 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1129 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1130 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1134 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1135 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1137 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1138 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1140 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1141 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1145 static struct snd_kcontrol_new stac925x_mixer[] = {
1146 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1147 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1148 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1149 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1153 static struct snd_kcontrol_new stac9205_mixer[] = {
1154 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1156 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1157 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1159 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1160 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1164 /* This needs to be generated dynamically based on sequence */
1165 static struct snd_kcontrol_new stac922x_mixer[] = {
1166 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1167 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1169 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1170 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1175 static struct snd_kcontrol_new stac927x_mixer[] = {
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] = {
1499 [STAC_AUTO] = "auto",
1501 [STAC_9200_OQO] = "oqo",
1502 [STAC_9200_DELL_D21] = "dell-d21",
1503 [STAC_9200_DELL_D22] = "dell-d22",
1504 [STAC_9200_DELL_D23] = "dell-d23",
1505 [STAC_9200_DELL_M21] = "dell-m21",
1506 [STAC_9200_DELL_M22] = "dell-m22",
1507 [STAC_9200_DELL_M23] = "dell-m23",
1508 [STAC_9200_DELL_M24] = "dell-m24",
1509 [STAC_9200_DELL_M25] = "dell-m25",
1510 [STAC_9200_DELL_M26] = "dell-m26",
1511 [STAC_9200_DELL_M27] = "dell-m27",
1512 [STAC_9200_M4] = "gateway-m4",
1513 [STAC_9200_M4_2] = "gateway-m4-2",
1514 [STAC_9200_PANASONIC] = "panasonic",
1517 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1518 /* SigmaTel reference board */
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1520 "DFI LanParty", STAC_REF),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1522 "DFI LanParty", STAC_REF),
1523 /* Dell laptops have BIOS problem */
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1525 "unknown Dell", STAC_9200_DELL_D21),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1527 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1529 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1531 "unknown Dell", STAC_9200_DELL_D22),
1532 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1533 "unknown Dell", STAC_9200_DELL_D22),
1534 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1535 "Dell Latitude D620", STAC_9200_DELL_M22),
1536 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1537 "unknown Dell", STAC_9200_DELL_D23),
1538 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1539 "unknown Dell", STAC_9200_DELL_D23),
1540 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1541 "unknown Dell", STAC_9200_DELL_M22),
1542 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1543 "unknown Dell", STAC_9200_DELL_M24),
1544 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1545 "unknown Dell", STAC_9200_DELL_M24),
1546 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1547 "Dell Latitude 120L", STAC_9200_DELL_M24),
1548 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1549 "Dell Latitude D820", STAC_9200_DELL_M22),
1550 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1551 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1552 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1553 "Dell XPS M1710", STAC_9200_DELL_M23),
1554 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1555 "Dell Precision M90", STAC_9200_DELL_M23),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1557 "unknown Dell", STAC_9200_DELL_M22),
1558 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1559 "unknown Dell", STAC_9200_DELL_M22),
1560 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1561 "unknown Dell", STAC_9200_DELL_M22),
1562 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1563 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1564 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1565 "unknown Dell", STAC_9200_DELL_D23),
1566 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1567 "unknown Dell", STAC_9200_DELL_D23),
1568 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1569 "unknown Dell", STAC_9200_DELL_D21),
1570 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1571 "unknown Dell", STAC_9200_DELL_D23),
1572 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1573 "unknown Dell", STAC_9200_DELL_D21),
1574 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1575 "unknown Dell", STAC_9200_DELL_M25),
1576 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1577 "unknown Dell", STAC_9200_DELL_M25),
1578 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1579 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1580 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1581 "unknown Dell", STAC_9200_DELL_M26),
1583 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1584 /* Gateway machines needs EAPD to be set on resume */
1585 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1586 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1587 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1589 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1593 static unsigned int ref925x_pin_configs[8] = {
1594 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1595 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1598 static unsigned int stac925xM1_pin_configs[8] = {
1599 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1600 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1603 static unsigned int stac925xM1_2_pin_configs[8] = {
1604 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1605 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1608 static unsigned int stac925xM2_pin_configs[8] = {
1609 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1610 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1613 static unsigned int stac925xM2_2_pin_configs[8] = {
1614 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1615 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1618 static unsigned int stac925xM3_pin_configs[8] = {
1619 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1620 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1623 static unsigned int stac925xM5_pin_configs[8] = {
1624 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1625 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1628 static unsigned int stac925xM6_pin_configs[8] = {
1629 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1630 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1633 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1634 [STAC_REF] = ref925x_pin_configs,
1635 [STAC_M1] = stac925xM1_pin_configs,
1636 [STAC_M1_2] = stac925xM1_2_pin_configs,
1637 [STAC_M2] = stac925xM2_pin_configs,
1638 [STAC_M2_2] = stac925xM2_2_pin_configs,
1639 [STAC_M3] = stac925xM3_pin_configs,
1640 [STAC_M5] = stac925xM5_pin_configs,
1641 [STAC_M6] = stac925xM6_pin_configs,
1644 static const char *stac925x_models[STAC_925x_MODELS] = {
1645 [STAC_925x_AUTO] = "auto",
1648 [STAC_M1_2] = "m1-2",
1650 [STAC_M2_2] = "m2-2",
1656 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1657 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1658 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1659 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1660 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1661 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1662 /* Not sure about the brand name for those */
1663 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1664 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1665 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1666 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1670 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1671 /* SigmaTel reference board */
1672 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1674 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1676 /* Default table for unknown ID */
1677 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1682 static unsigned int ref92hd73xx_pin_configs[13] = {
1683 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1684 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1685 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1689 static unsigned int dell_m6_pin_configs[13] = {
1690 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1691 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1692 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1696 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1697 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1698 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1699 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1700 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1701 [STAC_DELL_EQ] = dell_m6_pin_configs,
1704 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1705 [STAC_92HD73XX_AUTO] = "auto",
1706 [STAC_92HD73XX_NO_JD] = "no-jd",
1707 [STAC_92HD73XX_REF] = "ref",
1708 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1709 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1710 [STAC_DELL_M6_BOTH] = "dell-m6",
1711 [STAC_DELL_EQ] = "dell-eq",
1714 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1715 /* SigmaTel reference board */
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1717 "DFI LanParty", STAC_92HD73XX_REF),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1719 "DFI LanParty", STAC_92HD73XX_REF),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1721 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1723 "unknown Dell", STAC_DELL_M6_DMIC),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1725 "unknown Dell", STAC_DELL_M6_BOTH),
1726 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1727 "unknown Dell", STAC_DELL_M6_BOTH),
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1729 "unknown Dell", STAC_DELL_M6_AMIC),
1730 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1731 "unknown Dell", STAC_DELL_M6_AMIC),
1732 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1733 "unknown Dell", STAC_DELL_M6_DMIC),
1734 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1735 "unknown Dell", STAC_DELL_M6_DMIC),
1736 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1737 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1738 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1739 "Dell Studio 17", STAC_DELL_M6_DMIC),
1743 static unsigned int ref92hd83xxx_pin_configs[10] = {
1744 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1745 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1746 0x01451160, 0x98560170,
1749 static unsigned int dell_s14_pin_configs[10] = {
1750 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1751 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1752 0x40f000f0, 0x40f000f0,
1755 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1756 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1757 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1758 [STAC_DELL_S14] = dell_s14_pin_configs,
1761 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1762 [STAC_92HD83XXX_AUTO] = "auto",
1763 [STAC_92HD83XXX_REF] = "ref",
1764 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1765 [STAC_DELL_S14] = "dell-s14",
1768 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1769 /* SigmaTel reference board */
1770 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1771 "DFI LanParty", STAC_92HD83XXX_REF),
1772 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1773 "DFI LanParty", STAC_92HD83XXX_REF),
1774 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1775 "unknown Dell", STAC_DELL_S14),
1779 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1780 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1781 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1782 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1786 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1787 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1788 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1789 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1793 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1794 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1795 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1796 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1800 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1801 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1802 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1803 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1807 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1808 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1809 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1810 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1811 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1812 [STAC_HP_M4] = NULL,
1813 [STAC_HP_DV5] = NULL,
1816 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1817 [STAC_92HD71BXX_AUTO] = "auto",
1818 [STAC_92HD71BXX_REF] = "ref",
1819 [STAC_DELL_M4_1] = "dell-m4-1",
1820 [STAC_DELL_M4_2] = "dell-m4-2",
1821 [STAC_DELL_M4_3] = "dell-m4-3",
1822 [STAC_HP_M4] = "hp-m4",
1823 [STAC_HP_DV5] = "hp-dv5",
1826 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1827 /* SigmaTel reference board */
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1829 "DFI LanParty", STAC_92HD71BXX_REF),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1831 "DFI LanParty", STAC_92HD71BXX_REF),
1832 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1833 "HP dv4-7", STAC_HP_DV5),
1834 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1835 "HP dv4-7", STAC_HP_DV5),
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1837 "HP mini 1000", STAC_HP_M4),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1839 "unknown Dell", STAC_DELL_M4_1),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1841 "unknown Dell", STAC_DELL_M4_1),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1843 "unknown Dell", STAC_DELL_M4_1),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1845 "unknown Dell", STAC_DELL_M4_1),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1847 "unknown Dell", STAC_DELL_M4_1),
1848 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1849 "unknown Dell", STAC_DELL_M4_1),
1850 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1851 "unknown Dell", STAC_DELL_M4_1),
1852 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1853 "unknown Dell", STAC_DELL_M4_2),
1854 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1855 "unknown Dell", STAC_DELL_M4_2),
1856 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1857 "unknown Dell", STAC_DELL_M4_2),
1858 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1859 "unknown Dell", STAC_DELL_M4_2),
1860 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1861 "unknown Dell", STAC_DELL_M4_3),
1865 static unsigned int ref922x_pin_configs[10] = {
1866 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1867 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1868 0x40000100, 0x40000100,
1872 STAC 922X pin configs for
1879 static unsigned int dell_922x_d81_pin_configs[10] = {
1880 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1881 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1882 0x01813122, 0x400001f2,
1886 STAC 922X pin configs for
1890 static unsigned int dell_922x_d82_pin_configs[10] = {
1891 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1892 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1893 0x01813122, 0x400001f1,
1897 STAC 922X pin configs for
1900 static unsigned int dell_922x_m81_pin_configs[10] = {
1901 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1902 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1903 0x40C003f1, 0x405003f0,
1907 STAC 9221 A1 pin configs for
1908 102801D7 (Dell XPS M1210)
1910 static unsigned int dell_922x_m82_pin_configs[10] = {
1911 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1912 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1913 0x508003f3, 0x405003f4,
1916 static unsigned int d945gtp3_pin_configs[10] = {
1917 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1918 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1919 0x02a19120, 0x40000100,
1922 static unsigned int d945gtp5_pin_configs[10] = {
1923 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1924 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1925 0x02a19320, 0x40000100,
1928 static unsigned int intel_mac_v1_pin_configs[10] = {
1929 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1930 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1931 0x400000fc, 0x400000fb,
1934 static unsigned int intel_mac_v2_pin_configs[10] = {
1935 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1936 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1937 0x400000fc, 0x400000fb,
1940 static unsigned int intel_mac_v3_pin_configs[10] = {
1941 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1942 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1943 0x400000fc, 0x400000fb,
1946 static unsigned int intel_mac_v4_pin_configs[10] = {
1947 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1948 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1949 0x400000fc, 0x400000fb,
1952 static unsigned int intel_mac_v5_pin_configs[10] = {
1953 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1954 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1955 0x400000fc, 0x400000fb,
1958 static unsigned int ecs202_pin_configs[10] = {
1959 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1960 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1961 0x9037012e, 0x40e000f2,
1964 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1965 [STAC_D945_REF] = ref922x_pin_configs,
1966 [STAC_D945GTP3] = d945gtp3_pin_configs,
1967 [STAC_D945GTP5] = d945gtp5_pin_configs,
1968 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1969 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1970 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1971 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1972 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1973 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1974 /* for backward compatibility */
1975 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1976 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1977 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1978 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1979 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1980 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1981 [STAC_ECS_202] = ecs202_pin_configs,
1982 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1983 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1984 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1985 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1988 static const char *stac922x_models[STAC_922X_MODELS] = {
1989 [STAC_922X_AUTO] = "auto",
1990 [STAC_D945_REF] = "ref",
1991 [STAC_D945GTP5] = "5stack",
1992 [STAC_D945GTP3] = "3stack",
1993 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1994 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1995 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1996 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1997 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1998 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1999 /* for backward compatibility */
2000 [STAC_MACMINI] = "macmini",
2001 [STAC_MACBOOK] = "macbook",
2002 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2003 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
2004 [STAC_IMAC_INTEL] = "imac-intel",
2005 [STAC_IMAC_INTEL_20] = "imac-intel-20",
2006 [STAC_ECS_202] = "ecs202",
2007 [STAC_922X_DELL_D81] = "dell-d81",
2008 [STAC_922X_DELL_D82] = "dell-d82",
2009 [STAC_922X_DELL_M81] = "dell-m81",
2010 [STAC_922X_DELL_M82] = "dell-m82",
2013 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2014 /* SigmaTel reference board */
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2016 "DFI LanParty", STAC_D945_REF),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2018 "DFI LanParty", STAC_D945_REF),
2019 /* Intel 945G based systems */
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2021 "Intel D945G", STAC_D945GTP3),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2023 "Intel D945G", STAC_D945GTP3),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2025 "Intel D945G", STAC_D945GTP3),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2027 "Intel D945G", STAC_D945GTP3),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2029 "Intel D945G", STAC_D945GTP3),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2031 "Intel D945G", STAC_D945GTP3),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2033 "Intel D945G", STAC_D945GTP3),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2035 "Intel D945G", STAC_D945GTP3),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2037 "Intel D945G", STAC_D945GTP3),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2039 "Intel D945G", STAC_D945GTP3),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2041 "Intel D945G", STAC_D945GTP3),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2043 "Intel D945G", STAC_D945GTP3),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2045 "Intel D945G", STAC_D945GTP3),
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2047 "Intel D945G", STAC_D945GTP3),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2049 "Intel D945G", STAC_D945GTP3),
2050 /* Intel D945G 5-stack systems */
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2052 "Intel D945G", STAC_D945GTP5),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2054 "Intel D945G", STAC_D945GTP5),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2056 "Intel D945G", STAC_D945GTP5),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2058 "Intel D945G", STAC_D945GTP5),
2059 /* Intel 945P based systems */
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2061 "Intel D945P", STAC_D945GTP3),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2063 "Intel D945P", STAC_D945GTP3),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2065 "Intel D945P", STAC_D945GTP3),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2067 "Intel D945P", STAC_D945GTP3),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2069 "Intel D945P", STAC_D945GTP3),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2071 "Intel D945P", STAC_D945GTP5),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2074 "Intel D945", STAC_D945_REF),
2076 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2077 SND_PCI_QUIRK(0x8384, 0x7680,
2078 "Mac", STAC_INTEL_MAC_AUTO),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2081 "unknown Dell", STAC_922X_DELL_D81),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2083 "unknown Dell", STAC_922X_DELL_D81),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2085 "unknown Dell", STAC_922X_DELL_D81),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2087 "unknown Dell", STAC_922X_DELL_D82),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2089 "unknown Dell", STAC_922X_DELL_M81),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2091 "unknown Dell", STAC_922X_DELL_D82),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2093 "unknown Dell", STAC_922X_DELL_D81),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2095 "unknown Dell", STAC_922X_DELL_D81),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2097 "Dell XPS M1210", STAC_922X_DELL_M82),
2098 /* ECS/PC Chips boards */
2099 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2100 "ECS/PC chips", STAC_ECS_202),
2104 static unsigned int ref927x_pin_configs[14] = {
2105 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2106 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2107 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2108 0x01c42190, 0x40000100,
2111 static unsigned int d965_3st_pin_configs[14] = {
2112 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2113 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2114 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2115 0x40000100, 0x40000100
2118 static unsigned int d965_5st_pin_configs[14] = {
2119 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2120 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2121 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2122 0x40000100, 0x40000100
2125 static unsigned int dell_3st_pin_configs[14] = {
2126 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2127 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2128 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2129 0x40c003fc, 0x40000100
2132 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2133 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2134 [STAC_D965_REF] = ref927x_pin_configs,
2135 [STAC_D965_3ST] = d965_3st_pin_configs,
2136 [STAC_D965_5ST] = d965_5st_pin_configs,
2137 [STAC_DELL_3ST] = dell_3st_pin_configs,
2138 [STAC_DELL_BIOS] = NULL,
2141 static const char *stac927x_models[STAC_927X_MODELS] = {
2142 [STAC_927X_AUTO] = "auto",
2143 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2144 [STAC_D965_REF] = "ref",
2145 [STAC_D965_3ST] = "3stack",
2146 [STAC_D965_5ST] = "5stack",
2147 [STAC_DELL_3ST] = "dell-3stack",
2148 [STAC_DELL_BIOS] = "dell-bios",
2151 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2152 /* SigmaTel reference board */
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2154 "DFI LanParty", STAC_D965_REF),
2155 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2156 "DFI LanParty", STAC_D965_REF),
2157 /* Intel 946 based systems */
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2160 /* 965 based 3 stack systems */
2161 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2162 "Intel D965", STAC_D965_3ST),
2163 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2164 "Intel D965", STAC_D965_3ST),
2165 /* Dell 3 stack systems */
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2170 /* Dell 3 stack systems with verb table in BIOS */
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2179 /* 965 based 5 stack systems */
2180 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2181 "Intel D965", STAC_D965_5ST),
2182 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2183 "Intel D965", STAC_D965_5ST),
2187 static unsigned int ref9205_pin_configs[12] = {
2188 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2189 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2190 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2194 STAC 9205 pin configs for
2201 10280228 (Dell Vostro 1500)
2203 static unsigned int dell_9205_m42_pin_configs[12] = {
2204 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2205 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2206 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2210 STAC 9205 pin configs for
2214 102801FF (Dell Precision M4300)
2219 static unsigned int dell_9205_m43_pin_configs[12] = {
2220 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2221 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2222 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2225 static unsigned int dell_9205_m44_pin_configs[12] = {
2226 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2227 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2228 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2231 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2232 [STAC_9205_REF] = ref9205_pin_configs,
2233 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2234 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2235 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2236 [STAC_9205_EAPD] = NULL,
2239 static const char *stac9205_models[STAC_9205_MODELS] = {
2240 [STAC_9205_AUTO] = "auto",
2241 [STAC_9205_REF] = "ref",
2242 [STAC_9205_DELL_M42] = "dell-m42",
2243 [STAC_9205_DELL_M43] = "dell-m43",
2244 [STAC_9205_DELL_M44] = "dell-m44",
2245 [STAC_9205_EAPD] = "eapd",
2248 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2249 /* SigmaTel reference board */
2250 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2251 "DFI LanParty", STAC_9205_REF),
2252 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2253 "DFI LanParty", STAC_9205_REF),
2255 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2256 "unknown Dell", STAC_9205_DELL_M42),
2257 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2258 "unknown Dell", STAC_9205_DELL_M42),
2259 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2260 "Dell Precision", STAC_9205_DELL_M43),
2261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2262 "Dell Precision", STAC_9205_DELL_M43),
2263 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2264 "Dell Precision", STAC_9205_DELL_M43),
2265 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2266 "unknown Dell", STAC_9205_DELL_M42),
2267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2268 "unknown Dell", STAC_9205_DELL_M42),
2269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2270 "Dell Precision", STAC_9205_DELL_M43),
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2272 "Dell Precision M4300", STAC_9205_DELL_M43),
2273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2274 "unknown Dell", STAC_9205_DELL_M42),
2275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2276 "Dell Precision", STAC_9205_DELL_M43),
2277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2278 "Dell Precision", STAC_9205_DELL_M43),
2279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2280 "Dell Precision", STAC_9205_DELL_M43),
2281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2282 "Dell Inspiron", STAC_9205_DELL_M44),
2283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2284 "Dell Vostro 1500", STAC_9205_DELL_M42),
2286 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2290 static void stac92xx_set_config_regs(struct hda_codec *codec,
2291 unsigned int *pincfgs)
2294 struct sigmatel_spec *spec = codec->spec;
2299 for (i = 0; i < spec->num_pins; i++)
2300 if (spec->pin_nids[i] && pincfgs[i])
2301 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2306 * Analog playback callbacks
2308 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2309 struct hda_codec *codec,
2310 struct snd_pcm_substream *substream)
2312 struct sigmatel_spec *spec = codec->spec;
2313 if (spec->stream_delay)
2314 msleep(spec->stream_delay);
2315 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2319 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2320 struct hda_codec *codec,
2321 unsigned int stream_tag,
2322 unsigned int format,
2323 struct snd_pcm_substream *substream)
2325 struct sigmatel_spec *spec = codec->spec;
2326 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2329 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2330 struct hda_codec *codec,
2331 struct snd_pcm_substream *substream)
2333 struct sigmatel_spec *spec = codec->spec;
2334 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2338 * Digital playback callbacks
2340 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2341 struct hda_codec *codec,
2342 struct snd_pcm_substream *substream)
2344 struct sigmatel_spec *spec = codec->spec;
2345 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2348 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2349 struct hda_codec *codec,
2350 struct snd_pcm_substream *substream)
2352 struct sigmatel_spec *spec = codec->spec;
2353 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2356 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2357 struct hda_codec *codec,
2358 unsigned int stream_tag,
2359 unsigned int format,
2360 struct snd_pcm_substream *substream)
2362 struct sigmatel_spec *spec = codec->spec;
2363 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2364 stream_tag, format, substream);
2367 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2368 struct hda_codec *codec,
2369 struct snd_pcm_substream *substream)
2371 struct sigmatel_spec *spec = codec->spec;
2372 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2377 * Analog capture callbacks
2379 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2380 struct hda_codec *codec,
2381 unsigned int stream_tag,
2382 unsigned int format,
2383 struct snd_pcm_substream *substream)
2385 struct sigmatel_spec *spec = codec->spec;
2386 hda_nid_t nid = spec->adc_nids[substream->number];
2388 if (spec->powerdown_adcs) {
2390 snd_hda_codec_write(codec, nid, 0,
2391 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2393 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2397 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2398 struct hda_codec *codec,
2399 struct snd_pcm_substream *substream)
2401 struct sigmatel_spec *spec = codec->spec;
2402 hda_nid_t nid = spec->adc_nids[substream->number];
2404 snd_hda_codec_cleanup_stream(codec, nid);
2405 if (spec->powerdown_adcs)
2406 snd_hda_codec_write(codec, nid, 0,
2407 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2411 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2415 /* NID is set in stac92xx_build_pcms */
2417 .open = stac92xx_dig_playback_pcm_open,
2418 .close = stac92xx_dig_playback_pcm_close,
2419 .prepare = stac92xx_dig_playback_pcm_prepare,
2420 .cleanup = stac92xx_dig_playback_pcm_cleanup
2424 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2428 /* NID is set in stac92xx_build_pcms */
2431 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2435 .nid = 0x02, /* NID to query formats and rates */
2437 .open = stac92xx_playback_pcm_open,
2438 .prepare = stac92xx_playback_pcm_prepare,
2439 .cleanup = stac92xx_playback_pcm_cleanup
2443 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2447 .nid = 0x06, /* NID to query formats and rates */
2449 .open = stac92xx_playback_pcm_open,
2450 .prepare = stac92xx_playback_pcm_prepare,
2451 .cleanup = stac92xx_playback_pcm_cleanup
2455 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2458 /* NID + .substreams is set in stac92xx_build_pcms */
2460 .prepare = stac92xx_capture_pcm_prepare,
2461 .cleanup = stac92xx_capture_pcm_cleanup
2465 static int stac92xx_build_pcms(struct hda_codec *codec)
2467 struct sigmatel_spec *spec = codec->spec;
2468 struct hda_pcm *info = spec->pcm_rec;
2470 codec->num_pcms = 1;
2471 codec->pcm_info = info;
2473 info->name = "STAC92xx Analog";
2474 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2475 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2476 spec->multiout.dac_nids[0];
2477 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2478 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2479 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2481 if (spec->alt_switch) {
2484 info->name = "STAC92xx Analog Alt";
2485 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2488 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2491 info->name = "STAC92xx Digital";
2492 info->pcm_type = spec->autocfg.dig_out_type[0];
2493 if (spec->multiout.dig_out_nid) {
2494 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2495 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2497 if (spec->dig_in_nid) {
2498 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2499 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2506 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2508 unsigned int pincap = snd_hda_param_read(codec, nid,
2510 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2511 if (pincap & AC_PINCAP_VREF_100)
2512 return AC_PINCTL_VREF_100;
2513 if (pincap & AC_PINCAP_VREF_80)
2514 return AC_PINCTL_VREF_80;
2515 if (pincap & AC_PINCAP_VREF_50)
2516 return AC_PINCTL_VREF_50;
2517 if (pincap & AC_PINCAP_VREF_GRD)
2518 return AC_PINCTL_VREF_GRD;
2522 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2525 snd_hda_codec_write_cache(codec, nid, 0,
2526 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2529 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2531 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2532 struct snd_ctl_elem_value *ucontrol)
2534 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2535 struct sigmatel_spec *spec = codec->spec;
2537 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2541 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2542 unsigned char type);
2544 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2545 struct snd_ctl_elem_value *ucontrol)
2547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2548 struct sigmatel_spec *spec = codec->spec;
2549 int nid = kcontrol->private_value;
2551 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2553 /* check to be sure that the ports are upto date with
2556 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2561 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2563 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2565 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2566 struct sigmatel_spec *spec = codec->spec;
2567 int io_idx = kcontrol-> private_value & 0xff;
2569 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2573 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2575 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2576 struct sigmatel_spec *spec = codec->spec;
2577 hda_nid_t nid = kcontrol->private_value >> 8;
2578 int io_idx = kcontrol-> private_value & 0xff;
2579 unsigned short val = !!ucontrol->value.integer.value[0];
2581 spec->io_switch[io_idx] = val;
2584 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2586 unsigned int pinctl = AC_PINCTL_IN_EN;
2587 if (io_idx) /* set VREF for mic */
2588 pinctl |= stac92xx_get_vref(codec, nid);
2589 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2592 /* check the auto-mute again: we need to mute/unmute the speaker
2593 * appropriately according to the pin direction
2595 if (spec->hp_detect)
2596 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2601 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2603 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2604 struct snd_ctl_elem_value *ucontrol)
2606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2607 struct sigmatel_spec *spec = codec->spec;
2609 ucontrol->value.integer.value[0] = spec->clfe_swap;
2613 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2614 struct snd_ctl_elem_value *ucontrol)
2616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2617 struct sigmatel_spec *spec = codec->spec;
2618 hda_nid_t nid = kcontrol->private_value & 0xff;
2619 unsigned int val = !!ucontrol->value.integer.value[0];
2621 if (spec->clfe_swap == val)
2624 spec->clfe_swap = val;
2626 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2627 spec->clfe_swap ? 0x4 : 0x0);
2632 #define STAC_CODEC_HP_SWITCH(xname) \
2633 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2636 .info = stac92xx_hp_switch_info, \
2637 .get = stac92xx_hp_switch_get, \
2638 .put = stac92xx_hp_switch_put, \
2641 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2642 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2645 .info = stac92xx_io_switch_info, \
2646 .get = stac92xx_io_switch_get, \
2647 .put = stac92xx_io_switch_put, \
2648 .private_value = xpval, \
2651 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2652 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2655 .info = stac92xx_clfe_switch_info, \
2656 .get = stac92xx_clfe_switch_get, \
2657 .put = stac92xx_clfe_switch_put, \
2658 .private_value = xpval, \
2662 STAC_CTL_WIDGET_VOL,
2663 STAC_CTL_WIDGET_MUTE,
2664 STAC_CTL_WIDGET_MONO_MUX,
2665 STAC_CTL_WIDGET_AMP_MUX,
2666 STAC_CTL_WIDGET_AMP_VOL,
2667 STAC_CTL_WIDGET_HP_SWITCH,
2668 STAC_CTL_WIDGET_IO_SWITCH,
2669 STAC_CTL_WIDGET_CLFE_SWITCH
2672 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2673 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2674 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2677 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2678 STAC_CODEC_HP_SWITCH(NULL),
2679 STAC_CODEC_IO_SWITCH(NULL, 0),
2680 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2683 /* add dynamic controls */
2684 static struct snd_kcontrol_new *
2685 stac_control_new(struct sigmatel_spec *spec,
2686 struct snd_kcontrol_new *ktemp,
2689 struct snd_kcontrol_new *knew;
2691 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2692 knew = snd_array_new(&spec->kctls);
2696 knew->name = kstrdup(name, GFP_KERNEL);
2699 memset(knew, 0, sizeof(*knew));
2700 spec->kctls.alloced--;
2706 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2707 struct snd_kcontrol_new *ktemp,
2708 int idx, const char *name,
2711 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2715 knew->private_value = val;
2719 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2720 int type, int idx, const char *name,
2723 return stac92xx_add_control_temp(spec,
2724 &stac92xx_control_templates[type],
2729 /* add dynamic controls */
2730 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2731 const char *name, unsigned long val)
2733 return stac92xx_add_control_idx(spec, type, 0, name, val);
2736 static struct snd_kcontrol_new stac_input_src_temp = {
2737 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2738 .name = "Input Source",
2739 .info = stac92xx_mux_enum_info,
2740 .get = stac92xx_mux_enum_get,
2741 .put = stac92xx_mux_enum_put,
2744 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2746 struct snd_kcontrol_new *knew;
2747 struct hda_input_mux *imux = &spec->private_imux;
2749 if (!spec->num_adcs || imux->num_items <= 1)
2750 return 0; /* no need for input source control */
2751 knew = stac_control_new(spec, &stac_input_src_temp,
2752 stac_input_src_temp.name);
2755 knew->count = spec->num_adcs;
2759 /* check whether the line-input can be used as line-out */
2760 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2762 struct sigmatel_spec *spec = codec->spec;
2763 struct auto_pin_cfg *cfg = &spec->autocfg;
2765 unsigned int pincap;
2767 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2769 nid = cfg->input_pins[AUTO_PIN_LINE];
2770 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2771 if (pincap & AC_PINCAP_OUT)
2776 /* check whether the mic-input can be used as line-out */
2777 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2779 struct sigmatel_spec *spec = codec->spec;
2780 struct auto_pin_cfg *cfg = &spec->autocfg;
2781 unsigned int def_conf, pincap;
2782 unsigned int mic_pin;
2784 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2786 mic_pin = AUTO_PIN_MIC;
2788 hda_nid_t nid = cfg->input_pins[mic_pin];
2789 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2790 /* some laptops have an internal analog microphone
2791 * which can't be used as a output */
2792 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2793 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2794 if (pincap & AC_PINCAP_OUT)
2797 if (mic_pin == AUTO_PIN_MIC)
2798 mic_pin = AUTO_PIN_FRONT_MIC;
2805 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2809 for (i = 0; i < spec->multiout.num_dacs; i++) {
2810 if (spec->multiout.dac_nids[i] == nid)
2817 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2820 if (is_in_dac_nids(spec, nid))
2822 for (i = 0; i < spec->autocfg.hp_outs; i++)
2823 if (spec->hp_dacs[i] == nid)
2825 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2826 if (spec->speaker_dacs[i] == nid)
2831 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2833 struct sigmatel_spec *spec = codec->spec;
2835 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2836 unsigned int wcaps, wtype;
2838 conn_len = snd_hda_get_connections(codec, nid, conn,
2839 HDA_MAX_CONNECTIONS);
2840 for (j = 0; j < conn_len; j++) {
2841 wcaps = snd_hda_param_read(codec, conn[j],
2842 AC_PAR_AUDIO_WIDGET_CAP);
2843 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2844 /* we check only analog outputs */
2845 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2847 /* if this route has a free DAC, assign it */
2848 if (!check_all_dac_nids(spec, conn[j])) {
2850 /* select this DAC in the pin's input mux */
2851 snd_hda_codec_write_cache(codec, nid, 0,
2852 AC_VERB_SET_CONNECT_SEL, j);
2860 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2861 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2864 * Fill in the dac_nids table from the parsed pin configuration
2865 * This function only works when every pin in line_out_pins[]
2866 * contains atleast one DAC in its connection list. Some 92xx
2867 * codecs are not connected directly to a DAC, such as the 9200
2868 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2870 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2872 struct sigmatel_spec *spec = codec->spec;
2873 struct auto_pin_cfg *cfg = &spec->autocfg;
2877 for (i = 0; i < cfg->line_outs; i++) {
2878 nid = cfg->line_out_pins[i];
2879 dac = get_unassigned_dac(codec, nid);
2881 if (spec->multiout.num_dacs > 0) {
2882 /* we have already working output pins,
2883 * so let's drop the broken ones again
2885 cfg->line_outs = spec->multiout.num_dacs;
2888 /* error out, no available DAC found */
2890 "%s: No available DAC for pin 0x%x\n",
2894 add_spec_dacs(spec, dac);
2897 /* add line-in as output */
2898 nid = check_line_out_switch(codec);
2900 dac = get_unassigned_dac(codec, nid);
2902 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2903 nid, cfg->line_outs);
2904 cfg->line_out_pins[cfg->line_outs] = nid;
2906 spec->line_switch = nid;
2907 add_spec_dacs(spec, dac);
2910 /* add mic as output */
2911 nid = check_mic_out_switch(codec);
2913 dac = get_unassigned_dac(codec, nid);
2915 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2916 nid, cfg->line_outs);
2917 cfg->line_out_pins[cfg->line_outs] = nid;
2919 spec->mic_switch = nid;
2920 add_spec_dacs(spec, dac);
2924 for (i = 0; i < cfg->hp_outs; i++) {
2925 nid = cfg->hp_pins[i];
2926 dac = get_unassigned_dac(codec, nid);
2928 if (!spec->multiout.hp_nid)
2929 spec->multiout.hp_nid = dac;
2931 add_spec_extra_dacs(spec, dac);
2933 spec->hp_dacs[i] = dac;
2936 for (i = 0; i < cfg->speaker_outs; i++) {
2937 nid = cfg->speaker_pins[i];
2938 dac = get_unassigned_dac(codec, nid);
2940 add_spec_extra_dacs(spec, dac);
2941 spec->speaker_dacs[i] = dac;
2944 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2945 spec->multiout.num_dacs,
2946 spec->multiout.dac_nids[0],
2947 spec->multiout.dac_nids[1],
2948 spec->multiout.dac_nids[2],
2949 spec->multiout.dac_nids[3],
2950 spec->multiout.dac_nids[4]);
2955 /* create volume control/switch for the given prefx type */
2956 static int create_controls(struct hda_codec *codec, const char *pfx,
2957 hda_nid_t nid, int chs)
2959 struct sigmatel_spec *spec = codec->spec;
2963 if (!spec->check_volume_offset) {
2964 unsigned int caps, step, nums, db_scale;
2965 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2966 step = (caps & AC_AMPCAP_STEP_SIZE) >>
2967 AC_AMPCAP_STEP_SIZE_SHIFT;
2968 step = (step + 1) * 25; /* in .01dB unit */
2969 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
2970 AC_AMPCAP_NUM_STEPS_SHIFT;
2971 db_scale = nums * step;
2972 /* if dB scale is over -64dB, and finer enough,
2973 * let's reduce it to half
2975 if (db_scale > 6400 && nums >= 0x1f)
2976 spec->volume_offset = nums / 2;
2977 spec->check_volume_offset = 1;
2980 sprintf(name, "%s Playback Volume", pfx);
2981 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2982 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
2983 spec->volume_offset));
2986 sprintf(name, "%s Playback Switch", pfx);
2987 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2988 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2994 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2996 if (spec->multiout.num_dacs > 4) {
2997 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3000 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3001 spec->multiout.num_dacs++;
3006 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3009 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3010 if (!spec->multiout.extra_out_nid[i]) {
3011 spec->multiout.extra_out_nid[i] = nid;
3015 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3019 static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid)
3023 if (spec->autocfg.line_outs != 1)
3025 if (spec->multiout.hp_nid == nid)
3027 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
3028 if (spec->multiout.extra_out_nid[i] == nid)
3033 /* add playback controls from the parsed DAC table */
3034 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3035 const struct auto_pin_cfg *cfg)
3037 struct sigmatel_spec *spec = codec->spec;
3038 static const char *chname[4] = {
3039 "Front", "Surround", NULL /*CLFE*/, "Side"
3043 unsigned int wid_caps;
3045 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) {
3046 nid = spec->multiout.dac_nids[i];
3049 err = create_controls(codec, "Center", nid, 1);
3052 err = create_controls(codec, "LFE", nid, 2);
3056 wid_caps = get_wcaps(codec, nid);
3058 if (wid_caps & AC_WCAP_LR_SWAP) {
3059 err = stac92xx_add_control(spec,
3060 STAC_CTL_WIDGET_CLFE_SWITCH,
3061 "Swap Center/LFE Playback Switch", nid);
3068 const char *name = chname[i];
3069 /* if it's a single DAC, assign a better name */
3070 if (!i && is_unique_dac(spec, nid)) {
3071 switch (cfg->line_out_type) {
3072 case AUTO_PIN_HP_OUT:
3075 case AUTO_PIN_SPEAKER_OUT:
3080 err = create_controls(codec, name, nid, 3);
3086 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3087 err = stac92xx_add_control(spec,
3088 STAC_CTL_WIDGET_HP_SWITCH,
3089 "Headphone as Line Out Switch",
3090 cfg->hp_pins[cfg->hp_outs - 1]);
3095 if (spec->line_switch) {
3096 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3097 "Line In as Output Switch",
3098 spec->line_switch << 8);
3103 if (spec->mic_switch) {
3104 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3105 "Mic as Output Switch",
3106 (spec->mic_switch << 8) | 1);
3114 /* add playback controls for Speaker and HP outputs */
3115 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3116 struct auto_pin_cfg *cfg)
3118 struct sigmatel_spec *spec = codec->spec;
3123 for (i = 0; i < cfg->hp_outs; i++) {
3124 static const char *pfxs[] = {
3125 "Headphone", "Headphone2", "Headphone3",
3127 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3128 if (wid_caps & AC_WCAP_UNSOL_CAP)
3129 spec->hp_detect = 1;
3130 if (nums >= ARRAY_SIZE(pfxs))
3132 nid = spec->hp_dacs[i];
3135 err = create_controls(codec, pfxs[nums++], nid, 3);
3140 for (i = 0; i < cfg->speaker_outs; i++) {
3141 static const char *pfxs[] = {
3142 "Speaker", "External Speaker", "Speaker2",
3144 if (nums >= ARRAY_SIZE(pfxs))
3146 nid = spec->speaker_dacs[i];
3149 err = create_controls(codec, pfxs[nums++], nid, 3);
3156 /* labels for mono mux outputs */
3157 static const char *stac92xx_mono_labels[4] = {
3158 "DAC0", "DAC1", "Mixer", "DAC2"
3161 /* create mono mux for mono out on capable codecs */
3162 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3164 struct sigmatel_spec *spec = codec->spec;
3165 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3167 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3169 num_cons = snd_hda_get_connections(codec,
3172 HDA_MAX_NUM_INPUTS);
3173 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3176 for (i = 0; i < num_cons; i++) {
3177 mono_mux->items[mono_mux->num_items].label =
3178 stac92xx_mono_labels[i];
3179 mono_mux->items[mono_mux->num_items].index = i;
3180 mono_mux->num_items++;
3183 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3184 "Mono Mux", spec->mono_nid);
3187 /* labels for amp mux outputs */
3188 static const char *stac92xx_amp_labels[3] = {
3189 "Front Microphone", "Microphone", "Line In",
3192 /* create amp out controls mux on capable codecs */
3193 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3195 struct sigmatel_spec *spec = codec->spec;
3196 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3199 for (i = 0; i < spec->num_amps; i++) {
3200 amp_mux->items[amp_mux->num_items].label =
3201 stac92xx_amp_labels[i];
3202 amp_mux->items[amp_mux->num_items].index = i;
3203 amp_mux->num_items++;
3206 if (spec->num_amps > 1) {
3207 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3208 "Amp Selector Capture Switch", 0);
3212 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3213 "Amp Capture Volume",
3214 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3218 /* create PC beep volume controls */
3219 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3222 struct sigmatel_spec *spec = codec->spec;
3223 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3226 /* check for mute support for the the amp */
3227 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3228 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3229 "PC Beep Playback Switch",
3230 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3235 /* check to see if there is volume support for the amp */
3236 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3237 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3238 "PC Beep Playback Volume",
3239 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3246 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3247 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3249 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3250 struct snd_ctl_elem_value *ucontrol)
3252 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3253 ucontrol->value.integer.value[0] = codec->beep->enabled;
3257 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3258 struct snd_ctl_elem_value *ucontrol)
3260 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3261 int enabled = !!ucontrol->value.integer.value[0];
3262 if (codec->beep->enabled != enabled) {
3263 codec->beep->enabled = enabled;
3269 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3270 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3271 .info = stac92xx_dig_beep_switch_info,
3272 .get = stac92xx_dig_beep_switch_get,
3273 .put = stac92xx_dig_beep_switch_put,
3276 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3278 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3279 0, "PC Beep Playback Switch", 0);
3283 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3285 struct sigmatel_spec *spec = codec->spec;
3286 int wcaps, nid, i, err = 0;
3288 for (i = 0; i < spec->num_muxes; i++) {
3289 nid = spec->mux_nids[i];
3290 wcaps = get_wcaps(codec, nid);
3292 if (wcaps & AC_WCAP_OUT_AMP) {
3293 err = stac92xx_add_control_idx(spec,
3294 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3295 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3303 static const char *stac92xx_spdif_labels[3] = {
3304 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3307 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3309 struct sigmatel_spec *spec = codec->spec;
3310 struct hda_input_mux *spdif_mux = &spec->private_smux;
3311 const char **labels = spec->spdif_labels;
3313 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3315 num_cons = snd_hda_get_connections(codec,
3318 HDA_MAX_NUM_INPUTS);
3323 labels = stac92xx_spdif_labels;
3325 for (i = 0; i < num_cons; i++) {
3326 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3327 spdif_mux->items[spdif_mux->num_items].index = i;
3328 spdif_mux->num_items++;
3334 /* labels for dmic mux inputs */
3335 static const char *stac92xx_dmic_labels[5] = {
3336 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3337 "Digital Mic 3", "Digital Mic 4"
3340 /* create playback/capture controls for input pins on dmic capable codecs */
3341 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3342 const struct auto_pin_cfg *cfg)
3344 struct sigmatel_spec *spec = codec->spec;
3345 struct hda_input_mux *dimux = &spec->private_dimux;
3346 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3350 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3351 dimux->items[dimux->num_items].index = 0;
3354 for (i = 0; i < spec->num_dmics; i++) {
3359 unsigned int def_conf;
3361 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3362 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3365 nid = spec->dmic_nids[i];
3366 num_cons = snd_hda_get_connections(codec,
3369 HDA_MAX_NUM_INPUTS);
3370 for (j = 0; j < num_cons; j++)
3371 if (con_lst[j] == nid) {
3377 wcaps = get_wcaps(codec, nid) &
3378 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3381 sprintf(name, "%s Capture Volume",
3382 stac92xx_dmic_labels[dimux->num_items]);
3384 err = stac92xx_add_control(spec,
3385 STAC_CTL_WIDGET_VOL,
3387 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3388 (wcaps & AC_WCAP_OUT_AMP) ?
3389 HDA_OUTPUT : HDA_INPUT));
3394 dimux->items[dimux->num_items].label =
3395 stac92xx_dmic_labels[dimux->num_items];
3396 dimux->items[dimux->num_items].index = index;
3403 /* create playback/capture controls for input pins */
3404 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3406 struct sigmatel_spec *spec = codec->spec;
3407 struct hda_input_mux *imux = &spec->private_imux;
3408 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3411 for (i = 0; i < AUTO_PIN_LAST; i++) {
3414 if (!cfg->input_pins[i])
3417 for (j = 0; j < spec->num_muxes; j++) {
3419 num_cons = snd_hda_get_connections(codec,
3422 HDA_MAX_NUM_INPUTS);
3423 for (k = 0; k < num_cons; k++)
3424 if (con_lst[k] == cfg->input_pins[i]) {
3431 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3432 imux->items[imux->num_items].index = index;
3436 if (imux->num_items) {
3438 * Set the current input for the muxes.
3439 * The STAC9221 has two input muxes with identical source
3440 * NID lists. Hopefully this won't get confused.
3442 for (i = 0; i < spec->num_muxes; i++) {
3443 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3444 AC_VERB_SET_CONNECT_SEL,
3445 imux->items[0].index);
3452 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3454 struct sigmatel_spec *spec = codec->spec;
3457 for (i = 0; i < spec->autocfg.line_outs; i++) {
3458 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3459 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3463 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3465 struct sigmatel_spec *spec = codec->spec;
3468 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3470 pin = spec->autocfg.hp_pins[i];
3471 if (pin) /* connect to front */
3472 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3474 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3476 pin = spec->autocfg.speaker_pins[i];
3477 if (pin) /* connect to front */
3478 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3482 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3484 struct sigmatel_spec *spec = codec->spec;
3487 if ((err = snd_hda_parse_pin_def_config(codec,
3489 spec->dmic_nids)) < 0)
3491 if (! spec->autocfg.line_outs)
3492 return 0; /* can't find valid pin config */
3494 /* If we have no real line-out pin and multiple hp-outs, HPs should
3495 * be set up as multi-channel outputs.
3497 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3498 spec->autocfg.hp_outs > 1) {
3499 /* Copy hp_outs to line_outs, backup line_outs in
3500 * speaker_outs so that the following routines can handle
3501 * HP pins as primary outputs.
3503 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3504 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3505 sizeof(spec->autocfg.line_out_pins));
3506 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3507 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3508 sizeof(spec->autocfg.hp_pins));
3509 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3510 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3511 spec->autocfg.hp_outs = 0;
3513 if (spec->autocfg.mono_out_pin) {
3514 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3515 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3516 u32 caps = query_amp_caps(codec,
3517 spec->autocfg.mono_out_pin, dir);
3518 hda_nid_t conn_list[1];
3520 /* get the mixer node and then the mono mux if it exists */
3521 if (snd_hda_get_connections(codec,
3522 spec->autocfg.mono_out_pin, conn_list, 1) &&
3523 snd_hda_get_connections(codec, conn_list[0],
3526 int wcaps = get_wcaps(codec, conn_list[0]);
3527 int wid_type = (wcaps & AC_WCAP_TYPE)
3528 >> AC_WCAP_TYPE_SHIFT;
3529 /* LR swap check, some stac925x have a mux that
3530 * changes the DACs output path instead of the
3533 if (wid_type == AC_WID_AUD_SEL &&
3534 !(wcaps & AC_WCAP_LR_SWAP))
3535 spec->mono_nid = conn_list[0];
3538 hda_nid_t nid = spec->autocfg.mono_out_pin;
3540 /* most mono outs have a least a mute/unmute switch */
3541 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3542 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3543 "Mono Playback Switch",
3544 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3547 /* check for volume support for the amp */
3548 if ((caps & AC_AMPCAP_NUM_STEPS)
3549 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3550 err = stac92xx_add_control(spec,
3551 STAC_CTL_WIDGET_VOL,
3552 "Mono Playback Volume",
3553 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3559 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3563 if (!spec->multiout.num_dacs) {
3564 err = stac92xx_auto_fill_dac_nids(codec);
3567 err = stac92xx_auto_create_multi_out_ctls(codec,
3573 /* setup analog beep controls */
3574 if (spec->anabeep_nid > 0) {
3575 err = stac92xx_auto_create_beep_ctls(codec,
3581 /* setup digital beep controls and input device */
3582 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3583 if (spec->digbeep_nid > 0) {
3584 hda_nid_t nid = spec->digbeep_nid;
3587 err = stac92xx_auto_create_beep_ctls(codec, nid);
3590 err = snd_hda_attach_beep_device(codec, nid);
3593 /* if no beep switch is available, make its own one */
3594 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3596 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3597 err = stac92xx_beep_switch_ctl(codec);
3604 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3609 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3614 if (spec->mono_nid > 0) {
3615 err = stac92xx_auto_create_mono_output_ctls(codec);
3619 if (spec->num_amps > 0) {
3620 err = stac92xx_auto_create_amp_output_ctls(codec);
3624 if (spec->num_dmics > 0 && !spec->dinput_mux)
3625 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3626 &spec->autocfg)) < 0)
3628 if (spec->num_muxes > 0) {
3629 err = stac92xx_auto_create_mux_input_ctls(codec);
3633 if (spec->num_smuxes > 0) {
3634 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3639 err = stac92xx_add_input_source(spec);
3643 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3644 if (spec->multiout.max_channels > 2)
3645 spec->surr_switch = 1;
3647 if (spec->autocfg.dig_outs)
3648 spec->multiout.dig_out_nid = dig_out;
3649 if (dig_in && spec->autocfg.dig_in_pin)
3650 spec->dig_in_nid = dig_in;
3652 if (spec->kctls.list)
3653 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3655 spec->input_mux = &spec->private_imux;
3656 if (!spec->dinput_mux)
3657 spec->dinput_mux = &spec->private_dimux;
3658 spec->sinput_mux = &spec->private_smux;
3659 spec->mono_mux = &spec->private_mono_mux;
3660 spec->amp_mux = &spec->private_amp_mux;
3664 /* add playback controls for HP output */
3665 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3666 struct auto_pin_cfg *cfg)
3668 struct sigmatel_spec *spec = codec->spec;
3669 hda_nid_t pin = cfg->hp_pins[0];
3670 unsigned int wid_caps;
3675 wid_caps = get_wcaps(codec, pin);
3676 if (wid_caps & AC_WCAP_UNSOL_CAP)
3677 spec->hp_detect = 1;
3682 /* add playback controls for LFE output */
3683 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3684 struct auto_pin_cfg *cfg)
3686 struct sigmatel_spec *spec = codec->spec;
3688 hda_nid_t lfe_pin = 0x0;
3692 * search speaker outs and line outs for a mono speaker pin
3693 * with an amp. If one is found, add LFE controls
3696 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3697 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3698 unsigned int wcaps = get_wcaps(codec, pin);
3699 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3700 if (wcaps == AC_WCAP_OUT_AMP)
3701 /* found a mono speaker with an amp, must be lfe */
3705 /* if speaker_outs is 0, then speakers may be in line_outs */
3706 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3707 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3708 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3709 unsigned int defcfg;
3710 defcfg = snd_hda_codec_get_pincfg(codec, pin);
3711 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3712 unsigned int wcaps = get_wcaps(codec, pin);
3713 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3714 if (wcaps == AC_WCAP_OUT_AMP)
3715 /* found a mono speaker with an amp,
3723 err = create_controls(codec, "LFE", lfe_pin, 1);
3731 static int stac9200_parse_auto_config(struct hda_codec *codec)
3733 struct sigmatel_spec *spec = codec->spec;
3736 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3739 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3742 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3745 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3748 if (spec->num_muxes > 0) {
3749 err = stac92xx_auto_create_mux_input_ctls(codec);
3754 err = stac92xx_add_input_source(spec);
3758 if (spec->autocfg.dig_outs)
3759 spec->multiout.dig_out_nid = 0x05;
3760 if (spec->autocfg.dig_in_pin)
3761 spec->dig_in_nid = 0x04;
3763 if (spec->kctls.list)
3764 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3766 spec->input_mux = &spec->private_imux;
3767 spec->dinput_mux = &spec->private_dimux;
3773 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3774 * funky external mute control using GPIO pins.
3777 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3778 unsigned int dir_mask, unsigned int data)
3780 unsigned int gpiostate, gpiomask, gpiodir;
3782 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3783 AC_VERB_GET_GPIO_DATA, 0);
3784 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3786 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3787 AC_VERB_GET_GPIO_MASK, 0);
3790 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3791 AC_VERB_GET_GPIO_DIRECTION, 0);
3792 gpiodir |= dir_mask;
3794 /* Configure GPIOx as CMOS */
3795 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3797 snd_hda_codec_write(codec, codec->afg, 0,
3798 AC_VERB_SET_GPIO_MASK, gpiomask);
3799 snd_hda_codec_read(codec, codec->afg, 0,
3800 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3804 snd_hda_codec_read(codec, codec->afg, 0,
3805 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3808 static int stac92xx_add_jack(struct hda_codec *codec,
3809 hda_nid_t nid, int type)
3811 #ifdef CONFIG_SND_JACK
3812 struct sigmatel_spec *spec = codec->spec;
3813 struct sigmatel_jack *jack;
3814 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
3815 int connectivity = get_defcfg_connect(def_conf);
3818 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3821 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3822 jack = snd_array_new(&spec->jacks);
3828 sprintf(name, "%s at %s %s Jack",
3829 snd_hda_get_jack_type(def_conf),
3830 snd_hda_get_jack_connectivity(def_conf),
3831 snd_hda_get_jack_location(def_conf));
3833 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
3839 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3840 unsigned char type, int data)
3842 struct sigmatel_event *event;
3844 snd_array_init(&spec->events, sizeof(*event), 32);
3845 event = snd_array_new(&spec->events);
3850 event->tag = spec->events.used;
3856 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3857 hda_nid_t nid, unsigned char type)
3859 struct sigmatel_spec *spec = codec->spec;
3860 struct sigmatel_event *event = spec->events.list;
3863 for (i = 0; i < spec->events.used; i++, event++) {
3864 if (event->nid == nid && event->type == type)
3870 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3873 struct sigmatel_spec *spec = codec->spec;
3874 struct sigmatel_event *event = spec->events.list;
3877 for (i = 0; i < spec->events.used; i++, event++) {
3878 if (event->tag == tag)
3884 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3887 struct sigmatel_event *event;
3890 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3892 event = stac_get_event(codec, nid, type);
3896 tag = stac_add_event(codec->spec, nid, type, 0);
3899 snd_hda_codec_write_cache(codec, nid, 0,
3900 AC_VERB_SET_UNSOLICITED_ENABLE,
3904 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3907 for (i = 0; i < cfg->hp_outs; i++)
3908 if (cfg->hp_pins[i] == nid)
3909 return 1; /* nid is a HP-Out */
3911 return 0; /* nid is not a HP-Out */
3914 static void stac92xx_power_down(struct hda_codec *codec)
3916 struct sigmatel_spec *spec = codec->spec;
3918 /* power down inactive DACs */
3920 for (dac = spec->dac_list; *dac; dac++)
3921 if (!check_all_dac_nids(spec, *dac))
3922 snd_hda_codec_write(codec, *dac, 0,
3923 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3926 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3929 static int stac92xx_init(struct hda_codec *codec)
3931 struct sigmatel_spec *spec = codec->spec;
3932 struct auto_pin_cfg *cfg = &spec->autocfg;
3936 snd_hda_sequence_write(codec, spec->init);
3938 /* power down adcs initially */
3939 if (spec->powerdown_adcs)
3940 for (i = 0; i < spec->num_adcs; i++)
3941 snd_hda_codec_write(codec,
3942 spec->adc_nids[i], 0,
3943 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3946 gpio = spec->gpio_data;
3947 /* turn on EAPD statically when spec->eapd_switch isn't set.
3948 * otherwise, unsol event will turn it on/off dynamically
3950 if (!spec->eapd_switch)
3951 gpio |= spec->eapd_mask;
3952 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3955 if (spec->hp_detect) {
3956 /* Enable unsolicited responses on the HP widget */
3957 for (i = 0; i < cfg->hp_outs; i++) {
3958 hda_nid_t nid = cfg->hp_pins[i];
3959 enable_pin_detect(codec, nid, STAC_HP_EVENT);
3961 /* force to enable the first line-out; the others are set up
3964 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3966 /* fake event to set up pins */
3967 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
3970 stac92xx_auto_init_multi_out(codec);
3971 stac92xx_auto_init_hp_out(codec);
3972 for (i = 0; i < cfg->hp_outs; i++)
3973 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
3975 for (i = 0; i < AUTO_PIN_LAST; i++) {
3976 hda_nid_t nid = cfg->input_pins[i];
3978 unsigned int pinctl, conf;
3979 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3980 /* for mic pins, force to initialize */
3981 pinctl = stac92xx_get_vref(codec, nid);
3982 pinctl |= AC_PINCTL_IN_EN;
3983 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3985 pinctl = snd_hda_codec_read(codec, nid, 0,
3986 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3987 /* if PINCTL already set then skip */
3988 if (!(pinctl & AC_PINCTL_IN_EN)) {
3989 pinctl |= AC_PINCTL_IN_EN;
3990 stac92xx_auto_set_pinctl(codec, nid,
3994 conf = snd_hda_codec_get_pincfg(codec, nid);
3995 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
3996 enable_pin_detect(codec, nid,
3998 stac_issue_unsol_event(codec, nid,
4003 for (i = 0; i < spec->num_dmics; i++)
4004 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4006 if (cfg->dig_out_pins[0])
4007 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4009 if (cfg->dig_in_pin)
4010 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4012 for (i = 0; i < spec->num_pwrs; i++) {
4013 hda_nid_t nid = spec->pwr_nids[i];
4014 int pinctl, def_conf;
4016 /* power on when no jack detection is available */
4017 if (!spec->hp_detect) {
4018 stac_toggle_power_map(codec, nid, 1);
4022 if (is_nid_hp_pin(cfg, nid))
4023 continue; /* already has an unsol event */
4025 pinctl = snd_hda_codec_read(codec, nid, 0,
4026 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4027 /* outputs are only ports capable of power management
4028 * any attempts on powering down a input port cause the
4029 * referenced VREF to act quirky.
4031 if (pinctl & AC_PINCTL_IN_EN) {
4032 stac_toggle_power_map(codec, nid, 1);
4035 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4036 def_conf = get_defcfg_connect(def_conf);
4037 /* skip any ports that don't have jacks since presence
4038 * detection is useless */
4039 if (def_conf != AC_JACK_PORT_COMPLEX) {
4040 if (def_conf != AC_JACK_PORT_NONE)
4041 stac_toggle_power_map(codec, nid, 1);
4044 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4045 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4046 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4050 stac92xx_power_down(codec);
4054 static void stac92xx_free_jacks(struct hda_codec *codec)
4056 #ifdef CONFIG_SND_JACK
4057 /* free jack instances manually when clearing/reconfiguring */
4058 struct sigmatel_spec *spec = codec->spec;
4059 if (!codec->bus->shutdown && spec->jacks.list) {
4060 struct sigmatel_jack *jacks = spec->jacks.list;
4062 for (i = 0; i < spec->jacks.used; i++)
4063 snd_device_free(codec->bus->card, &jacks[i].jack);
4065 snd_array_free(&spec->jacks);
4069 static void stac92xx_free_kctls(struct hda_codec *codec)
4071 struct sigmatel_spec *spec = codec->spec;
4073 if (spec->kctls.list) {
4074 struct snd_kcontrol_new *kctl = spec->kctls.list;
4076 for (i = 0; i < spec->kctls.used; i++)
4077 kfree(kctl[i].name);
4079 snd_array_free(&spec->kctls);
4082 static void stac92xx_free(struct hda_codec *codec)
4084 struct sigmatel_spec *spec = codec->spec;
4089 stac92xx_free_jacks(codec);
4090 snd_array_free(&spec->events);
4093 snd_hda_detach_beep_device(codec);
4096 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4099 unsigned int old_ctl, pin_ctl;
4101 pin_ctl = snd_hda_codec_read(codec, nid,
4102 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4104 if (pin_ctl & AC_PINCTL_IN_EN) {
4106 * we need to check the current set-up direction of
4107 * shared input pins since they can be switched via
4108 * "xxx as Output" mixer switch
4110 struct sigmatel_spec *spec = codec->spec;
4111 if (nid == spec->line_switch || nid == spec->mic_switch)
4116 /* if setting pin direction bits, clear the current
4117 direction bits first */
4118 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4119 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4122 if (old_ctl != pin_ctl)
4123 snd_hda_codec_write_cache(codec, nid, 0,
4124 AC_VERB_SET_PIN_WIDGET_CONTROL,
4128 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4131 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4132 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4134 snd_hda_codec_write_cache(codec, nid, 0,
4135 AC_VERB_SET_PIN_WIDGET_CONTROL,
4139 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4143 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
4149 /* return non-zero if the hp-pin of the given array index isn't
4150 * a jack-detection target
4152 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4154 struct auto_pin_cfg *cfg = &spec->autocfg;
4156 /* ignore sensing of shared line and mic jacks */
4157 if (cfg->hp_pins[i] == spec->line_switch)
4159 if (cfg->hp_pins[i] == spec->mic_switch)
4161 /* ignore if the pin is set as line-out */
4162 if (cfg->hp_pins[i] == spec->hp_switch)
4167 static void stac92xx_hp_detect(struct hda_codec *codec)
4169 struct sigmatel_spec *spec = codec->spec;
4170 struct auto_pin_cfg *cfg = &spec->autocfg;
4174 if (spec->gpio_mute)
4175 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4176 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4178 for (i = 0; i < cfg->hp_outs; i++) {
4181 if (no_hp_sensing(spec, i))
4183 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4185 unsigned int pinctl;
4186 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4187 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4188 if (pinctl & AC_PINCTL_IN_EN)
4189 presence = 0; /* mic- or line-input */
4194 /* disable lineouts */
4195 if (spec->hp_switch)
4196 stac92xx_reset_pinctl(codec, spec->hp_switch,
4198 for (i = 0; i < cfg->line_outs; i++)
4199 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4201 for (i = 0; i < cfg->speaker_outs; i++)
4202 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4204 if (spec->eapd_mask && spec->eapd_switch)
4205 stac_gpio_set(codec, spec->gpio_mask,
4206 spec->gpio_dir, spec->gpio_data &
4209 /* enable lineouts */
4210 if (spec->hp_switch)
4211 stac92xx_set_pinctl(codec, spec->hp_switch,
4213 for (i = 0; i < cfg->line_outs; i++)
4214 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4216 for (i = 0; i < cfg->speaker_outs; i++)
4217 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4219 if (spec->eapd_mask && spec->eapd_switch)
4220 stac_gpio_set(codec, spec->gpio_mask,
4221 spec->gpio_dir, spec->gpio_data |
4224 /* toggle hp outs */
4225 for (i = 0; i < cfg->hp_outs; i++) {
4226 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4227 if (no_hp_sensing(spec, i))
4230 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4232 /* Resetting the pinctl like below may lead to (a sort of) regressions
4233 * on some devices since they use the HP pin actually for line/speaker
4234 * outs although the default pin config shows a different pin (that is
4235 * wrong and useless).
4237 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4238 * But, disabling the code below just works around it, and I'm too tired of
4239 * bug reports with such devices...
4242 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4247 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4250 struct sigmatel_spec *spec = codec->spec;
4251 unsigned int idx, val;
4253 for (idx = 0; idx < spec->num_pwrs; idx++) {
4254 if (spec->pwr_nids[idx] == nid)
4257 if (idx >= spec->num_pwrs)
4260 /* several codecs have two power down bits */
4261 if (spec->pwr_mapping)
4262 idx = spec->pwr_mapping[idx];
4266 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4272 /* power down unused output ports */
4273 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4276 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4278 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4281 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4283 struct sigmatel_spec *spec = codec->spec;
4284 struct sigmatel_jack *jacks = spec->jacks.list;
4288 for (i = 0; i < spec->jacks.used; i++) {
4289 if (jacks->nid == nid) {
4290 unsigned int pin_ctl =
4291 snd_hda_codec_read(codec, nid,
4292 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4294 int type = jacks->type;
4295 if (type == (SND_JACK_LINEOUT
4296 | SND_JACK_HEADPHONE))
4297 type = (pin_ctl & AC_PINCTL_HP_EN)
4298 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4299 snd_jack_report(jacks->jack,
4300 get_pin_presence(codec, nid)
4308 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4311 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4314 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4317 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4319 struct sigmatel_spec *spec = codec->spec;
4320 struct sigmatel_event *event;
4323 tag = (res >> 26) & 0x7f;
4324 event = stac_get_event_from_tag(codec, tag);
4328 switch (event->type) {
4330 stac92xx_hp_detect(codec);
4332 case STAC_INSERT_EVENT:
4333 case STAC_PWR_EVENT:
4334 if (spec->num_pwrs > 0)
4335 stac92xx_pin_sense(codec, event->nid);
4336 stac92xx_report_jack(codec, event->nid);
4338 case STAC_VREF_EVENT:
4339 data = snd_hda_codec_read(codec, codec->afg, 0,
4340 AC_VERB_GET_GPIO_DATA, 0);
4341 /* toggle VREF state based on GPIOx status */
4342 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4343 !!(data & (1 << event->data)));
4348 #ifdef CONFIG_PROC_FS
4349 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4350 struct hda_codec *codec, hda_nid_t nid)
4352 if (nid == codec->afg)
4353 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4354 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4357 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4358 struct hda_codec *codec,
4361 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4362 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4365 /* stac92hd71bxx, stac92hd73xx */
4366 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4367 struct hda_codec *codec, hda_nid_t nid)
4369 stac92hd_proc_hook(buffer, codec, nid);
4370 if (nid == codec->afg)
4371 analog_loop_proc_hook(buffer, codec, 0xfa0);
4374 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4375 struct hda_codec *codec, hda_nid_t nid)
4377 if (nid == codec->afg)
4378 analog_loop_proc_hook(buffer, codec, 0xfe0);
4381 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4382 struct hda_codec *codec, hda_nid_t nid)
4384 if (nid == codec->afg)
4385 analog_loop_proc_hook(buffer, codec, 0xfeb);
4388 #define stac92hd_proc_hook NULL
4389 #define stac92hd7x_proc_hook NULL
4390 #define stac9205_proc_hook NULL
4391 #define stac927x_proc_hook NULL
4394 #ifdef SND_HDA_NEEDS_RESUME
4395 static int stac92xx_resume(struct hda_codec *codec)
4397 struct sigmatel_spec *spec = codec->spec;
4399 stac92xx_init(codec);
4400 snd_hda_codec_resume_amp(codec);
4401 snd_hda_codec_resume_cache(codec);
4402 /* fake event to set up pins again to override cached values */
4403 if (spec->hp_detect)
4404 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4409 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4411 struct sigmatel_spec *spec = codec->spec;
4412 if (spec->eapd_mask)
4413 stac_gpio_set(codec, spec->gpio_mask,
4414 spec->gpio_dir, spec->gpio_data &
4420 static struct hda_codec_ops stac92xx_patch_ops = {
4421 .build_controls = stac92xx_build_controls,
4422 .build_pcms = stac92xx_build_pcms,
4423 .init = stac92xx_init,
4424 .free = stac92xx_free,
4425 .unsol_event = stac92xx_unsol_event,
4426 #ifdef SND_HDA_NEEDS_RESUME
4427 .suspend = stac92xx_suspend,
4428 .resume = stac92xx_resume,
4432 static int patch_stac9200(struct hda_codec *codec)
4434 struct sigmatel_spec *spec;
4437 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4442 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4443 spec->pin_nids = stac9200_pin_nids;
4444 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4447 if (spec->board_config < 0)
4448 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4450 stac92xx_set_config_regs(codec,
4451 stac9200_brd_tbl[spec->board_config]);
4453 spec->multiout.max_channels = 2;
4454 spec->multiout.num_dacs = 1;
4455 spec->multiout.dac_nids = stac9200_dac_nids;
4456 spec->adc_nids = stac9200_adc_nids;
4457 spec->mux_nids = stac9200_mux_nids;
4458 spec->num_muxes = 1;
4459 spec->num_dmics = 0;
4463 if (spec->board_config == STAC_9200_M4 ||
4464 spec->board_config == STAC_9200_M4_2 ||
4465 spec->board_config == STAC_9200_OQO)
4466 spec->init = stac9200_eapd_init;
4468 spec->init = stac9200_core_init;
4469 spec->mixer = stac9200_mixer;
4471 if (spec->board_config == STAC_9200_PANASONIC) {
4472 spec->gpio_mask = spec->gpio_dir = 0x09;
4473 spec->gpio_data = 0x00;
4476 err = stac9200_parse_auto_config(codec);
4478 stac92xx_free(codec);
4482 /* CF-74 has no headphone detection, and the driver should *NOT*
4483 * do detection and HP/speaker toggle because the hardware does it.
4485 if (spec->board_config == STAC_9200_PANASONIC)
4486 spec->hp_detect = 0;
4488 codec->patch_ops = stac92xx_patch_ops;
4493 static int patch_stac925x(struct hda_codec *codec)
4495 struct sigmatel_spec *spec;
4498 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4503 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4504 spec->pin_nids = stac925x_pin_nids;
4506 /* Check first for codec ID */
4507 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4510 stac925x_codec_id_cfg_tbl);
4512 /* Now checks for PCI ID, if codec ID is not found */
4513 if (spec->board_config < 0)
4514 spec->board_config = snd_hda_check_board_config(codec,
4519 if (spec->board_config < 0)
4520 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4521 "using BIOS defaults\n");
4523 stac92xx_set_config_regs(codec,
4524 stac925x_brd_tbl[spec->board_config]);
4526 spec->multiout.max_channels = 2;
4527 spec->multiout.num_dacs = 1;
4528 spec->multiout.dac_nids = stac925x_dac_nids;
4529 spec->adc_nids = stac925x_adc_nids;
4530 spec->mux_nids = stac925x_mux_nids;
4531 spec->num_muxes = 1;
4534 switch (codec->vendor_id) {
4535 case 0x83847632: /* STAC9202 */
4536 case 0x83847633: /* STAC9202D */
4537 case 0x83847636: /* STAC9251 */
4538 case 0x83847637: /* STAC9251D */
4539 spec->num_dmics = STAC925X_NUM_DMICS;
4540 spec->dmic_nids = stac925x_dmic_nids;
4541 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4542 spec->dmux_nids = stac925x_dmux_nids;
4545 spec->num_dmics = 0;
4549 spec->init = stac925x_core_init;
4550 spec->mixer = stac925x_mixer;
4552 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4554 if (spec->board_config < 0) {
4555 printk(KERN_WARNING "hda_codec: No auto-config is "
4556 "available, default to model=ref\n");
4557 spec->board_config = STAC_925x_REF;
4563 stac92xx_free(codec);
4567 codec->patch_ops = stac92xx_patch_ops;
4572 static struct hda_input_mux stac92hd73xx_dmux = {
4575 { "Analog Inputs", 0x0b },
4576 { "Digital Mic 1", 0x09 },
4577 { "Digital Mic 2", 0x0a },
4582 static int patch_stac92hd73xx(struct hda_codec *codec)
4584 struct sigmatel_spec *spec;
4585 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4589 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4594 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4595 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4596 spec->pin_nids = stac92hd73xx_pin_nids;
4597 spec->board_config = snd_hda_check_board_config(codec,
4598 STAC_92HD73XX_MODELS,
4599 stac92hd73xx_models,
4600 stac92hd73xx_cfg_tbl);
4602 if (spec->board_config < 0)
4603 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4604 " STAC92HD73XX, using BIOS defaults\n");
4606 stac92xx_set_config_regs(codec,
4607 stac92hd73xx_brd_tbl[spec->board_config]);
4609 num_dacs = snd_hda_get_connections(codec, 0x0a,
4610 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4612 if (num_dacs < 3 || num_dacs > 5) {
4613 printk(KERN_WARNING "hda_codec: Could not determine "
4614 "number of channels defaulting to DAC count\n");
4615 num_dacs = STAC92HD73_DAC_COUNT;
4618 case 0x3: /* 6 Channel */
4619 spec->mixer = stac92hd73xx_6ch_mixer;
4620 spec->init = stac92hd73xx_6ch_core_init;
4622 case 0x4: /* 8 Channel */
4623 spec->mixer = stac92hd73xx_8ch_mixer;
4624 spec->init = stac92hd73xx_8ch_core_init;
4626 case 0x5: /* 10 Channel */
4627 spec->mixer = stac92hd73xx_10ch_mixer;
4628 spec->init = stac92hd73xx_10ch_core_init;
4630 spec->multiout.dac_nids = spec->dac_nids;
4632 spec->aloopback_mask = 0x01;
4633 spec->aloopback_shift = 8;
4635 spec->digbeep_nid = 0x1c;
4636 spec->mux_nids = stac92hd73xx_mux_nids;
4637 spec->adc_nids = stac92hd73xx_adc_nids;
4638 spec->dmic_nids = stac92hd73xx_dmic_nids;
4639 spec->dmux_nids = stac92hd73xx_dmux_nids;
4640 spec->smux_nids = stac92hd73xx_smux_nids;
4641 spec->amp_nids = stac92hd73xx_amp_nids;
4642 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4644 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4645 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4646 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4647 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4648 sizeof(stac92hd73xx_dmux));
4650 switch (spec->board_config) {
4652 spec->init = dell_eq_core_init;
4654 case STAC_DELL_M6_AMIC:
4655 case STAC_DELL_M6_DMIC:
4656 case STAC_DELL_M6_BOTH:
4657 spec->num_smuxes = 0;
4658 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4659 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4660 spec->eapd_switch = 0;
4663 if (spec->board_config != STAC_DELL_EQ)
4664 spec->init = dell_m6_core_init;
4665 switch (spec->board_config) {
4666 case STAC_DELL_M6_AMIC: /* Analog Mics */
4667 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4668 spec->num_dmics = 0;
4669 spec->private_dimux.num_items = 1;
4671 case STAC_DELL_M6_DMIC: /* Digital Mics */
4672 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
4673 spec->num_dmics = 1;
4674 spec->private_dimux.num_items = 2;
4676 case STAC_DELL_M6_BOTH: /* Both */
4677 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4678 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
4679 spec->num_dmics = 1;
4680 spec->private_dimux.num_items = 2;
4685 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4686 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4687 spec->eapd_switch = 1;
4689 if (spec->board_config > STAC_92HD73XX_REF) {
4690 /* GPIO0 High = Enable EAPD */
4691 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4692 spec->gpio_data = 0x01;
4694 spec->dinput_mux = &spec->private_dimux;
4696 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4697 spec->pwr_nids = stac92hd73xx_pwr_nids;
4699 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
4702 if (spec->board_config < 0) {
4703 printk(KERN_WARNING "hda_codec: No auto-config is "
4704 "available, default to model=ref\n");
4705 spec->board_config = STAC_92HD73XX_REF;
4712 stac92xx_free(codec);
4716 if (spec->board_config == STAC_92HD73XX_NO_JD)
4717 spec->hp_detect = 0;
4719 codec->patch_ops = stac92xx_patch_ops;
4721 codec->proc_widget_hook = stac92hd7x_proc_hook;
4726 static struct hda_input_mux stac92hd83xxx_dmux = {
4729 { "Analog Inputs", 0x03 },
4730 { "Digital Mic 1", 0x04 },
4731 { "Digital Mic 2", 0x05 },
4735 static int patch_stac92hd83xxx(struct hda_codec *codec)
4737 struct sigmatel_spec *spec;
4738 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
4743 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4748 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
4749 spec->mono_nid = 0x19;
4750 spec->digbeep_nid = 0x21;
4751 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4752 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4753 spec->adc_nids = stac92hd83xxx_adc_nids;
4754 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4755 spec->amp_nids = stac92hd83xxx_amp_nids;
4756 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4757 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4758 spec->multiout.dac_nids = spec->dac_nids;
4760 spec->init = stac92hd83xxx_core_init;
4761 spec->mixer = stac92hd83xxx_mixer;
4762 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4763 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4764 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4765 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
4766 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4767 spec->dinput_mux = &stac92hd83xxx_dmux;
4768 spec->pin_nids = stac92hd83xxx_pin_nids;
4769 spec->board_config = snd_hda_check_board_config(codec,
4770 STAC_92HD83XXX_MODELS,
4771 stac92hd83xxx_models,
4772 stac92hd83xxx_cfg_tbl);
4774 if (spec->board_config < 0)
4775 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4776 " STAC92HD83XXX, using BIOS defaults\n");
4778 stac92xx_set_config_regs(codec,
4779 stac92hd83xxx_brd_tbl[spec->board_config]);
4781 switch (codec->vendor_id) {
4784 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
4790 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4792 if (spec->board_config < 0) {
4793 printk(KERN_WARNING "hda_codec: No auto-config is "
4794 "available, default to model=ref\n");
4795 spec->board_config = STAC_92HD83XXX_REF;
4802 stac92xx_free(codec);
4806 switch (spec->board_config) {
4815 num_dacs = snd_hda_get_connections(codec, nid,
4816 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4818 /* set port X to select the last DAC
4820 snd_hda_codec_write_cache(codec, nid, 0,
4821 AC_VERB_SET_CONNECT_SEL, num_dacs);
4823 codec->patch_ops = stac92xx_patch_ops;
4825 codec->proc_widget_hook = stac92hd_proc_hook;
4830 static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
4833 { "Analog Inputs", 0x00 },
4834 { "Digital Mic 1", 0x02 },
4835 { "Digital Mic 2", 0x03 },
4839 static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
4842 { "Analog Inputs", 0x00 },
4844 { "Digital Mic 1", 0x02 },
4845 { "Digital Mic 2", 0x03 },
4849 /* get the pin connection (fixed, none, etc) */
4850 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4852 struct sigmatel_spec *spec = codec->spec;
4855 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4856 return get_defcfg_connect(cfg);
4859 static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
4860 hda_nid_t *nids, int num_nids)
4862 struct sigmatel_spec *spec = codec->spec;
4864 unsigned int def_conf;
4866 for (num = 0; num < num_nids; num++) {
4867 for (idx = 0; idx < spec->num_pins; idx++)
4868 if (spec->pin_nids[idx] == nids[num])
4870 if (idx >= spec->num_pins)
4872 def_conf = stac_get_defcfg_connect(codec, idx);
4873 if (def_conf == AC_JACK_PORT_NONE)
4879 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
4882 struct sigmatel_spec *spec = codec->spec;
4885 for (idx = 0; idx < spec->num_pins; idx++)
4886 if (spec->pin_nids[idx] == dig0pin)
4888 if ((idx + 2) >= spec->num_pins)
4892 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
4895 /* dig0pin + dig2pin case */
4896 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
4898 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
4904 static int patch_stac92hd71bxx(struct hda_codec *codec)
4906 struct sigmatel_spec *spec;
4907 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
4909 unsigned int ndmic_nids = 0;
4911 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4916 codec->patch_ops = stac92xx_patch_ops;
4917 spec->num_pins = STAC92HD71BXX_NUM_PINS;
4918 switch (codec->vendor_id) {
4921 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
4925 /* On 92HD75Bx 0x27 isn't a pin nid */
4929 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
4931 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4932 spec->board_config = snd_hda_check_board_config(codec,
4933 STAC_92HD71BXX_MODELS,
4934 stac92hd71bxx_models,
4935 stac92hd71bxx_cfg_tbl);
4937 if (spec->board_config < 0)
4938 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4939 " STAC92HD71BXX, using BIOS defaults\n");
4941 stac92xx_set_config_regs(codec,
4942 stac92hd71bxx_brd_tbl[spec->board_config]);
4944 if (spec->board_config > STAC_92HD71BXX_REF) {
4946 spec->gpio_mask = 0x01;
4947 spec->gpio_dir = 0x01;
4948 spec->gpio_data = 0x01;
4951 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4952 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4954 switch (codec->vendor_id) {
4955 case 0x111d76b6: /* 4 Port without Analog Mixer */
4959 case 0x111d76b4: /* 6 Port without Analog Mixer */
4961 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
4962 sizeof(stac92hd71bxx_dmux_nomixer));
4963 spec->mixer = stac92hd71bxx_mixer;
4964 spec->init = stac92hd71bxx_core_init;
4965 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4966 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
4967 stac92hd71bxx_dmic_nids,
4968 STAC92HD71BXX_NUM_DMICS);
4969 if (spec->num_dmics) {
4970 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4971 spec->dinput_mux = &spec->private_dimux;
4972 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
4975 case 0x111d7608: /* 5 Port with Analog Mixer */
4976 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
4977 sizeof(stac92hd71bxx_dmux_amixer));
4978 spec->private_dimux.num_items--;
4979 switch (spec->board_config) {
4981 /* Enable VREF power saving on GPIO1 detect */
4982 err = stac_add_event(spec, codec->afg,
4983 STAC_VREF_EVENT, 0x02);
4986 snd_hda_codec_write_cache(codec, codec->afg, 0,
4987 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4988 snd_hda_codec_write_cache(codec, codec->afg, 0,
4989 AC_VERB_SET_UNSOLICITED_ENABLE,
4991 spec->gpio_mask |= 0x02;
4994 if ((codec->revision_id & 0xf) == 0 ||
4995 (codec->revision_id & 0xf) == 1)
4996 spec->stream_delay = 40; /* 40 milliseconds */
4998 /* no output amps */
5000 spec->mixer = stac92hd71bxx_analog_mixer;
5001 spec->dinput_mux = &spec->private_dimux;
5004 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
5006 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5007 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5008 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5009 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5010 stac92hd71bxx_dmic_nids,
5011 STAC92HD71BXX_NUM_DMICS - 1);
5012 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5013 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
5015 case 0x111d7603: /* 6 Port with Analog Mixer */
5016 if ((codec->revision_id & 0xf) == 1)
5017 spec->stream_delay = 40; /* 40 milliseconds */
5019 /* no output amps */
5023 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5024 sizeof(stac92hd71bxx_dmux_amixer));
5025 spec->dinput_mux = &spec->private_dimux;
5026 spec->mixer = stac92hd71bxx_analog_mixer;
5027 spec->init = stac92hd71bxx_analog_core_init;
5028 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5029 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5030 stac92hd71bxx_dmic_nids,
5031 STAC92HD71BXX_NUM_DMICS);
5032 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5033 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5036 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5037 snd_hda_sequence_write_cache(codec, unmute_init);
5039 spec->aloopback_mask = 0x50;
5040 spec->aloopback_shift = 0;
5042 spec->powerdown_adcs = 1;
5043 spec->digbeep_nid = 0x26;
5044 spec->mux_nids = stac92hd71bxx_mux_nids;
5045 spec->adc_nids = stac92hd71bxx_adc_nids;
5046 spec->smux_nids = stac92hd71bxx_smux_nids;
5047 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5049 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5050 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5051 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5053 switch (spec->board_config) {
5055 /* enable internal microphone */
5056 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5057 stac92xx_auto_set_pinctl(codec, 0x0e,
5058 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5060 case STAC_DELL_M4_2:
5061 spec->num_dmics = 0;
5062 spec->num_smuxes = 0;
5063 spec->num_dmuxes = 0;
5065 case STAC_DELL_M4_1:
5066 case STAC_DELL_M4_3:
5067 spec->num_dmics = 1;
5068 spec->num_smuxes = 0;
5069 spec->num_dmuxes = 1;
5072 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5073 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5077 spec->multiout.dac_nids = spec->dac_nids;
5078 if (spec->dinput_mux)
5079 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
5081 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5083 if (spec->board_config < 0) {
5084 printk(KERN_WARNING "hda_codec: No auto-config is "
5085 "available, default to model=ref\n");
5086 spec->board_config = STAC_92HD71BXX_REF;
5093 stac92xx_free(codec);
5097 codec->proc_widget_hook = stac92hd7x_proc_hook;
5102 static int patch_stac922x(struct hda_codec *codec)
5104 struct sigmatel_spec *spec;
5107 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5112 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5113 spec->pin_nids = stac922x_pin_nids;
5114 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5117 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5118 spec->gpio_mask = spec->gpio_dir = 0x03;
5119 spec->gpio_data = 0x03;
5120 /* Intel Macs have all same PCI SSID, so we need to check
5121 * codec SSID to distinguish the exact models
5123 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5124 switch (codec->subsystem_id) {
5127 spec->board_config = STAC_INTEL_MAC_V1;
5131 spec->board_config = STAC_INTEL_MAC_V2;
5139 spec->board_config = STAC_INTEL_MAC_V3;
5143 spec->board_config = STAC_INTEL_MAC_V4;
5147 spec->board_config = STAC_INTEL_MAC_V5;
5150 spec->board_config = STAC_INTEL_MAC_V3;
5156 if (spec->board_config < 0)
5157 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5158 "using BIOS defaults\n");
5160 stac92xx_set_config_regs(codec,
5161 stac922x_brd_tbl[spec->board_config]);
5163 spec->adc_nids = stac922x_adc_nids;
5164 spec->mux_nids = stac922x_mux_nids;
5165 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5166 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5167 spec->num_dmics = 0;
5170 spec->init = stac922x_core_init;
5171 spec->mixer = stac922x_mixer;
5173 spec->multiout.dac_nids = spec->dac_nids;
5175 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5177 if (spec->board_config < 0) {
5178 printk(KERN_WARNING "hda_codec: No auto-config is "
5179 "available, default to model=ref\n");
5180 spec->board_config = STAC_D945_REF;
5186 stac92xx_free(codec);
5190 codec->patch_ops = stac92xx_patch_ops;
5192 /* Fix Mux capture level; max to 2 */
5193 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5194 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5195 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5196 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5197 (0 << AC_AMPCAP_MUTE_SHIFT));
5202 static int patch_stac927x(struct hda_codec *codec)
5204 struct sigmatel_spec *spec;
5207 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5212 codec->slave_dig_outs = stac927x_slave_dig_outs;
5213 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5214 spec->pin_nids = stac927x_pin_nids;
5215 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5219 if (spec->board_config < 0)
5220 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5221 "STAC927x, using BIOS defaults\n");
5223 stac92xx_set_config_regs(codec,
5224 stac927x_brd_tbl[spec->board_config]);
5226 spec->digbeep_nid = 0x23;
5227 spec->adc_nids = stac927x_adc_nids;
5228 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5229 spec->mux_nids = stac927x_mux_nids;
5230 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5231 spec->smux_nids = stac927x_smux_nids;
5232 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5233 spec->spdif_labels = stac927x_spdif_labels;
5234 spec->dac_list = stac927x_dac_nids;
5235 spec->multiout.dac_nids = spec->dac_nids;
5237 switch (spec->board_config) {
5240 /* GPIO0 High = Enable EAPD */
5241 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
5242 spec->gpio_data = 0x01;
5243 spec->num_dmics = 0;
5245 spec->init = d965_core_init;
5246 spec->mixer = stac927x_mixer;
5248 case STAC_DELL_BIOS:
5249 switch (codec->subsystem_id) {
5252 /* correct the device field to SPDIF out */
5253 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5256 /* configure the analog microphone on some laptops */
5257 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5258 /* correct the front output jack as a hp out */
5259 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5260 /* correct the front input jack as a mic */
5261 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5264 /* GPIO2 High = Enable EAPD */
5265 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
5266 spec->gpio_data = 0x04;
5267 spec->dmic_nids = stac927x_dmic_nids;
5268 spec->num_dmics = STAC927X_NUM_DMICS;
5270 spec->init = d965_core_init;
5271 spec->mixer = stac927x_mixer;
5272 spec->dmux_nids = stac927x_dmux_nids;
5273 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5276 if (spec->board_config > STAC_D965_REF) {
5277 /* GPIO0 High = Enable EAPD */
5278 spec->eapd_mask = spec->gpio_mask = 0x01;
5279 spec->gpio_dir = spec->gpio_data = 0x01;
5281 spec->num_dmics = 0;
5283 spec->init = stac927x_core_init;
5284 spec->mixer = stac927x_mixer;
5288 spec->aloopback_mask = 0x40;
5289 spec->aloopback_shift = 0;
5290 spec->eapd_switch = 1;
5292 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
5294 if (spec->board_config < 0) {
5295 printk(KERN_WARNING "hda_codec: No auto-config is "
5296 "available, default to model=ref\n");
5297 spec->board_config = STAC_D965_REF;
5303 stac92xx_free(codec);
5307 codec->patch_ops = stac92xx_patch_ops;
5309 codec->proc_widget_hook = stac927x_proc_hook;
5313 * The STAC927x seem to require fairly long delays for certain
5314 * command sequences. With too short delays (even if the answer
5315 * is set to RIRB properly), it results in the silence output
5316 * on some hardwares like Dell.
5318 * The below flag enables the longer delay (see get_response
5321 codec->bus->needs_damn_long_delay = 1;
5323 /* no jack detecion for ref-no-jd model */
5324 if (spec->board_config == STAC_D965_REF_NO_JD)
5325 spec->hp_detect = 0;
5330 static int patch_stac9205(struct hda_codec *codec)
5332 struct sigmatel_spec *spec;
5335 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5340 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
5341 spec->pin_nids = stac9205_pin_nids;
5342 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5346 if (spec->board_config < 0)
5347 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5349 stac92xx_set_config_regs(codec,
5350 stac9205_brd_tbl[spec->board_config]);
5352 spec->digbeep_nid = 0x23;
5353 spec->adc_nids = stac9205_adc_nids;
5354 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
5355 spec->mux_nids = stac9205_mux_nids;
5356 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
5357 spec->smux_nids = stac9205_smux_nids;
5358 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
5359 spec->dmic_nids = stac9205_dmic_nids;
5360 spec->num_dmics = STAC9205_NUM_DMICS;
5361 spec->dmux_nids = stac9205_dmux_nids;
5362 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
5365 spec->init = stac9205_core_init;
5366 spec->mixer = stac9205_mixer;
5368 spec->aloopback_mask = 0x40;
5369 spec->aloopback_shift = 0;
5370 /* Turn on/off EAPD per HP plugging */
5371 if (spec->board_config != STAC_9205_EAPD)
5372 spec->eapd_switch = 1;
5373 spec->multiout.dac_nids = spec->dac_nids;
5375 switch (spec->board_config){
5376 case STAC_9205_DELL_M43:
5377 /* Enable SPDIF in/out */
5378 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5379 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
5381 /* Enable unsol response for GPIO4/Dock HP connection */
5382 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5385 snd_hda_codec_write_cache(codec, codec->afg, 0,
5386 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5387 snd_hda_codec_write_cache(codec, codec->afg, 0,
5388 AC_VERB_SET_UNSOLICITED_ENABLE,
5391 spec->gpio_dir = 0x0b;
5392 spec->eapd_mask = 0x01;
5393 spec->gpio_mask = 0x1b;
5394 spec->gpio_mute = 0x10;
5395 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5398 spec->gpio_data = 0x01;
5401 /* SPDIF-In enabled */
5404 /* GPIO0 High = EAPD */
5405 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5406 spec->gpio_data = 0x01;
5410 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5412 if (spec->board_config < 0) {
5413 printk(KERN_WARNING "hda_codec: No auto-config is "
5414 "available, default to model=ref\n");
5415 spec->board_config = STAC_9205_REF;
5421 stac92xx_free(codec);
5425 codec->patch_ops = stac92xx_patch_ops;
5427 codec->proc_widget_hook = stac9205_proc_hook;
5436 static struct hda_verb stac9872_core_init[] = {
5437 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5438 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5442 static struct snd_kcontrol_new stac9872_mixer[] = {
5443 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5444 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5448 static hda_nid_t stac9872_pin_nids[] = {
5449 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5453 static hda_nid_t stac9872_adc_nids[] = {
5457 static hda_nid_t stac9872_mux_nids[] = {
5461 static int patch_stac9872(struct hda_codec *codec)
5463 struct sigmatel_spec *spec;
5466 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5471 #if 0 /* no model right now */
5472 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5477 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5478 spec->pin_nids = stac9872_pin_nids;
5479 spec->multiout.dac_nids = spec->dac_nids;
5480 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5481 spec->adc_nids = stac9872_adc_nids;
5482 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5483 spec->mux_nids = stac9872_mux_nids;
5484 spec->mixer = stac9872_mixer;
5485 spec->init = stac9872_core_init;
5487 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5489 stac92xx_free(codec);
5492 spec->input_mux = &spec->private_imux;
5493 codec->patch_ops = stac92xx_patch_ops;
5501 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5502 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5503 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5504 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5505 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5506 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5507 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5508 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5509 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5510 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5511 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5512 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5513 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5514 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5515 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5516 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5517 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5518 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5519 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5520 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5521 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5522 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5523 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5524 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5525 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5526 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5527 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5528 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5529 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5530 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5531 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5532 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5533 /* The following does not take into account .id=0x83847661 when subsys =
5534 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5535 * currently not fully supported.
5537 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5538 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5539 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5540 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5541 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5542 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5543 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5544 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5545 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5546 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5547 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5548 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5549 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5550 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5551 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5552 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5553 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5554 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5555 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5556 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5557 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5558 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5559 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5560 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5561 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5562 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5566 MODULE_ALIAS("snd-hda-codec-id:8384*");
5567 MODULE_ALIAS("snd-hda-codec-id:111d*");
5569 MODULE_LICENSE("GPL");
5570 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5572 static struct hda_codec_preset_list sigmatel_list = {
5573 .preset = snd_hda_preset_sigmatel,
5574 .owner = THIS_MODULE,
5577 static int __init patch_sigmatel_init(void)
5579 return snd_hda_add_codec_preset(&sigmatel_list);
5582 static void __exit patch_sigmatel_exit(void)
5584 snd_hda_delete_codec_preset(&sigmatel_list);
5587 module_init(patch_sigmatel_init)
5588 module_exit(patch_sigmatel_exit)