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},
865 static struct hda_verb stac92hd71bxx_core_init[] = {
866 /* set master volume and direct control */
867 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
868 /* connect headphone jack to dac1 */
869 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
870 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
871 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
872 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
873 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
877 #define HD_DISABLE_PORTF 2
878 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
879 /* start of config #1 */
881 /* connect port 0f to audio mixer */
882 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
883 /* unmute right and left channels for node 0x0f */
884 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
885 /* start of config #2 */
887 /* set master volume and direct control */
888 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
889 /* connect headphone jack to dac1 */
890 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
891 /* unmute right and left channels for nodes 0x0a, 0xd */
892 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
893 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
897 static struct hda_verb stac925x_core_init[] = {
898 /* set dac0mux for dac converter */
899 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
903 static struct hda_verb stac922x_core_init[] = {
904 /* set master volume and direct control */
905 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
909 static struct hda_verb d965_core_init[] = {
910 /* set master volume and direct control */
911 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
912 /* unmute node 0x1b */
913 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
914 /* select node 0x03 as DAC */
915 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
919 static struct hda_verb stac927x_core_init[] = {
920 /* set master volume and direct control */
921 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
922 /* enable analog pc beep path */
923 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
927 static struct hda_verb stac9205_core_init[] = {
928 /* set master volume and direct control */
929 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
930 /* enable analog pc beep path */
931 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
935 #define STAC_MONO_MUX \
937 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
938 .name = "Mono Mux", \
940 .info = stac92xx_mono_mux_enum_info, \
941 .get = stac92xx_mono_mux_enum_get, \
942 .put = stac92xx_mono_mux_enum_put, \
945 #define STAC_AMP_MUX \
947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
948 .name = "Amp Selector Capture Switch", \
950 .info = stac92xx_amp_mux_enum_info, \
951 .get = stac92xx_amp_mux_enum_get, \
952 .put = stac92xx_amp_mux_enum_put, \
955 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
960 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
961 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
962 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
963 .info = stac92xx_amp_volume_info, \
964 .get = stac92xx_amp_volume_get, \
965 .put = stac92xx_amp_volume_put, \
966 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
967 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
970 #define STAC_INPUT_SOURCE(cnt) \
972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
973 .name = "Input Source", \
975 .info = stac92xx_mux_enum_info, \
976 .get = stac92xx_mux_enum_get, \
977 .put = stac92xx_mux_enum_put, \
980 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
982 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
983 .name = "Analog Loopback", \
985 .info = stac92xx_aloopback_info, \
986 .get = stac92xx_aloopback_get, \
987 .put = stac92xx_aloopback_put, \
988 .private_value = verb_read | (verb_write << 16), \
991 static struct snd_kcontrol_new stac9200_mixer[] = {
992 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
993 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
994 STAC_INPUT_SOURCE(1),
995 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
996 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1000 #define DELL_M6_MIXER 6
1001 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1002 /* start of config #1 */
1003 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1004 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1006 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1007 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1009 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1010 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1012 /* start of config #2 */
1013 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1014 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1016 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1017 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1019 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1021 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1022 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1024 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1025 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1030 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1031 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1033 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1034 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1036 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1037 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1039 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1040 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1042 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1043 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1045 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1046 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1048 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1049 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1051 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1052 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1056 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1057 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1059 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1060 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1062 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1063 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1065 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1066 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1068 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1069 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1071 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1072 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1074 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1075 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1077 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1078 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1083 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1084 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1085 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1087 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1088 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1090 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1091 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1093 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1094 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1096 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1097 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1099 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1100 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1103 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1104 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1109 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1110 STAC_INPUT_SOURCE(2),
1111 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1113 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1114 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1116 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1117 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1118 /* analog pc-beep replaced with digital beep support */
1120 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1121 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1124 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1125 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1127 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1128 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1130 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1131 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1133 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1134 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1138 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1139 STAC_INPUT_SOURCE(2),
1140 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1142 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1143 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1145 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1146 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1150 static struct snd_kcontrol_new stac925x_mixer[] = {
1151 STAC_INPUT_SOURCE(1),
1152 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1153 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1157 static struct snd_kcontrol_new stac9205_mixer[] = {
1158 STAC_INPUT_SOURCE(2),
1159 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1161 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1162 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1164 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1165 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1169 /* This needs to be generated dynamically based on sequence */
1170 static struct snd_kcontrol_new stac922x_mixer[] = {
1171 STAC_INPUT_SOURCE(2),
1172 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1173 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1175 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1176 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1181 static struct snd_kcontrol_new stac927x_mixer[] = {
1182 STAC_INPUT_SOURCE(3),
1183 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1185 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1186 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1188 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1189 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1191 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1192 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1196 static struct snd_kcontrol_new stac_dmux_mixer = {
1197 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1198 .name = "Digital Input Source",
1199 /* count set later */
1200 .info = stac92xx_dmux_enum_info,
1201 .get = stac92xx_dmux_enum_get,
1202 .put = stac92xx_dmux_enum_put,
1205 static struct snd_kcontrol_new stac_smux_mixer = {
1206 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1207 .name = "IEC958 Playback Source",
1208 /* count set later */
1209 .info = stac92xx_smux_enum_info,
1210 .get = stac92xx_smux_enum_get,
1211 .put = stac92xx_smux_enum_put,
1214 static const char *slave_vols[] = {
1215 "Front Playback Volume",
1216 "Surround Playback Volume",
1217 "Center Playback Volume",
1218 "LFE Playback Volume",
1219 "Side Playback Volume",
1220 "Headphone Playback Volume",
1221 "Headphone Playback Volume",
1222 "Speaker Playback Volume",
1223 "External Speaker Playback Volume",
1224 "Speaker2 Playback Volume",
1228 static const char *slave_sws[] = {
1229 "Front Playback Switch",
1230 "Surround Playback Switch",
1231 "Center Playback Switch",
1232 "LFE Playback Switch",
1233 "Side Playback Switch",
1234 "Headphone Playback Switch",
1235 "Headphone Playback Switch",
1236 "Speaker Playback Switch",
1237 "External Speaker Playback Switch",
1238 "Speaker2 Playback Switch",
1239 "IEC958 Playback Switch",
1243 static int stac92xx_build_controls(struct hda_codec *codec)
1245 struct sigmatel_spec *spec = codec->spec;
1249 err = snd_hda_add_new_ctls(codec, spec->mixer);
1253 for (i = 0; i < spec->num_mixers; i++) {
1254 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1258 if (spec->num_dmuxes > 0) {
1259 stac_dmux_mixer.count = spec->num_dmuxes;
1260 err = snd_ctl_add(codec->bus->card,
1261 snd_ctl_new1(&stac_dmux_mixer, codec));
1265 if (spec->num_smuxes > 0) {
1266 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1267 struct hda_input_mux *smux = &spec->private_smux;
1268 /* check for mute support on SPDIF out */
1269 if (wcaps & AC_WCAP_OUT_AMP) {
1270 smux->items[smux->num_items].label = "Off";
1271 smux->items[smux->num_items].index = 0;
1273 spec->spdif_mute = 1;
1275 stac_smux_mixer.count = spec->num_smuxes;
1276 err = snd_ctl_add(codec->bus->card,
1277 snd_ctl_new1(&stac_smux_mixer, codec));
1282 if (spec->multiout.dig_out_nid) {
1283 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1286 err = snd_hda_create_spdif_share_sw(codec,
1290 spec->multiout.share_spdif = 1;
1292 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1293 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1298 /* if we have no master control, let's create it */
1299 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1300 unsigned int vmaster_tlv[4];
1301 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1302 HDA_OUTPUT, vmaster_tlv);
1303 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1304 vmaster_tlv, slave_vols);
1308 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1309 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1318 static unsigned int ref9200_pin_configs[8] = {
1319 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1320 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1324 STAC 9200 pin configs for
1329 static unsigned int dell9200_d21_pin_configs[8] = {
1330 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1331 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1335 STAC 9200 pin configs for
1339 static unsigned int dell9200_d22_pin_configs[8] = {
1340 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1341 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1345 STAC 9200 pin configs for
1346 102801C4 (Dell Dimension E310)
1353 static unsigned int dell9200_d23_pin_configs[8] = {
1354 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1355 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1360 STAC 9200-32 pin configs for
1361 102801B5 (Dell Inspiron 630m)
1362 102801D8 (Dell Inspiron 640m)
1364 static unsigned int dell9200_m21_pin_configs[8] = {
1365 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1366 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1370 STAC 9200-32 pin configs for
1371 102801C2 (Dell Latitude D620)
1373 102801CC (Dell Latitude D820)
1377 static unsigned int dell9200_m22_pin_configs[8] = {
1378 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1379 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1383 STAC 9200-32 pin configs for
1384 102801CE (Dell XPS M1710)
1385 102801CF (Dell Precision M90)
1387 static unsigned int dell9200_m23_pin_configs[8] = {
1388 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1389 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1393 STAC 9200-32 pin configs for
1396 102801CB (Dell Latitude 120L)
1399 static unsigned int dell9200_m24_pin_configs[8] = {
1400 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1401 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1405 STAC 9200-32 pin configs for
1406 102801BD (Dell Inspiron E1505n)
1410 static unsigned int dell9200_m25_pin_configs[8] = {
1411 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1412 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1416 STAC 9200-32 pin configs for
1417 102801F5 (Dell Inspiron 1501)
1420 static unsigned int dell9200_m26_pin_configs[8] = {
1421 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1422 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1427 102801CD (Dell Inspiron E1705/9400)
1429 static unsigned int dell9200_m27_pin_configs[8] = {
1430 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1431 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1434 static unsigned int oqo9200_pin_configs[8] = {
1435 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1436 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1440 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1441 [STAC_REF] = ref9200_pin_configs,
1442 [STAC_9200_OQO] = oqo9200_pin_configs,
1443 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1444 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1445 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1446 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1447 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1448 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1449 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1450 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1451 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1452 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1453 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1456 static const char *stac9200_models[STAC_9200_MODELS] = {
1458 [STAC_9200_OQO] = "oqo",
1459 [STAC_9200_DELL_D21] = "dell-d21",
1460 [STAC_9200_DELL_D22] = "dell-d22",
1461 [STAC_9200_DELL_D23] = "dell-d23",
1462 [STAC_9200_DELL_M21] = "dell-m21",
1463 [STAC_9200_DELL_M22] = "dell-m22",
1464 [STAC_9200_DELL_M23] = "dell-m23",
1465 [STAC_9200_DELL_M24] = "dell-m24",
1466 [STAC_9200_DELL_M25] = "dell-m25",
1467 [STAC_9200_DELL_M26] = "dell-m26",
1468 [STAC_9200_DELL_M27] = "dell-m27",
1469 [STAC_9200_GATEWAY] = "gateway",
1470 [STAC_9200_PANASONIC] = "panasonic",
1473 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1474 /* SigmaTel reference board */
1475 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1476 "DFI LanParty", STAC_REF),
1477 /* Dell laptops have BIOS problem */
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1479 "unknown Dell", STAC_9200_DELL_D21),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1481 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1483 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1485 "unknown Dell", STAC_9200_DELL_D22),
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1487 "unknown Dell", STAC_9200_DELL_D22),
1488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1489 "Dell Latitude D620", STAC_9200_DELL_M22),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1491 "unknown Dell", STAC_9200_DELL_D23),
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1493 "unknown Dell", STAC_9200_DELL_D23),
1494 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1495 "unknown Dell", STAC_9200_DELL_M22),
1496 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1497 "unknown Dell", STAC_9200_DELL_M24),
1498 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1499 "unknown Dell", STAC_9200_DELL_M24),
1500 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1501 "Dell Latitude 120L", STAC_9200_DELL_M24),
1502 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1503 "Dell Latitude D820", STAC_9200_DELL_M22),
1504 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1505 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1507 "Dell XPS M1710", STAC_9200_DELL_M23),
1508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1509 "Dell Precision M90", STAC_9200_DELL_M23),
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1511 "unknown Dell", STAC_9200_DELL_M22),
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1513 "unknown Dell", STAC_9200_DELL_M22),
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1515 "unknown Dell", STAC_9200_DELL_M22),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1517 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1519 "unknown Dell", STAC_9200_DELL_D23),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1521 "unknown Dell", STAC_9200_DELL_D23),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1523 "unknown Dell", STAC_9200_DELL_D21),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1525 "unknown Dell", STAC_9200_DELL_D23),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1527 "unknown Dell", STAC_9200_DELL_D21),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1529 "unknown Dell", STAC_9200_DELL_M25),
1530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1531 "unknown Dell", STAC_9200_DELL_M25),
1532 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1533 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1534 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1535 "unknown Dell", STAC_9200_DELL_M26),
1537 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1538 /* Gateway machines needs EAPD to be set on resume */
1539 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1540 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1542 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1545 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1549 static unsigned int ref925x_pin_configs[8] = {
1550 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1551 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1554 static unsigned int stac925x_MA6_pin_configs[8] = {
1555 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1556 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1559 static unsigned int stac925x_PA6_pin_configs[8] = {
1560 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1561 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1564 static unsigned int stac925xM2_2_pin_configs[8] = {
1565 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1566 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1569 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1570 [STAC_REF] = ref925x_pin_configs,
1571 [STAC_M2_2] = stac925xM2_2_pin_configs,
1572 [STAC_MA6] = stac925x_MA6_pin_configs,
1573 [STAC_PA6] = stac925x_PA6_pin_configs,
1576 static const char *stac925x_models[STAC_925x_MODELS] = {
1578 [STAC_M2_2] = "m2-2",
1583 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1584 /* SigmaTel reference board */
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1586 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1587 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1588 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1589 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1590 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1591 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1595 static unsigned int ref92hd73xx_pin_configs[13] = {
1596 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1597 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1598 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1602 static unsigned int dell_m6_pin_configs[13] = {
1603 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1604 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1605 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1609 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1610 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1611 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1612 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1613 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1614 [STAC_DELL_EQ] = dell_m6_pin_configs,
1617 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1618 [STAC_92HD73XX_NO_JD] = "no-jd",
1619 [STAC_92HD73XX_REF] = "ref",
1620 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1621 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1622 [STAC_DELL_M6_BOTH] = "dell-m6",
1623 [STAC_DELL_EQ] = "dell-eq",
1626 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1627 /* SigmaTel reference board */
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1629 "DFI LanParty", STAC_92HD73XX_REF),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1631 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1633 "unknown Dell", STAC_DELL_M6_DMIC),
1634 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1635 "unknown Dell", STAC_DELL_M6_BOTH),
1636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1637 "unknown Dell", STAC_DELL_M6_BOTH),
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1639 "unknown Dell", STAC_DELL_M6_AMIC),
1640 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1641 "unknown Dell", STAC_DELL_M6_AMIC),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1643 "unknown Dell", STAC_DELL_M6_DMIC),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1645 "unknown Dell", STAC_DELL_M6_DMIC),
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1647 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1648 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1649 "Dell Studio 17", STAC_DELL_M6_DMIC),
1653 static unsigned int ref92hd83xxx_pin_configs[14] = {
1654 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1655 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1656 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1657 0x01451160, 0x98560170,
1660 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1661 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1664 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1665 [STAC_92HD83XXX_REF] = "ref",
1668 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1669 /* SigmaTel reference board */
1670 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1671 "DFI LanParty", STAC_92HD71BXX_REF),
1675 static unsigned int ref92hd71bxx_pin_configs[11] = {
1676 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1677 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1678 0x90a000f0, 0x01452050, 0x01452050,
1681 static unsigned int dell_m4_1_pin_configs[11] = {
1682 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1683 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1684 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
1687 static unsigned int dell_m4_2_pin_configs[11] = {
1688 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1689 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1690 0x40f000f0, 0x044413b0, 0x044413b0,
1693 static unsigned int dell_m4_3_pin_configs[11] = {
1694 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1695 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1696 0x40f000f0, 0x044413b0, 0x044413b0,
1699 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1700 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1701 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1702 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1703 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1704 [STAC_HP_M4] = NULL,
1707 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1708 [STAC_92HD71BXX_REF] = "ref",
1709 [STAC_DELL_M4_1] = "dell-m4-1",
1710 [STAC_DELL_M4_2] = "dell-m4-2",
1711 [STAC_DELL_M4_3] = "dell-m4-3",
1712 [STAC_HP_M4] = "hp-m4",
1715 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1716 /* SigmaTel reference board */
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1718 "DFI LanParty", STAC_92HD71BXX_REF),
1719 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1720 "HP dv5", STAC_HP_M4),
1721 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1722 "HP dv7", STAC_HP_M4),
1723 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1724 "unknown HP", STAC_HP_M4),
1725 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1726 "unknown Dell", STAC_DELL_M4_1),
1727 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1728 "unknown Dell", STAC_DELL_M4_1),
1729 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1730 "unknown Dell", STAC_DELL_M4_1),
1731 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1732 "unknown Dell", STAC_DELL_M4_1),
1733 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1734 "unknown Dell", STAC_DELL_M4_1),
1735 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1736 "unknown Dell", STAC_DELL_M4_1),
1737 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1738 "unknown Dell", STAC_DELL_M4_1),
1739 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1740 "unknown Dell", STAC_DELL_M4_2),
1741 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1742 "unknown Dell", STAC_DELL_M4_2),
1743 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1744 "unknown Dell", STAC_DELL_M4_2),
1745 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1746 "unknown Dell", STAC_DELL_M4_2),
1747 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1748 "unknown Dell", STAC_DELL_M4_3),
1752 static unsigned int ref922x_pin_configs[10] = {
1753 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1754 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1755 0x40000100, 0x40000100,
1759 STAC 922X pin configs for
1766 static unsigned int dell_922x_d81_pin_configs[10] = {
1767 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1768 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1769 0x01813122, 0x400001f2,
1773 STAC 922X pin configs for
1777 static unsigned int dell_922x_d82_pin_configs[10] = {
1778 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1779 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1780 0x01813122, 0x400001f1,
1784 STAC 922X pin configs for
1787 static unsigned int dell_922x_m81_pin_configs[10] = {
1788 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1789 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1790 0x40C003f1, 0x405003f0,
1794 STAC 9221 A1 pin configs for
1795 102801D7 (Dell XPS M1210)
1797 static unsigned int dell_922x_m82_pin_configs[10] = {
1798 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1799 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1800 0x508003f3, 0x405003f4,
1803 static unsigned int d945gtp3_pin_configs[10] = {
1804 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1805 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1806 0x02a19120, 0x40000100,
1809 static unsigned int d945gtp5_pin_configs[10] = {
1810 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1811 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1812 0x02a19320, 0x40000100,
1815 static unsigned int intel_mac_v1_pin_configs[10] = {
1816 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1817 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1818 0x400000fc, 0x400000fb,
1821 static unsigned int intel_mac_v2_pin_configs[10] = {
1822 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1823 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1824 0x400000fc, 0x400000fb,
1827 static unsigned int intel_mac_v3_pin_configs[10] = {
1828 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1829 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1830 0x400000fc, 0x400000fb,
1833 static unsigned int intel_mac_v4_pin_configs[10] = {
1834 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1835 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1836 0x400000fc, 0x400000fb,
1839 static unsigned int intel_mac_v5_pin_configs[10] = {
1840 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1841 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1842 0x400000fc, 0x400000fb,
1845 static unsigned int ecs202_pin_configs[10] = {
1846 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1847 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1848 0x9037012e, 0x40e000f2,
1851 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1852 [STAC_D945_REF] = ref922x_pin_configs,
1853 [STAC_D945GTP3] = d945gtp3_pin_configs,
1854 [STAC_D945GTP5] = d945gtp5_pin_configs,
1855 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1856 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1857 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1858 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1859 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1860 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1861 /* for backward compatibility */
1862 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1863 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1864 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1865 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1866 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1867 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1868 [STAC_ECS_202] = ecs202_pin_configs,
1869 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1870 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1871 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1872 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1875 static const char *stac922x_models[STAC_922X_MODELS] = {
1876 [STAC_D945_REF] = "ref",
1877 [STAC_D945GTP5] = "5stack",
1878 [STAC_D945GTP3] = "3stack",
1879 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1880 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1881 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1882 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1883 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1884 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1885 /* for backward compatibility */
1886 [STAC_MACMINI] = "macmini",
1887 [STAC_MACBOOK] = "macbook",
1888 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1889 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1890 [STAC_IMAC_INTEL] = "imac-intel",
1891 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1892 [STAC_ECS_202] = "ecs202",
1893 [STAC_922X_DELL_D81] = "dell-d81",
1894 [STAC_922X_DELL_D82] = "dell-d82",
1895 [STAC_922X_DELL_M81] = "dell-m81",
1896 [STAC_922X_DELL_M82] = "dell-m82",
1899 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1900 /* SigmaTel reference board */
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1902 "DFI LanParty", STAC_D945_REF),
1903 /* Intel 945G based systems */
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1905 "Intel D945G", STAC_D945GTP3),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1907 "Intel D945G", STAC_D945GTP3),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1909 "Intel D945G", STAC_D945GTP3),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1911 "Intel D945G", STAC_D945GTP3),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1913 "Intel D945G", STAC_D945GTP3),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1915 "Intel D945G", STAC_D945GTP3),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1917 "Intel D945G", STAC_D945GTP3),
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1919 "Intel D945G", STAC_D945GTP3),
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1921 "Intel D945G", STAC_D945GTP3),
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1923 "Intel D945G", STAC_D945GTP3),
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1925 "Intel D945G", STAC_D945GTP3),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1927 "Intel D945G", STAC_D945GTP3),
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1929 "Intel D945G", STAC_D945GTP3),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1931 "Intel D945G", STAC_D945GTP3),
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1933 "Intel D945G", STAC_D945GTP3),
1934 /* Intel D945G 5-stack systems */
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1936 "Intel D945G", STAC_D945GTP5),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1938 "Intel D945G", STAC_D945GTP5),
1939 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1940 "Intel D945G", STAC_D945GTP5),
1941 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1942 "Intel D945G", STAC_D945GTP5),
1943 /* Intel 945P based systems */
1944 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1945 "Intel D945P", STAC_D945GTP3),
1946 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1947 "Intel D945P", STAC_D945GTP3),
1948 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1949 "Intel D945P", STAC_D945GTP3),
1950 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1951 "Intel D945P", STAC_D945GTP3),
1952 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1953 "Intel D945P", STAC_D945GTP3),
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1955 "Intel D945P", STAC_D945GTP5),
1957 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1958 SND_PCI_QUIRK(0x8384, 0x7680,
1959 "Mac", STAC_INTEL_MAC_AUTO),
1961 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1962 "unknown Dell", STAC_922X_DELL_D81),
1963 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1964 "unknown Dell", STAC_922X_DELL_D81),
1965 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1966 "unknown Dell", STAC_922X_DELL_D81),
1967 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1968 "unknown Dell", STAC_922X_DELL_D82),
1969 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1970 "unknown Dell", STAC_922X_DELL_M81),
1971 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1972 "unknown Dell", STAC_922X_DELL_D82),
1973 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1974 "unknown Dell", STAC_922X_DELL_D81),
1975 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1976 "unknown Dell", STAC_922X_DELL_D81),
1977 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1978 "Dell XPS M1210", STAC_922X_DELL_M82),
1979 /* ECS/PC Chips boards */
1980 SND_PCI_QUIRK(0x1019, 0x2144,
1981 "ECS/PC chips", STAC_ECS_202),
1982 SND_PCI_QUIRK(0x1019, 0x2608,
1983 "ECS/PC chips", STAC_ECS_202),
1984 SND_PCI_QUIRK(0x1019, 0x2633,
1985 "ECS/PC chips P17G/1333", STAC_ECS_202),
1986 SND_PCI_QUIRK(0x1019, 0x2811,
1987 "ECS/PC chips", STAC_ECS_202),
1988 SND_PCI_QUIRK(0x1019, 0x2812,
1989 "ECS/PC chips", STAC_ECS_202),
1990 SND_PCI_QUIRK(0x1019, 0x2813,
1991 "ECS/PC chips", STAC_ECS_202),
1992 SND_PCI_QUIRK(0x1019, 0x2814,
1993 "ECS/PC chips", STAC_ECS_202),
1994 SND_PCI_QUIRK(0x1019, 0x2815,
1995 "ECS/PC chips", STAC_ECS_202),
1996 SND_PCI_QUIRK(0x1019, 0x2816,
1997 "ECS/PC chips", STAC_ECS_202),
1998 SND_PCI_QUIRK(0x1019, 0x2817,
1999 "ECS/PC chips", STAC_ECS_202),
2000 SND_PCI_QUIRK(0x1019, 0x2818,
2001 "ECS/PC chips", STAC_ECS_202),
2002 SND_PCI_QUIRK(0x1019, 0x2819,
2003 "ECS/PC chips", STAC_ECS_202),
2004 SND_PCI_QUIRK(0x1019, 0x2820,
2005 "ECS/PC chips", STAC_ECS_202),
2009 static unsigned int ref927x_pin_configs[14] = {
2010 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2011 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2012 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2013 0x01c42190, 0x40000100,
2016 static unsigned int d965_3st_pin_configs[14] = {
2017 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2018 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2019 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2020 0x40000100, 0x40000100
2023 static unsigned int d965_5st_pin_configs[14] = {
2024 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2025 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2026 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2027 0x40000100, 0x40000100
2030 static unsigned int dell_3st_pin_configs[14] = {
2031 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2032 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2033 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2034 0x40c003fc, 0x40000100
2037 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2038 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2039 [STAC_D965_REF] = ref927x_pin_configs,
2040 [STAC_D965_3ST] = d965_3st_pin_configs,
2041 [STAC_D965_5ST] = d965_5st_pin_configs,
2042 [STAC_DELL_3ST] = dell_3st_pin_configs,
2043 [STAC_DELL_BIOS] = NULL,
2046 static const char *stac927x_models[STAC_927X_MODELS] = {
2047 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2048 [STAC_D965_REF] = "ref",
2049 [STAC_D965_3ST] = "3stack",
2050 [STAC_D965_5ST] = "5stack",
2051 [STAC_DELL_3ST] = "dell-3stack",
2052 [STAC_DELL_BIOS] = "dell-bios",
2055 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2056 /* SigmaTel reference board */
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2058 "DFI LanParty", STAC_D965_REF),
2059 /* Intel 946 based systems */
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2062 /* 965 based 3 stack systems */
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2075 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
2079 /* Dell 3 stack systems */
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2081 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2084 /* Dell 3 stack systems with verb table in BIOS */
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2087 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2089 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2091 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2093 /* 965 based 5 stack systems */
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2095 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2097 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2098 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2099 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2100 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2101 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
2106 static unsigned int ref9205_pin_configs[12] = {
2107 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2108 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2109 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2113 STAC 9205 pin configs for
2120 10280228 (Dell Vostro 1500)
2122 static unsigned int dell_9205_m42_pin_configs[12] = {
2123 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2124 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2125 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2129 STAC 9205 pin configs for
2133 102801FF (Dell Precision M4300)
2138 static unsigned int dell_9205_m43_pin_configs[12] = {
2139 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2140 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2141 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2144 static unsigned int dell_9205_m44_pin_configs[12] = {
2145 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2146 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2147 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2150 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2151 [STAC_9205_REF] = ref9205_pin_configs,
2152 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2153 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2154 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2157 static const char *stac9205_models[STAC_9205_MODELS] = {
2158 [STAC_9205_REF] = "ref",
2159 [STAC_9205_DELL_M42] = "dell-m42",
2160 [STAC_9205_DELL_M43] = "dell-m43",
2161 [STAC_9205_DELL_M44] = "dell-m44",
2164 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2165 /* SigmaTel reference board */
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2167 "DFI LanParty", STAC_9205_REF),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2169 "unknown Dell", STAC_9205_DELL_M42),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2171 "unknown Dell", STAC_9205_DELL_M42),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2173 "Dell Precision", STAC_9205_DELL_M43),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2175 "Dell Precision", STAC_9205_DELL_M43),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2177 "Dell Precision", STAC_9205_DELL_M43),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2179 "unknown Dell", STAC_9205_DELL_M42),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2181 "unknown Dell", STAC_9205_DELL_M42),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2183 "Dell Precision", STAC_9205_DELL_M43),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2185 "Dell Precision M4300", STAC_9205_DELL_M43),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2187 "unknown Dell", STAC_9205_DELL_M42),
2188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2189 "Dell Precision", STAC_9205_DELL_M43),
2190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2191 "Dell Precision", STAC_9205_DELL_M43),
2192 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2193 "Dell Precision", STAC_9205_DELL_M43),
2194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2195 "Dell Inspiron", STAC_9205_DELL_M44),
2196 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2197 "Dell Vostro 1500", STAC_9205_DELL_M42),
2201 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2204 struct sigmatel_spec *spec = codec->spec;
2206 if (! spec->bios_pin_configs) {
2207 spec->bios_pin_configs = kcalloc(spec->num_pins,
2208 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2209 if (! spec->bios_pin_configs)
2213 for (i = 0; i < spec->num_pins; i++) {
2214 hda_nid_t nid = spec->pin_nids[i];
2215 unsigned int pin_cfg;
2217 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2218 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2219 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2221 spec->bios_pin_configs[i] = pin_cfg;
2227 static void stac92xx_set_config_reg(struct hda_codec *codec,
2228 hda_nid_t pin_nid, unsigned int pin_config)
2231 snd_hda_codec_write(codec, pin_nid, 0,
2232 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2233 pin_config & 0x000000ff);
2234 snd_hda_codec_write(codec, pin_nid, 0,
2235 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2236 (pin_config & 0x0000ff00) >> 8);
2237 snd_hda_codec_write(codec, pin_nid, 0,
2238 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2239 (pin_config & 0x00ff0000) >> 16);
2240 snd_hda_codec_write(codec, pin_nid, 0,
2241 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2243 i = snd_hda_codec_read(codec, pin_nid, 0,
2244 AC_VERB_GET_CONFIG_DEFAULT,
2246 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2250 static void stac92xx_set_config_regs(struct hda_codec *codec)
2253 struct sigmatel_spec *spec = codec->spec;
2255 if (!spec->pin_configs)
2258 for (i = 0; i < spec->num_pins; i++)
2259 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2260 spec->pin_configs[i]);
2264 * Analog playback callbacks
2266 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2267 struct hda_codec *codec,
2268 struct snd_pcm_substream *substream)
2270 struct sigmatel_spec *spec = codec->spec;
2271 if (spec->stream_delay)
2272 msleep(spec->stream_delay);
2273 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2277 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2278 struct hda_codec *codec,
2279 unsigned int stream_tag,
2280 unsigned int format,
2281 struct snd_pcm_substream *substream)
2283 struct sigmatel_spec *spec = codec->spec;
2284 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2287 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2288 struct hda_codec *codec,
2289 struct snd_pcm_substream *substream)
2291 struct sigmatel_spec *spec = codec->spec;
2292 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2296 * Digital playback callbacks
2298 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2299 struct hda_codec *codec,
2300 struct snd_pcm_substream *substream)
2302 struct sigmatel_spec *spec = codec->spec;
2303 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2306 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2307 struct hda_codec *codec,
2308 struct snd_pcm_substream *substream)
2310 struct sigmatel_spec *spec = codec->spec;
2311 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2314 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2315 struct hda_codec *codec,
2316 unsigned int stream_tag,
2317 unsigned int format,
2318 struct snd_pcm_substream *substream)
2320 struct sigmatel_spec *spec = codec->spec;
2321 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2322 stream_tag, format, substream);
2327 * Analog capture callbacks
2329 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2330 struct hda_codec *codec,
2331 unsigned int stream_tag,
2332 unsigned int format,
2333 struct snd_pcm_substream *substream)
2335 struct sigmatel_spec *spec = codec->spec;
2336 hda_nid_t nid = spec->adc_nids[substream->number];
2338 if (spec->powerdown_adcs) {
2340 snd_hda_codec_write_cache(codec, nid, 0,
2341 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2343 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2347 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2348 struct hda_codec *codec,
2349 struct snd_pcm_substream *substream)
2351 struct sigmatel_spec *spec = codec->spec;
2352 hda_nid_t nid = spec->adc_nids[substream->number];
2354 snd_hda_codec_cleanup_stream(codec, nid);
2355 if (spec->powerdown_adcs)
2356 snd_hda_codec_write_cache(codec, nid, 0,
2357 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2361 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2365 /* NID is set in stac92xx_build_pcms */
2367 .open = stac92xx_dig_playback_pcm_open,
2368 .close = stac92xx_dig_playback_pcm_close,
2369 .prepare = stac92xx_dig_playback_pcm_prepare
2373 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2377 /* NID is set in stac92xx_build_pcms */
2380 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2384 .nid = 0x02, /* NID to query formats and rates */
2386 .open = stac92xx_playback_pcm_open,
2387 .prepare = stac92xx_playback_pcm_prepare,
2388 .cleanup = stac92xx_playback_pcm_cleanup
2392 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2396 .nid = 0x06, /* NID to query formats and rates */
2398 .open = stac92xx_playback_pcm_open,
2399 .prepare = stac92xx_playback_pcm_prepare,
2400 .cleanup = stac92xx_playback_pcm_cleanup
2404 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2407 /* NID + .substreams is set in stac92xx_build_pcms */
2409 .prepare = stac92xx_capture_pcm_prepare,
2410 .cleanup = stac92xx_capture_pcm_cleanup
2414 static int stac92xx_build_pcms(struct hda_codec *codec)
2416 struct sigmatel_spec *spec = codec->spec;
2417 struct hda_pcm *info = spec->pcm_rec;
2419 codec->num_pcms = 1;
2420 codec->pcm_info = info;
2422 info->name = "STAC92xx Analog";
2423 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2424 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2425 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2426 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2428 if (spec->alt_switch) {
2431 info->name = "STAC92xx Analog Alt";
2432 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2435 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2438 info->name = "STAC92xx Digital";
2439 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2440 if (spec->multiout.dig_out_nid) {
2441 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2442 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2444 if (spec->dig_in_nid) {
2445 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2446 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2453 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2455 unsigned int pincap = snd_hda_param_read(codec, nid,
2457 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2458 if (pincap & AC_PINCAP_VREF_100)
2459 return AC_PINCTL_VREF_100;
2460 if (pincap & AC_PINCAP_VREF_80)
2461 return AC_PINCTL_VREF_80;
2462 if (pincap & AC_PINCAP_VREF_50)
2463 return AC_PINCTL_VREF_50;
2464 if (pincap & AC_PINCAP_VREF_GRD)
2465 return AC_PINCTL_VREF_GRD;
2469 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2472 snd_hda_codec_write_cache(codec, nid, 0,
2473 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2476 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2478 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2479 struct snd_ctl_elem_value *ucontrol)
2481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2482 struct sigmatel_spec *spec = codec->spec;
2484 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2488 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2489 struct snd_ctl_elem_value *ucontrol)
2491 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2492 struct sigmatel_spec *spec = codec->spec;
2493 int nid = kcontrol->private_value;
2495 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2497 /* check to be sure that the ports are upto date with
2500 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2505 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2507 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2509 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2510 struct sigmatel_spec *spec = codec->spec;
2511 int io_idx = kcontrol-> private_value & 0xff;
2513 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2517 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2520 struct sigmatel_spec *spec = codec->spec;
2521 hda_nid_t nid = kcontrol->private_value >> 8;
2522 int io_idx = kcontrol-> private_value & 0xff;
2523 unsigned short val = !!ucontrol->value.integer.value[0];
2525 spec->io_switch[io_idx] = val;
2528 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2530 unsigned int pinctl = AC_PINCTL_IN_EN;
2531 if (io_idx) /* set VREF for mic */
2532 pinctl |= stac92xx_get_vref(codec, nid);
2533 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2536 /* check the auto-mute again: we need to mute/unmute the speaker
2537 * appropriately according to the pin direction
2539 if (spec->hp_detect)
2540 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2545 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2547 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2548 struct snd_ctl_elem_value *ucontrol)
2550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2551 struct sigmatel_spec *spec = codec->spec;
2553 ucontrol->value.integer.value[0] = spec->clfe_swap;
2557 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2558 struct snd_ctl_elem_value *ucontrol)
2560 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2561 struct sigmatel_spec *spec = codec->spec;
2562 hda_nid_t nid = kcontrol->private_value & 0xff;
2563 unsigned int val = !!ucontrol->value.integer.value[0];
2565 if (spec->clfe_swap == val)
2568 spec->clfe_swap = val;
2570 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2571 spec->clfe_swap ? 0x4 : 0x0);
2576 #define STAC_CODEC_HP_SWITCH(xname) \
2577 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2580 .info = stac92xx_hp_switch_info, \
2581 .get = stac92xx_hp_switch_get, \
2582 .put = stac92xx_hp_switch_put, \
2585 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2586 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2589 .info = stac92xx_io_switch_info, \
2590 .get = stac92xx_io_switch_get, \
2591 .put = stac92xx_io_switch_put, \
2592 .private_value = xpval, \
2595 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2596 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2599 .info = stac92xx_clfe_switch_info, \
2600 .get = stac92xx_clfe_switch_get, \
2601 .put = stac92xx_clfe_switch_put, \
2602 .private_value = xpval, \
2606 STAC_CTL_WIDGET_VOL,
2607 STAC_CTL_WIDGET_MUTE,
2608 STAC_CTL_WIDGET_MONO_MUX,
2609 STAC_CTL_WIDGET_AMP_MUX,
2610 STAC_CTL_WIDGET_AMP_VOL,
2611 STAC_CTL_WIDGET_HP_SWITCH,
2612 STAC_CTL_WIDGET_IO_SWITCH,
2613 STAC_CTL_WIDGET_CLFE_SWITCH
2616 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2617 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2618 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2621 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2622 STAC_CODEC_HP_SWITCH(NULL),
2623 STAC_CODEC_IO_SWITCH(NULL, 0),
2624 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2627 /* add dynamic controls */
2628 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2629 struct snd_kcontrol_new *ktemp,
2630 int idx, const char *name,
2633 struct snd_kcontrol_new *knew;
2635 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2636 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2638 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2641 if (spec->kctl_alloc) {
2642 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2643 kfree(spec->kctl_alloc);
2645 spec->kctl_alloc = knew;
2646 spec->num_kctl_alloc = num;
2649 knew = &spec->kctl_alloc[spec->num_kctl_used];
2652 knew->name = kstrdup(name, GFP_KERNEL);
2655 knew->private_value = val;
2656 spec->num_kctl_used++;
2660 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2661 int type, int idx, const char *name,
2664 return stac92xx_add_control_temp(spec,
2665 &stac92xx_control_templates[type],
2670 /* add dynamic controls */
2671 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2672 const char *name, unsigned long val)
2674 return stac92xx_add_control_idx(spec, type, 0, name, val);
2677 /* flag inputs as additional dynamic lineouts */
2678 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2680 struct sigmatel_spec *spec = codec->spec;
2681 unsigned int wcaps, wtype;
2682 int i, num_dacs = 0;
2684 /* use the wcaps cache to count all DACs available for line-outs */
2685 for (i = 0; i < codec->num_nodes; i++) {
2686 wcaps = codec->wcaps[i];
2687 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2689 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2693 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2695 switch (cfg->line_outs) {
2697 /* add line-in as side */
2698 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2699 cfg->line_out_pins[cfg->line_outs] =
2700 cfg->input_pins[AUTO_PIN_LINE];
2701 spec->line_switch = 1;
2706 /* add line-in as clfe and mic as side */
2707 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2708 cfg->line_out_pins[cfg->line_outs] =
2709 cfg->input_pins[AUTO_PIN_LINE];
2710 spec->line_switch = 1;
2713 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2714 cfg->line_out_pins[cfg->line_outs] =
2715 cfg->input_pins[AUTO_PIN_MIC];
2716 spec->mic_switch = 1;
2721 /* add line-in as surr and mic as clfe */
2722 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2723 cfg->line_out_pins[cfg->line_outs] =
2724 cfg->input_pins[AUTO_PIN_LINE];
2725 spec->line_switch = 1;
2728 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2729 cfg->line_out_pins[cfg->line_outs] =
2730 cfg->input_pins[AUTO_PIN_MIC];
2731 spec->mic_switch = 1;
2741 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2745 for (i = 0; i < spec->multiout.num_dacs; i++) {
2746 if (spec->multiout.dac_nids[i] == nid)
2754 * Fill in the dac_nids table from the parsed pin configuration
2755 * This function only works when every pin in line_out_pins[]
2756 * contains atleast one DAC in its connection list. Some 92xx
2757 * codecs are not connected directly to a DAC, such as the 9200
2758 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2760 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2761 struct auto_pin_cfg *cfg)
2763 struct sigmatel_spec *spec = codec->spec;
2764 int i, j, conn_len = 0;
2765 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2766 unsigned int wcaps, wtype;
2768 for (i = 0; i < cfg->line_outs; i++) {
2769 nid = cfg->line_out_pins[i];
2770 conn_len = snd_hda_get_connections(codec, nid, conn,
2771 HDA_MAX_CONNECTIONS);
2772 for (j = 0; j < conn_len; j++) {
2773 wcaps = snd_hda_param_read(codec, conn[j],
2774 AC_PAR_AUDIO_WIDGET_CAP);
2775 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2776 if (wtype != AC_WID_AUD_OUT ||
2777 (wcaps & AC_WCAP_DIGITAL))
2779 /* conn[j] is a DAC routed to this line-out */
2780 if (!is_in_dac_nids(spec, conn[j]))
2784 if (j == conn_len) {
2785 if (spec->multiout.num_dacs > 0) {
2786 /* we have already working output pins,
2787 * so let's drop the broken ones again
2789 cfg->line_outs = spec->multiout.num_dacs;
2792 /* error out, no available DAC found */
2794 "%s: No available DAC for pin 0x%x\n",
2799 spec->multiout.dac_nids[i] = conn[j];
2800 spec->multiout.num_dacs++;
2802 /* select this DAC in the pin's input mux */
2803 snd_hda_codec_write_cache(codec, nid, 0,
2804 AC_VERB_SET_CONNECT_SEL, j);
2809 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2810 spec->multiout.num_dacs,
2811 spec->multiout.dac_nids[0],
2812 spec->multiout.dac_nids[1],
2813 spec->multiout.dac_nids[2],
2814 spec->multiout.dac_nids[3],
2815 spec->multiout.dac_nids[4]);
2819 /* create volume control/switch for the given prefx type */
2820 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2825 sprintf(name, "%s Playback Volume", pfx);
2826 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2827 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2830 sprintf(name, "%s Playback Switch", pfx);
2831 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2832 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2838 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2840 if (!spec->multiout.hp_nid)
2841 spec->multiout.hp_nid = nid;
2842 else if (spec->multiout.num_dacs > 4) {
2843 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2846 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2847 spec->multiout.num_dacs++;
2852 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2854 if (is_in_dac_nids(spec, nid))
2856 if (spec->multiout.hp_nid == nid)
2861 /* add playback controls from the parsed DAC table */
2862 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2863 const struct auto_pin_cfg *cfg)
2865 static const char *chname[4] = {
2866 "Front", "Surround", NULL /*CLFE*/, "Side"
2871 struct sigmatel_spec *spec = codec->spec;
2872 unsigned int wid_caps, pincap;
2875 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2876 if (!spec->multiout.dac_nids[i])
2879 nid = spec->multiout.dac_nids[i];
2883 err = create_controls(spec, "Center", nid, 1);
2886 err = create_controls(spec, "LFE", nid, 2);
2890 wid_caps = get_wcaps(codec, nid);
2892 if (wid_caps & AC_WCAP_LR_SWAP) {
2893 err = stac92xx_add_control(spec,
2894 STAC_CTL_WIDGET_CLFE_SWITCH,
2895 "Swap Center/LFE Playback Switch", nid);
2902 err = create_controls(spec, chname[i], nid, 3);
2908 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2909 cfg->hp_outs == 1 && !spec->multiout.hp_nid)
2910 spec->multiout.hp_nid = nid;
2912 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
2913 err = stac92xx_add_control(spec,
2914 STAC_CTL_WIDGET_HP_SWITCH,
2915 "Headphone as Line Out Switch",
2916 cfg->hp_pins[cfg->hp_outs - 1]);
2921 if (spec->line_switch) {
2922 nid = cfg->input_pins[AUTO_PIN_LINE];
2923 pincap = snd_hda_param_read(codec, nid,
2925 if (pincap & AC_PINCAP_OUT) {
2926 err = stac92xx_add_control(spec,
2927 STAC_CTL_WIDGET_IO_SWITCH,
2928 "Line In as Output Switch", nid << 8);
2934 if (spec->mic_switch) {
2935 unsigned int def_conf;
2936 unsigned int mic_pin = AUTO_PIN_MIC;
2938 nid = cfg->input_pins[mic_pin];
2939 def_conf = snd_hda_codec_read(codec, nid, 0,
2940 AC_VERB_GET_CONFIG_DEFAULT, 0);
2941 /* some laptops have an internal analog microphone
2942 * which can't be used as a output */
2943 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2944 pincap = snd_hda_param_read(codec, nid,
2946 if (pincap & AC_PINCAP_OUT) {
2947 err = stac92xx_add_control(spec,
2948 STAC_CTL_WIDGET_IO_SWITCH,
2949 "Mic as Output Switch", (nid << 8) | 1);
2950 nid = snd_hda_codec_read(codec, nid, 0,
2951 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2952 if (!check_in_dac_nids(spec, nid))
2953 add_spec_dacs(spec, nid);
2957 } else if (mic_pin == AUTO_PIN_MIC) {
2958 mic_pin = AUTO_PIN_FRONT_MIC;
2966 /* add playback controls for Speaker and HP outputs */
2967 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2968 struct auto_pin_cfg *cfg)
2970 struct sigmatel_spec *spec = codec->spec;
2972 int i, old_num_dacs, err;
2974 old_num_dacs = spec->multiout.num_dacs;
2975 for (i = 0; i < cfg->hp_outs; i++) {
2976 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2977 if (wid_caps & AC_WCAP_UNSOL_CAP)
2978 spec->hp_detect = 1;
2979 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2980 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2981 if (check_in_dac_nids(spec, nid))
2985 add_spec_dacs(spec, nid);
2987 for (i = 0; i < cfg->speaker_outs; i++) {
2988 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2989 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2990 if (check_in_dac_nids(spec, nid))
2994 add_spec_dacs(spec, nid);
2996 for (i = 0; i < cfg->line_outs; i++) {
2997 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2998 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2999 if (check_in_dac_nids(spec, nid))
3003 add_spec_dacs(spec, nid);
3005 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
3006 static const char *pfxs[] = {
3007 "Speaker", "External Speaker", "Speaker2",
3009 err = create_controls(spec, pfxs[i - old_num_dacs],
3010 spec->multiout.dac_nids[i], 3);
3014 if (spec->multiout.hp_nid) {
3015 err = create_controls(spec, "Headphone",
3016 spec->multiout.hp_nid, 3);
3024 /* labels for mono mux outputs */
3025 static const char *stac92xx_mono_labels[4] = {
3026 "DAC0", "DAC1", "Mixer", "DAC2"
3029 /* create mono mux for mono out on capable codecs */
3030 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3032 struct sigmatel_spec *spec = codec->spec;
3033 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3035 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3037 num_cons = snd_hda_get_connections(codec,
3040 HDA_MAX_NUM_INPUTS);
3041 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3044 for (i = 0; i < num_cons; i++) {
3045 mono_mux->items[mono_mux->num_items].label =
3046 stac92xx_mono_labels[i];
3047 mono_mux->items[mono_mux->num_items].index = i;
3048 mono_mux->num_items++;
3051 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3052 "Mono Mux", spec->mono_nid);
3055 /* labels for amp mux outputs */
3056 static const char *stac92xx_amp_labels[3] = {
3057 "Front Microphone", "Microphone", "Line In",
3060 /* create amp out controls mux on capable codecs */
3061 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3063 struct sigmatel_spec *spec = codec->spec;
3064 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3067 for (i = 0; i < spec->num_amps; i++) {
3068 amp_mux->items[amp_mux->num_items].label =
3069 stac92xx_amp_labels[i];
3070 amp_mux->items[amp_mux->num_items].index = i;
3071 amp_mux->num_items++;
3074 if (spec->num_amps > 1) {
3075 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3076 "Amp Selector Capture Switch", 0);
3080 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3081 "Amp Capture Volume",
3082 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3086 /* create PC beep volume controls */
3087 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3090 struct sigmatel_spec *spec = codec->spec;
3091 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3094 /* check for mute support for the the amp */
3095 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3096 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3097 "PC Beep Playback Switch",
3098 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3103 /* check to see if there is volume support for the amp */
3104 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3105 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3106 "PC Beep Playback Volume",
3107 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3114 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3115 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3117 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3118 struct snd_ctl_elem_value *ucontrol)
3120 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3121 ucontrol->value.integer.value[0] = codec->beep->enabled;
3125 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3126 struct snd_ctl_elem_value *ucontrol)
3128 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3129 int enabled = !!ucontrol->value.integer.value[0];
3130 if (codec->beep->enabled != enabled) {
3131 codec->beep->enabled = enabled;
3137 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3139 .info = stac92xx_dig_beep_switch_info,
3140 .get = stac92xx_dig_beep_switch_get,
3141 .put = stac92xx_dig_beep_switch_put,
3144 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3146 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3147 0, "PC Beep Playback Switch", 0);
3151 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3153 struct sigmatel_spec *spec = codec->spec;
3154 int wcaps, nid, i, err = 0;
3156 for (i = 0; i < spec->num_muxes; i++) {
3157 nid = spec->mux_nids[i];
3158 wcaps = get_wcaps(codec, nid);
3160 if (wcaps & AC_WCAP_OUT_AMP) {
3161 err = stac92xx_add_control_idx(spec,
3162 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3163 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3171 static const char *stac92xx_spdif_labels[3] = {
3172 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3175 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3177 struct sigmatel_spec *spec = codec->spec;
3178 struct hda_input_mux *spdif_mux = &spec->private_smux;
3179 const char **labels = spec->spdif_labels;
3181 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3183 num_cons = snd_hda_get_connections(codec,
3186 HDA_MAX_NUM_INPUTS);
3191 labels = stac92xx_spdif_labels;
3193 for (i = 0; i < num_cons; i++) {
3194 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3195 spdif_mux->items[spdif_mux->num_items].index = i;
3196 spdif_mux->num_items++;
3202 /* labels for dmic mux inputs */
3203 static const char *stac92xx_dmic_labels[5] = {
3204 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3205 "Digital Mic 3", "Digital Mic 4"
3208 /* create playback/capture controls for input pins on dmic capable codecs */
3209 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3210 const struct auto_pin_cfg *cfg)
3212 struct sigmatel_spec *spec = codec->spec;
3213 struct hda_input_mux *dimux = &spec->private_dimux;
3214 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3218 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3219 dimux->items[dimux->num_items].index = 0;
3222 for (i = 0; i < spec->num_dmics; i++) {
3227 unsigned int def_conf;
3229 def_conf = snd_hda_codec_read(codec,
3232 AC_VERB_GET_CONFIG_DEFAULT,
3234 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3237 nid = spec->dmic_nids[i];
3238 num_cons = snd_hda_get_connections(codec,
3241 HDA_MAX_NUM_INPUTS);
3242 for (j = 0; j < num_cons; j++)
3243 if (con_lst[j] == nid) {
3249 wcaps = get_wcaps(codec, nid) &
3250 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3253 sprintf(name, "%s Capture Volume",
3254 stac92xx_dmic_labels[dimux->num_items]);
3256 err = stac92xx_add_control(spec,
3257 STAC_CTL_WIDGET_VOL,
3259 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3260 (wcaps & AC_WCAP_OUT_AMP) ?
3261 HDA_OUTPUT : HDA_INPUT));
3266 dimux->items[dimux->num_items].label =
3267 stac92xx_dmic_labels[dimux->num_items];
3268 dimux->items[dimux->num_items].index = index;
3275 /* create playback/capture controls for input pins */
3276 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3278 struct sigmatel_spec *spec = codec->spec;
3279 struct hda_input_mux *imux = &spec->private_imux;
3280 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3283 for (i = 0; i < AUTO_PIN_LAST; i++) {
3286 if (!cfg->input_pins[i])
3289 for (j = 0; j < spec->num_muxes; j++) {
3291 num_cons = snd_hda_get_connections(codec,
3294 HDA_MAX_NUM_INPUTS);
3295 for (k = 0; k < num_cons; k++)
3296 if (con_lst[k] == cfg->input_pins[i]) {
3303 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3304 imux->items[imux->num_items].index = index;
3308 if (imux->num_items) {
3310 * Set the current input for the muxes.
3311 * The STAC9221 has two input muxes with identical source
3312 * NID lists. Hopefully this won't get confused.
3314 for (i = 0; i < spec->num_muxes; i++) {
3315 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3316 AC_VERB_SET_CONNECT_SEL,
3317 imux->items[0].index);
3324 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3326 struct sigmatel_spec *spec = codec->spec;
3329 for (i = 0; i < spec->autocfg.line_outs; i++) {
3330 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3331 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3335 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3337 struct sigmatel_spec *spec = codec->spec;
3340 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3342 pin = spec->autocfg.hp_pins[i];
3343 if (pin) /* connect to front */
3344 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3346 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3348 pin = spec->autocfg.speaker_pins[i];
3349 if (pin) /* connect to front */
3350 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3354 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3356 struct sigmatel_spec *spec = codec->spec;
3358 int hp_speaker_swap = 0;
3360 if ((err = snd_hda_parse_pin_def_config(codec,
3362 spec->dmic_nids)) < 0)
3364 if (! spec->autocfg.line_outs)
3365 return 0; /* can't find valid pin config */
3367 /* If we have no real line-out pin and multiple hp-outs, HPs should
3368 * be set up as multi-channel outputs.
3370 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3371 spec->autocfg.hp_outs > 1) {
3372 /* Copy hp_outs to line_outs, backup line_outs in
3373 * speaker_outs so that the following routines can handle
3374 * HP pins as primary outputs.
3376 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3377 sizeof(spec->autocfg.line_out_pins));
3378 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3379 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3380 sizeof(spec->autocfg.hp_pins));
3381 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3382 hp_speaker_swap = 1;
3384 if (spec->autocfg.mono_out_pin) {
3385 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3386 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3387 u32 caps = query_amp_caps(codec,
3388 spec->autocfg.mono_out_pin, dir);
3389 hda_nid_t conn_list[1];
3391 /* get the mixer node and then the mono mux if it exists */
3392 if (snd_hda_get_connections(codec,
3393 spec->autocfg.mono_out_pin, conn_list, 1) &&
3394 snd_hda_get_connections(codec, conn_list[0],
3397 int wcaps = get_wcaps(codec, conn_list[0]);
3398 int wid_type = (wcaps & AC_WCAP_TYPE)
3399 >> AC_WCAP_TYPE_SHIFT;
3400 /* LR swap check, some stac925x have a mux that
3401 * changes the DACs output path instead of the
3404 if (wid_type == AC_WID_AUD_SEL &&
3405 !(wcaps & AC_WCAP_LR_SWAP))
3406 spec->mono_nid = conn_list[0];
3409 hda_nid_t nid = spec->autocfg.mono_out_pin;
3411 /* most mono outs have a least a mute/unmute switch */
3412 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3413 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3414 "Mono Playback Switch",
3415 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3418 /* check for volume support for the amp */
3419 if ((caps & AC_AMPCAP_NUM_STEPS)
3420 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3421 err = stac92xx_add_control(spec,
3422 STAC_CTL_WIDGET_VOL,
3423 "Mono Playback Volume",
3424 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3430 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3434 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3436 if (spec->multiout.num_dacs == 0)
3437 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3440 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3445 /* setup analog beep controls */
3446 if (spec->anabeep_nid > 0) {
3447 err = stac92xx_auto_create_beep_ctls(codec,
3453 /* setup digital beep controls and input device */
3454 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3455 if (spec->digbeep_nid > 0) {
3456 hda_nid_t nid = spec->digbeep_nid;
3459 err = stac92xx_auto_create_beep_ctls(codec, nid);
3462 err = snd_hda_attach_beep_device(codec, nid);
3465 /* if no beep switch is available, make its own one */
3466 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3468 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3469 err = stac92xx_beep_switch_ctl(codec);
3476 if (hp_speaker_swap == 1) {
3477 /* Restore the hp_outs and line_outs */
3478 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3479 sizeof(spec->autocfg.line_out_pins));
3480 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3481 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3482 sizeof(spec->autocfg.speaker_pins));
3483 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3484 memset(spec->autocfg.speaker_pins, 0,
3485 sizeof(spec->autocfg.speaker_pins));
3486 spec->autocfg.speaker_outs = 0;
3489 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3494 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3499 if (spec->mono_nid > 0) {
3500 err = stac92xx_auto_create_mono_output_ctls(codec);
3504 if (spec->num_amps > 0) {
3505 err = stac92xx_auto_create_amp_output_ctls(codec);
3509 if (spec->num_dmics > 0 && !spec->dinput_mux)
3510 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3511 &spec->autocfg)) < 0)
3513 if (spec->num_muxes > 0) {
3514 err = stac92xx_auto_create_mux_input_ctls(codec);
3518 if (spec->num_smuxes > 0) {
3519 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3524 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3525 if (spec->multiout.max_channels > 2)
3526 spec->surr_switch = 1;
3528 if (spec->autocfg.dig_out_pin)
3529 spec->multiout.dig_out_nid = dig_out;
3530 if (dig_in && spec->autocfg.dig_in_pin)
3531 spec->dig_in_nid = dig_in;
3533 if (spec->kctl_alloc)
3534 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3536 spec->input_mux = &spec->private_imux;
3537 spec->dinput_mux = &spec->private_dimux;
3538 spec->sinput_mux = &spec->private_smux;
3539 spec->mono_mux = &spec->private_mono_mux;
3540 spec->amp_mux = &spec->private_amp_mux;
3544 /* add playback controls for HP output */
3545 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3546 struct auto_pin_cfg *cfg)
3548 struct sigmatel_spec *spec = codec->spec;
3549 hda_nid_t pin = cfg->hp_pins[0];
3550 unsigned int wid_caps;
3555 wid_caps = get_wcaps(codec, pin);
3556 if (wid_caps & AC_WCAP_UNSOL_CAP)
3557 spec->hp_detect = 1;
3562 /* add playback controls for LFE output */
3563 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3564 struct auto_pin_cfg *cfg)
3566 struct sigmatel_spec *spec = codec->spec;
3568 hda_nid_t lfe_pin = 0x0;
3572 * search speaker outs and line outs for a mono speaker pin
3573 * with an amp. If one is found, add LFE controls
3576 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3577 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3578 unsigned int wcaps = get_wcaps(codec, pin);
3579 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3580 if (wcaps == AC_WCAP_OUT_AMP)
3581 /* found a mono speaker with an amp, must be lfe */
3585 /* if speaker_outs is 0, then speakers may be in line_outs */
3586 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3587 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3588 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3589 unsigned int defcfg;
3590 defcfg = snd_hda_codec_read(codec, pin, 0,
3591 AC_VERB_GET_CONFIG_DEFAULT,
3593 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3594 unsigned int wcaps = get_wcaps(codec, pin);
3595 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3596 if (wcaps == AC_WCAP_OUT_AMP)
3597 /* found a mono speaker with an amp,
3605 err = create_controls(spec, "LFE", lfe_pin, 1);
3613 static int stac9200_parse_auto_config(struct hda_codec *codec)
3615 struct sigmatel_spec *spec = codec->spec;
3618 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3621 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3624 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3627 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3630 if (spec->num_muxes > 0) {
3631 err = stac92xx_auto_create_mux_input_ctls(codec);
3636 if (spec->autocfg.dig_out_pin)
3637 spec->multiout.dig_out_nid = 0x05;
3638 if (spec->autocfg.dig_in_pin)
3639 spec->dig_in_nid = 0x04;
3641 if (spec->kctl_alloc)
3642 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3644 spec->input_mux = &spec->private_imux;
3645 spec->dinput_mux = &spec->private_dimux;
3651 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3652 * funky external mute control using GPIO pins.
3655 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3656 unsigned int dir_mask, unsigned int data)
3658 unsigned int gpiostate, gpiomask, gpiodir;
3660 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3661 AC_VERB_GET_GPIO_DATA, 0);
3662 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3664 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3665 AC_VERB_GET_GPIO_MASK, 0);
3668 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3669 AC_VERB_GET_GPIO_DIRECTION, 0);
3670 gpiodir |= dir_mask;
3672 /* Configure GPIOx as CMOS */
3673 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3675 snd_hda_codec_write(codec, codec->afg, 0,
3676 AC_VERB_SET_GPIO_MASK, gpiomask);
3677 snd_hda_codec_read(codec, codec->afg, 0,
3678 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3682 snd_hda_codec_read(codec, codec->afg, 0,
3683 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3686 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3689 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
3690 snd_hda_codec_write_cache(codec, nid, 0,
3691 AC_VERB_SET_UNSOLICITED_ENABLE,
3692 (AC_USRSP_EN | event));
3695 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3698 for (i = 0; i < cfg->hp_outs; i++)
3699 if (cfg->hp_pins[i] == nid)
3700 return 1; /* nid is a HP-Out */
3702 return 0; /* nid is not a HP-Out */
3705 static void stac92xx_power_down(struct hda_codec *codec)
3707 struct sigmatel_spec *spec = codec->spec;
3709 /* power down inactive DACs */
3711 for (dac = spec->dac_list; *dac; dac++)
3712 if (!is_in_dac_nids(spec, *dac) &&
3713 spec->multiout.hp_nid != *dac)
3714 snd_hda_codec_write_cache(codec, *dac, 0,
3715 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3718 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3721 static int stac92xx_init(struct hda_codec *codec)
3723 struct sigmatel_spec *spec = codec->spec;
3724 struct auto_pin_cfg *cfg = &spec->autocfg;
3728 snd_hda_sequence_write(codec, spec->init);
3730 /* power down adcs initially */
3731 if (spec->powerdown_adcs)
3732 for (i = 0; i < spec->num_adcs; i++)
3733 snd_hda_codec_write_cache(codec,
3734 spec->adc_nids[i], 0,
3735 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3738 gpio = spec->gpio_data;
3739 /* turn on EAPD statically when spec->eapd_switch isn't set.
3740 * otherwise, unsol event will turn it on/off dynamically
3742 if (!spec->eapd_switch)
3743 gpio |= spec->eapd_mask;
3744 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3747 if (spec->hp_detect) {
3748 /* Enable unsolicited responses on the HP widget */
3749 for (i = 0; i < cfg->hp_outs; i++)
3750 enable_pin_detect(codec, cfg->hp_pins[i],
3752 /* force to enable the first line-out; the others are set up
3755 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3757 stac92xx_auto_init_hp_out(codec);
3758 /* fake event to set up pins */
3759 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3761 stac92xx_auto_init_multi_out(codec);
3762 stac92xx_auto_init_hp_out(codec);
3764 for (i = 0; i < AUTO_PIN_LAST; i++) {
3765 hda_nid_t nid = cfg->input_pins[i];
3767 unsigned int pinctl;
3768 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3769 /* for mic pins, force to initialize */
3770 pinctl = stac92xx_get_vref(codec, nid);
3772 pinctl = snd_hda_codec_read(codec, nid, 0,
3773 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3774 /* if PINCTL already set then skip */
3775 if (pinctl & AC_PINCTL_IN_EN)
3778 pinctl |= AC_PINCTL_IN_EN;
3779 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3782 for (i = 0; i < spec->num_dmics; i++)
3783 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3785 if (cfg->dig_out_pin)
3786 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3788 if (cfg->dig_in_pin)
3789 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3791 for (i = 0; i < spec->num_pwrs; i++) {
3792 hda_nid_t nid = spec->pwr_nids[i];
3793 int pinctl, def_conf;
3794 int event = STAC_PWR_EVENT;
3796 if (is_nid_hp_pin(cfg, nid) && spec->hp_detect)
3797 continue; /* already has an unsol event */
3799 pinctl = snd_hda_codec_read(codec, nid, 0,
3800 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3801 /* outputs are only ports capable of power management
3802 * any attempts on powering down a input port cause the
3803 * referenced VREF to act quirky.
3805 if (pinctl & AC_PINCTL_IN_EN)
3807 def_conf = snd_hda_codec_read(codec, nid, 0,
3808 AC_VERB_GET_CONFIG_DEFAULT, 0);
3809 def_conf = get_defcfg_connect(def_conf);
3810 /* skip any ports that don't have jacks since presence
3811 * detection is useless */
3812 if (def_conf != AC_JACK_PORT_COMPLEX) {
3813 if (def_conf != AC_JACK_PORT_NONE)
3814 stac_toggle_power_map(codec, nid, 1);
3817 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3818 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3821 stac92xx_power_down(codec);
3825 static void stac92xx_free(struct hda_codec *codec)
3827 struct sigmatel_spec *spec = codec->spec;
3833 if (spec->kctl_alloc) {
3834 for (i = 0; i < spec->num_kctl_used; i++)
3835 kfree(spec->kctl_alloc[i].name);
3836 kfree(spec->kctl_alloc);
3839 if (spec->bios_pin_configs)
3840 kfree(spec->bios_pin_configs);
3843 snd_hda_detach_beep_device(codec);
3846 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3849 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3850 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3852 if (pin_ctl & AC_PINCTL_IN_EN) {
3854 * we need to check the current set-up direction of
3855 * shared input pins since they can be switched via
3856 * "xxx as Output" mixer switch
3858 struct sigmatel_spec *spec = codec->spec;
3859 struct auto_pin_cfg *cfg = &spec->autocfg;
3860 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3861 spec->line_switch) ||
3862 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3867 /* if setting pin direction bits, clear the current
3868 direction bits first */
3869 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3870 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3872 snd_hda_codec_write_cache(codec, nid, 0,
3873 AC_VERB_SET_PIN_WIDGET_CONTROL,
3877 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3880 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3881 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3882 snd_hda_codec_write_cache(codec, nid, 0,
3883 AC_VERB_SET_PIN_WIDGET_CONTROL,
3887 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3891 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3893 unsigned int pinctl;
3894 pinctl = snd_hda_codec_read(codec, nid, 0,
3895 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3896 if (pinctl & AC_PINCTL_IN_EN)
3897 return 0; /* mic- or line-input */
3899 return 1; /* HP-output */
3904 /* return non-zero if the hp-pin of the given array index isn't
3905 * a jack-detection target
3907 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
3909 struct auto_pin_cfg *cfg = &spec->autocfg;
3911 /* ignore sensing of shared line and mic jacks */
3912 if (spec->line_switch &&
3913 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
3915 if (spec->mic_switch &&
3916 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
3918 /* ignore if the pin is set as line-out */
3919 if (cfg->hp_pins[i] == spec->hp_switch)
3924 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3926 struct sigmatel_spec *spec = codec->spec;
3927 struct auto_pin_cfg *cfg = &spec->autocfg;
3931 if (spec->gpio_mute)
3932 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3933 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3935 for (i = 0; i < cfg->hp_outs; i++) {
3938 if (no_hp_sensing(spec, i))
3940 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3944 /* disable lineouts */
3945 if (spec->hp_switch)
3946 stac92xx_reset_pinctl(codec, spec->hp_switch,
3948 for (i = 0; i < cfg->line_outs; i++)
3949 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3951 for (i = 0; i < cfg->speaker_outs; i++)
3952 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3954 if (spec->eapd_mask && spec->eapd_switch)
3955 stac_gpio_set(codec, spec->gpio_mask,
3956 spec->gpio_dir, spec->gpio_data &
3959 /* enable lineouts */
3960 if (spec->hp_switch)
3961 stac92xx_set_pinctl(codec, spec->hp_switch,
3963 for (i = 0; i < cfg->line_outs; i++)
3964 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3966 for (i = 0; i < cfg->speaker_outs; i++)
3967 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3969 if (spec->eapd_mask && spec->eapd_switch)
3970 stac_gpio_set(codec, spec->gpio_mask,
3971 spec->gpio_dir, spec->gpio_data |
3974 /* toggle hp outs */
3975 for (i = 0; i < cfg->hp_outs; i++) {
3976 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
3977 if (no_hp_sensing(spec, i))
3980 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
3982 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
3986 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3989 struct sigmatel_spec *spec = codec->spec;
3990 unsigned int idx, val;
3992 for (idx = 0; idx < spec->num_pwrs; idx++) {
3993 if (spec->pwr_nids[idx] == nid)
3996 if (idx >= spec->num_pwrs)
3999 /* several codecs have two power down bits */
4000 if (spec->pwr_mapping)
4001 idx = spec->pwr_mapping[idx];
4005 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4011 /* power down unused output ports */
4012 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4015 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4017 stac_toggle_power_map(codec, nid, get_hp_pin_presence(codec, nid));
4020 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4022 struct sigmatel_spec *spec = codec->spec;
4023 int idx = res >> 26 & 0x0f;
4025 switch ((res >> 26) & 0x70) {
4027 stac92xx_hp_detect(codec, res);
4029 case STAC_PWR_EVENT:
4030 if (spec->num_pwrs > 0)
4031 stac92xx_pin_sense(codec, idx);
4033 case STAC_VREF_EVENT: {
4034 int data = snd_hda_codec_read(codec, codec->afg, 0,
4035 AC_VERB_GET_GPIO_DATA, 0);
4036 /* toggle VREF state based on GPIOx status */
4037 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4038 !!(data & (1 << idx)));
4044 #ifdef SND_HDA_NEEDS_RESUME
4045 static int stac92xx_resume(struct hda_codec *codec)
4047 struct sigmatel_spec *spec = codec->spec;
4049 stac92xx_set_config_regs(codec);
4050 snd_hda_sequence_write(codec, spec->init);
4051 stac_gpio_set(codec, spec->gpio_mask,
4052 spec->gpio_dir, spec->gpio_data);
4053 snd_hda_codec_resume_amp(codec);
4054 snd_hda_codec_resume_cache(codec);
4055 /* power down inactive DACs */
4057 stac92xx_power_down(codec);
4058 /* invoke unsolicited event to reset the HP state */
4059 if (spec->hp_detect)
4060 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4065 static struct hda_codec_ops stac92xx_patch_ops = {
4066 .build_controls = stac92xx_build_controls,
4067 .build_pcms = stac92xx_build_pcms,
4068 .init = stac92xx_init,
4069 .free = stac92xx_free,
4070 .unsol_event = stac92xx_unsol_event,
4071 #ifdef SND_HDA_NEEDS_RESUME
4072 .resume = stac92xx_resume,
4076 static int patch_stac9200(struct hda_codec *codec)
4078 struct sigmatel_spec *spec;
4081 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4086 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4087 spec->pin_nids = stac9200_pin_nids;
4088 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4091 if (spec->board_config < 0) {
4092 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4093 err = stac92xx_save_bios_config_regs(codec);
4095 stac92xx_free(codec);
4098 spec->pin_configs = spec->bios_pin_configs;
4100 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4101 stac92xx_set_config_regs(codec);
4104 spec->multiout.max_channels = 2;
4105 spec->multiout.num_dacs = 1;
4106 spec->multiout.dac_nids = stac9200_dac_nids;
4107 spec->adc_nids = stac9200_adc_nids;
4108 spec->mux_nids = stac9200_mux_nids;
4109 spec->num_muxes = 1;
4110 spec->num_dmics = 0;
4114 if (spec->board_config == STAC_9200_GATEWAY ||
4115 spec->board_config == STAC_9200_OQO)
4116 spec->init = stac9200_eapd_init;
4118 spec->init = stac9200_core_init;
4119 spec->mixer = stac9200_mixer;
4121 if (spec->board_config == STAC_9200_PANASONIC) {
4122 spec->gpio_mask = spec->gpio_dir = 0x09;
4123 spec->gpio_data = 0x00;
4126 err = stac9200_parse_auto_config(codec);
4128 stac92xx_free(codec);
4132 codec->patch_ops = stac92xx_patch_ops;
4137 static int patch_stac925x(struct hda_codec *codec)
4139 struct sigmatel_spec *spec;
4142 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4147 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4148 spec->pin_nids = stac925x_pin_nids;
4149 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4153 if (spec->board_config < 0) {
4154 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4155 "using BIOS defaults\n");
4156 err = stac92xx_save_bios_config_regs(codec);
4158 stac92xx_free(codec);
4161 spec->pin_configs = spec->bios_pin_configs;
4162 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4163 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4164 stac92xx_set_config_regs(codec);
4167 spec->multiout.max_channels = 2;
4168 spec->multiout.num_dacs = 1;
4169 spec->multiout.dac_nids = stac925x_dac_nids;
4170 spec->adc_nids = stac925x_adc_nids;
4171 spec->mux_nids = stac925x_mux_nids;
4172 spec->num_muxes = 1;
4175 switch (codec->vendor_id) {
4176 case 0x83847632: /* STAC9202 */
4177 case 0x83847633: /* STAC9202D */
4178 case 0x83847636: /* STAC9251 */
4179 case 0x83847637: /* STAC9251D */
4180 spec->num_dmics = STAC925X_NUM_DMICS;
4181 spec->dmic_nids = stac925x_dmic_nids;
4182 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4183 spec->dmux_nids = stac925x_dmux_nids;
4186 spec->num_dmics = 0;
4190 spec->init = stac925x_core_init;
4191 spec->mixer = stac925x_mixer;
4193 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4195 if (spec->board_config < 0) {
4196 printk(KERN_WARNING "hda_codec: No auto-config is "
4197 "available, default to model=ref\n");
4198 spec->board_config = STAC_925x_REF;
4204 stac92xx_free(codec);
4208 codec->patch_ops = stac92xx_patch_ops;
4213 static struct hda_input_mux stac92hd73xx_dmux = {
4216 { "Analog Inputs", 0x0b },
4217 { "Digital Mic 1", 0x09 },
4218 { "Digital Mic 2", 0x0a },
4223 static int patch_stac92hd73xx(struct hda_codec *codec)
4225 struct sigmatel_spec *spec;
4226 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4229 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4234 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4235 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4236 spec->pin_nids = stac92hd73xx_pin_nids;
4237 spec->board_config = snd_hda_check_board_config(codec,
4238 STAC_92HD73XX_MODELS,
4239 stac92hd73xx_models,
4240 stac92hd73xx_cfg_tbl);
4242 if (spec->board_config < 0) {
4243 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4244 " STAC92HD73XX, using BIOS defaults\n");
4245 err = stac92xx_save_bios_config_regs(codec);
4247 stac92xx_free(codec);
4250 spec->pin_configs = spec->bios_pin_configs;
4252 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4253 stac92xx_set_config_regs(codec);
4256 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4257 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4259 if (spec->multiout.num_dacs < 0) {
4260 printk(KERN_WARNING "hda_codec: Could not determine "
4261 "number of channels defaulting to DAC count\n");
4262 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4265 switch (spec->multiout.num_dacs) {
4266 case 0x3: /* 6 Channel */
4267 spec->multiout.hp_nid = 0x17;
4268 spec->mixer = stac92hd73xx_6ch_mixer;
4269 spec->init = stac92hd73xx_6ch_core_init;
4271 case 0x4: /* 8 Channel */
4272 spec->multiout.hp_nid = 0x18;
4273 spec->mixer = stac92hd73xx_8ch_mixer;
4274 spec->init = stac92hd73xx_8ch_core_init;
4276 case 0x5: /* 10 Channel */
4277 spec->multiout.hp_nid = 0x19;
4278 spec->mixer = stac92hd73xx_10ch_mixer;
4279 spec->init = stac92hd73xx_10ch_core_init;
4282 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4283 spec->aloopback_mask = 0x01;
4284 spec->aloopback_shift = 8;
4286 spec->digbeep_nid = 0x1c;
4287 spec->mux_nids = stac92hd73xx_mux_nids;
4288 spec->adc_nids = stac92hd73xx_adc_nids;
4289 spec->dmic_nids = stac92hd73xx_dmic_nids;
4290 spec->dmux_nids = stac92hd73xx_dmux_nids;
4291 spec->smux_nids = stac92hd73xx_smux_nids;
4292 spec->amp_nids = stac92hd73xx_amp_nids;
4293 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4295 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4296 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4297 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4298 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4299 sizeof(stac92hd73xx_dmux));
4301 switch (spec->board_config) {
4303 spec->init = dell_eq_core_init;
4305 case STAC_DELL_M6_AMIC:
4306 case STAC_DELL_M6_DMIC:
4307 case STAC_DELL_M6_BOTH:
4308 spec->num_smuxes = 0;
4309 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4310 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4311 spec->eapd_switch = 0;
4313 spec->multiout.hp_nid = 0; /* dual HPs */
4316 spec->init = dell_m6_core_init;
4317 switch (spec->board_config) {
4318 case STAC_DELL_M6_AMIC: /* Analog Mics */
4319 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4320 spec->num_dmics = 0;
4321 spec->private_dimux.num_items = 1;
4323 case STAC_DELL_M6_DMIC: /* Digital Mics */
4324 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4325 spec->num_dmics = 1;
4326 spec->private_dimux.num_items = 2;
4328 case STAC_DELL_M6_BOTH: /* Both */
4329 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4330 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4331 spec->num_dmics = 1;
4332 spec->private_dimux.num_items = 2;
4337 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4338 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4339 spec->eapd_switch = 1;
4341 if (spec->board_config > STAC_92HD73XX_REF) {
4342 /* GPIO0 High = Enable EAPD */
4343 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4344 spec->gpio_data = 0x01;
4346 spec->dinput_mux = &spec->private_dimux;
4348 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4349 spec->pwr_nids = stac92hd73xx_pwr_nids;
4351 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
4354 if (spec->board_config < 0) {
4355 printk(KERN_WARNING "hda_codec: No auto-config is "
4356 "available, default to model=ref\n");
4357 spec->board_config = STAC_92HD73XX_REF;
4364 stac92xx_free(codec);
4368 if (spec->board_config == STAC_92HD73XX_NO_JD)
4369 spec->hp_detect = 0;
4371 codec->patch_ops = stac92xx_patch_ops;
4376 static struct hda_input_mux stac92hd83xxx_dmux = {
4379 { "Analog Inputs", 0x03 },
4380 { "Digital Mic 1", 0x04 },
4381 { "Digital Mic 2", 0x05 },
4385 static int patch_stac92hd83xxx(struct hda_codec *codec)
4387 struct sigmatel_spec *spec;
4390 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4395 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
4396 spec->mono_nid = 0x19;
4397 spec->digbeep_nid = 0x21;
4398 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4399 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4400 spec->adc_nids = stac92hd83xxx_adc_nids;
4401 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4402 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4403 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4404 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4406 spec->init = stac92hd83xxx_core_init;
4407 switch (codec->vendor_id) {
4409 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4413 spec->init++; /* switch to config #2 */
4414 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4417 spec->mixer = stac92hd83xxx_mixer;
4418 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4419 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4420 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4421 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4422 spec->dinput_mux = &stac92hd83xxx_dmux;
4423 spec->pin_nids = stac92hd83xxx_pin_nids;
4424 spec->board_config = snd_hda_check_board_config(codec,
4425 STAC_92HD83XXX_MODELS,
4426 stac92hd83xxx_models,
4427 stac92hd83xxx_cfg_tbl);
4429 if (spec->board_config < 0) {
4430 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4431 " STAC92HD83XXX, using BIOS defaults\n");
4432 err = stac92xx_save_bios_config_regs(codec);
4434 stac92xx_free(codec);
4437 spec->pin_configs = spec->bios_pin_configs;
4439 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4440 stac92xx_set_config_regs(codec);
4443 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4445 if (spec->board_config < 0) {
4446 printk(KERN_WARNING "hda_codec: No auto-config is "
4447 "available, default to model=ref\n");
4448 spec->board_config = STAC_92HD83XXX_REF;
4455 stac92xx_free(codec);
4459 codec->patch_ops = stac92xx_patch_ops;
4464 #ifdef SND_HDA_NEEDS_RESUME
4465 static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4467 struct sigmatel_spec *spec = codec->spec;
4469 snd_hda_codec_write_cache(codec, codec->afg, 0,
4470 AC_VERB_SET_POWER_STATE, pwr);
4473 for (i = 0; i < spec->num_adcs; i++) {
4474 snd_hda_codec_write_cache(codec,
4475 spec->adc_nids[i], 0,
4476 AC_VERB_SET_POWER_STATE, pwr);
4480 static int stac92hd71xx_resume(struct hda_codec *codec)
4482 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4483 return stac92xx_resume(codec);
4486 static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4488 struct sigmatel_spec *spec = codec->spec;
4490 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4491 if (spec->eapd_mask)
4492 stac_gpio_set(codec, spec->gpio_mask,
4493 spec->gpio_dir, spec->gpio_data &
4500 static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4501 .build_controls = stac92xx_build_controls,
4502 .build_pcms = stac92xx_build_pcms,
4503 .init = stac92xx_init,
4504 .free = stac92xx_free,
4505 .unsol_event = stac92xx_unsol_event,
4506 #ifdef SND_HDA_NEEDS_RESUME
4507 .resume = stac92hd71xx_resume,
4508 .suspend = stac92hd71xx_suspend,
4512 static struct hda_input_mux stac92hd71bxx_dmux = {
4515 { "Analog Inputs", 0x00 },
4517 { "Digital Mic 1", 0x02 },
4518 { "Digital Mic 2", 0x03 },
4522 static int patch_stac92hd71bxx(struct hda_codec *codec)
4524 struct sigmatel_spec *spec;
4527 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4532 codec->patch_ops = stac92xx_patch_ops;
4533 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
4534 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4535 spec->pin_nids = stac92hd71bxx_pin_nids;
4536 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4537 sizeof(stac92hd71bxx_dmux));
4538 spec->board_config = snd_hda_check_board_config(codec,
4539 STAC_92HD71BXX_MODELS,
4540 stac92hd71bxx_models,
4541 stac92hd71bxx_cfg_tbl);
4543 if (spec->board_config < 0) {
4544 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4545 " STAC92HD71BXX, using BIOS defaults\n");
4546 err = stac92xx_save_bios_config_regs(codec);
4548 stac92xx_free(codec);
4551 spec->pin_configs = spec->bios_pin_configs;
4553 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4554 stac92xx_set_config_regs(codec);
4557 if (spec->board_config > STAC_92HD71BXX_REF) {
4559 spec->gpio_mask = 0x01;
4560 spec->gpio_dir = 0x01;
4561 spec->gpio_data = 0x01;
4564 switch (codec->vendor_id) {
4565 case 0x111d76b6: /* 4 Port without Analog Mixer */
4567 case 0x111d76b4: /* 6 Port without Analog Mixer */
4569 spec->mixer = stac92hd71bxx_mixer;
4570 spec->init = stac92hd71bxx_core_init;
4571 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4573 case 0x111d7608: /* 5 Port with Analog Mixer */
4574 switch (spec->board_config) {
4576 /* Enable VREF power saving on GPIO1 detect */
4577 snd_hda_codec_write_cache(codec, codec->afg, 0,
4578 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4579 snd_hda_codec_write_cache(codec, codec->afg, 0,
4580 AC_VERB_SET_UNSOLICITED_ENABLE,
4581 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4582 spec->gpio_mask |= 0x02;
4585 if ((codec->revision_id & 0xf) == 0 ||
4586 (codec->revision_id & 0xf) == 1) {
4587 #ifdef SND_HDA_NEEDS_RESUME
4588 codec->patch_ops = stac92hd71bxx_patch_ops;
4590 spec->stream_delay = 40; /* 40 milliseconds */
4593 /* no output amps */
4595 spec->mixer = stac92hd71bxx_analog_mixer;
4596 spec->dinput_mux = &spec->private_dimux;
4599 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4600 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4602 case 0x111d7603: /* 6 Port with Analog Mixer */
4603 if ((codec->revision_id & 0xf) == 1) {
4604 #ifdef SND_HDA_NEEDS_RESUME
4605 codec->patch_ops = stac92hd71bxx_patch_ops;
4607 spec->stream_delay = 40; /* 40 milliseconds */
4610 /* no output amps */
4614 spec->dinput_mux = &spec->private_dimux;
4615 spec->mixer = stac92hd71bxx_analog_mixer;
4616 spec->init = stac92hd71bxx_analog_core_init;
4617 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4620 spec->aloopback_mask = 0x50;
4621 spec->aloopback_shift = 0;
4623 spec->powerdown_adcs = 1;
4624 spec->digbeep_nid = 0x26;
4625 spec->mux_nids = stac92hd71bxx_mux_nids;
4626 spec->adc_nids = stac92hd71bxx_adc_nids;
4627 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4628 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4629 spec->smux_nids = stac92hd71bxx_smux_nids;
4630 spec->pwr_nids = stac92hd71bxx_pwr_nids;
4632 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4633 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
4635 switch (spec->board_config) {
4637 /* enable internal microphone */
4638 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4639 stac92xx_auto_set_pinctl(codec, 0x0e,
4640 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
4642 case STAC_DELL_M4_2:
4643 spec->num_dmics = 0;
4644 spec->num_smuxes = 0;
4645 spec->num_dmuxes = 0;
4647 case STAC_DELL_M4_1:
4648 case STAC_DELL_M4_3:
4649 spec->num_dmics = 1;
4650 spec->num_smuxes = 0;
4651 spec->num_dmuxes = 0;
4654 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4655 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4656 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4659 spec->multiout.num_dacs = 1;
4660 spec->multiout.hp_nid = 0x11;
4661 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4662 if (spec->dinput_mux)
4663 spec->private_dimux.num_items +=
4665 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
4667 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4669 if (spec->board_config < 0) {
4670 printk(KERN_WARNING "hda_codec: No auto-config is "
4671 "available, default to model=ref\n");
4672 spec->board_config = STAC_92HD71BXX_REF;
4679 stac92xx_free(codec);
4686 static int patch_stac922x(struct hda_codec *codec)
4688 struct sigmatel_spec *spec;
4691 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4696 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
4697 spec->pin_nids = stac922x_pin_nids;
4698 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4701 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
4702 spec->gpio_mask = spec->gpio_dir = 0x03;
4703 spec->gpio_data = 0x03;
4704 /* Intel Macs have all same PCI SSID, so we need to check
4705 * codec SSID to distinguish the exact models
4707 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
4708 switch (codec->subsystem_id) {
4711 spec->board_config = STAC_INTEL_MAC_V1;
4715 spec->board_config = STAC_INTEL_MAC_V2;
4723 spec->board_config = STAC_INTEL_MAC_V3;
4727 spec->board_config = STAC_INTEL_MAC_V4;
4731 spec->board_config = STAC_INTEL_MAC_V5;
4734 spec->board_config = STAC_INTEL_MAC_V3;
4740 if (spec->board_config < 0) {
4741 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4742 "using BIOS defaults\n");
4743 err = stac92xx_save_bios_config_regs(codec);
4745 stac92xx_free(codec);
4748 spec->pin_configs = spec->bios_pin_configs;
4749 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
4750 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4751 stac92xx_set_config_regs(codec);
4754 spec->adc_nids = stac922x_adc_nids;
4755 spec->mux_nids = stac922x_mux_nids;
4756 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
4757 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
4758 spec->num_dmics = 0;
4761 spec->init = stac922x_core_init;
4762 spec->mixer = stac922x_mixer;
4764 spec->multiout.dac_nids = spec->dac_nids;
4766 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
4768 if (spec->board_config < 0) {
4769 printk(KERN_WARNING "hda_codec: No auto-config is "
4770 "available, default to model=ref\n");
4771 spec->board_config = STAC_D945_REF;
4777 stac92xx_free(codec);
4781 codec->patch_ops = stac92xx_patch_ops;
4783 /* Fix Mux capture level; max to 2 */
4784 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4785 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4786 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4787 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4788 (0 << AC_AMPCAP_MUTE_SHIFT));
4793 static int patch_stac927x(struct hda_codec *codec)
4795 struct sigmatel_spec *spec;
4798 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4803 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
4804 spec->pin_nids = stac927x_pin_nids;
4805 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4809 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4810 if (spec->board_config < 0)
4811 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4812 "STAC927x, using BIOS defaults\n");
4813 err = stac92xx_save_bios_config_regs(codec);
4815 stac92xx_free(codec);
4818 spec->pin_configs = spec->bios_pin_configs;
4820 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4821 stac92xx_set_config_regs(codec);
4824 spec->digbeep_nid = 0x23;
4825 spec->adc_nids = stac927x_adc_nids;
4826 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4827 spec->mux_nids = stac927x_mux_nids;
4828 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
4829 spec->smux_nids = stac927x_smux_nids;
4830 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
4831 spec->spdif_labels = stac927x_spdif_labels;
4832 spec->dac_list = stac927x_dac_nids;
4833 spec->multiout.dac_nids = spec->dac_nids;
4835 switch (spec->board_config) {
4838 /* GPIO0 High = Enable EAPD */
4839 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
4840 spec->gpio_data = 0x01;
4841 spec->num_dmics = 0;
4843 spec->init = d965_core_init;
4844 spec->mixer = stac927x_mixer;
4846 case STAC_DELL_BIOS:
4847 switch (codec->subsystem_id) {
4850 /* correct the device field to SPDIF out */
4851 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4854 /* configure the analog microphone on some laptops */
4855 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
4856 /* correct the front output jack as a hp out */
4857 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
4858 /* correct the front input jack as a mic */
4859 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4862 /* GPIO2 High = Enable EAPD */
4863 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
4864 spec->gpio_data = 0x04;
4865 spec->dmic_nids = stac927x_dmic_nids;
4866 spec->num_dmics = STAC927X_NUM_DMICS;
4868 spec->init = d965_core_init;
4869 spec->mixer = stac927x_mixer;
4870 spec->dmux_nids = stac927x_dmux_nids;
4871 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
4874 if (spec->board_config > STAC_D965_REF) {
4875 /* GPIO0 High = Enable EAPD */
4876 spec->eapd_mask = spec->gpio_mask = 0x01;
4877 spec->gpio_dir = spec->gpio_data = 0x01;
4879 spec->num_dmics = 0;
4881 spec->init = stac927x_core_init;
4882 spec->mixer = stac927x_mixer;
4886 spec->aloopback_mask = 0x40;
4887 spec->aloopback_shift = 0;
4888 spec->eapd_switch = 1;
4890 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
4892 if (spec->board_config < 0) {
4893 printk(KERN_WARNING "hda_codec: No auto-config is "
4894 "available, default to model=ref\n");
4895 spec->board_config = STAC_D965_REF;
4901 stac92xx_free(codec);
4905 codec->patch_ops = stac92xx_patch_ops;
4909 * The STAC927x seem to require fairly long delays for certain
4910 * command sequences. With too short delays (even if the answer
4911 * is set to RIRB properly), it results in the silence output
4912 * on some hardwares like Dell.
4914 * The below flag enables the longer delay (see get_response
4917 codec->bus->needs_damn_long_delay = 1;
4919 /* no jack detecion for ref-no-jd model */
4920 if (spec->board_config == STAC_D965_REF_NO_JD)
4921 spec->hp_detect = 0;
4926 static int patch_stac9205(struct hda_codec *codec)
4928 struct sigmatel_spec *spec;
4931 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4936 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
4937 spec->pin_nids = stac9205_pin_nids;
4938 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4942 if (spec->board_config < 0) {
4943 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4944 err = stac92xx_save_bios_config_regs(codec);
4946 stac92xx_free(codec);
4949 spec->pin_configs = spec->bios_pin_configs;
4951 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4952 stac92xx_set_config_regs(codec);
4955 spec->digbeep_nid = 0x23;
4956 spec->adc_nids = stac9205_adc_nids;
4957 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
4958 spec->mux_nids = stac9205_mux_nids;
4959 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
4960 spec->smux_nids = stac9205_smux_nids;
4961 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
4962 spec->dmic_nids = stac9205_dmic_nids;
4963 spec->num_dmics = STAC9205_NUM_DMICS;
4964 spec->dmux_nids = stac9205_dmux_nids;
4965 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
4968 spec->init = stac9205_core_init;
4969 spec->mixer = stac9205_mixer;
4971 spec->aloopback_mask = 0x40;
4972 spec->aloopback_shift = 0;
4973 spec->eapd_switch = 1;
4974 spec->multiout.dac_nids = spec->dac_nids;
4976 switch (spec->board_config){
4977 case STAC_9205_DELL_M43:
4978 /* Enable SPDIF in/out */
4979 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4980 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
4982 /* Enable unsol response for GPIO4/Dock HP connection */
4983 snd_hda_codec_write_cache(codec, codec->afg, 0,
4984 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4985 snd_hda_codec_write_cache(codec, codec->afg, 0,
4986 AC_VERB_SET_UNSOLICITED_ENABLE,
4987 (AC_USRSP_EN | STAC_HP_EVENT));
4989 spec->gpio_dir = 0x0b;
4990 spec->eapd_mask = 0x01;
4991 spec->gpio_mask = 0x1b;
4992 spec->gpio_mute = 0x10;
4993 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
4996 spec->gpio_data = 0x01;
4999 /* SPDIF-In enabled */
5002 /* GPIO0 High = EAPD */
5003 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5004 spec->gpio_data = 0x01;
5008 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5010 if (spec->board_config < 0) {
5011 printk(KERN_WARNING "hda_codec: No auto-config is "
5012 "available, default to model=ref\n");
5013 spec->board_config = STAC_9205_REF;
5019 stac92xx_free(codec);
5023 codec->patch_ops = stac92xx_patch_ops;
5032 /* static config for Sony VAIO FE550G and Sony VAIO AR */
5033 static hda_nid_t vaio_dacs[] = { 0x2 };
5034 #define VAIO_HP_DAC 0x5
5035 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5036 static hda_nid_t vaio_mux_nids[] = { 0x15 };
5038 static struct hda_input_mux vaio_mux = {
5041 /* { "HP", 0x0 }, */
5042 { "Mic Jack", 0x1 },
5043 { "Internal Mic", 0x2 },
5048 static struct hda_verb vaio_init[] = {
5049 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5050 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
5051 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5052 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5053 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5054 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5055 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5056 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5057 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5058 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5059 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5060 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5064 static struct hda_verb vaio_ar_init[] = {
5065 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5066 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5067 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5068 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5069 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5070 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5071 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5072 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5073 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5074 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5075 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5076 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5081 /* bind volumes of both NID 0x02 and 0x05 */
5082 static struct hda_bind_ctls vaio_bind_master_vol = {
5083 .ops = &snd_hda_bind_vol,
5085 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5086 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5091 /* bind volumes of both NID 0x02 and 0x05 */
5092 static struct hda_bind_ctls vaio_bind_master_sw = {
5093 .ops = &snd_hda_bind_sw,
5095 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5096 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5101 static struct snd_kcontrol_new vaio_mixer[] = {
5102 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5103 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
5104 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5105 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5106 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5108 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5109 .name = "Capture Source",
5111 .info = stac92xx_mux_enum_info,
5112 .get = stac92xx_mux_enum_get,
5113 .put = stac92xx_mux_enum_put,
5118 static struct snd_kcontrol_new vaio_ar_mixer[] = {
5119 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5120 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
5121 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5122 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5123 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5124 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5125 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5127 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5128 .name = "Capture Source",
5130 .info = stac92xx_mux_enum_info,
5131 .get = stac92xx_mux_enum_get,
5132 .put = stac92xx_mux_enum_put,
5137 static struct hda_codec_ops stac9872_patch_ops = {
5138 .build_controls = stac92xx_build_controls,
5139 .build_pcms = stac92xx_build_pcms,
5140 .init = stac92xx_init,
5141 .free = stac92xx_free,
5142 #ifdef SND_HDA_NEEDS_RESUME
5143 .resume = stac92xx_resume,
5147 static int stac9872_vaio_init(struct hda_codec *codec)
5151 err = stac92xx_init(codec);
5154 if (codec->patch_ops.unsol_event)
5155 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5159 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5161 if (get_hp_pin_presence(codec, 0x0a)) {
5162 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5163 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5165 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5166 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5170 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5172 switch (res >> 26) {
5174 stac9872_vaio_hp_detect(codec, res);
5179 static struct hda_codec_ops stac9872_vaio_patch_ops = {
5180 .build_controls = stac92xx_build_controls,
5181 .build_pcms = stac92xx_build_pcms,
5182 .init = stac9872_vaio_init,
5183 .free = stac92xx_free,
5184 .unsol_event = stac9872_vaio_unsol_event,
5186 .resume = stac92xx_resume,
5190 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5192 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5194 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5196 /* AR Series. id=0x83847664 and subsys=104D1300 */
5201 static const char *stac9872_models[STAC_9872_MODELS] = {
5202 [CXD9872RD_VAIO] = "vaio",
5203 [CXD9872AKD_VAIO] = "vaio-ar",
5206 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5207 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5208 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5209 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
5210 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
5214 static int patch_stac9872(struct hda_codec *codec)
5216 struct sigmatel_spec *spec;
5219 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5222 if (board_config < 0)
5223 /* unknown config, let generic-parser do its job... */
5224 return snd_hda_parse_generic_codec(codec);
5226 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5231 switch (board_config) {
5232 case CXD9872RD_VAIO:
5233 case STAC9872AK_VAIO:
5234 case STAC9872K_VAIO:
5235 spec->mixer = vaio_mixer;
5236 spec->init = vaio_init;
5237 spec->multiout.max_channels = 2;
5238 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5239 spec->multiout.dac_nids = vaio_dacs;
5240 spec->multiout.hp_nid = VAIO_HP_DAC;
5241 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5242 spec->adc_nids = vaio_adcs;
5244 spec->input_mux = &vaio_mux;
5245 spec->mux_nids = vaio_mux_nids;
5246 codec->patch_ops = stac9872_vaio_patch_ops;
5249 case CXD9872AKD_VAIO:
5250 spec->mixer = vaio_ar_mixer;
5251 spec->init = vaio_ar_init;
5252 spec->multiout.max_channels = 2;
5253 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5254 spec->multiout.dac_nids = vaio_dacs;
5255 spec->multiout.hp_nid = VAIO_HP_DAC;
5256 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5258 spec->adc_nids = vaio_adcs;
5259 spec->input_mux = &vaio_mux;
5260 spec->mux_nids = vaio_mux_nids;
5261 codec->patch_ops = stac9872_patch_ops;
5272 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5273 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5274 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5275 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5276 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5277 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5278 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5279 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5280 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5281 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5282 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5283 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5284 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5285 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5286 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5287 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5288 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5289 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5290 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5291 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5292 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5293 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5294 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5295 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5296 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5297 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5298 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5299 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5300 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5301 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5302 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5303 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5304 /* The following does not take into account .id=0x83847661 when subsys =
5305 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5306 * currently not fully supported.
5308 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5309 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5310 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5311 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5312 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5313 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5314 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5315 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5316 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5317 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5318 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5319 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5320 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5321 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5322 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5323 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5324 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5325 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5326 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5327 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5328 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5329 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5330 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5331 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5332 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5333 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },