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
40 #define STAC_VREF_EVENT 0x00
41 #define STAC_INSERT_EVENT 0x10
42 #define STAC_PWR_EVENT 0x20
43 #define STAC_HP_EVENT 0x30
72 STAC_92HD73XX_NO_JD, /* no jack-detection */
112 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
113 * is given, one of the above models will be
114 * chosen according to the subsystem id. */
115 /* for backward compatibility */
131 STAC_D965_REF_NO_JD, /* no jack-detection */
140 struct sigmatel_spec {
141 struct snd_kcontrol_new *mixers[4];
142 unsigned int num_mixers;
145 unsigned int eapd_switch: 1;
146 unsigned int surr_switch: 1;
147 unsigned int line_switch: 1;
148 unsigned int mic_switch: 1;
149 unsigned int alt_switch: 1;
150 unsigned int hp_detect: 1;
151 unsigned int spdif_mute: 1;
154 unsigned int eapd_mask;
155 unsigned int gpio_mask;
156 unsigned int gpio_dir;
157 unsigned int gpio_data;
158 unsigned int gpio_mute;
161 unsigned int stream_delay;
163 /* analog loopback */
164 unsigned char aloopback_mask;
165 unsigned char aloopback_shift;
167 /* power management */
168 unsigned int num_pwrs;
169 unsigned int *pwr_mapping;
174 struct hda_input_mux *mono_mux;
175 struct hda_input_mux *amp_mux;
176 unsigned int cur_mmux;
177 struct hda_multi_out multiout;
178 hda_nid_t dac_nids[5];
182 unsigned int num_adcs;
184 unsigned int num_muxes;
185 hda_nid_t *dmic_nids;
186 unsigned int num_dmics;
187 hda_nid_t *dmux_nids;
188 unsigned int num_dmuxes;
189 hda_nid_t *smux_nids;
190 unsigned int num_smuxes;
191 const char **spdif_labels;
193 hda_nid_t dig_in_nid;
195 hda_nid_t anabeep_nid;
196 hda_nid_t digbeep_nid;
200 unsigned int num_pins;
201 unsigned int *pin_configs;
202 unsigned int *bios_pin_configs;
204 /* codec specific stuff */
205 struct hda_verb *init;
206 struct snd_kcontrol_new *mixer;
209 struct hda_input_mux *dinput_mux;
210 unsigned int cur_dmux[2];
211 struct hda_input_mux *input_mux;
212 unsigned int cur_mux[3];
213 struct hda_input_mux *sinput_mux;
214 unsigned int cur_smux[2];
215 unsigned int cur_amux;
217 unsigned int num_amps;
218 unsigned int powerdown_adcs;
221 unsigned int io_switch[2];
222 unsigned int clfe_swap;
223 unsigned int hp_switch; /* NID of HP as line-out */
224 unsigned int aloopback;
226 struct hda_pcm pcm_rec[2]; /* PCM information */
228 /* dynamic controls and input_mux */
229 struct auto_pin_cfg autocfg;
230 unsigned int num_kctl_alloc, num_kctl_used;
231 struct snd_kcontrol_new *kctl_alloc;
232 struct hda_input_mux private_dimux;
233 struct hda_input_mux private_imux;
234 struct hda_input_mux private_smux;
235 struct hda_input_mux private_amp_mux;
236 struct hda_input_mux private_mono_mux;
239 static hda_nid_t stac9200_adc_nids[1] = {
243 static hda_nid_t stac9200_mux_nids[1] = {
247 static hda_nid_t stac9200_dac_nids[1] = {
251 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
252 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
256 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
260 static hda_nid_t stac92hd73xx_adc_nids[2] = {
264 #define DELL_M6_AMP 2
265 static hda_nid_t stac92hd73xx_amp_nids[3] = {
269 #define STAC92HD73XX_NUM_DMICS 2
270 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
274 #define STAC92HD73_DAC_COUNT 5
275 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
276 0x15, 0x16, 0x17, 0x18, 0x19,
279 static hda_nid_t stac92hd73xx_mux_nids[4] = {
280 0x28, 0x29, 0x2a, 0x2b,
283 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
287 static hda_nid_t stac92hd73xx_smux_nids[2] = {
291 #define STAC92HD83XXX_NUM_DMICS 2
292 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
296 #define STAC92HD81_DAC_COUNT 2
297 #define STAC92HD83_DAC_COUNT 3
298 static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
302 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
306 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
310 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
314 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
318 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
319 0x03, 0x0c, 0x10, 0x40,
322 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
326 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
330 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
334 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
338 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
342 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
346 #define STAC92HD71BXX_NUM_DMICS 2
347 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
351 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
355 static hda_nid_t stac925x_adc_nids[1] = {
359 static hda_nid_t stac925x_mux_nids[1] = {
363 static hda_nid_t stac925x_dac_nids[1] = {
367 #define STAC925X_NUM_DMICS 1
368 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
372 static hda_nid_t stac925x_dmux_nids[1] = {
376 static hda_nid_t stac922x_adc_nids[2] = {
380 static hda_nid_t stac922x_mux_nids[2] = {
384 static hda_nid_t stac927x_adc_nids[3] = {
388 static hda_nid_t stac927x_mux_nids[3] = {
392 static hda_nid_t stac927x_smux_nids[1] = {
396 static hda_nid_t stac927x_dac_nids[6] = {
397 0x02, 0x03, 0x04, 0x05, 0x06, 0
400 static hda_nid_t stac927x_dmux_nids[1] = {
404 #define STAC927X_NUM_DMICS 2
405 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
409 static const char *stac927x_spdif_labels[5] = {
410 "Digital Playback", "ADAT", "Analog Mux 1",
411 "Analog Mux 2", "Analog Mux 3"
414 static hda_nid_t stac9205_adc_nids[2] = {
418 static hda_nid_t stac9205_mux_nids[2] = {
422 static hda_nid_t stac9205_dmux_nids[1] = {
426 static hda_nid_t stac9205_smux_nids[1] = {
430 #define STAC9205_NUM_DMICS 2
431 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
435 static hda_nid_t stac9200_pin_nids[8] = {
436 0x08, 0x09, 0x0d, 0x0e,
437 0x0f, 0x10, 0x11, 0x12,
440 static hda_nid_t stac925x_pin_nids[8] = {
441 0x07, 0x08, 0x0a, 0x0b,
442 0x0c, 0x0d, 0x10, 0x11,
445 static hda_nid_t stac922x_pin_nids[10] = {
446 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
447 0x0f, 0x10, 0x11, 0x15, 0x1b,
450 static hda_nid_t stac92hd73xx_pin_nids[13] = {
451 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
452 0x0f, 0x10, 0x11, 0x12, 0x13,
456 static hda_nid_t stac92hd83xxx_pin_nids[14] = {
457 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
458 0x0f, 0x10, 0x11, 0x12, 0x13,
459 0x1d, 0x1e, 0x1f, 0x20
461 static hda_nid_t stac92hd71bxx_pin_nids[11] = {
462 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
463 0x0f, 0x14, 0x18, 0x19, 0x1e,
467 static hda_nid_t stac927x_pin_nids[14] = {
468 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
469 0x0f, 0x10, 0x11, 0x12, 0x13,
470 0x14, 0x21, 0x22, 0x23,
473 static hda_nid_t stac9205_pin_nids[12] = {
474 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
475 0x0f, 0x14, 0x16, 0x17, 0x18,
479 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
481 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
482 struct snd_ctl_elem_value *ucontrol)
484 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
485 struct sigmatel_spec *spec = codec->spec;
486 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
488 kcontrol->private_value ^= get_amp_nid(kcontrol);
489 kcontrol->private_value |= nid;
491 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
494 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
495 struct snd_ctl_elem_value *ucontrol)
497 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
498 struct sigmatel_spec *spec = codec->spec;
499 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
501 kcontrol->private_value ^= get_amp_nid(kcontrol);
502 kcontrol->private_value |= nid;
504 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
507 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
508 struct snd_ctl_elem_info *uinfo)
510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
511 struct sigmatel_spec *spec = codec->spec;
512 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
515 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_value *ucontrol)
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 struct sigmatel_spec *spec = codec->spec;
520 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
522 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
526 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
527 struct snd_ctl_elem_value *ucontrol)
529 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
530 struct sigmatel_spec *spec = codec->spec;
531 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
533 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
534 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
537 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
538 struct snd_ctl_elem_info *uinfo)
540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
541 struct sigmatel_spec *spec = codec->spec;
542 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
545 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
546 struct snd_ctl_elem_value *ucontrol)
548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
549 struct sigmatel_spec *spec = codec->spec;
550 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
552 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
556 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
557 struct snd_ctl_elem_value *ucontrol)
559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
560 struct sigmatel_spec *spec = codec->spec;
561 struct hda_input_mux *smux = &spec->private_smux;
562 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
566 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
567 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
571 if (spec->spdif_mute) {
573 nid = spec->multiout.dig_out_nid;
575 nid = codec->slave_dig_outs[smux_idx - 1];
576 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
579 val = AMP_OUT_UNMUTE;
580 /* un/mute SPDIF out */
581 snd_hda_codec_write_cache(codec, nid, 0,
582 AC_VERB_SET_AMP_GAIN_MUTE, val);
587 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
589 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
590 struct sigmatel_spec *spec = codec->spec;
591 return snd_hda_input_mux_info(spec->input_mux, uinfo);
594 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
596 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
597 struct sigmatel_spec *spec = codec->spec;
598 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
600 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
604 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
607 struct sigmatel_spec *spec = codec->spec;
608 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
610 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
611 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
614 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_info *uinfo)
617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
618 struct sigmatel_spec *spec = codec->spec;
619 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
622 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
623 struct snd_ctl_elem_value *ucontrol)
625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
626 struct sigmatel_spec *spec = codec->spec;
628 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
632 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_value *ucontrol)
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 struct sigmatel_spec *spec = codec->spec;
638 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
639 spec->mono_nid, &spec->cur_mmux);
642 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_info *uinfo)
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 struct sigmatel_spec *spec = codec->spec;
647 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
650 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
651 struct snd_ctl_elem_value *ucontrol)
653 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
654 struct sigmatel_spec *spec = codec->spec;
656 ucontrol->value.enumerated.item[0] = spec->cur_amux;
660 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
661 struct snd_ctl_elem_value *ucontrol)
663 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
664 struct sigmatel_spec *spec = codec->spec;
665 struct snd_kcontrol *ctl =
666 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
670 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
671 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
673 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
677 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
679 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
680 struct snd_ctl_elem_value *ucontrol)
682 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
683 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
684 struct sigmatel_spec *spec = codec->spec;
686 ucontrol->value.integer.value[0] = !!(spec->aloopback &
687 (spec->aloopback_mask << idx));
691 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
692 struct snd_ctl_elem_value *ucontrol)
694 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
695 struct sigmatel_spec *spec = codec->spec;
696 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
697 unsigned int dac_mode;
698 unsigned int val, idx_val;
700 idx_val = spec->aloopback_mask << idx;
701 if (ucontrol->value.integer.value[0])
702 val = spec->aloopback | idx_val;
704 val = spec->aloopback & ~idx_val;
705 if (spec->aloopback == val)
708 spec->aloopback = val;
710 /* Only return the bits defined by the shift value of the
711 * first two bytes of the mask
713 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
714 kcontrol->private_value & 0xFFFF, 0x0);
715 dac_mode >>= spec->aloopback_shift;
717 if (spec->aloopback & idx_val) {
718 snd_hda_power_up(codec);
721 snd_hda_power_down(codec);
722 dac_mode &= ~idx_val;
725 snd_hda_codec_write_cache(codec, codec->afg, 0,
726 kcontrol->private_value >> 16, dac_mode);
731 static struct hda_verb stac9200_core_init[] = {
732 /* set dac0mux for dac converter */
733 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
737 static struct hda_verb stac9200_eapd_init[] = {
738 /* set dac0mux for dac converter */
739 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
740 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
744 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
745 /* set master volume and direct control */
746 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
747 /* setup audio connections */
748 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
749 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
750 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
751 /* setup adcs to point to mixer */
752 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
753 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
754 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
755 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
756 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
757 /* setup import muxs */
758 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
759 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
760 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
761 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
765 static struct hda_verb dell_eq_core_init[] = {
766 /* set master volume to max value without distortion
767 * and direct control */
768 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
769 /* setup audio connections */
770 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
771 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
772 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
773 /* setup adcs to point to mixer */
774 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
775 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
776 /* setup import muxs */
777 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
778 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
779 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
780 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
784 static struct hda_verb dell_m6_core_init[] = {
785 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
786 /* setup audio connections */
787 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
788 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
789 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
790 /* setup adcs to point to mixer */
791 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
792 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
793 /* setup import muxs */
794 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
795 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
796 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
797 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
801 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
802 /* set master volume and direct control */
803 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
804 /* setup audio connections */
805 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
806 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
807 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
808 /* connect hp ports to dac3 */
809 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
810 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
811 /* setup adcs to point to mixer */
812 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
813 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
814 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
815 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
816 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
817 /* setup import muxs */
818 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
819 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
820 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
821 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
825 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
826 /* set master volume and direct control */
827 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
828 /* setup audio connections */
829 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
830 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
831 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
832 /* dac3 is connected to import3 mux */
833 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
834 /* connect hp ports to dac4 */
835 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
836 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
837 /* setup adcs to point to mixer */
838 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
839 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
840 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
841 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
842 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
843 /* setup import muxs */
844 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
845 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
846 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
847 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
851 static struct hda_verb stac92hd83xxx_core_init[] = {
852 /* start of config #1 */
853 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
855 /* start of config #2 */
856 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
857 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
858 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
860 /* power state controls amps */
861 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
864 static struct hda_verb stac92hd71bxx_core_init[] = {
865 /* set master volume and direct control */
866 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
867 /* connect headphone jack to dac1 */
868 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
869 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
870 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
871 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
872 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
875 #define HD_DISABLE_PORTF 2
876 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
877 /* start of config #1 */
879 /* connect port 0f to audio mixer */
880 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
881 /* unmute right and left channels for node 0x0f */
882 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
883 /* start of config #2 */
885 /* set master volume and direct control */
886 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
887 /* connect headphone jack to dac1 */
888 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
889 /* unmute right and left channels for nodes 0x0a, 0xd */
890 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
891 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
895 static struct hda_verb stac925x_core_init[] = {
896 /* set dac0mux for dac converter */
897 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
901 static struct hda_verb stac922x_core_init[] = {
902 /* set master volume and direct control */
903 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
907 static struct hda_verb d965_core_init[] = {
908 /* set master volume and direct control */
909 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
910 /* unmute node 0x1b */
911 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
912 /* select node 0x03 as DAC */
913 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
917 static struct hda_verb stac927x_core_init[] = {
918 /* set master volume and direct control */
919 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
920 /* enable analog pc beep path */
921 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
925 static struct hda_verb stac9205_core_init[] = {
926 /* set master volume and direct control */
927 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
928 /* enable analog pc beep path */
929 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
933 #define STAC_MONO_MUX \
935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
936 .name = "Mono Mux", \
938 .info = stac92xx_mono_mux_enum_info, \
939 .get = stac92xx_mono_mux_enum_get, \
940 .put = stac92xx_mono_mux_enum_put, \
943 #define STAC_AMP_MUX \
945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
946 .name = "Amp Selector Capture Switch", \
948 .info = stac92xx_amp_mux_enum_info, \
949 .get = stac92xx_amp_mux_enum_get, \
950 .put = stac92xx_amp_mux_enum_put, \
953 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
958 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
959 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
960 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
961 .info = stac92xx_amp_volume_info, \
962 .get = stac92xx_amp_volume_get, \
963 .put = stac92xx_amp_volume_put, \
964 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
965 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
968 #define STAC_INPUT_SOURCE(cnt) \
970 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
971 .name = "Input Source", \
973 .info = stac92xx_mux_enum_info, \
974 .get = stac92xx_mux_enum_get, \
975 .put = stac92xx_mux_enum_put, \
978 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
981 .name = "Analog Loopback", \
983 .info = stac92xx_aloopback_info, \
984 .get = stac92xx_aloopback_get, \
985 .put = stac92xx_aloopback_put, \
986 .private_value = verb_read | (verb_write << 16), \
989 static struct snd_kcontrol_new stac9200_mixer[] = {
990 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
991 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
992 STAC_INPUT_SOURCE(1),
993 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
994 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
998 #define DELL_M6_MIXER 6
999 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1000 /* start of config #1 */
1001 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1002 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1004 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1005 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1007 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1008 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1010 /* start of config #2 */
1011 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1012 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1014 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1015 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1017 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1019 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1020 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1022 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1023 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1028 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1029 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1031 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1032 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1034 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1035 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1037 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1038 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1040 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1041 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1043 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1044 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1046 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1047 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1049 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1050 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1054 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1055 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1057 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1058 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1060 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1061 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1063 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1064 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1066 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1067 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1069 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1070 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1072 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1073 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1075 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1076 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1081 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1082 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1083 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1085 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1086 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1088 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1089 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1091 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1092 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1094 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1095 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1097 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1098 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1101 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1102 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1107 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1108 STAC_INPUT_SOURCE(2),
1109 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1111 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1112 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1114 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1115 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1116 /* analog pc-beep replaced with digital beep support */
1118 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1119 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1122 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1123 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1125 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1126 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1128 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1129 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1131 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1132 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1136 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1137 STAC_INPUT_SOURCE(2),
1138 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1140 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1141 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1143 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1144 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1148 static struct snd_kcontrol_new stac925x_mixer[] = {
1149 STAC_INPUT_SOURCE(1),
1150 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1151 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1155 static struct snd_kcontrol_new stac9205_mixer[] = {
1156 STAC_INPUT_SOURCE(2),
1157 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1159 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1160 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1162 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1163 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1167 /* This needs to be generated dynamically based on sequence */
1168 static struct snd_kcontrol_new stac922x_mixer[] = {
1169 STAC_INPUT_SOURCE(2),
1170 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1171 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1173 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1174 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1179 static struct snd_kcontrol_new stac927x_mixer[] = {
1180 STAC_INPUT_SOURCE(3),
1181 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1183 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1184 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1186 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1187 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1189 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1190 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1194 static struct snd_kcontrol_new stac_dmux_mixer = {
1195 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1196 .name = "Digital Input Source",
1197 /* count set later */
1198 .info = stac92xx_dmux_enum_info,
1199 .get = stac92xx_dmux_enum_get,
1200 .put = stac92xx_dmux_enum_put,
1203 static struct snd_kcontrol_new stac_smux_mixer = {
1204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1205 .name = "IEC958 Playback Source",
1206 /* count set later */
1207 .info = stac92xx_smux_enum_info,
1208 .get = stac92xx_smux_enum_get,
1209 .put = stac92xx_smux_enum_put,
1212 static const char *slave_vols[] = {
1213 "Front Playback Volume",
1214 "Surround Playback Volume",
1215 "Center Playback Volume",
1216 "LFE Playback Volume",
1217 "Side Playback Volume",
1218 "Headphone Playback Volume",
1219 "Headphone Playback Volume",
1220 "Speaker Playback Volume",
1221 "External Speaker Playback Volume",
1222 "Speaker2 Playback Volume",
1226 static const char *slave_sws[] = {
1227 "Front Playback Switch",
1228 "Surround Playback Switch",
1229 "Center Playback Switch",
1230 "LFE Playback Switch",
1231 "Side Playback Switch",
1232 "Headphone Playback Switch",
1233 "Headphone Playback Switch",
1234 "Speaker Playback Switch",
1235 "External Speaker Playback Switch",
1236 "Speaker2 Playback Switch",
1237 "IEC958 Playback Switch",
1241 static int stac92xx_build_controls(struct hda_codec *codec)
1243 struct sigmatel_spec *spec = codec->spec;
1247 err = snd_hda_add_new_ctls(codec, spec->mixer);
1251 for (i = 0; i < spec->num_mixers; i++) {
1252 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1256 if (spec->num_dmuxes > 0) {
1257 stac_dmux_mixer.count = spec->num_dmuxes;
1258 err = snd_ctl_add(codec->bus->card,
1259 snd_ctl_new1(&stac_dmux_mixer, codec));
1263 if (spec->num_smuxes > 0) {
1264 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1265 struct hda_input_mux *smux = &spec->private_smux;
1266 /* check for mute support on SPDIF out */
1267 if (wcaps & AC_WCAP_OUT_AMP) {
1268 smux->items[smux->num_items].label = "Off";
1269 smux->items[smux->num_items].index = 0;
1271 spec->spdif_mute = 1;
1273 stac_smux_mixer.count = spec->num_smuxes;
1274 err = snd_ctl_add(codec->bus->card,
1275 snd_ctl_new1(&stac_smux_mixer, codec));
1280 if (spec->multiout.dig_out_nid) {
1281 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1284 err = snd_hda_create_spdif_share_sw(codec,
1288 spec->multiout.share_spdif = 1;
1290 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1291 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1296 /* if we have no master control, let's create it */
1297 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1298 unsigned int vmaster_tlv[4];
1299 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1300 HDA_OUTPUT, vmaster_tlv);
1301 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1302 vmaster_tlv, slave_vols);
1306 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1307 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1316 static unsigned int ref9200_pin_configs[8] = {
1317 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1318 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1322 STAC 9200 pin configs for
1327 static unsigned int dell9200_d21_pin_configs[8] = {
1328 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1329 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1333 STAC 9200 pin configs for
1337 static unsigned int dell9200_d22_pin_configs[8] = {
1338 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1339 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1343 STAC 9200 pin configs for
1344 102801C4 (Dell Dimension E310)
1351 static unsigned int dell9200_d23_pin_configs[8] = {
1352 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1353 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1358 STAC 9200-32 pin configs for
1359 102801B5 (Dell Inspiron 630m)
1360 102801D8 (Dell Inspiron 640m)
1362 static unsigned int dell9200_m21_pin_configs[8] = {
1363 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1364 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1368 STAC 9200-32 pin configs for
1369 102801C2 (Dell Latitude D620)
1371 102801CC (Dell Latitude D820)
1375 static unsigned int dell9200_m22_pin_configs[8] = {
1376 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1377 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1381 STAC 9200-32 pin configs for
1382 102801CE (Dell XPS M1710)
1383 102801CF (Dell Precision M90)
1385 static unsigned int dell9200_m23_pin_configs[8] = {
1386 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1387 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1391 STAC 9200-32 pin configs for
1394 102801CB (Dell Latitude 120L)
1397 static unsigned int dell9200_m24_pin_configs[8] = {
1398 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1399 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1403 STAC 9200-32 pin configs for
1404 102801BD (Dell Inspiron E1505n)
1408 static unsigned int dell9200_m25_pin_configs[8] = {
1409 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1410 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1414 STAC 9200-32 pin configs for
1415 102801F5 (Dell Inspiron 1501)
1418 static unsigned int dell9200_m26_pin_configs[8] = {
1419 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1420 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1425 102801CD (Dell Inspiron E1705/9400)
1427 static unsigned int dell9200_m27_pin_configs[8] = {
1428 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1429 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1432 static unsigned int oqo9200_pin_configs[8] = {
1433 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1434 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1438 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1439 [STAC_REF] = ref9200_pin_configs,
1440 [STAC_9200_OQO] = oqo9200_pin_configs,
1441 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1442 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1443 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1444 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1445 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1446 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1447 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1448 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1449 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1450 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1451 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1454 static const char *stac9200_models[STAC_9200_MODELS] = {
1456 [STAC_9200_OQO] = "oqo",
1457 [STAC_9200_DELL_D21] = "dell-d21",
1458 [STAC_9200_DELL_D22] = "dell-d22",
1459 [STAC_9200_DELL_D23] = "dell-d23",
1460 [STAC_9200_DELL_M21] = "dell-m21",
1461 [STAC_9200_DELL_M22] = "dell-m22",
1462 [STAC_9200_DELL_M23] = "dell-m23",
1463 [STAC_9200_DELL_M24] = "dell-m24",
1464 [STAC_9200_DELL_M25] = "dell-m25",
1465 [STAC_9200_DELL_M26] = "dell-m26",
1466 [STAC_9200_DELL_M27] = "dell-m27",
1467 [STAC_9200_GATEWAY] = "gateway",
1468 [STAC_9200_PANASONIC] = "panasonic",
1471 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1472 /* SigmaTel reference board */
1473 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1474 "DFI LanParty", STAC_REF),
1475 /* Dell laptops have BIOS problem */
1476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1477 "unknown Dell", STAC_9200_DELL_D21),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1479 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1481 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1483 "unknown Dell", STAC_9200_DELL_D22),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1485 "unknown Dell", STAC_9200_DELL_D22),
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1487 "Dell Latitude D620", STAC_9200_DELL_M22),
1488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1489 "unknown Dell", STAC_9200_DELL_D23),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1491 "unknown Dell", STAC_9200_DELL_D23),
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1493 "unknown Dell", STAC_9200_DELL_M22),
1494 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1495 "unknown Dell", STAC_9200_DELL_M24),
1496 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1497 "unknown Dell", STAC_9200_DELL_M24),
1498 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1499 "Dell Latitude 120L", STAC_9200_DELL_M24),
1500 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1501 "Dell Latitude D820", STAC_9200_DELL_M22),
1502 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1503 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1504 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1505 "Dell XPS M1710", STAC_9200_DELL_M23),
1506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1507 "Dell Precision M90", STAC_9200_DELL_M23),
1508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1509 "unknown Dell", STAC_9200_DELL_M22),
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1511 "unknown Dell", STAC_9200_DELL_M22),
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1513 "unknown Dell", STAC_9200_DELL_M22),
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1515 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1517 "unknown Dell", STAC_9200_DELL_D23),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1519 "unknown Dell", STAC_9200_DELL_D23),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1521 "unknown Dell", STAC_9200_DELL_D21),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1523 "unknown Dell", STAC_9200_DELL_D23),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1525 "unknown Dell", STAC_9200_DELL_D21),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1527 "unknown Dell", STAC_9200_DELL_M25),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1529 "unknown Dell", STAC_9200_DELL_M25),
1530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1531 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1532 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1533 "unknown Dell", STAC_9200_DELL_M26),
1535 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1536 /* Gateway machines needs EAPD to be set on resume */
1537 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1538 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1540 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1543 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1547 static unsigned int ref925x_pin_configs[8] = {
1548 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1549 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1552 static unsigned int stac925x_MA6_pin_configs[8] = {
1553 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1554 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1557 static unsigned int stac925x_PA6_pin_configs[8] = {
1558 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1559 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1562 static unsigned int stac925xM2_2_pin_configs[8] = {
1563 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1564 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1567 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1568 [STAC_REF] = ref925x_pin_configs,
1569 [STAC_M2_2] = stac925xM2_2_pin_configs,
1570 [STAC_MA6] = stac925x_MA6_pin_configs,
1571 [STAC_PA6] = stac925x_PA6_pin_configs,
1574 static const char *stac925x_models[STAC_925x_MODELS] = {
1576 [STAC_M2_2] = "m2-2",
1581 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1582 /* SigmaTel reference board */
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1584 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1585 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1586 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1587 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1588 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1589 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1593 static unsigned int ref92hd73xx_pin_configs[13] = {
1594 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1595 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1596 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1600 static unsigned int dell_m6_pin_configs[13] = {
1601 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1602 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1603 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1607 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1608 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1609 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1610 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1611 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1612 [STAC_DELL_EQ] = dell_m6_pin_configs,
1615 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1616 [STAC_92HD73XX_NO_JD] = "no-jd",
1617 [STAC_92HD73XX_REF] = "ref",
1618 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1619 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1620 [STAC_DELL_M6_BOTH] = "dell-m6",
1621 [STAC_DELL_EQ] = "dell-eq",
1624 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1625 /* SigmaTel reference board */
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1627 "DFI LanParty", STAC_92HD73XX_REF),
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1629 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1631 "unknown Dell", STAC_DELL_M6_DMIC),
1632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1633 "unknown Dell", STAC_DELL_M6_BOTH),
1634 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1635 "unknown Dell", STAC_DELL_M6_BOTH),
1636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1637 "unknown Dell", STAC_DELL_M6_AMIC),
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1639 "unknown Dell", STAC_DELL_M6_AMIC),
1640 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1641 "unknown Dell", STAC_DELL_M6_DMIC),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1643 "unknown Dell", STAC_DELL_M6_DMIC),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1645 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1647 "Dell Studio 17", STAC_DELL_M6_DMIC),
1651 static unsigned int ref92hd83xxx_pin_configs[14] = {
1652 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1653 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1654 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1655 0x01451160, 0x98560170,
1658 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1659 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1662 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1663 [STAC_92HD83XXX_REF] = "ref",
1666 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1667 /* SigmaTel reference board */
1668 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1669 "DFI LanParty", STAC_92HD71BXX_REF),
1672 static unsigned int ref92hd71bxx_pin_configs[11] = {
1673 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1674 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1675 0x90a000f0, 0x01452050, 0x01452050,
1678 static unsigned int dell_m4_1_pin_configs[11] = {
1679 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1680 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1681 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
1684 static unsigned int dell_m4_2_pin_configs[11] = {
1685 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1686 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1687 0x40f000f0, 0x044413b0, 0x044413b0,
1690 static unsigned int dell_m4_3_pin_configs[11] = {
1691 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1692 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1693 0x40f000f0, 0x044413b0, 0x044413b0,
1696 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1697 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1698 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1699 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1700 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1701 [STAC_HP_M4] = NULL,
1704 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1705 [STAC_92HD71BXX_REF] = "ref",
1706 [STAC_DELL_M4_1] = "dell-m4-1",
1707 [STAC_DELL_M4_2] = "dell-m4-2",
1708 [STAC_DELL_M4_3] = "dell-m4-3",
1709 [STAC_HP_M4] = "hp-m4",
1712 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1713 /* SigmaTel reference board */
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1715 "DFI LanParty", STAC_92HD71BXX_REF),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1717 "HP dv5", STAC_HP_M4),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1719 "HP dv7", STAC_HP_M4),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1721 "unknown HP", STAC_HP_M4),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1723 "unknown Dell", STAC_DELL_M4_1),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1725 "unknown Dell", STAC_DELL_M4_1),
1726 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1727 "unknown Dell", STAC_DELL_M4_1),
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1729 "unknown Dell", STAC_DELL_M4_1),
1730 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1731 "unknown Dell", STAC_DELL_M4_1),
1732 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1733 "unknown Dell", STAC_DELL_M4_1),
1734 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1735 "unknown Dell", STAC_DELL_M4_1),
1736 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1737 "unknown Dell", STAC_DELL_M4_2),
1738 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1739 "unknown Dell", STAC_DELL_M4_2),
1740 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1741 "unknown Dell", STAC_DELL_M4_2),
1742 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1743 "unknown Dell", STAC_DELL_M4_2),
1744 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1745 "unknown Dell", STAC_DELL_M4_3),
1749 static unsigned int ref922x_pin_configs[10] = {
1750 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1751 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1752 0x40000100, 0x40000100,
1756 STAC 922X pin configs for
1763 static unsigned int dell_922x_d81_pin_configs[10] = {
1764 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1765 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1766 0x01813122, 0x400001f2,
1770 STAC 922X pin configs for
1774 static unsigned int dell_922x_d82_pin_configs[10] = {
1775 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1776 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1777 0x01813122, 0x400001f1,
1781 STAC 922X pin configs for
1784 static unsigned int dell_922x_m81_pin_configs[10] = {
1785 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1786 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1787 0x40C003f1, 0x405003f0,
1791 STAC 9221 A1 pin configs for
1792 102801D7 (Dell XPS M1210)
1794 static unsigned int dell_922x_m82_pin_configs[10] = {
1795 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1796 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1797 0x508003f3, 0x405003f4,
1800 static unsigned int d945gtp3_pin_configs[10] = {
1801 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1802 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1803 0x02a19120, 0x40000100,
1806 static unsigned int d945gtp5_pin_configs[10] = {
1807 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1808 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1809 0x02a19320, 0x40000100,
1812 static unsigned int intel_mac_v1_pin_configs[10] = {
1813 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1814 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1815 0x400000fc, 0x400000fb,
1818 static unsigned int intel_mac_v2_pin_configs[10] = {
1819 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1820 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1821 0x400000fc, 0x400000fb,
1824 static unsigned int intel_mac_v3_pin_configs[10] = {
1825 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1826 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1827 0x400000fc, 0x400000fb,
1830 static unsigned int intel_mac_v4_pin_configs[10] = {
1831 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1832 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1833 0x400000fc, 0x400000fb,
1836 static unsigned int intel_mac_v5_pin_configs[10] = {
1837 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1838 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1839 0x400000fc, 0x400000fb,
1842 static unsigned int ecs202_pin_configs[10] = {
1843 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1844 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1845 0x9037012e, 0x40e000f2,
1848 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1849 [STAC_D945_REF] = ref922x_pin_configs,
1850 [STAC_D945GTP3] = d945gtp3_pin_configs,
1851 [STAC_D945GTP5] = d945gtp5_pin_configs,
1852 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1853 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1854 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1855 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1856 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1857 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1858 /* for backward compatibility */
1859 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1860 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1861 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1862 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1863 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1864 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1865 [STAC_ECS_202] = ecs202_pin_configs,
1866 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1867 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1868 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1869 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1872 static const char *stac922x_models[STAC_922X_MODELS] = {
1873 [STAC_D945_REF] = "ref",
1874 [STAC_D945GTP5] = "5stack",
1875 [STAC_D945GTP3] = "3stack",
1876 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1877 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1878 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1879 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1880 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1881 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1882 /* for backward compatibility */
1883 [STAC_MACMINI] = "macmini",
1884 [STAC_MACBOOK] = "macbook",
1885 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1886 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1887 [STAC_IMAC_INTEL] = "imac-intel",
1888 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1889 [STAC_ECS_202] = "ecs202",
1890 [STAC_922X_DELL_D81] = "dell-d81",
1891 [STAC_922X_DELL_D82] = "dell-d82",
1892 [STAC_922X_DELL_M81] = "dell-m81",
1893 [STAC_922X_DELL_M82] = "dell-m82",
1896 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1897 /* SigmaTel reference board */
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1899 "DFI LanParty", STAC_D945_REF),
1900 /* Intel 945G based systems */
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1902 "Intel D945G", STAC_D945GTP3),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1904 "Intel D945G", STAC_D945GTP3),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1906 "Intel D945G", STAC_D945GTP3),
1907 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1908 "Intel D945G", STAC_D945GTP3),
1909 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1910 "Intel D945G", STAC_D945GTP3),
1911 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1912 "Intel D945G", STAC_D945GTP3),
1913 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1914 "Intel D945G", STAC_D945GTP3),
1915 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1916 "Intel D945G", STAC_D945GTP3),
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1918 "Intel D945G", STAC_D945GTP3),
1919 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1920 "Intel D945G", STAC_D945GTP3),
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1922 "Intel D945G", STAC_D945GTP3),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1924 "Intel D945G", STAC_D945GTP3),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1926 "Intel D945G", STAC_D945GTP3),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1928 "Intel D945G", STAC_D945GTP3),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1930 "Intel D945G", STAC_D945GTP3),
1931 /* Intel D945G 5-stack systems */
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1933 "Intel D945G", STAC_D945GTP5),
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1935 "Intel D945G", STAC_D945GTP5),
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1937 "Intel D945G", STAC_D945GTP5),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1939 "Intel D945G", STAC_D945GTP5),
1940 /* Intel 945P based systems */
1941 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1942 "Intel D945P", STAC_D945GTP3),
1943 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1944 "Intel D945P", STAC_D945GTP3),
1945 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1946 "Intel D945P", STAC_D945GTP3),
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1948 "Intel D945P", STAC_D945GTP3),
1949 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1950 "Intel D945P", STAC_D945GTP3),
1951 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1952 "Intel D945P", STAC_D945GTP5),
1954 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1955 SND_PCI_QUIRK(0x8384, 0x7680,
1956 "Mac", STAC_INTEL_MAC_AUTO),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1959 "unknown Dell", STAC_922X_DELL_D81),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1961 "unknown Dell", STAC_922X_DELL_D81),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1963 "unknown Dell", STAC_922X_DELL_D81),
1964 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1965 "unknown Dell", STAC_922X_DELL_D82),
1966 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1967 "unknown Dell", STAC_922X_DELL_M81),
1968 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1969 "unknown Dell", STAC_922X_DELL_D82),
1970 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1971 "unknown Dell", STAC_922X_DELL_D81),
1972 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1973 "unknown Dell", STAC_922X_DELL_D81),
1974 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1975 "Dell XPS M1210", STAC_922X_DELL_M82),
1976 /* ECS/PC Chips boards */
1977 SND_PCI_QUIRK(0x1019, 0x2144,
1978 "ECS/PC chips", STAC_ECS_202),
1979 SND_PCI_QUIRK(0x1019, 0x2608,
1980 "ECS/PC chips", STAC_ECS_202),
1981 SND_PCI_QUIRK(0x1019, 0x2633,
1982 "ECS/PC chips P17G/1333", STAC_ECS_202),
1983 SND_PCI_QUIRK(0x1019, 0x2811,
1984 "ECS/PC chips", STAC_ECS_202),
1985 SND_PCI_QUIRK(0x1019, 0x2812,
1986 "ECS/PC chips", STAC_ECS_202),
1987 SND_PCI_QUIRK(0x1019, 0x2813,
1988 "ECS/PC chips", STAC_ECS_202),
1989 SND_PCI_QUIRK(0x1019, 0x2814,
1990 "ECS/PC chips", STAC_ECS_202),
1991 SND_PCI_QUIRK(0x1019, 0x2815,
1992 "ECS/PC chips", STAC_ECS_202),
1993 SND_PCI_QUIRK(0x1019, 0x2816,
1994 "ECS/PC chips", STAC_ECS_202),
1995 SND_PCI_QUIRK(0x1019, 0x2817,
1996 "ECS/PC chips", STAC_ECS_202),
1997 SND_PCI_QUIRK(0x1019, 0x2818,
1998 "ECS/PC chips", STAC_ECS_202),
1999 SND_PCI_QUIRK(0x1019, 0x2819,
2000 "ECS/PC chips", STAC_ECS_202),
2001 SND_PCI_QUIRK(0x1019, 0x2820,
2002 "ECS/PC chips", STAC_ECS_202),
2006 static unsigned int ref927x_pin_configs[14] = {
2007 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2008 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2009 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2010 0x01c42190, 0x40000100,
2013 static unsigned int d965_3st_pin_configs[14] = {
2014 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2015 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2016 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2017 0x40000100, 0x40000100
2020 static unsigned int d965_5st_pin_configs[14] = {
2021 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2022 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2023 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2024 0x40000100, 0x40000100
2027 static unsigned int dell_3st_pin_configs[14] = {
2028 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2029 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2030 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2031 0x40c003fc, 0x40000100
2034 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2035 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2036 [STAC_D965_REF] = ref927x_pin_configs,
2037 [STAC_D965_3ST] = d965_3st_pin_configs,
2038 [STAC_D965_5ST] = d965_5st_pin_configs,
2039 [STAC_DELL_3ST] = dell_3st_pin_configs,
2040 [STAC_DELL_BIOS] = NULL,
2043 static const char *stac927x_models[STAC_927X_MODELS] = {
2044 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2045 [STAC_D965_REF] = "ref",
2046 [STAC_D965_3ST] = "3stack",
2047 [STAC_D965_5ST] = "5stack",
2048 [STAC_DELL_3ST] = "dell-3stack",
2049 [STAC_DELL_BIOS] = "dell-bios",
2052 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2053 /* SigmaTel reference board */
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2055 "DFI LanParty", STAC_D965_REF),
2056 /* Intel 946 based systems */
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2059 /* 965 based 3 stack systems */
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2075 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
2076 /* Dell 3 stack systems */
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2081 /* Dell 3 stack systems with verb table in BIOS */
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2087 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2089 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2090 /* 965 based 5 stack systems */
2091 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2093 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2095 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2097 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2098 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2099 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
2103 static unsigned int ref9205_pin_configs[12] = {
2104 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2105 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2106 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2110 STAC 9205 pin configs for
2117 10280228 (Dell Vostro 1500)
2119 static unsigned int dell_9205_m42_pin_configs[12] = {
2120 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2121 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2122 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2126 STAC 9205 pin configs for
2130 102801FF (Dell Precision M4300)
2135 static unsigned int dell_9205_m43_pin_configs[12] = {
2136 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2137 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2138 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2141 static unsigned int dell_9205_m44_pin_configs[12] = {
2142 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2143 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2144 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2147 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2148 [STAC_9205_REF] = ref9205_pin_configs,
2149 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2150 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2151 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2154 static const char *stac9205_models[STAC_9205_MODELS] = {
2155 [STAC_9205_REF] = "ref",
2156 [STAC_9205_DELL_M42] = "dell-m42",
2157 [STAC_9205_DELL_M43] = "dell-m43",
2158 [STAC_9205_DELL_M44] = "dell-m44",
2161 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2162 /* SigmaTel reference board */
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2164 "DFI LanParty", STAC_9205_REF),
2165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2166 "unknown Dell", STAC_9205_DELL_M42),
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2168 "unknown Dell", STAC_9205_DELL_M42),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2170 "Dell Precision", STAC_9205_DELL_M43),
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2172 "Dell Precision", STAC_9205_DELL_M43),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2174 "Dell Precision", STAC_9205_DELL_M43),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2176 "unknown Dell", STAC_9205_DELL_M42),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2178 "unknown Dell", STAC_9205_DELL_M42),
2179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2180 "Dell Precision", STAC_9205_DELL_M43),
2181 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2182 "Dell Precision M4300", STAC_9205_DELL_M43),
2183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2184 "unknown Dell", STAC_9205_DELL_M42),
2185 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2186 "Dell Precision", STAC_9205_DELL_M43),
2187 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2188 "Dell Precision", STAC_9205_DELL_M43),
2189 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2190 "Dell Precision", STAC_9205_DELL_M43),
2191 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2192 "Dell Inspiron", STAC_9205_DELL_M44),
2193 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2194 "Dell Vostro 1500", STAC_9205_DELL_M42),
2198 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2201 struct sigmatel_spec *spec = codec->spec;
2203 if (! spec->bios_pin_configs) {
2204 spec->bios_pin_configs = kcalloc(spec->num_pins,
2205 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2206 if (! spec->bios_pin_configs)
2210 for (i = 0; i < spec->num_pins; i++) {
2211 hda_nid_t nid = spec->pin_nids[i];
2212 unsigned int pin_cfg;
2214 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2215 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2216 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2218 spec->bios_pin_configs[i] = pin_cfg;
2224 static void stac92xx_set_config_reg(struct hda_codec *codec,
2225 hda_nid_t pin_nid, unsigned int pin_config)
2228 snd_hda_codec_write(codec, pin_nid, 0,
2229 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2230 pin_config & 0x000000ff);
2231 snd_hda_codec_write(codec, pin_nid, 0,
2232 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2233 (pin_config & 0x0000ff00) >> 8);
2234 snd_hda_codec_write(codec, pin_nid, 0,
2235 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2236 (pin_config & 0x00ff0000) >> 16);
2237 snd_hda_codec_write(codec, pin_nid, 0,
2238 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2240 i = snd_hda_codec_read(codec, pin_nid, 0,
2241 AC_VERB_GET_CONFIG_DEFAULT,
2243 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2247 static void stac92xx_set_config_regs(struct hda_codec *codec)
2250 struct sigmatel_spec *spec = codec->spec;
2252 if (!spec->pin_configs)
2255 for (i = 0; i < spec->num_pins; i++)
2256 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2257 spec->pin_configs[i]);
2261 * Analog playback callbacks
2263 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2264 struct hda_codec *codec,
2265 struct snd_pcm_substream *substream)
2267 struct sigmatel_spec *spec = codec->spec;
2268 if (spec->stream_delay)
2269 msleep(spec->stream_delay);
2270 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2274 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2275 struct hda_codec *codec,
2276 unsigned int stream_tag,
2277 unsigned int format,
2278 struct snd_pcm_substream *substream)
2280 struct sigmatel_spec *spec = codec->spec;
2281 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2284 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2285 struct hda_codec *codec,
2286 struct snd_pcm_substream *substream)
2288 struct sigmatel_spec *spec = codec->spec;
2289 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2293 * Digital playback callbacks
2295 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2296 struct hda_codec *codec,
2297 struct snd_pcm_substream *substream)
2299 struct sigmatel_spec *spec = codec->spec;
2300 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2303 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2304 struct hda_codec *codec,
2305 struct snd_pcm_substream *substream)
2307 struct sigmatel_spec *spec = codec->spec;
2308 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2311 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2312 struct hda_codec *codec,
2313 unsigned int stream_tag,
2314 unsigned int format,
2315 struct snd_pcm_substream *substream)
2317 struct sigmatel_spec *spec = codec->spec;
2318 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2319 stream_tag, format, substream);
2324 * Analog capture callbacks
2326 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2327 struct hda_codec *codec,
2328 unsigned int stream_tag,
2329 unsigned int format,
2330 struct snd_pcm_substream *substream)
2332 struct sigmatel_spec *spec = codec->spec;
2333 hda_nid_t nid = spec->adc_nids[substream->number];
2335 if (spec->powerdown_adcs) {
2337 snd_hda_codec_write_cache(codec, nid, 0,
2338 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2340 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2344 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2345 struct hda_codec *codec,
2346 struct snd_pcm_substream *substream)
2348 struct sigmatel_spec *spec = codec->spec;
2349 hda_nid_t nid = spec->adc_nids[substream->number];
2351 snd_hda_codec_cleanup_stream(codec, nid);
2352 if (spec->powerdown_adcs)
2353 snd_hda_codec_write_cache(codec, nid, 0,
2354 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2358 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2362 /* NID is set in stac92xx_build_pcms */
2364 .open = stac92xx_dig_playback_pcm_open,
2365 .close = stac92xx_dig_playback_pcm_close,
2366 .prepare = stac92xx_dig_playback_pcm_prepare
2370 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2374 /* NID is set in stac92xx_build_pcms */
2377 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2381 .nid = 0x02, /* NID to query formats and rates */
2383 .open = stac92xx_playback_pcm_open,
2384 .prepare = stac92xx_playback_pcm_prepare,
2385 .cleanup = stac92xx_playback_pcm_cleanup
2389 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2393 .nid = 0x06, /* NID to query formats and rates */
2395 .open = stac92xx_playback_pcm_open,
2396 .prepare = stac92xx_playback_pcm_prepare,
2397 .cleanup = stac92xx_playback_pcm_cleanup
2401 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2404 /* NID + .substreams is set in stac92xx_build_pcms */
2406 .prepare = stac92xx_capture_pcm_prepare,
2407 .cleanup = stac92xx_capture_pcm_cleanup
2411 static int stac92xx_build_pcms(struct hda_codec *codec)
2413 struct sigmatel_spec *spec = codec->spec;
2414 struct hda_pcm *info = spec->pcm_rec;
2416 codec->num_pcms = 1;
2417 codec->pcm_info = info;
2419 info->name = "STAC92xx Analog";
2420 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2421 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2422 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2423 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2425 if (spec->alt_switch) {
2428 info->name = "STAC92xx Analog Alt";
2429 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2432 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2435 info->name = "STAC92xx Digital";
2436 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2437 if (spec->multiout.dig_out_nid) {
2438 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2439 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2441 if (spec->dig_in_nid) {
2442 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2443 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2450 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2452 unsigned int pincap = snd_hda_param_read(codec, nid,
2454 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2455 if (pincap & AC_PINCAP_VREF_100)
2456 return AC_PINCTL_VREF_100;
2457 if (pincap & AC_PINCAP_VREF_80)
2458 return AC_PINCTL_VREF_80;
2459 if (pincap & AC_PINCAP_VREF_50)
2460 return AC_PINCTL_VREF_50;
2461 if (pincap & AC_PINCAP_VREF_GRD)
2462 return AC_PINCTL_VREF_GRD;
2466 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2469 snd_hda_codec_write_cache(codec, nid, 0,
2470 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2473 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2475 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2476 struct snd_ctl_elem_value *ucontrol)
2478 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2479 struct sigmatel_spec *spec = codec->spec;
2481 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2485 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2486 struct snd_ctl_elem_value *ucontrol)
2488 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2489 struct sigmatel_spec *spec = codec->spec;
2490 int nid = kcontrol->private_value;
2492 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2494 /* check to be sure that the ports are upto date with
2497 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2502 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2504 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2506 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2507 struct sigmatel_spec *spec = codec->spec;
2508 int io_idx = kcontrol-> private_value & 0xff;
2510 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2514 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2517 struct sigmatel_spec *spec = codec->spec;
2518 hda_nid_t nid = kcontrol->private_value >> 8;
2519 int io_idx = kcontrol-> private_value & 0xff;
2520 unsigned short val = !!ucontrol->value.integer.value[0];
2522 spec->io_switch[io_idx] = val;
2525 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2527 unsigned int pinctl = AC_PINCTL_IN_EN;
2528 if (io_idx) /* set VREF for mic */
2529 pinctl |= stac92xx_get_vref(codec, nid);
2530 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2533 /* check the auto-mute again: we need to mute/unmute the speaker
2534 * appropriately according to the pin direction
2536 if (spec->hp_detect)
2537 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2542 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2544 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2545 struct snd_ctl_elem_value *ucontrol)
2547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2548 struct sigmatel_spec *spec = codec->spec;
2550 ucontrol->value.integer.value[0] = spec->clfe_swap;
2554 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2555 struct snd_ctl_elem_value *ucontrol)
2557 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2558 struct sigmatel_spec *spec = codec->spec;
2559 hda_nid_t nid = kcontrol->private_value & 0xff;
2560 unsigned int val = !!ucontrol->value.integer.value[0];
2562 if (spec->clfe_swap == val)
2565 spec->clfe_swap = val;
2567 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2568 spec->clfe_swap ? 0x4 : 0x0);
2573 #define STAC_CODEC_HP_SWITCH(xname) \
2574 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2577 .info = stac92xx_hp_switch_info, \
2578 .get = stac92xx_hp_switch_get, \
2579 .put = stac92xx_hp_switch_put, \
2582 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2583 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2586 .info = stac92xx_io_switch_info, \
2587 .get = stac92xx_io_switch_get, \
2588 .put = stac92xx_io_switch_put, \
2589 .private_value = xpval, \
2592 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2593 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2596 .info = stac92xx_clfe_switch_info, \
2597 .get = stac92xx_clfe_switch_get, \
2598 .put = stac92xx_clfe_switch_put, \
2599 .private_value = xpval, \
2603 STAC_CTL_WIDGET_VOL,
2604 STAC_CTL_WIDGET_MUTE,
2605 STAC_CTL_WIDGET_MONO_MUX,
2606 STAC_CTL_WIDGET_AMP_MUX,
2607 STAC_CTL_WIDGET_AMP_VOL,
2608 STAC_CTL_WIDGET_HP_SWITCH,
2609 STAC_CTL_WIDGET_IO_SWITCH,
2610 STAC_CTL_WIDGET_CLFE_SWITCH
2613 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2614 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2615 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2618 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2619 STAC_CODEC_HP_SWITCH(NULL),
2620 STAC_CODEC_IO_SWITCH(NULL, 0),
2621 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2624 /* add dynamic controls */
2625 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2626 struct snd_kcontrol_new *ktemp,
2627 int idx, const char *name,
2630 struct snd_kcontrol_new *knew;
2632 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2633 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2635 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2638 if (spec->kctl_alloc) {
2639 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2640 kfree(spec->kctl_alloc);
2642 spec->kctl_alloc = knew;
2643 spec->num_kctl_alloc = num;
2646 knew = &spec->kctl_alloc[spec->num_kctl_used];
2649 knew->name = kstrdup(name, GFP_KERNEL);
2652 knew->private_value = val;
2653 spec->num_kctl_used++;
2657 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2658 int type, int idx, const char *name,
2661 return stac92xx_add_control_temp(spec,
2662 &stac92xx_control_templates[type],
2667 /* add dynamic controls */
2668 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2669 const char *name, unsigned long val)
2671 return stac92xx_add_control_idx(spec, type, 0, name, val);
2674 /* flag inputs as additional dynamic lineouts */
2675 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2677 struct sigmatel_spec *spec = codec->spec;
2678 unsigned int wcaps, wtype;
2679 int i, num_dacs = 0;
2681 /* use the wcaps cache to count all DACs available for line-outs */
2682 for (i = 0; i < codec->num_nodes; i++) {
2683 wcaps = codec->wcaps[i];
2684 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2686 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2690 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2692 switch (cfg->line_outs) {
2694 /* add line-in as side */
2695 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2696 cfg->line_out_pins[cfg->line_outs] =
2697 cfg->input_pins[AUTO_PIN_LINE];
2698 spec->line_switch = 1;
2703 /* add line-in as clfe and mic as side */
2704 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2705 cfg->line_out_pins[cfg->line_outs] =
2706 cfg->input_pins[AUTO_PIN_LINE];
2707 spec->line_switch = 1;
2710 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2711 cfg->line_out_pins[cfg->line_outs] =
2712 cfg->input_pins[AUTO_PIN_MIC];
2713 spec->mic_switch = 1;
2718 /* add line-in as surr and mic as clfe */
2719 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2720 cfg->line_out_pins[cfg->line_outs] =
2721 cfg->input_pins[AUTO_PIN_LINE];
2722 spec->line_switch = 1;
2725 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2726 cfg->line_out_pins[cfg->line_outs] =
2727 cfg->input_pins[AUTO_PIN_MIC];
2728 spec->mic_switch = 1;
2738 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2742 for (i = 0; i < spec->multiout.num_dacs; i++) {
2743 if (spec->multiout.dac_nids[i] == nid)
2751 * Fill in the dac_nids table from the parsed pin configuration
2752 * This function only works when every pin in line_out_pins[]
2753 * contains atleast one DAC in its connection list. Some 92xx
2754 * codecs are not connected directly to a DAC, such as the 9200
2755 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2757 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2758 struct auto_pin_cfg *cfg)
2760 struct sigmatel_spec *spec = codec->spec;
2761 int i, j, conn_len = 0;
2762 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2763 unsigned int wcaps, wtype;
2765 for (i = 0; i < cfg->line_outs; i++) {
2766 nid = cfg->line_out_pins[i];
2767 conn_len = snd_hda_get_connections(codec, nid, conn,
2768 HDA_MAX_CONNECTIONS);
2769 for (j = 0; j < conn_len; j++) {
2770 wcaps = snd_hda_param_read(codec, conn[j],
2771 AC_PAR_AUDIO_WIDGET_CAP);
2772 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2773 if (wtype != AC_WID_AUD_OUT ||
2774 (wcaps & AC_WCAP_DIGITAL))
2776 /* conn[j] is a DAC routed to this line-out */
2777 if (!is_in_dac_nids(spec, conn[j]))
2781 if (j == conn_len) {
2782 if (spec->multiout.num_dacs > 0) {
2783 /* we have already working output pins,
2784 * so let's drop the broken ones again
2786 cfg->line_outs = spec->multiout.num_dacs;
2789 /* error out, no available DAC found */
2791 "%s: No available DAC for pin 0x%x\n",
2796 spec->multiout.dac_nids[i] = conn[j];
2797 spec->multiout.num_dacs++;
2799 /* select this DAC in the pin's input mux */
2800 snd_hda_codec_write_cache(codec, nid, 0,
2801 AC_VERB_SET_CONNECT_SEL, j);
2806 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2807 spec->multiout.num_dacs,
2808 spec->multiout.dac_nids[0],
2809 spec->multiout.dac_nids[1],
2810 spec->multiout.dac_nids[2],
2811 spec->multiout.dac_nids[3],
2812 spec->multiout.dac_nids[4]);
2816 /* create volume control/switch for the given prefx type */
2817 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2822 sprintf(name, "%s Playback Volume", pfx);
2823 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2824 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2827 sprintf(name, "%s Playback Switch", pfx);
2828 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2829 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2835 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2837 if (!spec->multiout.hp_nid)
2838 spec->multiout.hp_nid = nid;
2839 else if (spec->multiout.num_dacs > 4) {
2840 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2843 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2844 spec->multiout.num_dacs++;
2849 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2851 if (is_in_dac_nids(spec, nid))
2853 if (spec->multiout.hp_nid == nid)
2858 /* add playback controls from the parsed DAC table */
2859 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2860 const struct auto_pin_cfg *cfg)
2862 static const char *chname[4] = {
2863 "Front", "Surround", NULL /*CLFE*/, "Side"
2868 struct sigmatel_spec *spec = codec->spec;
2869 unsigned int wid_caps, pincap;
2872 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2873 if (!spec->multiout.dac_nids[i])
2876 nid = spec->multiout.dac_nids[i];
2880 err = create_controls(spec, "Center", nid, 1);
2883 err = create_controls(spec, "LFE", nid, 2);
2887 wid_caps = get_wcaps(codec, nid);
2889 if (wid_caps & AC_WCAP_LR_SWAP) {
2890 err = stac92xx_add_control(spec,
2891 STAC_CTL_WIDGET_CLFE_SWITCH,
2892 "Swap Center/LFE Playback Switch", nid);
2899 err = create_controls(spec, chname[i], nid, 3);
2905 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2906 cfg->hp_outs == 1 && !spec->multiout.hp_nid)
2907 spec->multiout.hp_nid = nid;
2909 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
2910 err = stac92xx_add_control(spec,
2911 STAC_CTL_WIDGET_HP_SWITCH,
2912 "Headphone as Line Out Switch",
2913 cfg->hp_pins[cfg->hp_outs - 1]);
2918 if (spec->line_switch) {
2919 nid = cfg->input_pins[AUTO_PIN_LINE];
2920 pincap = snd_hda_param_read(codec, nid,
2922 if (pincap & AC_PINCAP_OUT) {
2923 err = stac92xx_add_control(spec,
2924 STAC_CTL_WIDGET_IO_SWITCH,
2925 "Line In as Output Switch", nid << 8);
2931 if (spec->mic_switch) {
2932 unsigned int def_conf;
2933 unsigned int mic_pin = AUTO_PIN_MIC;
2935 nid = cfg->input_pins[mic_pin];
2936 def_conf = snd_hda_codec_read(codec, nid, 0,
2937 AC_VERB_GET_CONFIG_DEFAULT, 0);
2938 /* some laptops have an internal analog microphone
2939 * which can't be used as a output */
2940 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2941 pincap = snd_hda_param_read(codec, nid,
2943 if (pincap & AC_PINCAP_OUT) {
2944 err = stac92xx_add_control(spec,
2945 STAC_CTL_WIDGET_IO_SWITCH,
2946 "Mic as Output Switch", (nid << 8) | 1);
2947 nid = snd_hda_codec_read(codec, nid, 0,
2948 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2949 if (!check_in_dac_nids(spec, nid))
2950 add_spec_dacs(spec, nid);
2954 } else if (mic_pin == AUTO_PIN_MIC) {
2955 mic_pin = AUTO_PIN_FRONT_MIC;
2963 /* add playback controls for Speaker and HP outputs */
2964 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2965 struct auto_pin_cfg *cfg)
2967 struct sigmatel_spec *spec = codec->spec;
2969 int i, old_num_dacs, err;
2971 old_num_dacs = spec->multiout.num_dacs;
2972 for (i = 0; i < cfg->hp_outs; i++) {
2973 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2974 if (wid_caps & AC_WCAP_UNSOL_CAP)
2975 spec->hp_detect = 1;
2976 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2977 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2978 if (check_in_dac_nids(spec, nid))
2982 add_spec_dacs(spec, nid);
2984 for (i = 0; i < cfg->speaker_outs; i++) {
2985 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2986 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2987 if (check_in_dac_nids(spec, nid))
2991 add_spec_dacs(spec, nid);
2993 for (i = 0; i < cfg->line_outs; i++) {
2994 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2995 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2996 if (check_in_dac_nids(spec, nid))
3000 add_spec_dacs(spec, nid);
3002 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
3003 static const char *pfxs[] = {
3004 "Speaker", "External Speaker", "Speaker2",
3006 err = create_controls(spec, pfxs[i - old_num_dacs],
3007 spec->multiout.dac_nids[i], 3);
3011 if (spec->multiout.hp_nid) {
3012 err = create_controls(spec, "Headphone",
3013 spec->multiout.hp_nid, 3);
3021 /* labels for mono mux outputs */
3022 static const char *stac92xx_mono_labels[4] = {
3023 "DAC0", "DAC1", "Mixer", "DAC2"
3026 /* create mono mux for mono out on capable codecs */
3027 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3029 struct sigmatel_spec *spec = codec->spec;
3030 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3032 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3034 num_cons = snd_hda_get_connections(codec,
3037 HDA_MAX_NUM_INPUTS);
3038 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3041 for (i = 0; i < num_cons; i++) {
3042 mono_mux->items[mono_mux->num_items].label =
3043 stac92xx_mono_labels[i];
3044 mono_mux->items[mono_mux->num_items].index = i;
3045 mono_mux->num_items++;
3048 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3049 "Mono Mux", spec->mono_nid);
3052 /* labels for amp mux outputs */
3053 static const char *stac92xx_amp_labels[3] = {
3054 "Front Microphone", "Microphone", "Line In",
3057 /* create amp out controls mux on capable codecs */
3058 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3060 struct sigmatel_spec *spec = codec->spec;
3061 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3064 for (i = 0; i < spec->num_amps; i++) {
3065 amp_mux->items[amp_mux->num_items].label =
3066 stac92xx_amp_labels[i];
3067 amp_mux->items[amp_mux->num_items].index = i;
3068 amp_mux->num_items++;
3071 if (spec->num_amps > 1) {
3072 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3073 "Amp Selector Capture Switch", 0);
3077 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3078 "Amp Capture Volume",
3079 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3083 /* create PC beep volume controls */
3084 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3087 struct sigmatel_spec *spec = codec->spec;
3088 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3091 /* check for mute support for the the amp */
3092 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3093 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3094 "PC Beep Playback Switch",
3095 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3100 /* check to see if there is volume support for the amp */
3101 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3102 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3103 "PC Beep Playback Volume",
3104 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3111 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3112 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3114 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3115 struct snd_ctl_elem_value *ucontrol)
3117 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3118 ucontrol->value.integer.value[0] = codec->beep->enabled;
3122 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3123 struct snd_ctl_elem_value *ucontrol)
3125 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3126 int enabled = !!ucontrol->value.integer.value[0];
3127 if (codec->beep->enabled != enabled) {
3128 codec->beep->enabled = enabled;
3134 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3135 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3136 .info = stac92xx_dig_beep_switch_info,
3137 .get = stac92xx_dig_beep_switch_get,
3138 .put = stac92xx_dig_beep_switch_put,
3141 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3143 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3144 0, "PC Beep Playback Switch", 0);
3148 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3150 struct sigmatel_spec *spec = codec->spec;
3151 int wcaps, nid, i, err = 0;
3153 for (i = 0; i < spec->num_muxes; i++) {
3154 nid = spec->mux_nids[i];
3155 wcaps = get_wcaps(codec, nid);
3157 if (wcaps & AC_WCAP_OUT_AMP) {
3158 err = stac92xx_add_control_idx(spec,
3159 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3160 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3168 static const char *stac92xx_spdif_labels[3] = {
3169 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3172 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3174 struct sigmatel_spec *spec = codec->spec;
3175 struct hda_input_mux *spdif_mux = &spec->private_smux;
3176 const char **labels = spec->spdif_labels;
3178 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3180 num_cons = snd_hda_get_connections(codec,
3183 HDA_MAX_NUM_INPUTS);
3188 labels = stac92xx_spdif_labels;
3190 for (i = 0; i < num_cons; i++) {
3191 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3192 spdif_mux->items[spdif_mux->num_items].index = i;
3193 spdif_mux->num_items++;
3199 /* labels for dmic mux inputs */
3200 static const char *stac92xx_dmic_labels[5] = {
3201 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3202 "Digital Mic 3", "Digital Mic 4"
3205 /* create playback/capture controls for input pins on dmic capable codecs */
3206 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3207 const struct auto_pin_cfg *cfg)
3209 struct sigmatel_spec *spec = codec->spec;
3210 struct hda_input_mux *dimux = &spec->private_dimux;
3211 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3215 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3216 dimux->items[dimux->num_items].index = 0;
3219 for (i = 0; i < spec->num_dmics; i++) {
3224 unsigned int def_conf;
3226 def_conf = snd_hda_codec_read(codec,
3229 AC_VERB_GET_CONFIG_DEFAULT,
3231 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3234 nid = spec->dmic_nids[i];
3235 num_cons = snd_hda_get_connections(codec,
3238 HDA_MAX_NUM_INPUTS);
3239 for (j = 0; j < num_cons; j++)
3240 if (con_lst[j] == nid) {
3246 wcaps = get_wcaps(codec, nid) &
3247 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3250 sprintf(name, "%s Capture Volume",
3251 stac92xx_dmic_labels[dimux->num_items]);
3253 err = stac92xx_add_control(spec,
3254 STAC_CTL_WIDGET_VOL,
3256 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3257 (wcaps & AC_WCAP_OUT_AMP) ?
3258 HDA_OUTPUT : HDA_INPUT));
3263 dimux->items[dimux->num_items].label =
3264 stac92xx_dmic_labels[dimux->num_items];
3265 dimux->items[dimux->num_items].index = index;
3272 /* create playback/capture controls for input pins */
3273 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3275 struct sigmatel_spec *spec = codec->spec;
3276 struct hda_input_mux *imux = &spec->private_imux;
3277 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3280 for (i = 0; i < AUTO_PIN_LAST; i++) {
3283 if (!cfg->input_pins[i])
3286 for (j = 0; j < spec->num_muxes; j++) {
3288 num_cons = snd_hda_get_connections(codec,
3291 HDA_MAX_NUM_INPUTS);
3292 for (k = 0; k < num_cons; k++)
3293 if (con_lst[k] == cfg->input_pins[i]) {
3300 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3301 imux->items[imux->num_items].index = index;
3305 if (imux->num_items) {
3307 * Set the current input for the muxes.
3308 * The STAC9221 has two input muxes with identical source
3309 * NID lists. Hopefully this won't get confused.
3311 for (i = 0; i < spec->num_muxes; i++) {
3312 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3313 AC_VERB_SET_CONNECT_SEL,
3314 imux->items[0].index);
3321 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3323 struct sigmatel_spec *spec = codec->spec;
3326 for (i = 0; i < spec->autocfg.line_outs; i++) {
3327 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3328 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3332 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3334 struct sigmatel_spec *spec = codec->spec;
3337 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3339 pin = spec->autocfg.hp_pins[i];
3340 if (pin) /* connect to front */
3341 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3343 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3345 pin = spec->autocfg.speaker_pins[i];
3346 if (pin) /* connect to front */
3347 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3351 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3353 struct sigmatel_spec *spec = codec->spec;
3355 int hp_speaker_swap = 0;
3357 if ((err = snd_hda_parse_pin_def_config(codec,
3359 spec->dmic_nids)) < 0)
3361 if (! spec->autocfg.line_outs)
3362 return 0; /* can't find valid pin config */
3364 /* If we have no real line-out pin and multiple hp-outs, HPs should
3365 * be set up as multi-channel outputs.
3367 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3368 spec->autocfg.hp_outs > 1) {
3369 /* Copy hp_outs to line_outs, backup line_outs in
3370 * speaker_outs so that the following routines can handle
3371 * HP pins as primary outputs.
3373 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3374 sizeof(spec->autocfg.line_out_pins));
3375 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3376 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3377 sizeof(spec->autocfg.hp_pins));
3378 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3379 hp_speaker_swap = 1;
3381 if (spec->autocfg.mono_out_pin) {
3382 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3383 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3384 u32 caps = query_amp_caps(codec,
3385 spec->autocfg.mono_out_pin, dir);
3386 hda_nid_t conn_list[1];
3388 /* get the mixer node and then the mono mux if it exists */
3389 if (snd_hda_get_connections(codec,
3390 spec->autocfg.mono_out_pin, conn_list, 1) &&
3391 snd_hda_get_connections(codec, conn_list[0],
3394 int wcaps = get_wcaps(codec, conn_list[0]);
3395 int wid_type = (wcaps & AC_WCAP_TYPE)
3396 >> AC_WCAP_TYPE_SHIFT;
3397 /* LR swap check, some stac925x have a mux that
3398 * changes the DACs output path instead of the
3401 if (wid_type == AC_WID_AUD_SEL &&
3402 !(wcaps & AC_WCAP_LR_SWAP))
3403 spec->mono_nid = conn_list[0];
3406 hda_nid_t nid = spec->autocfg.mono_out_pin;
3408 /* most mono outs have a least a mute/unmute switch */
3409 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3410 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3411 "Mono Playback Switch",
3412 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3415 /* check for volume support for the amp */
3416 if ((caps & AC_AMPCAP_NUM_STEPS)
3417 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3418 err = stac92xx_add_control(spec,
3419 STAC_CTL_WIDGET_VOL,
3420 "Mono Playback Volume",
3421 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3427 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3431 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3433 if (spec->multiout.num_dacs == 0)
3434 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3437 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3442 /* setup analog beep controls */
3443 if (spec->anabeep_nid > 0) {
3444 err = stac92xx_auto_create_beep_ctls(codec,
3450 /* setup digital beep controls and input device */
3451 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3452 if (spec->digbeep_nid > 0) {
3453 hda_nid_t nid = spec->digbeep_nid;
3456 err = stac92xx_auto_create_beep_ctls(codec, nid);
3459 err = snd_hda_attach_beep_device(codec, nid);
3462 /* if no beep switch is available, make its own one */
3463 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3465 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3466 err = stac92xx_beep_switch_ctl(codec);
3473 if (hp_speaker_swap == 1) {
3474 /* Restore the hp_outs and line_outs */
3475 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3476 sizeof(spec->autocfg.line_out_pins));
3477 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3478 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3479 sizeof(spec->autocfg.speaker_pins));
3480 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3481 memset(spec->autocfg.speaker_pins, 0,
3482 sizeof(spec->autocfg.speaker_pins));
3483 spec->autocfg.speaker_outs = 0;
3486 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3491 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3496 if (spec->mono_nid > 0) {
3497 err = stac92xx_auto_create_mono_output_ctls(codec);
3501 if (spec->num_amps > 0) {
3502 err = stac92xx_auto_create_amp_output_ctls(codec);
3506 if (spec->num_dmics > 0 && !spec->dinput_mux)
3507 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3508 &spec->autocfg)) < 0)
3510 if (spec->num_muxes > 0) {
3511 err = stac92xx_auto_create_mux_input_ctls(codec);
3515 if (spec->num_smuxes > 0) {
3516 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3521 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3522 if (spec->multiout.max_channels > 2)
3523 spec->surr_switch = 1;
3525 if (spec->autocfg.dig_out_pin)
3526 spec->multiout.dig_out_nid = dig_out;
3527 if (dig_in && spec->autocfg.dig_in_pin)
3528 spec->dig_in_nid = dig_in;
3530 if (spec->kctl_alloc)
3531 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3533 spec->input_mux = &spec->private_imux;
3534 spec->dinput_mux = &spec->private_dimux;
3535 spec->sinput_mux = &spec->private_smux;
3536 spec->mono_mux = &spec->private_mono_mux;
3537 spec->amp_mux = &spec->private_amp_mux;
3541 /* add playback controls for HP output */
3542 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3543 struct auto_pin_cfg *cfg)
3545 struct sigmatel_spec *spec = codec->spec;
3546 hda_nid_t pin = cfg->hp_pins[0];
3547 unsigned int wid_caps;
3552 wid_caps = get_wcaps(codec, pin);
3553 if (wid_caps & AC_WCAP_UNSOL_CAP)
3554 spec->hp_detect = 1;
3559 /* add playback controls for LFE output */
3560 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3561 struct auto_pin_cfg *cfg)
3563 struct sigmatel_spec *spec = codec->spec;
3565 hda_nid_t lfe_pin = 0x0;
3569 * search speaker outs and line outs for a mono speaker pin
3570 * with an amp. If one is found, add LFE controls
3573 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3574 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3575 unsigned int wcaps = get_wcaps(codec, pin);
3576 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3577 if (wcaps == AC_WCAP_OUT_AMP)
3578 /* found a mono speaker with an amp, must be lfe */
3582 /* if speaker_outs is 0, then speakers may be in line_outs */
3583 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3584 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3585 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3586 unsigned int defcfg;
3587 defcfg = snd_hda_codec_read(codec, pin, 0,
3588 AC_VERB_GET_CONFIG_DEFAULT,
3590 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3591 unsigned int wcaps = get_wcaps(codec, pin);
3592 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3593 if (wcaps == AC_WCAP_OUT_AMP)
3594 /* found a mono speaker with an amp,
3602 err = create_controls(spec, "LFE", lfe_pin, 1);
3610 static int stac9200_parse_auto_config(struct hda_codec *codec)
3612 struct sigmatel_spec *spec = codec->spec;
3615 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3618 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3621 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3624 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3627 if (spec->num_muxes > 0) {
3628 err = stac92xx_auto_create_mux_input_ctls(codec);
3633 if (spec->autocfg.dig_out_pin)
3634 spec->multiout.dig_out_nid = 0x05;
3635 if (spec->autocfg.dig_in_pin)
3636 spec->dig_in_nid = 0x04;
3638 if (spec->kctl_alloc)
3639 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3641 spec->input_mux = &spec->private_imux;
3642 spec->dinput_mux = &spec->private_dimux;
3648 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3649 * funky external mute control using GPIO pins.
3652 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3653 unsigned int dir_mask, unsigned int data)
3655 unsigned int gpiostate, gpiomask, gpiodir;
3657 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3658 AC_VERB_GET_GPIO_DATA, 0);
3659 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3661 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3662 AC_VERB_GET_GPIO_MASK, 0);
3665 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3666 AC_VERB_GET_GPIO_DIRECTION, 0);
3667 gpiodir |= dir_mask;
3669 /* Configure GPIOx as CMOS */
3670 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3672 snd_hda_codec_write(codec, codec->afg, 0,
3673 AC_VERB_SET_GPIO_MASK, gpiomask);
3674 snd_hda_codec_read(codec, codec->afg, 0,
3675 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3679 snd_hda_codec_read(codec, codec->afg, 0,
3680 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3683 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3686 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
3687 snd_hda_codec_write_cache(codec, nid, 0,
3688 AC_VERB_SET_UNSOLICITED_ENABLE,
3689 (AC_USRSP_EN | event));
3692 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3695 for (i = 0; i < cfg->hp_outs; i++)
3696 if (cfg->hp_pins[i] == nid)
3697 return 1; /* nid is a HP-Out */
3699 return 0; /* nid is not a HP-Out */
3702 static void stac92xx_power_down(struct hda_codec *codec)
3704 struct sigmatel_spec *spec = codec->spec;
3706 /* power down inactive DACs */
3708 for (dac = spec->dac_list; *dac; dac++)
3709 if (!is_in_dac_nids(spec, *dac) &&
3710 spec->multiout.hp_nid != *dac)
3711 snd_hda_codec_write_cache(codec, *dac, 0,
3712 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3715 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3718 static int stac92xx_init(struct hda_codec *codec)
3720 struct sigmatel_spec *spec = codec->spec;
3721 struct auto_pin_cfg *cfg = &spec->autocfg;
3725 snd_hda_sequence_write(codec, spec->init);
3727 /* power down adcs initially */
3728 if (spec->powerdown_adcs)
3729 for (i = 0; i < spec->num_adcs; i++)
3730 snd_hda_codec_write_cache(codec,
3731 spec->adc_nids[i], 0,
3732 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3735 gpio = spec->gpio_data;
3736 /* turn on EAPD statically when spec->eapd_switch isn't set.
3737 * otherwise, unsol event will turn it on/off dynamically
3739 if (!spec->eapd_switch)
3740 gpio |= spec->eapd_mask;
3741 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3744 if (spec->hp_detect) {
3745 /* Enable unsolicited responses on the HP widget */
3746 for (i = 0; i < cfg->hp_outs; i++)
3747 enable_pin_detect(codec, cfg->hp_pins[i],
3749 /* force to enable the first line-out; the others are set up
3752 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3754 stac92xx_auto_init_hp_out(codec);
3755 /* fake event to set up pins */
3756 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3758 stac92xx_auto_init_multi_out(codec);
3759 stac92xx_auto_init_hp_out(codec);
3761 for (i = 0; i < AUTO_PIN_LAST; i++) {
3762 hda_nid_t nid = cfg->input_pins[i];
3764 unsigned int pinctl;
3765 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3766 /* for mic pins, force to initialize */
3767 pinctl = stac92xx_get_vref(codec, nid);
3769 pinctl = snd_hda_codec_read(codec, nid, 0,
3770 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3771 /* if PINCTL already set then skip */
3772 if (pinctl & AC_PINCTL_IN_EN)
3775 pinctl |= AC_PINCTL_IN_EN;
3776 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3779 for (i = 0; i < spec->num_dmics; i++)
3780 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3782 if (cfg->dig_out_pin)
3783 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3785 if (cfg->dig_in_pin)
3786 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3788 for (i = 0; i < spec->num_pwrs; i++) {
3789 hda_nid_t nid = spec->pwr_nids[i];
3790 int pinctl, def_conf;
3791 int event = STAC_PWR_EVENT;
3793 if (is_nid_hp_pin(cfg, nid) && spec->hp_detect)
3794 continue; /* already has an unsol event */
3796 pinctl = snd_hda_codec_read(codec, nid, 0,
3797 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3798 /* outputs are only ports capable of power management
3799 * any attempts on powering down a input port cause the
3800 * referenced VREF to act quirky.
3802 if (pinctl & AC_PINCTL_IN_EN)
3804 def_conf = snd_hda_codec_read(codec, nid, 0,
3805 AC_VERB_GET_CONFIG_DEFAULT, 0);
3806 def_conf = get_defcfg_connect(def_conf);
3807 /* skip any ports that don't have jacks since presence
3808 * detection is useless */
3809 if (def_conf != AC_JACK_PORT_COMPLEX) {
3810 if (def_conf != AC_JACK_PORT_NONE)
3811 stac_toggle_power_map(codec, nid, 1);
3814 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3815 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3818 stac92xx_power_down(codec);
3822 static void stac92xx_free(struct hda_codec *codec)
3824 struct sigmatel_spec *spec = codec->spec;
3830 if (spec->kctl_alloc) {
3831 for (i = 0; i < spec->num_kctl_used; i++)
3832 kfree(spec->kctl_alloc[i].name);
3833 kfree(spec->kctl_alloc);
3836 if (spec->bios_pin_configs)
3837 kfree(spec->bios_pin_configs);
3840 snd_hda_detach_beep_device(codec);
3843 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3846 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3847 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3849 if (pin_ctl & AC_PINCTL_IN_EN) {
3851 * we need to check the current set-up direction of
3852 * shared input pins since they can be switched via
3853 * "xxx as Output" mixer switch
3855 struct sigmatel_spec *spec = codec->spec;
3856 struct auto_pin_cfg *cfg = &spec->autocfg;
3857 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3858 spec->line_switch) ||
3859 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3864 /* if setting pin direction bits, clear the current
3865 direction bits first */
3866 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3867 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3869 snd_hda_codec_write_cache(codec, nid, 0,
3870 AC_VERB_SET_PIN_WIDGET_CONTROL,
3874 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3877 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3878 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3879 snd_hda_codec_write_cache(codec, nid, 0,
3880 AC_VERB_SET_PIN_WIDGET_CONTROL,
3884 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3888 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3890 unsigned int pinctl;
3891 pinctl = snd_hda_codec_read(codec, nid, 0,
3892 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3893 if (pinctl & AC_PINCTL_IN_EN)
3894 return 0; /* mic- or line-input */
3896 return 1; /* HP-output */
3901 /* return non-zero if the hp-pin of the given array index isn't
3902 * a jack-detection target
3904 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
3906 struct auto_pin_cfg *cfg = &spec->autocfg;
3908 /* ignore sensing of shared line and mic jacks */
3909 if (spec->line_switch &&
3910 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
3912 if (spec->mic_switch &&
3913 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
3915 /* ignore if the pin is set as line-out */
3916 if (cfg->hp_pins[i] == spec->hp_switch)
3921 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3923 struct sigmatel_spec *spec = codec->spec;
3924 struct auto_pin_cfg *cfg = &spec->autocfg;
3928 if (spec->gpio_mute)
3929 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3930 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3932 for (i = 0; i < cfg->hp_outs; i++) {
3935 if (no_hp_sensing(spec, i))
3937 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3941 /* disable lineouts */
3942 if (spec->hp_switch)
3943 stac92xx_reset_pinctl(codec, spec->hp_switch,
3945 for (i = 0; i < cfg->line_outs; i++)
3946 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3948 for (i = 0; i < cfg->speaker_outs; i++)
3949 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3951 if (spec->eapd_mask && spec->eapd_switch)
3952 stac_gpio_set(codec, spec->gpio_mask,
3953 spec->gpio_dir, spec->gpio_data &
3956 /* enable lineouts */
3957 if (spec->hp_switch)
3958 stac92xx_set_pinctl(codec, spec->hp_switch,
3960 for (i = 0; i < cfg->line_outs; i++)
3961 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3963 for (i = 0; i < cfg->speaker_outs; i++)
3964 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3966 if (spec->eapd_mask && spec->eapd_switch)
3967 stac_gpio_set(codec, spec->gpio_mask,
3968 spec->gpio_dir, spec->gpio_data |
3971 /* toggle hp outs */
3972 for (i = 0; i < cfg->hp_outs; i++) {
3973 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
3974 if (no_hp_sensing(spec, i))
3977 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
3979 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
3983 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3986 struct sigmatel_spec *spec = codec->spec;
3987 unsigned int idx, val;
3989 for (idx = 0; idx < spec->num_pwrs; idx++) {
3990 if (spec->pwr_nids[idx] == nid)
3993 if (idx >= spec->num_pwrs)
3996 /* several codecs have two power down bits */
3997 if (spec->pwr_mapping)
3998 idx = spec->pwr_mapping[idx];
4002 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4008 /* power down unused output ports */
4009 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4012 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4014 stac_toggle_power_map(codec, nid, get_hp_pin_presence(codec, nid));
4017 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4019 struct sigmatel_spec *spec = codec->spec;
4020 int idx = res >> 26 & 0x0f;
4022 switch ((res >> 26) & 0x70) {
4024 stac92xx_hp_detect(codec, res);
4026 case STAC_PWR_EVENT:
4027 if (spec->num_pwrs > 0)
4028 stac92xx_pin_sense(codec, idx);
4030 case STAC_VREF_EVENT: {
4031 int data = snd_hda_codec_read(codec, codec->afg, 0,
4032 AC_VERB_GET_GPIO_DATA, 0);
4033 /* toggle VREF state based on GPIOx status */
4034 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4035 !!(data & (1 << idx)));
4041 #ifdef SND_HDA_NEEDS_RESUME
4042 static int stac92xx_resume(struct hda_codec *codec)
4044 struct sigmatel_spec *spec = codec->spec;
4046 stac92xx_set_config_regs(codec);
4047 snd_hda_sequence_write(codec, spec->init);
4048 stac_gpio_set(codec, spec->gpio_mask,
4049 spec->gpio_dir, spec->gpio_data);
4050 snd_hda_codec_resume_amp(codec);
4051 snd_hda_codec_resume_cache(codec);
4052 /* power down inactive DACs */
4054 stac92xx_power_down(codec);
4055 /* invoke unsolicited event to reset the HP state */
4056 if (spec->hp_detect)
4057 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4062 static struct hda_codec_ops stac92xx_patch_ops = {
4063 .build_controls = stac92xx_build_controls,
4064 .build_pcms = stac92xx_build_pcms,
4065 .init = stac92xx_init,
4066 .free = stac92xx_free,
4067 .unsol_event = stac92xx_unsol_event,
4068 #ifdef SND_HDA_NEEDS_RESUME
4069 .resume = stac92xx_resume,
4073 static int patch_stac9200(struct hda_codec *codec)
4075 struct sigmatel_spec *spec;
4078 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4083 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4084 spec->pin_nids = stac9200_pin_nids;
4085 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4088 if (spec->board_config < 0) {
4089 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4090 err = stac92xx_save_bios_config_regs(codec);
4092 stac92xx_free(codec);
4095 spec->pin_configs = spec->bios_pin_configs;
4097 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4098 stac92xx_set_config_regs(codec);
4101 spec->multiout.max_channels = 2;
4102 spec->multiout.num_dacs = 1;
4103 spec->multiout.dac_nids = stac9200_dac_nids;
4104 spec->adc_nids = stac9200_adc_nids;
4105 spec->mux_nids = stac9200_mux_nids;
4106 spec->num_muxes = 1;
4107 spec->num_dmics = 0;
4111 if (spec->board_config == STAC_9200_GATEWAY ||
4112 spec->board_config == STAC_9200_OQO)
4113 spec->init = stac9200_eapd_init;
4115 spec->init = stac9200_core_init;
4116 spec->mixer = stac9200_mixer;
4118 if (spec->board_config == STAC_9200_PANASONIC) {
4119 spec->gpio_mask = spec->gpio_dir = 0x09;
4120 spec->gpio_data = 0x00;
4123 err = stac9200_parse_auto_config(codec);
4125 stac92xx_free(codec);
4129 codec->patch_ops = stac92xx_patch_ops;
4134 static int patch_stac925x(struct hda_codec *codec)
4136 struct sigmatel_spec *spec;
4139 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4144 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4145 spec->pin_nids = stac925x_pin_nids;
4146 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4150 if (spec->board_config < 0) {
4151 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4152 "using BIOS defaults\n");
4153 err = stac92xx_save_bios_config_regs(codec);
4155 stac92xx_free(codec);
4158 spec->pin_configs = spec->bios_pin_configs;
4159 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4160 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4161 stac92xx_set_config_regs(codec);
4164 spec->multiout.max_channels = 2;
4165 spec->multiout.num_dacs = 1;
4166 spec->multiout.dac_nids = stac925x_dac_nids;
4167 spec->adc_nids = stac925x_adc_nids;
4168 spec->mux_nids = stac925x_mux_nids;
4169 spec->num_muxes = 1;
4172 switch (codec->vendor_id) {
4173 case 0x83847632: /* STAC9202 */
4174 case 0x83847633: /* STAC9202D */
4175 case 0x83847636: /* STAC9251 */
4176 case 0x83847637: /* STAC9251D */
4177 spec->num_dmics = STAC925X_NUM_DMICS;
4178 spec->dmic_nids = stac925x_dmic_nids;
4179 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4180 spec->dmux_nids = stac925x_dmux_nids;
4183 spec->num_dmics = 0;
4187 spec->init = stac925x_core_init;
4188 spec->mixer = stac925x_mixer;
4190 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4192 if (spec->board_config < 0) {
4193 printk(KERN_WARNING "hda_codec: No auto-config is "
4194 "available, default to model=ref\n");
4195 spec->board_config = STAC_925x_REF;
4201 stac92xx_free(codec);
4205 codec->patch_ops = stac92xx_patch_ops;
4210 static struct hda_input_mux stac92hd73xx_dmux = {
4213 { "Analog Inputs", 0x0b },
4214 { "Digital Mic 1", 0x09 },
4215 { "Digital Mic 2", 0x0a },
4220 static int patch_stac92hd73xx(struct hda_codec *codec)
4222 struct sigmatel_spec *spec;
4223 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4226 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4231 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4232 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4233 spec->pin_nids = stac92hd73xx_pin_nids;
4234 spec->board_config = snd_hda_check_board_config(codec,
4235 STAC_92HD73XX_MODELS,
4236 stac92hd73xx_models,
4237 stac92hd73xx_cfg_tbl);
4239 if (spec->board_config < 0) {
4240 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4241 " STAC92HD73XX, using BIOS defaults\n");
4242 err = stac92xx_save_bios_config_regs(codec);
4244 stac92xx_free(codec);
4247 spec->pin_configs = spec->bios_pin_configs;
4249 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4250 stac92xx_set_config_regs(codec);
4253 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4254 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4256 if (spec->multiout.num_dacs < 0) {
4257 printk(KERN_WARNING "hda_codec: Could not determine "
4258 "number of channels defaulting to DAC count\n");
4259 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4262 switch (spec->multiout.num_dacs) {
4263 case 0x3: /* 6 Channel */
4264 spec->multiout.hp_nid = 0x17;
4265 spec->mixer = stac92hd73xx_6ch_mixer;
4266 spec->init = stac92hd73xx_6ch_core_init;
4268 case 0x4: /* 8 Channel */
4269 spec->multiout.hp_nid = 0x18;
4270 spec->mixer = stac92hd73xx_8ch_mixer;
4271 spec->init = stac92hd73xx_8ch_core_init;
4273 case 0x5: /* 10 Channel */
4274 spec->multiout.hp_nid = 0x19;
4275 spec->mixer = stac92hd73xx_10ch_mixer;
4276 spec->init = stac92hd73xx_10ch_core_init;
4279 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4280 spec->aloopback_mask = 0x01;
4281 spec->aloopback_shift = 8;
4283 spec->digbeep_nid = 0x1c;
4284 spec->mux_nids = stac92hd73xx_mux_nids;
4285 spec->adc_nids = stac92hd73xx_adc_nids;
4286 spec->dmic_nids = stac92hd73xx_dmic_nids;
4287 spec->dmux_nids = stac92hd73xx_dmux_nids;
4288 spec->smux_nids = stac92hd73xx_smux_nids;
4289 spec->amp_nids = stac92hd73xx_amp_nids;
4290 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4292 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4293 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4294 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4295 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4296 sizeof(stac92hd73xx_dmux));
4298 switch (spec->board_config) {
4300 spec->init = dell_eq_core_init;
4302 case STAC_DELL_M6_AMIC:
4303 case STAC_DELL_M6_DMIC:
4304 case STAC_DELL_M6_BOTH:
4305 spec->num_smuxes = 0;
4306 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4307 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4308 spec->eapd_switch = 0;
4310 spec->multiout.hp_nid = 0; /* dual HPs */
4313 spec->init = dell_m6_core_init;
4314 switch (spec->board_config) {
4315 case STAC_DELL_M6_AMIC: /* Analog Mics */
4316 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4317 spec->num_dmics = 0;
4318 spec->private_dimux.num_items = 1;
4320 case STAC_DELL_M6_DMIC: /* Digital Mics */
4321 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4322 spec->num_dmics = 1;
4323 spec->private_dimux.num_items = 2;
4325 case STAC_DELL_M6_BOTH: /* Both */
4326 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4327 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4328 spec->num_dmics = 1;
4329 spec->private_dimux.num_items = 2;
4334 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4335 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4336 spec->eapd_switch = 1;
4338 if (spec->board_config > STAC_92HD73XX_REF) {
4339 /* GPIO0 High = Enable EAPD */
4340 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4341 spec->gpio_data = 0x01;
4343 spec->dinput_mux = &spec->private_dimux;
4345 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4346 spec->pwr_nids = stac92hd73xx_pwr_nids;
4348 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
4351 if (spec->board_config < 0) {
4352 printk(KERN_WARNING "hda_codec: No auto-config is "
4353 "available, default to model=ref\n");
4354 spec->board_config = STAC_92HD73XX_REF;
4361 stac92xx_free(codec);
4365 if (spec->board_config == STAC_92HD73XX_NO_JD)
4366 spec->hp_detect = 0;
4368 codec->patch_ops = stac92xx_patch_ops;
4373 static struct hda_input_mux stac92hd83xxx_dmux = {
4376 { "Analog Inputs", 0x03 },
4377 { "Digital Mic 1", 0x04 },
4378 { "Digital Mic 2", 0x05 },
4382 static int patch_stac92hd83xxx(struct hda_codec *codec)
4384 struct sigmatel_spec *spec;
4387 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4392 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
4393 spec->mono_nid = 0x19;
4394 spec->digbeep_nid = 0x21;
4395 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4396 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4397 spec->adc_nids = stac92hd83xxx_adc_nids;
4398 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4399 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4400 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4401 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4403 spec->init = stac92hd83xxx_core_init;
4404 switch (codec->vendor_id) {
4406 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4410 spec->init++; /* switch to config #2 */
4411 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4414 spec->mixer = stac92hd83xxx_mixer;
4415 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4416 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4417 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4418 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4419 spec->dinput_mux = &stac92hd83xxx_dmux;
4420 spec->pin_nids = stac92hd83xxx_pin_nids;
4421 spec->board_config = snd_hda_check_board_config(codec,
4422 STAC_92HD83XXX_MODELS,
4423 stac92hd83xxx_models,
4424 stac92hd83xxx_cfg_tbl);
4426 if (spec->board_config < 0) {
4427 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4428 " STAC92HD83XXX, using BIOS defaults\n");
4429 err = stac92xx_save_bios_config_regs(codec);
4431 stac92xx_free(codec);
4434 spec->pin_configs = spec->bios_pin_configs;
4436 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4437 stac92xx_set_config_regs(codec);
4440 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4442 if (spec->board_config < 0) {
4443 printk(KERN_WARNING "hda_codec: No auto-config is "
4444 "available, default to model=ref\n");
4445 spec->board_config = STAC_92HD83XXX_REF;
4452 stac92xx_free(codec);
4456 codec->patch_ops = stac92xx_patch_ops;
4461 #ifdef SND_HDA_NEEDS_RESUME
4462 static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4464 struct sigmatel_spec *spec = codec->spec;
4466 snd_hda_codec_write_cache(codec, codec->afg, 0,
4467 AC_VERB_SET_POWER_STATE, pwr);
4470 for (i = 0; i < spec->num_adcs; i++) {
4471 snd_hda_codec_write_cache(codec,
4472 spec->adc_nids[i], 0,
4473 AC_VERB_SET_POWER_STATE, pwr);
4477 static int stac92hd71xx_resume(struct hda_codec *codec)
4479 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4480 return stac92xx_resume(codec);
4483 static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4485 struct sigmatel_spec *spec = codec->spec;
4487 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4488 if (spec->eapd_mask)
4489 stac_gpio_set(codec, spec->gpio_mask,
4490 spec->gpio_dir, spec->gpio_data &
4497 static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4498 .build_controls = stac92xx_build_controls,
4499 .build_pcms = stac92xx_build_pcms,
4500 .init = stac92xx_init,
4501 .free = stac92xx_free,
4502 .unsol_event = stac92xx_unsol_event,
4503 #ifdef SND_HDA_NEEDS_RESUME
4504 .resume = stac92hd71xx_resume,
4505 .suspend = stac92hd71xx_suspend,
4509 static struct hda_input_mux stac92hd71bxx_dmux = {
4512 { "Analog Inputs", 0x00 },
4514 { "Digital Mic 1", 0x02 },
4515 { "Digital Mic 2", 0x03 },
4519 static int patch_stac92hd71bxx(struct hda_codec *codec)
4521 struct sigmatel_spec *spec;
4524 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4529 codec->patch_ops = stac92xx_patch_ops;
4530 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
4531 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4532 spec->pin_nids = stac92hd71bxx_pin_nids;
4533 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4534 sizeof(stac92hd71bxx_dmux));
4535 spec->board_config = snd_hda_check_board_config(codec,
4536 STAC_92HD71BXX_MODELS,
4537 stac92hd71bxx_models,
4538 stac92hd71bxx_cfg_tbl);
4540 if (spec->board_config < 0) {
4541 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4542 " STAC92HD71BXX, using BIOS defaults\n");
4543 err = stac92xx_save_bios_config_regs(codec);
4545 stac92xx_free(codec);
4548 spec->pin_configs = spec->bios_pin_configs;
4550 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4551 stac92xx_set_config_regs(codec);
4554 if (spec->board_config > STAC_92HD71BXX_REF) {
4556 spec->gpio_mask = 0x01;
4557 spec->gpio_dir = 0x01;
4558 spec->gpio_data = 0x01;
4561 switch (codec->vendor_id) {
4562 case 0x111d76b6: /* 4 Port without Analog Mixer */
4564 case 0x111d76b4: /* 6 Port without Analog Mixer */
4566 spec->mixer = stac92hd71bxx_mixer;
4567 spec->init = stac92hd71bxx_core_init;
4568 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4570 case 0x111d7608: /* 5 Port with Analog Mixer */
4571 switch (spec->board_config) {
4573 /* Enable VREF power saving on GPIO1 detect */
4574 snd_hda_codec_write_cache(codec, codec->afg, 0,
4575 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4576 snd_hda_codec_write_cache(codec, codec->afg, 0,
4577 AC_VERB_SET_UNSOLICITED_ENABLE,
4578 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4579 spec->gpio_mask |= 0x02;
4582 if ((codec->revision_id & 0xf) == 0 ||
4583 (codec->revision_id & 0xf) == 1) {
4584 #ifdef SND_HDA_NEEDS_RESUME
4585 codec->patch_ops = stac92hd71bxx_patch_ops;
4587 spec->stream_delay = 40; /* 40 milliseconds */
4590 /* no output amps */
4592 spec->mixer = stac92hd71bxx_analog_mixer;
4593 spec->dinput_mux = &spec->private_dimux;
4596 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4597 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4599 case 0x111d7603: /* 6 Port with Analog Mixer */
4600 if ((codec->revision_id & 0xf) == 1) {
4601 #ifdef SND_HDA_NEEDS_RESUME
4602 codec->patch_ops = stac92hd71bxx_patch_ops;
4604 spec->stream_delay = 40; /* 40 milliseconds */
4607 /* no output amps */
4611 spec->dinput_mux = &spec->private_dimux;
4612 spec->mixer = stac92hd71bxx_analog_mixer;
4613 spec->init = stac92hd71bxx_analog_core_init;
4614 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4617 spec->aloopback_mask = 0x50;
4618 spec->aloopback_shift = 0;
4620 spec->powerdown_adcs = 1;
4621 spec->digbeep_nid = 0x26;
4622 spec->mux_nids = stac92hd71bxx_mux_nids;
4623 spec->adc_nids = stac92hd71bxx_adc_nids;
4624 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4625 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4626 spec->smux_nids = stac92hd71bxx_smux_nids;
4627 spec->pwr_nids = stac92hd71bxx_pwr_nids;
4629 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4630 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
4632 switch (spec->board_config) {
4634 /* enable internal microphone */
4635 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4636 stac92xx_auto_set_pinctl(codec, 0x0e,
4637 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
4639 case STAC_DELL_M4_2:
4640 spec->num_dmics = 0;
4641 spec->num_smuxes = 0;
4642 spec->num_dmuxes = 0;
4644 case STAC_DELL_M4_1:
4645 case STAC_DELL_M4_3:
4646 spec->num_dmics = 1;
4647 spec->num_smuxes = 0;
4648 spec->num_dmuxes = 0;
4651 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4652 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4653 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4656 spec->multiout.num_dacs = 1;
4657 spec->multiout.hp_nid = 0x11;
4658 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4659 if (spec->dinput_mux)
4660 spec->private_dimux.num_items +=
4662 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
4664 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4666 if (spec->board_config < 0) {
4667 printk(KERN_WARNING "hda_codec: No auto-config is "
4668 "available, default to model=ref\n");
4669 spec->board_config = STAC_92HD71BXX_REF;
4676 stac92xx_free(codec);
4683 static int patch_stac922x(struct hda_codec *codec)
4685 struct sigmatel_spec *spec;
4688 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4693 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
4694 spec->pin_nids = stac922x_pin_nids;
4695 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4698 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
4699 spec->gpio_mask = spec->gpio_dir = 0x03;
4700 spec->gpio_data = 0x03;
4701 /* Intel Macs have all same PCI SSID, so we need to check
4702 * codec SSID to distinguish the exact models
4704 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
4705 switch (codec->subsystem_id) {
4708 spec->board_config = STAC_INTEL_MAC_V1;
4712 spec->board_config = STAC_INTEL_MAC_V2;
4720 spec->board_config = STAC_INTEL_MAC_V3;
4724 spec->board_config = STAC_INTEL_MAC_V4;
4728 spec->board_config = STAC_INTEL_MAC_V5;
4731 spec->board_config = STAC_INTEL_MAC_V3;
4737 if (spec->board_config < 0) {
4738 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4739 "using BIOS defaults\n");
4740 err = stac92xx_save_bios_config_regs(codec);
4742 stac92xx_free(codec);
4745 spec->pin_configs = spec->bios_pin_configs;
4746 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
4747 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4748 stac92xx_set_config_regs(codec);
4751 spec->adc_nids = stac922x_adc_nids;
4752 spec->mux_nids = stac922x_mux_nids;
4753 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
4754 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
4755 spec->num_dmics = 0;
4758 spec->init = stac922x_core_init;
4759 spec->mixer = stac922x_mixer;
4761 spec->multiout.dac_nids = spec->dac_nids;
4763 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
4765 if (spec->board_config < 0) {
4766 printk(KERN_WARNING "hda_codec: No auto-config is "
4767 "available, default to model=ref\n");
4768 spec->board_config = STAC_D945_REF;
4774 stac92xx_free(codec);
4778 codec->patch_ops = stac92xx_patch_ops;
4780 /* Fix Mux capture level; max to 2 */
4781 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4782 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4783 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4784 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4785 (0 << AC_AMPCAP_MUTE_SHIFT));
4790 static int patch_stac927x(struct hda_codec *codec)
4792 struct sigmatel_spec *spec;
4795 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4800 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
4801 spec->pin_nids = stac927x_pin_nids;
4802 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4806 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4807 if (spec->board_config < 0)
4808 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4809 "STAC927x, using BIOS defaults\n");
4810 err = stac92xx_save_bios_config_regs(codec);
4812 stac92xx_free(codec);
4815 spec->pin_configs = spec->bios_pin_configs;
4817 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4818 stac92xx_set_config_regs(codec);
4821 spec->digbeep_nid = 0x23;
4822 spec->adc_nids = stac927x_adc_nids;
4823 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4824 spec->mux_nids = stac927x_mux_nids;
4825 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
4826 spec->smux_nids = stac927x_smux_nids;
4827 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
4828 spec->spdif_labels = stac927x_spdif_labels;
4829 spec->dac_list = stac927x_dac_nids;
4830 spec->multiout.dac_nids = spec->dac_nids;
4832 switch (spec->board_config) {
4835 /* GPIO0 High = Enable EAPD */
4836 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
4837 spec->gpio_data = 0x01;
4838 spec->num_dmics = 0;
4840 spec->init = d965_core_init;
4841 spec->mixer = stac927x_mixer;
4843 case STAC_DELL_BIOS:
4844 switch (codec->subsystem_id) {
4847 /* correct the device field to SPDIF out */
4848 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4851 /* configure the analog microphone on some laptops */
4852 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
4853 /* correct the front output jack as a hp out */
4854 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
4855 /* correct the front input jack as a mic */
4856 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4859 /* GPIO2 High = Enable EAPD */
4860 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
4861 spec->gpio_data = 0x04;
4862 spec->dmic_nids = stac927x_dmic_nids;
4863 spec->num_dmics = STAC927X_NUM_DMICS;
4865 spec->init = d965_core_init;
4866 spec->mixer = stac927x_mixer;
4867 spec->dmux_nids = stac927x_dmux_nids;
4868 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
4871 if (spec->board_config > STAC_D965_REF) {
4872 /* GPIO0 High = Enable EAPD */
4873 spec->eapd_mask = spec->gpio_mask = 0x01;
4874 spec->gpio_dir = spec->gpio_data = 0x01;
4876 spec->num_dmics = 0;
4878 spec->init = stac927x_core_init;
4879 spec->mixer = stac927x_mixer;
4883 spec->aloopback_mask = 0x40;
4884 spec->aloopback_shift = 0;
4885 spec->eapd_switch = 1;
4887 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
4889 if (spec->board_config < 0) {
4890 printk(KERN_WARNING "hda_codec: No auto-config is "
4891 "available, default to model=ref\n");
4892 spec->board_config = STAC_D965_REF;
4898 stac92xx_free(codec);
4902 codec->patch_ops = stac92xx_patch_ops;
4906 * The STAC927x seem to require fairly long delays for certain
4907 * command sequences. With too short delays (even if the answer
4908 * is set to RIRB properly), it results in the silence output
4909 * on some hardwares like Dell.
4911 * The below flag enables the longer delay (see get_response
4914 codec->bus->needs_damn_long_delay = 1;
4916 /* no jack detecion for ref-no-jd model */
4917 if (spec->board_config == STAC_D965_REF_NO_JD)
4918 spec->hp_detect = 0;
4923 static int patch_stac9205(struct hda_codec *codec)
4925 struct sigmatel_spec *spec;
4928 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4933 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
4934 spec->pin_nids = stac9205_pin_nids;
4935 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4939 if (spec->board_config < 0) {
4940 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4941 err = stac92xx_save_bios_config_regs(codec);
4943 stac92xx_free(codec);
4946 spec->pin_configs = spec->bios_pin_configs;
4948 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4949 stac92xx_set_config_regs(codec);
4952 spec->digbeep_nid = 0x23;
4953 spec->adc_nids = stac9205_adc_nids;
4954 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
4955 spec->mux_nids = stac9205_mux_nids;
4956 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
4957 spec->smux_nids = stac9205_smux_nids;
4958 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
4959 spec->dmic_nids = stac9205_dmic_nids;
4960 spec->num_dmics = STAC9205_NUM_DMICS;
4961 spec->dmux_nids = stac9205_dmux_nids;
4962 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
4965 spec->init = stac9205_core_init;
4966 spec->mixer = stac9205_mixer;
4968 spec->aloopback_mask = 0x40;
4969 spec->aloopback_shift = 0;
4970 spec->eapd_switch = 1;
4971 spec->multiout.dac_nids = spec->dac_nids;
4973 switch (spec->board_config){
4974 case STAC_9205_DELL_M43:
4975 /* Enable SPDIF in/out */
4976 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4977 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
4979 /* Enable unsol response for GPIO4/Dock HP connection */
4980 snd_hda_codec_write_cache(codec, codec->afg, 0,
4981 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4982 snd_hda_codec_write_cache(codec, codec->afg, 0,
4983 AC_VERB_SET_UNSOLICITED_ENABLE,
4984 (AC_USRSP_EN | STAC_HP_EVENT));
4986 spec->gpio_dir = 0x0b;
4987 spec->eapd_mask = 0x01;
4988 spec->gpio_mask = 0x1b;
4989 spec->gpio_mute = 0x10;
4990 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
4993 spec->gpio_data = 0x01;
4996 /* SPDIF-In enabled */
4999 /* GPIO0 High = EAPD */
5000 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5001 spec->gpio_data = 0x01;
5005 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5007 if (spec->board_config < 0) {
5008 printk(KERN_WARNING "hda_codec: No auto-config is "
5009 "available, default to model=ref\n");
5010 spec->board_config = STAC_9205_REF;
5016 stac92xx_free(codec);
5020 codec->patch_ops = stac92xx_patch_ops;
5029 /* static config for Sony VAIO FE550G and Sony VAIO AR */
5030 static hda_nid_t vaio_dacs[] = { 0x2 };
5031 #define VAIO_HP_DAC 0x5
5032 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5033 static hda_nid_t vaio_mux_nids[] = { 0x15 };
5035 static struct hda_input_mux vaio_mux = {
5038 /* { "HP", 0x0 }, */
5039 { "Mic Jack", 0x1 },
5040 { "Internal Mic", 0x2 },
5045 static struct hda_verb vaio_init[] = {
5046 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5047 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
5048 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5049 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5050 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5051 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5052 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5053 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5054 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5055 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5057 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5061 static struct hda_verb vaio_ar_init[] = {
5062 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5063 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5064 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5065 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5066 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5067 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5068 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5069 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5070 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5071 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5073 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5078 /* bind volumes of both NID 0x02 and 0x05 */
5079 static struct hda_bind_ctls vaio_bind_master_vol = {
5080 .ops = &snd_hda_bind_vol,
5082 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5083 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5088 /* bind volumes of both NID 0x02 and 0x05 */
5089 static struct hda_bind_ctls vaio_bind_master_sw = {
5090 .ops = &snd_hda_bind_sw,
5092 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5093 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5098 static struct snd_kcontrol_new vaio_mixer[] = {
5099 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5100 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
5101 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5102 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5103 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5105 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5106 .name = "Capture Source",
5108 .info = stac92xx_mux_enum_info,
5109 .get = stac92xx_mux_enum_get,
5110 .put = stac92xx_mux_enum_put,
5115 static struct snd_kcontrol_new vaio_ar_mixer[] = {
5116 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5117 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
5118 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5119 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5120 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5121 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5122 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5125 .name = "Capture Source",
5127 .info = stac92xx_mux_enum_info,
5128 .get = stac92xx_mux_enum_get,
5129 .put = stac92xx_mux_enum_put,
5134 static struct hda_codec_ops stac9872_patch_ops = {
5135 .build_controls = stac92xx_build_controls,
5136 .build_pcms = stac92xx_build_pcms,
5137 .init = stac92xx_init,
5138 .free = stac92xx_free,
5139 #ifdef SND_HDA_NEEDS_RESUME
5140 .resume = stac92xx_resume,
5144 static int stac9872_vaio_init(struct hda_codec *codec)
5148 err = stac92xx_init(codec);
5151 if (codec->patch_ops.unsol_event)
5152 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5156 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5158 if (get_hp_pin_presence(codec, 0x0a)) {
5159 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5160 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5162 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5163 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5167 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5169 switch (res >> 26) {
5171 stac9872_vaio_hp_detect(codec, res);
5176 static struct hda_codec_ops stac9872_vaio_patch_ops = {
5177 .build_controls = stac92xx_build_controls,
5178 .build_pcms = stac92xx_build_pcms,
5179 .init = stac9872_vaio_init,
5180 .free = stac92xx_free,
5181 .unsol_event = stac9872_vaio_unsol_event,
5183 .resume = stac92xx_resume,
5187 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5189 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5191 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5193 /* AR Series. id=0x83847664 and subsys=104D1300 */
5198 static const char *stac9872_models[STAC_9872_MODELS] = {
5199 [CXD9872RD_VAIO] = "vaio",
5200 [CXD9872AKD_VAIO] = "vaio-ar",
5203 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5204 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5205 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5206 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
5207 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
5211 static int patch_stac9872(struct hda_codec *codec)
5213 struct sigmatel_spec *spec;
5216 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5219 if (board_config < 0)
5220 /* unknown config, let generic-parser do its job... */
5221 return snd_hda_parse_generic_codec(codec);
5223 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5228 switch (board_config) {
5229 case CXD9872RD_VAIO:
5230 case STAC9872AK_VAIO:
5231 case STAC9872K_VAIO:
5232 spec->mixer = vaio_mixer;
5233 spec->init = vaio_init;
5234 spec->multiout.max_channels = 2;
5235 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5236 spec->multiout.dac_nids = vaio_dacs;
5237 spec->multiout.hp_nid = VAIO_HP_DAC;
5238 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5239 spec->adc_nids = vaio_adcs;
5241 spec->input_mux = &vaio_mux;
5242 spec->mux_nids = vaio_mux_nids;
5243 codec->patch_ops = stac9872_vaio_patch_ops;
5246 case CXD9872AKD_VAIO:
5247 spec->mixer = vaio_ar_mixer;
5248 spec->init = vaio_ar_init;
5249 spec->multiout.max_channels = 2;
5250 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5251 spec->multiout.dac_nids = vaio_dacs;
5252 spec->multiout.hp_nid = VAIO_HP_DAC;
5253 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5255 spec->adc_nids = vaio_adcs;
5256 spec->input_mux = &vaio_mux;
5257 spec->mux_nids = vaio_mux_nids;
5258 codec->patch_ops = stac9872_patch_ops;
5269 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5270 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5271 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5272 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5273 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5274 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5275 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5276 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5277 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5278 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5279 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5280 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5281 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5282 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5283 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5284 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5285 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5286 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5287 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5288 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5289 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5290 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5291 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5292 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5293 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5294 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5295 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5296 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5297 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5298 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5299 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5300 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5301 /* The following does not take into account .id=0x83847661 when subsys =
5302 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5303 * currently not fully supported.
5305 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5306 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5307 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5308 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5309 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5310 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5311 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5312 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5313 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5314 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5315 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5316 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5317 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5318 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5319 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5320 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5321 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5322 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5323 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5324 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5325 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5326 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5327 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5328 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5329 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5330 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },