2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include <sound/asoundef.h>
33 #include <sound/jack.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
74 STAC_92HD73XX_NO_JD, /* no jack-detection */
85 STAC_92HD83XXX_PWR_REF,
121 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
122 * is given, one of the above models will be
123 * chosen according to the subsystem id. */
124 /* for backward compatibility */
140 STAC_D965_REF_NO_JD, /* no jack-detection */
149 struct sigmatel_event {
156 struct sigmatel_jack {
159 struct snd_jack *jack;
162 struct sigmatel_spec {
163 struct snd_kcontrol_new *mixers[4];
164 unsigned int num_mixers;
167 unsigned int eapd_switch: 1;
168 unsigned int surr_switch: 1;
169 unsigned int alt_switch: 1;
170 unsigned int hp_detect: 1;
171 unsigned int spdif_mute: 1;
172 unsigned int check_volume_offset:1;
175 unsigned int eapd_mask;
176 unsigned int gpio_mask;
177 unsigned int gpio_dir;
178 unsigned int gpio_data;
179 unsigned int gpio_mute;
182 unsigned int stream_delay;
184 /* analog loopback */
185 unsigned char aloopback_mask;
186 unsigned char aloopback_shift;
188 /* power management */
189 unsigned int num_pwrs;
190 unsigned int *pwr_mapping;
195 struct snd_array jacks;
198 struct snd_array events;
201 struct hda_input_mux *mono_mux;
202 struct hda_input_mux *amp_mux;
203 unsigned int cur_mmux;
204 struct hda_multi_out multiout;
205 hda_nid_t dac_nids[5];
206 hda_nid_t hp_dacs[5];
207 hda_nid_t speaker_dacs[5];
213 unsigned int num_adcs;
215 unsigned int num_muxes;
216 hda_nid_t *dmic_nids;
217 unsigned int num_dmics;
218 hda_nid_t *dmux_nids;
219 unsigned int num_dmuxes;
220 hda_nid_t *smux_nids;
221 unsigned int num_smuxes;
222 const char **spdif_labels;
224 hda_nid_t dig_in_nid;
226 hda_nid_t anabeep_nid;
227 hda_nid_t digbeep_nid;
231 unsigned int num_pins;
233 /* codec specific stuff */
234 struct hda_verb *init;
235 struct snd_kcontrol_new *mixer;
238 struct hda_input_mux *dinput_mux;
239 unsigned int cur_dmux[2];
240 struct hda_input_mux *input_mux;
241 unsigned int cur_mux[3];
242 struct hda_input_mux *sinput_mux;
243 unsigned int cur_smux[2];
244 unsigned int cur_amux;
246 unsigned int num_amps;
247 unsigned int powerdown_adcs;
250 unsigned int io_switch[2];
251 unsigned int clfe_swap;
252 hda_nid_t line_switch; /* shared line-in for input and output */
253 hda_nid_t mic_switch; /* shared mic-in for input and output */
254 hda_nid_t hp_switch; /* NID of HP as line-out */
255 unsigned int aloopback;
257 struct hda_pcm pcm_rec[2]; /* PCM information */
259 /* dynamic controls and input_mux */
260 struct auto_pin_cfg autocfg;
261 struct snd_array kctls;
262 struct hda_input_mux private_dimux;
263 struct hda_input_mux private_imux;
264 struct hda_input_mux private_smux;
265 struct hda_input_mux private_amp_mux;
266 struct hda_input_mux private_mono_mux;
269 static hda_nid_t stac9200_adc_nids[1] = {
273 static hda_nid_t stac9200_mux_nids[1] = {
277 static hda_nid_t stac9200_dac_nids[1] = {
281 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
282 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
286 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
290 static hda_nid_t stac92hd73xx_adc_nids[2] = {
294 #define DELL_M6_AMP 2
295 static hda_nid_t stac92hd73xx_amp_nids[3] = {
299 #define STAC92HD73XX_NUM_DMICS 2
300 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
304 #define STAC92HD73_DAC_COUNT 5
306 static hda_nid_t stac92hd73xx_mux_nids[4] = {
307 0x28, 0x29, 0x2a, 0x2b,
310 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
314 static hda_nid_t stac92hd73xx_smux_nids[2] = {
318 #define STAC92HD83XXX_NUM_DMICS 2
319 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
323 #define STAC92HD83_DAC_COUNT 3
325 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
329 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
333 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
337 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
341 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
342 0x03, 0x0c, 0x20, 0x40,
345 static hda_nid_t stac92hd83xxx_amp_nids[1] = {
349 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
353 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
357 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
361 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
365 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
369 #define STAC92HD71BXX_NUM_DMICS 2
370 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
374 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
378 static hda_nid_t stac925x_adc_nids[1] = {
382 static hda_nid_t stac925x_mux_nids[1] = {
386 static hda_nid_t stac925x_dac_nids[1] = {
390 #define STAC925X_NUM_DMICS 1
391 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
395 static hda_nid_t stac925x_dmux_nids[1] = {
399 static hda_nid_t stac922x_adc_nids[2] = {
403 static hda_nid_t stac922x_mux_nids[2] = {
407 static hda_nid_t stac927x_slave_dig_outs[2] = {
411 static hda_nid_t stac927x_adc_nids[3] = {
415 static hda_nid_t stac927x_mux_nids[3] = {
419 static hda_nid_t stac927x_smux_nids[1] = {
423 static hda_nid_t stac927x_dac_nids[6] = {
424 0x02, 0x03, 0x04, 0x05, 0x06, 0
427 static hda_nid_t stac927x_dmux_nids[1] = {
431 #define STAC927X_NUM_DMICS 2
432 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
436 static const char *stac927x_spdif_labels[5] = {
437 "Digital Playback", "ADAT", "Analog Mux 1",
438 "Analog Mux 2", "Analog Mux 3"
441 static hda_nid_t stac9205_adc_nids[2] = {
445 static hda_nid_t stac9205_mux_nids[2] = {
449 static hda_nid_t stac9205_dmux_nids[1] = {
453 static hda_nid_t stac9205_smux_nids[1] = {
457 #define STAC9205_NUM_DMICS 2
458 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
462 static hda_nid_t stac9200_pin_nids[8] = {
463 0x08, 0x09, 0x0d, 0x0e,
464 0x0f, 0x10, 0x11, 0x12,
467 static hda_nid_t stac925x_pin_nids[8] = {
468 0x07, 0x08, 0x0a, 0x0b,
469 0x0c, 0x0d, 0x10, 0x11,
472 static hda_nid_t stac922x_pin_nids[10] = {
473 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
474 0x0f, 0x10, 0x11, 0x15, 0x1b,
477 static hda_nid_t stac92hd73xx_pin_nids[13] = {
478 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
479 0x0f, 0x10, 0x11, 0x12, 0x13,
483 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
484 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
485 0x0f, 0x10, 0x11, 0x1f, 0x20,
488 #define STAC92HD71BXX_NUM_PINS 13
489 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
490 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
491 0x00, 0x14, 0x18, 0x19, 0x1e,
494 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
495 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
496 0x0f, 0x14, 0x18, 0x19, 0x1e,
500 static hda_nid_t stac927x_pin_nids[14] = {
501 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
502 0x0f, 0x10, 0x11, 0x12, 0x13,
503 0x14, 0x21, 0x22, 0x23,
506 static hda_nid_t stac9205_pin_nids[12] = {
507 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
508 0x0f, 0x14, 0x16, 0x17, 0x18,
512 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
514 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_value *ucontrol)
517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
518 struct sigmatel_spec *spec = codec->spec;
519 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
521 kcontrol->private_value ^= get_amp_nid(kcontrol);
522 kcontrol->private_value |= nid;
524 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
527 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
528 struct snd_ctl_elem_value *ucontrol)
530 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
531 struct sigmatel_spec *spec = codec->spec;
532 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
534 kcontrol->private_value ^= get_amp_nid(kcontrol);
535 kcontrol->private_value |= nid;
537 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
540 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
541 struct snd_ctl_elem_info *uinfo)
543 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
544 struct sigmatel_spec *spec = codec->spec;
545 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
548 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_value *ucontrol)
551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
552 struct sigmatel_spec *spec = codec->spec;
553 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
555 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
559 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
560 struct snd_ctl_elem_value *ucontrol)
562 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
563 struct sigmatel_spec *spec = codec->spec;
564 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
566 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
567 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
570 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
571 struct snd_ctl_elem_info *uinfo)
573 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
574 struct sigmatel_spec *spec = codec->spec;
575 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
578 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
579 struct snd_ctl_elem_value *ucontrol)
581 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
582 struct sigmatel_spec *spec = codec->spec;
583 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
585 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
589 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
590 struct snd_ctl_elem_value *ucontrol)
592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
593 struct sigmatel_spec *spec = codec->spec;
594 struct hda_input_mux *smux = &spec->private_smux;
595 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
599 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
600 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
604 if (spec->spdif_mute) {
606 nid = spec->multiout.dig_out_nid;
608 nid = codec->slave_dig_outs[smux_idx - 1];
609 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
613 /* un/mute SPDIF out */
614 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
620 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
622 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
623 struct sigmatel_spec *spec = codec->spec;
624 return snd_hda_input_mux_info(spec->input_mux, uinfo);
627 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
630 struct sigmatel_spec *spec = codec->spec;
631 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
633 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
637 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
640 struct sigmatel_spec *spec = codec->spec;
641 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
643 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
644 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
647 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
648 struct snd_ctl_elem_info *uinfo)
650 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
651 struct sigmatel_spec *spec = codec->spec;
652 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
655 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_value *ucontrol)
658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
659 struct sigmatel_spec *spec = codec->spec;
661 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
665 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
666 struct snd_ctl_elem_value *ucontrol)
668 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
669 struct sigmatel_spec *spec = codec->spec;
671 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
672 spec->mono_nid, &spec->cur_mmux);
675 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
676 struct snd_ctl_elem_info *uinfo)
678 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
679 struct sigmatel_spec *spec = codec->spec;
680 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
683 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
684 struct snd_ctl_elem_value *ucontrol)
686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
687 struct sigmatel_spec *spec = codec->spec;
689 ucontrol->value.enumerated.item[0] = spec->cur_amux;
693 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
694 struct snd_ctl_elem_value *ucontrol)
696 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
697 struct sigmatel_spec *spec = codec->spec;
698 struct snd_kcontrol *ctl =
699 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
703 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
704 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
706 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
710 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
712 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
713 struct snd_ctl_elem_value *ucontrol)
715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
716 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
717 struct sigmatel_spec *spec = codec->spec;
719 ucontrol->value.integer.value[0] = !!(spec->aloopback &
720 (spec->aloopback_mask << idx));
724 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
725 struct snd_ctl_elem_value *ucontrol)
727 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
728 struct sigmatel_spec *spec = codec->spec;
729 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
730 unsigned int dac_mode;
731 unsigned int val, idx_val;
733 idx_val = spec->aloopback_mask << idx;
734 if (ucontrol->value.integer.value[0])
735 val = spec->aloopback | idx_val;
737 val = spec->aloopback & ~idx_val;
738 if (spec->aloopback == val)
741 spec->aloopback = val;
743 /* Only return the bits defined by the shift value of the
744 * first two bytes of the mask
746 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
747 kcontrol->private_value & 0xFFFF, 0x0);
748 dac_mode >>= spec->aloopback_shift;
750 if (spec->aloopback & idx_val) {
751 snd_hda_power_up(codec);
754 snd_hda_power_down(codec);
755 dac_mode &= ~idx_val;
758 snd_hda_codec_write_cache(codec, codec->afg, 0,
759 kcontrol->private_value >> 16, dac_mode);
764 static struct hda_verb stac9200_core_init[] = {
765 /* set dac0mux for dac converter */
766 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
770 static struct hda_verb stac9200_eapd_init[] = {
771 /* set dac0mux for dac converter */
772 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
773 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
777 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
778 /* set master volume and direct control */
779 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
780 /* setup adcs to point to mixer */
781 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
782 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
783 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
784 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
785 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
786 /* setup import muxs */
787 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
788 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
789 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
790 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
794 static struct hda_verb dell_eq_core_init[] = {
795 /* set master volume to max value without distortion
796 * and direct control */
797 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
798 /* setup adcs to point to mixer */
799 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
800 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
801 /* setup import muxs */
802 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
803 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
804 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
805 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
809 static struct hda_verb dell_m6_core_init[] = {
810 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
811 /* setup adcs to point to mixer */
812 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
813 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
814 /* setup import muxs */
815 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
816 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
817 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
818 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
822 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
823 /* set master volume and direct control */
824 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
825 /* setup adcs to point to mixer */
826 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
827 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
828 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
829 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
830 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
831 /* setup import muxs */
832 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
833 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
834 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
835 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
839 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
840 /* set master volume and direct control */
841 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
842 /* dac3 is connected to import3 mux */
843 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
844 /* setup adcs to point to mixer */
845 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
846 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
847 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
848 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
849 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
850 /* setup import muxs */
851 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
852 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
853 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
854 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
858 static struct hda_verb stac92hd83xxx_core_init[] = {
859 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
860 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
861 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
863 /* power state controls amps */
864 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
868 static struct hda_verb stac92hd71bxx_core_init[] = {
869 /* set master volume and direct control */
870 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
874 #define HD_DISABLE_PORTF 1
875 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
876 /* start of config #1 */
878 /* connect port 0f to audio mixer */
879 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
880 /* start of config #2 */
882 /* set master volume and direct control */
883 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
887 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
888 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
889 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
890 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
891 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
895 static struct hda_verb stac925x_core_init[] = {
896 /* set dac0mux for dac converter */
897 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
898 /* mute the master volume */
899 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
903 static struct hda_verb stac922x_core_init[] = {
904 /* set master volume and direct control */
905 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
909 static struct hda_verb d965_core_init[] = {
910 /* set master volume and direct control */
911 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
912 /* unmute node 0x1b */
913 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
914 /* select node 0x03 as DAC */
915 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
919 static struct hda_verb stac927x_core_init[] = {
920 /* set master volume and direct control */
921 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
922 /* enable analog pc beep path */
923 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
927 static struct hda_verb stac9205_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 #define STAC_MONO_MUX \
937 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
938 .name = "Mono Mux", \
940 .info = stac92xx_mono_mux_enum_info, \
941 .get = stac92xx_mono_mux_enum_get, \
942 .put = stac92xx_mono_mux_enum_put, \
945 #define STAC_AMP_MUX \
947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
948 .name = "Amp Selector Capture Switch", \
950 .info = stac92xx_amp_mux_enum_info, \
951 .get = stac92xx_amp_mux_enum_get, \
952 .put = stac92xx_amp_mux_enum_put, \
955 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
960 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
961 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
962 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
963 .info = stac92xx_amp_volume_info, \
964 .get = stac92xx_amp_volume_get, \
965 .put = stac92xx_amp_volume_put, \
966 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
967 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
970 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
973 .name = "Analog Loopback", \
975 .info = stac92xx_aloopback_info, \
976 .get = stac92xx_aloopback_get, \
977 .put = stac92xx_aloopback_put, \
978 .private_value = verb_read | (verb_write << 16), \
981 static struct snd_kcontrol_new stac9200_mixer[] = {
982 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
983 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
984 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
985 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
989 #define DELL_M6_MIXER 6
990 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
991 /* start of config #1 */
992 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
993 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
995 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
996 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
998 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
999 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1001 /* start of config #2 */
1002 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1003 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1005 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1006 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1008 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1010 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1011 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1013 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1014 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1019 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1020 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1022 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1023 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1025 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1026 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1028 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1029 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1031 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1032 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1034 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1035 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1037 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1038 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1040 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1041 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1045 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1046 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1048 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1049 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1051 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1052 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1054 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1055 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1057 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1058 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1060 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1061 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1063 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1064 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1066 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1067 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1072 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1073 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1074 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1076 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1077 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1079 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1080 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
1082 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1083 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
1085 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1086 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
1088 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1089 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
1092 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1093 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
1098 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1099 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1101 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1102 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1104 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1105 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1106 /* analog pc-beep replaced with digital beep support */
1108 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1109 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1112 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1113 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1115 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1116 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1118 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1119 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1121 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1122 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1126 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1127 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1129 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1132 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1133 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1137 static struct snd_kcontrol_new stac925x_mixer[] = {
1138 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1139 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1140 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1141 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1145 static struct snd_kcontrol_new stac9205_mixer[] = {
1146 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1148 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1149 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1151 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1152 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1156 /* This needs to be generated dynamically based on sequence */
1157 static struct snd_kcontrol_new stac922x_mixer[] = {
1158 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1159 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1161 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1162 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1167 static struct snd_kcontrol_new stac927x_mixer[] = {
1168 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1170 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1171 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1173 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1174 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1176 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1177 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1181 static struct snd_kcontrol_new stac_dmux_mixer = {
1182 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1183 .name = "Digital Input Source",
1184 /* count set later */
1185 .info = stac92xx_dmux_enum_info,
1186 .get = stac92xx_dmux_enum_get,
1187 .put = stac92xx_dmux_enum_put,
1190 static struct snd_kcontrol_new stac_smux_mixer = {
1191 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1192 .name = "IEC958 Playback Source",
1193 /* count set later */
1194 .info = stac92xx_smux_enum_info,
1195 .get = stac92xx_smux_enum_get,
1196 .put = stac92xx_smux_enum_put,
1199 static const char *slave_vols[] = {
1200 "Front Playback Volume",
1201 "Surround Playback Volume",
1202 "Center Playback Volume",
1203 "LFE Playback Volume",
1204 "Side Playback Volume",
1205 "Headphone Playback Volume",
1206 "Headphone Playback Volume",
1207 "Speaker Playback Volume",
1208 "External Speaker Playback Volume",
1209 "Speaker2 Playback Volume",
1213 static const char *slave_sws[] = {
1214 "Front Playback Switch",
1215 "Surround Playback Switch",
1216 "Center Playback Switch",
1217 "LFE Playback Switch",
1218 "Side Playback Switch",
1219 "Headphone Playback Switch",
1220 "Headphone Playback Switch",
1221 "Speaker Playback Switch",
1222 "External Speaker Playback Switch",
1223 "Speaker2 Playback Switch",
1224 "IEC958 Playback Switch",
1228 static void stac92xx_free_kctls(struct hda_codec *codec);
1229 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1231 static int stac92xx_build_controls(struct hda_codec *codec)
1233 struct sigmatel_spec *spec = codec->spec;
1234 struct auto_pin_cfg *cfg = &spec->autocfg;
1239 err = snd_hda_add_new_ctls(codec, spec->mixer);
1243 for (i = 0; i < spec->num_mixers; i++) {
1244 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1248 if (spec->num_dmuxes > 0) {
1249 stac_dmux_mixer.count = spec->num_dmuxes;
1250 err = snd_hda_ctl_add(codec,
1251 snd_ctl_new1(&stac_dmux_mixer, codec));
1255 if (spec->num_smuxes > 0) {
1256 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1257 struct hda_input_mux *smux = &spec->private_smux;
1258 /* check for mute support on SPDIF out */
1259 if (wcaps & AC_WCAP_OUT_AMP) {
1260 smux->items[smux->num_items].label = "Off";
1261 smux->items[smux->num_items].index = 0;
1263 spec->spdif_mute = 1;
1265 stac_smux_mixer.count = spec->num_smuxes;
1266 err = snd_hda_ctl_add(codec,
1267 snd_ctl_new1(&stac_smux_mixer, codec));
1272 if (spec->multiout.dig_out_nid) {
1273 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1276 err = snd_hda_create_spdif_share_sw(codec,
1280 spec->multiout.share_spdif = 1;
1282 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1283 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1288 /* if we have no master control, let's create it */
1289 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1290 unsigned int vmaster_tlv[4];
1291 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1292 HDA_OUTPUT, vmaster_tlv);
1293 /* correct volume offset */
1294 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1295 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1296 vmaster_tlv, slave_vols);
1300 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1301 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1307 stac92xx_free_kctls(codec); /* no longer needed */
1309 /* create jack input elements */
1310 if (spec->hp_detect) {
1311 for (i = 0; i < cfg->hp_outs; i++) {
1312 int type = SND_JACK_HEADPHONE;
1313 nid = cfg->hp_pins[i];
1314 /* jack detection */
1315 if (cfg->hp_outs == i)
1316 type |= SND_JACK_LINEOUT;
1317 err = stac92xx_add_jack(codec, nid, type);
1322 for (i = 0; i < cfg->line_outs; i++) {
1323 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1328 for (i = 0; i < AUTO_PIN_LAST; i++) {
1329 nid = cfg->input_pins[i];
1331 err = stac92xx_add_jack(codec, nid,
1332 SND_JACK_MICROPHONE);
1341 static unsigned int ref9200_pin_configs[8] = {
1342 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1343 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1346 static unsigned int gateway9200_m4_pin_configs[8] = {
1347 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1348 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1350 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1351 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1352 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1356 STAC 9200 pin configs for
1361 static unsigned int dell9200_d21_pin_configs[8] = {
1362 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1363 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1367 STAC 9200 pin configs for
1371 static unsigned int dell9200_d22_pin_configs[8] = {
1372 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1373 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1377 STAC 9200 pin configs for
1378 102801C4 (Dell Dimension E310)
1385 static unsigned int dell9200_d23_pin_configs[8] = {
1386 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1387 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1392 STAC 9200-32 pin configs for
1393 102801B5 (Dell Inspiron 630m)
1394 102801D8 (Dell Inspiron 640m)
1396 static unsigned int dell9200_m21_pin_configs[8] = {
1397 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1398 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1402 STAC 9200-32 pin configs for
1403 102801C2 (Dell Latitude D620)
1405 102801CC (Dell Latitude D820)
1409 static unsigned int dell9200_m22_pin_configs[8] = {
1410 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1411 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1415 STAC 9200-32 pin configs for
1416 102801CE (Dell XPS M1710)
1417 102801CF (Dell Precision M90)
1419 static unsigned int dell9200_m23_pin_configs[8] = {
1420 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1421 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1425 STAC 9200-32 pin configs for
1428 102801CB (Dell Latitude 120L)
1431 static unsigned int dell9200_m24_pin_configs[8] = {
1432 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1433 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1437 STAC 9200-32 pin configs for
1438 102801BD (Dell Inspiron E1505n)
1442 static unsigned int dell9200_m25_pin_configs[8] = {
1443 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1444 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1448 STAC 9200-32 pin configs for
1449 102801F5 (Dell Inspiron 1501)
1452 static unsigned int dell9200_m26_pin_configs[8] = {
1453 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1454 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1459 102801CD (Dell Inspiron E1705/9400)
1461 static unsigned int dell9200_m27_pin_configs[8] = {
1462 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1463 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1466 static unsigned int oqo9200_pin_configs[8] = {
1467 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1468 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1472 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1473 [STAC_REF] = ref9200_pin_configs,
1474 [STAC_9200_OQO] = oqo9200_pin_configs,
1475 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1476 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1477 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1478 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1479 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1480 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1481 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1482 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1483 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1484 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1485 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1486 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1487 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1490 static const char *stac9200_models[STAC_9200_MODELS] = {
1492 [STAC_9200_OQO] = "oqo",
1493 [STAC_9200_DELL_D21] = "dell-d21",
1494 [STAC_9200_DELL_D22] = "dell-d22",
1495 [STAC_9200_DELL_D23] = "dell-d23",
1496 [STAC_9200_DELL_M21] = "dell-m21",
1497 [STAC_9200_DELL_M22] = "dell-m22",
1498 [STAC_9200_DELL_M23] = "dell-m23",
1499 [STAC_9200_DELL_M24] = "dell-m24",
1500 [STAC_9200_DELL_M25] = "dell-m25",
1501 [STAC_9200_DELL_M26] = "dell-m26",
1502 [STAC_9200_DELL_M27] = "dell-m27",
1503 [STAC_9200_M4] = "gateway-m4",
1504 [STAC_9200_M4_2] = "gateway-m4-2",
1505 [STAC_9200_PANASONIC] = "panasonic",
1508 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1509 /* SigmaTel reference board */
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1511 "DFI LanParty", STAC_REF),
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1513 "DFI LanParty", STAC_REF),
1514 /* Dell laptops have BIOS problem */
1515 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1516 "unknown Dell", STAC_9200_DELL_D21),
1517 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1518 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1520 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1522 "unknown Dell", STAC_9200_DELL_D22),
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1524 "unknown Dell", STAC_9200_DELL_D22),
1525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1526 "Dell Latitude D620", STAC_9200_DELL_M22),
1527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1528 "unknown Dell", STAC_9200_DELL_D23),
1529 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1530 "unknown Dell", STAC_9200_DELL_D23),
1531 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1532 "unknown Dell", STAC_9200_DELL_M22),
1533 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1534 "unknown Dell", STAC_9200_DELL_M24),
1535 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1536 "unknown Dell", STAC_9200_DELL_M24),
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1538 "Dell Latitude 120L", STAC_9200_DELL_M24),
1539 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1540 "Dell Latitude D820", STAC_9200_DELL_M22),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1542 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1544 "Dell XPS M1710", STAC_9200_DELL_M23),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1546 "Dell Precision M90", STAC_9200_DELL_M23),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1548 "unknown Dell", STAC_9200_DELL_M22),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1550 "unknown Dell", STAC_9200_DELL_M22),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1552 "unknown Dell", STAC_9200_DELL_M22),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1554 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1556 "unknown Dell", STAC_9200_DELL_D23),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1558 "unknown Dell", STAC_9200_DELL_D23),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1560 "unknown Dell", STAC_9200_DELL_D21),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1562 "unknown Dell", STAC_9200_DELL_D23),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1564 "unknown Dell", STAC_9200_DELL_D21),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1566 "unknown Dell", STAC_9200_DELL_M25),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1568 "unknown Dell", STAC_9200_DELL_M25),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1570 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1572 "unknown Dell", STAC_9200_DELL_M26),
1574 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1575 /* Gateway machines needs EAPD to be set on resume */
1576 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1577 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1578 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1580 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1584 static unsigned int ref925x_pin_configs[8] = {
1585 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1586 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1589 static unsigned int stac925xM1_pin_configs[8] = {
1590 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1591 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1594 static unsigned int stac925xM1_2_pin_configs[8] = {
1595 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1596 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1599 static unsigned int stac925xM2_pin_configs[8] = {
1600 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1601 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1604 static unsigned int stac925xM2_2_pin_configs[8] = {
1605 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1606 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1609 static unsigned int stac925xM3_pin_configs[8] = {
1610 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1611 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1614 static unsigned int stac925xM5_pin_configs[8] = {
1615 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1616 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1619 static unsigned int stac925xM6_pin_configs[8] = {
1620 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1621 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1624 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1625 [STAC_REF] = ref925x_pin_configs,
1626 [STAC_M1] = stac925xM1_pin_configs,
1627 [STAC_M1_2] = stac925xM1_2_pin_configs,
1628 [STAC_M2] = stac925xM2_pin_configs,
1629 [STAC_M2_2] = stac925xM2_2_pin_configs,
1630 [STAC_M3] = stac925xM3_pin_configs,
1631 [STAC_M5] = stac925xM5_pin_configs,
1632 [STAC_M6] = stac925xM6_pin_configs,
1635 static const char *stac925x_models[STAC_925x_MODELS] = {
1638 [STAC_M1_2] = "m1-2",
1640 [STAC_M2_2] = "m2-2",
1646 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1647 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1648 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1649 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1650 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1651 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1652 /* Not sure about the brand name for those */
1653 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1654 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1655 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1656 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1660 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1661 /* SigmaTel reference board */
1662 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1664 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1666 /* Default table for unknown ID */
1667 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1672 static unsigned int ref92hd73xx_pin_configs[13] = {
1673 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1674 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1675 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1679 static unsigned int dell_m6_pin_configs[13] = {
1680 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1681 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1682 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1686 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1687 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1688 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1689 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1690 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1691 [STAC_DELL_EQ] = dell_m6_pin_configs,
1694 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1695 [STAC_92HD73XX_NO_JD] = "no-jd",
1696 [STAC_92HD73XX_REF] = "ref",
1697 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1698 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1699 [STAC_DELL_M6_BOTH] = "dell-m6",
1700 [STAC_DELL_EQ] = "dell-eq",
1703 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1704 /* SigmaTel reference board */
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1706 "DFI LanParty", STAC_92HD73XX_REF),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1708 "DFI LanParty", STAC_92HD73XX_REF),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1710 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1712 "unknown Dell", STAC_DELL_M6_DMIC),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1714 "unknown Dell", STAC_DELL_M6_BOTH),
1715 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1716 "unknown Dell", STAC_DELL_M6_BOTH),
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1718 "unknown Dell", STAC_DELL_M6_AMIC),
1719 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1720 "unknown Dell", STAC_DELL_M6_AMIC),
1721 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1722 "unknown Dell", STAC_DELL_M6_DMIC),
1723 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1724 "unknown Dell", STAC_DELL_M6_DMIC),
1725 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1726 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1727 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1728 "Dell Studio 17", STAC_DELL_M6_DMIC),
1732 static unsigned int ref92hd83xxx_pin_configs[10] = {
1733 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1734 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1735 0x01451160, 0x98560170,
1738 static unsigned int dell_s14_pin_configs[10] = {
1739 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1740 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1741 0x40f000f0, 0x40f000f0,
1744 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1745 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1746 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1747 [STAC_DELL_S14] = dell_s14_pin_configs,
1750 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1751 [STAC_92HD83XXX_REF] = "ref",
1752 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1753 [STAC_DELL_S14] = "dell-s14",
1756 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1757 /* SigmaTel reference board */
1758 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1759 "DFI LanParty", STAC_92HD83XXX_REF),
1760 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1761 "DFI LanParty", STAC_92HD83XXX_REF),
1762 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1763 "unknown Dell", STAC_DELL_S14),
1767 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1768 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1769 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1770 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1774 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1775 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1776 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1777 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1781 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1782 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1783 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1784 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1788 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1789 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1790 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1791 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1795 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1796 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1797 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1798 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1799 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1800 [STAC_HP_M4] = NULL,
1801 [STAC_HP_DV5] = NULL,
1804 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1805 [STAC_92HD71BXX_REF] = "ref",
1806 [STAC_DELL_M4_1] = "dell-m4-1",
1807 [STAC_DELL_M4_2] = "dell-m4-2",
1808 [STAC_DELL_M4_3] = "dell-m4-3",
1809 [STAC_HP_M4] = "hp-m4",
1810 [STAC_HP_DV5] = "hp-dv5",
1813 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1814 /* SigmaTel reference board */
1815 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1816 "DFI LanParty", STAC_92HD71BXX_REF),
1817 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1818 "DFI LanParty", STAC_92HD71BXX_REF),
1819 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1820 "HP dv4-7", STAC_HP_DV5),
1821 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1822 "HP dv4-7", STAC_HP_DV5),
1823 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1824 "HP mini 1000", STAC_HP_M4),
1825 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1826 "unknown Dell", STAC_DELL_M4_1),
1827 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1828 "unknown Dell", STAC_DELL_M4_1),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1830 "unknown Dell", STAC_DELL_M4_1),
1831 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1832 "unknown Dell", STAC_DELL_M4_1),
1833 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1834 "unknown Dell", STAC_DELL_M4_1),
1835 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1836 "unknown Dell", STAC_DELL_M4_1),
1837 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1838 "unknown Dell", STAC_DELL_M4_1),
1839 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1840 "unknown Dell", STAC_DELL_M4_2),
1841 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1842 "unknown Dell", STAC_DELL_M4_2),
1843 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1844 "unknown Dell", STAC_DELL_M4_2),
1845 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1846 "unknown Dell", STAC_DELL_M4_2),
1847 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1848 "unknown Dell", STAC_DELL_M4_3),
1852 static unsigned int ref922x_pin_configs[10] = {
1853 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1854 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1855 0x40000100, 0x40000100,
1859 STAC 922X pin configs for
1866 static unsigned int dell_922x_d81_pin_configs[10] = {
1867 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1868 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1869 0x01813122, 0x400001f2,
1873 STAC 922X pin configs for
1877 static unsigned int dell_922x_d82_pin_configs[10] = {
1878 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1879 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1880 0x01813122, 0x400001f1,
1884 STAC 922X pin configs for
1887 static unsigned int dell_922x_m81_pin_configs[10] = {
1888 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1889 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1890 0x40C003f1, 0x405003f0,
1894 STAC 9221 A1 pin configs for
1895 102801D7 (Dell XPS M1210)
1897 static unsigned int dell_922x_m82_pin_configs[10] = {
1898 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1899 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1900 0x508003f3, 0x405003f4,
1903 static unsigned int d945gtp3_pin_configs[10] = {
1904 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1905 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1906 0x02a19120, 0x40000100,
1909 static unsigned int d945gtp5_pin_configs[10] = {
1910 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1911 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1912 0x02a19320, 0x40000100,
1915 static unsigned int intel_mac_v1_pin_configs[10] = {
1916 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1917 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1918 0x400000fc, 0x400000fb,
1921 static unsigned int intel_mac_v2_pin_configs[10] = {
1922 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1923 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1924 0x400000fc, 0x400000fb,
1927 static unsigned int intel_mac_v3_pin_configs[10] = {
1928 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1929 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1930 0x400000fc, 0x400000fb,
1933 static unsigned int intel_mac_v4_pin_configs[10] = {
1934 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1935 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1936 0x400000fc, 0x400000fb,
1939 static unsigned int intel_mac_v5_pin_configs[10] = {
1940 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1941 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1942 0x400000fc, 0x400000fb,
1945 static unsigned int ecs202_pin_configs[10] = {
1946 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1947 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1948 0x9037012e, 0x40e000f2,
1951 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1952 [STAC_D945_REF] = ref922x_pin_configs,
1953 [STAC_D945GTP3] = d945gtp3_pin_configs,
1954 [STAC_D945GTP5] = d945gtp5_pin_configs,
1955 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1956 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1957 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1958 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1959 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1960 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1961 /* for backward compatibility */
1962 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1963 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1964 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1965 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1966 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1967 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1968 [STAC_ECS_202] = ecs202_pin_configs,
1969 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1970 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1971 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1972 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1975 static const char *stac922x_models[STAC_922X_MODELS] = {
1976 [STAC_D945_REF] = "ref",
1977 [STAC_D945GTP5] = "5stack",
1978 [STAC_D945GTP3] = "3stack",
1979 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1980 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1981 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1982 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1983 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1984 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1985 /* for backward compatibility */
1986 [STAC_MACMINI] = "macmini",
1987 [STAC_MACBOOK] = "macbook",
1988 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1989 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1990 [STAC_IMAC_INTEL] = "imac-intel",
1991 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1992 [STAC_ECS_202] = "ecs202",
1993 [STAC_922X_DELL_D81] = "dell-d81",
1994 [STAC_922X_DELL_D82] = "dell-d82",
1995 [STAC_922X_DELL_M81] = "dell-m81",
1996 [STAC_922X_DELL_M82] = "dell-m82",
1999 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2000 /* SigmaTel reference board */
2001 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2002 "DFI LanParty", STAC_D945_REF),
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2004 "DFI LanParty", STAC_D945_REF),
2005 /* Intel 945G based systems */
2006 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2007 "Intel D945G", STAC_D945GTP3),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2009 "Intel D945G", STAC_D945GTP3),
2010 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2011 "Intel D945G", STAC_D945GTP3),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2013 "Intel D945G", STAC_D945GTP3),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2015 "Intel D945G", STAC_D945GTP3),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2017 "Intel D945G", STAC_D945GTP3),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2019 "Intel D945G", STAC_D945GTP3),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2021 "Intel D945G", STAC_D945GTP3),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2023 "Intel D945G", STAC_D945GTP3),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2025 "Intel D945G", STAC_D945GTP3),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2027 "Intel D945G", STAC_D945GTP3),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2029 "Intel D945G", STAC_D945GTP3),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2031 "Intel D945G", STAC_D945GTP3),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2033 "Intel D945G", STAC_D945GTP3),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2035 "Intel D945G", STAC_D945GTP3),
2036 /* Intel D945G 5-stack systems */
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2038 "Intel D945G", STAC_D945GTP5),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2040 "Intel D945G", STAC_D945GTP5),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2042 "Intel D945G", STAC_D945GTP5),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2044 "Intel D945G", STAC_D945GTP5),
2045 /* Intel 945P based systems */
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2047 "Intel D945P", STAC_D945GTP3),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2049 "Intel D945P", STAC_D945GTP3),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2051 "Intel D945P", STAC_D945GTP3),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2053 "Intel D945P", STAC_D945GTP3),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2055 "Intel D945P", STAC_D945GTP3),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2057 "Intel D945P", STAC_D945GTP5),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2060 "Intel D945", STAC_D945_REF),
2062 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2063 SND_PCI_QUIRK(0x8384, 0x7680,
2064 "Mac", STAC_INTEL_MAC_AUTO),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2067 "unknown Dell", STAC_922X_DELL_D81),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2069 "unknown Dell", STAC_922X_DELL_D81),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2071 "unknown Dell", STAC_922X_DELL_D81),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2073 "unknown Dell", STAC_922X_DELL_D82),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2075 "unknown Dell", STAC_922X_DELL_M81),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2077 "unknown Dell", STAC_922X_DELL_D82),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2079 "unknown Dell", STAC_922X_DELL_D81),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2081 "unknown Dell", STAC_922X_DELL_D81),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2083 "Dell XPS M1210", STAC_922X_DELL_M82),
2084 /* ECS/PC Chips boards */
2085 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2086 "ECS/PC chips", STAC_ECS_202),
2090 static unsigned int ref927x_pin_configs[14] = {
2091 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2092 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2093 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2094 0x01c42190, 0x40000100,
2097 static unsigned int d965_3st_pin_configs[14] = {
2098 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2099 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2100 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2101 0x40000100, 0x40000100
2104 static unsigned int d965_5st_pin_configs[14] = {
2105 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2106 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2107 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2108 0x40000100, 0x40000100
2111 static unsigned int dell_3st_pin_configs[14] = {
2112 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2113 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2114 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2115 0x40c003fc, 0x40000100
2118 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2119 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2120 [STAC_D965_REF] = ref927x_pin_configs,
2121 [STAC_D965_3ST] = d965_3st_pin_configs,
2122 [STAC_D965_5ST] = d965_5st_pin_configs,
2123 [STAC_DELL_3ST] = dell_3st_pin_configs,
2124 [STAC_DELL_BIOS] = NULL,
2127 static const char *stac927x_models[STAC_927X_MODELS] = {
2128 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2129 [STAC_D965_REF] = "ref",
2130 [STAC_D965_3ST] = "3stack",
2131 [STAC_D965_5ST] = "5stack",
2132 [STAC_DELL_3ST] = "dell-3stack",
2133 [STAC_DELL_BIOS] = "dell-bios",
2136 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2137 /* SigmaTel reference board */
2138 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2139 "DFI LanParty", STAC_D965_REF),
2140 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2141 "DFI LanParty", STAC_D965_REF),
2142 /* Intel 946 based systems */
2143 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2144 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2145 /* 965 based 3 stack systems */
2146 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2147 "Intel D965", STAC_D965_3ST),
2148 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2149 "Intel D965", STAC_D965_3ST),
2150 /* Dell 3 stack systems */
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2155 /* Dell 3 stack systems with verb table in BIOS */
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2157 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2164 /* 965 based 5 stack systems */
2165 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2166 "Intel D965", STAC_D965_5ST),
2167 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2168 "Intel D965", STAC_D965_5ST),
2172 static unsigned int ref9205_pin_configs[12] = {
2173 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2174 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2175 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2179 STAC 9205 pin configs for
2186 10280228 (Dell Vostro 1500)
2188 static unsigned int dell_9205_m42_pin_configs[12] = {
2189 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2190 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2191 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2195 STAC 9205 pin configs for
2199 102801FF (Dell Precision M4300)
2204 static unsigned int dell_9205_m43_pin_configs[12] = {
2205 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2206 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2207 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2210 static unsigned int dell_9205_m44_pin_configs[12] = {
2211 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2212 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2213 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2216 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2217 [STAC_9205_REF] = ref9205_pin_configs,
2218 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2219 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2220 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2221 [STAC_9205_EAPD] = NULL,
2224 static const char *stac9205_models[STAC_9205_MODELS] = {
2225 [STAC_9205_REF] = "ref",
2226 [STAC_9205_DELL_M42] = "dell-m42",
2227 [STAC_9205_DELL_M43] = "dell-m43",
2228 [STAC_9205_DELL_M44] = "dell-m44",
2229 [STAC_9205_EAPD] = "eapd",
2232 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2233 /* SigmaTel reference board */
2234 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2235 "DFI LanParty", STAC_9205_REF),
2236 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2237 "DFI LanParty", STAC_9205_REF),
2239 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2240 "unknown Dell", STAC_9205_DELL_M42),
2241 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2242 "unknown Dell", STAC_9205_DELL_M42),
2243 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2244 "Dell Precision", STAC_9205_DELL_M43),
2245 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2246 "Dell Precision", STAC_9205_DELL_M43),
2247 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2248 "Dell Precision", STAC_9205_DELL_M43),
2249 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2250 "unknown Dell", STAC_9205_DELL_M42),
2251 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2252 "unknown Dell", STAC_9205_DELL_M42),
2253 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2254 "Dell Precision", STAC_9205_DELL_M43),
2255 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2256 "Dell Precision M4300", STAC_9205_DELL_M43),
2257 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2258 "unknown Dell", STAC_9205_DELL_M42),
2259 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2260 "Dell Precision", STAC_9205_DELL_M43),
2261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2262 "Dell Precision", STAC_9205_DELL_M43),
2263 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2264 "Dell Precision", STAC_9205_DELL_M43),
2265 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2266 "Dell Inspiron", STAC_9205_DELL_M44),
2267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2268 "Dell Vostro 1500", STAC_9205_DELL_M42),
2270 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2274 static void stac92xx_set_config_regs(struct hda_codec *codec,
2275 unsigned int *pincfgs)
2278 struct sigmatel_spec *spec = codec->spec;
2283 for (i = 0; i < spec->num_pins; i++)
2284 if (spec->pin_nids[i] && pincfgs[i])
2285 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2290 * Analog playback callbacks
2292 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2293 struct hda_codec *codec,
2294 struct snd_pcm_substream *substream)
2296 struct sigmatel_spec *spec = codec->spec;
2297 if (spec->stream_delay)
2298 msleep(spec->stream_delay);
2299 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2303 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2304 struct hda_codec *codec,
2305 unsigned int stream_tag,
2306 unsigned int format,
2307 struct snd_pcm_substream *substream)
2309 struct sigmatel_spec *spec = codec->spec;
2310 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2313 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2314 struct hda_codec *codec,
2315 struct snd_pcm_substream *substream)
2317 struct sigmatel_spec *spec = codec->spec;
2318 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2322 * Digital playback callbacks
2324 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2325 struct hda_codec *codec,
2326 struct snd_pcm_substream *substream)
2328 struct sigmatel_spec *spec = codec->spec;
2329 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2332 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2333 struct hda_codec *codec,
2334 struct snd_pcm_substream *substream)
2336 struct sigmatel_spec *spec = codec->spec;
2337 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2340 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2341 struct hda_codec *codec,
2342 unsigned int stream_tag,
2343 unsigned int format,
2344 struct snd_pcm_substream *substream)
2346 struct sigmatel_spec *spec = codec->spec;
2347 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2348 stream_tag, format, substream);
2351 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2352 struct hda_codec *codec,
2353 struct snd_pcm_substream *substream)
2355 struct sigmatel_spec *spec = codec->spec;
2356 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2361 * Analog capture callbacks
2363 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2364 struct hda_codec *codec,
2365 unsigned int stream_tag,
2366 unsigned int format,
2367 struct snd_pcm_substream *substream)
2369 struct sigmatel_spec *spec = codec->spec;
2370 hda_nid_t nid = spec->adc_nids[substream->number];
2372 if (spec->powerdown_adcs) {
2374 snd_hda_codec_write(codec, nid, 0,
2375 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2377 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2381 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2382 struct hda_codec *codec,
2383 struct snd_pcm_substream *substream)
2385 struct sigmatel_spec *spec = codec->spec;
2386 hda_nid_t nid = spec->adc_nids[substream->number];
2388 snd_hda_codec_cleanup_stream(codec, nid);
2389 if (spec->powerdown_adcs)
2390 snd_hda_codec_write(codec, nid, 0,
2391 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2395 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2399 /* NID is set in stac92xx_build_pcms */
2401 .open = stac92xx_dig_playback_pcm_open,
2402 .close = stac92xx_dig_playback_pcm_close,
2403 .prepare = stac92xx_dig_playback_pcm_prepare,
2404 .cleanup = stac92xx_dig_playback_pcm_cleanup
2408 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2412 /* NID is set in stac92xx_build_pcms */
2415 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2419 .nid = 0x02, /* NID to query formats and rates */
2421 .open = stac92xx_playback_pcm_open,
2422 .prepare = stac92xx_playback_pcm_prepare,
2423 .cleanup = stac92xx_playback_pcm_cleanup
2427 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2431 .nid = 0x06, /* NID to query formats and rates */
2433 .open = stac92xx_playback_pcm_open,
2434 .prepare = stac92xx_playback_pcm_prepare,
2435 .cleanup = stac92xx_playback_pcm_cleanup
2439 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2442 /* NID + .substreams is set in stac92xx_build_pcms */
2444 .prepare = stac92xx_capture_pcm_prepare,
2445 .cleanup = stac92xx_capture_pcm_cleanup
2449 static int stac92xx_build_pcms(struct hda_codec *codec)
2451 struct sigmatel_spec *spec = codec->spec;
2452 struct hda_pcm *info = spec->pcm_rec;
2454 codec->num_pcms = 1;
2455 codec->pcm_info = info;
2457 info->name = "STAC92xx Analog";
2458 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2459 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2460 spec->multiout.dac_nids[0];
2461 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2462 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2463 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2465 if (spec->alt_switch) {
2468 info->name = "STAC92xx Analog Alt";
2469 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2472 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2475 info->name = "STAC92xx Digital";
2476 info->pcm_type = spec->autocfg.dig_out_type[0];
2477 if (spec->multiout.dig_out_nid) {
2478 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2479 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2481 if (spec->dig_in_nid) {
2482 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2483 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2490 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2492 unsigned int pincap = snd_hda_param_read(codec, nid,
2494 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2495 if (pincap & AC_PINCAP_VREF_100)
2496 return AC_PINCTL_VREF_100;
2497 if (pincap & AC_PINCAP_VREF_80)
2498 return AC_PINCTL_VREF_80;
2499 if (pincap & AC_PINCAP_VREF_50)
2500 return AC_PINCTL_VREF_50;
2501 if (pincap & AC_PINCAP_VREF_GRD)
2502 return AC_PINCTL_VREF_GRD;
2506 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2509 snd_hda_codec_write_cache(codec, nid, 0,
2510 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2513 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2515 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2516 struct snd_ctl_elem_value *ucontrol)
2518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2519 struct sigmatel_spec *spec = codec->spec;
2521 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2525 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2526 unsigned char type);
2528 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2529 struct snd_ctl_elem_value *ucontrol)
2531 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2532 struct sigmatel_spec *spec = codec->spec;
2533 int nid = kcontrol->private_value;
2535 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2537 /* check to be sure that the ports are upto date with
2540 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2545 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2547 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2550 struct sigmatel_spec *spec = codec->spec;
2551 int io_idx = kcontrol-> private_value & 0xff;
2553 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2557 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2560 struct sigmatel_spec *spec = codec->spec;
2561 hda_nid_t nid = kcontrol->private_value >> 8;
2562 int io_idx = kcontrol-> private_value & 0xff;
2563 unsigned short val = !!ucontrol->value.integer.value[0];
2565 spec->io_switch[io_idx] = val;
2568 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2570 unsigned int pinctl = AC_PINCTL_IN_EN;
2571 if (io_idx) /* set VREF for mic */
2572 pinctl |= stac92xx_get_vref(codec, nid);
2573 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2576 /* check the auto-mute again: we need to mute/unmute the speaker
2577 * appropriately according to the pin direction
2579 if (spec->hp_detect)
2580 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2585 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2587 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2588 struct snd_ctl_elem_value *ucontrol)
2590 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2591 struct sigmatel_spec *spec = codec->spec;
2593 ucontrol->value.integer.value[0] = spec->clfe_swap;
2597 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2598 struct snd_ctl_elem_value *ucontrol)
2600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2601 struct sigmatel_spec *spec = codec->spec;
2602 hda_nid_t nid = kcontrol->private_value & 0xff;
2603 unsigned int val = !!ucontrol->value.integer.value[0];
2605 if (spec->clfe_swap == val)
2608 spec->clfe_swap = val;
2610 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2611 spec->clfe_swap ? 0x4 : 0x0);
2616 #define STAC_CODEC_HP_SWITCH(xname) \
2617 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2620 .info = stac92xx_hp_switch_info, \
2621 .get = stac92xx_hp_switch_get, \
2622 .put = stac92xx_hp_switch_put, \
2625 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2626 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2629 .info = stac92xx_io_switch_info, \
2630 .get = stac92xx_io_switch_get, \
2631 .put = stac92xx_io_switch_put, \
2632 .private_value = xpval, \
2635 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2636 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2639 .info = stac92xx_clfe_switch_info, \
2640 .get = stac92xx_clfe_switch_get, \
2641 .put = stac92xx_clfe_switch_put, \
2642 .private_value = xpval, \
2646 STAC_CTL_WIDGET_VOL,
2647 STAC_CTL_WIDGET_MUTE,
2648 STAC_CTL_WIDGET_MONO_MUX,
2649 STAC_CTL_WIDGET_AMP_MUX,
2650 STAC_CTL_WIDGET_AMP_VOL,
2651 STAC_CTL_WIDGET_HP_SWITCH,
2652 STAC_CTL_WIDGET_IO_SWITCH,
2653 STAC_CTL_WIDGET_CLFE_SWITCH
2656 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2657 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2658 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2661 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2662 STAC_CODEC_HP_SWITCH(NULL),
2663 STAC_CODEC_IO_SWITCH(NULL, 0),
2664 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2667 /* add dynamic controls */
2668 static struct snd_kcontrol_new *
2669 stac_control_new(struct sigmatel_spec *spec,
2670 struct snd_kcontrol_new *ktemp,
2673 struct snd_kcontrol_new *knew;
2675 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2676 knew = snd_array_new(&spec->kctls);
2680 knew->name = kstrdup(name, GFP_KERNEL);
2683 memset(knew, 0, sizeof(*knew));
2684 spec->kctls.alloced--;
2690 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2691 struct snd_kcontrol_new *ktemp,
2692 int idx, const char *name,
2695 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2699 knew->private_value = val;
2703 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2704 int type, int idx, const char *name,
2707 return stac92xx_add_control_temp(spec,
2708 &stac92xx_control_templates[type],
2713 /* add dynamic controls */
2714 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2715 const char *name, unsigned long val)
2717 return stac92xx_add_control_idx(spec, type, 0, name, val);
2720 static struct snd_kcontrol_new stac_input_src_temp = {
2721 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2722 .name = "Input Source",
2723 .info = stac92xx_mux_enum_info,
2724 .get = stac92xx_mux_enum_get,
2725 .put = stac92xx_mux_enum_put,
2728 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2730 struct snd_kcontrol_new *knew;
2731 struct hda_input_mux *imux = &spec->private_imux;
2733 if (!spec->num_adcs || imux->num_items <= 1)
2734 return 0; /* no need for input source control */
2735 knew = stac_control_new(spec, &stac_input_src_temp,
2736 stac_input_src_temp.name);
2739 knew->count = spec->num_adcs;
2743 /* check whether the line-input can be used as line-out */
2744 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2746 struct sigmatel_spec *spec = codec->spec;
2747 struct auto_pin_cfg *cfg = &spec->autocfg;
2749 unsigned int pincap;
2751 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2753 nid = cfg->input_pins[AUTO_PIN_LINE];
2754 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2755 if (pincap & AC_PINCAP_OUT)
2760 /* check whether the mic-input can be used as line-out */
2761 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2763 struct sigmatel_spec *spec = codec->spec;
2764 struct auto_pin_cfg *cfg = &spec->autocfg;
2765 unsigned int def_conf, pincap;
2766 unsigned int mic_pin;
2768 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2770 mic_pin = AUTO_PIN_MIC;
2772 hda_nid_t nid = cfg->input_pins[mic_pin];
2773 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2774 /* some laptops have an internal analog microphone
2775 * which can't be used as a output */
2776 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2777 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
2778 if (pincap & AC_PINCAP_OUT)
2781 if (mic_pin == AUTO_PIN_MIC)
2782 mic_pin = AUTO_PIN_FRONT_MIC;
2789 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2793 for (i = 0; i < spec->multiout.num_dacs; i++) {
2794 if (spec->multiout.dac_nids[i] == nid)
2801 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2804 if (is_in_dac_nids(spec, nid))
2806 for (i = 0; i < spec->autocfg.hp_outs; i++)
2807 if (spec->hp_dacs[i] == nid)
2809 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2810 if (spec->speaker_dacs[i] == nid)
2815 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2817 struct sigmatel_spec *spec = codec->spec;
2819 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2820 unsigned int wcaps, wtype;
2822 conn_len = snd_hda_get_connections(codec, nid, conn,
2823 HDA_MAX_CONNECTIONS);
2824 for (j = 0; j < conn_len; j++) {
2825 wcaps = snd_hda_param_read(codec, conn[j],
2826 AC_PAR_AUDIO_WIDGET_CAP);
2827 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2828 /* we check only analog outputs */
2829 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2831 /* if this route has a free DAC, assign it */
2832 if (!check_all_dac_nids(spec, conn[j])) {
2834 /* select this DAC in the pin's input mux */
2835 snd_hda_codec_write_cache(codec, nid, 0,
2836 AC_VERB_SET_CONNECT_SEL, j);
2844 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2845 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2848 * Fill in the dac_nids table from the parsed pin configuration
2849 * This function only works when every pin in line_out_pins[]
2850 * contains atleast one DAC in its connection list. Some 92xx
2851 * codecs are not connected directly to a DAC, such as the 9200
2852 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2854 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2856 struct sigmatel_spec *spec = codec->spec;
2857 struct auto_pin_cfg *cfg = &spec->autocfg;
2861 for (i = 0; i < cfg->line_outs; i++) {
2862 nid = cfg->line_out_pins[i];
2863 dac = get_unassigned_dac(codec, nid);
2865 if (spec->multiout.num_dacs > 0) {
2866 /* we have already working output pins,
2867 * so let's drop the broken ones again
2869 cfg->line_outs = spec->multiout.num_dacs;
2872 /* error out, no available DAC found */
2874 "%s: No available DAC for pin 0x%x\n",
2878 add_spec_dacs(spec, dac);
2881 /* add line-in as output */
2882 nid = check_line_out_switch(codec);
2884 dac = get_unassigned_dac(codec, nid);
2886 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2887 nid, cfg->line_outs);
2888 cfg->line_out_pins[cfg->line_outs] = nid;
2890 spec->line_switch = nid;
2891 add_spec_dacs(spec, dac);
2894 /* add mic as output */
2895 nid = check_mic_out_switch(codec);
2897 dac = get_unassigned_dac(codec, nid);
2899 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2900 nid, cfg->line_outs);
2901 cfg->line_out_pins[cfg->line_outs] = nid;
2903 spec->mic_switch = nid;
2904 add_spec_dacs(spec, dac);
2908 for (i = 0; i < cfg->hp_outs; i++) {
2909 nid = cfg->hp_pins[i];
2910 dac = get_unassigned_dac(codec, nid);
2912 if (!spec->multiout.hp_nid)
2913 spec->multiout.hp_nid = dac;
2915 add_spec_extra_dacs(spec, dac);
2917 spec->hp_dacs[i] = dac;
2920 for (i = 0; i < cfg->speaker_outs; i++) {
2921 nid = cfg->speaker_pins[i];
2922 dac = get_unassigned_dac(codec, nid);
2924 add_spec_extra_dacs(spec, dac);
2925 spec->speaker_dacs[i] = dac;
2928 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2929 spec->multiout.num_dacs,
2930 spec->multiout.dac_nids[0],
2931 spec->multiout.dac_nids[1],
2932 spec->multiout.dac_nids[2],
2933 spec->multiout.dac_nids[3],
2934 spec->multiout.dac_nids[4]);
2939 /* create volume control/switch for the given prefx type */
2940 static int create_controls(struct hda_codec *codec, const char *pfx,
2941 hda_nid_t nid, int chs)
2943 struct sigmatel_spec *spec = codec->spec;
2947 if (!spec->check_volume_offset) {
2948 unsigned int caps, step, nums, db_scale;
2949 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2950 step = (caps & AC_AMPCAP_STEP_SIZE) >>
2951 AC_AMPCAP_STEP_SIZE_SHIFT;
2952 step = (step + 1) * 25; /* in .01dB unit */
2953 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
2954 AC_AMPCAP_NUM_STEPS_SHIFT;
2955 db_scale = nums * step;
2956 /* if dB scale is over -64dB, and finer enough,
2957 * let's reduce it to half
2959 if (db_scale > 6400 && nums >= 0x1f)
2960 spec->volume_offset = nums / 2;
2961 spec->check_volume_offset = 1;
2964 sprintf(name, "%s Playback Volume", pfx);
2965 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2966 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
2967 spec->volume_offset));
2970 sprintf(name, "%s Playback Switch", pfx);
2971 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2972 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2978 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2980 if (spec->multiout.num_dacs > 4) {
2981 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2984 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2985 spec->multiout.num_dacs++;
2990 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2993 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
2994 if (!spec->multiout.extra_out_nid[i]) {
2995 spec->multiout.extra_out_nid[i] = nid;
2999 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3003 static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid)
3007 if (spec->autocfg.line_outs != 1)
3009 if (spec->multiout.hp_nid == nid)
3011 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
3012 if (spec->multiout.extra_out_nid[i] == nid)
3017 /* add playback controls from the parsed DAC table */
3018 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3019 const struct auto_pin_cfg *cfg)
3021 struct sigmatel_spec *spec = codec->spec;
3022 static const char *chname[4] = {
3023 "Front", "Surround", NULL /*CLFE*/, "Side"
3027 unsigned int wid_caps;
3029 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) {
3030 nid = spec->multiout.dac_nids[i];
3033 err = create_controls(codec, "Center", nid, 1);
3036 err = create_controls(codec, "LFE", nid, 2);
3040 wid_caps = get_wcaps(codec, nid);
3042 if (wid_caps & AC_WCAP_LR_SWAP) {
3043 err = stac92xx_add_control(spec,
3044 STAC_CTL_WIDGET_CLFE_SWITCH,
3045 "Swap Center/LFE Playback Switch", nid);
3052 const char *name = chname[i];
3053 /* if it's a single DAC, assign a better name */
3054 if (!i && is_unique_dac(spec, nid)) {
3055 switch (cfg->line_out_type) {
3056 case AUTO_PIN_HP_OUT:
3059 case AUTO_PIN_SPEAKER_OUT:
3064 err = create_controls(codec, name, nid, 3);
3070 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3071 err = stac92xx_add_control(spec,
3072 STAC_CTL_WIDGET_HP_SWITCH,
3073 "Headphone as Line Out Switch",
3074 cfg->hp_pins[cfg->hp_outs - 1]);
3079 if (spec->line_switch) {
3080 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3081 "Line In as Output Switch",
3082 spec->line_switch << 8);
3087 if (spec->mic_switch) {
3088 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3089 "Mic as Output Switch",
3090 (spec->mic_switch << 8) | 1);
3098 /* add playback controls for Speaker and HP outputs */
3099 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3100 struct auto_pin_cfg *cfg)
3102 struct sigmatel_spec *spec = codec->spec;
3107 for (i = 0; i < cfg->hp_outs; i++) {
3108 static const char *pfxs[] = {
3109 "Headphone", "Headphone2", "Headphone3",
3111 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3112 if (wid_caps & AC_WCAP_UNSOL_CAP)
3113 spec->hp_detect = 1;
3114 if (nums >= ARRAY_SIZE(pfxs))
3116 nid = spec->hp_dacs[i];
3119 err = create_controls(codec, pfxs[nums++], nid, 3);
3124 for (i = 0; i < cfg->speaker_outs; i++) {
3125 static const char *pfxs[] = {
3126 "Speaker", "External Speaker", "Speaker2",
3128 if (nums >= ARRAY_SIZE(pfxs))
3130 nid = spec->speaker_dacs[i];
3133 err = create_controls(codec, pfxs[nums++], nid, 3);
3140 /* labels for mono mux outputs */
3141 static const char *stac92xx_mono_labels[4] = {
3142 "DAC0", "DAC1", "Mixer", "DAC2"
3145 /* create mono mux for mono out on capable codecs */
3146 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3148 struct sigmatel_spec *spec = codec->spec;
3149 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3151 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3153 num_cons = snd_hda_get_connections(codec,
3156 HDA_MAX_NUM_INPUTS);
3157 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3160 for (i = 0; i < num_cons; i++) {
3161 mono_mux->items[mono_mux->num_items].label =
3162 stac92xx_mono_labels[i];
3163 mono_mux->items[mono_mux->num_items].index = i;
3164 mono_mux->num_items++;
3167 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3168 "Mono Mux", spec->mono_nid);
3171 /* labels for amp mux outputs */
3172 static const char *stac92xx_amp_labels[3] = {
3173 "Front Microphone", "Microphone", "Line In",
3176 /* create amp out controls mux on capable codecs */
3177 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3179 struct sigmatel_spec *spec = codec->spec;
3180 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3183 for (i = 0; i < spec->num_amps; i++) {
3184 amp_mux->items[amp_mux->num_items].label =
3185 stac92xx_amp_labels[i];
3186 amp_mux->items[amp_mux->num_items].index = i;
3187 amp_mux->num_items++;
3190 if (spec->num_amps > 1) {
3191 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3192 "Amp Selector Capture Switch", 0);
3196 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3197 "Amp Capture Volume",
3198 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3202 /* create PC beep volume controls */
3203 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3206 struct sigmatel_spec *spec = codec->spec;
3207 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3210 /* check for mute support for the the amp */
3211 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3212 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3213 "PC Beep Playback Switch",
3214 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3219 /* check to see if there is volume support for the amp */
3220 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3221 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3222 "PC Beep Playback Volume",
3223 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3230 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3231 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3233 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3234 struct snd_ctl_elem_value *ucontrol)
3236 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3237 ucontrol->value.integer.value[0] = codec->beep->enabled;
3241 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3242 struct snd_ctl_elem_value *ucontrol)
3244 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3245 int enabled = !!ucontrol->value.integer.value[0];
3246 if (codec->beep->enabled != enabled) {
3247 codec->beep->enabled = enabled;
3253 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3254 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3255 .info = stac92xx_dig_beep_switch_info,
3256 .get = stac92xx_dig_beep_switch_get,
3257 .put = stac92xx_dig_beep_switch_put,
3260 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3262 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3263 0, "PC Beep Playback Switch", 0);
3267 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3269 struct sigmatel_spec *spec = codec->spec;
3270 int wcaps, nid, i, err = 0;
3272 for (i = 0; i < spec->num_muxes; i++) {
3273 nid = spec->mux_nids[i];
3274 wcaps = get_wcaps(codec, nid);
3276 if (wcaps & AC_WCAP_OUT_AMP) {
3277 err = stac92xx_add_control_idx(spec,
3278 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3279 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3287 static const char *stac92xx_spdif_labels[3] = {
3288 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3291 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3293 struct sigmatel_spec *spec = codec->spec;
3294 struct hda_input_mux *spdif_mux = &spec->private_smux;
3295 const char **labels = spec->spdif_labels;
3297 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3299 num_cons = snd_hda_get_connections(codec,
3302 HDA_MAX_NUM_INPUTS);
3307 labels = stac92xx_spdif_labels;
3309 for (i = 0; i < num_cons; i++) {
3310 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3311 spdif_mux->items[spdif_mux->num_items].index = i;
3312 spdif_mux->num_items++;
3318 /* labels for dmic mux inputs */
3319 static const char *stac92xx_dmic_labels[5] = {
3320 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3321 "Digital Mic 3", "Digital Mic 4"
3324 /* create playback/capture controls for input pins on dmic capable codecs */
3325 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3326 const struct auto_pin_cfg *cfg)
3328 struct sigmatel_spec *spec = codec->spec;
3329 struct hda_input_mux *dimux = &spec->private_dimux;
3330 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3334 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3335 dimux->items[dimux->num_items].index = 0;
3338 for (i = 0; i < spec->num_dmics; i++) {
3343 unsigned int def_conf;
3345 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3346 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3349 nid = spec->dmic_nids[i];
3350 num_cons = snd_hda_get_connections(codec,
3353 HDA_MAX_NUM_INPUTS);
3354 for (j = 0; j < num_cons; j++)
3355 if (con_lst[j] == nid) {
3361 wcaps = get_wcaps(codec, nid) &
3362 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3365 sprintf(name, "%s Capture Volume",
3366 stac92xx_dmic_labels[dimux->num_items]);
3368 err = stac92xx_add_control(spec,
3369 STAC_CTL_WIDGET_VOL,
3371 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3372 (wcaps & AC_WCAP_OUT_AMP) ?
3373 HDA_OUTPUT : HDA_INPUT));
3378 dimux->items[dimux->num_items].label =
3379 stac92xx_dmic_labels[dimux->num_items];
3380 dimux->items[dimux->num_items].index = index;
3387 /* create playback/capture controls for input pins */
3388 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3390 struct sigmatel_spec *spec = codec->spec;
3391 struct hda_input_mux *imux = &spec->private_imux;
3392 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3395 for (i = 0; i < AUTO_PIN_LAST; i++) {
3398 if (!cfg->input_pins[i])
3401 for (j = 0; j < spec->num_muxes; j++) {
3403 num_cons = snd_hda_get_connections(codec,
3406 HDA_MAX_NUM_INPUTS);
3407 for (k = 0; k < num_cons; k++)
3408 if (con_lst[k] == cfg->input_pins[i]) {
3415 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3416 imux->items[imux->num_items].index = index;
3420 if (imux->num_items) {
3422 * Set the current input for the muxes.
3423 * The STAC9221 has two input muxes with identical source
3424 * NID lists. Hopefully this won't get confused.
3426 for (i = 0; i < spec->num_muxes; i++) {
3427 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3428 AC_VERB_SET_CONNECT_SEL,
3429 imux->items[0].index);
3436 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3438 struct sigmatel_spec *spec = codec->spec;
3441 for (i = 0; i < spec->autocfg.line_outs; i++) {
3442 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3443 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3447 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3449 struct sigmatel_spec *spec = codec->spec;
3452 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3454 pin = spec->autocfg.hp_pins[i];
3455 if (pin) /* connect to front */
3456 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3458 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3460 pin = spec->autocfg.speaker_pins[i];
3461 if (pin) /* connect to front */
3462 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3466 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3468 struct sigmatel_spec *spec = codec->spec;
3471 if ((err = snd_hda_parse_pin_def_config(codec,
3473 spec->dmic_nids)) < 0)
3475 if (! spec->autocfg.line_outs)
3476 return 0; /* can't find valid pin config */
3478 /* If we have no real line-out pin and multiple hp-outs, HPs should
3479 * be set up as multi-channel outputs.
3481 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3482 spec->autocfg.hp_outs > 1) {
3483 /* Copy hp_outs to line_outs, backup line_outs in
3484 * speaker_outs so that the following routines can handle
3485 * HP pins as primary outputs.
3487 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3488 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3489 sizeof(spec->autocfg.line_out_pins));
3490 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3491 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3492 sizeof(spec->autocfg.hp_pins));
3493 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3494 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3495 spec->autocfg.hp_outs = 0;
3497 if (spec->autocfg.mono_out_pin) {
3498 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3499 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3500 u32 caps = query_amp_caps(codec,
3501 spec->autocfg.mono_out_pin, dir);
3502 hda_nid_t conn_list[1];
3504 /* get the mixer node and then the mono mux if it exists */
3505 if (snd_hda_get_connections(codec,
3506 spec->autocfg.mono_out_pin, conn_list, 1) &&
3507 snd_hda_get_connections(codec, conn_list[0],
3510 int wcaps = get_wcaps(codec, conn_list[0]);
3511 int wid_type = (wcaps & AC_WCAP_TYPE)
3512 >> AC_WCAP_TYPE_SHIFT;
3513 /* LR swap check, some stac925x have a mux that
3514 * changes the DACs output path instead of the
3517 if (wid_type == AC_WID_AUD_SEL &&
3518 !(wcaps & AC_WCAP_LR_SWAP))
3519 spec->mono_nid = conn_list[0];
3522 hda_nid_t nid = spec->autocfg.mono_out_pin;
3524 /* most mono outs have a least a mute/unmute switch */
3525 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3526 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3527 "Mono Playback Switch",
3528 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3531 /* check for volume support for the amp */
3532 if ((caps & AC_AMPCAP_NUM_STEPS)
3533 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3534 err = stac92xx_add_control(spec,
3535 STAC_CTL_WIDGET_VOL,
3536 "Mono Playback Volume",
3537 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3543 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3547 if (!spec->multiout.num_dacs) {
3548 err = stac92xx_auto_fill_dac_nids(codec);
3551 err = stac92xx_auto_create_multi_out_ctls(codec,
3557 /* setup analog beep controls */
3558 if (spec->anabeep_nid > 0) {
3559 err = stac92xx_auto_create_beep_ctls(codec,
3565 /* setup digital beep controls and input device */
3566 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3567 if (spec->digbeep_nid > 0) {
3568 hda_nid_t nid = spec->digbeep_nid;
3571 err = stac92xx_auto_create_beep_ctls(codec, nid);
3574 err = snd_hda_attach_beep_device(codec, nid);
3577 /* if no beep switch is available, make its own one */
3578 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3580 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3581 err = stac92xx_beep_switch_ctl(codec);
3588 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3593 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3598 if (spec->mono_nid > 0) {
3599 err = stac92xx_auto_create_mono_output_ctls(codec);
3603 if (spec->num_amps > 0) {
3604 err = stac92xx_auto_create_amp_output_ctls(codec);
3608 if (spec->num_dmics > 0 && !spec->dinput_mux)
3609 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3610 &spec->autocfg)) < 0)
3612 if (spec->num_muxes > 0) {
3613 err = stac92xx_auto_create_mux_input_ctls(codec);
3617 if (spec->num_smuxes > 0) {
3618 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3623 err = stac92xx_add_input_source(spec);
3627 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3628 if (spec->multiout.max_channels > 2)
3629 spec->surr_switch = 1;
3631 if (spec->autocfg.dig_outs)
3632 spec->multiout.dig_out_nid = dig_out;
3633 if (dig_in && spec->autocfg.dig_in_pin)
3634 spec->dig_in_nid = dig_in;
3636 if (spec->kctls.list)
3637 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3639 spec->input_mux = &spec->private_imux;
3640 if (!spec->dinput_mux)
3641 spec->dinput_mux = &spec->private_dimux;
3642 spec->sinput_mux = &spec->private_smux;
3643 spec->mono_mux = &spec->private_mono_mux;
3644 spec->amp_mux = &spec->private_amp_mux;
3648 /* add playback controls for HP output */
3649 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3650 struct auto_pin_cfg *cfg)
3652 struct sigmatel_spec *spec = codec->spec;
3653 hda_nid_t pin = cfg->hp_pins[0];
3654 unsigned int wid_caps;
3659 wid_caps = get_wcaps(codec, pin);
3660 if (wid_caps & AC_WCAP_UNSOL_CAP)
3661 spec->hp_detect = 1;
3666 /* add playback controls for LFE output */
3667 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3668 struct auto_pin_cfg *cfg)
3670 struct sigmatel_spec *spec = codec->spec;
3672 hda_nid_t lfe_pin = 0x0;
3676 * search speaker outs and line outs for a mono speaker pin
3677 * with an amp. If one is found, add LFE controls
3680 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3681 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3682 unsigned int wcaps = get_wcaps(codec, pin);
3683 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3684 if (wcaps == AC_WCAP_OUT_AMP)
3685 /* found a mono speaker with an amp, must be lfe */
3689 /* if speaker_outs is 0, then speakers may be in line_outs */
3690 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3691 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3692 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3693 unsigned int defcfg;
3694 defcfg = snd_hda_codec_get_pincfg(codec, pin);
3695 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3696 unsigned int wcaps = get_wcaps(codec, pin);
3697 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3698 if (wcaps == AC_WCAP_OUT_AMP)
3699 /* found a mono speaker with an amp,
3707 err = create_controls(codec, "LFE", lfe_pin, 1);
3715 static int stac9200_parse_auto_config(struct hda_codec *codec)
3717 struct sigmatel_spec *spec = codec->spec;
3720 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3723 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3726 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3729 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3732 if (spec->num_muxes > 0) {
3733 err = stac92xx_auto_create_mux_input_ctls(codec);
3738 err = stac92xx_add_input_source(spec);
3742 if (spec->autocfg.dig_outs)
3743 spec->multiout.dig_out_nid = 0x05;
3744 if (spec->autocfg.dig_in_pin)
3745 spec->dig_in_nid = 0x04;
3747 if (spec->kctls.list)
3748 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3750 spec->input_mux = &spec->private_imux;
3751 spec->dinput_mux = &spec->private_dimux;
3757 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3758 * funky external mute control using GPIO pins.
3761 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3762 unsigned int dir_mask, unsigned int data)
3764 unsigned int gpiostate, gpiomask, gpiodir;
3766 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3767 AC_VERB_GET_GPIO_DATA, 0);
3768 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3770 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3771 AC_VERB_GET_GPIO_MASK, 0);
3774 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3775 AC_VERB_GET_GPIO_DIRECTION, 0);
3776 gpiodir |= dir_mask;
3778 /* Configure GPIOx as CMOS */
3779 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3781 snd_hda_codec_write(codec, codec->afg, 0,
3782 AC_VERB_SET_GPIO_MASK, gpiomask);
3783 snd_hda_codec_read(codec, codec->afg, 0,
3784 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3788 snd_hda_codec_read(codec, codec->afg, 0,
3789 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3792 static int stac92xx_add_jack(struct hda_codec *codec,
3793 hda_nid_t nid, int type)
3795 #ifdef CONFIG_SND_JACK
3796 struct sigmatel_spec *spec = codec->spec;
3797 struct sigmatel_jack *jack;
3798 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
3799 int connectivity = get_defcfg_connect(def_conf);
3802 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3805 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3806 jack = snd_array_new(&spec->jacks);
3812 sprintf(name, "%s at %s %s Jack",
3813 snd_hda_get_jack_type(def_conf),
3814 snd_hda_get_jack_connectivity(def_conf),
3815 snd_hda_get_jack_location(def_conf));
3817 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
3823 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3824 unsigned char type, int data)
3826 struct sigmatel_event *event;
3828 snd_array_init(&spec->events, sizeof(*event), 32);
3829 event = snd_array_new(&spec->events);
3834 event->tag = spec->events.used;
3840 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3841 hda_nid_t nid, unsigned char type)
3843 struct sigmatel_spec *spec = codec->spec;
3844 struct sigmatel_event *event = spec->events.list;
3847 for (i = 0; i < spec->events.used; i++, event++) {
3848 if (event->nid == nid && event->type == type)
3854 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
3857 struct sigmatel_spec *spec = codec->spec;
3858 struct sigmatel_event *event = spec->events.list;
3861 for (i = 0; i < spec->events.used; i++, event++) {
3862 if (event->tag == tag)
3868 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3871 struct sigmatel_event *event;
3874 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
3876 event = stac_get_event(codec, nid, type);
3880 tag = stac_add_event(codec->spec, nid, type, 0);
3883 snd_hda_codec_write_cache(codec, nid, 0,
3884 AC_VERB_SET_UNSOLICITED_ENABLE,
3888 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3891 for (i = 0; i < cfg->hp_outs; i++)
3892 if (cfg->hp_pins[i] == nid)
3893 return 1; /* nid is a HP-Out */
3895 return 0; /* nid is not a HP-Out */
3898 static void stac92xx_power_down(struct hda_codec *codec)
3900 struct sigmatel_spec *spec = codec->spec;
3902 /* power down inactive DACs */
3904 for (dac = spec->dac_list; *dac; dac++)
3905 if (!check_all_dac_nids(spec, *dac))
3906 snd_hda_codec_write(codec, *dac, 0,
3907 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3910 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3913 static int stac92xx_init(struct hda_codec *codec)
3915 struct sigmatel_spec *spec = codec->spec;
3916 struct auto_pin_cfg *cfg = &spec->autocfg;
3920 snd_hda_sequence_write(codec, spec->init);
3922 /* power down adcs initially */
3923 if (spec->powerdown_adcs)
3924 for (i = 0; i < spec->num_adcs; i++)
3925 snd_hda_codec_write(codec,
3926 spec->adc_nids[i], 0,
3927 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3930 gpio = spec->gpio_data;
3931 /* turn on EAPD statically when spec->eapd_switch isn't set.
3932 * otherwise, unsol event will turn it on/off dynamically
3934 if (!spec->eapd_switch)
3935 gpio |= spec->eapd_mask;
3936 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3939 if (spec->hp_detect) {
3940 /* Enable unsolicited responses on the HP widget */
3941 for (i = 0; i < cfg->hp_outs; i++) {
3942 hda_nid_t nid = cfg->hp_pins[i];
3943 enable_pin_detect(codec, nid, STAC_HP_EVENT);
3945 /* force to enable the first line-out; the others are set up
3948 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3950 /* fake event to set up pins */
3951 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
3954 stac92xx_auto_init_multi_out(codec);
3955 stac92xx_auto_init_hp_out(codec);
3956 for (i = 0; i < cfg->hp_outs; i++)
3957 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
3959 for (i = 0; i < AUTO_PIN_LAST; i++) {
3960 hda_nid_t nid = cfg->input_pins[i];
3962 unsigned int pinctl, conf;
3963 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3964 /* for mic pins, force to initialize */
3965 pinctl = stac92xx_get_vref(codec, nid);
3966 pinctl |= AC_PINCTL_IN_EN;
3967 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3969 pinctl = snd_hda_codec_read(codec, nid, 0,
3970 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3971 /* if PINCTL already set then skip */
3972 if (!(pinctl & AC_PINCTL_IN_EN)) {
3973 pinctl |= AC_PINCTL_IN_EN;
3974 stac92xx_auto_set_pinctl(codec, nid,
3978 conf = snd_hda_codec_get_pincfg(codec, nid);
3979 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
3980 enable_pin_detect(codec, nid,
3982 stac_issue_unsol_event(codec, nid,
3987 for (i = 0; i < spec->num_dmics; i++)
3988 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3990 if (cfg->dig_out_pins[0])
3991 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
3993 if (cfg->dig_in_pin)
3994 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3996 for (i = 0; i < spec->num_pwrs; i++) {
3997 hda_nid_t nid = spec->pwr_nids[i];
3998 int pinctl, def_conf;
4000 /* power on when no jack detection is available */
4001 if (!spec->hp_detect) {
4002 stac_toggle_power_map(codec, nid, 1);
4006 if (is_nid_hp_pin(cfg, nid))
4007 continue; /* already has an unsol event */
4009 pinctl = snd_hda_codec_read(codec, nid, 0,
4010 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4011 /* outputs are only ports capable of power management
4012 * any attempts on powering down a input port cause the
4013 * referenced VREF to act quirky.
4015 if (pinctl & AC_PINCTL_IN_EN) {
4016 stac_toggle_power_map(codec, nid, 1);
4019 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4020 def_conf = get_defcfg_connect(def_conf);
4021 /* skip any ports that don't have jacks since presence
4022 * detection is useless */
4023 if (def_conf != AC_JACK_PORT_COMPLEX) {
4024 if (def_conf != AC_JACK_PORT_NONE)
4025 stac_toggle_power_map(codec, nid, 1);
4028 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4029 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4030 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4034 stac92xx_power_down(codec);
4038 static void stac92xx_free_jacks(struct hda_codec *codec)
4040 #ifdef CONFIG_SND_JACK
4041 /* free jack instances manually when clearing/reconfiguring */
4042 struct sigmatel_spec *spec = codec->spec;
4043 if (!codec->bus->shutdown && spec->jacks.list) {
4044 struct sigmatel_jack *jacks = spec->jacks.list;
4046 for (i = 0; i < spec->jacks.used; i++)
4047 snd_device_free(codec->bus->card, &jacks[i].jack);
4049 snd_array_free(&spec->jacks);
4053 static void stac92xx_free_kctls(struct hda_codec *codec)
4055 struct sigmatel_spec *spec = codec->spec;
4057 if (spec->kctls.list) {
4058 struct snd_kcontrol_new *kctl = spec->kctls.list;
4060 for (i = 0; i < spec->kctls.used; i++)
4061 kfree(kctl[i].name);
4063 snd_array_free(&spec->kctls);
4066 static void stac92xx_free(struct hda_codec *codec)
4068 struct sigmatel_spec *spec = codec->spec;
4073 stac92xx_free_jacks(codec);
4074 snd_array_free(&spec->events);
4077 snd_hda_detach_beep_device(codec);
4080 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4083 unsigned int old_ctl, pin_ctl;
4085 pin_ctl = snd_hda_codec_read(codec, nid,
4086 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4088 if (pin_ctl & AC_PINCTL_IN_EN) {
4090 * we need to check the current set-up direction of
4091 * shared input pins since they can be switched via
4092 * "xxx as Output" mixer switch
4094 struct sigmatel_spec *spec = codec->spec;
4095 if (nid == spec->line_switch || nid == spec->mic_switch)
4100 /* if setting pin direction bits, clear the current
4101 direction bits first */
4102 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4103 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4106 if (old_ctl != pin_ctl)
4107 snd_hda_codec_write_cache(codec, nid, 0,
4108 AC_VERB_SET_PIN_WIDGET_CONTROL,
4112 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4115 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4116 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4118 snd_hda_codec_write_cache(codec, nid, 0,
4119 AC_VERB_SET_PIN_WIDGET_CONTROL,
4123 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4127 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
4133 /* return non-zero if the hp-pin of the given array index isn't
4134 * a jack-detection target
4136 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4138 struct auto_pin_cfg *cfg = &spec->autocfg;
4140 /* ignore sensing of shared line and mic jacks */
4141 if (cfg->hp_pins[i] == spec->line_switch)
4143 if (cfg->hp_pins[i] == spec->mic_switch)
4145 /* ignore if the pin is set as line-out */
4146 if (cfg->hp_pins[i] == spec->hp_switch)
4151 static void stac92xx_hp_detect(struct hda_codec *codec)
4153 struct sigmatel_spec *spec = codec->spec;
4154 struct auto_pin_cfg *cfg = &spec->autocfg;
4158 if (spec->gpio_mute)
4159 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4160 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4162 for (i = 0; i < cfg->hp_outs; i++) {
4165 if (no_hp_sensing(spec, i))
4167 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4169 unsigned int pinctl;
4170 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4171 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4172 if (pinctl & AC_PINCTL_IN_EN)
4173 presence = 0; /* mic- or line-input */
4178 /* disable lineouts */
4179 if (spec->hp_switch)
4180 stac92xx_reset_pinctl(codec, spec->hp_switch,
4182 for (i = 0; i < cfg->line_outs; i++)
4183 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4185 for (i = 0; i < cfg->speaker_outs; i++)
4186 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4188 if (spec->eapd_mask && spec->eapd_switch)
4189 stac_gpio_set(codec, spec->gpio_mask,
4190 spec->gpio_dir, spec->gpio_data &
4193 /* enable lineouts */
4194 if (spec->hp_switch)
4195 stac92xx_set_pinctl(codec, spec->hp_switch,
4197 for (i = 0; i < cfg->line_outs; i++)
4198 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4200 for (i = 0; i < cfg->speaker_outs; i++)
4201 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4203 if (spec->eapd_mask && spec->eapd_switch)
4204 stac_gpio_set(codec, spec->gpio_mask,
4205 spec->gpio_dir, spec->gpio_data |
4208 /* toggle hp outs */
4209 for (i = 0; i < cfg->hp_outs; i++) {
4210 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4211 if (no_hp_sensing(spec, i))
4214 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4216 /* Resetting the pinctl like below may lead to (a sort of) regressions
4217 * on some devices since they use the HP pin actually for line/speaker
4218 * outs although the default pin config shows a different pin (that is
4219 * wrong and useless).
4221 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4222 * But, disabling the code below just works around it, and I'm too tired of
4223 * bug reports with such devices...
4226 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4231 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4234 struct sigmatel_spec *spec = codec->spec;
4235 unsigned int idx, val;
4237 for (idx = 0; idx < spec->num_pwrs; idx++) {
4238 if (spec->pwr_nids[idx] == nid)
4241 if (idx >= spec->num_pwrs)
4244 /* several codecs have two power down bits */
4245 if (spec->pwr_mapping)
4246 idx = spec->pwr_mapping[idx];
4250 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4256 /* power down unused output ports */
4257 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4260 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4262 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4265 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4267 struct sigmatel_spec *spec = codec->spec;
4268 struct sigmatel_jack *jacks = spec->jacks.list;
4272 for (i = 0; i < spec->jacks.used; i++) {
4273 if (jacks->nid == nid) {
4274 unsigned int pin_ctl =
4275 snd_hda_codec_read(codec, nid,
4276 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4278 int type = jacks->type;
4279 if (type == (SND_JACK_LINEOUT
4280 | SND_JACK_HEADPHONE))
4281 type = (pin_ctl & AC_PINCTL_HP_EN)
4282 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4283 snd_jack_report(jacks->jack,
4284 get_pin_presence(codec, nid)
4292 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4295 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4298 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4301 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4303 struct sigmatel_spec *spec = codec->spec;
4304 struct sigmatel_event *event;
4307 tag = (res >> 26) & 0x7f;
4308 event = stac_get_event_from_tag(codec, tag);
4312 switch (event->type) {
4314 stac92xx_hp_detect(codec);
4316 case STAC_INSERT_EVENT:
4317 case STAC_PWR_EVENT:
4318 if (spec->num_pwrs > 0)
4319 stac92xx_pin_sense(codec, event->nid);
4320 stac92xx_report_jack(codec, event->nid);
4322 case STAC_VREF_EVENT:
4323 data = snd_hda_codec_read(codec, codec->afg, 0,
4324 AC_VERB_GET_GPIO_DATA, 0);
4325 /* toggle VREF state based on GPIOx status */
4326 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4327 !!(data & (1 << event->data)));
4332 #ifdef CONFIG_PROC_FS
4333 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4334 struct hda_codec *codec, hda_nid_t nid)
4336 if (nid == codec->afg)
4337 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4338 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4341 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4342 struct hda_codec *codec,
4345 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4346 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4349 /* stac92hd71bxx, stac92hd73xx */
4350 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4351 struct hda_codec *codec, hda_nid_t nid)
4353 stac92hd_proc_hook(buffer, codec, nid);
4354 if (nid == codec->afg)
4355 analog_loop_proc_hook(buffer, codec, 0xfa0);
4358 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4359 struct hda_codec *codec, hda_nid_t nid)
4361 if (nid == codec->afg)
4362 analog_loop_proc_hook(buffer, codec, 0xfe0);
4365 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4366 struct hda_codec *codec, hda_nid_t nid)
4368 if (nid == codec->afg)
4369 analog_loop_proc_hook(buffer, codec, 0xfeb);
4372 #define stac92hd_proc_hook NULL
4373 #define stac92hd7x_proc_hook NULL
4374 #define stac9205_proc_hook NULL
4375 #define stac927x_proc_hook NULL
4378 #ifdef SND_HDA_NEEDS_RESUME
4379 static int stac92xx_resume(struct hda_codec *codec)
4381 struct sigmatel_spec *spec = codec->spec;
4383 stac92xx_init(codec);
4384 snd_hda_codec_resume_amp(codec);
4385 snd_hda_codec_resume_cache(codec);
4386 /* fake event to set up pins again to override cached values */
4387 if (spec->hp_detect)
4388 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4393 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4395 struct sigmatel_spec *spec = codec->spec;
4396 if (spec->eapd_mask)
4397 stac_gpio_set(codec, spec->gpio_mask,
4398 spec->gpio_dir, spec->gpio_data &
4404 static struct hda_codec_ops stac92xx_patch_ops = {
4405 .build_controls = stac92xx_build_controls,
4406 .build_pcms = stac92xx_build_pcms,
4407 .init = stac92xx_init,
4408 .free = stac92xx_free,
4409 .unsol_event = stac92xx_unsol_event,
4410 #ifdef SND_HDA_NEEDS_RESUME
4411 .suspend = stac92xx_suspend,
4412 .resume = stac92xx_resume,
4416 static int patch_stac9200(struct hda_codec *codec)
4418 struct sigmatel_spec *spec;
4421 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4426 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4427 spec->pin_nids = stac9200_pin_nids;
4428 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4431 if (spec->board_config < 0)
4432 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4434 stac92xx_set_config_regs(codec,
4435 stac9200_brd_tbl[spec->board_config]);
4437 spec->multiout.max_channels = 2;
4438 spec->multiout.num_dacs = 1;
4439 spec->multiout.dac_nids = stac9200_dac_nids;
4440 spec->adc_nids = stac9200_adc_nids;
4441 spec->mux_nids = stac9200_mux_nids;
4442 spec->num_muxes = 1;
4443 spec->num_dmics = 0;
4447 if (spec->board_config == STAC_9200_M4 ||
4448 spec->board_config == STAC_9200_M4_2 ||
4449 spec->board_config == STAC_9200_OQO)
4450 spec->init = stac9200_eapd_init;
4452 spec->init = stac9200_core_init;
4453 spec->mixer = stac9200_mixer;
4455 if (spec->board_config == STAC_9200_PANASONIC) {
4456 spec->gpio_mask = spec->gpio_dir = 0x09;
4457 spec->gpio_data = 0x00;
4460 err = stac9200_parse_auto_config(codec);
4462 stac92xx_free(codec);
4466 /* CF-74 has no headphone detection, and the driver should *NOT*
4467 * do detection and HP/speaker toggle because the hardware does it.
4469 if (spec->board_config == STAC_9200_PANASONIC)
4470 spec->hp_detect = 0;
4472 codec->patch_ops = stac92xx_patch_ops;
4477 static int patch_stac925x(struct hda_codec *codec)
4479 struct sigmatel_spec *spec;
4482 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4487 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4488 spec->pin_nids = stac925x_pin_nids;
4490 /* Check first for codec ID */
4491 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4494 stac925x_codec_id_cfg_tbl);
4496 /* Now checks for PCI ID, if codec ID is not found */
4497 if (spec->board_config < 0)
4498 spec->board_config = snd_hda_check_board_config(codec,
4503 if (spec->board_config < 0)
4504 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4505 "using BIOS defaults\n");
4507 stac92xx_set_config_regs(codec,
4508 stac925x_brd_tbl[spec->board_config]);
4510 spec->multiout.max_channels = 2;
4511 spec->multiout.num_dacs = 1;
4512 spec->multiout.dac_nids = stac925x_dac_nids;
4513 spec->adc_nids = stac925x_adc_nids;
4514 spec->mux_nids = stac925x_mux_nids;
4515 spec->num_muxes = 1;
4518 switch (codec->vendor_id) {
4519 case 0x83847632: /* STAC9202 */
4520 case 0x83847633: /* STAC9202D */
4521 case 0x83847636: /* STAC9251 */
4522 case 0x83847637: /* STAC9251D */
4523 spec->num_dmics = STAC925X_NUM_DMICS;
4524 spec->dmic_nids = stac925x_dmic_nids;
4525 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4526 spec->dmux_nids = stac925x_dmux_nids;
4529 spec->num_dmics = 0;
4533 spec->init = stac925x_core_init;
4534 spec->mixer = stac925x_mixer;
4536 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4538 if (spec->board_config < 0) {
4539 printk(KERN_WARNING "hda_codec: No auto-config is "
4540 "available, default to model=ref\n");
4541 spec->board_config = STAC_925x_REF;
4547 stac92xx_free(codec);
4551 codec->patch_ops = stac92xx_patch_ops;
4556 static struct hda_input_mux stac92hd73xx_dmux = {
4559 { "Analog Inputs", 0x0b },
4560 { "Digital Mic 1", 0x09 },
4561 { "Digital Mic 2", 0x0a },
4566 static int patch_stac92hd73xx(struct hda_codec *codec)
4568 struct sigmatel_spec *spec;
4569 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4573 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4578 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4579 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4580 spec->pin_nids = stac92hd73xx_pin_nids;
4581 spec->board_config = snd_hda_check_board_config(codec,
4582 STAC_92HD73XX_MODELS,
4583 stac92hd73xx_models,
4584 stac92hd73xx_cfg_tbl);
4586 if (spec->board_config < 0)
4587 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4588 " STAC92HD73XX, using BIOS defaults\n");
4590 stac92xx_set_config_regs(codec,
4591 stac92hd73xx_brd_tbl[spec->board_config]);
4593 num_dacs = snd_hda_get_connections(codec, 0x0a,
4594 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4596 if (num_dacs < 3 || num_dacs > 5) {
4597 printk(KERN_WARNING "hda_codec: Could not determine "
4598 "number of channels defaulting to DAC count\n");
4599 num_dacs = STAC92HD73_DAC_COUNT;
4602 case 0x3: /* 6 Channel */
4603 spec->mixer = stac92hd73xx_6ch_mixer;
4604 spec->init = stac92hd73xx_6ch_core_init;
4606 case 0x4: /* 8 Channel */
4607 spec->mixer = stac92hd73xx_8ch_mixer;
4608 spec->init = stac92hd73xx_8ch_core_init;
4610 case 0x5: /* 10 Channel */
4611 spec->mixer = stac92hd73xx_10ch_mixer;
4612 spec->init = stac92hd73xx_10ch_core_init;
4614 spec->multiout.dac_nids = spec->dac_nids;
4616 spec->aloopback_mask = 0x01;
4617 spec->aloopback_shift = 8;
4619 spec->digbeep_nid = 0x1c;
4620 spec->mux_nids = stac92hd73xx_mux_nids;
4621 spec->adc_nids = stac92hd73xx_adc_nids;
4622 spec->dmic_nids = stac92hd73xx_dmic_nids;
4623 spec->dmux_nids = stac92hd73xx_dmux_nids;
4624 spec->smux_nids = stac92hd73xx_smux_nids;
4625 spec->amp_nids = stac92hd73xx_amp_nids;
4626 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4628 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4629 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4630 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4631 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4632 sizeof(stac92hd73xx_dmux));
4634 switch (spec->board_config) {
4636 spec->init = dell_eq_core_init;
4638 case STAC_DELL_M6_AMIC:
4639 case STAC_DELL_M6_DMIC:
4640 case STAC_DELL_M6_BOTH:
4641 spec->num_smuxes = 0;
4642 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4643 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4644 spec->eapd_switch = 0;
4647 if (spec->board_config != STAC_DELL_EQ)
4648 spec->init = dell_m6_core_init;
4649 switch (spec->board_config) {
4650 case STAC_DELL_M6_AMIC: /* Analog Mics */
4651 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4652 spec->num_dmics = 0;
4653 spec->private_dimux.num_items = 1;
4655 case STAC_DELL_M6_DMIC: /* Digital Mics */
4656 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
4657 spec->num_dmics = 1;
4658 spec->private_dimux.num_items = 2;
4660 case STAC_DELL_M6_BOTH: /* Both */
4661 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4662 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
4663 spec->num_dmics = 1;
4664 spec->private_dimux.num_items = 2;
4669 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4670 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4671 spec->eapd_switch = 1;
4673 if (spec->board_config > STAC_92HD73XX_REF) {
4674 /* GPIO0 High = Enable EAPD */
4675 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4676 spec->gpio_data = 0x01;
4678 spec->dinput_mux = &spec->private_dimux;
4680 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4681 spec->pwr_nids = stac92hd73xx_pwr_nids;
4683 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
4686 if (spec->board_config < 0) {
4687 printk(KERN_WARNING "hda_codec: No auto-config is "
4688 "available, default to model=ref\n");
4689 spec->board_config = STAC_92HD73XX_REF;
4696 stac92xx_free(codec);
4700 if (spec->board_config == STAC_92HD73XX_NO_JD)
4701 spec->hp_detect = 0;
4703 codec->patch_ops = stac92xx_patch_ops;
4705 codec->proc_widget_hook = stac92hd7x_proc_hook;
4710 static struct hda_input_mux stac92hd83xxx_dmux = {
4713 { "Analog Inputs", 0x03 },
4714 { "Digital Mic 1", 0x04 },
4715 { "Digital Mic 2", 0x05 },
4719 static int patch_stac92hd83xxx(struct hda_codec *codec)
4721 struct sigmatel_spec *spec;
4722 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
4727 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4732 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
4733 spec->mono_nid = 0x19;
4734 spec->digbeep_nid = 0x21;
4735 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4736 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4737 spec->adc_nids = stac92hd83xxx_adc_nids;
4738 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4739 spec->amp_nids = stac92hd83xxx_amp_nids;
4740 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4741 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4742 spec->multiout.dac_nids = spec->dac_nids;
4744 spec->init = stac92hd83xxx_core_init;
4745 spec->mixer = stac92hd83xxx_mixer;
4746 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4747 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4748 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4749 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
4750 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4751 spec->dinput_mux = &stac92hd83xxx_dmux;
4752 spec->pin_nids = stac92hd83xxx_pin_nids;
4753 spec->board_config = snd_hda_check_board_config(codec,
4754 STAC_92HD83XXX_MODELS,
4755 stac92hd83xxx_models,
4756 stac92hd83xxx_cfg_tbl);
4758 if (spec->board_config < 0)
4759 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4760 " STAC92HD83XXX, using BIOS defaults\n");
4762 stac92xx_set_config_regs(codec,
4763 stac92hd83xxx_brd_tbl[spec->board_config]);
4765 switch (codec->vendor_id) {
4768 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
4774 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4776 if (spec->board_config < 0) {
4777 printk(KERN_WARNING "hda_codec: No auto-config is "
4778 "available, default to model=ref\n");
4779 spec->board_config = STAC_92HD83XXX_REF;
4786 stac92xx_free(codec);
4790 switch (spec->board_config) {
4799 num_dacs = snd_hda_get_connections(codec, nid,
4800 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4802 /* set port X to select the last DAC
4804 snd_hda_codec_write_cache(codec, nid, 0,
4805 AC_VERB_SET_CONNECT_SEL, num_dacs);
4807 codec->patch_ops = stac92xx_patch_ops;
4809 codec->proc_widget_hook = stac92hd_proc_hook;
4814 static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
4817 { "Analog Inputs", 0x00 },
4818 { "Digital Mic 1", 0x02 },
4819 { "Digital Mic 2", 0x03 },
4823 static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
4826 { "Analog Inputs", 0x00 },
4828 { "Digital Mic 1", 0x02 },
4829 { "Digital Mic 2", 0x03 },
4833 /* get the pin connection (fixed, none, etc) */
4834 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4836 struct sigmatel_spec *spec = codec->spec;
4839 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4840 return get_defcfg_connect(cfg);
4843 static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
4844 hda_nid_t *nids, int num_nids)
4846 struct sigmatel_spec *spec = codec->spec;
4848 unsigned int def_conf;
4850 for (num = 0; num < num_nids; num++) {
4851 for (idx = 0; idx < spec->num_pins; idx++)
4852 if (spec->pin_nids[idx] == nids[num])
4854 if (idx >= spec->num_pins)
4856 def_conf = stac_get_defcfg_connect(codec, idx);
4857 if (def_conf == AC_JACK_PORT_NONE)
4863 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
4866 struct sigmatel_spec *spec = codec->spec;
4869 for (idx = 0; idx < spec->num_pins; idx++)
4870 if (spec->pin_nids[idx] == dig0pin)
4872 if ((idx + 2) >= spec->num_pins)
4876 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
4879 /* dig0pin + dig2pin case */
4880 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
4882 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
4888 static int patch_stac92hd71bxx(struct hda_codec *codec)
4890 struct sigmatel_spec *spec;
4891 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
4893 unsigned int ndmic_nids = 0;
4895 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4900 codec->patch_ops = stac92xx_patch_ops;
4901 spec->num_pins = STAC92HD71BXX_NUM_PINS;
4902 switch (codec->vendor_id) {
4905 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
4909 /* On 92HD75Bx 0x27 isn't a pin nid */
4913 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
4915 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4916 spec->board_config = snd_hda_check_board_config(codec,
4917 STAC_92HD71BXX_MODELS,
4918 stac92hd71bxx_models,
4919 stac92hd71bxx_cfg_tbl);
4921 if (spec->board_config < 0)
4922 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4923 " STAC92HD71BXX, using BIOS defaults\n");
4925 stac92xx_set_config_regs(codec,
4926 stac92hd71bxx_brd_tbl[spec->board_config]);
4928 if (spec->board_config > STAC_92HD71BXX_REF) {
4930 spec->gpio_mask = 0x01;
4931 spec->gpio_dir = 0x01;
4932 spec->gpio_data = 0x01;
4935 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4936 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4938 switch (codec->vendor_id) {
4939 case 0x111d76b6: /* 4 Port without Analog Mixer */
4943 case 0x111d76b4: /* 6 Port without Analog Mixer */
4945 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
4946 sizeof(stac92hd71bxx_dmux_nomixer));
4947 spec->mixer = stac92hd71bxx_mixer;
4948 spec->init = stac92hd71bxx_core_init;
4949 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4950 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
4951 stac92hd71bxx_dmic_nids,
4952 STAC92HD71BXX_NUM_DMICS);
4953 if (spec->num_dmics) {
4954 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4955 spec->dinput_mux = &spec->private_dimux;
4956 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
4959 case 0x111d7608: /* 5 Port with Analog Mixer */
4960 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
4961 sizeof(stac92hd71bxx_dmux_amixer));
4962 spec->private_dimux.num_items--;
4963 switch (spec->board_config) {
4965 /* Enable VREF power saving on GPIO1 detect */
4966 err = stac_add_event(spec, codec->afg,
4967 STAC_VREF_EVENT, 0x02);
4970 snd_hda_codec_write_cache(codec, codec->afg, 0,
4971 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4972 snd_hda_codec_write_cache(codec, codec->afg, 0,
4973 AC_VERB_SET_UNSOLICITED_ENABLE,
4975 spec->gpio_mask |= 0x02;
4978 if ((codec->revision_id & 0xf) == 0 ||
4979 (codec->revision_id & 0xf) == 1)
4980 spec->stream_delay = 40; /* 40 milliseconds */
4982 /* no output amps */
4984 spec->mixer = stac92hd71bxx_analog_mixer;
4985 spec->dinput_mux = &spec->private_dimux;
4988 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4990 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
4991 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
4992 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
4993 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
4994 stac92hd71bxx_dmic_nids,
4995 STAC92HD71BXX_NUM_DMICS - 1);
4996 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4997 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
4999 case 0x111d7603: /* 6 Port with Analog Mixer */
5000 if ((codec->revision_id & 0xf) == 1)
5001 spec->stream_delay = 40; /* 40 milliseconds */
5003 /* no output amps */
5007 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5008 sizeof(stac92hd71bxx_dmux_amixer));
5009 spec->dinput_mux = &spec->private_dimux;
5010 spec->mixer = stac92hd71bxx_analog_mixer;
5011 spec->init = stac92hd71bxx_analog_core_init;
5012 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5013 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5014 stac92hd71bxx_dmic_nids,
5015 STAC92HD71BXX_NUM_DMICS);
5016 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5017 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5020 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5021 snd_hda_sequence_write_cache(codec, unmute_init);
5023 spec->aloopback_mask = 0x50;
5024 spec->aloopback_shift = 0;
5026 spec->powerdown_adcs = 1;
5027 spec->digbeep_nid = 0x26;
5028 spec->mux_nids = stac92hd71bxx_mux_nids;
5029 spec->adc_nids = stac92hd71bxx_adc_nids;
5030 spec->smux_nids = stac92hd71bxx_smux_nids;
5031 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5033 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5034 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5035 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5037 switch (spec->board_config) {
5039 /* enable internal microphone */
5040 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5041 stac92xx_auto_set_pinctl(codec, 0x0e,
5042 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5044 case STAC_DELL_M4_2:
5045 spec->num_dmics = 0;
5046 spec->num_smuxes = 0;
5047 spec->num_dmuxes = 0;
5049 case STAC_DELL_M4_1:
5050 case STAC_DELL_M4_3:
5051 spec->num_dmics = 1;
5052 spec->num_smuxes = 0;
5053 spec->num_dmuxes = 0;
5056 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5057 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5061 spec->multiout.dac_nids = spec->dac_nids;
5062 if (spec->dinput_mux)
5063 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
5065 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5067 if (spec->board_config < 0) {
5068 printk(KERN_WARNING "hda_codec: No auto-config is "
5069 "available, default to model=ref\n");
5070 spec->board_config = STAC_92HD71BXX_REF;
5077 stac92xx_free(codec);
5081 codec->proc_widget_hook = stac92hd7x_proc_hook;
5086 static int patch_stac922x(struct hda_codec *codec)
5088 struct sigmatel_spec *spec;
5091 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5096 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5097 spec->pin_nids = stac922x_pin_nids;
5098 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5101 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5102 spec->gpio_mask = spec->gpio_dir = 0x03;
5103 spec->gpio_data = 0x03;
5104 /* Intel Macs have all same PCI SSID, so we need to check
5105 * codec SSID to distinguish the exact models
5107 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5108 switch (codec->subsystem_id) {
5111 spec->board_config = STAC_INTEL_MAC_V1;
5115 spec->board_config = STAC_INTEL_MAC_V2;
5123 spec->board_config = STAC_INTEL_MAC_V3;
5127 spec->board_config = STAC_INTEL_MAC_V4;
5131 spec->board_config = STAC_INTEL_MAC_V5;
5134 spec->board_config = STAC_INTEL_MAC_V3;
5140 if (spec->board_config < 0)
5141 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5142 "using BIOS defaults\n");
5144 stac92xx_set_config_regs(codec,
5145 stac922x_brd_tbl[spec->board_config]);
5147 spec->adc_nids = stac922x_adc_nids;
5148 spec->mux_nids = stac922x_mux_nids;
5149 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5150 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5151 spec->num_dmics = 0;
5154 spec->init = stac922x_core_init;
5155 spec->mixer = stac922x_mixer;
5157 spec->multiout.dac_nids = spec->dac_nids;
5159 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5161 if (spec->board_config < 0) {
5162 printk(KERN_WARNING "hda_codec: No auto-config is "
5163 "available, default to model=ref\n");
5164 spec->board_config = STAC_D945_REF;
5170 stac92xx_free(codec);
5174 codec->patch_ops = stac92xx_patch_ops;
5176 /* Fix Mux capture level; max to 2 */
5177 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5178 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5179 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5180 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5181 (0 << AC_AMPCAP_MUTE_SHIFT));
5186 static int patch_stac927x(struct hda_codec *codec)
5188 struct sigmatel_spec *spec;
5191 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5196 codec->slave_dig_outs = stac927x_slave_dig_outs;
5197 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5198 spec->pin_nids = stac927x_pin_nids;
5199 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5203 if (spec->board_config < 0)
5204 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5205 "STAC927x, using BIOS defaults\n");
5207 stac92xx_set_config_regs(codec,
5208 stac927x_brd_tbl[spec->board_config]);
5210 spec->digbeep_nid = 0x23;
5211 spec->adc_nids = stac927x_adc_nids;
5212 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5213 spec->mux_nids = stac927x_mux_nids;
5214 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5215 spec->smux_nids = stac927x_smux_nids;
5216 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5217 spec->spdif_labels = stac927x_spdif_labels;
5218 spec->dac_list = stac927x_dac_nids;
5219 spec->multiout.dac_nids = spec->dac_nids;
5221 switch (spec->board_config) {
5224 /* GPIO0 High = Enable EAPD */
5225 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
5226 spec->gpio_data = 0x01;
5227 spec->num_dmics = 0;
5229 spec->init = d965_core_init;
5230 spec->mixer = stac927x_mixer;
5232 case STAC_DELL_BIOS:
5233 switch (codec->subsystem_id) {
5236 /* correct the device field to SPDIF out */
5237 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5240 /* configure the analog microphone on some laptops */
5241 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5242 /* correct the front output jack as a hp out */
5243 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5244 /* correct the front input jack as a mic */
5245 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5248 /* GPIO2 High = Enable EAPD */
5249 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
5250 spec->gpio_data = 0x04;
5251 spec->dmic_nids = stac927x_dmic_nids;
5252 spec->num_dmics = STAC927X_NUM_DMICS;
5254 spec->init = d965_core_init;
5255 spec->mixer = stac927x_mixer;
5256 spec->dmux_nids = stac927x_dmux_nids;
5257 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5260 if (spec->board_config > STAC_D965_REF) {
5261 /* GPIO0 High = Enable EAPD */
5262 spec->eapd_mask = spec->gpio_mask = 0x01;
5263 spec->gpio_dir = spec->gpio_data = 0x01;
5265 spec->num_dmics = 0;
5267 spec->init = stac927x_core_init;
5268 spec->mixer = stac927x_mixer;
5272 spec->aloopback_mask = 0x40;
5273 spec->aloopback_shift = 0;
5274 spec->eapd_switch = 1;
5276 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
5278 if (spec->board_config < 0) {
5279 printk(KERN_WARNING "hda_codec: No auto-config is "
5280 "available, default to model=ref\n");
5281 spec->board_config = STAC_D965_REF;
5287 stac92xx_free(codec);
5291 codec->patch_ops = stac92xx_patch_ops;
5293 codec->proc_widget_hook = stac927x_proc_hook;
5297 * The STAC927x seem to require fairly long delays for certain
5298 * command sequences. With too short delays (even if the answer
5299 * is set to RIRB properly), it results in the silence output
5300 * on some hardwares like Dell.
5302 * The below flag enables the longer delay (see get_response
5305 codec->bus->needs_damn_long_delay = 1;
5307 /* no jack detecion for ref-no-jd model */
5308 if (spec->board_config == STAC_D965_REF_NO_JD)
5309 spec->hp_detect = 0;
5314 static int patch_stac9205(struct hda_codec *codec)
5316 struct sigmatel_spec *spec;
5319 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5324 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
5325 spec->pin_nids = stac9205_pin_nids;
5326 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5330 if (spec->board_config < 0)
5331 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5333 stac92xx_set_config_regs(codec,
5334 stac9205_brd_tbl[spec->board_config]);
5336 spec->digbeep_nid = 0x23;
5337 spec->adc_nids = stac9205_adc_nids;
5338 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
5339 spec->mux_nids = stac9205_mux_nids;
5340 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
5341 spec->smux_nids = stac9205_smux_nids;
5342 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
5343 spec->dmic_nids = stac9205_dmic_nids;
5344 spec->num_dmics = STAC9205_NUM_DMICS;
5345 spec->dmux_nids = stac9205_dmux_nids;
5346 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
5349 spec->init = stac9205_core_init;
5350 spec->mixer = stac9205_mixer;
5352 spec->aloopback_mask = 0x40;
5353 spec->aloopback_shift = 0;
5354 /* Turn on/off EAPD per HP plugging */
5355 if (spec->board_config != STAC_9205_EAPD)
5356 spec->eapd_switch = 1;
5357 spec->multiout.dac_nids = spec->dac_nids;
5359 switch (spec->board_config){
5360 case STAC_9205_DELL_M43:
5361 /* Enable SPDIF in/out */
5362 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5363 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
5365 /* Enable unsol response for GPIO4/Dock HP connection */
5366 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5369 snd_hda_codec_write_cache(codec, codec->afg, 0,
5370 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5371 snd_hda_codec_write_cache(codec, codec->afg, 0,
5372 AC_VERB_SET_UNSOLICITED_ENABLE,
5375 spec->gpio_dir = 0x0b;
5376 spec->eapd_mask = 0x01;
5377 spec->gpio_mask = 0x1b;
5378 spec->gpio_mute = 0x10;
5379 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5382 spec->gpio_data = 0x01;
5385 /* SPDIF-In enabled */
5388 /* GPIO0 High = EAPD */
5389 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5390 spec->gpio_data = 0x01;
5394 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5396 if (spec->board_config < 0) {
5397 printk(KERN_WARNING "hda_codec: No auto-config is "
5398 "available, default to model=ref\n");
5399 spec->board_config = STAC_9205_REF;
5405 stac92xx_free(codec);
5409 codec->patch_ops = stac92xx_patch_ops;
5411 codec->proc_widget_hook = stac9205_proc_hook;
5420 static struct hda_verb stac9872_core_init[] = {
5421 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5426 static struct snd_kcontrol_new stac9872_mixer[] = {
5427 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5428 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5432 static hda_nid_t stac9872_pin_nids[] = {
5433 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5437 static hda_nid_t stac9872_adc_nids[] = {
5441 static hda_nid_t stac9872_mux_nids[] = {
5445 static int patch_stac9872(struct hda_codec *codec)
5447 struct sigmatel_spec *spec;
5450 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5455 #if 0 /* no model right now */
5456 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5461 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5462 spec->pin_nids = stac9872_pin_nids;
5463 spec->multiout.dac_nids = spec->dac_nids;
5464 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5465 spec->adc_nids = stac9872_adc_nids;
5466 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5467 spec->mux_nids = stac9872_mux_nids;
5468 spec->mixer = stac9872_mixer;
5469 spec->init = stac9872_core_init;
5471 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5473 stac92xx_free(codec);
5476 spec->input_mux = &spec->private_imux;
5477 codec->patch_ops = stac92xx_patch_ops;
5485 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5486 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5487 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5488 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5489 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5490 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5491 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5492 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5493 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5494 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5495 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5496 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5497 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5498 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5499 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5500 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5501 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5502 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5503 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5504 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5505 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5506 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5507 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5508 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5509 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5510 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5511 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5512 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5513 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5514 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5515 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5516 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5517 /* The following does not take into account .id=0x83847661 when subsys =
5518 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5519 * currently not fully supported.
5521 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5522 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5523 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5524 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5525 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5526 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5527 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5528 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5529 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5530 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5531 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5532 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5533 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5534 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5535 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5536 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5537 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5538 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5539 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5540 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5541 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5542 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5543 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5544 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5545 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5546 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5550 MODULE_ALIAS("snd-hda-codec-id:8384*");
5551 MODULE_ALIAS("snd-hda-codec-id:111d*");
5553 MODULE_LICENSE("GPL");
5554 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5556 static struct hda_codec_preset_list sigmatel_list = {
5557 .preset = snd_hda_preset_sigmatel,
5558 .owner = THIS_MODULE,
5561 static int __init patch_sigmatel_init(void)
5563 return snd_hda_add_codec_preset(&sigmatel_list);
5566 static void __exit patch_sigmatel_exit(void)
5568 snd_hda_delete_codec_preset(&sigmatel_list);
5571 module_init(patch_sigmatel_init)
5572 module_exit(patch_sigmatel_exit)