2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include <sound/asoundef.h>
33 #include <sound/jack.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
77 STAC_92HD73XX_NO_JD, /* no jack-detection */
89 STAC_92HD83XXX_PWR_REF,
104 STAC_92HD71BXX_MODELS
130 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
131 * is given, one of the above models will be
132 * chosen according to the subsystem id. */
133 /* for backward compatibility */
150 STAC_D965_REF_NO_JD, /* no jack-detection */
166 struct sigmatel_event {
173 struct sigmatel_jack {
176 struct snd_jack *jack;
179 struct sigmatel_spec {
180 struct snd_kcontrol_new *mixers[4];
181 unsigned int num_mixers;
184 unsigned int eapd_switch: 1;
185 unsigned int surr_switch: 1;
186 unsigned int alt_switch: 1;
187 unsigned int hp_detect: 1;
188 unsigned int spdif_mute: 1;
189 unsigned int check_volume_offset:1;
192 unsigned int eapd_mask;
193 unsigned int gpio_mask;
194 unsigned int gpio_dir;
195 unsigned int gpio_data;
196 unsigned int gpio_mute;
197 unsigned int gpio_led;
200 unsigned int stream_delay;
202 /* analog loopback */
203 struct snd_kcontrol_new *aloopback_ctl;
204 unsigned char aloopback_mask;
205 unsigned char aloopback_shift;
207 /* power management */
208 unsigned int num_pwrs;
209 unsigned int *pwr_mapping;
214 struct snd_array jacks;
217 struct snd_array events;
220 struct hda_input_mux *mono_mux;
221 struct hda_input_mux *amp_mux;
222 unsigned int cur_mmux;
223 struct hda_multi_out multiout;
224 hda_nid_t dac_nids[5];
225 hda_nid_t hp_dacs[5];
226 hda_nid_t speaker_dacs[5];
232 unsigned int num_adcs;
234 unsigned int num_muxes;
235 hda_nid_t *dmic_nids;
236 unsigned int num_dmics;
237 hda_nid_t *dmux_nids;
238 unsigned int num_dmuxes;
239 hda_nid_t *smux_nids;
240 unsigned int num_smuxes;
241 const char **spdif_labels;
243 hda_nid_t dig_in_nid;
245 hda_nid_t anabeep_nid;
246 hda_nid_t digbeep_nid;
250 unsigned int num_pins;
252 /* codec specific stuff */
253 struct hda_verb *init;
254 struct snd_kcontrol_new *mixer;
257 struct hda_input_mux *dinput_mux;
258 unsigned int cur_dmux[2];
259 struct hda_input_mux *input_mux;
260 unsigned int cur_mux[3];
261 struct hda_input_mux *sinput_mux;
262 unsigned int cur_smux[2];
263 unsigned int cur_amux;
265 unsigned int num_amps;
266 unsigned int powerdown_adcs;
269 unsigned int io_switch[2];
270 unsigned int clfe_swap;
271 hda_nid_t line_switch; /* shared line-in for input and output */
272 hda_nid_t mic_switch; /* shared mic-in for input and output */
273 hda_nid_t hp_switch; /* NID of HP as line-out */
274 unsigned int aloopback;
276 struct hda_pcm pcm_rec[2]; /* PCM information */
278 /* dynamic controls and input_mux */
279 struct auto_pin_cfg autocfg;
280 struct snd_array kctls;
281 struct hda_input_mux private_dimux;
282 struct hda_input_mux private_imux;
283 struct hda_input_mux private_smux;
284 struct hda_input_mux private_amp_mux;
285 struct hda_input_mux private_mono_mux;
288 static hda_nid_t stac9200_adc_nids[1] = {
292 static hda_nid_t stac9200_mux_nids[1] = {
296 static hda_nid_t stac9200_dac_nids[1] = {
300 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
301 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
305 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
309 static hda_nid_t stac92hd73xx_adc_nids[2] = {
313 #define DELL_M6_AMP 2
314 static hda_nid_t stac92hd73xx_amp_nids[3] = {
318 #define STAC92HD73XX_NUM_DMICS 2
319 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
323 #define STAC92HD73_DAC_COUNT 5
325 static hda_nid_t stac92hd73xx_mux_nids[4] = {
326 0x28, 0x29, 0x2a, 0x2b,
329 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
333 static hda_nid_t stac92hd73xx_smux_nids[2] = {
337 #define STAC92HD83XXX_NUM_DMICS 2
338 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
342 #define STAC92HD83_DAC_COUNT 3
344 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
348 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
352 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
356 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
360 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
361 0x03, 0x0c, 0x20, 0x40,
364 static hda_nid_t stac92hd83xxx_amp_nids[1] = {
368 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
372 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
376 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
380 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
384 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
388 #define STAC92HD71BXX_NUM_DMICS 2
389 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
393 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
397 static hda_nid_t stac925x_adc_nids[1] = {
401 static hda_nid_t stac925x_mux_nids[1] = {
405 static hda_nid_t stac925x_dac_nids[1] = {
409 #define STAC925X_NUM_DMICS 1
410 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
414 static hda_nid_t stac925x_dmux_nids[1] = {
418 static hda_nid_t stac922x_adc_nids[2] = {
422 static hda_nid_t stac922x_mux_nids[2] = {
426 static hda_nid_t stac927x_slave_dig_outs[2] = {
430 static hda_nid_t stac927x_adc_nids[3] = {
434 static hda_nid_t stac927x_mux_nids[3] = {
438 static hda_nid_t stac927x_smux_nids[1] = {
442 static hda_nid_t stac927x_dac_nids[6] = {
443 0x02, 0x03, 0x04, 0x05, 0x06, 0
446 static hda_nid_t stac927x_dmux_nids[1] = {
450 #define STAC927X_NUM_DMICS 2
451 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
455 static const char *stac927x_spdif_labels[5] = {
456 "Digital Playback", "ADAT", "Analog Mux 1",
457 "Analog Mux 2", "Analog Mux 3"
460 static hda_nid_t stac9205_adc_nids[2] = {
464 static hda_nid_t stac9205_mux_nids[2] = {
468 static hda_nid_t stac9205_dmux_nids[1] = {
472 static hda_nid_t stac9205_smux_nids[1] = {
476 #define STAC9205_NUM_DMICS 2
477 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
481 static hda_nid_t stac9200_pin_nids[8] = {
482 0x08, 0x09, 0x0d, 0x0e,
483 0x0f, 0x10, 0x11, 0x12,
486 static hda_nid_t stac925x_pin_nids[8] = {
487 0x07, 0x08, 0x0a, 0x0b,
488 0x0c, 0x0d, 0x10, 0x11,
491 static hda_nid_t stac922x_pin_nids[10] = {
492 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
493 0x0f, 0x10, 0x11, 0x15, 0x1b,
496 static hda_nid_t stac92hd73xx_pin_nids[13] = {
497 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
498 0x0f, 0x10, 0x11, 0x12, 0x13,
502 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
503 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
504 0x0f, 0x10, 0x11, 0x1f, 0x20,
507 #define STAC92HD71BXX_NUM_PINS 13
508 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
509 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
510 0x00, 0x14, 0x18, 0x19, 0x1e,
513 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
514 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
515 0x0f, 0x14, 0x18, 0x19, 0x1e,
519 static hda_nid_t stac927x_pin_nids[14] = {
520 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
521 0x0f, 0x10, 0x11, 0x12, 0x13,
522 0x14, 0x21, 0x22, 0x23,
525 static hda_nid_t stac9205_pin_nids[12] = {
526 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
527 0x0f, 0x14, 0x16, 0x17, 0x18,
531 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
533 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
534 struct snd_ctl_elem_value *ucontrol)
536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537 struct sigmatel_spec *spec = codec->spec;
538 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
540 kcontrol->private_value ^= get_amp_nid(kcontrol);
541 kcontrol->private_value |= nid;
543 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
546 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
547 struct snd_ctl_elem_value *ucontrol)
549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
550 struct sigmatel_spec *spec = codec->spec;
551 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
553 kcontrol->private_value ^= get_amp_nid(kcontrol);
554 kcontrol->private_value |= nid;
556 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
559 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
560 struct snd_ctl_elem_info *uinfo)
562 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
563 struct sigmatel_spec *spec = codec->spec;
564 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
567 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
568 struct snd_ctl_elem_value *ucontrol)
570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
571 struct sigmatel_spec *spec = codec->spec;
572 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
574 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
578 static int stac92xx_dmux_enum_put(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 dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
585 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
586 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
589 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
590 struct snd_ctl_elem_info *uinfo)
592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
593 struct sigmatel_spec *spec = codec->spec;
594 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
597 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
598 struct snd_ctl_elem_value *ucontrol)
600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
601 struct sigmatel_spec *spec = codec->spec;
602 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
604 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
608 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
609 struct snd_ctl_elem_value *ucontrol)
611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
612 struct sigmatel_spec *spec = codec->spec;
613 struct hda_input_mux *smux = &spec->private_smux;
614 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
618 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
619 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
623 if (spec->spdif_mute) {
625 nid = spec->multiout.dig_out_nid;
627 nid = codec->slave_dig_outs[smux_idx - 1];
628 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
632 /* un/mute SPDIF out */
633 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
639 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
640 hda_nid_t nid, unsigned int new_vref)
644 pincfg = snd_hda_codec_read(codec, nid, 0,
645 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
648 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
651 if (new_vref == AC_PINCTL_VREF_HIZ)
652 pincfg |= AC_PINCTL_OUT_EN;
654 pincfg |= AC_PINCTL_IN_EN;
656 error = snd_hda_codec_write_cache(codec, nid, 0,
657 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
664 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
667 vref = snd_hda_codec_read(codec, nid, 0,
668 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
669 vref &= AC_PINCTL_VREFEN;
673 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 struct sigmatel_spec *spec = codec->spec;
677 return snd_hda_input_mux_info(spec->input_mux, uinfo);
680 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
682 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
683 struct sigmatel_spec *spec = codec->spec;
684 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
686 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
690 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
692 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
693 struct sigmatel_spec *spec = codec->spec;
694 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
696 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
697 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
700 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
701 struct snd_ctl_elem_info *uinfo)
703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
704 struct sigmatel_spec *spec = codec->spec;
705 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
708 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
709 struct snd_ctl_elem_value *ucontrol)
711 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
712 struct sigmatel_spec *spec = codec->spec;
714 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
718 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
719 struct snd_ctl_elem_value *ucontrol)
721 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
722 struct sigmatel_spec *spec = codec->spec;
724 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
725 spec->mono_nid, &spec->cur_mmux);
728 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
729 struct snd_ctl_elem_info *uinfo)
731 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
732 struct sigmatel_spec *spec = codec->spec;
733 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
736 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
737 struct snd_ctl_elem_value *ucontrol)
739 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
740 struct sigmatel_spec *spec = codec->spec;
742 ucontrol->value.enumerated.item[0] = spec->cur_amux;
746 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
747 struct snd_ctl_elem_value *ucontrol)
749 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
750 struct sigmatel_spec *spec = codec->spec;
751 struct snd_kcontrol *ctl =
752 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
756 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
757 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
759 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
763 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
765 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value *ucontrol)
768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
769 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
770 struct sigmatel_spec *spec = codec->spec;
772 ucontrol->value.integer.value[0] = !!(spec->aloopback &
773 (spec->aloopback_mask << idx));
777 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
778 struct snd_ctl_elem_value *ucontrol)
780 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
781 struct sigmatel_spec *spec = codec->spec;
782 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
783 unsigned int dac_mode;
784 unsigned int val, idx_val;
786 idx_val = spec->aloopback_mask << idx;
787 if (ucontrol->value.integer.value[0])
788 val = spec->aloopback | idx_val;
790 val = spec->aloopback & ~idx_val;
791 if (spec->aloopback == val)
794 spec->aloopback = val;
796 /* Only return the bits defined by the shift value of the
797 * first two bytes of the mask
799 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
800 kcontrol->private_value & 0xFFFF, 0x0);
801 dac_mode >>= spec->aloopback_shift;
803 if (spec->aloopback & idx_val) {
804 snd_hda_power_up(codec);
807 snd_hda_power_down(codec);
808 dac_mode &= ~idx_val;
811 snd_hda_codec_write_cache(codec, codec->afg, 0,
812 kcontrol->private_value >> 16, dac_mode);
817 static struct hda_verb stac9200_core_init[] = {
818 /* set dac0mux for dac converter */
819 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
823 static struct hda_verb stac9200_eapd_init[] = {
824 /* set dac0mux for dac converter */
825 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
826 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
830 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
831 /* set master volume and direct control */
832 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
833 /* setup adcs to point to mixer */
834 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
835 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
836 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
838 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
839 /* setup import muxs */
840 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
841 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
842 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
843 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
847 static struct hda_verb dell_eq_core_init[] = {
848 /* set master volume to max value without distortion
849 * and direct control */
850 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
851 /* setup adcs to point to mixer */
852 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
853 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
854 /* setup import muxs */
855 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
856 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
857 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
858 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
862 static struct hda_verb dell_m6_core_init[] = {
863 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
864 /* setup adcs to point to mixer */
865 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
866 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
867 /* setup import muxs */
868 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
869 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
870 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
871 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
875 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
876 /* set master volume and direct control */
877 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
878 /* setup adcs to point to mixer */
879 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
880 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
881 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
882 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
883 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
884 /* setup import muxs */
885 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
886 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
887 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
888 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
892 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
893 /* set master volume and direct control */
894 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
895 /* dac3 is connected to import3 mux */
896 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
897 /* setup adcs to point to mixer */
898 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
899 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
900 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
901 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
902 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
903 /* setup import muxs */
904 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
905 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
906 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
907 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
911 static struct hda_verb stac92hd83xxx_core_init[] = {
912 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
913 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
914 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
916 /* power state controls amps */
917 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
921 static struct hda_verb stac92hd71bxx_core_init[] = {
922 /* set master volume and direct control */
923 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
927 #define HD_DISABLE_PORTF 1
928 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
929 /* start of config #1 */
931 /* connect port 0f to audio mixer */
932 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
933 /* start of config #2 */
935 /* set master volume and direct control */
936 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
940 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
941 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
942 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
943 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
944 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
948 static struct hda_verb stac925x_core_init[] = {
949 /* set dac0mux for dac converter */
950 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
951 /* mute the master volume */
952 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
956 static struct hda_verb stac922x_core_init[] = {
957 /* set master volume and direct control */
958 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
962 static struct hda_verb d965_core_init[] = {
963 /* set master volume and direct control */
964 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
965 /* unmute node 0x1b */
966 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
967 /* select node 0x03 as DAC */
968 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
972 static struct hda_verb stac927x_core_init[] = {
973 /* set master volume and direct control */
974 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
975 /* enable analog pc beep path */
976 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
980 static struct hda_verb stac9205_core_init[] = {
981 /* set master volume and direct control */
982 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
983 /* enable analog pc beep path */
984 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
988 #define STAC_MONO_MUX \
990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
991 .name = "Mono Mux", \
993 .info = stac92xx_mono_mux_enum_info, \
994 .get = stac92xx_mono_mux_enum_get, \
995 .put = stac92xx_mono_mux_enum_put, \
998 #define STAC_AMP_MUX \
1000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1001 .name = "Amp Selector Capture Switch", \
1003 .info = stac92xx_amp_mux_enum_info, \
1004 .get = stac92xx_amp_mux_enum_get, \
1005 .put = stac92xx_amp_mux_enum_put, \
1008 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1013 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1014 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1015 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1016 .info = stac92xx_amp_volume_info, \
1017 .get = stac92xx_amp_volume_get, \
1018 .put = stac92xx_amp_volume_put, \
1019 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1020 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1023 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
1025 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1026 .name = "Analog Loopback", \
1028 .info = stac92xx_aloopback_info, \
1029 .get = stac92xx_aloopback_get, \
1030 .put = stac92xx_aloopback_put, \
1031 .private_value = verb_read | (verb_write << 16), \
1034 #define DC_BIAS(xname, idx, nid) \
1036 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1039 .info = stac92xx_dc_bias_info, \
1040 .get = stac92xx_dc_bias_get, \
1041 .put = stac92xx_dc_bias_put, \
1042 .private_value = nid, \
1045 static struct snd_kcontrol_new stac9200_mixer[] = {
1046 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1047 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
1048 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1049 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1053 #define DELL_M6_MIXER 6
1054 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1055 /* start of config #1 */
1056 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1057 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1059 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1060 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1062 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1063 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1065 /* start of config #2 */
1066 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1067 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1069 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1070 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1072 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1073 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1075 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1076 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1081 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1082 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1086 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1087 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1091 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1092 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1096 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1097 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1098 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1100 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1101 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1103 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1104 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1106 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1107 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1109 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1110 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1112 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1113 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1115 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1116 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1120 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1121 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1122 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1124 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1125 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1127 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1128 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1130 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1131 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1133 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1134 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1136 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1137 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1139 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1140 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1145 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1146 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1147 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1149 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1150 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1152 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1153 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
1155 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1156 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
1158 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1159 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
1161 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1162 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
1165 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1166 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
1171 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1172 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1173 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1175 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1176 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1177 /* analog pc-beep replaced with digital beep support */
1179 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1180 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1183 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1184 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1186 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1187 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1189 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1190 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1192 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1193 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1197 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1198 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1201 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1202 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1203 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1205 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1206 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1210 static struct snd_kcontrol_new stac925x_mixer[] = {
1211 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1212 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1213 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1214 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1218 static struct snd_kcontrol_new stac9205_mixer[] = {
1219 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1220 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1222 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1223 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1227 static struct snd_kcontrol_new stac9205_loopback[] = {
1228 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1232 /* This needs to be generated dynamically based on sequence */
1233 static struct snd_kcontrol_new stac922x_mixer[] = {
1234 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1235 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1237 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1238 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1243 static struct snd_kcontrol_new stac927x_mixer[] = {
1244 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1245 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1247 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1248 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1250 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1251 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1255 static struct snd_kcontrol_new stac927x_loopback[] = {
1256 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1260 static struct snd_kcontrol_new stac_dmux_mixer = {
1261 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1262 .name = "Digital Input Source",
1263 /* count set later */
1264 .info = stac92xx_dmux_enum_info,
1265 .get = stac92xx_dmux_enum_get,
1266 .put = stac92xx_dmux_enum_put,
1269 static struct snd_kcontrol_new stac_smux_mixer = {
1270 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1271 .name = "IEC958 Playback Source",
1272 /* count set later */
1273 .info = stac92xx_smux_enum_info,
1274 .get = stac92xx_smux_enum_get,
1275 .put = stac92xx_smux_enum_put,
1278 static const char *slave_vols[] = {
1279 "Front Playback Volume",
1280 "Surround Playback Volume",
1281 "Center Playback Volume",
1282 "LFE Playback Volume",
1283 "Side Playback Volume",
1284 "Headphone Playback Volume",
1285 "Speaker Playback Volume",
1289 static const char *slave_sws[] = {
1290 "Front Playback Switch",
1291 "Surround Playback Switch",
1292 "Center Playback Switch",
1293 "LFE Playback Switch",
1294 "Side Playback Switch",
1295 "Headphone Playback Switch",
1296 "Speaker Playback Switch",
1297 "IEC958 Playback Switch",
1301 static void stac92xx_free_kctls(struct hda_codec *codec);
1302 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1304 static int stac92xx_build_controls(struct hda_codec *codec)
1306 struct sigmatel_spec *spec = codec->spec;
1307 struct auto_pin_cfg *cfg = &spec->autocfg;
1312 err = snd_hda_add_new_ctls(codec, spec->mixer);
1316 for (i = 0; i < spec->num_mixers; i++) {
1317 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1321 if (spec->num_dmuxes > 0) {
1322 stac_dmux_mixer.count = spec->num_dmuxes;
1323 err = snd_hda_ctl_add(codec,
1324 snd_ctl_new1(&stac_dmux_mixer, codec));
1328 if (spec->num_smuxes > 0) {
1329 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1330 struct hda_input_mux *smux = &spec->private_smux;
1331 /* check for mute support on SPDIF out */
1332 if (wcaps & AC_WCAP_OUT_AMP) {
1333 smux->items[smux->num_items].label = "Off";
1334 smux->items[smux->num_items].index = 0;
1336 spec->spdif_mute = 1;
1338 stac_smux_mixer.count = spec->num_smuxes;
1339 err = snd_hda_ctl_add(codec,
1340 snd_ctl_new1(&stac_smux_mixer, codec));
1345 if (spec->multiout.dig_out_nid) {
1346 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1349 err = snd_hda_create_spdif_share_sw(codec,
1353 spec->multiout.share_spdif = 1;
1355 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1356 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1361 /* if we have no master control, let's create it */
1362 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1363 unsigned int vmaster_tlv[4];
1364 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1365 HDA_OUTPUT, vmaster_tlv);
1366 /* correct volume offset */
1367 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1368 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1369 vmaster_tlv, slave_vols);
1373 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1374 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1380 if (spec->aloopback_ctl &&
1381 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1382 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1387 stac92xx_free_kctls(codec); /* no longer needed */
1389 /* create jack input elements */
1390 if (spec->hp_detect) {
1391 for (i = 0; i < cfg->hp_outs; i++) {
1392 int type = SND_JACK_HEADPHONE;
1393 nid = cfg->hp_pins[i];
1394 /* jack detection */
1395 if (cfg->hp_outs == i)
1396 type |= SND_JACK_LINEOUT;
1397 err = stac92xx_add_jack(codec, nid, type);
1402 for (i = 0; i < cfg->line_outs; i++) {
1403 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1408 for (i = 0; i < AUTO_PIN_LAST; i++) {
1409 nid = cfg->input_pins[i];
1411 err = stac92xx_add_jack(codec, nid,
1412 SND_JACK_MICROPHONE);
1421 static unsigned int ref9200_pin_configs[8] = {
1422 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1423 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1426 static unsigned int gateway9200_m4_pin_configs[8] = {
1427 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1428 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1430 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1431 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1432 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1436 STAC 9200 pin configs for
1441 static unsigned int dell9200_d21_pin_configs[8] = {
1442 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1443 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1447 STAC 9200 pin configs for
1451 static unsigned int dell9200_d22_pin_configs[8] = {
1452 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1453 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1457 STAC 9200 pin configs for
1458 102801C4 (Dell Dimension E310)
1465 static unsigned int dell9200_d23_pin_configs[8] = {
1466 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1467 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1472 STAC 9200-32 pin configs for
1473 102801B5 (Dell Inspiron 630m)
1474 102801D8 (Dell Inspiron 640m)
1476 static unsigned int dell9200_m21_pin_configs[8] = {
1477 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1478 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1482 STAC 9200-32 pin configs for
1483 102801C2 (Dell Latitude D620)
1485 102801CC (Dell Latitude D820)
1489 static unsigned int dell9200_m22_pin_configs[8] = {
1490 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1491 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1495 STAC 9200-32 pin configs for
1496 102801CE (Dell XPS M1710)
1497 102801CF (Dell Precision M90)
1499 static unsigned int dell9200_m23_pin_configs[8] = {
1500 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1501 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1505 STAC 9200-32 pin configs for
1508 102801CB (Dell Latitude 120L)
1511 static unsigned int dell9200_m24_pin_configs[8] = {
1512 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1513 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1517 STAC 9200-32 pin configs for
1518 102801BD (Dell Inspiron E1505n)
1522 static unsigned int dell9200_m25_pin_configs[8] = {
1523 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1524 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1528 STAC 9200-32 pin configs for
1529 102801F5 (Dell Inspiron 1501)
1532 static unsigned int dell9200_m26_pin_configs[8] = {
1533 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1534 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1539 102801CD (Dell Inspiron E1705/9400)
1541 static unsigned int dell9200_m27_pin_configs[8] = {
1542 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1543 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1546 static unsigned int oqo9200_pin_configs[8] = {
1547 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1548 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1552 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1553 [STAC_REF] = ref9200_pin_configs,
1554 [STAC_9200_OQO] = oqo9200_pin_configs,
1555 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1556 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1557 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1558 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1559 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1560 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1561 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1562 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1563 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1564 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1565 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1566 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1567 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1570 static const char *stac9200_models[STAC_9200_MODELS] = {
1571 [STAC_AUTO] = "auto",
1573 [STAC_9200_OQO] = "oqo",
1574 [STAC_9200_DELL_D21] = "dell-d21",
1575 [STAC_9200_DELL_D22] = "dell-d22",
1576 [STAC_9200_DELL_D23] = "dell-d23",
1577 [STAC_9200_DELL_M21] = "dell-m21",
1578 [STAC_9200_DELL_M22] = "dell-m22",
1579 [STAC_9200_DELL_M23] = "dell-m23",
1580 [STAC_9200_DELL_M24] = "dell-m24",
1581 [STAC_9200_DELL_M25] = "dell-m25",
1582 [STAC_9200_DELL_M26] = "dell-m26",
1583 [STAC_9200_DELL_M27] = "dell-m27",
1584 [STAC_9200_M4] = "gateway-m4",
1585 [STAC_9200_M4_2] = "gateway-m4-2",
1586 [STAC_9200_PANASONIC] = "panasonic",
1589 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1590 /* SigmaTel reference board */
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1592 "DFI LanParty", STAC_REF),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1594 "DFI LanParty", STAC_REF),
1595 /* Dell laptops have BIOS problem */
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1597 "unknown Dell", STAC_9200_DELL_D21),
1598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1599 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1601 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1603 "unknown Dell", STAC_9200_DELL_D22),
1604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1605 "unknown Dell", STAC_9200_DELL_D22),
1606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1607 "Dell Latitude D620", STAC_9200_DELL_M22),
1608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1609 "unknown Dell", STAC_9200_DELL_D23),
1610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1611 "unknown Dell", STAC_9200_DELL_D23),
1612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1613 "unknown Dell", STAC_9200_DELL_M22),
1614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1615 "unknown Dell", STAC_9200_DELL_M24),
1616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1617 "unknown Dell", STAC_9200_DELL_M24),
1618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1619 "Dell Latitude 120L", STAC_9200_DELL_M24),
1620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1621 "Dell Latitude D820", STAC_9200_DELL_M22),
1622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1623 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1624 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1625 "Dell XPS M1710", STAC_9200_DELL_M23),
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1627 "Dell Precision M90", STAC_9200_DELL_M23),
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1629 "unknown Dell", STAC_9200_DELL_M22),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1631 "unknown Dell", STAC_9200_DELL_M22),
1632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1633 "unknown Dell", STAC_9200_DELL_M22),
1634 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1635 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1637 "unknown Dell", STAC_9200_DELL_D23),
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1639 "unknown Dell", STAC_9200_DELL_D23),
1640 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1641 "unknown Dell", STAC_9200_DELL_D21),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1643 "unknown Dell", STAC_9200_DELL_D23),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1645 "unknown Dell", STAC_9200_DELL_D21),
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1647 "unknown Dell", STAC_9200_DELL_M25),
1648 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1649 "unknown Dell", STAC_9200_DELL_M25),
1650 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1651 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1652 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1653 "unknown Dell", STAC_9200_DELL_M26),
1655 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1656 /* Gateway machines needs EAPD to be set on resume */
1657 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1658 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1659 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1661 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1665 static unsigned int ref925x_pin_configs[8] = {
1666 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1667 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1670 static unsigned int stac925xM1_pin_configs[8] = {
1671 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1672 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1675 static unsigned int stac925xM1_2_pin_configs[8] = {
1676 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1677 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1680 static unsigned int stac925xM2_pin_configs[8] = {
1681 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1682 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1685 static unsigned int stac925xM2_2_pin_configs[8] = {
1686 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1687 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1690 static unsigned int stac925xM3_pin_configs[8] = {
1691 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1692 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1695 static unsigned int stac925xM5_pin_configs[8] = {
1696 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1697 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1700 static unsigned int stac925xM6_pin_configs[8] = {
1701 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1702 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1705 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1706 [STAC_REF] = ref925x_pin_configs,
1707 [STAC_M1] = stac925xM1_pin_configs,
1708 [STAC_M1_2] = stac925xM1_2_pin_configs,
1709 [STAC_M2] = stac925xM2_pin_configs,
1710 [STAC_M2_2] = stac925xM2_2_pin_configs,
1711 [STAC_M3] = stac925xM3_pin_configs,
1712 [STAC_M5] = stac925xM5_pin_configs,
1713 [STAC_M6] = stac925xM6_pin_configs,
1716 static const char *stac925x_models[STAC_925x_MODELS] = {
1717 [STAC_925x_AUTO] = "auto",
1720 [STAC_M1_2] = "m1-2",
1722 [STAC_M2_2] = "m2-2",
1728 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1729 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1730 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1731 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1732 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1733 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1734 /* Not sure about the brand name for those */
1735 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1736 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1737 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1738 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1742 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1743 /* SigmaTel reference board */
1744 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1745 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1746 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1748 /* Default table for unknown ID */
1749 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1754 static unsigned int ref92hd73xx_pin_configs[13] = {
1755 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1756 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1757 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1761 static unsigned int dell_m6_pin_configs[13] = {
1762 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1763 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1764 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1768 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1769 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1770 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1771 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1772 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1773 [STAC_DELL_EQ] = dell_m6_pin_configs,
1776 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1777 [STAC_92HD73XX_AUTO] = "auto",
1778 [STAC_92HD73XX_NO_JD] = "no-jd",
1779 [STAC_92HD73XX_REF] = "ref",
1780 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1781 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1782 [STAC_DELL_M6_BOTH] = "dell-m6",
1783 [STAC_DELL_EQ] = "dell-eq",
1786 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1787 /* SigmaTel reference board */
1788 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1789 "DFI LanParty", STAC_92HD73XX_REF),
1790 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1791 "DFI LanParty", STAC_92HD73XX_REF),
1792 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1793 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1794 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1795 "unknown Dell", STAC_DELL_M6_DMIC),
1796 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1797 "unknown Dell", STAC_DELL_M6_BOTH),
1798 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1799 "unknown Dell", STAC_DELL_M6_BOTH),
1800 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1801 "unknown Dell", STAC_DELL_M6_AMIC),
1802 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1803 "unknown Dell", STAC_DELL_M6_AMIC),
1804 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1805 "unknown Dell", STAC_DELL_M6_DMIC),
1806 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1807 "unknown Dell", STAC_DELL_M6_DMIC),
1808 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1809 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1810 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1811 "Dell Studio 17", STAC_DELL_M6_DMIC),
1815 static unsigned int ref92hd83xxx_pin_configs[10] = {
1816 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1817 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1818 0x01451160, 0x98560170,
1821 static unsigned int dell_s14_pin_configs[10] = {
1822 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1823 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1824 0x40f000f0, 0x40f000f0,
1827 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1828 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1829 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1830 [STAC_DELL_S14] = dell_s14_pin_configs,
1833 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1834 [STAC_92HD83XXX_AUTO] = "auto",
1835 [STAC_92HD83XXX_REF] = "ref",
1836 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1837 [STAC_DELL_S14] = "dell-s14",
1840 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1841 /* SigmaTel reference board */
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1843 "DFI LanParty", STAC_92HD83XXX_REF),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1845 "DFI LanParty", STAC_92HD83XXX_REF),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1847 "unknown Dell", STAC_DELL_S14),
1851 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1852 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1853 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1854 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1858 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1859 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1860 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1861 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1865 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1866 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1867 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1868 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1872 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1873 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1874 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1875 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1879 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1880 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1881 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1882 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1883 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1884 [STAC_HP_M4] = NULL,
1885 [STAC_HP_DV5] = NULL,
1886 [STAC_HP_HDX] = NULL,
1887 [STAC_HP_DV4_1222NR] = NULL,
1890 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1891 [STAC_92HD71BXX_AUTO] = "auto",
1892 [STAC_92HD71BXX_REF] = "ref",
1893 [STAC_DELL_M4_1] = "dell-m4-1",
1894 [STAC_DELL_M4_2] = "dell-m4-2",
1895 [STAC_DELL_M4_3] = "dell-m4-3",
1896 [STAC_HP_M4] = "hp-m4",
1897 [STAC_HP_DV5] = "hp-dv5",
1898 [STAC_HP_HDX] = "hp-hdx",
1899 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1902 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1903 /* SigmaTel reference board */
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1905 "DFI LanParty", STAC_92HD71BXX_REF),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1907 "DFI LanParty", STAC_92HD71BXX_REF),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1909 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1910 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1912 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1913 "HP dv4-7", STAC_HP_DV5),
1914 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1915 "HP dv4-7", STAC_HP_DV5),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1917 "HP HDX", STAC_HP_HDX), /* HDX18 */
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1919 "HP mini 1000", STAC_HP_M4),
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1921 "HP HDX", STAC_HP_HDX), /* HDX16 */
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1923 "unknown Dell", STAC_DELL_M4_1),
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1925 "unknown Dell", STAC_DELL_M4_1),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1927 "unknown Dell", STAC_DELL_M4_1),
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1929 "unknown Dell", STAC_DELL_M4_1),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1931 "unknown Dell", STAC_DELL_M4_1),
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1933 "unknown Dell", STAC_DELL_M4_1),
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1935 "unknown Dell", STAC_DELL_M4_1),
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1937 "unknown Dell", STAC_DELL_M4_2),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1939 "unknown Dell", STAC_DELL_M4_2),
1940 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1941 "unknown Dell", STAC_DELL_M4_2),
1942 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1943 "unknown Dell", STAC_DELL_M4_2),
1944 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1945 "unknown Dell", STAC_DELL_M4_3),
1949 static unsigned int ref922x_pin_configs[10] = {
1950 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1951 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1952 0x40000100, 0x40000100,
1956 STAC 922X pin configs for
1963 static unsigned int dell_922x_d81_pin_configs[10] = {
1964 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1965 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1966 0x01813122, 0x400001f2,
1970 STAC 922X pin configs for
1974 static unsigned int dell_922x_d82_pin_configs[10] = {
1975 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1976 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1977 0x01813122, 0x400001f1,
1981 STAC 922X pin configs for
1984 static unsigned int dell_922x_m81_pin_configs[10] = {
1985 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1986 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1987 0x40C003f1, 0x405003f0,
1991 STAC 9221 A1 pin configs for
1992 102801D7 (Dell XPS M1210)
1994 static unsigned int dell_922x_m82_pin_configs[10] = {
1995 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1996 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1997 0x508003f3, 0x405003f4,
2000 static unsigned int d945gtp3_pin_configs[10] = {
2001 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
2002 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2003 0x02a19120, 0x40000100,
2006 static unsigned int d945gtp5_pin_configs[10] = {
2007 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
2008 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
2009 0x02a19320, 0x40000100,
2012 static unsigned int intel_mac_v1_pin_configs[10] = {
2013 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
2014 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
2015 0x400000fc, 0x400000fb,
2018 static unsigned int intel_mac_v2_pin_configs[10] = {
2019 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2020 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
2021 0x400000fc, 0x400000fb,
2024 static unsigned int intel_mac_v3_pin_configs[10] = {
2025 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2026 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
2027 0x400000fc, 0x400000fb,
2030 static unsigned int intel_mac_v4_pin_configs[10] = {
2031 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2032 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2033 0x400000fc, 0x400000fb,
2036 static unsigned int intel_mac_v5_pin_configs[10] = {
2037 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2038 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2039 0x400000fc, 0x400000fb,
2042 static unsigned int ecs202_pin_configs[10] = {
2043 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
2044 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
2045 0x9037012e, 0x40e000f2,
2048 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
2049 [STAC_D945_REF] = ref922x_pin_configs,
2050 [STAC_D945GTP3] = d945gtp3_pin_configs,
2051 [STAC_D945GTP5] = d945gtp5_pin_configs,
2052 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
2053 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
2054 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
2055 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
2056 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
2057 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
2058 /* for backward compatibility */
2059 [STAC_MACMINI] = intel_mac_v3_pin_configs,
2060 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
2061 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
2062 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
2063 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
2064 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
2065 [STAC_ECS_202] = ecs202_pin_configs,
2066 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
2067 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
2068 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
2069 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
2072 static const char *stac922x_models[STAC_922X_MODELS] = {
2073 [STAC_922X_AUTO] = "auto",
2074 [STAC_D945_REF] = "ref",
2075 [STAC_D945GTP5] = "5stack",
2076 [STAC_D945GTP3] = "3stack",
2077 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
2078 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
2079 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
2080 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
2081 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
2082 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
2083 /* for backward compatibility */
2084 [STAC_MACMINI] = "macmini",
2085 [STAC_MACBOOK] = "macbook",
2086 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2087 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
2088 [STAC_IMAC_INTEL] = "imac-intel",
2089 [STAC_IMAC_INTEL_20] = "imac-intel-20",
2090 [STAC_ECS_202] = "ecs202",
2091 [STAC_922X_DELL_D81] = "dell-d81",
2092 [STAC_922X_DELL_D82] = "dell-d82",
2093 [STAC_922X_DELL_M81] = "dell-m81",
2094 [STAC_922X_DELL_M82] = "dell-m82",
2097 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2098 /* SigmaTel reference board */
2099 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2100 "DFI LanParty", STAC_D945_REF),
2101 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2102 "DFI LanParty", STAC_D945_REF),
2103 /* Intel 945G based systems */
2104 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2105 "Intel D945G", STAC_D945GTP3),
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2107 "Intel D945G", STAC_D945GTP3),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2109 "Intel D945G", STAC_D945GTP3),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2111 "Intel D945G", STAC_D945GTP3),
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2113 "Intel D945G", STAC_D945GTP3),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2115 "Intel D945G", STAC_D945GTP3),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2117 "Intel D945G", STAC_D945GTP3),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2119 "Intel D945G", STAC_D945GTP3),
2120 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2121 "Intel D945G", STAC_D945GTP3),
2122 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2123 "Intel D945G", STAC_D945GTP3),
2124 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2125 "Intel D945G", STAC_D945GTP3),
2126 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2127 "Intel D945G", STAC_D945GTP3),
2128 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2129 "Intel D945G", STAC_D945GTP3),
2130 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2131 "Intel D945G", STAC_D945GTP3),
2132 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2133 "Intel D945G", STAC_D945GTP3),
2134 /* Intel D945G 5-stack systems */
2135 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2136 "Intel D945G", STAC_D945GTP5),
2137 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2138 "Intel D945G", STAC_D945GTP5),
2139 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2140 "Intel D945G", STAC_D945GTP5),
2141 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2142 "Intel D945G", STAC_D945GTP5),
2143 /* Intel 945P based systems */
2144 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2145 "Intel D945P", STAC_D945GTP3),
2146 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2147 "Intel D945P", STAC_D945GTP3),
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2149 "Intel D945P", STAC_D945GTP3),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2151 "Intel D945P", STAC_D945GTP3),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2153 "Intel D945P", STAC_D945GTP3),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2155 "Intel D945P", STAC_D945GTP5),
2157 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2158 "Intel D945", STAC_D945_REF),
2160 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2161 SND_PCI_QUIRK(0x8384, 0x7680,
2162 "Mac", STAC_INTEL_MAC_AUTO),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2165 "unknown Dell", STAC_922X_DELL_D81),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2167 "unknown Dell", STAC_922X_DELL_D81),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2169 "unknown Dell", STAC_922X_DELL_D81),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2171 "unknown Dell", STAC_922X_DELL_D82),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2173 "unknown Dell", STAC_922X_DELL_M81),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2175 "unknown Dell", STAC_922X_DELL_D82),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2177 "unknown Dell", STAC_922X_DELL_D81),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2179 "unknown Dell", STAC_922X_DELL_D81),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2181 "Dell XPS M1210", STAC_922X_DELL_M82),
2182 /* ECS/PC Chips boards */
2183 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2184 "ECS/PC chips", STAC_ECS_202),
2188 static unsigned int ref927x_pin_configs[14] = {
2189 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2190 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2191 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2192 0x01c42190, 0x40000100,
2195 static unsigned int d965_3st_pin_configs[14] = {
2196 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2197 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2198 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2199 0x40000100, 0x40000100
2202 static unsigned int d965_5st_pin_configs[14] = {
2203 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2204 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2205 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2206 0x40000100, 0x40000100
2209 static unsigned int d965_5st_no_fp_pin_configs[14] = {
2210 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2211 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2212 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2213 0x40000100, 0x40000100
2216 static unsigned int dell_3st_pin_configs[14] = {
2217 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2218 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2219 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2220 0x40c003fc, 0x40000100
2223 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2224 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2225 [STAC_D965_REF] = ref927x_pin_configs,
2226 [STAC_D965_3ST] = d965_3st_pin_configs,
2227 [STAC_D965_5ST] = d965_5st_pin_configs,
2228 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2229 [STAC_DELL_3ST] = dell_3st_pin_configs,
2230 [STAC_DELL_BIOS] = NULL,
2233 static const char *stac927x_models[STAC_927X_MODELS] = {
2234 [STAC_927X_AUTO] = "auto",
2235 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2236 [STAC_D965_REF] = "ref",
2237 [STAC_D965_3ST] = "3stack",
2238 [STAC_D965_5ST] = "5stack",
2239 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2240 [STAC_DELL_3ST] = "dell-3stack",
2241 [STAC_DELL_BIOS] = "dell-bios",
2244 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2245 /* SigmaTel reference board */
2246 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2247 "DFI LanParty", STAC_D965_REF),
2248 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2249 "DFI LanParty", STAC_D965_REF),
2250 /* Intel 946 based systems */
2251 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2252 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2253 /* 965 based 3 stack systems */
2254 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2255 "Intel D965", STAC_D965_3ST),
2256 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2257 "Intel D965", STAC_D965_3ST),
2258 /* Dell 3 stack systems */
2259 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2260 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2262 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2263 /* Dell 3 stack systems with verb table in BIOS */
2264 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2265 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2272 /* 965 based 5 stack systems */
2273 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2274 "Intel D965", STAC_D965_5ST),
2275 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2276 "Intel D965", STAC_D965_5ST),
2280 static unsigned int ref9205_pin_configs[12] = {
2281 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2282 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2283 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2287 STAC 9205 pin configs for
2294 10280228 (Dell Vostro 1500)
2296 static unsigned int dell_9205_m42_pin_configs[12] = {
2297 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2298 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2299 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2303 STAC 9205 pin configs for
2307 102801FF (Dell Precision M4300)
2312 static unsigned int dell_9205_m43_pin_configs[12] = {
2313 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2314 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2315 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2318 static unsigned int dell_9205_m44_pin_configs[12] = {
2319 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2320 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2321 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2324 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2325 [STAC_9205_REF] = ref9205_pin_configs,
2326 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2327 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2328 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2329 [STAC_9205_EAPD] = NULL,
2332 static const char *stac9205_models[STAC_9205_MODELS] = {
2333 [STAC_9205_AUTO] = "auto",
2334 [STAC_9205_REF] = "ref",
2335 [STAC_9205_DELL_M42] = "dell-m42",
2336 [STAC_9205_DELL_M43] = "dell-m43",
2337 [STAC_9205_DELL_M44] = "dell-m44",
2338 [STAC_9205_EAPD] = "eapd",
2341 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2342 /* SigmaTel reference board */
2343 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2344 "DFI LanParty", STAC_9205_REF),
2345 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2346 "DFI LanParty", STAC_9205_REF),
2348 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2349 "unknown Dell", STAC_9205_DELL_M42),
2350 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2351 "unknown Dell", STAC_9205_DELL_M42),
2352 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2353 "Dell Precision", STAC_9205_DELL_M43),
2354 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2355 "Dell Precision", STAC_9205_DELL_M43),
2356 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2357 "Dell Precision", STAC_9205_DELL_M43),
2358 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2359 "unknown Dell", STAC_9205_DELL_M42),
2360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2361 "unknown Dell", STAC_9205_DELL_M42),
2362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2363 "Dell Precision", STAC_9205_DELL_M43),
2364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2365 "Dell Precision M4300", STAC_9205_DELL_M43),
2366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2367 "unknown Dell", STAC_9205_DELL_M42),
2368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2369 "Dell Precision", STAC_9205_DELL_M43),
2370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2371 "Dell Precision", STAC_9205_DELL_M43),
2372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2373 "Dell Precision", STAC_9205_DELL_M43),
2374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2375 "Dell Inspiron", STAC_9205_DELL_M44),
2376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2377 "Dell Vostro 1500", STAC_9205_DELL_M42),
2379 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2383 static void stac92xx_set_config_regs(struct hda_codec *codec,
2384 unsigned int *pincfgs)
2387 struct sigmatel_spec *spec = codec->spec;
2392 for (i = 0; i < spec->num_pins; i++)
2393 if (spec->pin_nids[i] && pincfgs[i])
2394 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2399 * Analog playback callbacks
2401 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2402 struct hda_codec *codec,
2403 struct snd_pcm_substream *substream)
2405 struct sigmatel_spec *spec = codec->spec;
2406 if (spec->stream_delay)
2407 msleep(spec->stream_delay);
2408 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2412 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2413 struct hda_codec *codec,
2414 unsigned int stream_tag,
2415 unsigned int format,
2416 struct snd_pcm_substream *substream)
2418 struct sigmatel_spec *spec = codec->spec;
2419 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2422 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2423 struct hda_codec *codec,
2424 struct snd_pcm_substream *substream)
2426 struct sigmatel_spec *spec = codec->spec;
2427 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2431 * Digital playback callbacks
2433 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2434 struct hda_codec *codec,
2435 struct snd_pcm_substream *substream)
2437 struct sigmatel_spec *spec = codec->spec;
2438 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2441 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2442 struct hda_codec *codec,
2443 struct snd_pcm_substream *substream)
2445 struct sigmatel_spec *spec = codec->spec;
2446 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2449 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2450 struct hda_codec *codec,
2451 unsigned int stream_tag,
2452 unsigned int format,
2453 struct snd_pcm_substream *substream)
2455 struct sigmatel_spec *spec = codec->spec;
2456 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2457 stream_tag, format, substream);
2460 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2461 struct hda_codec *codec,
2462 struct snd_pcm_substream *substream)
2464 struct sigmatel_spec *spec = codec->spec;
2465 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2470 * Analog capture callbacks
2472 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2473 struct hda_codec *codec,
2474 unsigned int stream_tag,
2475 unsigned int format,
2476 struct snd_pcm_substream *substream)
2478 struct sigmatel_spec *spec = codec->spec;
2479 hda_nid_t nid = spec->adc_nids[substream->number];
2481 if (spec->powerdown_adcs) {
2483 snd_hda_codec_write(codec, nid, 0,
2484 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2486 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2490 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2491 struct hda_codec *codec,
2492 struct snd_pcm_substream *substream)
2494 struct sigmatel_spec *spec = codec->spec;
2495 hda_nid_t nid = spec->adc_nids[substream->number];
2497 snd_hda_codec_cleanup_stream(codec, nid);
2498 if (spec->powerdown_adcs)
2499 snd_hda_codec_write(codec, nid, 0,
2500 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2504 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2508 /* NID is set in stac92xx_build_pcms */
2510 .open = stac92xx_dig_playback_pcm_open,
2511 .close = stac92xx_dig_playback_pcm_close,
2512 .prepare = stac92xx_dig_playback_pcm_prepare,
2513 .cleanup = stac92xx_dig_playback_pcm_cleanup
2517 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2521 /* NID is set in stac92xx_build_pcms */
2524 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2528 .nid = 0x02, /* NID to query formats and rates */
2530 .open = stac92xx_playback_pcm_open,
2531 .prepare = stac92xx_playback_pcm_prepare,
2532 .cleanup = stac92xx_playback_pcm_cleanup
2536 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2540 .nid = 0x06, /* NID to query formats and rates */
2542 .open = stac92xx_playback_pcm_open,
2543 .prepare = stac92xx_playback_pcm_prepare,
2544 .cleanup = stac92xx_playback_pcm_cleanup
2548 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2551 /* NID + .substreams is set in stac92xx_build_pcms */
2553 .prepare = stac92xx_capture_pcm_prepare,
2554 .cleanup = stac92xx_capture_pcm_cleanup
2558 static int stac92xx_build_pcms(struct hda_codec *codec)
2560 struct sigmatel_spec *spec = codec->spec;
2561 struct hda_pcm *info = spec->pcm_rec;
2563 codec->num_pcms = 1;
2564 codec->pcm_info = info;
2566 info->name = "STAC92xx Analog";
2567 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2568 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2569 spec->multiout.dac_nids[0];
2570 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2571 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2572 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2574 if (spec->alt_switch) {
2577 info->name = "STAC92xx Analog Alt";
2578 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2581 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2584 info->name = "STAC92xx Digital";
2585 info->pcm_type = spec->autocfg.dig_out_type[0];
2586 if (spec->multiout.dig_out_nid) {
2587 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2588 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2590 if (spec->dig_in_nid) {
2591 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2592 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2599 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2602 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2603 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2604 if (pincap & AC_PINCAP_VREF_100)
2605 return AC_PINCTL_VREF_100;
2606 if (pincap & AC_PINCAP_VREF_80)
2607 return AC_PINCTL_VREF_80;
2608 if (pincap & AC_PINCAP_VREF_50)
2609 return AC_PINCTL_VREF_50;
2610 if (pincap & AC_PINCAP_VREF_GRD)
2611 return AC_PINCTL_VREF_GRD;
2615 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2618 snd_hda_codec_write_cache(codec, nid, 0,
2619 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2622 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2624 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2625 struct snd_ctl_elem_value *ucontrol)
2627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2628 struct sigmatel_spec *spec = codec->spec;
2630 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2634 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2635 unsigned char type);
2637 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2638 struct snd_ctl_elem_value *ucontrol)
2640 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2641 struct sigmatel_spec *spec = codec->spec;
2642 int nid = kcontrol->private_value;
2644 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2646 /* check to be sure that the ports are upto date with
2649 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2654 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2655 struct snd_ctl_elem_info *uinfo)
2658 static char *texts[] = {
2659 "Mic In", "Line In", "Line Out"
2662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2663 struct sigmatel_spec *spec = codec->spec;
2664 hda_nid_t nid = kcontrol->private_value;
2666 if (nid == spec->mic_switch || nid == spec->line_switch)
2671 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2672 uinfo->value.enumerated.items = i;
2674 if (uinfo->value.enumerated.item >= i)
2675 uinfo->value.enumerated.item = i-1;
2676 strcpy(uinfo->value.enumerated.name,
2677 texts[uinfo->value.enumerated.item]);
2682 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2683 struct snd_ctl_elem_value *ucontrol)
2685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2686 hda_nid_t nid = kcontrol->private_value;
2687 unsigned int vref = stac92xx_vref_get(codec, nid);
2689 if (vref == stac92xx_get_default_vref(codec, nid))
2690 ucontrol->value.enumerated.item[0] = 0;
2691 else if (vref == AC_PINCTL_VREF_GRD)
2692 ucontrol->value.enumerated.item[0] = 1;
2693 else if (vref == AC_PINCTL_VREF_HIZ)
2694 ucontrol->value.enumerated.item[0] = 2;
2699 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2700 struct snd_ctl_elem_value *ucontrol)
2702 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2703 unsigned int new_vref = 0;
2705 hda_nid_t nid = kcontrol->private_value;
2707 if (ucontrol->value.enumerated.item[0] == 0)
2708 new_vref = stac92xx_get_default_vref(codec, nid);
2709 else if (ucontrol->value.enumerated.item[0] == 1)
2710 new_vref = AC_PINCTL_VREF_GRD;
2711 else if (ucontrol->value.enumerated.item[0] == 2)
2712 new_vref = AC_PINCTL_VREF_HIZ;
2716 if (new_vref != stac92xx_vref_get(codec, nid)) {
2717 error = stac92xx_vref_set(codec, nid, new_vref);
2724 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2725 struct snd_ctl_elem_info *uinfo)
2727 static char *texts[2];
2728 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2729 struct sigmatel_spec *spec = codec->spec;
2731 if (kcontrol->private_value == spec->line_switch)
2732 texts[0] = "Line In";
2734 texts[0] = "Mic In";
2735 texts[1] = "Line Out";
2736 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2737 uinfo->value.enumerated.items = 2;
2740 if (uinfo->value.enumerated.item >= 2)
2741 uinfo->value.enumerated.item = 1;
2742 strcpy(uinfo->value.enumerated.name,
2743 texts[uinfo->value.enumerated.item]);
2748 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2750 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2751 struct sigmatel_spec *spec = codec->spec;
2752 hda_nid_t nid = kcontrol->private_value;
2753 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2755 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2759 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2761 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2762 struct sigmatel_spec *spec = codec->spec;
2763 hda_nid_t nid = kcontrol->private_value;
2764 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2765 unsigned short val = !!ucontrol->value.enumerated.item[0];
2767 spec->io_switch[io_idx] = val;
2770 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2772 unsigned int pinctl = AC_PINCTL_IN_EN;
2773 if (io_idx) /* set VREF for mic */
2774 pinctl |= stac92xx_get_default_vref(codec, nid);
2775 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2778 /* check the auto-mute again: we need to mute/unmute the speaker
2779 * appropriately according to the pin direction
2781 if (spec->hp_detect)
2782 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2787 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2789 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2790 struct snd_ctl_elem_value *ucontrol)
2792 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2793 struct sigmatel_spec *spec = codec->spec;
2795 ucontrol->value.integer.value[0] = spec->clfe_swap;
2799 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2800 struct snd_ctl_elem_value *ucontrol)
2802 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2803 struct sigmatel_spec *spec = codec->spec;
2804 hda_nid_t nid = kcontrol->private_value & 0xff;
2805 unsigned int val = !!ucontrol->value.integer.value[0];
2807 if (spec->clfe_swap == val)
2810 spec->clfe_swap = val;
2812 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2813 spec->clfe_swap ? 0x4 : 0x0);
2818 #define STAC_CODEC_HP_SWITCH(xname) \
2819 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2822 .info = stac92xx_hp_switch_info, \
2823 .get = stac92xx_hp_switch_get, \
2824 .put = stac92xx_hp_switch_put, \
2827 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2828 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2831 .info = stac92xx_io_switch_info, \
2832 .get = stac92xx_io_switch_get, \
2833 .put = stac92xx_io_switch_put, \
2834 .private_value = xpval, \
2837 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2838 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2841 .info = stac92xx_clfe_switch_info, \
2842 .get = stac92xx_clfe_switch_get, \
2843 .put = stac92xx_clfe_switch_put, \
2844 .private_value = xpval, \
2848 STAC_CTL_WIDGET_VOL,
2849 STAC_CTL_WIDGET_MUTE,
2850 STAC_CTL_WIDGET_MONO_MUX,
2851 STAC_CTL_WIDGET_AMP_MUX,
2852 STAC_CTL_WIDGET_AMP_VOL,
2853 STAC_CTL_WIDGET_HP_SWITCH,
2854 STAC_CTL_WIDGET_IO_SWITCH,
2855 STAC_CTL_WIDGET_CLFE_SWITCH,
2856 STAC_CTL_WIDGET_DC_BIAS
2859 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2860 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2861 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2864 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2865 STAC_CODEC_HP_SWITCH(NULL),
2866 STAC_CODEC_IO_SWITCH(NULL, 0),
2867 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2868 DC_BIAS(NULL, 0, 0),
2871 /* add dynamic controls */
2872 static struct snd_kcontrol_new *
2873 stac_control_new(struct sigmatel_spec *spec,
2874 struct snd_kcontrol_new *ktemp,
2877 struct snd_kcontrol_new *knew;
2879 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2880 knew = snd_array_new(&spec->kctls);
2884 knew->name = kstrdup(name, GFP_KERNEL);
2887 memset(knew, 0, sizeof(*knew));
2888 spec->kctls.alloced--;
2894 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2895 struct snd_kcontrol_new *ktemp,
2896 int idx, const char *name,
2899 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2903 knew->private_value = val;
2907 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2908 int type, int idx, const char *name,
2911 return stac92xx_add_control_temp(spec,
2912 &stac92xx_control_templates[type],
2917 /* add dynamic controls */
2918 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2919 const char *name, unsigned long val)
2921 return stac92xx_add_control_idx(spec, type, 0, name, val);
2924 static struct snd_kcontrol_new stac_input_src_temp = {
2925 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2926 .name = "Input Source",
2927 .info = stac92xx_mux_enum_info,
2928 .get = stac92xx_mux_enum_get,
2929 .put = stac92xx_mux_enum_put,
2932 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2933 hda_nid_t nid, int idx)
2935 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2937 struct sigmatel_spec *spec = codec->spec;
2940 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2941 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2942 && nid == spec->line_switch)
2943 control = STAC_CTL_WIDGET_IO_SWITCH;
2944 else if (snd_hda_query_pin_caps(codec, nid)
2945 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2946 control = STAC_CTL_WIDGET_DC_BIAS;
2947 else if (nid == spec->mic_switch)
2948 control = STAC_CTL_WIDGET_IO_SWITCH;
2952 strcpy(name, auto_pin_cfg_labels[idx]);
2953 return stac92xx_add_control(codec->spec, control,
2954 strcat(name, " Jack Mode"), nid);
2960 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2962 struct snd_kcontrol_new *knew;
2963 struct hda_input_mux *imux = &spec->private_imux;
2965 if (!spec->num_adcs || imux->num_items <= 1)
2966 return 0; /* no need for input source control */
2967 knew = stac_control_new(spec, &stac_input_src_temp,
2968 stac_input_src_temp.name);
2971 knew->count = spec->num_adcs;
2975 /* check whether the line-input can be used as line-out */
2976 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2978 struct sigmatel_spec *spec = codec->spec;
2979 struct auto_pin_cfg *cfg = &spec->autocfg;
2981 unsigned int pincap;
2983 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2985 nid = cfg->input_pins[AUTO_PIN_LINE];
2986 pincap = snd_hda_query_pin_caps(codec, nid);
2987 if (pincap & AC_PINCAP_OUT)
2992 /* check whether the mic-input can be used as line-out */
2993 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2995 struct sigmatel_spec *spec = codec->spec;
2996 struct auto_pin_cfg *cfg = &spec->autocfg;
2997 unsigned int def_conf, pincap;
2998 unsigned int mic_pin;
3000 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
3002 mic_pin = AUTO_PIN_MIC;
3004 hda_nid_t nid = cfg->input_pins[mic_pin];
3005 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3006 /* some laptops have an internal analog microphone
3007 * which can't be used as a output */
3008 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
3009 pincap = snd_hda_query_pin_caps(codec, nid);
3010 if (pincap & AC_PINCAP_OUT)
3013 if (mic_pin == AUTO_PIN_MIC)
3014 mic_pin = AUTO_PIN_FRONT_MIC;
3021 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3025 for (i = 0; i < spec->multiout.num_dacs; i++) {
3026 if (spec->multiout.dac_nids[i] == nid)
3033 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3036 if (is_in_dac_nids(spec, nid))
3038 for (i = 0; i < spec->autocfg.hp_outs; i++)
3039 if (spec->hp_dacs[i] == nid)
3041 for (i = 0; i < spec->autocfg.speaker_outs; i++)
3042 if (spec->speaker_dacs[i] == nid)
3047 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
3049 struct sigmatel_spec *spec = codec->spec;
3051 hda_nid_t conn[HDA_MAX_CONNECTIONS];
3052 unsigned int wcaps, wtype;
3054 conn_len = snd_hda_get_connections(codec, nid, conn,
3055 HDA_MAX_CONNECTIONS);
3056 for (j = 0; j < conn_len; j++) {
3057 wcaps = get_wcaps(codec, conn[j]);
3058 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3059 /* we check only analog outputs */
3060 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
3062 /* if this route has a free DAC, assign it */
3063 if (!check_all_dac_nids(spec, conn[j])) {
3065 /* select this DAC in the pin's input mux */
3066 snd_hda_codec_write_cache(codec, nid, 0,
3067 AC_VERB_SET_CONNECT_SEL, j);
3072 /* if all DACs are already assigned, connect to the primary DAC */
3074 for (j = 0; j < conn_len; j++) {
3075 if (conn[j] == spec->multiout.dac_nids[0]) {
3076 snd_hda_codec_write_cache(codec, nid, 0,
3077 AC_VERB_SET_CONNECT_SEL, j);
3085 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3086 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3089 * Fill in the dac_nids table from the parsed pin configuration
3090 * This function only works when every pin in line_out_pins[]
3091 * contains atleast one DAC in its connection list. Some 92xx
3092 * codecs are not connected directly to a DAC, such as the 9200
3093 * and 9202/925x. For those, dac_nids[] must be hard-coded.
3095 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
3097 struct sigmatel_spec *spec = codec->spec;
3098 struct auto_pin_cfg *cfg = &spec->autocfg;
3102 for (i = 0; i < cfg->line_outs; i++) {
3103 nid = cfg->line_out_pins[i];
3104 dac = get_unassigned_dac(codec, nid);
3106 if (spec->multiout.num_dacs > 0) {
3107 /* we have already working output pins,
3108 * so let's drop the broken ones again
3110 cfg->line_outs = spec->multiout.num_dacs;
3113 /* error out, no available DAC found */
3115 "%s: No available DAC for pin 0x%x\n",
3119 add_spec_dacs(spec, dac);
3122 for (i = 0; i < cfg->hp_outs; i++) {
3123 nid = cfg->hp_pins[i];
3124 dac = get_unassigned_dac(codec, nid);
3126 if (!spec->multiout.hp_nid)
3127 spec->multiout.hp_nid = dac;
3129 add_spec_extra_dacs(spec, dac);
3131 spec->hp_dacs[i] = dac;
3134 for (i = 0; i < cfg->speaker_outs; i++) {
3135 nid = cfg->speaker_pins[i];
3136 dac = get_unassigned_dac(codec, nid);
3138 add_spec_extra_dacs(spec, dac);
3139 spec->speaker_dacs[i] = dac;
3142 /* add line-in as output */
3143 nid = check_line_out_switch(codec);
3145 dac = get_unassigned_dac(codec, nid);
3147 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3148 nid, cfg->line_outs);
3149 cfg->line_out_pins[cfg->line_outs] = nid;
3151 spec->line_switch = nid;
3152 add_spec_dacs(spec, dac);
3155 /* add mic as output */
3156 nid = check_mic_out_switch(codec);
3158 dac = get_unassigned_dac(codec, nid);
3160 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3161 nid, cfg->line_outs);
3162 cfg->line_out_pins[cfg->line_outs] = nid;
3164 spec->mic_switch = nid;
3165 add_spec_dacs(spec, dac);
3169 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3170 spec->multiout.num_dacs,
3171 spec->multiout.dac_nids[0],
3172 spec->multiout.dac_nids[1],
3173 spec->multiout.dac_nids[2],
3174 spec->multiout.dac_nids[3],
3175 spec->multiout.dac_nids[4]);
3180 /* create volume control/switch for the given prefx type */
3181 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3182 int idx, hda_nid_t nid, int chs)
3184 struct sigmatel_spec *spec = codec->spec;
3188 if (!spec->check_volume_offset) {
3189 unsigned int caps, step, nums, db_scale;
3190 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3191 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3192 AC_AMPCAP_STEP_SIZE_SHIFT;
3193 step = (step + 1) * 25; /* in .01dB unit */
3194 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3195 AC_AMPCAP_NUM_STEPS_SHIFT;
3196 db_scale = nums * step;
3197 /* if dB scale is over -64dB, and finer enough,
3198 * let's reduce it to half
3200 if (db_scale > 6400 && nums >= 0x1f)
3201 spec->volume_offset = nums / 2;
3202 spec->check_volume_offset = 1;
3205 sprintf(name, "%s Playback Volume", pfx);
3206 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
3207 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3208 spec->volume_offset));
3211 sprintf(name, "%s Playback Switch", pfx);
3212 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
3213 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3219 #define create_controls(codec, pfx, nid, chs) \
3220 create_controls_idx(codec, pfx, 0, nid, chs)
3222 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3224 if (spec->multiout.num_dacs > 4) {
3225 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3228 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3229 spec->multiout.num_dacs++;
3234 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3237 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3238 if (!spec->multiout.extra_out_nid[i]) {
3239 spec->multiout.extra_out_nid[i] = nid;
3243 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3247 /* Create output controls
3248 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3250 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3251 const hda_nid_t *pins,
3252 const hda_nid_t *dac_nids,
3255 struct sigmatel_spec *spec = codec->spec;
3256 static const char *chname[4] = {
3257 "Front", "Surround", NULL /*CLFE*/, "Side"
3261 unsigned int wid_caps;
3263 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3264 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3265 wid_caps = get_wcaps(codec, pins[i]);
3266 if (wid_caps & AC_WCAP_UNSOL_CAP)
3267 spec->hp_detect = 1;
3272 if (type != AUTO_PIN_HP_OUT && i == 2) {
3274 err = create_controls(codec, "Center", nid, 1);
3277 err = create_controls(codec, "LFE", nid, 2);
3281 wid_caps = get_wcaps(codec, nid);
3283 if (wid_caps & AC_WCAP_LR_SWAP) {
3284 err = stac92xx_add_control(spec,
3285 STAC_CTL_WIDGET_CLFE_SWITCH,
3286 "Swap Center/LFE Playback Switch", nid);
3296 case AUTO_PIN_HP_OUT:
3300 case AUTO_PIN_SPEAKER_OUT:
3309 err = create_controls_idx(codec, name, idx, nid, 3);
3317 /* add playback controls from the parsed DAC table */
3318 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3319 const struct auto_pin_cfg *cfg)
3321 struct sigmatel_spec *spec = codec->spec;
3326 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3327 spec->multiout.dac_nids,
3328 cfg->line_out_type);
3332 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3333 err = stac92xx_add_control(spec,
3334 STAC_CTL_WIDGET_HP_SWITCH,
3335 "Headphone as Line Out Switch",
3336 cfg->hp_pins[cfg->hp_outs - 1]);
3341 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3342 nid = cfg->input_pins[idx];
3344 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3353 /* add playback controls for Speaker and HP outputs */
3354 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3355 struct auto_pin_cfg *cfg)
3357 struct sigmatel_spec *spec = codec->spec;
3360 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3361 spec->hp_dacs, AUTO_PIN_HP_OUT);
3365 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3366 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3373 /* labels for mono mux outputs */
3374 static const char *stac92xx_mono_labels[4] = {
3375 "DAC0", "DAC1", "Mixer", "DAC2"
3378 /* create mono mux for mono out on capable codecs */
3379 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3381 struct sigmatel_spec *spec = codec->spec;
3382 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3384 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3386 num_cons = snd_hda_get_connections(codec,
3389 HDA_MAX_NUM_INPUTS);
3390 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3393 for (i = 0; i < num_cons; i++) {
3394 mono_mux->items[mono_mux->num_items].label =
3395 stac92xx_mono_labels[i];
3396 mono_mux->items[mono_mux->num_items].index = i;
3397 mono_mux->num_items++;
3400 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3401 "Mono Mux", spec->mono_nid);
3404 /* labels for amp mux outputs */
3405 static const char *stac92xx_amp_labels[3] = {
3406 "Front Microphone", "Microphone", "Line In",
3409 /* create amp out controls mux on capable codecs */
3410 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3412 struct sigmatel_spec *spec = codec->spec;
3413 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3416 for (i = 0; i < spec->num_amps; i++) {
3417 amp_mux->items[amp_mux->num_items].label =
3418 stac92xx_amp_labels[i];
3419 amp_mux->items[amp_mux->num_items].index = i;
3420 amp_mux->num_items++;
3423 if (spec->num_amps > 1) {
3424 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3425 "Amp Selector Capture Switch", 0);
3429 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3430 "Amp Capture Volume",
3431 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3435 /* create PC beep volume controls */
3436 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3439 struct sigmatel_spec *spec = codec->spec;
3440 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3443 /* check for mute support for the the amp */
3444 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3445 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3446 "PC Beep Playback Switch",
3447 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3452 /* check to see if there is volume support for the amp */
3453 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3454 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3455 "PC Beep Playback Volume",
3456 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3463 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3464 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3466 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3467 struct snd_ctl_elem_value *ucontrol)
3469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3470 ucontrol->value.integer.value[0] = codec->beep->enabled;
3474 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3475 struct snd_ctl_elem_value *ucontrol)
3477 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3478 int enabled = !!ucontrol->value.integer.value[0];
3479 if (codec->beep->enabled != enabled) {
3480 codec->beep->enabled = enabled;
3486 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3487 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3488 .info = stac92xx_dig_beep_switch_info,
3489 .get = stac92xx_dig_beep_switch_get,
3490 .put = stac92xx_dig_beep_switch_put,
3493 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3495 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3496 0, "PC Beep Playback Switch", 0);
3500 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3502 struct sigmatel_spec *spec = codec->spec;
3503 int wcaps, nid, i, err = 0;
3505 for (i = 0; i < spec->num_muxes; i++) {
3506 nid = spec->mux_nids[i];
3507 wcaps = get_wcaps(codec, nid);
3509 if (wcaps & AC_WCAP_OUT_AMP) {
3510 err = stac92xx_add_control_idx(spec,
3511 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3512 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3520 static const char *stac92xx_spdif_labels[3] = {
3521 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3524 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3526 struct sigmatel_spec *spec = codec->spec;
3527 struct hda_input_mux *spdif_mux = &spec->private_smux;
3528 const char **labels = spec->spdif_labels;
3530 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3532 num_cons = snd_hda_get_connections(codec,
3535 HDA_MAX_NUM_INPUTS);
3540 labels = stac92xx_spdif_labels;
3542 for (i = 0; i < num_cons; i++) {
3543 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3544 spdif_mux->items[spdif_mux->num_items].index = i;
3545 spdif_mux->num_items++;
3551 /* labels for dmic mux inputs */
3552 static const char *stac92xx_dmic_labels[5] = {
3553 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3554 "Digital Mic 3", "Digital Mic 4"
3557 /* create playback/capture controls for input pins on dmic capable codecs */
3558 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3559 const struct auto_pin_cfg *cfg)
3561 struct sigmatel_spec *spec = codec->spec;
3562 struct hda_input_mux *dimux = &spec->private_dimux;
3563 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3567 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3568 dimux->items[dimux->num_items].index = 0;
3571 for (i = 0; i < spec->num_dmics; i++) {
3576 unsigned int def_conf;
3578 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3579 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3582 nid = spec->dmic_nids[i];
3583 num_cons = snd_hda_get_connections(codec,
3586 HDA_MAX_NUM_INPUTS);
3587 for (j = 0; j < num_cons; j++)
3588 if (con_lst[j] == nid) {
3594 wcaps = get_wcaps(codec, nid) &
3595 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3598 sprintf(name, "%s Capture Volume",
3599 stac92xx_dmic_labels[dimux->num_items]);
3601 err = stac92xx_add_control(spec,
3602 STAC_CTL_WIDGET_VOL,
3604 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3605 (wcaps & AC_WCAP_OUT_AMP) ?
3606 HDA_OUTPUT : HDA_INPUT));
3611 dimux->items[dimux->num_items].label =
3612 stac92xx_dmic_labels[dimux->num_items];
3613 dimux->items[dimux->num_items].index = index;
3620 /* create playback/capture controls for input pins */
3621 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3623 struct sigmatel_spec *spec = codec->spec;
3624 struct hda_input_mux *imux = &spec->private_imux;
3625 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3628 for (i = 0; i < AUTO_PIN_LAST; i++) {
3631 if (!cfg->input_pins[i])
3634 for (j = 0; j < spec->num_muxes; j++) {
3636 num_cons = snd_hda_get_connections(codec,
3639 HDA_MAX_NUM_INPUTS);
3640 for (k = 0; k < num_cons; k++)
3641 if (con_lst[k] == cfg->input_pins[i]) {
3648 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3649 imux->items[imux->num_items].index = index;
3653 if (imux->num_items) {
3655 * Set the current input for the muxes.
3656 * The STAC9221 has two input muxes with identical source
3657 * NID lists. Hopefully this won't get confused.
3659 for (i = 0; i < spec->num_muxes; i++) {
3660 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3661 AC_VERB_SET_CONNECT_SEL,
3662 imux->items[0].index);
3669 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3671 struct sigmatel_spec *spec = codec->spec;
3674 for (i = 0; i < spec->autocfg.line_outs; i++) {
3675 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3676 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3680 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3682 struct sigmatel_spec *spec = codec->spec;
3685 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3687 pin = spec->autocfg.hp_pins[i];
3688 if (pin) /* connect to front */
3689 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3691 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3693 pin = spec->autocfg.speaker_pins[i];
3694 if (pin) /* connect to front */
3695 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3699 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3701 struct sigmatel_spec *spec = codec->spec;
3705 if ((err = snd_hda_parse_pin_def_config(codec,
3707 spec->dmic_nids)) < 0)
3709 if (! spec->autocfg.line_outs)
3710 return 0; /* can't find valid pin config */
3712 /* If we have no real line-out pin and multiple hp-outs, HPs should
3713 * be set up as multi-channel outputs.
3715 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3716 spec->autocfg.hp_outs > 1) {
3717 /* Copy hp_outs to line_outs, backup line_outs in
3718 * speaker_outs so that the following routines can handle
3719 * HP pins as primary outputs.
3721 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3722 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3723 sizeof(spec->autocfg.line_out_pins));
3724 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3725 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3726 sizeof(spec->autocfg.hp_pins));
3727 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3728 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3729 spec->autocfg.hp_outs = 0;
3732 if (spec->autocfg.mono_out_pin) {
3733 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3734 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3735 u32 caps = query_amp_caps(codec,
3736 spec->autocfg.mono_out_pin, dir);
3737 hda_nid_t conn_list[1];
3739 /* get the mixer node and then the mono mux if it exists */
3740 if (snd_hda_get_connections(codec,
3741 spec->autocfg.mono_out_pin, conn_list, 1) &&
3742 snd_hda_get_connections(codec, conn_list[0],
3745 int wcaps = get_wcaps(codec, conn_list[0]);
3746 int wid_type = (wcaps & AC_WCAP_TYPE)
3747 >> AC_WCAP_TYPE_SHIFT;
3748 /* LR swap check, some stac925x have a mux that
3749 * changes the DACs output path instead of the
3752 if (wid_type == AC_WID_AUD_SEL &&
3753 !(wcaps & AC_WCAP_LR_SWAP))
3754 spec->mono_nid = conn_list[0];
3757 hda_nid_t nid = spec->autocfg.mono_out_pin;
3759 /* most mono outs have a least a mute/unmute switch */
3760 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3761 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3762 "Mono Playback Switch",
3763 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3766 /* check for volume support for the amp */
3767 if ((caps & AC_AMPCAP_NUM_STEPS)
3768 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3769 err = stac92xx_add_control(spec,
3770 STAC_CTL_WIDGET_VOL,
3771 "Mono Playback Volume",
3772 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3778 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3782 if (!spec->multiout.num_dacs) {
3783 err = stac92xx_auto_fill_dac_nids(codec);
3786 err = stac92xx_auto_create_multi_out_ctls(codec,
3792 /* setup analog beep controls */
3793 if (spec->anabeep_nid > 0) {
3794 err = stac92xx_auto_create_beep_ctls(codec,
3800 /* setup digital beep controls and input device */
3801 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3802 if (spec->digbeep_nid > 0) {
3803 hda_nid_t nid = spec->digbeep_nid;
3806 err = stac92xx_auto_create_beep_ctls(codec, nid);
3809 err = snd_hda_attach_beep_device(codec, nid);
3812 /* IDT/STAC codecs have linear beep tone parameter */
3813 codec->beep->linear_tone = 1;
3814 /* if no beep switch is available, make its own one */
3815 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3817 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3818 err = stac92xx_beep_switch_ctl(codec);
3825 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3829 /* All output parsing done, now restore the swapped hp pins */
3831 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3832 sizeof(spec->autocfg.hp_pins));
3833 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3834 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3835 spec->autocfg.line_outs = 0;
3838 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3842 if (spec->mono_nid > 0) {
3843 err = stac92xx_auto_create_mono_output_ctls(codec);
3847 if (spec->num_amps > 0) {
3848 err = stac92xx_auto_create_amp_output_ctls(codec);
3852 if (spec->num_dmics > 0 && !spec->dinput_mux)
3853 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3854 &spec->autocfg)) < 0)
3856 if (spec->num_muxes > 0) {
3857 err = stac92xx_auto_create_mux_input_ctls(codec);
3861 if (spec->num_smuxes > 0) {
3862 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3867 err = stac92xx_add_input_source(spec);
3871 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3872 if (spec->multiout.max_channels > 2)
3873 spec->surr_switch = 1;
3875 if (spec->autocfg.dig_outs)
3876 spec->multiout.dig_out_nid = dig_out;
3877 if (dig_in && spec->autocfg.dig_in_pin)
3878 spec->dig_in_nid = dig_in;
3880 if (spec->kctls.list)
3881 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3883 spec->input_mux = &spec->private_imux;
3884 if (!spec->dinput_mux)
3885 spec->dinput_mux = &spec->private_dimux;
3886 spec->sinput_mux = &spec->private_smux;
3887 spec->mono_mux = &spec->private_mono_mux;
3888 spec->amp_mux = &spec->private_amp_mux;
3892 /* add playback controls for HP output */
3893 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3894 struct auto_pin_cfg *cfg)
3896 struct sigmatel_spec *spec = codec->spec;
3897 hda_nid_t pin = cfg->hp_pins[0];
3898 unsigned int wid_caps;
3903 wid_caps = get_wcaps(codec, pin);
3904 if (wid_caps & AC_WCAP_UNSOL_CAP)
3905 spec->hp_detect = 1;
3910 /* add playback controls for LFE output */
3911 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3912 struct auto_pin_cfg *cfg)
3914 struct sigmatel_spec *spec = codec->spec;
3916 hda_nid_t lfe_pin = 0x0;
3920 * search speaker outs and line outs for a mono speaker pin
3921 * with an amp. If one is found, add LFE controls
3924 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3925 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3926 unsigned int wcaps = get_wcaps(codec, pin);
3927 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3928 if (wcaps == AC_WCAP_OUT_AMP)
3929 /* found a mono speaker with an amp, must be lfe */
3933 /* if speaker_outs is 0, then speakers may be in line_outs */
3934 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3935 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3936 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3937 unsigned int defcfg;
3938 defcfg = snd_hda_codec_get_pincfg(codec, pin);
3939 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3940 unsigned int wcaps = get_wcaps(codec, pin);
3941 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3942 if (wcaps == AC_WCAP_OUT_AMP)
3943 /* found a mono speaker with an amp,
3951 err = create_controls(codec, "LFE", lfe_pin, 1);
3959 static int stac9200_parse_auto_config(struct hda_codec *codec)
3961 struct sigmatel_spec *spec = codec->spec;
3964 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3967 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3970 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3973 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3976 if (spec->num_muxes > 0) {
3977 err = stac92xx_auto_create_mux_input_ctls(codec);
3982 err = stac92xx_add_input_source(spec);
3986 if (spec->autocfg.dig_outs)
3987 spec->multiout.dig_out_nid = 0x05;
3988 if (spec->autocfg.dig_in_pin)
3989 spec->dig_in_nid = 0x04;
3991 if (spec->kctls.list)
3992 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3994 spec->input_mux = &spec->private_imux;
3995 spec->dinput_mux = &spec->private_dimux;
4001 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4002 * funky external mute control using GPIO pins.
4005 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4006 unsigned int dir_mask, unsigned int data)
4008 unsigned int gpiostate, gpiomask, gpiodir;
4010 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4011 AC_VERB_GET_GPIO_DATA, 0);
4012 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
4014 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4015 AC_VERB_GET_GPIO_MASK, 0);
4018 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4019 AC_VERB_GET_GPIO_DIRECTION, 0);
4020 gpiodir |= dir_mask;
4022 /* Configure GPIOx as CMOS */
4023 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4025 snd_hda_codec_write(codec, codec->afg, 0,
4026 AC_VERB_SET_GPIO_MASK, gpiomask);
4027 snd_hda_codec_read(codec, codec->afg, 0,
4028 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
4032 snd_hda_codec_read(codec, codec->afg, 0,
4033 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
4036 #ifdef CONFIG_SND_JACK
4037 static void stac92xx_free_jack_priv(struct snd_jack *jack)
4039 struct sigmatel_jack *jacks = jack->private_data;
4045 static int stac92xx_add_jack(struct hda_codec *codec,
4046 hda_nid_t nid, int type)
4048 #ifdef CONFIG_SND_JACK
4049 struct sigmatel_spec *spec = codec->spec;
4050 struct sigmatel_jack *jack;
4051 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4052 int connectivity = get_defcfg_connect(def_conf);
4056 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4059 snd_array_init(&spec->jacks, sizeof(*jack), 32);
4060 jack = snd_array_new(&spec->jacks);
4066 sprintf(name, "%s at %s %s Jack",
4067 snd_hda_get_jack_type(def_conf),
4068 snd_hda_get_jack_connectivity(def_conf),
4069 snd_hda_get_jack_location(def_conf));
4071 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4076 jack->jack->private_data = jack;
4077 jack->jack->private_free = stac92xx_free_jack_priv;
4082 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4083 unsigned char type, int data)
4085 struct sigmatel_event *event;
4087 snd_array_init(&spec->events, sizeof(*event), 32);
4088 event = snd_array_new(&spec->events);
4093 event->tag = spec->events.used;
4099 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4100 hda_nid_t nid, unsigned char type)
4102 struct sigmatel_spec *spec = codec->spec;
4103 struct sigmatel_event *event = spec->events.list;
4106 for (i = 0; i < spec->events.used; i++, event++) {
4107 if (event->nid == nid && event->type == type)
4113 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4116 struct sigmatel_spec *spec = codec->spec;
4117 struct sigmatel_event *event = spec->events.list;
4120 for (i = 0; i < spec->events.used; i++, event++) {
4121 if (event->tag == tag)
4127 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4130 struct sigmatel_event *event;
4133 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4135 event = stac_get_event(codec, nid, type);
4139 tag = stac_add_event(codec->spec, nid, type, 0);
4142 snd_hda_codec_write_cache(codec, nid, 0,
4143 AC_VERB_SET_UNSOLICITED_ENABLE,
4147 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4150 for (i = 0; i < cfg->hp_outs; i++)
4151 if (cfg->hp_pins[i] == nid)
4152 return 1; /* nid is a HP-Out */
4154 return 0; /* nid is not a HP-Out */
4157 static void stac92xx_power_down(struct hda_codec *codec)
4159 struct sigmatel_spec *spec = codec->spec;
4161 /* power down inactive DACs */
4163 for (dac = spec->dac_list; *dac; dac++)
4164 if (!check_all_dac_nids(spec, *dac))
4165 snd_hda_codec_write(codec, *dac, 0,
4166 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4169 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4172 /* override some hints from the hwdep entry */
4173 static void stac_store_hints(struct hda_codec *codec)
4175 struct sigmatel_spec *spec = codec->spec;
4179 val = snd_hda_get_bool_hint(codec, "hp_detect");
4181 spec->hp_detect = val;
4182 p = snd_hda_get_hint(codec, "gpio_mask");
4184 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4185 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4188 p = snd_hda_get_hint(codec, "gpio_dir");
4190 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4191 p = snd_hda_get_hint(codec, "gpio_data");
4193 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4194 p = snd_hda_get_hint(codec, "eapd_mask");
4196 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4197 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4199 spec->eapd_switch = val;
4202 static int stac92xx_init(struct hda_codec *codec)
4204 struct sigmatel_spec *spec = codec->spec;
4205 struct auto_pin_cfg *cfg = &spec->autocfg;
4209 snd_hda_sequence_write(codec, spec->init);
4211 /* power down adcs initially */
4212 if (spec->powerdown_adcs)
4213 for (i = 0; i < spec->num_adcs; i++)
4214 snd_hda_codec_write(codec,
4215 spec->adc_nids[i], 0,
4216 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4218 /* override some hints */
4219 stac_store_hints(codec);
4222 gpio = spec->gpio_data;
4223 /* turn on EAPD statically when spec->eapd_switch isn't set.
4224 * otherwise, unsol event will turn it on/off dynamically
4226 if (!spec->eapd_switch)
4227 gpio |= spec->eapd_mask;
4228 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4231 if (spec->hp_detect) {
4232 /* Enable unsolicited responses on the HP widget */
4233 for (i = 0; i < cfg->hp_outs; i++) {
4234 hda_nid_t nid = cfg->hp_pins[i];
4235 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4237 /* force to enable the first line-out; the others are set up
4240 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4242 /* fake event to set up pins */
4243 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4246 stac92xx_auto_init_multi_out(codec);
4247 stac92xx_auto_init_hp_out(codec);
4248 for (i = 0; i < cfg->hp_outs; i++)
4249 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4251 for (i = 0; i < AUTO_PIN_LAST; i++) {
4252 hda_nid_t nid = cfg->input_pins[i];
4254 unsigned int pinctl, conf;
4255 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4256 /* for mic pins, force to initialize */
4257 pinctl = stac92xx_get_default_vref(codec, nid);
4258 pinctl |= AC_PINCTL_IN_EN;
4259 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4261 pinctl = snd_hda_codec_read(codec, nid, 0,
4262 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4263 /* if PINCTL already set then skip */
4264 /* Also, if both INPUT and OUTPUT are set,
4265 * it must be a BIOS bug; need to override, too
4267 if (!(pinctl & AC_PINCTL_IN_EN) ||
4268 (pinctl & AC_PINCTL_OUT_EN)) {
4269 pinctl &= ~AC_PINCTL_OUT_EN;
4270 pinctl |= AC_PINCTL_IN_EN;
4271 stac92xx_auto_set_pinctl(codec, nid,
4275 conf = snd_hda_codec_get_pincfg(codec, nid);
4276 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4277 enable_pin_detect(codec, nid,
4279 stac_issue_unsol_event(codec, nid,
4284 for (i = 0; i < spec->num_dmics; i++)
4285 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4287 if (cfg->dig_out_pins[0])
4288 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4290 if (cfg->dig_in_pin)
4291 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4293 for (i = 0; i < spec->num_pwrs; i++) {
4294 hda_nid_t nid = spec->pwr_nids[i];
4295 int pinctl, def_conf;
4297 /* power on when no jack detection is available */
4298 if (!spec->hp_detect) {
4299 stac_toggle_power_map(codec, nid, 1);
4303 if (is_nid_hp_pin(cfg, nid))
4304 continue; /* already has an unsol event */
4306 pinctl = snd_hda_codec_read(codec, nid, 0,
4307 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4308 /* outputs are only ports capable of power management
4309 * any attempts on powering down a input port cause the
4310 * referenced VREF to act quirky.
4312 if (pinctl & AC_PINCTL_IN_EN) {
4313 stac_toggle_power_map(codec, nid, 1);
4316 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4317 def_conf = get_defcfg_connect(def_conf);
4318 /* skip any ports that don't have jacks since presence
4319 * detection is useless */
4320 if (def_conf != AC_JACK_PORT_COMPLEX) {
4321 if (def_conf != AC_JACK_PORT_NONE)
4322 stac_toggle_power_map(codec, nid, 1);
4325 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4326 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4327 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4331 stac92xx_power_down(codec);
4335 static void stac92xx_free_jacks(struct hda_codec *codec)
4337 #ifdef CONFIG_SND_JACK
4338 /* free jack instances manually when clearing/reconfiguring */
4339 struct sigmatel_spec *spec = codec->spec;
4340 if (!codec->bus->shutdown && spec->jacks.list) {
4341 struct sigmatel_jack *jacks = spec->jacks.list;
4343 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4345 snd_device_free(codec->bus->card, jacks->jack);
4348 snd_array_free(&spec->jacks);
4352 static void stac92xx_free_kctls(struct hda_codec *codec)
4354 struct sigmatel_spec *spec = codec->spec;
4356 if (spec->kctls.list) {
4357 struct snd_kcontrol_new *kctl = spec->kctls.list;
4359 for (i = 0; i < spec->kctls.used; i++)
4360 kfree(kctl[i].name);
4362 snd_array_free(&spec->kctls);
4365 static void stac92xx_free(struct hda_codec *codec)
4367 struct sigmatel_spec *spec = codec->spec;
4372 stac92xx_free_jacks(codec);
4373 snd_array_free(&spec->events);
4376 snd_hda_detach_beep_device(codec);
4379 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4382 unsigned int old_ctl, pin_ctl;
4384 pin_ctl = snd_hda_codec_read(codec, nid,
4385 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4387 if (pin_ctl & AC_PINCTL_IN_EN) {
4389 * we need to check the current set-up direction of
4390 * shared input pins since they can be switched via
4391 * "xxx as Output" mixer switch
4393 struct sigmatel_spec *spec = codec->spec;
4394 if (nid == spec->line_switch || nid == spec->mic_switch)
4399 /* if setting pin direction bits, clear the current
4400 direction bits first */
4401 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4402 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4405 if (old_ctl != pin_ctl)
4406 snd_hda_codec_write_cache(codec, nid, 0,
4407 AC_VERB_SET_PIN_WIDGET_CONTROL,
4411 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4414 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4415 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4417 snd_hda_codec_write_cache(codec, nid, 0,
4418 AC_VERB_SET_PIN_WIDGET_CONTROL,
4422 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4426 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
4432 /* return non-zero if the hp-pin of the given array index isn't
4433 * a jack-detection target
4435 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4437 struct auto_pin_cfg *cfg = &spec->autocfg;
4439 /* ignore sensing of shared line and mic jacks */
4440 if (cfg->hp_pins[i] == spec->line_switch)
4442 if (cfg->hp_pins[i] == spec->mic_switch)
4444 /* ignore if the pin is set as line-out */
4445 if (cfg->hp_pins[i] == spec->hp_switch)
4450 static void stac92xx_hp_detect(struct hda_codec *codec)
4452 struct sigmatel_spec *spec = codec->spec;
4453 struct auto_pin_cfg *cfg = &spec->autocfg;
4457 if (spec->gpio_mute)
4458 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4459 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4461 for (i = 0; i < cfg->hp_outs; i++) {
4464 if (no_hp_sensing(spec, i))
4466 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4468 unsigned int pinctl;
4469 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4470 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4471 if (pinctl & AC_PINCTL_IN_EN)
4472 presence = 0; /* mic- or line-input */
4477 /* disable lineouts */
4478 if (spec->hp_switch)
4479 stac92xx_reset_pinctl(codec, spec->hp_switch,
4481 for (i = 0; i < cfg->line_outs; i++)
4482 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4484 for (i = 0; i < cfg->speaker_outs; i++)
4485 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4487 if (spec->eapd_mask && spec->eapd_switch)
4488 stac_gpio_set(codec, spec->gpio_mask,
4489 spec->gpio_dir, spec->gpio_data &
4492 /* enable lineouts */
4493 if (spec->hp_switch)
4494 stac92xx_set_pinctl(codec, spec->hp_switch,
4496 for (i = 0; i < cfg->line_outs; i++)
4497 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4499 for (i = 0; i < cfg->speaker_outs; i++)
4500 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4502 if (spec->eapd_mask && spec->eapd_switch)
4503 stac_gpio_set(codec, spec->gpio_mask,
4504 spec->gpio_dir, spec->gpio_data |
4507 /* toggle hp outs */
4508 for (i = 0; i < cfg->hp_outs; i++) {
4509 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4510 if (no_hp_sensing(spec, i))
4513 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4515 /* Resetting the pinctl like below may lead to (a sort of) regressions
4516 * on some devices since they use the HP pin actually for line/speaker
4517 * outs although the default pin config shows a different pin (that is
4518 * wrong and useless).
4520 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4521 * But, disabling the code below just works around it, and I'm too tired of
4522 * bug reports with such devices...
4525 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4530 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4533 struct sigmatel_spec *spec = codec->spec;
4534 unsigned int idx, val;
4536 for (idx = 0; idx < spec->num_pwrs; idx++) {
4537 if (spec->pwr_nids[idx] == nid)
4540 if (idx >= spec->num_pwrs)
4543 /* several codecs have two power down bits */
4544 if (spec->pwr_mapping)
4545 idx = spec->pwr_mapping[idx];
4549 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4555 /* power down unused output ports */
4556 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4559 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4561 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4564 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4566 struct sigmatel_spec *spec = codec->spec;
4567 struct sigmatel_jack *jacks = spec->jacks.list;
4571 for (i = 0; i < spec->jacks.used; i++) {
4572 if (jacks->nid == nid) {
4573 unsigned int pin_ctl =
4574 snd_hda_codec_read(codec, nid,
4575 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4577 int type = jacks->type;
4578 if (type == (SND_JACK_LINEOUT
4579 | SND_JACK_HEADPHONE))
4580 type = (pin_ctl & AC_PINCTL_HP_EN)
4581 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4582 snd_jack_report(jacks->jack,
4583 get_pin_presence(codec, nid)
4591 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4594 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4597 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4600 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4602 struct sigmatel_spec *spec = codec->spec;
4603 struct sigmatel_event *event;
4606 tag = (res >> 26) & 0x7f;
4607 event = stac_get_event_from_tag(codec, tag);
4611 switch (event->type) {
4613 stac92xx_hp_detect(codec);
4615 case STAC_INSERT_EVENT:
4616 case STAC_PWR_EVENT:
4617 if (spec->num_pwrs > 0)
4618 stac92xx_pin_sense(codec, event->nid);
4619 stac92xx_report_jack(codec, event->nid);
4621 switch (codec->subsystem_id) {
4623 if (event->nid == 0xb) {
4624 int pin = AC_PINCTL_IN_EN;
4626 if (get_pin_presence(codec, 0xa)
4627 && get_pin_presence(codec, 0xb))
4628 pin |= AC_PINCTL_VREF_80;
4629 if (!get_pin_presence(codec, 0xb))
4630 pin |= AC_PINCTL_VREF_80;
4632 /* toggle VREF state based on mic + hp pin
4635 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4639 case STAC_VREF_EVENT:
4640 data = snd_hda_codec_read(codec, codec->afg, 0,
4641 AC_VERB_GET_GPIO_DATA, 0);
4642 /* toggle VREF state based on GPIOx status */
4643 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4644 !!(data & (1 << event->data)));
4649 #ifdef CONFIG_PROC_FS
4650 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4651 struct hda_codec *codec, hda_nid_t nid)
4653 if (nid == codec->afg)
4654 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4655 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4658 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4659 struct hda_codec *codec,
4662 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4663 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4666 /* stac92hd71bxx, stac92hd73xx */
4667 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4668 struct hda_codec *codec, hda_nid_t nid)
4670 stac92hd_proc_hook(buffer, codec, nid);
4671 if (nid == codec->afg)
4672 analog_loop_proc_hook(buffer, codec, 0xfa0);
4675 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4676 struct hda_codec *codec, hda_nid_t nid)
4678 if (nid == codec->afg)
4679 analog_loop_proc_hook(buffer, codec, 0xfe0);
4682 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4683 struct hda_codec *codec, hda_nid_t nid)
4685 if (nid == codec->afg)
4686 analog_loop_proc_hook(buffer, codec, 0xfeb);
4689 #define stac92hd_proc_hook NULL
4690 #define stac92hd7x_proc_hook NULL
4691 #define stac9205_proc_hook NULL
4692 #define stac927x_proc_hook NULL
4695 #ifdef SND_HDA_NEEDS_RESUME
4696 static int stac92xx_resume(struct hda_codec *codec)
4698 struct sigmatel_spec *spec = codec->spec;
4700 stac92xx_init(codec);
4701 snd_hda_codec_resume_amp(codec);
4702 snd_hda_codec_resume_cache(codec);
4703 /* fake event to set up pins again to override cached values */
4704 if (spec->hp_detect)
4705 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4711 * using power check for controlling mute led of HP notebooks
4712 * check for mute state only on Speakers (nid = 0x10)
4714 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4715 * the LED is NOT working properly !
4717 * Changed name to reflect that it now works for any designated
4718 * model, not just HP HDX.
4721 #ifdef CONFIG_SND_HDA_POWER_SAVE
4722 static int stac92xx_hp_check_power_status(struct hda_codec *codec,
4725 struct sigmatel_spec *spec = codec->spec;
4728 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4730 spec->gpio_data &= ~spec->gpio_led; /* orange */
4732 spec->gpio_data |= spec->gpio_led; /* white */
4734 stac_gpio_set(codec, spec->gpio_mask,
4743 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4745 struct sigmatel_spec *spec = codec->spec;
4746 if (spec->eapd_mask)
4747 stac_gpio_set(codec, spec->gpio_mask,
4748 spec->gpio_dir, spec->gpio_data &
4754 static struct hda_codec_ops stac92xx_patch_ops = {
4755 .build_controls = stac92xx_build_controls,
4756 .build_pcms = stac92xx_build_pcms,
4757 .init = stac92xx_init,
4758 .free = stac92xx_free,
4759 .unsol_event = stac92xx_unsol_event,
4760 #ifdef SND_HDA_NEEDS_RESUME
4761 .suspend = stac92xx_suspend,
4762 .resume = stac92xx_resume,
4766 static int patch_stac9200(struct hda_codec *codec)
4768 struct sigmatel_spec *spec;
4771 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4776 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4777 spec->pin_nids = stac9200_pin_nids;
4778 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4781 if (spec->board_config < 0)
4782 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4784 stac92xx_set_config_regs(codec,
4785 stac9200_brd_tbl[spec->board_config]);
4787 spec->multiout.max_channels = 2;
4788 spec->multiout.num_dacs = 1;
4789 spec->multiout.dac_nids = stac9200_dac_nids;
4790 spec->adc_nids = stac9200_adc_nids;
4791 spec->mux_nids = stac9200_mux_nids;
4792 spec->num_muxes = 1;
4793 spec->num_dmics = 0;
4797 if (spec->board_config == STAC_9200_M4 ||
4798 spec->board_config == STAC_9200_M4_2 ||
4799 spec->board_config == STAC_9200_OQO)
4800 spec->init = stac9200_eapd_init;
4802 spec->init = stac9200_core_init;
4803 spec->mixer = stac9200_mixer;
4805 if (spec->board_config == STAC_9200_PANASONIC) {
4806 spec->gpio_mask = spec->gpio_dir = 0x09;
4807 spec->gpio_data = 0x00;
4810 err = stac9200_parse_auto_config(codec);
4812 stac92xx_free(codec);
4816 /* CF-74 has no headphone detection, and the driver should *NOT*
4817 * do detection and HP/speaker toggle because the hardware does it.
4819 if (spec->board_config == STAC_9200_PANASONIC)
4820 spec->hp_detect = 0;
4822 codec->patch_ops = stac92xx_patch_ops;
4827 static int patch_stac925x(struct hda_codec *codec)
4829 struct sigmatel_spec *spec;
4832 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4837 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4838 spec->pin_nids = stac925x_pin_nids;
4840 /* Check first for codec ID */
4841 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4844 stac925x_codec_id_cfg_tbl);
4846 /* Now checks for PCI ID, if codec ID is not found */
4847 if (spec->board_config < 0)
4848 spec->board_config = snd_hda_check_board_config(codec,
4853 if (spec->board_config < 0)
4854 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4855 "using BIOS defaults\n");
4857 stac92xx_set_config_regs(codec,
4858 stac925x_brd_tbl[spec->board_config]);
4860 spec->multiout.max_channels = 2;
4861 spec->multiout.num_dacs = 1;
4862 spec->multiout.dac_nids = stac925x_dac_nids;
4863 spec->adc_nids = stac925x_adc_nids;
4864 spec->mux_nids = stac925x_mux_nids;
4865 spec->num_muxes = 1;
4868 switch (codec->vendor_id) {
4869 case 0x83847632: /* STAC9202 */
4870 case 0x83847633: /* STAC9202D */
4871 case 0x83847636: /* STAC9251 */
4872 case 0x83847637: /* STAC9251D */
4873 spec->num_dmics = STAC925X_NUM_DMICS;
4874 spec->dmic_nids = stac925x_dmic_nids;
4875 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4876 spec->dmux_nids = stac925x_dmux_nids;
4879 spec->num_dmics = 0;
4883 spec->init = stac925x_core_init;
4884 spec->mixer = stac925x_mixer;
4886 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4888 if (spec->board_config < 0) {
4889 printk(KERN_WARNING "hda_codec: No auto-config is "
4890 "available, default to model=ref\n");
4891 spec->board_config = STAC_925x_REF;
4897 stac92xx_free(codec);
4901 codec->patch_ops = stac92xx_patch_ops;
4906 static struct hda_input_mux stac92hd73xx_dmux = {
4909 { "Analog Inputs", 0x0b },
4910 { "Digital Mic 1", 0x09 },
4911 { "Digital Mic 2", 0x0a },
4916 static int patch_stac92hd73xx(struct hda_codec *codec)
4918 struct sigmatel_spec *spec;
4919 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4923 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4928 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4929 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4930 spec->pin_nids = stac92hd73xx_pin_nids;
4931 spec->board_config = snd_hda_check_board_config(codec,
4932 STAC_92HD73XX_MODELS,
4933 stac92hd73xx_models,
4934 stac92hd73xx_cfg_tbl);
4936 if (spec->board_config < 0)
4937 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4938 " STAC92HD73XX, using BIOS defaults\n");
4940 stac92xx_set_config_regs(codec,
4941 stac92hd73xx_brd_tbl[spec->board_config]);
4943 num_dacs = snd_hda_get_connections(codec, 0x0a,
4944 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4946 if (num_dacs < 3 || num_dacs > 5) {
4947 printk(KERN_WARNING "hda_codec: Could not determine "
4948 "number of channels defaulting to DAC count\n");
4949 num_dacs = STAC92HD73_DAC_COUNT;
4952 case 0x3: /* 6 Channel */
4953 spec->mixer = stac92hd73xx_6ch_mixer;
4954 spec->init = stac92hd73xx_6ch_core_init;
4955 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
4957 case 0x4: /* 8 Channel */
4958 spec->mixer = stac92hd73xx_8ch_mixer;
4959 spec->init = stac92hd73xx_8ch_core_init;
4960 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
4962 case 0x5: /* 10 Channel */
4963 spec->mixer = stac92hd73xx_10ch_mixer;
4964 spec->init = stac92hd73xx_10ch_core_init;
4965 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4968 spec->multiout.dac_nids = spec->dac_nids;
4970 spec->aloopback_mask = 0x01;
4971 spec->aloopback_shift = 8;
4973 spec->digbeep_nid = 0x1c;
4974 spec->mux_nids = stac92hd73xx_mux_nids;
4975 spec->adc_nids = stac92hd73xx_adc_nids;
4976 spec->dmic_nids = stac92hd73xx_dmic_nids;
4977 spec->dmux_nids = stac92hd73xx_dmux_nids;
4978 spec->smux_nids = stac92hd73xx_smux_nids;
4979 spec->amp_nids = stac92hd73xx_amp_nids;
4980 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4982 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4983 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4984 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4985 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4986 sizeof(stac92hd73xx_dmux));
4988 switch (spec->board_config) {
4990 spec->init = dell_eq_core_init;
4992 case STAC_DELL_M6_AMIC:
4993 case STAC_DELL_M6_DMIC:
4994 case STAC_DELL_M6_BOTH:
4995 spec->num_smuxes = 0;
4996 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4997 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4998 spec->eapd_switch = 0;
5001 if (spec->board_config != STAC_DELL_EQ)
5002 spec->init = dell_m6_core_init;
5003 switch (spec->board_config) {
5004 case STAC_DELL_M6_AMIC: /* Analog Mics */
5005 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5006 spec->num_dmics = 0;
5007 spec->private_dimux.num_items = 1;
5009 case STAC_DELL_M6_DMIC: /* Digital Mics */
5010 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5011 spec->num_dmics = 1;
5012 spec->private_dimux.num_items = 2;
5014 case STAC_DELL_M6_BOTH: /* Both */
5015 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5016 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5017 spec->num_dmics = 1;
5018 spec->private_dimux.num_items = 2;
5023 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5024 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5025 spec->eapd_switch = 1;
5027 if (spec->board_config > STAC_92HD73XX_REF) {
5028 /* GPIO0 High = Enable EAPD */
5029 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5030 spec->gpio_data = 0x01;
5032 spec->dinput_mux = &spec->private_dimux;
5034 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5035 spec->pwr_nids = stac92hd73xx_pwr_nids;
5037 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
5040 if (spec->board_config < 0) {
5041 printk(KERN_WARNING "hda_codec: No auto-config is "
5042 "available, default to model=ref\n");
5043 spec->board_config = STAC_92HD73XX_REF;
5050 stac92xx_free(codec);
5054 if (spec->board_config == STAC_92HD73XX_NO_JD)
5055 spec->hp_detect = 0;
5057 codec->patch_ops = stac92xx_patch_ops;
5059 codec->proc_widget_hook = stac92hd7x_proc_hook;
5064 static struct hda_input_mux stac92hd83xxx_dmux = {
5067 { "Analog Inputs", 0x03 },
5068 { "Digital Mic 1", 0x04 },
5069 { "Digital Mic 2", 0x05 },
5073 static int patch_stac92hd83xxx(struct hda_codec *codec)
5075 struct sigmatel_spec *spec;
5076 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
5081 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5086 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5087 spec->mono_nid = 0x19;
5088 spec->digbeep_nid = 0x21;
5089 spec->dmic_nids = stac92hd83xxx_dmic_nids;
5090 spec->dmux_nids = stac92hd83xxx_dmux_nids;
5091 spec->adc_nids = stac92hd83xxx_adc_nids;
5092 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5093 spec->amp_nids = stac92hd83xxx_amp_nids;
5094 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5095 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5096 spec->multiout.dac_nids = spec->dac_nids;
5098 spec->init = stac92hd83xxx_core_init;
5099 spec->mixer = stac92hd83xxx_mixer;
5100 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5101 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
5102 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5103 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
5104 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
5105 spec->dinput_mux = &stac92hd83xxx_dmux;
5106 spec->pin_nids = stac92hd83xxx_pin_nids;
5107 spec->board_config = snd_hda_check_board_config(codec,
5108 STAC_92HD83XXX_MODELS,
5109 stac92hd83xxx_models,
5110 stac92hd83xxx_cfg_tbl);
5112 if (spec->board_config < 0)
5113 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5114 " STAC92HD83XXX, using BIOS defaults\n");
5116 stac92xx_set_config_regs(codec,
5117 stac92hd83xxx_brd_tbl[spec->board_config]);
5119 switch (codec->vendor_id) {
5123 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5129 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5131 if (spec->board_config < 0) {
5132 printk(KERN_WARNING "hda_codec: No auto-config is "
5133 "available, default to model=ref\n");
5134 spec->board_config = STAC_92HD83XXX_REF;
5141 stac92xx_free(codec);
5145 switch (spec->board_config) {
5154 num_dacs = snd_hda_get_connections(codec, nid,
5155 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5157 /* set port X to select the last DAC
5159 snd_hda_codec_write_cache(codec, nid, 0,
5160 AC_VERB_SET_CONNECT_SEL, num_dacs);
5162 codec->patch_ops = stac92xx_patch_ops;
5164 codec->proc_widget_hook = stac92hd_proc_hook;
5169 static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
5172 { "Analog Inputs", 0x00 },
5173 { "Digital Mic 1", 0x02 },
5174 { "Digital Mic 2", 0x03 },
5178 static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
5181 { "Analog Inputs", 0x00 },
5183 { "Digital Mic 1", 0x02 },
5184 { "Digital Mic 2", 0x03 },
5188 /* get the pin connection (fixed, none, etc) */
5189 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5191 struct sigmatel_spec *spec = codec->spec;
5194 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5195 return get_defcfg_connect(cfg);
5198 static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5199 hda_nid_t *nids, int num_nids)
5201 struct sigmatel_spec *spec = codec->spec;
5203 unsigned int def_conf;
5205 for (num = 0; num < num_nids; num++) {
5206 for (idx = 0; idx < spec->num_pins; idx++)
5207 if (spec->pin_nids[idx] == nids[num])
5209 if (idx >= spec->num_pins)
5211 def_conf = stac_get_defcfg_connect(codec, idx);
5212 if (def_conf == AC_JACK_PORT_NONE)
5218 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5221 struct sigmatel_spec *spec = codec->spec;
5224 for (idx = 0; idx < spec->num_pins; idx++)
5225 if (spec->pin_nids[idx] == dig0pin)
5227 if ((idx + 2) >= spec->num_pins)
5231 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5234 /* dig0pin + dig2pin case */
5235 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5237 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5243 static int patch_stac92hd71bxx(struct hda_codec *codec)
5245 struct sigmatel_spec *spec;
5246 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5248 unsigned int ndmic_nids = 0;
5250 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5255 codec->patch_ops = stac92xx_patch_ops;
5256 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5257 switch (codec->vendor_id) {
5260 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5264 /* On 92HD75Bx 0x27 isn't a pin nid */
5268 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5270 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5271 spec->board_config = snd_hda_check_board_config(codec,
5272 STAC_92HD71BXX_MODELS,
5273 stac92hd71bxx_models,
5274 stac92hd71bxx_cfg_tbl);
5276 if (spec->board_config < 0)
5277 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5278 " STAC92HD71BXX, using BIOS defaults\n");
5280 stac92xx_set_config_regs(codec,
5281 stac92hd71bxx_brd_tbl[spec->board_config]);
5283 if (spec->board_config > STAC_92HD71BXX_REF) {
5285 spec->gpio_mask = 0x01;
5286 spec->gpio_dir = 0x01;
5287 spec->gpio_data = 0x01;
5290 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5291 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5293 switch (codec->vendor_id) {
5294 case 0x111d76b6: /* 4 Port without Analog Mixer */
5298 case 0x111d76b4: /* 6 Port without Analog Mixer */
5300 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
5301 sizeof(stac92hd71bxx_dmux_nomixer));
5302 spec->mixer = stac92hd71bxx_mixer;
5303 spec->init = stac92hd71bxx_core_init;
5304 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5305 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5306 stac92hd71bxx_dmic_nids,
5307 STAC92HD71BXX_NUM_DMICS);
5308 if (spec->num_dmics) {
5309 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5310 spec->dinput_mux = &spec->private_dimux;
5311 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5314 case 0x111d7608: /* 5 Port with Analog Mixer */
5315 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5316 sizeof(stac92hd71bxx_dmux_amixer));
5317 spec->private_dimux.num_items--;
5318 switch (spec->board_config) {
5320 /* Enable VREF power saving on GPIO1 detect */
5321 err = stac_add_event(spec, codec->afg,
5322 STAC_VREF_EVENT, 0x02);
5325 snd_hda_codec_write_cache(codec, codec->afg, 0,
5326 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5327 snd_hda_codec_write_cache(codec, codec->afg, 0,
5328 AC_VERB_SET_UNSOLICITED_ENABLE,
5330 spec->gpio_mask |= 0x02;
5333 if ((codec->revision_id & 0xf) == 0 ||
5334 (codec->revision_id & 0xf) == 1)
5335 spec->stream_delay = 40; /* 40 milliseconds */
5337 /* no output amps */
5339 spec->mixer = stac92hd71bxx_analog_mixer;
5340 spec->dinput_mux = &spec->private_dimux;
5343 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
5345 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5346 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5347 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5348 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5349 stac92hd71bxx_dmic_nids,
5350 STAC92HD71BXX_NUM_DMICS - 1);
5351 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5352 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
5354 case 0x111d7603: /* 6 Port with Analog Mixer */
5355 if ((codec->revision_id & 0xf) == 1)
5356 spec->stream_delay = 40; /* 40 milliseconds */
5358 /* no output amps */
5362 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5363 sizeof(stac92hd71bxx_dmux_amixer));
5364 spec->dinput_mux = &spec->private_dimux;
5365 spec->mixer = stac92hd71bxx_analog_mixer;
5366 spec->init = stac92hd71bxx_analog_core_init;
5367 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5368 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5369 stac92hd71bxx_dmic_nids,
5370 STAC92HD71BXX_NUM_DMICS);
5371 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5372 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5375 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5376 snd_hda_sequence_write_cache(codec, unmute_init);
5378 /* Some HP machines seem to have unstable codec communications
5379 * especially with ATI fglrx driver. For recovering from the
5380 * CORB/RIRB stall, allow the BUS reset and keep always sync
5382 if (spec->board_config == STAC_HP_DV5) {
5383 codec->bus->sync_write = 1;
5384 codec->bus->allow_bus_reset = 1;
5387 spec->aloopback_ctl = stac92hd71bxx_loopback;
5388 spec->aloopback_mask = 0x50;
5389 spec->aloopback_shift = 0;
5391 spec->powerdown_adcs = 1;
5392 spec->digbeep_nid = 0x26;
5393 spec->mux_nids = stac92hd71bxx_mux_nids;
5394 spec->adc_nids = stac92hd71bxx_adc_nids;
5395 spec->smux_nids = stac92hd71bxx_smux_nids;
5396 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5398 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5399 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5400 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5402 switch (spec->board_config) {
5404 /* enable internal microphone */
5405 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5406 stac92xx_auto_set_pinctl(codec, 0x0e,
5407 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5409 case STAC_DELL_M4_2:
5410 spec->num_dmics = 0;
5411 spec->num_smuxes = 0;
5412 spec->num_dmuxes = 0;
5414 case STAC_DELL_M4_1:
5415 case STAC_DELL_M4_3:
5416 spec->num_dmics = 1;
5417 spec->num_smuxes = 0;
5418 spec->num_dmuxes = 1;
5420 case STAC_HP_DV4_1222NR:
5421 spec->num_dmics = 1;
5422 /* I don't know if it needs 1 or 2 smuxes - will wait for
5423 * bug reports to fix if needed
5425 spec->num_smuxes = 1;
5426 spec->num_dmuxes = 1;
5427 spec->gpio_led = 0x01;
5430 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5431 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5434 spec->num_dmics = 1;
5435 spec->num_dmuxes = 1;
5436 spec->num_smuxes = 1;
5437 /* orange/white mute led on GPIO3, orange=0, white=1 */
5438 spec->gpio_led = 0x08;
5442 #ifdef CONFIG_SND_HDA_POWER_SAVE
5443 if (spec->gpio_led) {
5444 spec->gpio_mask |= spec->gpio_led;
5445 spec->gpio_dir |= spec->gpio_led;
5446 spec->gpio_data |= spec->gpio_led;
5447 /* register check_power_status callback. */
5448 codec->patch_ops.check_power_status =
5449 stac92xx_hp_check_power_status;
5453 spec->multiout.dac_nids = spec->dac_nids;
5454 if (spec->dinput_mux)
5455 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
5457 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5459 if (spec->board_config < 0) {
5460 printk(KERN_WARNING "hda_codec: No auto-config is "
5461 "available, default to model=ref\n");
5462 spec->board_config = STAC_92HD71BXX_REF;
5469 stac92xx_free(codec);
5473 codec->proc_widget_hook = stac92hd7x_proc_hook;
5478 static int patch_stac922x(struct hda_codec *codec)
5480 struct sigmatel_spec *spec;
5483 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5488 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5489 spec->pin_nids = stac922x_pin_nids;
5490 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5493 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5494 spec->gpio_mask = spec->gpio_dir = 0x03;
5495 spec->gpio_data = 0x03;
5496 /* Intel Macs have all same PCI SSID, so we need to check
5497 * codec SSID to distinguish the exact models
5499 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5500 switch (codec->subsystem_id) {
5503 spec->board_config = STAC_INTEL_MAC_V1;
5507 spec->board_config = STAC_INTEL_MAC_V2;
5515 spec->board_config = STAC_INTEL_MAC_V3;
5519 spec->board_config = STAC_INTEL_MAC_V4;
5523 spec->board_config = STAC_INTEL_MAC_V5;
5526 spec->board_config = STAC_INTEL_MAC_V3;
5532 if (spec->board_config < 0)
5533 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5534 "using BIOS defaults\n");
5536 stac92xx_set_config_regs(codec,
5537 stac922x_brd_tbl[spec->board_config]);
5539 spec->adc_nids = stac922x_adc_nids;
5540 spec->mux_nids = stac922x_mux_nids;
5541 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5542 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5543 spec->num_dmics = 0;
5546 spec->init = stac922x_core_init;
5547 spec->mixer = stac922x_mixer;
5549 spec->multiout.dac_nids = spec->dac_nids;
5551 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5553 if (spec->board_config < 0) {
5554 printk(KERN_WARNING "hda_codec: No auto-config is "
5555 "available, default to model=ref\n");
5556 spec->board_config = STAC_D945_REF;
5562 stac92xx_free(codec);
5566 codec->patch_ops = stac92xx_patch_ops;
5568 /* Fix Mux capture level; max to 2 */
5569 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5570 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5571 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5572 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5573 (0 << AC_AMPCAP_MUTE_SHIFT));
5578 static int patch_stac927x(struct hda_codec *codec)
5580 struct sigmatel_spec *spec;
5583 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5588 codec->slave_dig_outs = stac927x_slave_dig_outs;
5589 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5590 spec->pin_nids = stac927x_pin_nids;
5591 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5595 if (spec->board_config < 0)
5596 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5597 "STAC927x, using BIOS defaults\n");
5599 stac92xx_set_config_regs(codec,
5600 stac927x_brd_tbl[spec->board_config]);
5602 spec->digbeep_nid = 0x23;
5603 spec->adc_nids = stac927x_adc_nids;
5604 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5605 spec->mux_nids = stac927x_mux_nids;
5606 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5607 spec->smux_nids = stac927x_smux_nids;
5608 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5609 spec->spdif_labels = stac927x_spdif_labels;
5610 spec->dac_list = stac927x_dac_nids;
5611 spec->multiout.dac_nids = spec->dac_nids;
5613 switch (spec->board_config) {
5616 /* GPIO0 High = Enable EAPD */
5617 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
5618 spec->gpio_data = 0x01;
5619 spec->num_dmics = 0;
5621 spec->init = d965_core_init;
5622 spec->mixer = stac927x_mixer;
5624 case STAC_DELL_BIOS:
5625 switch (codec->subsystem_id) {
5628 /* correct the device field to SPDIF out */
5629 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5632 /* configure the analog microphone on some laptops */
5633 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5634 /* correct the front output jack as a hp out */
5635 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5636 /* correct the front input jack as a mic */
5637 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5640 /* GPIO2 High = Enable EAPD */
5641 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
5642 spec->gpio_data = 0x04;
5643 spec->dmic_nids = stac927x_dmic_nids;
5644 spec->num_dmics = STAC927X_NUM_DMICS;
5646 spec->init = d965_core_init;
5647 spec->mixer = stac927x_mixer;
5648 spec->dmux_nids = stac927x_dmux_nids;
5649 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5652 if (spec->board_config > STAC_D965_REF) {
5653 /* GPIO0 High = Enable EAPD */
5654 spec->eapd_mask = spec->gpio_mask = 0x01;
5655 spec->gpio_dir = spec->gpio_data = 0x01;
5657 spec->num_dmics = 0;
5659 spec->init = stac927x_core_init;
5660 spec->mixer = stac927x_mixer;
5664 spec->aloopback_ctl = stac927x_loopback;
5665 spec->aloopback_mask = 0x40;
5666 spec->aloopback_shift = 0;
5667 spec->eapd_switch = 1;
5669 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
5671 if (spec->board_config < 0) {
5672 printk(KERN_WARNING "hda_codec: No auto-config is "
5673 "available, default to model=ref\n");
5674 spec->board_config = STAC_D965_REF;
5680 stac92xx_free(codec);
5684 codec->patch_ops = stac92xx_patch_ops;
5686 codec->proc_widget_hook = stac927x_proc_hook;
5690 * The STAC927x seem to require fairly long delays for certain
5691 * command sequences. With too short delays (even if the answer
5692 * is set to RIRB properly), it results in the silence output
5693 * on some hardwares like Dell.
5695 * The below flag enables the longer delay (see get_response
5698 codec->bus->needs_damn_long_delay = 1;
5700 /* no jack detecion for ref-no-jd model */
5701 if (spec->board_config == STAC_D965_REF_NO_JD)
5702 spec->hp_detect = 0;
5707 static int patch_stac9205(struct hda_codec *codec)
5709 struct sigmatel_spec *spec;
5712 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5717 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
5718 spec->pin_nids = stac9205_pin_nids;
5719 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5723 if (spec->board_config < 0)
5724 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5726 stac92xx_set_config_regs(codec,
5727 stac9205_brd_tbl[spec->board_config]);
5729 spec->digbeep_nid = 0x23;
5730 spec->adc_nids = stac9205_adc_nids;
5731 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
5732 spec->mux_nids = stac9205_mux_nids;
5733 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
5734 spec->smux_nids = stac9205_smux_nids;
5735 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
5736 spec->dmic_nids = stac9205_dmic_nids;
5737 spec->num_dmics = STAC9205_NUM_DMICS;
5738 spec->dmux_nids = stac9205_dmux_nids;
5739 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
5742 spec->init = stac9205_core_init;
5743 spec->mixer = stac9205_mixer;
5744 spec->aloopback_ctl = stac9205_loopback;
5746 spec->aloopback_mask = 0x40;
5747 spec->aloopback_shift = 0;
5748 /* Turn on/off EAPD per HP plugging */
5749 if (spec->board_config != STAC_9205_EAPD)
5750 spec->eapd_switch = 1;
5751 spec->multiout.dac_nids = spec->dac_nids;
5753 switch (spec->board_config){
5754 case STAC_9205_DELL_M43:
5755 /* Enable SPDIF in/out */
5756 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5757 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
5759 /* Enable unsol response for GPIO4/Dock HP connection */
5760 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5763 snd_hda_codec_write_cache(codec, codec->afg, 0,
5764 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5765 snd_hda_codec_write_cache(codec, codec->afg, 0,
5766 AC_VERB_SET_UNSOLICITED_ENABLE,
5769 spec->gpio_dir = 0x0b;
5770 spec->eapd_mask = 0x01;
5771 spec->gpio_mask = 0x1b;
5772 spec->gpio_mute = 0x10;
5773 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5776 spec->gpio_data = 0x01;
5779 /* SPDIF-In enabled */
5782 /* GPIO0 High = EAPD */
5783 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5784 spec->gpio_data = 0x01;
5788 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5790 if (spec->board_config < 0) {
5791 printk(KERN_WARNING "hda_codec: No auto-config is "
5792 "available, default to model=ref\n");
5793 spec->board_config = STAC_9205_REF;
5799 stac92xx_free(codec);
5803 codec->patch_ops = stac92xx_patch_ops;
5805 codec->proc_widget_hook = stac9205_proc_hook;
5814 static struct hda_verb stac9872_core_init[] = {
5815 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5820 static struct snd_kcontrol_new stac9872_mixer[] = {
5821 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5822 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5826 static hda_nid_t stac9872_pin_nids[] = {
5827 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5831 static hda_nid_t stac9872_adc_nids[] = {
5835 static hda_nid_t stac9872_mux_nids[] = {
5839 static unsigned int stac9872_vaio_pin_configs[9] = {
5840 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5841 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5845 static const char *stac9872_models[STAC_9872_MODELS] = {
5846 [STAC_9872_AUTO] = "auto",
5847 [STAC_9872_VAIO] = "vaio",
5850 static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5851 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5854 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5858 static int patch_stac9872(struct hda_codec *codec)
5860 struct sigmatel_spec *spec;
5863 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5868 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5871 if (spec->board_config < 0)
5872 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, "
5873 "using BIOS defaults\n");
5875 stac92xx_set_config_regs(codec,
5876 stac9872_brd_tbl[spec->board_config]);
5878 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5879 spec->pin_nids = stac9872_pin_nids;
5880 spec->multiout.dac_nids = spec->dac_nids;
5881 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5882 spec->adc_nids = stac9872_adc_nids;
5883 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5884 spec->mux_nids = stac9872_mux_nids;
5885 spec->mixer = stac9872_mixer;
5886 spec->init = stac9872_core_init;
5888 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5890 stac92xx_free(codec);
5893 spec->input_mux = &spec->private_imux;
5894 codec->patch_ops = stac92xx_patch_ops;
5902 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5903 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5904 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5905 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5906 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5907 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5908 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5909 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5910 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5911 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5912 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5913 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5914 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5915 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5916 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5917 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5918 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5919 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5920 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5921 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5922 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5923 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5924 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5925 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5926 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5927 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5928 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5929 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5930 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5931 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5932 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5933 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5934 /* The following does not take into account .id=0x83847661 when subsys =
5935 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5936 * currently not fully supported.
5938 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5939 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5940 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5941 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5942 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5943 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5944 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5945 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5946 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5947 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5948 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5949 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5950 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5951 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5952 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
5953 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5954 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5955 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5956 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5957 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5958 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5959 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5960 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5961 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5962 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5963 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5964 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5968 MODULE_ALIAS("snd-hda-codec-id:8384*");
5969 MODULE_ALIAS("snd-hda-codec-id:111d*");
5971 MODULE_LICENSE("GPL");
5972 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5974 static struct hda_codec_preset_list sigmatel_list = {
5975 .preset = snd_hda_preset_sigmatel,
5976 .owner = THIS_MODULE,
5979 static int __init patch_sigmatel_init(void)
5981 return snd_hda_add_codec_preset(&sigmatel_list);
5984 static void __exit patch_sigmatel_exit(void)
5986 snd_hda_delete_codec_preset(&sigmatel_list);
5989 module_init(patch_sigmatel_init)
5990 module_exit(patch_sigmatel_exit)