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 "hda_codec.h"
34 #include "hda_local.h"
35 #include "hda_patch.h"
38 #define NUM_CONTROL_ALLOC 32
39 #define STAC_PWR_EVENT 0x20
40 #define STAC_HP_EVENT 0x30
41 #define STAC_VREF_EVENT 0x40
105 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
106 * is given, one of the above models will be
107 * chosen according to the subsystem id. */
108 /* for backward compatibility */
132 struct sigmatel_spec {
133 struct snd_kcontrol_new *mixers[4];
134 unsigned int num_mixers;
137 unsigned int surr_switch: 1;
138 unsigned int line_switch: 1;
139 unsigned int mic_switch: 1;
140 unsigned int alt_switch: 1;
141 unsigned int hp_detect: 1;
142 unsigned int spdif_mute: 1;
145 unsigned int eapd_mask;
146 unsigned int gpio_mask;
147 unsigned int gpio_dir;
148 unsigned int gpio_data;
149 unsigned int gpio_mute;
152 unsigned int stream_delay;
154 /* analog loopback */
155 unsigned char aloopback_mask;
156 unsigned char aloopback_shift;
158 /* power management */
159 unsigned int num_pwrs;
160 unsigned int *pwr_mapping;
165 struct hda_input_mux *mono_mux;
166 struct hda_input_mux *amp_mux;
167 unsigned int cur_mmux;
168 struct hda_multi_out multiout;
169 hda_nid_t dac_nids[5];
173 unsigned int num_adcs;
175 unsigned int num_muxes;
176 hda_nid_t *dmic_nids;
177 unsigned int num_dmics;
178 hda_nid_t *dmux_nids;
179 unsigned int num_dmuxes;
180 hda_nid_t *smux_nids;
181 unsigned int num_smuxes;
182 const char **spdif_labels;
184 hda_nid_t dig_in_nid;
186 hda_nid_t anabeep_nid;
187 hda_nid_t digbeep_nid;
191 unsigned int num_pins;
192 unsigned int *pin_configs;
193 unsigned int *bios_pin_configs;
195 /* codec specific stuff */
196 struct hda_verb *init;
197 struct snd_kcontrol_new *mixer;
200 struct hda_input_mux *dinput_mux;
201 unsigned int cur_dmux[2];
202 struct hda_input_mux *input_mux;
203 unsigned int cur_mux[3];
204 struct hda_input_mux *sinput_mux;
205 unsigned int cur_smux[2];
206 unsigned int cur_amux;
208 unsigned int num_amps;
209 unsigned int powerdown_adcs;
212 unsigned int io_switch[2];
213 unsigned int clfe_swap;
214 unsigned int hp_switch;
215 unsigned int aloopback;
217 struct hda_pcm pcm_rec[2]; /* PCM information */
219 /* dynamic controls and input_mux */
220 struct auto_pin_cfg autocfg;
221 unsigned int num_kctl_alloc, num_kctl_used;
222 struct snd_kcontrol_new *kctl_alloc;
223 struct hda_input_mux private_dimux;
224 struct hda_input_mux private_imux;
225 struct hda_input_mux private_smux;
226 struct hda_input_mux private_amp_mux;
227 struct hda_input_mux private_mono_mux;
230 static hda_nid_t stac9200_adc_nids[1] = {
234 static hda_nid_t stac9200_mux_nids[1] = {
238 static hda_nid_t stac9200_dac_nids[1] = {
242 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
243 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
247 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
251 static hda_nid_t stac92hd73xx_adc_nids[2] = {
255 #define DELL_M6_AMP 2
256 static hda_nid_t stac92hd73xx_amp_nids[3] = {
260 #define STAC92HD73XX_NUM_DMICS 2
261 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
265 #define STAC92HD73_DAC_COUNT 5
266 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
267 0x15, 0x16, 0x17, 0x18, 0x19,
270 static hda_nid_t stac92hd73xx_mux_nids[4] = {
271 0x28, 0x29, 0x2a, 0x2b,
274 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
278 static hda_nid_t stac92hd73xx_smux_nids[2] = {
282 #define STAC92HD83XXX_NUM_DMICS 2
283 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
287 #define STAC92HD81_DAC_COUNT 2
288 #define STAC92HD83_DAC_COUNT 3
289 static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
293 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
297 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
301 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
305 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
309 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
310 0x03, 0x0c, 0x10, 0x40,
313 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
317 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
321 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
325 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
329 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
333 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
337 #define STAC92HD71BXX_NUM_DMICS 2
338 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
342 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
346 static hda_nid_t stac925x_adc_nids[1] = {
350 static hda_nid_t stac925x_mux_nids[1] = {
354 static hda_nid_t stac925x_dac_nids[1] = {
358 #define STAC925X_NUM_DMICS 1
359 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
363 static hda_nid_t stac925x_dmux_nids[1] = {
367 static hda_nid_t stac922x_adc_nids[2] = {
371 static hda_nid_t stac922x_mux_nids[2] = {
375 static hda_nid_t stac927x_adc_nids[3] = {
379 static hda_nid_t stac927x_mux_nids[3] = {
383 static hda_nid_t stac927x_smux_nids[1] = {
387 static hda_nid_t stac927x_dac_nids[6] = {
388 0x02, 0x03, 0x04, 0x05, 0x06, 0
391 static hda_nid_t stac927x_dmux_nids[1] = {
395 #define STAC927X_NUM_DMICS 2
396 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
400 static const char *stac927x_spdif_labels[5] = {
401 "Digital Playback", "ADAT", "Analog Mux 1",
402 "Analog Mux 2", "Analog Mux 3"
405 static hda_nid_t stac9205_adc_nids[2] = {
409 static hda_nid_t stac9205_mux_nids[2] = {
413 static hda_nid_t stac9205_dmux_nids[1] = {
417 static hda_nid_t stac9205_smux_nids[1] = {
421 #define STAC9205_NUM_DMICS 2
422 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
426 static hda_nid_t stac9200_pin_nids[8] = {
427 0x08, 0x09, 0x0d, 0x0e,
428 0x0f, 0x10, 0x11, 0x12,
431 static hda_nid_t stac925x_pin_nids[8] = {
432 0x07, 0x08, 0x0a, 0x0b,
433 0x0c, 0x0d, 0x10, 0x11,
436 static hda_nid_t stac922x_pin_nids[10] = {
437 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
438 0x0f, 0x10, 0x11, 0x15, 0x1b,
441 static hda_nid_t stac92hd73xx_pin_nids[13] = {
442 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
443 0x0f, 0x10, 0x11, 0x12, 0x13,
447 static hda_nid_t stac92hd83xxx_pin_nids[14] = {
448 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
449 0x0f, 0x10, 0x11, 0x12, 0x13,
450 0x1d, 0x1e, 0x1f, 0x20
452 static hda_nid_t stac92hd71bxx_pin_nids[11] = {
453 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
454 0x0f, 0x14, 0x18, 0x19, 0x1e,
458 static hda_nid_t stac927x_pin_nids[14] = {
459 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
460 0x0f, 0x10, 0x11, 0x12, 0x13,
461 0x14, 0x21, 0x22, 0x23,
464 static hda_nid_t stac9205_pin_nids[12] = {
465 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
466 0x0f, 0x14, 0x16, 0x17, 0x18,
470 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
472 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
473 struct snd_ctl_elem_value *ucontrol)
475 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
476 struct sigmatel_spec *spec = codec->spec;
477 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
479 kcontrol->private_value ^= get_amp_nid(kcontrol);
480 kcontrol->private_value |= nid;
482 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
485 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
486 struct snd_ctl_elem_value *ucontrol)
488 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
489 struct sigmatel_spec *spec = codec->spec;
490 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
492 kcontrol->private_value ^= get_amp_nid(kcontrol);
493 kcontrol->private_value |= nid;
495 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
498 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
499 struct snd_ctl_elem_info *uinfo)
501 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
502 struct sigmatel_spec *spec = codec->spec;
503 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
506 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
507 struct snd_ctl_elem_value *ucontrol)
509 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
510 struct sigmatel_spec *spec = codec->spec;
511 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
513 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
517 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
518 struct snd_ctl_elem_value *ucontrol)
520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
521 struct sigmatel_spec *spec = codec->spec;
522 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
524 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
525 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
528 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_info *uinfo)
531 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
532 struct sigmatel_spec *spec = codec->spec;
533 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
536 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
537 struct snd_ctl_elem_value *ucontrol)
539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
540 struct sigmatel_spec *spec = codec->spec;
541 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
543 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
547 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
548 struct snd_ctl_elem_value *ucontrol)
550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
551 struct sigmatel_spec *spec = codec->spec;
552 struct hda_input_mux *smux = &spec->private_smux;
553 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
557 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
558 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
562 if (spec->spdif_mute) {
564 nid = spec->multiout.dig_out_nid;
566 nid = codec->slave_dig_outs[smux_idx - 1];
567 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
570 nid = spec->multiout.dig_out_nid;
572 nid = codec->slave_dig_outs[smux_idx - 1];
573 /* un/mute SPDIF out */
574 snd_hda_codec_write_cache(codec, nid, 0,
575 AC_VERB_SET_AMP_GAIN_MUTE, val);
580 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
583 struct sigmatel_spec *spec = codec->spec;
584 return snd_hda_input_mux_info(spec->input_mux, uinfo);
587 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
589 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
590 struct sigmatel_spec *spec = codec->spec;
591 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
593 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
597 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 struct sigmatel_spec *spec = codec->spec;
601 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
603 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
604 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
607 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
608 struct snd_ctl_elem_info *uinfo)
610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
611 struct sigmatel_spec *spec = codec->spec;
612 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
615 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
616 struct snd_ctl_elem_value *ucontrol)
618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
619 struct sigmatel_spec *spec = codec->spec;
621 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
625 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
626 struct snd_ctl_elem_value *ucontrol)
628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
629 struct sigmatel_spec *spec = codec->spec;
631 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
632 spec->mono_nid, &spec->cur_mmux);
635 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_info *uinfo)
638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
639 struct sigmatel_spec *spec = codec->spec;
640 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
643 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
644 struct snd_ctl_elem_value *ucontrol)
646 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
647 struct sigmatel_spec *spec = codec->spec;
649 ucontrol->value.enumerated.item[0] = spec->cur_amux;
653 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
654 struct snd_ctl_elem_value *ucontrol)
656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
657 struct sigmatel_spec *spec = codec->spec;
658 struct snd_kcontrol *ctl =
659 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
663 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
664 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
666 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
670 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
672 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_value *ucontrol)
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
677 struct sigmatel_spec *spec = codec->spec;
679 ucontrol->value.integer.value[0] = !!(spec->aloopback &
680 (spec->aloopback_mask << idx));
684 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
685 struct snd_ctl_elem_value *ucontrol)
687 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
688 struct sigmatel_spec *spec = codec->spec;
689 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
690 unsigned int dac_mode;
691 unsigned int val, idx_val;
693 idx_val = spec->aloopback_mask << idx;
694 if (ucontrol->value.integer.value[0])
695 val = spec->aloopback | idx_val;
697 val = spec->aloopback & ~idx_val;
698 if (spec->aloopback == val)
701 spec->aloopback = val;
703 /* Only return the bits defined by the shift value of the
704 * first two bytes of the mask
706 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
707 kcontrol->private_value & 0xFFFF, 0x0);
708 dac_mode >>= spec->aloopback_shift;
710 if (spec->aloopback & idx_val) {
711 snd_hda_power_up(codec);
714 snd_hda_power_down(codec);
715 dac_mode &= ~idx_val;
718 snd_hda_codec_write_cache(codec, codec->afg, 0,
719 kcontrol->private_value >> 16, dac_mode);
724 static struct hda_verb stac9200_core_init[] = {
725 /* set dac0mux for dac converter */
726 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
730 static struct hda_verb stac9200_eapd_init[] = {
731 /* set dac0mux for dac converter */
732 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
733 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
737 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
738 /* set master volume and direct control */
739 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
740 /* setup audio connections */
741 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
742 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
743 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
744 /* setup adcs to point to mixer */
745 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
746 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
747 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
748 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
749 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
750 /* setup import muxs */
751 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
752 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
753 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
754 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
758 static struct hda_verb dell_eq_core_init[] = {
759 /* set master volume to max value without distortion
760 * and direct control */
761 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
762 /* setup audio connections */
763 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
764 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
765 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
766 /* setup adcs to point to mixer */
767 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
768 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
769 /* setup import muxs */
770 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
771 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
772 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
773 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
777 static struct hda_verb dell_m6_core_init[] = {
778 /* set master volume to max value without distortion
779 * and direct control */
780 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
781 /* setup audio connections */
782 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
783 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
784 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
785 /* setup adcs to point to mixer */
786 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
787 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
788 /* setup import muxs */
789 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
790 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
791 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
792 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
796 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
797 /* set master volume and direct control */
798 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
799 /* setup audio connections */
800 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
801 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
802 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
803 /* connect hp ports to dac3 */
804 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
805 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
806 /* setup adcs to point to mixer */
807 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
808 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
809 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
810 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
811 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
812 /* setup import muxs */
813 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
814 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
815 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
816 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
820 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
821 /* set master volume and direct control */
822 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
823 /* setup audio connections */
824 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
825 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
826 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
827 /* dac3 is connected to import3 mux */
828 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
829 /* connect hp ports to dac4 */
830 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
831 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
832 /* setup adcs to point to mixer */
833 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
834 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
835 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
836 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
838 /* setup import muxs */
839 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
840 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
841 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
842 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
846 static struct hda_verb stac92hd83xxx_core_init[] = {
847 /* start of config #1 */
848 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
850 /* start of config #2 */
851 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
852 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
853 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
855 /* power state controls amps */
856 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
859 static struct hda_verb stac92hd71bxx_core_init[] = {
860 /* set master volume and direct control */
861 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
862 /* connect headphone jack to dac1 */
863 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
864 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
865 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
866 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
867 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
870 #define HD_DISABLE_PORTF 2
871 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
872 /* start of config #1 */
874 /* connect port 0f to audio mixer */
875 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
876 /* unmute right and left channels for node 0x0f */
877 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
878 /* start of config #2 */
880 /* set master volume and direct control */
881 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
882 /* connect headphone jack to dac1 */
883 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
884 /* unmute right and left channels for nodes 0x0a, 0xd */
885 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
886 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
890 static struct hda_verb stac925x_core_init[] = {
891 /* set dac0mux for dac converter */
892 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
896 static struct hda_verb stac922x_core_init[] = {
897 /* set master volume and direct control */
898 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
902 static struct hda_verb d965_core_init[] = {
903 /* set master volume and direct control */
904 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
905 /* unmute node 0x1b */
906 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
907 /* select node 0x03 as DAC */
908 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
912 static struct hda_verb stac927x_core_init[] = {
913 /* set master volume and direct control */
914 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
915 /* enable analog pc beep path */
916 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
920 static struct hda_verb stac9205_core_init[] = {
921 /* set master volume and direct control */
922 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
923 /* enable analog pc beep path */
924 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
928 #define STAC_MONO_MUX \
930 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
931 .name = "Mono Mux", \
933 .info = stac92xx_mono_mux_enum_info, \
934 .get = stac92xx_mono_mux_enum_get, \
935 .put = stac92xx_mono_mux_enum_put, \
938 #define STAC_AMP_MUX \
940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
941 .name = "Amp Selector Capture Switch", \
943 .info = stac92xx_amp_mux_enum_info, \
944 .get = stac92xx_amp_mux_enum_get, \
945 .put = stac92xx_amp_mux_enum_put, \
948 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
950 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
953 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
954 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
955 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
956 .info = stac92xx_amp_volume_info, \
957 .get = stac92xx_amp_volume_get, \
958 .put = stac92xx_amp_volume_put, \
959 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
960 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
963 #define STAC_INPUT_SOURCE(cnt) \
965 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
966 .name = "Input Source", \
968 .info = stac92xx_mux_enum_info, \
969 .get = stac92xx_mux_enum_get, \
970 .put = stac92xx_mux_enum_put, \
973 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
975 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
976 .name = "Analog Loopback", \
978 .info = stac92xx_aloopback_info, \
979 .get = stac92xx_aloopback_get, \
980 .put = stac92xx_aloopback_put, \
981 .private_value = verb_read | (verb_write << 16), \
984 static struct snd_kcontrol_new stac9200_mixer[] = {
985 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
986 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
987 STAC_INPUT_SOURCE(1),
988 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
989 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
993 #define DELL_M6_MIXER 6
994 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
995 /* start of config #1 */
996 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
997 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
999 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1000 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1002 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1003 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1005 /* start of config #2 */
1006 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1007 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1009 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1010 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1012 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1014 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1015 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1017 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1018 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1023 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1024 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1026 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1027 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1029 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1030 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1032 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1033 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1035 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1036 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1038 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1039 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1041 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1042 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1044 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1045 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1049 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1050 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1052 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1053 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1055 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1056 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1058 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1059 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1061 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1062 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1064 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1065 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1067 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1068 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1070 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1071 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1076 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1077 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1078 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1080 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1081 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1083 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1084 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1086 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1087 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1089 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1090 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1092 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1093 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1096 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1097 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1102 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1103 STAC_INPUT_SOURCE(2),
1104 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1106 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1107 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1109 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1110 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1111 /* analog pc-beep replaced with digital beep support */
1113 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1114 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1117 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1118 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1120 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1121 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1123 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1124 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1126 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1127 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1131 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1132 STAC_INPUT_SOURCE(2),
1133 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1135 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1136 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1138 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1139 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1143 static struct snd_kcontrol_new stac925x_mixer[] = {
1144 STAC_INPUT_SOURCE(1),
1145 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1146 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1150 static struct snd_kcontrol_new stac9205_mixer[] = {
1151 STAC_INPUT_SOURCE(2),
1152 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1154 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1155 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1157 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1158 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1162 /* This needs to be generated dynamically based on sequence */
1163 static struct snd_kcontrol_new stac922x_mixer[] = {
1164 STAC_INPUT_SOURCE(2),
1165 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1166 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1168 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1169 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1174 static struct snd_kcontrol_new stac927x_mixer[] = {
1175 STAC_INPUT_SOURCE(3),
1176 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1178 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1179 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1181 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1182 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1184 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1185 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1189 static struct snd_kcontrol_new stac_dmux_mixer = {
1190 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1191 .name = "Digital Input Source",
1192 /* count set later */
1193 .info = stac92xx_dmux_enum_info,
1194 .get = stac92xx_dmux_enum_get,
1195 .put = stac92xx_dmux_enum_put,
1198 static struct snd_kcontrol_new stac_smux_mixer = {
1199 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1200 .name = "IEC958 Playback Source",
1201 /* count set later */
1202 .info = stac92xx_smux_enum_info,
1203 .get = stac92xx_smux_enum_get,
1204 .put = stac92xx_smux_enum_put,
1207 static const char *slave_vols[] = {
1208 "Front Playback Volume",
1209 "Surround Playback Volume",
1210 "Center Playback Volume",
1211 "LFE Playback Volume",
1212 "Side Playback Volume",
1213 "Headphone Playback Volume",
1214 "Headphone Playback Volume",
1215 "Speaker Playback Volume",
1216 "External Speaker Playback Volume",
1217 "Speaker2 Playback Volume",
1221 static const char *slave_sws[] = {
1222 "Front Playback Switch",
1223 "Surround Playback Switch",
1224 "Center Playback Switch",
1225 "LFE Playback Switch",
1226 "Side Playback Switch",
1227 "Headphone Playback Switch",
1228 "Headphone Playback Switch",
1229 "Speaker Playback Switch",
1230 "External Speaker Playback Switch",
1231 "Speaker2 Playback Switch",
1232 "IEC958 Playback Switch",
1236 static int stac92xx_build_controls(struct hda_codec *codec)
1238 struct sigmatel_spec *spec = codec->spec;
1242 err = snd_hda_add_new_ctls(codec, spec->mixer);
1246 for (i = 0; i < spec->num_mixers; i++) {
1247 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1251 if (spec->num_dmuxes > 0) {
1252 stac_dmux_mixer.count = spec->num_dmuxes;
1253 err = snd_ctl_add(codec->bus->card,
1254 snd_ctl_new1(&stac_dmux_mixer, codec));
1258 if (spec->num_smuxes > 0) {
1259 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1260 struct hda_input_mux *smux = &spec->private_smux;
1261 /* check for mute support on SPDIF out */
1262 if (wcaps & AC_WCAP_OUT_AMP) {
1263 smux->items[smux->num_items].label = "Off";
1264 smux->items[smux->num_items].index = 0;
1266 spec->spdif_mute = 1;
1268 stac_smux_mixer.count = spec->num_smuxes;
1269 err = snd_ctl_add(codec->bus->card,
1270 snd_ctl_new1(&stac_smux_mixer, codec));
1275 if (spec->multiout.dig_out_nid) {
1276 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1279 err = snd_hda_create_spdif_share_sw(codec,
1283 spec->multiout.share_spdif = 1;
1285 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1286 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1291 /* if we have no master control, let's create it */
1292 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1293 unsigned int vmaster_tlv[4];
1294 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1295 HDA_OUTPUT, vmaster_tlv);
1296 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1297 vmaster_tlv, slave_vols);
1301 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1302 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1311 static unsigned int ref9200_pin_configs[8] = {
1312 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1313 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1317 STAC 9200 pin configs for
1322 static unsigned int dell9200_d21_pin_configs[8] = {
1323 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1324 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1328 STAC 9200 pin configs for
1332 static unsigned int dell9200_d22_pin_configs[8] = {
1333 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1334 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1338 STAC 9200 pin configs for
1339 102801C4 (Dell Dimension E310)
1346 static unsigned int dell9200_d23_pin_configs[8] = {
1347 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1348 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1353 STAC 9200-32 pin configs for
1354 102801B5 (Dell Inspiron 630m)
1355 102801D8 (Dell Inspiron 640m)
1357 static unsigned int dell9200_m21_pin_configs[8] = {
1358 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1359 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1363 STAC 9200-32 pin configs for
1364 102801C2 (Dell Latitude D620)
1366 102801CC (Dell Latitude D820)
1370 static unsigned int dell9200_m22_pin_configs[8] = {
1371 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1372 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1376 STAC 9200-32 pin configs for
1377 102801CE (Dell XPS M1710)
1378 102801CF (Dell Precision M90)
1380 static unsigned int dell9200_m23_pin_configs[8] = {
1381 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1382 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1386 STAC 9200-32 pin configs for
1389 102801CB (Dell Latitude 120L)
1392 static unsigned int dell9200_m24_pin_configs[8] = {
1393 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1394 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1398 STAC 9200-32 pin configs for
1399 102801BD (Dell Inspiron E1505n)
1403 static unsigned int dell9200_m25_pin_configs[8] = {
1404 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1405 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1409 STAC 9200-32 pin configs for
1410 102801F5 (Dell Inspiron 1501)
1413 static unsigned int dell9200_m26_pin_configs[8] = {
1414 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1415 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1420 102801CD (Dell Inspiron E1705/9400)
1422 static unsigned int dell9200_m27_pin_configs[8] = {
1423 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1424 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1427 static unsigned int oqo9200_pin_configs[8] = {
1428 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1429 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1433 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1434 [STAC_REF] = ref9200_pin_configs,
1435 [STAC_9200_OQO] = oqo9200_pin_configs,
1436 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1437 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1438 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1439 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1440 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1441 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1442 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1443 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1444 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1445 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1446 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1449 static const char *stac9200_models[STAC_9200_MODELS] = {
1451 [STAC_9200_OQO] = "oqo",
1452 [STAC_9200_DELL_D21] = "dell-d21",
1453 [STAC_9200_DELL_D22] = "dell-d22",
1454 [STAC_9200_DELL_D23] = "dell-d23",
1455 [STAC_9200_DELL_M21] = "dell-m21",
1456 [STAC_9200_DELL_M22] = "dell-m22",
1457 [STAC_9200_DELL_M23] = "dell-m23",
1458 [STAC_9200_DELL_M24] = "dell-m24",
1459 [STAC_9200_DELL_M25] = "dell-m25",
1460 [STAC_9200_DELL_M26] = "dell-m26",
1461 [STAC_9200_DELL_M27] = "dell-m27",
1462 [STAC_9200_GATEWAY] = "gateway",
1463 [STAC_9200_PANASONIC] = "panasonic",
1466 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1467 /* SigmaTel reference board */
1468 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1469 "DFI LanParty", STAC_REF),
1470 /* Dell laptops have BIOS problem */
1471 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1472 "unknown Dell", STAC_9200_DELL_D21),
1473 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1474 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1475 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1476 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1477 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1478 "unknown Dell", STAC_9200_DELL_D22),
1479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1480 "unknown Dell", STAC_9200_DELL_D22),
1481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1482 "Dell Latitude D620", STAC_9200_DELL_M22),
1483 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1484 "unknown Dell", STAC_9200_DELL_D23),
1485 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1486 "unknown Dell", STAC_9200_DELL_D23),
1487 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1488 "unknown Dell", STAC_9200_DELL_M22),
1489 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1490 "unknown Dell", STAC_9200_DELL_M24),
1491 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1492 "unknown Dell", STAC_9200_DELL_M24),
1493 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1494 "Dell Latitude 120L", STAC_9200_DELL_M24),
1495 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1496 "Dell Latitude D820", STAC_9200_DELL_M22),
1497 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1498 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1499 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1500 "Dell XPS M1710", STAC_9200_DELL_M23),
1501 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1502 "Dell Precision M90", STAC_9200_DELL_M23),
1503 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1504 "unknown Dell", STAC_9200_DELL_M22),
1505 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1506 "unknown Dell", STAC_9200_DELL_M22),
1507 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1508 "unknown Dell", STAC_9200_DELL_M22),
1509 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1510 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1511 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1512 "unknown Dell", STAC_9200_DELL_D23),
1513 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1514 "unknown Dell", STAC_9200_DELL_D23),
1515 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1516 "unknown Dell", STAC_9200_DELL_D21),
1517 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1518 "unknown Dell", STAC_9200_DELL_D23),
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1520 "unknown Dell", STAC_9200_DELL_D21),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1522 "unknown Dell", STAC_9200_DELL_M25),
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1524 "unknown Dell", STAC_9200_DELL_M25),
1525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1526 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1528 "unknown Dell", STAC_9200_DELL_M26),
1530 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1531 /* Gateway machines needs EAPD to be set on resume */
1532 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1533 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1535 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1538 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1542 static unsigned int ref925x_pin_configs[8] = {
1543 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1544 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1547 static unsigned int stac925x_MA6_pin_configs[8] = {
1548 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1549 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1552 static unsigned int stac925x_PA6_pin_configs[8] = {
1553 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1554 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1557 static unsigned int stac925xM2_2_pin_configs[8] = {
1558 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1559 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1562 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1563 [STAC_REF] = ref925x_pin_configs,
1564 [STAC_M2_2] = stac925xM2_2_pin_configs,
1565 [STAC_MA6] = stac925x_MA6_pin_configs,
1566 [STAC_PA6] = stac925x_PA6_pin_configs,
1569 static const char *stac925x_models[STAC_925x_MODELS] = {
1571 [STAC_M2_2] = "m2-2",
1576 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1577 /* SigmaTel reference board */
1578 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1579 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1580 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1581 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1582 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1583 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1584 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1588 static unsigned int ref92hd73xx_pin_configs[13] = {
1589 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1590 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1591 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1595 static unsigned int dell_m6_pin_configs[13] = {
1596 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1597 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1598 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1602 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1603 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1604 [STAC_DELL_M6] = dell_m6_pin_configs,
1607 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1608 [STAC_92HD73XX_REF] = "ref",
1609 [STAC_DELL_M6] = "dell-m6",
1612 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1613 /* SigmaTel reference board */
1614 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1615 "DFI LanParty", STAC_92HD73XX_REF),
1616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1617 "unknown Dell", STAC_DELL_M6),
1618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1619 "unknown Dell", STAC_DELL_M6),
1620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1621 "unknown Dell", STAC_DELL_M6),
1622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1623 "unknown Dell", STAC_DELL_M6),
1624 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1625 "unknown Dell", STAC_DELL_M6),
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1627 "unknown Dell", STAC_DELL_M6),
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1629 "unknown Dell", STAC_DELL_M6),
1633 static unsigned int ref92hd83xxx_pin_configs[14] = {
1634 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1635 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1636 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1637 0x01451160, 0x98560170,
1640 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1641 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1644 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1645 [STAC_92HD83XXX_REF] = "ref",
1648 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1649 /* SigmaTel reference board */
1650 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1651 "DFI LanParty", STAC_92HD71BXX_REF),
1654 static unsigned int ref92hd71bxx_pin_configs[11] = {
1655 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1656 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1657 0x90a000f0, 0x01452050, 0x01452050,
1660 static unsigned int dell_m4_1_pin_configs[11] = {
1661 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1662 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1663 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
1666 static unsigned int dell_m4_2_pin_configs[11] = {
1667 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1668 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1669 0x40f000f0, 0x044413b0, 0x044413b0,
1672 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1673 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1674 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1675 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1676 [STAC_HP_M4] = NULL,
1679 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1680 [STAC_92HD71BXX_REF] = "ref",
1681 [STAC_DELL_M4_1] = "dell-m4-1",
1682 [STAC_DELL_M4_2] = "dell-m4-2",
1683 [STAC_HP_M4] = "hp-m4",
1686 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1687 /* SigmaTel reference board */
1688 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1689 "DFI LanParty", STAC_92HD71BXX_REF),
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1691 "unknown HP", STAC_HP_M4),
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1693 "unknown Dell", STAC_DELL_M4_1),
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1695 "unknown Dell", STAC_DELL_M4_1),
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1697 "unknown Dell", STAC_DELL_M4_1),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1699 "unknown Dell", STAC_DELL_M4_1),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1701 "unknown Dell", STAC_DELL_M4_1),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1703 "unknown Dell", STAC_DELL_M4_1),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1705 "unknown Dell", STAC_DELL_M4_1),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1707 "unknown Dell", STAC_DELL_M4_2),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1709 "unknown Dell", STAC_DELL_M4_2),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1711 "unknown Dell", STAC_DELL_M4_2),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1713 "unknown Dell", STAC_DELL_M4_2),
1717 static unsigned int ref922x_pin_configs[10] = {
1718 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1719 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1720 0x40000100, 0x40000100,
1724 STAC 922X pin configs for
1731 static unsigned int dell_922x_d81_pin_configs[10] = {
1732 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1733 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1734 0x01813122, 0x400001f2,
1738 STAC 922X pin configs for
1742 static unsigned int dell_922x_d82_pin_configs[10] = {
1743 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1744 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1745 0x01813122, 0x400001f1,
1749 STAC 922X pin configs for
1752 static unsigned int dell_922x_m81_pin_configs[10] = {
1753 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1754 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1755 0x40C003f1, 0x405003f0,
1759 STAC 9221 A1 pin configs for
1760 102801D7 (Dell XPS M1210)
1762 static unsigned int dell_922x_m82_pin_configs[10] = {
1763 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1764 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1765 0x508003f3, 0x405003f4,
1768 static unsigned int d945gtp3_pin_configs[10] = {
1769 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1770 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1771 0x02a19120, 0x40000100,
1774 static unsigned int d945gtp5_pin_configs[10] = {
1775 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1776 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1777 0x02a19320, 0x40000100,
1780 static unsigned int intel_mac_v1_pin_configs[10] = {
1781 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1782 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1783 0x400000fc, 0x400000fb,
1786 static unsigned int intel_mac_v2_pin_configs[10] = {
1787 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1788 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1789 0x400000fc, 0x400000fb,
1792 static unsigned int intel_mac_v3_pin_configs[10] = {
1793 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1794 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1795 0x400000fc, 0x400000fb,
1798 static unsigned int intel_mac_v4_pin_configs[10] = {
1799 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1800 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1801 0x400000fc, 0x400000fb,
1804 static unsigned int intel_mac_v5_pin_configs[10] = {
1805 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1806 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1807 0x400000fc, 0x400000fb,
1810 static unsigned int ecs202_pin_configs[10] = {
1811 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1812 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1813 0x9037012e, 0x40e000f2,
1816 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1817 [STAC_D945_REF] = ref922x_pin_configs,
1818 [STAC_D945GTP3] = d945gtp3_pin_configs,
1819 [STAC_D945GTP5] = d945gtp5_pin_configs,
1820 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1821 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1822 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1823 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1824 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1825 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1826 /* for backward compatibility */
1827 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1828 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1829 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1830 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1831 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1832 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1833 [STAC_ECS_202] = ecs202_pin_configs,
1834 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1835 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1836 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1837 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1840 static const char *stac922x_models[STAC_922X_MODELS] = {
1841 [STAC_D945_REF] = "ref",
1842 [STAC_D945GTP5] = "5stack",
1843 [STAC_D945GTP3] = "3stack",
1844 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1845 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1846 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1847 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1848 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1849 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1850 /* for backward compatibility */
1851 [STAC_MACMINI] = "macmini",
1852 [STAC_MACBOOK] = "macbook",
1853 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1854 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1855 [STAC_IMAC_INTEL] = "imac-intel",
1856 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1857 [STAC_ECS_202] = "ecs202",
1858 [STAC_922X_DELL_D81] = "dell-d81",
1859 [STAC_922X_DELL_D82] = "dell-d82",
1860 [STAC_922X_DELL_M81] = "dell-m81",
1861 [STAC_922X_DELL_M82] = "dell-m82",
1864 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1865 /* SigmaTel reference board */
1866 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1867 "DFI LanParty", STAC_D945_REF),
1868 /* Intel 945G based systems */
1869 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1870 "Intel D945G", STAC_D945GTP3),
1871 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1872 "Intel D945G", STAC_D945GTP3),
1873 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1874 "Intel D945G", STAC_D945GTP3),
1875 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1876 "Intel D945G", STAC_D945GTP3),
1877 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1878 "Intel D945G", STAC_D945GTP3),
1879 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1880 "Intel D945G", STAC_D945GTP3),
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1882 "Intel D945G", STAC_D945GTP3),
1883 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1884 "Intel D945G", STAC_D945GTP3),
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1886 "Intel D945G", STAC_D945GTP3),
1887 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1888 "Intel D945G", STAC_D945GTP3),
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1890 "Intel D945G", STAC_D945GTP3),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1892 "Intel D945G", STAC_D945GTP3),
1893 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1894 "Intel D945G", STAC_D945GTP3),
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1896 "Intel D945G", STAC_D945GTP3),
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1898 "Intel D945G", STAC_D945GTP3),
1899 /* Intel D945G 5-stack systems */
1900 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1901 "Intel D945G", STAC_D945GTP5),
1902 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1903 "Intel D945G", STAC_D945GTP5),
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1905 "Intel D945G", STAC_D945GTP5),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1907 "Intel D945G", STAC_D945GTP5),
1908 /* Intel 945P based systems */
1909 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1910 "Intel D945P", STAC_D945GTP3),
1911 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1912 "Intel D945P", STAC_D945GTP3),
1913 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1914 "Intel D945P", STAC_D945GTP3),
1915 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1916 "Intel D945P", STAC_D945GTP3),
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1918 "Intel D945P", STAC_D945GTP3),
1919 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1920 "Intel D945P", STAC_D945GTP5),
1922 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1923 SND_PCI_QUIRK(0x8384, 0x7680,
1924 "Mac", STAC_INTEL_MAC_AUTO),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1927 "unknown Dell", STAC_922X_DELL_D81),
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1929 "unknown Dell", STAC_922X_DELL_D81),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1931 "unknown Dell", STAC_922X_DELL_D81),
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1933 "unknown Dell", STAC_922X_DELL_D82),
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1935 "unknown Dell", STAC_922X_DELL_M81),
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1937 "unknown Dell", STAC_922X_DELL_D82),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1939 "unknown Dell", STAC_922X_DELL_D81),
1940 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1941 "unknown Dell", STAC_922X_DELL_D81),
1942 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1943 "Dell XPS M1210", STAC_922X_DELL_M82),
1944 /* ECS/PC Chips boards */
1945 SND_PCI_QUIRK(0x1019, 0x2144,
1946 "ECS/PC chips", STAC_ECS_202),
1947 SND_PCI_QUIRK(0x1019, 0x2608,
1948 "ECS/PC chips", STAC_ECS_202),
1949 SND_PCI_QUIRK(0x1019, 0x2633,
1950 "ECS/PC chips P17G/1333", STAC_ECS_202),
1951 SND_PCI_QUIRK(0x1019, 0x2811,
1952 "ECS/PC chips", STAC_ECS_202),
1953 SND_PCI_QUIRK(0x1019, 0x2812,
1954 "ECS/PC chips", STAC_ECS_202),
1955 SND_PCI_QUIRK(0x1019, 0x2813,
1956 "ECS/PC chips", STAC_ECS_202),
1957 SND_PCI_QUIRK(0x1019, 0x2814,
1958 "ECS/PC chips", STAC_ECS_202),
1959 SND_PCI_QUIRK(0x1019, 0x2815,
1960 "ECS/PC chips", STAC_ECS_202),
1961 SND_PCI_QUIRK(0x1019, 0x2816,
1962 "ECS/PC chips", STAC_ECS_202),
1963 SND_PCI_QUIRK(0x1019, 0x2817,
1964 "ECS/PC chips", STAC_ECS_202),
1965 SND_PCI_QUIRK(0x1019, 0x2818,
1966 "ECS/PC chips", STAC_ECS_202),
1967 SND_PCI_QUIRK(0x1019, 0x2819,
1968 "ECS/PC chips", STAC_ECS_202),
1969 SND_PCI_QUIRK(0x1019, 0x2820,
1970 "ECS/PC chips", STAC_ECS_202),
1974 static unsigned int ref927x_pin_configs[14] = {
1975 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1976 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1977 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1978 0x01c42190, 0x40000100,
1981 static unsigned int d965_3st_pin_configs[14] = {
1982 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1983 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1984 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1985 0x40000100, 0x40000100
1988 static unsigned int d965_5st_pin_configs[14] = {
1989 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1990 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1991 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1992 0x40000100, 0x40000100
1995 static unsigned int dell_3st_pin_configs[14] = {
1996 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1997 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1998 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1999 0x40c003fc, 0x40000100
2002 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2003 [STAC_D965_REF] = ref927x_pin_configs,
2004 [STAC_D965_3ST] = d965_3st_pin_configs,
2005 [STAC_D965_5ST] = d965_5st_pin_configs,
2006 [STAC_DELL_3ST] = dell_3st_pin_configs,
2007 [STAC_DELL_BIOS] = NULL,
2010 static const char *stac927x_models[STAC_927X_MODELS] = {
2011 [STAC_D965_REF] = "ref",
2012 [STAC_D965_3ST] = "3stack",
2013 [STAC_D965_5ST] = "5stack",
2014 [STAC_DELL_3ST] = "dell-3stack",
2015 [STAC_DELL_BIOS] = "dell-bios",
2018 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2019 /* SigmaTel reference board */
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2021 "DFI LanParty", STAC_D965_REF),
2022 /* Intel 946 based systems */
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2025 /* 965 based 3 stack systems */
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
2042 /* Dell 3 stack systems */
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2047 /* Dell 3 stack systems with verb table in BIOS */
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2056 /* 965 based 5 stack systems */
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
2069 static unsigned int ref9205_pin_configs[12] = {
2070 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2071 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2072 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2076 STAC 9205 pin configs for
2083 10280228 (Dell Vostro 1500)
2085 static unsigned int dell_9205_m42_pin_configs[12] = {
2086 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2087 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2088 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2092 STAC 9205 pin configs for
2096 102801FF (Dell Precision M4300)
2101 static unsigned int dell_9205_m43_pin_configs[12] = {
2102 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2103 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2104 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2107 static unsigned int dell_9205_m44_pin_configs[12] = {
2108 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2109 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2110 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2113 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2114 [STAC_9205_REF] = ref9205_pin_configs,
2115 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2116 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2117 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2120 static const char *stac9205_models[STAC_9205_MODELS] = {
2121 [STAC_9205_REF] = "ref",
2122 [STAC_9205_DELL_M42] = "dell-m42",
2123 [STAC_9205_DELL_M43] = "dell-m43",
2124 [STAC_9205_DELL_M44] = "dell-m44",
2127 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2128 /* SigmaTel reference board */
2129 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2130 "DFI LanParty", STAC_9205_REF),
2131 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2132 "unknown Dell", STAC_9205_DELL_M42),
2133 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2134 "unknown Dell", STAC_9205_DELL_M42),
2135 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2136 "Dell Precision", STAC_9205_DELL_M43),
2137 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2138 "Dell Precision", STAC_9205_DELL_M43),
2139 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2140 "Dell Precision", STAC_9205_DELL_M43),
2141 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2142 "unknown Dell", STAC_9205_DELL_M42),
2143 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2144 "unknown Dell", STAC_9205_DELL_M42),
2145 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2146 "Dell Precision", STAC_9205_DELL_M43),
2147 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2148 "Dell Precision M4300", STAC_9205_DELL_M43),
2149 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2150 "unknown Dell", STAC_9205_DELL_M42),
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2152 "Dell Precision", STAC_9205_DELL_M43),
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2154 "Dell Precision", STAC_9205_DELL_M43),
2155 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2156 "Dell Precision", STAC_9205_DELL_M43),
2157 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2158 "Dell Inspiron", STAC_9205_DELL_M44),
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2160 "Dell Vostro 1500", STAC_9205_DELL_M42),
2164 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2167 struct sigmatel_spec *spec = codec->spec;
2169 if (! spec->bios_pin_configs) {
2170 spec->bios_pin_configs = kcalloc(spec->num_pins,
2171 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2172 if (! spec->bios_pin_configs)
2176 for (i = 0; i < spec->num_pins; i++) {
2177 hda_nid_t nid = spec->pin_nids[i];
2178 unsigned int pin_cfg;
2180 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2181 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2182 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2184 spec->bios_pin_configs[i] = pin_cfg;
2190 static void stac92xx_set_config_reg(struct hda_codec *codec,
2191 hda_nid_t pin_nid, unsigned int pin_config)
2194 snd_hda_codec_write(codec, pin_nid, 0,
2195 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2196 pin_config & 0x000000ff);
2197 snd_hda_codec_write(codec, pin_nid, 0,
2198 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2199 (pin_config & 0x0000ff00) >> 8);
2200 snd_hda_codec_write(codec, pin_nid, 0,
2201 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2202 (pin_config & 0x00ff0000) >> 16);
2203 snd_hda_codec_write(codec, pin_nid, 0,
2204 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2206 i = snd_hda_codec_read(codec, pin_nid, 0,
2207 AC_VERB_GET_CONFIG_DEFAULT,
2209 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2213 static void stac92xx_set_config_regs(struct hda_codec *codec)
2216 struct sigmatel_spec *spec = codec->spec;
2218 if (!spec->pin_configs)
2221 for (i = 0; i < spec->num_pins; i++)
2222 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2223 spec->pin_configs[i]);
2227 * Analog playback callbacks
2229 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2230 struct hda_codec *codec,
2231 struct snd_pcm_substream *substream)
2233 struct sigmatel_spec *spec = codec->spec;
2234 if (spec->stream_delay)
2235 msleep(spec->stream_delay);
2236 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2240 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2241 struct hda_codec *codec,
2242 unsigned int stream_tag,
2243 unsigned int format,
2244 struct snd_pcm_substream *substream)
2246 struct sigmatel_spec *spec = codec->spec;
2247 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2250 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2251 struct hda_codec *codec,
2252 struct snd_pcm_substream *substream)
2254 struct sigmatel_spec *spec = codec->spec;
2255 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2259 * Digital playback callbacks
2261 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2262 struct hda_codec *codec,
2263 struct snd_pcm_substream *substream)
2265 struct sigmatel_spec *spec = codec->spec;
2266 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2269 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2270 struct hda_codec *codec,
2271 struct snd_pcm_substream *substream)
2273 struct sigmatel_spec *spec = codec->spec;
2274 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2277 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2278 struct hda_codec *codec,
2279 unsigned int stream_tag,
2280 unsigned int format,
2281 struct snd_pcm_substream *substream)
2283 struct sigmatel_spec *spec = codec->spec;
2284 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2285 stream_tag, format, substream);
2290 * Analog capture callbacks
2292 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2293 struct hda_codec *codec,
2294 unsigned int stream_tag,
2295 unsigned int format,
2296 struct snd_pcm_substream *substream)
2298 struct sigmatel_spec *spec = codec->spec;
2299 hda_nid_t nid = spec->adc_nids[substream->number];
2301 if (spec->powerdown_adcs) {
2303 snd_hda_codec_write_cache(codec, nid, 0,
2304 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2306 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2310 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2311 struct hda_codec *codec,
2312 struct snd_pcm_substream *substream)
2314 struct sigmatel_spec *spec = codec->spec;
2315 hda_nid_t nid = spec->adc_nids[substream->number];
2317 snd_hda_codec_cleanup_stream(codec, nid);
2318 if (spec->powerdown_adcs)
2319 snd_hda_codec_write_cache(codec, nid, 0,
2320 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2324 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2328 /* NID is set in stac92xx_build_pcms */
2330 .open = stac92xx_dig_playback_pcm_open,
2331 .close = stac92xx_dig_playback_pcm_close,
2332 .prepare = stac92xx_dig_playback_pcm_prepare
2336 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2340 /* NID is set in stac92xx_build_pcms */
2343 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2347 .nid = 0x02, /* NID to query formats and rates */
2349 .open = stac92xx_playback_pcm_open,
2350 .prepare = stac92xx_playback_pcm_prepare,
2351 .cleanup = stac92xx_playback_pcm_cleanup
2355 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2359 .nid = 0x06, /* NID to query formats and rates */
2361 .open = stac92xx_playback_pcm_open,
2362 .prepare = stac92xx_playback_pcm_prepare,
2363 .cleanup = stac92xx_playback_pcm_cleanup
2367 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2370 /* NID + .substreams is set in stac92xx_build_pcms */
2372 .prepare = stac92xx_capture_pcm_prepare,
2373 .cleanup = stac92xx_capture_pcm_cleanup
2377 static int stac92xx_build_pcms(struct hda_codec *codec)
2379 struct sigmatel_spec *spec = codec->spec;
2380 struct hda_pcm *info = spec->pcm_rec;
2382 codec->num_pcms = 1;
2383 codec->pcm_info = info;
2385 info->name = "STAC92xx Analog";
2386 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2387 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2388 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2389 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2391 if (spec->alt_switch) {
2394 info->name = "STAC92xx Analog Alt";
2395 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2398 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2401 info->name = "STAC92xx Digital";
2402 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2403 if (spec->multiout.dig_out_nid) {
2404 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2405 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2407 if (spec->dig_in_nid) {
2408 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2409 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2416 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2418 unsigned int pincap = snd_hda_param_read(codec, nid,
2420 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2421 if (pincap & AC_PINCAP_VREF_100)
2422 return AC_PINCTL_VREF_100;
2423 if (pincap & AC_PINCAP_VREF_80)
2424 return AC_PINCTL_VREF_80;
2425 if (pincap & AC_PINCAP_VREF_50)
2426 return AC_PINCTL_VREF_50;
2427 if (pincap & AC_PINCAP_VREF_GRD)
2428 return AC_PINCTL_VREF_GRD;
2432 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2435 snd_hda_codec_write_cache(codec, nid, 0,
2436 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2439 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2441 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2442 struct snd_ctl_elem_value *ucontrol)
2444 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2445 struct sigmatel_spec *spec = codec->spec;
2447 ucontrol->value.integer.value[0] = spec->hp_switch;
2451 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2452 struct snd_ctl_elem_value *ucontrol)
2454 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2455 struct sigmatel_spec *spec = codec->spec;
2457 spec->hp_switch = ucontrol->value.integer.value[0];
2459 /* check to be sure that the ports are upto date with
2462 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2467 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2469 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2472 struct sigmatel_spec *spec = codec->spec;
2473 int io_idx = kcontrol-> private_value & 0xff;
2475 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2479 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2482 struct sigmatel_spec *spec = codec->spec;
2483 hda_nid_t nid = kcontrol->private_value >> 8;
2484 int io_idx = kcontrol-> private_value & 0xff;
2485 unsigned short val = !!ucontrol->value.integer.value[0];
2487 spec->io_switch[io_idx] = val;
2490 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2492 unsigned int pinctl = AC_PINCTL_IN_EN;
2493 if (io_idx) /* set VREF for mic */
2494 pinctl |= stac92xx_get_vref(codec, nid);
2495 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2498 /* check the auto-mute again: we need to mute/unmute the speaker
2499 * appropriately according to the pin direction
2501 if (spec->hp_detect)
2502 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2507 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2509 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2510 struct snd_ctl_elem_value *ucontrol)
2512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2513 struct sigmatel_spec *spec = codec->spec;
2515 ucontrol->value.integer.value[0] = spec->clfe_swap;
2519 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2520 struct snd_ctl_elem_value *ucontrol)
2522 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2523 struct sigmatel_spec *spec = codec->spec;
2524 hda_nid_t nid = kcontrol->private_value & 0xff;
2525 unsigned int val = !!ucontrol->value.integer.value[0];
2527 if (spec->clfe_swap == val)
2530 spec->clfe_swap = val;
2532 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2533 spec->clfe_swap ? 0x4 : 0x0);
2538 #define STAC_CODEC_HP_SWITCH(xname) \
2539 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2542 .info = stac92xx_hp_switch_info, \
2543 .get = stac92xx_hp_switch_get, \
2544 .put = stac92xx_hp_switch_put, \
2547 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2548 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2551 .info = stac92xx_io_switch_info, \
2552 .get = stac92xx_io_switch_get, \
2553 .put = stac92xx_io_switch_put, \
2554 .private_value = xpval, \
2557 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2558 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2561 .info = stac92xx_clfe_switch_info, \
2562 .get = stac92xx_clfe_switch_get, \
2563 .put = stac92xx_clfe_switch_put, \
2564 .private_value = xpval, \
2568 STAC_CTL_WIDGET_VOL,
2569 STAC_CTL_WIDGET_MUTE,
2570 STAC_CTL_WIDGET_MONO_MUX,
2571 STAC_CTL_WIDGET_AMP_MUX,
2572 STAC_CTL_WIDGET_AMP_VOL,
2573 STAC_CTL_WIDGET_HP_SWITCH,
2574 STAC_CTL_WIDGET_IO_SWITCH,
2575 STAC_CTL_WIDGET_CLFE_SWITCH
2578 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2579 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2580 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2583 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2584 STAC_CODEC_HP_SWITCH(NULL),
2585 STAC_CODEC_IO_SWITCH(NULL, 0),
2586 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2589 /* add dynamic controls */
2590 static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2591 int idx, const char *name, unsigned long val)
2593 struct snd_kcontrol_new *knew;
2595 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2596 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2598 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2601 if (spec->kctl_alloc) {
2602 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2603 kfree(spec->kctl_alloc);
2605 spec->kctl_alloc = knew;
2606 spec->num_kctl_alloc = num;
2609 knew = &spec->kctl_alloc[spec->num_kctl_used];
2610 *knew = stac92xx_control_templates[type];
2612 knew->name = kstrdup(name, GFP_KERNEL);
2615 knew->private_value = val;
2616 spec->num_kctl_used++;
2621 /* add dynamic controls */
2622 static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2623 const char *name, unsigned long val)
2625 return stac92xx_add_control_idx(spec, type, 0, name, val);
2628 /* flag inputs as additional dynamic lineouts */
2629 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2631 struct sigmatel_spec *spec = codec->spec;
2632 unsigned int wcaps, wtype;
2633 int i, num_dacs = 0;
2635 /* use the wcaps cache to count all DACs available for line-outs */
2636 for (i = 0; i < codec->num_nodes; i++) {
2637 wcaps = codec->wcaps[i];
2638 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2640 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2644 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2646 switch (cfg->line_outs) {
2648 /* add line-in as side */
2649 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2650 cfg->line_out_pins[cfg->line_outs] =
2651 cfg->input_pins[AUTO_PIN_LINE];
2652 spec->line_switch = 1;
2657 /* add line-in as clfe and mic as side */
2658 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2659 cfg->line_out_pins[cfg->line_outs] =
2660 cfg->input_pins[AUTO_PIN_LINE];
2661 spec->line_switch = 1;
2664 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2665 cfg->line_out_pins[cfg->line_outs] =
2666 cfg->input_pins[AUTO_PIN_MIC];
2667 spec->mic_switch = 1;
2672 /* add line-in as surr and mic as clfe */
2673 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2674 cfg->line_out_pins[cfg->line_outs] =
2675 cfg->input_pins[AUTO_PIN_LINE];
2676 spec->line_switch = 1;
2679 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2680 cfg->line_out_pins[cfg->line_outs] =
2681 cfg->input_pins[AUTO_PIN_MIC];
2682 spec->mic_switch = 1;
2692 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2696 for (i = 0; i < spec->multiout.num_dacs; i++) {
2697 if (spec->multiout.dac_nids[i] == nid)
2705 * Fill in the dac_nids table from the parsed pin configuration
2706 * This function only works when every pin in line_out_pins[]
2707 * contains atleast one DAC in its connection list. Some 92xx
2708 * codecs are not connected directly to a DAC, such as the 9200
2709 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2711 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2712 struct auto_pin_cfg *cfg)
2714 struct sigmatel_spec *spec = codec->spec;
2715 int i, j, conn_len = 0;
2716 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2717 unsigned int wcaps, wtype;
2719 for (i = 0; i < cfg->line_outs; i++) {
2720 nid = cfg->line_out_pins[i];
2721 conn_len = snd_hda_get_connections(codec, nid, conn,
2722 HDA_MAX_CONNECTIONS);
2723 for (j = 0; j < conn_len; j++) {
2724 wcaps = snd_hda_param_read(codec, conn[j],
2725 AC_PAR_AUDIO_WIDGET_CAP);
2726 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2727 if (wtype != AC_WID_AUD_OUT ||
2728 (wcaps & AC_WCAP_DIGITAL))
2730 /* conn[j] is a DAC routed to this line-out */
2731 if (!is_in_dac_nids(spec, conn[j]))
2735 if (j == conn_len) {
2736 if (spec->multiout.num_dacs > 0) {
2737 /* we have already working output pins,
2738 * so let's drop the broken ones again
2740 cfg->line_outs = spec->multiout.num_dacs;
2743 /* error out, no available DAC found */
2745 "%s: No available DAC for pin 0x%x\n",
2750 spec->multiout.dac_nids[i] = conn[j];
2751 spec->multiout.num_dacs++;
2753 /* select this DAC in the pin's input mux */
2754 snd_hda_codec_write_cache(codec, nid, 0,
2755 AC_VERB_SET_CONNECT_SEL, j);
2760 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2761 spec->multiout.num_dacs,
2762 spec->multiout.dac_nids[0],
2763 spec->multiout.dac_nids[1],
2764 spec->multiout.dac_nids[2],
2765 spec->multiout.dac_nids[3],
2766 spec->multiout.dac_nids[4]);
2770 /* create volume control/switch for the given prefx type */
2771 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2776 sprintf(name, "%s Playback Volume", pfx);
2777 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2778 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2781 sprintf(name, "%s Playback Switch", pfx);
2782 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2783 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2789 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2791 if (!spec->multiout.hp_nid)
2792 spec->multiout.hp_nid = nid;
2793 else if (spec->multiout.num_dacs > 4) {
2794 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2797 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2798 spec->multiout.num_dacs++;
2803 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2805 if (is_in_dac_nids(spec, nid))
2807 if (spec->multiout.hp_nid == nid)
2812 /* add playback controls from the parsed DAC table */
2813 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2814 const struct auto_pin_cfg *cfg)
2816 static const char *chname[4] = {
2817 "Front", "Surround", NULL /*CLFE*/, "Side"
2822 struct sigmatel_spec *spec = codec->spec;
2823 unsigned int wid_caps, pincap;
2826 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2827 if (!spec->multiout.dac_nids[i])
2830 nid = spec->multiout.dac_nids[i];
2834 err = create_controls(spec, "Center", nid, 1);
2837 err = create_controls(spec, "LFE", nid, 2);
2841 wid_caps = get_wcaps(codec, nid);
2843 if (wid_caps & AC_WCAP_LR_SWAP) {
2844 err = stac92xx_add_control(spec,
2845 STAC_CTL_WIDGET_CLFE_SWITCH,
2846 "Swap Center/LFE Playback Switch", nid);
2853 err = create_controls(spec, chname[i], nid, 3);
2859 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2860 cfg->hp_outs && !spec->multiout.hp_nid)
2861 spec->multiout.hp_nid = nid;
2863 if (cfg->hp_outs > 1) {
2864 err = stac92xx_add_control(spec,
2865 STAC_CTL_WIDGET_HP_SWITCH,
2866 "Headphone as Line Out Switch", 0);
2871 if (spec->line_switch) {
2872 nid = cfg->input_pins[AUTO_PIN_LINE];
2873 pincap = snd_hda_param_read(codec, nid,
2875 if (pincap & AC_PINCAP_OUT) {
2876 err = stac92xx_add_control(spec,
2877 STAC_CTL_WIDGET_IO_SWITCH,
2878 "Line In as Output Switch", nid << 8);
2884 if (spec->mic_switch) {
2885 unsigned int def_conf;
2886 unsigned int mic_pin = AUTO_PIN_MIC;
2888 nid = cfg->input_pins[mic_pin];
2889 def_conf = snd_hda_codec_read(codec, nid, 0,
2890 AC_VERB_GET_CONFIG_DEFAULT, 0);
2891 /* some laptops have an internal analog microphone
2892 * which can't be used as a output */
2893 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2894 pincap = snd_hda_param_read(codec, nid,
2896 if (pincap & AC_PINCAP_OUT) {
2897 err = stac92xx_add_control(spec,
2898 STAC_CTL_WIDGET_IO_SWITCH,
2899 "Mic as Output Switch", (nid << 8) | 1);
2900 nid = snd_hda_codec_read(codec, nid, 0,
2901 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2902 if (!check_in_dac_nids(spec, nid))
2903 add_spec_dacs(spec, nid);
2907 } else if (mic_pin == AUTO_PIN_MIC) {
2908 mic_pin = AUTO_PIN_FRONT_MIC;
2916 /* add playback controls for Speaker and HP outputs */
2917 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2918 struct auto_pin_cfg *cfg)
2920 struct sigmatel_spec *spec = codec->spec;
2922 int i, old_num_dacs, err;
2924 old_num_dacs = spec->multiout.num_dacs;
2925 for (i = 0; i < cfg->hp_outs; i++) {
2926 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2927 if (wid_caps & AC_WCAP_UNSOL_CAP)
2928 spec->hp_detect = 1;
2929 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2930 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2931 if (check_in_dac_nids(spec, nid))
2935 add_spec_dacs(spec, nid);
2937 for (i = 0; i < cfg->speaker_outs; i++) {
2938 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2939 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2940 if (check_in_dac_nids(spec, nid))
2944 add_spec_dacs(spec, nid);
2946 for (i = 0; i < cfg->line_outs; i++) {
2947 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2948 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2949 if (check_in_dac_nids(spec, nid))
2953 add_spec_dacs(spec, nid);
2955 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2956 static const char *pfxs[] = {
2957 "Speaker", "External Speaker", "Speaker2",
2959 err = create_controls(spec, pfxs[i - old_num_dacs],
2960 spec->multiout.dac_nids[i], 3);
2964 if (spec->multiout.hp_nid) {
2965 err = create_controls(spec, "Headphone",
2966 spec->multiout.hp_nid, 3);
2974 /* labels for mono mux outputs */
2975 static const char *stac92xx_mono_labels[4] = {
2976 "DAC0", "DAC1", "Mixer", "DAC2"
2979 /* create mono mux for mono out on capable codecs */
2980 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2982 struct sigmatel_spec *spec = codec->spec;
2983 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2985 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2987 num_cons = snd_hda_get_connections(codec,
2990 HDA_MAX_NUM_INPUTS);
2991 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2994 for (i = 0; i < num_cons; i++) {
2995 mono_mux->items[mono_mux->num_items].label =
2996 stac92xx_mono_labels[i];
2997 mono_mux->items[mono_mux->num_items].index = i;
2998 mono_mux->num_items++;
3001 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3002 "Mono Mux", spec->mono_nid);
3005 /* labels for amp mux outputs */
3006 static const char *stac92xx_amp_labels[3] = {
3007 "Front Microphone", "Microphone", "Line In",
3010 /* create amp out controls mux on capable codecs */
3011 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3013 struct sigmatel_spec *spec = codec->spec;
3014 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3017 for (i = 0; i < spec->num_amps; i++) {
3018 amp_mux->items[amp_mux->num_items].label =
3019 stac92xx_amp_labels[i];
3020 amp_mux->items[amp_mux->num_items].index = i;
3021 amp_mux->num_items++;
3024 if (spec->num_amps > 1) {
3025 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3026 "Amp Selector Capture Switch", 0);
3030 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3031 "Amp Capture Volume",
3032 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3036 /* create PC beep volume controls */
3037 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3040 struct sigmatel_spec *spec = codec->spec;
3041 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3044 /* check for mute support for the the amp */
3045 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3046 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3047 "PC Beep Playback Switch",
3048 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3053 /* check to see if there is volume support for the amp */
3054 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3055 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3056 "PC Beep Playback Volume",
3057 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3064 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3066 struct sigmatel_spec *spec = codec->spec;
3067 int wcaps, nid, i, err = 0;
3069 for (i = 0; i < spec->num_muxes; i++) {
3070 nid = spec->mux_nids[i];
3071 wcaps = get_wcaps(codec, nid);
3073 if (wcaps & AC_WCAP_OUT_AMP) {
3074 err = stac92xx_add_control_idx(spec,
3075 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3076 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3084 static const char *stac92xx_spdif_labels[3] = {
3085 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3088 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3090 struct sigmatel_spec *spec = codec->spec;
3091 struct hda_input_mux *spdif_mux = &spec->private_smux;
3092 const char **labels = spec->spdif_labels;
3094 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3096 num_cons = snd_hda_get_connections(codec,
3099 HDA_MAX_NUM_INPUTS);
3104 labels = stac92xx_spdif_labels;
3106 for (i = 0; i < num_cons; i++) {
3107 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3108 spdif_mux->items[spdif_mux->num_items].index = i;
3109 spdif_mux->num_items++;
3115 /* labels for dmic mux inputs */
3116 static const char *stac92xx_dmic_labels[5] = {
3117 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3118 "Digital Mic 3", "Digital Mic 4"
3121 /* create playback/capture controls for input pins on dmic capable codecs */
3122 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3123 const struct auto_pin_cfg *cfg)
3125 struct sigmatel_spec *spec = codec->spec;
3126 struct hda_input_mux *dimux = &spec->private_dimux;
3127 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3131 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3132 dimux->items[dimux->num_items].index = 0;
3135 for (i = 0; i < spec->num_dmics; i++) {
3140 unsigned int def_conf;
3142 def_conf = snd_hda_codec_read(codec,
3145 AC_VERB_GET_CONFIG_DEFAULT,
3147 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3150 nid = spec->dmic_nids[i];
3151 num_cons = snd_hda_get_connections(codec,
3154 HDA_MAX_NUM_INPUTS);
3155 for (j = 0; j < num_cons; j++)
3156 if (con_lst[j] == nid) {
3162 wcaps = get_wcaps(codec, nid) &
3163 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3166 sprintf(name, "%s Capture Volume",
3167 stac92xx_dmic_labels[dimux->num_items]);
3169 err = stac92xx_add_control(spec,
3170 STAC_CTL_WIDGET_VOL,
3172 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3173 (wcaps & AC_WCAP_OUT_AMP) ?
3174 HDA_OUTPUT : HDA_INPUT));
3179 dimux->items[dimux->num_items].label =
3180 stac92xx_dmic_labels[dimux->num_items];
3181 dimux->items[dimux->num_items].index = index;
3188 /* create playback/capture controls for input pins */
3189 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3191 struct sigmatel_spec *spec = codec->spec;
3192 struct hda_input_mux *imux = &spec->private_imux;
3193 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3196 for (i = 0; i < AUTO_PIN_LAST; i++) {
3199 if (!cfg->input_pins[i])
3202 for (j = 0; j < spec->num_muxes; j++) {
3204 num_cons = snd_hda_get_connections(codec,
3207 HDA_MAX_NUM_INPUTS);
3208 for (k = 0; k < num_cons; k++)
3209 if (con_lst[k] == cfg->input_pins[i]) {
3216 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3217 imux->items[imux->num_items].index = index;
3221 if (imux->num_items) {
3223 * Set the current input for the muxes.
3224 * The STAC9221 has two input muxes with identical source
3225 * NID lists. Hopefully this won't get confused.
3227 for (i = 0; i < spec->num_muxes; i++) {
3228 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3229 AC_VERB_SET_CONNECT_SEL,
3230 imux->items[0].index);
3237 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3239 struct sigmatel_spec *spec = codec->spec;
3242 for (i = 0; i < spec->autocfg.line_outs; i++) {
3243 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3244 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3248 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3250 struct sigmatel_spec *spec = codec->spec;
3253 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3255 pin = spec->autocfg.hp_pins[i];
3256 if (pin) /* connect to front */
3257 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3259 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3261 pin = spec->autocfg.speaker_pins[i];
3262 if (pin) /* connect to front */