2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include <sound/asoundef.h>
33 #include <sound/jack.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
36 #include "hda_patch.h"
39 #define STAC_INSERT_EVENT 0x10
40 #define STAC_PWR_EVENT 0x20
41 #define STAC_HP_EVENT 0x30
42 #define STAC_VREF_EVENT 0x40
106 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
107 * is given, one of the above models will be
108 * chosen according to the subsystem id. */
109 /* for backward compatibility */
133 struct sigmatel_event {
138 struct sigmatel_jack {
141 struct snd_jack *jack;
144 struct sigmatel_spec {
145 struct snd_kcontrol_new *mixers[4];
146 unsigned int num_mixers;
149 unsigned int surr_switch: 1;
150 unsigned int line_switch: 1;
151 unsigned int mic_switch: 1;
152 unsigned int alt_switch: 1;
153 unsigned int hp_detect: 1;
154 unsigned int spdif_mute: 1;
157 unsigned int eapd_mask;
158 unsigned int gpio_mask;
159 unsigned int gpio_dir;
160 unsigned int gpio_data;
161 unsigned int gpio_mute;
164 unsigned int stream_delay;
166 /* analog loopback */
167 unsigned char aloopback_mask;
168 unsigned char aloopback_shift;
170 /* power management */
171 unsigned int num_pwrs;
172 unsigned int *pwr_mapping;
177 struct snd_array jacks;
180 struct snd_array events;
183 struct hda_input_mux *mono_mux;
184 struct hda_input_mux *amp_mux;
185 unsigned int cur_mmux;
186 struct hda_multi_out multiout;
187 hda_nid_t dac_nids[5];
191 unsigned int num_adcs;
193 unsigned int num_muxes;
194 hda_nid_t *dmic_nids;
195 unsigned int num_dmics;
196 hda_nid_t *dmux_nids;
197 unsigned int num_dmuxes;
198 hda_nid_t *smux_nids;
199 unsigned int num_smuxes;
200 const char **spdif_labels;
202 hda_nid_t dig_in_nid;
204 hda_nid_t anabeep_nid;
205 hda_nid_t digbeep_nid;
209 unsigned int num_pins;
210 unsigned int *pin_configs;
211 unsigned int *bios_pin_configs;
213 /* codec specific stuff */
214 struct hda_verb *init;
215 struct snd_kcontrol_new *mixer;
218 struct hda_input_mux *dinput_mux;
219 unsigned int cur_dmux[2];
220 struct hda_input_mux *input_mux;
221 unsigned int cur_mux[3];
222 struct hda_input_mux *sinput_mux;
223 unsigned int cur_smux[2];
224 unsigned int cur_amux;
226 unsigned int num_amps;
227 unsigned int powerdown_adcs;
230 unsigned int io_switch[2];
231 unsigned int clfe_swap;
232 unsigned int hp_switch;
233 unsigned int aloopback;
235 struct hda_pcm pcm_rec[2]; /* PCM information */
237 /* dynamic controls and input_mux */
238 struct auto_pin_cfg autocfg;
239 struct snd_array kctls;
240 struct hda_input_mux private_dimux;
241 struct hda_input_mux private_imux;
242 struct hda_input_mux private_smux;
243 struct hda_input_mux private_amp_mux;
244 struct hda_input_mux private_mono_mux;
247 static hda_nid_t stac9200_adc_nids[1] = {
251 static hda_nid_t stac9200_mux_nids[1] = {
255 static hda_nid_t stac9200_dac_nids[1] = {
259 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
260 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
264 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
268 static hda_nid_t stac92hd73xx_adc_nids[2] = {
272 #define DELL_M6_AMP 2
273 static hda_nid_t stac92hd73xx_amp_nids[3] = {
277 #define STAC92HD73XX_NUM_DMICS 2
278 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
282 #define STAC92HD73_DAC_COUNT 5
283 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
284 0x15, 0x16, 0x17, 0x18, 0x19,
287 static hda_nid_t stac92hd73xx_mux_nids[4] = {
288 0x28, 0x29, 0x2a, 0x2b,
291 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
295 static hda_nid_t stac92hd73xx_smux_nids[2] = {
299 #define STAC92HD83XXX_NUM_DMICS 2
300 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
304 #define STAC92HD81_DAC_COUNT 2
305 #define STAC92HD83_DAC_COUNT 3
306 static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
310 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
314 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
318 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
322 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
326 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
327 0x03, 0x0c, 0x10, 0x40,
330 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
334 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
338 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
342 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
346 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
350 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
354 #define STAC92HD71BXX_NUM_DMICS 2
355 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
359 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
363 static hda_nid_t stac925x_adc_nids[1] = {
367 static hda_nid_t stac925x_mux_nids[1] = {
371 static hda_nid_t stac925x_dac_nids[1] = {
375 #define STAC925X_NUM_DMICS 1
376 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
380 static hda_nid_t stac925x_dmux_nids[1] = {
384 static hda_nid_t stac922x_adc_nids[2] = {
388 static hda_nid_t stac922x_mux_nids[2] = {
392 static hda_nid_t stac927x_adc_nids[3] = {
396 static hda_nid_t stac927x_mux_nids[3] = {
400 static hda_nid_t stac927x_smux_nids[1] = {
404 static hda_nid_t stac927x_dac_nids[6] = {
405 0x02, 0x03, 0x04, 0x05, 0x06, 0
408 static hda_nid_t stac927x_dmux_nids[1] = {
412 #define STAC927X_NUM_DMICS 2
413 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
417 static const char *stac927x_spdif_labels[5] = {
418 "Digital Playback", "ADAT", "Analog Mux 1",
419 "Analog Mux 2", "Analog Mux 3"
422 static hda_nid_t stac9205_adc_nids[2] = {
426 static hda_nid_t stac9205_mux_nids[2] = {
430 static hda_nid_t stac9205_dmux_nids[1] = {
434 static hda_nid_t stac9205_smux_nids[1] = {
438 #define STAC9205_NUM_DMICS 2
439 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
443 static hda_nid_t stac9200_pin_nids[8] = {
444 0x08, 0x09, 0x0d, 0x0e,
445 0x0f, 0x10, 0x11, 0x12,
448 static hda_nid_t stac925x_pin_nids[8] = {
449 0x07, 0x08, 0x0a, 0x0b,
450 0x0c, 0x0d, 0x10, 0x11,
453 static hda_nid_t stac922x_pin_nids[10] = {
454 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
455 0x0f, 0x10, 0x11, 0x15, 0x1b,
458 static hda_nid_t stac92hd73xx_pin_nids[13] = {
459 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
460 0x0f, 0x10, 0x11, 0x12, 0x13,
464 static hda_nid_t stac92hd83xxx_pin_nids[14] = {
465 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
466 0x0f, 0x10, 0x11, 0x12, 0x13,
467 0x1d, 0x1e, 0x1f, 0x20
469 static hda_nid_t stac92hd71bxx_pin_nids[11] = {
470 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
471 0x0f, 0x14, 0x18, 0x19, 0x1e,
475 static hda_nid_t stac927x_pin_nids[14] = {
476 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
477 0x0f, 0x10, 0x11, 0x12, 0x13,
478 0x14, 0x21, 0x22, 0x23,
481 static hda_nid_t stac9205_pin_nids[12] = {
482 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
483 0x0f, 0x14, 0x16, 0x17, 0x18,
487 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
489 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
490 struct snd_ctl_elem_value *ucontrol)
492 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
493 struct sigmatel_spec *spec = codec->spec;
494 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
496 kcontrol->private_value ^= get_amp_nid(kcontrol);
497 kcontrol->private_value |= nid;
499 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
502 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
503 struct snd_ctl_elem_value *ucontrol)
505 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
506 struct sigmatel_spec *spec = codec->spec;
507 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
509 kcontrol->private_value ^= get_amp_nid(kcontrol);
510 kcontrol->private_value |= nid;
512 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
515 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_info *uinfo)
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 struct sigmatel_spec *spec = codec->spec;
520 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
523 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
524 struct snd_ctl_elem_value *ucontrol)
526 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
527 struct sigmatel_spec *spec = codec->spec;
528 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
530 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
534 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
535 struct snd_ctl_elem_value *ucontrol)
537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
538 struct sigmatel_spec *spec = codec->spec;
539 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
541 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
542 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
545 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
546 struct snd_ctl_elem_info *uinfo)
548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
549 struct sigmatel_spec *spec = codec->spec;
550 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
553 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
554 struct snd_ctl_elem_value *ucontrol)
556 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
557 struct sigmatel_spec *spec = codec->spec;
558 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
560 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
564 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
565 struct snd_ctl_elem_value *ucontrol)
567 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
568 struct sigmatel_spec *spec = codec->spec;
569 struct hda_input_mux *smux = &spec->private_smux;
570 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
574 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
575 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
579 if (spec->spdif_mute) {
581 nid = spec->multiout.dig_out_nid;
583 nid = codec->slave_dig_outs[smux_idx - 1];
584 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
587 nid = spec->multiout.dig_out_nid;
589 nid = codec->slave_dig_outs[smux_idx - 1];
590 /* un/mute SPDIF out */
591 snd_hda_codec_write_cache(codec, nid, 0,
592 AC_VERB_SET_AMP_GAIN_MUTE, val);
597 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 struct sigmatel_spec *spec = codec->spec;
601 return snd_hda_input_mux_info(spec->input_mux, uinfo);
604 static int stac92xx_mux_enum_get(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 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
614 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
617 struct sigmatel_spec *spec = codec->spec;
618 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
620 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
621 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
624 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
625 struct snd_ctl_elem_info *uinfo)
627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
628 struct sigmatel_spec *spec = codec->spec;
629 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
632 static int stac92xx_mono_mux_enum_get(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 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
642 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 struct sigmatel_spec *spec = codec->spec;
648 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
649 spec->mono_nid, &spec->cur_mmux);
652 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_info *uinfo)
655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
656 struct sigmatel_spec *spec = codec->spec;
657 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
660 static int stac92xx_amp_mux_enum_get(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;
666 ucontrol->value.enumerated.item[0] = spec->cur_amux;
670 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
671 struct snd_ctl_elem_value *ucontrol)
673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
674 struct sigmatel_spec *spec = codec->spec;
675 struct snd_kcontrol *ctl =
676 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
680 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
681 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
683 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
687 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
689 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
690 struct snd_ctl_elem_value *ucontrol)
692 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
693 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
694 struct sigmatel_spec *spec = codec->spec;
696 ucontrol->value.integer.value[0] = !!(spec->aloopback &
697 (spec->aloopback_mask << idx));
701 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
702 struct snd_ctl_elem_value *ucontrol)
704 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
705 struct sigmatel_spec *spec = codec->spec;
706 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
707 unsigned int dac_mode;
708 unsigned int val, idx_val;
710 idx_val = spec->aloopback_mask << idx;
711 if (ucontrol->value.integer.value[0])
712 val = spec->aloopback | idx_val;
714 val = spec->aloopback & ~idx_val;
715 if (spec->aloopback == val)
718 spec->aloopback = val;
720 /* Only return the bits defined by the shift value of the
721 * first two bytes of the mask
723 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
724 kcontrol->private_value & 0xFFFF, 0x0);
725 dac_mode >>= spec->aloopback_shift;
727 if (spec->aloopback & idx_val) {
728 snd_hda_power_up(codec);
731 snd_hda_power_down(codec);
732 dac_mode &= ~idx_val;
735 snd_hda_codec_write_cache(codec, codec->afg, 0,
736 kcontrol->private_value >> 16, dac_mode);
741 static struct hda_verb stac9200_core_init[] = {
742 /* set dac0mux for dac converter */
743 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
747 static struct hda_verb stac9200_eapd_init[] = {
748 /* set dac0mux for dac converter */
749 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
750 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
754 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
755 /* set master volume and direct control */
756 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
757 /* setup audio connections */
758 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
759 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
760 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
761 /* setup adcs to point to mixer */
762 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
763 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
764 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
765 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
766 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
767 /* setup import muxs */
768 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
769 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
770 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
771 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
775 static struct hda_verb dell_eq_core_init[] = {
776 /* set master volume to max value without distortion
777 * and direct control */
778 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
779 /* setup audio connections */
780 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
781 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
782 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
783 /* setup adcs to point to mixer */
784 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
785 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
786 /* setup import muxs */
787 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
788 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
789 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
790 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
794 static struct hda_verb dell_m6_core_init[] = {
795 /* set master volume to max value without distortion
796 * and direct control */
797 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
798 /* setup audio connections */
799 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
800 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
801 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
802 /* setup adcs to point to mixer */
803 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
804 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
805 /* setup import muxs */
806 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
807 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
808 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
809 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
813 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
814 /* set master volume and direct control */
815 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
816 /* setup audio connections */
817 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
818 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
819 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
820 /* connect hp ports to dac3 */
821 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
822 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
823 /* setup adcs to point to mixer */
824 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
825 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
826 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
827 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
828 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
829 /* setup import muxs */
830 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
831 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
832 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
833 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
837 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
838 /* set master volume and direct control */
839 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
840 /* setup audio connections */
841 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
842 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
843 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
844 /* dac3 is connected to import3 mux */
845 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
846 /* connect hp ports to dac4 */
847 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
848 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
849 /* setup adcs to point to mixer */
850 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
851 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
852 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
853 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
854 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
855 /* setup import muxs */
856 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
857 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
858 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
859 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
863 static struct hda_verb stac92hd83xxx_core_init[] = {
864 /* start of config #1 */
865 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
867 /* start of config #2 */
868 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
869 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
870 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
872 /* power state controls amps */
873 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
876 static struct hda_verb stac92hd71bxx_core_init[] = {
877 /* set master volume and direct control */
878 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
879 /* connect headphone jack to dac1 */
880 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
881 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
882 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
883 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
884 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
887 #define HD_DISABLE_PORTF 2
888 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
889 /* start of config #1 */
891 /* connect port 0f to audio mixer */
892 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
893 /* unmute right and left channels for node 0x0f */
894 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
895 /* start of config #2 */
897 /* set master volume and direct control */
898 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
899 /* connect headphone jack to dac1 */
900 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
901 /* unmute right and left channels for nodes 0x0a, 0xd */
902 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
903 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
907 static struct hda_verb stac925x_core_init[] = {
908 /* set dac0mux for dac converter */
909 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
913 static struct hda_verb stac922x_core_init[] = {
914 /* set master volume and direct control */
915 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
919 static struct hda_verb d965_core_init[] = {
920 /* set master volume and direct control */
921 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
922 /* unmute node 0x1b */
923 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
924 /* select node 0x03 as DAC */
925 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
929 static struct hda_verb stac927x_core_init[] = {
930 /* set master volume and direct control */
931 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
932 /* enable analog pc beep path */
933 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
937 static struct hda_verb stac9205_core_init[] = {
938 /* set master volume and direct control */
939 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
940 /* enable analog pc beep path */
941 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
945 #define STAC_MONO_MUX \
947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
948 .name = "Mono Mux", \
950 .info = stac92xx_mono_mux_enum_info, \
951 .get = stac92xx_mono_mux_enum_get, \
952 .put = stac92xx_mono_mux_enum_put, \
955 #define STAC_AMP_MUX \
957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
958 .name = "Amp Selector Capture Switch", \
960 .info = stac92xx_amp_mux_enum_info, \
961 .get = stac92xx_amp_mux_enum_get, \
962 .put = stac92xx_amp_mux_enum_put, \
965 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
967 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
970 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
971 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
972 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
973 .info = stac92xx_amp_volume_info, \
974 .get = stac92xx_amp_volume_get, \
975 .put = stac92xx_amp_volume_put, \
976 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
977 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
980 #define STAC_INPUT_SOURCE(cnt) \
982 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
983 .name = "Input Source", \
985 .info = stac92xx_mux_enum_info, \
986 .get = stac92xx_mux_enum_get, \
987 .put = stac92xx_mux_enum_put, \
990 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
992 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
993 .name = "Analog Loopback", \
995 .info = stac92xx_aloopback_info, \
996 .get = stac92xx_aloopback_get, \
997 .put = stac92xx_aloopback_put, \
998 .private_value = verb_read | (verb_write << 16), \
1001 static struct snd_kcontrol_new stac9200_mixer[] = {
1002 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1003 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
1004 STAC_INPUT_SOURCE(1),
1005 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1006 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1010 #define DELL_M6_MIXER 6
1011 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1012 /* start of config #1 */
1013 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1014 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1016 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1017 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1019 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1020 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1022 /* start of config #2 */
1023 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1024 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1026 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1027 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1029 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1031 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1032 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1034 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1035 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1040 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1041 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1043 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1044 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1046 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1047 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1049 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1050 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1052 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1053 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1055 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1056 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1058 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1059 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1061 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1062 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1066 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1067 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1069 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1070 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1072 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1073 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1075 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1076 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1078 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1079 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1081 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1082 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1084 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1085 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1087 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1088 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1093 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1094 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1095 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1097 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1098 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1100 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1101 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1103 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1104 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1106 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1107 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1109 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1110 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1113 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1114 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1119 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1120 STAC_INPUT_SOURCE(2),
1121 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1123 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1124 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1126 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1127 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1128 /* analog pc-beep replaced with digital beep support */
1130 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1131 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1134 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1135 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1137 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1138 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1140 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1141 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1143 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1144 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1148 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1149 STAC_INPUT_SOURCE(2),
1150 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1152 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1153 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1155 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1156 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1160 static struct snd_kcontrol_new stac925x_mixer[] = {
1161 STAC_INPUT_SOURCE(1),
1162 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1163 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1167 static struct snd_kcontrol_new stac9205_mixer[] = {
1168 STAC_INPUT_SOURCE(2),
1169 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1171 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1172 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1174 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1175 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1179 /* This needs to be generated dynamically based on sequence */
1180 static struct snd_kcontrol_new stac922x_mixer[] = {
1181 STAC_INPUT_SOURCE(2),
1182 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1183 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1185 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1186 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1191 static struct snd_kcontrol_new stac927x_mixer[] = {
1192 STAC_INPUT_SOURCE(3),
1193 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1195 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1196 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1198 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1199 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1201 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1202 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1206 static struct snd_kcontrol_new stac_dmux_mixer = {
1207 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1208 .name = "Digital Input Source",
1209 /* count set later */
1210 .info = stac92xx_dmux_enum_info,
1211 .get = stac92xx_dmux_enum_get,
1212 .put = stac92xx_dmux_enum_put,
1215 static struct snd_kcontrol_new stac_smux_mixer = {
1216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1217 .name = "IEC958 Playback Source",
1218 /* count set later */
1219 .info = stac92xx_smux_enum_info,
1220 .get = stac92xx_smux_enum_get,
1221 .put = stac92xx_smux_enum_put,
1224 static const char *slave_vols[] = {
1225 "Front Playback Volume",
1226 "Surround Playback Volume",
1227 "Center Playback Volume",
1228 "LFE Playback Volume",
1229 "Side Playback Volume",
1230 "Headphone Playback Volume",
1231 "Headphone Playback Volume",
1232 "Speaker Playback Volume",
1233 "External Speaker Playback Volume",
1234 "Speaker2 Playback Volume",
1238 static const char *slave_sws[] = {
1239 "Front Playback Switch",
1240 "Surround Playback Switch",
1241 "Center Playback Switch",
1242 "LFE Playback Switch",
1243 "Side Playback Switch",
1244 "Headphone Playback Switch",
1245 "Headphone Playback Switch",
1246 "Speaker Playback Switch",
1247 "External Speaker Playback Switch",
1248 "Speaker2 Playback Switch",
1249 "IEC958 Playback Switch",
1253 static void stac92xx_free_kctls(struct hda_codec *codec);
1255 static int stac92xx_build_controls(struct hda_codec *codec)
1257 struct sigmatel_spec *spec = codec->spec;
1261 err = snd_hda_add_new_ctls(codec, spec->mixer);
1265 for (i = 0; i < spec->num_mixers; i++) {
1266 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1270 if (spec->num_dmuxes > 0) {
1271 stac_dmux_mixer.count = spec->num_dmuxes;
1272 err = snd_hda_ctl_add(codec,
1273 snd_ctl_new1(&stac_dmux_mixer, codec));
1277 if (spec->num_smuxes > 0) {
1278 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1279 struct hda_input_mux *smux = &spec->private_smux;
1280 /* check for mute support on SPDIF out */
1281 if (wcaps & AC_WCAP_OUT_AMP) {
1282 smux->items[smux->num_items].label = "Off";
1283 smux->items[smux->num_items].index = 0;
1285 spec->spdif_mute = 1;
1287 stac_smux_mixer.count = spec->num_smuxes;
1288 err = snd_ctl_add(codec->bus->card,
1289 snd_ctl_new1(&stac_smux_mixer, codec));
1294 if (spec->multiout.dig_out_nid) {
1295 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1298 err = snd_hda_create_spdif_share_sw(codec,
1302 spec->multiout.share_spdif = 1;
1304 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1305 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1310 /* if we have no master control, let's create it */
1311 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1312 unsigned int vmaster_tlv[4];
1313 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1314 HDA_OUTPUT, vmaster_tlv);
1315 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1316 vmaster_tlv, slave_vols);
1320 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1321 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1327 stac92xx_free_kctls(codec); /* no longer needed */
1331 static unsigned int ref9200_pin_configs[8] = {
1332 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1333 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1337 STAC 9200 pin configs for
1342 static unsigned int dell9200_d21_pin_configs[8] = {
1343 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1344 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1348 STAC 9200 pin configs for
1352 static unsigned int dell9200_d22_pin_configs[8] = {
1353 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1354 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1358 STAC 9200 pin configs for
1359 102801C4 (Dell Dimension E310)
1366 static unsigned int dell9200_d23_pin_configs[8] = {
1367 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1368 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1373 STAC 9200-32 pin configs for
1374 102801B5 (Dell Inspiron 630m)
1375 102801D8 (Dell Inspiron 640m)
1377 static unsigned int dell9200_m21_pin_configs[8] = {
1378 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1379 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1383 STAC 9200-32 pin configs for
1384 102801C2 (Dell Latitude D620)
1386 102801CC (Dell Latitude D820)
1390 static unsigned int dell9200_m22_pin_configs[8] = {
1391 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1392 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1396 STAC 9200-32 pin configs for
1397 102801CE (Dell XPS M1710)
1398 102801CF (Dell Precision M90)
1400 static unsigned int dell9200_m23_pin_configs[8] = {
1401 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1402 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1406 STAC 9200-32 pin configs for
1409 102801CB (Dell Latitude 120L)
1412 static unsigned int dell9200_m24_pin_configs[8] = {
1413 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1414 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1418 STAC 9200-32 pin configs for
1419 102801BD (Dell Inspiron E1505n)
1423 static unsigned int dell9200_m25_pin_configs[8] = {
1424 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1425 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1429 STAC 9200-32 pin configs for
1430 102801F5 (Dell Inspiron 1501)
1433 static unsigned int dell9200_m26_pin_configs[8] = {
1434 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1435 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1440 102801CD (Dell Inspiron E1705/9400)
1442 static unsigned int dell9200_m27_pin_configs[8] = {
1443 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1444 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1447 static unsigned int oqo9200_pin_configs[8] = {
1448 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1449 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1453 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1454 [STAC_REF] = ref9200_pin_configs,
1455 [STAC_9200_OQO] = oqo9200_pin_configs,
1456 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1457 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1458 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1459 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1460 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1461 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1462 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1463 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1464 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1465 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1466 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1469 static const char *stac9200_models[STAC_9200_MODELS] = {
1471 [STAC_9200_OQO] = "oqo",
1472 [STAC_9200_DELL_D21] = "dell-d21",
1473 [STAC_9200_DELL_D22] = "dell-d22",
1474 [STAC_9200_DELL_D23] = "dell-d23",
1475 [STAC_9200_DELL_M21] = "dell-m21",
1476 [STAC_9200_DELL_M22] = "dell-m22",
1477 [STAC_9200_DELL_M23] = "dell-m23",
1478 [STAC_9200_DELL_M24] = "dell-m24",
1479 [STAC_9200_DELL_M25] = "dell-m25",
1480 [STAC_9200_DELL_M26] = "dell-m26",
1481 [STAC_9200_DELL_M27] = "dell-m27",
1482 [STAC_9200_GATEWAY] = "gateway",
1483 [STAC_9200_PANASONIC] = "panasonic",
1486 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1487 /* SigmaTel reference board */
1488 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1489 "DFI LanParty", STAC_REF),
1490 /* Dell laptops have BIOS problem */
1491 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1492 "unknown Dell", STAC_9200_DELL_D21),
1493 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1494 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1495 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1496 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1497 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1498 "unknown Dell", STAC_9200_DELL_D22),
1499 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1500 "unknown Dell", STAC_9200_DELL_D22),
1501 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1502 "Dell Latitude D620", STAC_9200_DELL_M22),
1503 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1504 "unknown Dell", STAC_9200_DELL_D23),
1505 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1506 "unknown Dell", STAC_9200_DELL_D23),
1507 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1508 "unknown Dell", STAC_9200_DELL_M22),
1509 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1510 "unknown Dell", STAC_9200_DELL_M24),
1511 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1512 "unknown Dell", STAC_9200_DELL_M24),
1513 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1514 "Dell Latitude 120L", STAC_9200_DELL_M24),
1515 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1516 "Dell Latitude D820", STAC_9200_DELL_M22),
1517 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1518 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1520 "Dell XPS M1710", STAC_9200_DELL_M23),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1522 "Dell Precision M90", STAC_9200_DELL_M23),
1523 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1524 "unknown Dell", STAC_9200_DELL_M22),
1525 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1526 "unknown Dell", STAC_9200_DELL_M22),
1527 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1528 "unknown Dell", STAC_9200_DELL_M22),
1529 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1530 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1531 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1532 "unknown Dell", STAC_9200_DELL_D23),
1533 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1534 "unknown Dell", STAC_9200_DELL_D23),
1535 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1536 "unknown Dell", STAC_9200_DELL_D21),
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1538 "unknown Dell", STAC_9200_DELL_D23),
1539 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1540 "unknown Dell", STAC_9200_DELL_D21),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1542 "unknown Dell", STAC_9200_DELL_M25),
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1544 "unknown Dell", STAC_9200_DELL_M25),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1546 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1548 "unknown Dell", STAC_9200_DELL_M26),
1550 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1551 /* Gateway machines needs EAPD to be set on resume */
1552 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1553 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1555 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1558 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1562 static unsigned int ref925x_pin_configs[8] = {
1563 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1564 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1567 static unsigned int stac925x_MA6_pin_configs[8] = {
1568 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1569 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1572 static unsigned int stac925x_PA6_pin_configs[8] = {
1573 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1574 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1577 static unsigned int stac925xM2_2_pin_configs[8] = {
1578 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1579 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1582 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1583 [STAC_REF] = ref925x_pin_configs,
1584 [STAC_M2_2] = stac925xM2_2_pin_configs,
1585 [STAC_MA6] = stac925x_MA6_pin_configs,
1586 [STAC_PA6] = stac925x_PA6_pin_configs,
1589 static const char *stac925x_models[STAC_925x_MODELS] = {
1591 [STAC_M2_2] = "m2-2",
1596 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1597 /* SigmaTel reference board */
1598 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1599 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1600 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1601 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1602 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1603 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1604 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1608 static unsigned int ref92hd73xx_pin_configs[13] = {
1609 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1610 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1611 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1615 static unsigned int dell_m6_pin_configs[13] = {
1616 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1617 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1618 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1622 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1623 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1624 [STAC_DELL_M6] = dell_m6_pin_configs,
1627 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1628 [STAC_92HD73XX_REF] = "ref",
1629 [STAC_DELL_M6] = "dell-m6",
1632 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1633 /* SigmaTel reference board */
1634 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1635 "DFI LanParty", STAC_92HD73XX_REF),
1636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1637 "unknown Dell", STAC_DELL_M6),
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1639 "unknown Dell", STAC_DELL_M6),
1640 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1641 "unknown Dell", STAC_DELL_M6),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1643 "unknown Dell", STAC_DELL_M6),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1645 "unknown Dell", STAC_DELL_M6),
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1647 "unknown Dell", STAC_DELL_M6),
1648 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1649 "unknown Dell", STAC_DELL_M6),
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),
1674 static unsigned int ref92hd71bxx_pin_configs[11] = {
1675 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1676 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1677 0x90a000f0, 0x01452050, 0x01452050,
1680 static unsigned int dell_m4_1_pin_configs[11] = {
1681 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1682 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1683 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
1686 static unsigned int dell_m4_2_pin_configs[11] = {
1687 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1688 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1689 0x40f000f0, 0x044413b0, 0x044413b0,
1692 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1693 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1694 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1695 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1696 [STAC_HP_M4] = NULL,
1699 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1700 [STAC_92HD71BXX_REF] = "ref",
1701 [STAC_DELL_M4_1] = "dell-m4-1",
1702 [STAC_DELL_M4_2] = "dell-m4-2",
1703 [STAC_HP_M4] = "hp-m4",
1706 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1707 /* SigmaTel reference board */
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1709 "DFI LanParty", STAC_92HD71BXX_REF),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1711 "unknown HP", STAC_HP_M4),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1713 "unknown Dell", STAC_DELL_M4_1),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1715 "unknown Dell", STAC_DELL_M4_1),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1717 "unknown Dell", STAC_DELL_M4_1),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1719 "unknown Dell", STAC_DELL_M4_1),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1721 "unknown Dell", STAC_DELL_M4_1),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1723 "unknown Dell", STAC_DELL_M4_1),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1725 "unknown Dell", STAC_DELL_M4_1),
1726 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1727 "unknown Dell", STAC_DELL_M4_2),
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1729 "unknown Dell", STAC_DELL_M4_2),
1730 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1731 "unknown Dell", STAC_DELL_M4_2),
1732 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1733 "unknown Dell", STAC_DELL_M4_2),
1737 static unsigned int ref922x_pin_configs[10] = {
1738 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1739 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1740 0x40000100, 0x40000100,
1744 STAC 922X pin configs for
1751 static unsigned int dell_922x_d81_pin_configs[10] = {
1752 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1753 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1754 0x01813122, 0x400001f2,
1758 STAC 922X pin configs for
1762 static unsigned int dell_922x_d82_pin_configs[10] = {
1763 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1764 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1765 0x01813122, 0x400001f1,
1769 STAC 922X pin configs for
1772 static unsigned int dell_922x_m81_pin_configs[10] = {
1773 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1774 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1775 0x40C003f1, 0x405003f0,
1779 STAC 9221 A1 pin configs for
1780 102801D7 (Dell XPS M1210)
1782 static unsigned int dell_922x_m82_pin_configs[10] = {
1783 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1784 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1785 0x508003f3, 0x405003f4,
1788 static unsigned int d945gtp3_pin_configs[10] = {
1789 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1790 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1791 0x02a19120, 0x40000100,
1794 static unsigned int d945gtp5_pin_configs[10] = {
1795 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1796 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1797 0x02a19320, 0x40000100,
1800 static unsigned int intel_mac_v1_pin_configs[10] = {
1801 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1802 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1803 0x400000fc, 0x400000fb,
1806 static unsigned int intel_mac_v2_pin_configs[10] = {
1807 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1808 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1809 0x400000fc, 0x400000fb,
1812 static unsigned int intel_mac_v3_pin_configs[10] = {
1813 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1814 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1815 0x400000fc, 0x400000fb,
1818 static unsigned int intel_mac_v4_pin_configs[10] = {
1819 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1820 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1821 0x400000fc, 0x400000fb,
1824 static unsigned int intel_mac_v5_pin_configs[10] = {
1825 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1826 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1827 0x400000fc, 0x400000fb,
1830 static unsigned int ecs202_pin_configs[10] = {
1831 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1832 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1833 0x9037012e, 0x40e000f2,
1836 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1837 [STAC_D945_REF] = ref922x_pin_configs,
1838 [STAC_D945GTP3] = d945gtp3_pin_configs,
1839 [STAC_D945GTP5] = d945gtp5_pin_configs,
1840 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1841 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1842 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1843 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1844 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1845 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1846 /* for backward compatibility */
1847 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1848 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1849 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1850 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1851 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1852 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1853 [STAC_ECS_202] = ecs202_pin_configs,
1854 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1855 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1856 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1857 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1860 static const char *stac922x_models[STAC_922X_MODELS] = {
1861 [STAC_D945_REF] = "ref",
1862 [STAC_D945GTP5] = "5stack",
1863 [STAC_D945GTP3] = "3stack",
1864 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1865 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1866 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1867 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1868 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1869 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1870 /* for backward compatibility */
1871 [STAC_MACMINI] = "macmini",
1872 [STAC_MACBOOK] = "macbook",
1873 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1874 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1875 [STAC_IMAC_INTEL] = "imac-intel",
1876 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1877 [STAC_ECS_202] = "ecs202",
1878 [STAC_922X_DELL_D81] = "dell-d81",
1879 [STAC_922X_DELL_D82] = "dell-d82",
1880 [STAC_922X_DELL_M81] = "dell-m81",
1881 [STAC_922X_DELL_M82] = "dell-m82",
1884 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1885 /* SigmaTel reference board */
1886 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1887 "DFI LanParty", STAC_D945_REF),
1888 /* Intel 945G based systems */
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1890 "Intel D945G", STAC_D945GTP3),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1892 "Intel D945G", STAC_D945GTP3),
1893 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1894 "Intel D945G", STAC_D945GTP3),
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1896 "Intel D945G", STAC_D945GTP3),
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1898 "Intel D945G", STAC_D945GTP3),
1899 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1900 "Intel D945G", STAC_D945GTP3),
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1902 "Intel D945G", STAC_D945GTP3),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1904 "Intel D945G", STAC_D945GTP3),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1906 "Intel D945G", STAC_D945GTP3),
1907 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1908 "Intel D945G", STAC_D945GTP3),
1909 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1910 "Intel D945G", STAC_D945GTP3),
1911 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1912 "Intel D945G", STAC_D945GTP3),
1913 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1914 "Intel D945G", STAC_D945GTP3),
1915 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1916 "Intel D945G", STAC_D945GTP3),
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1918 "Intel D945G", STAC_D945GTP3),
1919 /* Intel D945G 5-stack systems */
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1921 "Intel D945G", STAC_D945GTP5),
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1923 "Intel D945G", STAC_D945GTP5),
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1925 "Intel D945G", STAC_D945GTP5),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1927 "Intel D945G", STAC_D945GTP5),
1928 /* Intel 945P based systems */
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1930 "Intel D945P", STAC_D945GTP3),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1932 "Intel D945P", STAC_D945GTP3),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1934 "Intel D945P", STAC_D945GTP3),
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1936 "Intel D945P", STAC_D945GTP3),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1938 "Intel D945P", STAC_D945GTP3),
1939 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1940 "Intel D945P", STAC_D945GTP5),
1942 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1943 SND_PCI_QUIRK(0x8384, 0x7680,
1944 "Mac", STAC_INTEL_MAC_AUTO),
1946 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1947 "unknown Dell", STAC_922X_DELL_D81),
1948 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1949 "unknown Dell", STAC_922X_DELL_D81),
1950 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1951 "unknown Dell", STAC_922X_DELL_D81),
1952 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1953 "unknown Dell", STAC_922X_DELL_D82),
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1955 "unknown Dell", STAC_922X_DELL_M81),
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1957 "unknown Dell", STAC_922X_DELL_D82),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1959 "unknown Dell", STAC_922X_DELL_D81),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1961 "unknown Dell", STAC_922X_DELL_D81),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1963 "Dell XPS M1210", STAC_922X_DELL_M82),
1964 /* ECS/PC Chips boards */
1965 SND_PCI_QUIRK(0x1019, 0x2144,
1966 "ECS/PC chips", STAC_ECS_202),
1967 SND_PCI_QUIRK(0x1019, 0x2608,
1968 "ECS/PC chips", STAC_ECS_202),
1969 SND_PCI_QUIRK(0x1019, 0x2633,
1970 "ECS/PC chips P17G/1333", STAC_ECS_202),
1971 SND_PCI_QUIRK(0x1019, 0x2811,
1972 "ECS/PC chips", STAC_ECS_202),
1973 SND_PCI_QUIRK(0x1019, 0x2812,
1974 "ECS/PC chips", STAC_ECS_202),
1975 SND_PCI_QUIRK(0x1019, 0x2813,
1976 "ECS/PC chips", STAC_ECS_202),
1977 SND_PCI_QUIRK(0x1019, 0x2814,
1978 "ECS/PC chips", STAC_ECS_202),
1979 SND_PCI_QUIRK(0x1019, 0x2815,
1980 "ECS/PC chips", STAC_ECS_202),
1981 SND_PCI_QUIRK(0x1019, 0x2816,
1982 "ECS/PC chips", STAC_ECS_202),
1983 SND_PCI_QUIRK(0x1019, 0x2817,
1984 "ECS/PC chips", STAC_ECS_202),
1985 SND_PCI_QUIRK(0x1019, 0x2818,
1986 "ECS/PC chips", STAC_ECS_202),
1987 SND_PCI_QUIRK(0x1019, 0x2819,
1988 "ECS/PC chips", STAC_ECS_202),
1989 SND_PCI_QUIRK(0x1019, 0x2820,
1990 "ECS/PC chips", STAC_ECS_202),
1994 static unsigned int ref927x_pin_configs[14] = {
1995 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1996 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1997 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1998 0x01c42190, 0x40000100,
2001 static unsigned int d965_3st_pin_configs[14] = {
2002 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2003 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2004 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2005 0x40000100, 0x40000100
2008 static unsigned int d965_5st_pin_configs[14] = {
2009 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2010 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2011 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2012 0x40000100, 0x40000100
2015 static unsigned int dell_3st_pin_configs[14] = {
2016 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2017 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2018 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2019 0x40c003fc, 0x40000100
2022 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2023 [STAC_D965_REF] = ref927x_pin_configs,
2024 [STAC_D965_3ST] = d965_3st_pin_configs,
2025 [STAC_D965_5ST] = d965_5st_pin_configs,
2026 [STAC_DELL_3ST] = dell_3st_pin_configs,
2027 [STAC_DELL_BIOS] = NULL,
2030 static const char *stac927x_models[STAC_927X_MODELS] = {
2031 [STAC_D965_REF] = "ref",
2032 [STAC_D965_3ST] = "3stack",
2033 [STAC_D965_5ST] = "5stack",
2034 [STAC_DELL_3ST] = "dell-3stack",
2035 [STAC_DELL_BIOS] = "dell-bios",
2038 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2039 /* SigmaTel reference board */
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2041 "DFI LanParty", STAC_D965_REF),
2042 /* Intel 946 based systems */
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2045 /* 965 based 3 stack systems */
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
2062 /* Dell 3 stack systems */
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2067 /* Dell 3 stack systems with verb table in BIOS */
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2075 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2076 /* 965 based 5 stack systems */
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2081 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
2089 static unsigned int ref9205_pin_configs[12] = {
2090 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2091 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2092 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2096 STAC 9205 pin configs for
2103 10280228 (Dell Vostro 1500)
2105 static unsigned int dell_9205_m42_pin_configs[12] = {
2106 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2107 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2108 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2112 STAC 9205 pin configs for
2116 102801FF (Dell Precision M4300)
2121 static unsigned int dell_9205_m43_pin_configs[12] = {
2122 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2123 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2124 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2127 static unsigned int dell_9205_m44_pin_configs[12] = {
2128 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2129 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2130 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2133 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2134 [STAC_9205_REF] = ref9205_pin_configs,
2135 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2136 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2137 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2140 static const char *stac9205_models[STAC_9205_MODELS] = {
2141 [STAC_9205_REF] = "ref",
2142 [STAC_9205_DELL_M42] = "dell-m42",
2143 [STAC_9205_DELL_M43] = "dell-m43",
2144 [STAC_9205_DELL_M44] = "dell-m44",
2147 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2148 /* SigmaTel reference board */
2149 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2150 "DFI LanParty", STAC_9205_REF),
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2152 "unknown Dell", STAC_9205_DELL_M42),
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2154 "unknown Dell", STAC_9205_DELL_M42),
2155 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2156 "Dell Precision", STAC_9205_DELL_M43),
2157 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2158 "Dell Precision", STAC_9205_DELL_M43),
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2160 "Dell Precision", STAC_9205_DELL_M43),
2161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2162 "unknown Dell", STAC_9205_DELL_M42),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2164 "unknown Dell", STAC_9205_DELL_M42),
2165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2166 "Dell Precision", STAC_9205_DELL_M43),
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2168 "Dell Precision M4300", STAC_9205_DELL_M43),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2170 "unknown Dell", STAC_9205_DELL_M42),
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2172 "Dell Precision", STAC_9205_DELL_M43),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2174 "Dell Precision", STAC_9205_DELL_M43),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2176 "Dell Precision", STAC_9205_DELL_M43),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2178 "Dell Inspiron", STAC_9205_DELL_M44),
2179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2180 "Dell Vostro 1500", STAC_9205_DELL_M42),
2184 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2187 struct sigmatel_spec *spec = codec->spec;
2189 if (! spec->bios_pin_configs) {
2190 spec->bios_pin_configs = kcalloc(spec->num_pins,
2191 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2192 if (! spec->bios_pin_configs)
2196 for (i = 0; i < spec->num_pins; i++) {
2197 hda_nid_t nid = spec->pin_nids[i];
2198 unsigned int pin_cfg;
2200 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2201 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2202 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2204 spec->bios_pin_configs[i] = pin_cfg;
2210 static void stac92xx_set_config_reg(struct hda_codec *codec,
2211 hda_nid_t pin_nid, unsigned int pin_config)
2214 snd_hda_codec_write(codec, pin_nid, 0,
2215 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2216 pin_config & 0x000000ff);
2217 snd_hda_codec_write(codec, pin_nid, 0,
2218 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2219 (pin_config & 0x0000ff00) >> 8);
2220 snd_hda_codec_write(codec, pin_nid, 0,
2221 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2222 (pin_config & 0x00ff0000) >> 16);
2223 snd_hda_codec_write(codec, pin_nid, 0,
2224 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2226 i = snd_hda_codec_read(codec, pin_nid, 0,
2227 AC_VERB_GET_CONFIG_DEFAULT,
2229 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2233 static void stac92xx_set_config_regs(struct hda_codec *codec)
2236 struct sigmatel_spec *spec = codec->spec;
2238 if (!spec->pin_configs)
2241 for (i = 0; i < spec->num_pins; i++)
2242 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2243 spec->pin_configs[i]);
2247 * Analog playback callbacks
2249 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2250 struct hda_codec *codec,
2251 struct snd_pcm_substream *substream)
2253 struct sigmatel_spec *spec = codec->spec;
2254 if (spec->stream_delay)
2255 msleep(spec->stream_delay);
2256 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2260 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2261 struct hda_codec *codec,
2262 unsigned int stream_tag,
2263 unsigned int format,
2264 struct snd_pcm_substream *substream)
2266 struct sigmatel_spec *spec = codec->spec;
2267 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2270 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2271 struct hda_codec *codec,
2272 struct snd_pcm_substream *substream)
2274 struct sigmatel_spec *spec = codec->spec;
2275 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2279 * Digital playback callbacks
2281 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2282 struct hda_codec *codec,
2283 struct snd_pcm_substream *substream)
2285 struct sigmatel_spec *spec = codec->spec;
2286 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2289 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2290 struct hda_codec *codec,
2291 struct snd_pcm_substream *substream)
2293 struct sigmatel_spec *spec = codec->spec;
2294 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2297 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2298 struct hda_codec *codec,
2299 unsigned int stream_tag,
2300 unsigned int format,
2301 struct snd_pcm_substream *substream)
2303 struct sigmatel_spec *spec = codec->spec;
2304 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2305 stream_tag, format, substream);
2310 * Analog capture callbacks
2312 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2313 struct hda_codec *codec,
2314 unsigned int stream_tag,
2315 unsigned int format,
2316 struct snd_pcm_substream *substream)
2318 struct sigmatel_spec *spec = codec->spec;
2319 hda_nid_t nid = spec->adc_nids[substream->number];
2321 if (spec->powerdown_adcs) {
2323 snd_hda_codec_write_cache(codec, nid, 0,
2324 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2326 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2330 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2331 struct hda_codec *codec,
2332 struct snd_pcm_substream *substream)
2334 struct sigmatel_spec *spec = codec->spec;
2335 hda_nid_t nid = spec->adc_nids[substream->number];
2337 snd_hda_codec_cleanup_stream(codec, nid);
2338 if (spec->powerdown_adcs)
2339 snd_hda_codec_write_cache(codec, nid, 0,
2340 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2344 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2348 /* NID is set in stac92xx_build_pcms */
2350 .open = stac92xx_dig_playback_pcm_open,
2351 .close = stac92xx_dig_playback_pcm_close,
2352 .prepare = stac92xx_dig_playback_pcm_prepare
2356 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2360 /* NID is set in stac92xx_build_pcms */
2363 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2367 .nid = 0x02, /* NID to query formats and rates */
2369 .open = stac92xx_playback_pcm_open,
2370 .prepare = stac92xx_playback_pcm_prepare,
2371 .cleanup = stac92xx_playback_pcm_cleanup
2375 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2379 .nid = 0x06, /* NID to query formats and rates */
2381 .open = stac92xx_playback_pcm_open,
2382 .prepare = stac92xx_playback_pcm_prepare,
2383 .cleanup = stac92xx_playback_pcm_cleanup
2387 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2390 /* NID + .substreams is set in stac92xx_build_pcms */
2392 .prepare = stac92xx_capture_pcm_prepare,
2393 .cleanup = stac92xx_capture_pcm_cleanup
2397 static int stac92xx_build_pcms(struct hda_codec *codec)
2399 struct sigmatel_spec *spec = codec->spec;
2400 struct hda_pcm *info = spec->pcm_rec;
2402 codec->num_pcms = 1;
2403 codec->pcm_info = info;
2405 info->name = "STAC92xx Analog";
2406 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2407 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2408 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2409 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2411 if (spec->alt_switch) {
2414 info->name = "STAC92xx Analog Alt";
2415 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2418 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2421 info->name = "STAC92xx Digital";
2422 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2423 if (spec->multiout.dig_out_nid) {
2424 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2425 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2427 if (spec->dig_in_nid) {
2428 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2429 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2436 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2438 unsigned int pincap = snd_hda_param_read(codec, nid,
2440 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2441 if (pincap & AC_PINCAP_VREF_100)
2442 return AC_PINCTL_VREF_100;
2443 if (pincap & AC_PINCAP_VREF_80)
2444 return AC_PINCTL_VREF_80;
2445 if (pincap & AC_PINCAP_VREF_50)
2446 return AC_PINCTL_VREF_50;
2447 if (pincap & AC_PINCAP_VREF_GRD)
2448 return AC_PINCTL_VREF_GRD;
2452 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2455 snd_hda_codec_write_cache(codec, nid, 0,
2456 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2459 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2461 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2462 struct snd_ctl_elem_value *ucontrol)
2464 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2465 struct sigmatel_spec *spec = codec->spec;
2467 ucontrol->value.integer.value[0] = spec->hp_switch;
2471 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2472 struct snd_ctl_elem_value *ucontrol)
2474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2475 struct sigmatel_spec *spec = codec->spec;
2476 struct auto_pin_cfg *cfg = &spec->autocfg;
2477 int nid = cfg->hp_pins[cfg->hp_outs - 1];
2479 spec->hp_switch = ucontrol->value.integer.value[0];
2481 /* check to be sure that the ports are upto date with
2484 codec->patch_ops.unsol_event(codec, (STAC_HP_EVENT | nid) << 26);
2489 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2491 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2493 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2494 struct sigmatel_spec *spec = codec->spec;
2495 int io_idx = kcontrol-> private_value & 0xff;
2497 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2501 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2504 struct sigmatel_spec *spec = codec->spec;
2505 hda_nid_t nid = kcontrol->private_value >> 8;
2506 int io_idx = kcontrol-> private_value & 0xff;
2507 unsigned short val = !!ucontrol->value.integer.value[0];
2509 spec->io_switch[io_idx] = val;
2512 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2514 unsigned int pinctl = AC_PINCTL_IN_EN;
2515 if (io_idx) /* set VREF for mic */
2516 pinctl |= stac92xx_get_vref(codec, nid);
2517 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2520 /* check the auto-mute again: we need to mute/unmute the speaker
2521 * appropriately according to the pin direction
2523 if (spec->hp_detect)
2524 codec->patch_ops.unsol_event(codec,
2525 (STAC_HP_EVENT | nid) << 26);
2530 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2532 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2533 struct snd_ctl_elem_value *ucontrol)
2535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2536 struct sigmatel_spec *spec = codec->spec;
2538 ucontrol->value.integer.value[0] = spec->clfe_swap;
2542 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2543 struct snd_ctl_elem_value *ucontrol)
2545 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2546 struct sigmatel_spec *spec = codec->spec;
2547 hda_nid_t nid = kcontrol->private_value & 0xff;
2548 unsigned int val = !!ucontrol->value.integer.value[0];
2550 if (spec->clfe_swap == val)
2553 spec->clfe_swap = val;
2555 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2556 spec->clfe_swap ? 0x4 : 0x0);
2561 #define STAC_CODEC_HP_SWITCH(xname) \
2562 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2565 .info = stac92xx_hp_switch_info, \
2566 .get = stac92xx_hp_switch_get, \
2567 .put = stac92xx_hp_switch_put, \
2570 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2571 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2574 .info = stac92xx_io_switch_info, \
2575 .get = stac92xx_io_switch_get, \
2576 .put = stac92xx_io_switch_put, \
2577 .private_value = xpval, \
2580 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2581 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2584 .info = stac92xx_clfe_switch_info, \
2585 .get = stac92xx_clfe_switch_get, \
2586 .put = stac92xx_clfe_switch_put, \
2587 .private_value = xpval, \
2591 STAC_CTL_WIDGET_VOL,
2592 STAC_CTL_WIDGET_MUTE,
2593 STAC_CTL_WIDGET_MONO_MUX,
2594 STAC_CTL_WIDGET_AMP_MUX,
2595 STAC_CTL_WIDGET_AMP_VOL,
2596 STAC_CTL_WIDGET_HP_SWITCH,
2597 STAC_CTL_WIDGET_IO_SWITCH,
2598 STAC_CTL_WIDGET_CLFE_SWITCH
2601 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2602 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2603 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2606 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2607 STAC_CODEC_HP_SWITCH(NULL),
2608 STAC_CODEC_IO_SWITCH(NULL, 0),
2609 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2612 /* add dynamic controls */
2613 static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2614 int idx, const char *name, unsigned long val)
2616 struct snd_kcontrol_new *knew;
2618 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2619 knew = snd_array_new(&spec->kctls);
2622 *knew = stac92xx_control_templates[type];
2624 knew->name = kstrdup(name, GFP_KERNEL);
2627 knew->private_value = val;
2632 /* add dynamic controls */
2633 static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2634 const char *name, unsigned long val)
2636 return stac92xx_add_control_idx(spec, type, 0, name, val);
2639 /* flag inputs as additional dynamic lineouts */
2640 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2642 struct sigmatel_spec *spec = codec->spec;
2643 unsigned int wcaps, wtype;
2644 int i, num_dacs = 0;
2646 /* use the wcaps cache to count all DACs available for line-outs */
2647 for (i = 0; i < codec->num_nodes; i++) {
2648 wcaps = codec->wcaps[i];
2649 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2651 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2655 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2657 switch (cfg->line_outs) {
2659 /* add line-in as side */
2660 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2661 cfg->line_out_pins[cfg->line_outs] =
2662 cfg->input_pins[AUTO_PIN_LINE];
2663 spec->line_switch = 1;
2668 /* add line-in as clfe and mic as side */
2669 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2670 cfg->line_out_pins[cfg->line_outs] =
2671 cfg->input_pins[AUTO_PIN_LINE];
2672 spec->line_switch = 1;
2675 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2676 cfg->line_out_pins[cfg->line_outs] =
2677 cfg->input_pins[AUTO_PIN_MIC];
2678 spec->mic_switch = 1;
2683 /* add line-in as surr and mic as clfe */
2684 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2685 cfg->line_out_pins[cfg->line_outs] =
2686 cfg->input_pins[AUTO_PIN_LINE];
2687 spec->line_switch = 1;
2690 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2691 cfg->line_out_pins[cfg->line_outs] =
2692 cfg->input_pins[AUTO_PIN_MIC];
2693 spec->mic_switch = 1;
2703 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2707 for (i = 0; i < spec->multiout.num_dacs; i++) {
2708 if (spec->multiout.dac_nids[i] == nid)
2716 * Fill in the dac_nids table from the parsed pin configuration
2717 * This function only works when every pin in line_out_pins[]
2718 * contains atleast one DAC in its connection list. Some 92xx
2719 * codecs are not connected directly to a DAC, such as the 9200
2720 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2722 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2723 struct auto_pin_cfg *cfg)
2725 struct sigmatel_spec *spec = codec->spec;
2726 int i, j, conn_len = 0;
2727 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2728 unsigned int wcaps, wtype;
2730 for (i = 0; i < cfg->line_outs; i++) {
2731 nid = cfg->line_out_pins[i];
2732 conn_len = snd_hda_get_connections(codec, nid, conn,
2733 HDA_MAX_CONNECTIONS);
2734 for (j = 0; j < conn_len; j++) {
2735 wcaps = snd_hda_param_read(codec, conn[j],
2736 AC_PAR_AUDIO_WIDGET_CAP);
2737 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2738 if (wtype != AC_WID_AUD_OUT ||
2739 (wcaps & AC_WCAP_DIGITAL))
2741 /* conn[j] is a DAC routed to this line-out */
2742 if (!is_in_dac_nids(spec, conn[j]))
2746 if (j == conn_len) {
2747 if (spec->multiout.num_dacs > 0) {
2748 /* we have already working output pins,
2749 * so let's drop the broken ones again
2751 cfg->line_outs = spec->multiout.num_dacs;
2754 /* error out, no available DAC found */
2756 "%s: No available DAC for pin 0x%x\n",
2761 spec->multiout.dac_nids[i] = conn[j];
2762 spec->multiout.num_dacs++;
2764 /* select this DAC in the pin's input mux */
2765 snd_hda_codec_write_cache(codec, nid, 0,
2766 AC_VERB_SET_CONNECT_SEL, j);
2771 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2772 spec->multiout.num_dacs,
2773 spec->multiout.dac_nids[0],
2774 spec->multiout.dac_nids[1],
2775 spec->multiout.dac_nids[2],
2776 spec->multiout.dac_nids[3],
2777 spec->multiout.dac_nids[4]);
2781 /* create volume control/switch for the given prefx type */
2782 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2787 sprintf(name, "%s Playback Volume", pfx);
2788 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2789 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2792 sprintf(name, "%s Playback Switch", pfx);
2793 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2794 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2800 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2802 if (!spec->multiout.hp_nid)
2803 spec->multiout.hp_nid = nid;
2804 else if (spec->multiout.num_dacs > 4) {
2805 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2808 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2809 spec->multiout.num_dacs++;
2814 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2816 if (is_in_dac_nids(spec, nid))
2818 if (spec->multiout.hp_nid == nid)
2823 /* add playback controls from the parsed DAC table */
2824 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2825 const struct auto_pin_cfg *cfg)
2827 static const char *chname[4] = {
2828 "Front", "Surround", NULL /*CLFE*/, "Side"
2833 struct sigmatel_spec *spec = codec->spec;
2834 unsigned int wid_caps, pincap;
2837 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2838 if (!spec->multiout.dac_nids[i])
2841 nid = spec->multiout.dac_nids[i];
2845 err = create_controls(spec, "Center", nid, 1);
2848 err = create_controls(spec, "LFE", nid, 2);
2852 wid_caps = get_wcaps(codec, nid);
2854 if (wid_caps & AC_WCAP_LR_SWAP) {
2855 err = stac92xx_add_control(spec,
2856 STAC_CTL_WIDGET_CLFE_SWITCH,
2857 "Swap Center/LFE Playback Switch", nid);
2864 err = create_controls(spec, chname[i], nid, 3);
2870 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2871 cfg->hp_outs && !spec->multiout.hp_nid)
2872 spec->multiout.hp_nid = nid;
2874 if (cfg->hp_outs > 1) {
2875 err = stac92xx_add_control(spec,
2876 STAC_CTL_WIDGET_HP_SWITCH,
2877 "Headphone as Line Out Switch", 0);
2882 if (spec->line_switch) {
2883 nid = cfg->input_pins[AUTO_PIN_LINE];
2884 pincap = snd_hda_param_read(codec, nid,
2886 if (pincap & AC_PINCAP_OUT) {
2887 err = stac92xx_add_control(spec,
2888 STAC_CTL_WIDGET_IO_SWITCH,
2889 "Line In as Output Switch", nid << 8);
2895 if (spec->mic_switch) {
2896 unsigned int def_conf;
2897 unsigned int mic_pin = AUTO_PIN_MIC;
2899 nid = cfg->input_pins[mic_pin];
2900 def_conf = snd_hda_codec_read(codec, nid, 0,
2901 AC_VERB_GET_CONFIG_DEFAULT, 0);
2902 /* some laptops have an internal analog microphone
2903 * which can't be used as a output */
2904 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2905 pincap = snd_hda_param_read(codec, nid,
2907 if (pincap & AC_PINCAP_OUT) {
2908 err = stac92xx_add_control(spec,
2909 STAC_CTL_WIDGET_IO_SWITCH,
2910 "Mic as Output Switch", (nid << 8) | 1);
2911 nid = snd_hda_codec_read(codec, nid, 0,
2912 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2913 if (!check_in_dac_nids(spec, nid))
2914 add_spec_dacs(spec, nid);
2918 } else if (mic_pin == AUTO_PIN_MIC) {
2919 mic_pin = AUTO_PIN_FRONT_MIC;
2927 /* add playback controls for Speaker and HP outputs */
2928 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2929 struct auto_pin_cfg *cfg)
2931 struct sigmatel_spec *spec = codec->spec;
2933 int i, old_num_dacs, err;
2935 old_num_dacs = spec->multiout.num_dacs;
2936 for (i = 0; i < cfg->hp_outs; i++) {
2937 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2938 if (wid_caps & AC_WCAP_UNSOL_CAP)
2939 spec->hp_detect = 1;
2940 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2941 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2942 if (check_in_dac_nids(spec, nid))
2946 add_spec_dacs(spec, nid);
2948 for (i = 0; i < cfg->speaker_outs; i++) {
2949 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2950 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2951 if (check_in_dac_nids(spec, nid))
2955 add_spec_dacs(spec, nid);
2957 for (i = 0; i < cfg->line_outs; i++) {
2958 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2959 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2960 if (check_in_dac_nids(spec, nid))
2964 add_spec_dacs(spec, nid);
2966 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2967 static const char *pfxs[] = {
2968 "Speaker", "External Speaker", "Speaker2",
2970 err = create_controls(spec, pfxs[i - old_num_dacs],
2971 spec->multiout.dac_nids[i], 3);
2975 if (spec->multiout.hp_nid) {
2976 err = create_controls(spec, "Headphone",
2977 spec->multiout.hp_nid, 3);
2985 /* labels for mono mux outputs */
2986 static const char *stac92xx_mono_labels[4] = {
2987 "DAC0", "DAC1", "Mixer", "DAC2"
2990 /* create mono mux for mono out on capable codecs */
2991 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2993 struct sigmatel_spec *spec = codec->spec;
2994 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2996 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2998 num_cons = snd_hda_get_connections(codec,
3001 HDA_MAX_NUM_INPUTS);
3002 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3005 for (i = 0; i < num_cons; i++) {
3006 mono_mux->items[mono_mux->num_items].label =
3007 stac92xx_mono_labels[i];
3008 mono_mux->items[mono_mux->num_items].index = i;
3009 mono_mux->num_items++;
3012 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3013 "Mono Mux", spec->mono_nid);
3016 /* labels for amp mux outputs */
3017 static const char *stac92xx_amp_labels[3] = {
3018 "Front Microphone", "Microphone", "Line In",
3021 /* create amp out controls mux on capable codecs */
3022 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3024 struct sigmatel_spec *spec = codec->spec;
3025 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3028 for (i = 0; i < spec->num_amps; i++) {
3029 amp_mux->items[amp_mux->num_items].label =
3030 stac92xx_amp_labels[i];
3031 amp_mux->items[amp_mux->num_items].index = i;
3032 amp_mux->num_items++;
3035 if (spec->num_amps > 1) {
3036 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3037 "Amp Selector Capture Switch", 0);
3041 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3042 "Amp Capture Volume",
3043 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3047 /* create PC beep volume controls */
3048 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3051 struct sigmatel_spec *spec = codec->spec;
3052 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3055 /* check for mute support for the the amp */
3056 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3057 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3058 "PC Beep Playback Switch",
3059 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3064 /* check to see if there is volume support for the amp */
3065 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3066 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3067 "PC Beep Playback Volume",
3068 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3075 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3077 struct sigmatel_spec *spec = codec->spec;
3078 int wcaps, nid, i, err = 0;
3080 for (i = 0; i < spec->num_muxes; i++) {
3081 nid = spec->mux_nids[i];
3082 wcaps = get_wcaps(codec, nid);
3084 if (wcaps & AC_WCAP_OUT_AMP) {
3085 err = stac92xx_add_control_idx(spec,
3086 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3087 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3095 static const char *stac92xx_spdif_labels[3] = {
3096 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3099 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3101 struct sigmatel_spec *spec = codec->spec;
3102 struct hda_input_mux *spdif_mux = &spec->private_smux;
3103 const char **labels = spec->spdif_labels;
3105 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3107 num_cons = snd_hda_get_connections(codec,
3110 HDA_MAX_NUM_INPUTS);
3115 labels = stac92xx_spdif_labels;
3117 for (i = 0; i < num_cons; i++) {
3118 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3119 spdif_mux->items[spdif_mux->num_items].index = i;
3120 spdif_mux->num_items++;
3126 /* labels for dmic mux inputs */
3127 static const char *stac92xx_dmic_labels[5] = {
3128 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3129 "Digital Mic 3", "Digital Mic 4"
3132 /* create playback/capture controls for input pins on dmic capable codecs */
3133 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3134 const struct auto_pin_cfg *cfg)
3136 struct sigmatel_spec *spec = codec->spec;
3137 struct hda_input_mux *dimux = &spec->private_dimux;
3138 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3142 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3143 dimux->items[dimux->num_items].index = 0;
3146 for (i = 0; i < spec->num_dmics; i++) {
3151 unsigned int def_conf;
3153 def_conf = snd_hda_codec_read(codec,
3156 AC_VERB_GET_CONFIG_DEFAULT,
3158 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3161 nid = spec->dmic_nids[i];
3162 num_cons = snd_hda_get_connections(codec,
3165 HDA_MAX_NUM_INPUTS);
3166 for (j = 0; j < num_cons; j++)
3167 if (con_lst[j] == nid) {
3173 wcaps = get_wcaps(codec, nid) &
3174 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3177 sprintf(name, "%s Capture Volume",
3178 stac92xx_dmic_labels[dimux->num_items]);
3180 err = stac92xx_add_control(spec,
3181 STAC_CTL_WIDGET_VOL,
3183 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3184 (wcaps & AC_WCAP_OUT_AMP) ?
3185 HDA_OUTPUT : HDA_INPUT));
3190 dimux->items[dimux->num_items].label =
3191 stac92xx_dmic_labels[dimux->num_items];
3192 dimux->items[dimux->num_items].index = index;
3199 /* create playback/capture controls for input pins */
3200 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3202 struct sigmatel_spec *spec = codec->spec;
3203 struct hda_input_mux *imux = &spec->private_imux;
3204 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3207 for (i = 0; i < AUTO_PIN_LAST; i++) {
3210 if (!cfg->input_pins[i])
3213 for (j = 0; j < spec->num_muxes; j++) {
3215 num_cons = snd_hda_get_connections(codec,
3218 HDA_MAX_NUM_INPUTS);
3219 for (k = 0; k < num_cons; k++)
3220 if (con_lst[k] == cfg->input_pins[i]) {
3227 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3228 imux->items[imux->num_items].index = index;
3232 if (imux->num_items) {
3234 * Set the current input for the muxes.
3235 * The STAC9221 has two input muxes with identical source
3236 * NID lists. Hopefully this won't get confused.
3238 for (i = 0; i < spec->num_muxes; i++) {
3239 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3240 AC_VERB_SET_CONNECT_SEL,
3241 imux->items[0].index);
3248 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3250 struct sigmatel_spec *spec = codec->spec;
3253 for (i = 0; i < spec->autocfg.line_outs; i++) {
3254 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3255 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3259 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3261 struct sigmatel_spec *spec = codec->spec;
3264 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3266 pin = spec->autocfg.hp_pins[i];
3267 if (pin) /* connect to front */
3268 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3270 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3272 pin = spec->autocfg.speaker_pins[i];
3273 if (pin) /* connect to front */
3274 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3278 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3280 struct sigmatel_spec *spec = codec->spec;
3282 int hp_speaker_swap = 0;
3284 if ((err = snd_hda_parse_pin_def_config(codec,
3286 spec->dmic_nids)) < 0)
3288 if (! spec->autocfg.line_outs)
3289 return 0; /* can't find valid pin config */
3291 /* If we have no real line-out pin and multiple hp-outs, HPs should
3292 * be set up as multi-channel outputs.
3294 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3295 spec->autocfg.hp_outs > 1) {
3296 /* Copy hp_outs to line_outs, backup line_outs in
3297 * speaker_outs so that the following routines can handle
3298 * HP pins as primary outputs.
3300 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3301 sizeof(spec->autocfg.line_out_pins));
3302 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3303 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3304 sizeof(spec->autocfg.hp_pins));
3305 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3306 hp_speaker_swap = 1;
3308 if (spec->autocfg.mono_out_pin) {
3309 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3310 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3311 u32 caps = query_amp_caps(codec,
3312 spec->autocfg.mono_out_pin, dir);
3313 hda_nid_t conn_list[1];
3315 /* get the mixer node and then the mono mux if it exists */
3316 if (snd_hda_get_connections(codec,
3317 spec->autocfg.mono_out_pin, conn_list, 1) &&
3318 snd_hda_get_connections(codec, conn_list[0],
3321 int wcaps = get_wcaps(codec, conn_list[0]);
3322 int wid_type = (wcaps & AC_WCAP_TYPE)
3323 >> AC_WCAP_TYPE_SHIFT;
3324 /* LR swap check, some stac925x have a mux that
3325 * changes the DACs output path instead of the
3328 if (wid_type == AC_WID_AUD_SEL &&
3329 !(wcaps & AC_WCAP_LR_SWAP))
3330 spec->mono_nid = conn_list[0];
3333 hda_nid_t nid = spec->autocfg.mono_out_pin;
3335 /* most mono outs have a least a mute/unmute switch */
3336 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3337 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3338 "Mono Playback Switch",
3339 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3342 /* check for volume support for the amp */
3343 if ((caps & AC_AMPCAP_NUM_STEPS)
3344 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3345 err = stac92xx_add_control(spec,
3346 STAC_CTL_WIDGET_VOL,
3347 "Mono Playback Volume",
3348 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3354 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3358 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3360 if (spec->multiout.num_dacs == 0)
3361 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3364 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3369 /* setup analog beep controls */
3370 if (spec->anabeep_nid > 0) {
3371 err = stac92xx_auto_create_beep_ctls(codec,
3377 /* setup digital beep controls and input device */
3378 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3379 if (spec->digbeep_nid > 0) {
3380 hda_nid_t nid = spec->digbeep_nid;
3382 err = stac92xx_auto_create_beep_ctls(codec, nid);
3385 err = snd_hda_attach_beep_device(codec, nid);
3391 if (hp_speaker_swap == 1) {
3392 /* Restore the hp_outs and line_outs */
3393 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3394 sizeof(spec->autocfg.line_out_pins));
3395 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3396 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3397 sizeof(spec->autocfg.speaker_pins));
3398 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3399 memset(spec->autocfg.speaker_pins, 0,
3400 sizeof(spec->autocfg.speaker_pins));
3401 spec->autocfg.speaker_outs = 0;
3404 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3409 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3414 if (spec->mono_nid > 0) {
3415 err = stac92xx_auto_create_mono_output_ctls(codec);
3419 if (spec->num_amps > 0) {
3420 err = stac92xx_auto_create_amp_output_ctls(codec);
3424 if (spec->num_dmics > 0 && !spec->dinput_mux)
3425 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3426 &spec->autocfg)) < 0)
3428 if (spec->num_muxes > 0) {
3429 err = stac92xx_auto_create_mux_input_ctls(codec);
3433 if (spec->num_smuxes > 0) {
3434 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3439 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3440 if (spec->multiout.max_channels > 2)
3441 spec->surr_switch = 1;
3443 if (spec->autocfg.dig_out_pin)
3444 spec->multiout.dig_out_nid = dig_out;
3445 if (dig_in && spec->autocfg.dig_in_pin)
3446 spec->dig_in_nid = dig_in;
3448 if (spec->kctls.list)
3449 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3451 spec->input_mux = &spec->private_imux;
3452 spec->dinput_mux = &spec->private_dimux;
3453 spec->sinput_mux = &spec->private_smux;
3454 spec->mono_mux = &spec->private_mono_mux;
3455 spec->amp_mux = &spec->private_amp_mux;
3459 /* add playback controls for HP output */
3460 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3461 struct auto_pin_cfg *cfg)
3463 struct sigmatel_spec *spec = codec->spec;
3464 hda_nid_t pin = cfg->hp_pins[0];
3465 unsigned int wid_caps;
3470 wid_caps = get_wcaps(codec, pin);
3471 if (wid_caps & AC_WCAP_UNSOL_CAP)
3472 spec->hp_detect = 1;
3477 /* add playback controls for LFE output */
3478 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3479 struct auto_pin_cfg *cfg)
3481 struct sigmatel_spec *spec = codec->spec;
3483 hda_nid_t lfe_pin = 0x0;
3487 * search speaker outs and line outs for a mono speaker pin
3488 * with an amp. If one is found, add LFE controls
3491 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3492 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3493 unsigned int wcaps = get_wcaps(codec, pin);
3494 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3495 if (wcaps == AC_WCAP_OUT_AMP)
3496 /* found a mono speaker with an amp, must be lfe */
3500 /* if speaker_outs is 0, then speakers may be in line_outs */
3501 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3502 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3503 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3504 unsigned int defcfg;
3505 defcfg = snd_hda_codec_read(codec, pin, 0,
3506 AC_VERB_GET_CONFIG_DEFAULT,
3508 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3509 unsigned int wcaps = get_wcaps(codec, pin);
3510 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3511 if (wcaps == AC_WCAP_OUT_AMP)
3512 /* found a mono speaker with an amp,
3520 err = create_controls(spec, "LFE", lfe_pin, 1);
3528 static int stac9200_parse_auto_config(struct hda_codec *codec)
3530 struct sigmatel_spec *spec = codec->spec;
3533 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3536 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3539 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3542 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3545 if (spec->autocfg.dig_out_pin)
3546 spec->multiout.dig_out_nid = 0x05;
3547 if (spec->autocfg.dig_in_pin)
3548 spec->dig_in_nid = 0x04;
3550 if (spec->kctls.list)
3551 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3553 spec->input_mux = &spec->private_imux;
3554 spec->dinput_mux = &spec->private_dimux;
3560 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3561 * funky external mute control using GPIO pins.
3564 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3565 unsigned int dir_mask, unsigned int data)
3567 unsigned int gpiostate, gpiomask, gpiodir;
3569 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3570 AC_VERB_GET_GPIO_DATA, 0);
3571 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3573 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3574 AC_VERB_GET_GPIO_MASK, 0);
3577 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3578 AC_VERB_GET_GPIO_DIRECTION, 0);
3579 gpiodir |= dir_mask;
3581 /* Configure GPIOx as CMOS */
3582 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3584 snd_hda_codec_write(codec, codec->afg, 0,
3585 AC_VERB_SET_GPIO_MASK, gpiomask);
3586 snd_hda_codec_read(codec, codec->afg, 0,
3587 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3591 snd_hda_codec_read(codec, codec->afg, 0,
3592 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3595 static int stac92xx_add_jack(struct hda_codec *codec,
3596 hda_nid_t nid, int type)
3598 struct sigmatel_spec *spec = codec->spec;
3599 struct sigmatel_jack *jack;
3600 int def_conf = snd_hda_codec_read(codec, nid,
3601 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3602 int connectivity = get_defcfg_connect(def_conf);
3605 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3608 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3609 jack = snd_array_new(&spec->jacks);
3615 sprintf(name, "%s at %s %s Jack",
3616 snd_hda_get_jack_type(def_conf),
3617 snd_hda_get_jack_connectivity(def_conf),
3618 snd_hda_get_jack_location(def_conf));
3620 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
3623 static int stac92xx_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3626 struct sigmatel_event *event;
3628 snd_array_init(&spec->events, sizeof(*event), 32);
3629 event = snd_array_new(&spec->events);
3638 static int stac92xx_event_data(struct hda_codec *codec, hda_nid_t nid)
3640 struct sigmatel_spec *spec = codec->spec;
3641 struct sigmatel_event *events = spec->events.list;
3644 for (i = 0; i < spec->events.used; i++)
3645 if (events[i].nid == nid)
3646 return events[i].data;
3651 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3654 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
3655 snd_hda_codec_write_cache(codec, nid, 0,
3656 AC_VERB_SET_UNSOLICITED_ENABLE,
3657 (AC_USRSP_EN | event | nid));
3661 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3664 for (i = 0; i < cfg->hp_outs; i++)
3665 if (cfg->hp_pins[i] == nid)
3666 return 1; /* nid is a HP-Out */
3668 return 0; /* nid is not a HP-Out */
3671 static void stac92xx_power_down(struct hda_codec *codec)
3673 struct sigmatel_spec *spec = codec->spec;
3675 /* power down inactive DACs */
3677 for (dac = spec->dac_list; *dac; dac++)
3678 if (!is_in_dac_nids(spec, *dac) &&
3679 spec->multiout.hp_nid != *dac)
3680 snd_hda_codec_write_cache(codec, *dac, 0,
3681 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3684 static int stac92xx_init(struct hda_codec *codec)
3686 struct sigmatel_spec *spec = codec->spec;
3687 struct auto_pin_cfg *cfg = &spec->autocfg;
3690 snd_hda_sequence_write(codec, spec->init);
3692 /* power down adcs initially */
3693 if (spec->powerdown_adcs)
3694 for (i = 0; i < spec->num_adcs; i++)
3695 snd_hda_codec_write_cache(codec,
3696 spec->adc_nids[i], 0,
3697 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3699 if (spec->hp_detect) {
3700 /* Enable unsolicited responses on the HP widget */
3701 for (i = 0; i < cfg->hp_outs; i++) {
3702 int type = SND_JACK_HEADPHONE;
3703 hda_nid_t nid = cfg->hp_pins[i];
3704 enable_pin_detect(codec, nid, STAC_HP_EVENT | nid);
3705 /* jack detection */
3706 if (cfg->hp_outs == i)
3707 type |= SND_JACK_LINEOUT;
3708 err = stac92xx_add_jack(codec, nid, type);
3713 /* force to enable the first line-out; the others are set up
3716 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3718 /* fake event to set up pins */
3719 codec->patch_ops.unsol_event(codec,
3720 (STAC_HP_EVENT | spec->autocfg.hp_pins[0]) << 26);
3722 stac92xx_auto_init_multi_out(codec);
3723 stac92xx_auto_init_hp_out(codec);
3725 for (i = 0; i < cfg->line_outs; i++) {
3726 err = stac92xx_add_jack(codec,
3727 cfg->line_out_pins[i], SND_JACK_LINEOUT);
3731 for (i = 0; i < AUTO_PIN_LAST; i++) {
3732 hda_nid_t nid = cfg->input_pins[i];
3734 unsigned int pinctl = snd_hda_codec_read(codec, nid,
3735 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3736 /* if PINCTL already set then skip */
3737 if (pinctl & AC_PINCAP_IN)
3739 pinctl = AC_PINCTL_IN_EN;
3740 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3741 pinctl |= stac92xx_get_vref(codec, nid);
3742 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3743 err = stac92xx_add_jack(codec, nid,
3744 SND_JACK_MICROPHONE);
3747 enable_pin_detect(codec, nid, STAC_INSERT_EVENT | nid);
3750 for (i = 0; i < spec->num_dmics; i++)
3751 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3753 for (i = 0; i < spec->num_pwrs; i++) {
3754 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3755 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3756 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3757 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3758 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3759 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3760 def_conf = get_defcfg_connect(def_conf);
3761 /* outputs are only ports capable of power management
3762 * any attempts on powering down a input port cause the
3763 * referenced VREF to act quirky.
3765 if (pinctl & AC_PINCTL_IN_EN)
3767 /* skip any ports that don't have jacks since presence
3768 * detection is useless */
3769 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
3771 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3772 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3775 stac92xx_power_down(codec);
3776 if (cfg->dig_out_pin)
3777 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3779 if (cfg->dig_in_pin)
3780 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3783 stac_gpio_set(codec, spec->gpio_mask,
3784 spec->gpio_dir, spec->gpio_data);
3789 static void stac92xx_free_jacks(struct hda_codec *codec)
3791 struct sigmatel_spec *spec = codec->spec;
3792 if (spec->jacks.list) {
3793 struct sigmatel_jack *jacks = spec->jacks.list;
3795 for (i = 0; i < spec->jacks.used; i++)
3796 snd_device_free(codec->bus->card, &jacks[i].jack);
3798 snd_array_free(&spec->jacks);
3801 static void stac92xx_free_kctls(struct hda_codec *codec)
3803 struct sigmatel_spec *spec = codec->spec;
3805 if (spec->kctls.list) {
3806 struct snd_kcontrol_new *kctl = spec->kctls.list;
3808 for (i = 0; i < spec->kctls.used; i++)
3809 kfree(kctl[i].name);
3811 snd_array_free(&spec->kctls);
3814 static void stac92xx_free(struct hda_codec *codec)
3816 struct sigmatel_spec *spec = codec->spec;
3821 if (spec->bios_pin_configs)
3822 kfree(spec->bios_pin_configs);
3823 stac92xx_free_jacks(codec);
3824 snd_array_free(&spec->events);
3827 snd_hda_detach_beep_device(codec);
3830 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3833 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3834 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3836 if (pin_ctl & AC_PINCTL_IN_EN) {
3838 * we need to check the current set-up direction of
3839 * shared input pins since they can be switched via
3840 * "xxx as Output" mixer switch
3842 struct sigmatel_spec *spec = codec->spec;
3843 struct auto_pin_cfg *cfg = &spec->autocfg;
3844 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3845 spec->line_switch) ||
3846 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3851 /* if setting pin direction bits, clear the current
3852 direction bits first */
3853 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3854 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3856 snd_hda_codec_write_cache(codec, nid, 0,
3857 AC_VERB_SET_PIN_WIDGET_CONTROL,
3861 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3864 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3865 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3866 snd_hda_codec_write_cache(codec, nid, 0,
3867 AC_VERB_SET_PIN_WIDGET_CONTROL,
3871 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3875 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3877 unsigned int pinctl;
3878 pinctl = snd_hda_codec_read(codec, nid, 0,
3879 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3880 if (pinctl & AC_PINCTL_IN_EN)
3881 return 0; /* mic- or line-input */
3883 return 1; /* HP-output */
3888 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3890 struct sigmatel_spec *spec = codec->spec;
3891 struct auto_pin_cfg *cfg = &spec->autocfg;
3892 int nid = cfg->hp_pins[cfg->hp_outs - 1];
3896 if (spec->gpio_mute)
3897 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3898 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3900 for (i = 0; i < cfg->hp_outs; i++) {
3903 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3905 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3909 /* disable lineouts, enable hp */
3910 if (spec->hp_switch)
3911 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3912 for (i = 0; i < cfg->line_outs; i++)
3913 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3915 for (i = 0; i < cfg->speaker_outs; i++)
3916 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3918 if (spec->eapd_mask)
3919 stac_gpio_set(codec, spec->gpio_mask,
3920 spec->gpio_dir, spec->gpio_data &
3923 /* enable lineouts, disable hp */
3924 if (spec->hp_switch)
3925 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3926 for (i = 0; i < cfg->line_outs; i++)
3927 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3929 for (i = 0; i < cfg->speaker_outs; i++)
3930 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3932 if (spec->eapd_mask)
3933 stac_gpio_set(codec, spec->gpio_mask,
3934 spec->gpio_dir, spec->gpio_data |
3937 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3938 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3941 static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3943 struct sigmatel_spec *spec = codec->spec;
3944 hda_nid_t nid = spec->pwr_nids[idx];
3946 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3948 presence = get_hp_pin_presence(codec, nid);
3950 /* several codecs have two power down bits */
3951 if (spec->pwr_mapping)
3952 idx = spec->pwr_mapping[idx];
3961 /* power down unused output ports */
3962 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3965 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
3967 struct sigmatel_spec *spec = codec->spec;
3968 struct sigmatel_jack *jacks = spec->jacks.list;
3972 for (i = 0; i < spec->jacks.used; i++) {
3973 if (jacks->nid == nid) {
3974 unsigned int pin_ctl =
3975 snd_hda_codec_read(codec, nid,
3976 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
3978 int type = jacks->type;
3979 if (type == (SND_JACK_LINEOUT
3980 | SND_JACK_HEADPHONE))
3981 type = (pin_ctl & AC_PINCTL_HP_EN)
3982 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
3983 snd_jack_report(jacks->jack,
3984 get_hp_pin_presence(codec, nid)
3992 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3994 struct sigmatel_spec *spec = codec->spec;
3995 int event = (res >> 26) & 0x70;
3996 int nid = res >> 26 & 0x0f;
4000 stac92xx_hp_detect(codec, res);
4002 case STAC_INSERT_EVENT:
4003 case STAC_PWR_EVENT:
4005 if (spec->num_pwrs > 0)
4006 stac92xx_pin_sense(codec, nid);
4007 stac92xx_report_jack(codec, nid);
4010 case STAC_VREF_EVENT: {
4011 int data = snd_hda_codec_read(codec, codec->afg, 0,
4012 AC_VERB_GET_GPIO_DATA, 0);
4013 int idx = stac92xx_event_data(codec, nid);
4014 /* toggle VREF state based on GPIOx status */
4015 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4016 !!(data & (1 << idx)));
4022 #ifdef SND_HDA_NEEDS_RESUME
4023 static int stac92xx_resume(struct hda_codec *codec)
4025 struct sigmatel_spec *spec = codec->spec;
4027 stac92xx_set_config_regs(codec);
4028 snd_hda_sequence_write(codec, spec->init);
4029 stac_gpio_set(codec, spec->gpio_mask,
4030 spec->gpio_dir, spec->gpio_data);
4031 snd_hda_codec_resume_amp(codec);
4032 snd_hda_codec_resume_cache(codec);
4033 /* power down inactive DACs */
4035 stac92xx_power_down(codec);
4036 /* invoke unsolicited event to reset the HP state */
4037 if (spec->hp_detect)
4038 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4043 static struct hda_codec_ops stac92xx_patch_ops = {
4044 .build_controls = stac92xx_build_controls,
4045 .build_pcms = stac92xx_build_pcms,
4046 .init = stac92xx_init,
4047 .free = stac92xx_free,
4048 .unsol_event = stac92xx_unsol_event,
4049 #ifdef SND_HDA_NEEDS_RESUME
4050 .resume = stac92xx_resume,
4054 static int patch_stac9200(struct hda_codec *codec)
4056 struct sigmatel_spec *spec;
4059 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4064 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4065 spec->pin_nids = stac9200_pin_nids;
4066 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4069 if (spec->board_config < 0) {
4070 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4071 err = stac92xx_save_bios_config_regs(codec);
4073 stac92xx_free(codec);
4076 spec->pin_configs = spec->bios_pin_configs;
4078 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4079 stac92xx_set_config_regs(codec);
4082 spec->multiout.max_channels = 2;
4083 spec->multiout.num_dacs = 1;
4084 spec->multiout.dac_nids = stac9200_dac_nids;
4085 spec->adc_nids = stac9200_adc_nids;
4086 spec->mux_nids = stac9200_mux_nids;
4087 spec->num_muxes = 1;
4088 spec->num_dmics = 0;
4092 if (spec->board_config == STAC_9200_GATEWAY ||
4093 spec->board_config == STAC_9200_OQO)
4094 spec->init = stac9200_eapd_init;
4096 spec->init = stac9200_core_init;
4097 spec->mixer = stac9200_mixer;
4099 if (spec->board_config == STAC_9200_PANASONIC) {
4100 spec->gpio_mask = spec->gpio_dir = 0x09;
4101 spec->gpio_data = 0x00;
4104 err = stac9200_parse_auto_config(codec);
4106 stac92xx_free(codec);
4110 codec->patch_ops = stac92xx_patch_ops;
4115 static int patch_stac925x(struct hda_codec *codec)
4117 struct sigmatel_spec *spec;
4120 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4125 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4126 spec->pin_nids = stac925x_pin_nids;
4127 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4131 if (spec->board_config < 0) {
4132 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4133 "using BIOS defaults\n");
4134 err = stac92xx_save_bios_config_regs(codec);
4136 stac92xx_free(codec);
4139 spec->pin_configs = spec->bios_pin_configs;
4140 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4141 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4142 stac92xx_set_config_regs(codec);
4145 spec->multiout.max_channels = 2;
4146 spec->multiout.num_dacs = 1;
4147 spec->multiout.dac_nids = stac925x_dac_nids;
4148 spec->adc_nids = stac925x_adc_nids;
4149 spec->mux_nids = stac925x_mux_nids;
4150 spec->num_muxes = 1;
4153 switch (codec->vendor_id) {
4154 case 0x83847632: /* STAC9202 */
4155 case 0x83847633: /* STAC9202D */
4156 case 0x83847636: /* STAC9251 */
4157 case 0x83847637: /* STAC9251D */
4158 spec->num_dmics = STAC925X_NUM_DMICS;
4159 spec->dmic_nids = stac925x_dmic_nids;
4160 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4161 spec->dmux_nids = stac925x_dmux_nids;
4164 spec->num_dmics = 0;
4168 spec->init = stac925x_core_init;
4169 spec->mixer = stac925x_mixer;
4171 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4173 if (spec->board_config < 0) {
4174 printk(KERN_WARNING "hda_codec: No auto-config is "
4175 "available, default to model=ref\n");
4176 spec->board_config = STAC_925x_REF;
4182 stac92xx_free(codec);
4186 codec->patch_ops = stac92xx_patch_ops;
4191 static struct hda_input_mux stac92hd73xx_dmux = {
4194 { "Analog Inputs", 0x0b },
4195 { "Digital Mic 1", 0x09 },
4196 { "Digital Mic 2", 0x0a },
4201 static int patch_stac92hd73xx(struct hda_codec *codec)
4203 struct sigmatel_spec *spec;
4204 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4207 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4212 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4213 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4214 spec->pin_nids = stac92hd73xx_pin_nids;
4215 spec->board_config = snd_hda_check_board_config(codec,
4216 STAC_92HD73XX_MODELS,
4217 stac92hd73xx_models,
4218 stac92hd73xx_cfg_tbl);
4220 if (spec->board_config < 0) {
4221 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4222 " STAC92HD73XX, using BIOS defaults\n");
4223 err = stac92xx_save_bios_config_regs(codec);
4225 stac92xx_free(codec);
4228 spec->pin_configs = spec->bios_pin_configs;
4230 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4231 stac92xx_set_config_regs(codec);
4234 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4235 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4237 if (spec->multiout.num_dacs < 0) {
4238 printk(KERN_WARNING "hda_codec: Could not determine "
4239 "number of channels defaulting to DAC count\n");
4240 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4243 switch (spec->multiout.num_dacs) {
4244 case 0x3: /* 6 Channel */
4245 spec->mixer = stac92hd73xx_6ch_mixer;
4246 spec->init = stac92hd73xx_6ch_core_init;
4248 case 0x4: /* 8 Channel */
4249 spec->mixer = stac92hd73xx_8ch_mixer;
4250 spec->init = stac92hd73xx_8ch_core_init;
4252 case 0x5: /* 10 Channel */
4253 spec->mixer = stac92hd73xx_10ch_mixer;
4254 spec->init = stac92hd73xx_10ch_core_init;
4257 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4258 spec->aloopback_mask = 0x01;
4259 spec->aloopback_shift = 8;
4261 spec->digbeep_nid = 0x1c;
4262 spec->mux_nids = stac92hd73xx_mux_nids;
4263 spec->adc_nids = stac92hd73xx_adc_nids;
4264 spec->dmic_nids = stac92hd73xx_dmic_nids;
4265 spec->dmux_nids = stac92hd73xx_dmux_nids;
4266 spec->smux_nids = stac92hd73xx_smux_nids;
4267 spec->amp_nids = stac92hd73xx_amp_nids;
4268 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4270 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4271 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4272 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4273 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4274 sizeof(stac92hd73xx_dmux));
4276 switch (spec->board_config) {
4278 spec->init = dell_eq_core_init;
4279 spec->num_smuxes = 0;
4280 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4281 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4283 switch (codec->subsystem_id) {
4284 case 0x1028025e: /* Analog Mics */
4286 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4287 spec->num_dmics = 0;
4288 spec->private_dimux.num_items = 1;
4290 case 0x10280271: /* Digital Mics */
4292 spec->init = dell_m6_core_init;
4296 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4297 spec->num_dmics = 1;
4298 spec->private_dimux.num_items = 2;
4300 case 0x10280256: /* Both */
4302 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4303 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4304 spec->num_dmics = 1;
4305 spec->private_dimux.num_items = 2;
4310 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4311 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4313 if (spec->board_config > STAC_92HD73XX_REF) {
4314 /* GPIO0 High = Enable EAPD */
4315 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4316 spec->gpio_data = 0x01;
4318 spec->dinput_mux = &spec->private_dimux;
4320 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4321 spec->pwr_nids = stac92hd73xx_pwr_nids;
4323 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
4326 if (spec->board_config < 0) {
4327 printk(KERN_WARNING "hda_codec: No auto-config is "
4328 "available, default to model=ref\n");
4329 spec->board_config = STAC_92HD73XX_REF;
4336 stac92xx_free(codec);
4340 codec->patch_ops = stac92xx_patch_ops;
4345 static struct hda_input_mux stac92hd83xxx_dmux = {
4348 { "Analog Inputs", 0x03 },
4349 { "Digital Mic 1", 0x04 },
4350 { "Digital Mic 2", 0x05 },
4354 static int patch_stac92hd83xxx(struct hda_codec *codec)
4356 struct sigmatel_spec *spec;
4359 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4364 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
4365 spec->mono_nid = 0x19;
4366 spec->digbeep_nid = 0x21;
4367 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4368 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4369 spec->adc_nids = stac92hd83xxx_adc_nids;
4370 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4371 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4372 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4373 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4375 spec->init = stac92hd83xxx_core_init;
4376 switch (codec->vendor_id) {
4378 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4382 spec->init++; /* switch to config #2 */
4383 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4386 spec->mixer = stac92hd83xxx_mixer;
4387 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4388 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4389 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4390 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4391 spec->dinput_mux = &stac92hd83xxx_dmux;
4392 spec->pin_nids = stac92hd83xxx_pin_nids;
4393 spec->board_config = snd_hda_check_board_config(codec,
4394 STAC_92HD83XXX_MODELS,
4395 stac92hd83xxx_models,
4396 stac92hd83xxx_cfg_tbl);
4398 if (spec->board_config < 0) {
4399 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4400 " STAC92HD83XXX, using BIOS defaults\n");
4401 err = stac92xx_save_bios_config_regs(codec);
4403 stac92xx_free(codec);
4406 spec->pin_configs = spec->bios_pin_configs;
4408 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4409 stac92xx_set_config_regs(codec);
4412 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4414 if (spec->board_config < 0) {
4415 printk(KERN_WARNING "hda_codec: No auto-config is "
4416 "available, default to model=ref\n");
4417 spec->board_config = STAC_92HD83XXX_REF;
4424 stac92xx_free(codec);
4428 codec->patch_ops = stac92xx_patch_ops;
4433 #ifdef SND_HDA_NEEDS_RESUME
4434 static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4436 struct sigmatel_spec *spec = codec->spec;
4438 snd_hda_codec_write_cache(codec, codec->afg, 0,
4439 AC_VERB_SET_POWER_STATE, pwr);
4442 for (i = 0; i < spec->num_adcs; i++) {
4443 snd_hda_codec_write_cache(codec,
4444 spec->adc_nids[i], 0,
4445 AC_VERB_SET_POWER_STATE, pwr);
4449 static int stac92hd71xx_resume(struct hda_codec *codec)
4451 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4452 return stac92xx_resume(codec);
4455 static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4457 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4463 static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4464 .build_controls = stac92xx_build_controls,
4465 .build_pcms = stac92xx_build_pcms,
4466 .init = stac92xx_init,
4467 .free = stac92xx_free,
4468 .unsol_event = stac92xx_unsol_event,
4469 #ifdef SND_HDA_NEEDS_RESUME
4470 .resume = stac92hd71xx_resume,
4471 .suspend = stac92hd71xx_suspend,
4475 static struct hda_input_mux stac92hd71bxx_dmux = {
4478 { "Analog Inputs", 0x00 },
4480 { "Digital Mic 1", 0x02 },
4481 { "Digital Mic 2", 0x03 },
4485 static int patch_stac92hd71bxx(struct hda_codec *codec)
4487 struct sigmatel_spec *spec;
4490 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4495 codec->patch_ops = stac92xx_patch_ops;
4496 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
4497 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4498 spec->pin_nids = stac92hd71bxx_pin_nids;
4499 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4500 sizeof(stac92hd71bxx_dmux));
4501 spec->board_config = snd_hda_check_board_config(codec,
4502 STAC_92HD71BXX_MODELS,
4503 stac92hd71bxx_models,
4504 stac92hd71bxx_cfg_tbl);
4506 if (spec->board_config < 0) {
4507 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4508 " STAC92HD71BXX, using BIOS defaults\n");
4509 err = stac92xx_save_bios_config_regs(codec);
4511 stac92xx_free(codec);
4514 spec->pin_configs = spec->bios_pin_configs;
4516 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4517 stac92xx_set_config_regs(codec);
4520 switch (codec->vendor_id) {
4521 case 0x111d76b6: /* 4 Port without Analog Mixer */
4523 case 0x111d76b4: /* 6 Port without Analog Mixer */
4525 spec->mixer = stac92hd71bxx_mixer;
4526 spec->init = stac92hd71bxx_core_init;
4527 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4529 case 0x111d7608: /* 5 Port with Analog Mixer */
4530 switch (codec->subsystem_id) {
4532 /* Enable VREF power saving on GPIO1 detect */
4533 snd_hda_codec_write(codec, codec->afg, 0,
4534 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4535 snd_hda_codec_write_cache(codec, codec->afg, 0,
4536 AC_VERB_SET_UNSOLICITED_ENABLE,
4537 (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
4538 err = stac92xx_add_event(spec, codec->afg, 0x02);
4541 spec->gpio_mask |= 0x02;
4544 if ((codec->revision_id & 0xf) == 0 ||
4545 (codec->revision_id & 0xf) == 1) {
4546 #ifdef SND_HDA_NEEDS_RESUME
4547 codec->patch_ops = stac92hd71bxx_patch_ops;
4549 spec->stream_delay = 40; /* 40 milliseconds */
4552 /* no output amps */
4554 spec->mixer = stac92hd71bxx_analog_mixer;
4555 spec->dinput_mux = &spec->private_dimux;
4558 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4559 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4561 case 0x111d7603: /* 6 Port with Analog Mixer */
4562 if ((codec->revision_id & 0xf) == 1) {
4563 #ifdef SND_HDA_NEEDS_RESUME
4564 codec->patch_ops = stac92hd71bxx_patch_ops;
4566 spec->stream_delay = 40; /* 40 milliseconds */
4569 /* no output amps */
4573 spec->dinput_mux = &spec->private_dimux;
4574 spec->mixer = stac92hd71bxx_analog_mixer;
4575 spec->init = stac92hd71bxx_analog_core_init;
4576 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4579 spec->aloopback_mask = 0x50;
4580 spec->aloopback_shift = 0;
4582 if (spec->board_config > STAC_92HD71BXX_REF) {
4584 spec->gpio_mask = 0x01;
4585 spec->gpio_dir = 0x01;
4586 spec->gpio_data = 0x01;
4589 spec->powerdown_adcs = 1;
4590 spec->digbeep_nid = 0x26;
4591 spec->mux_nids = stac92hd71bxx_mux_nids;
4592 spec->adc_nids = stac92hd71bxx_adc_nids;
4593 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4594 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4595 spec->smux_nids = stac92hd71bxx_smux_nids;
4596 spec->pwr_nids = stac92hd71bxx_pwr_nids;
4598 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4599 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
4601 switch (spec->board_config) {
4603 spec->num_dmics = 0;
4604 spec->num_smuxes = 0;
4605 spec->num_dmuxes = 0;
4607 /* enable internal microphone */
4608 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4609 stac92xx_auto_set_pinctl(codec, 0x0e,
4610 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
4613 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4614 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4615 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4618 spec->multiout.num_dacs = 1;
4619 spec->multiout.hp_nid = 0x11;
4620 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4621 if (spec->dinput_mux)
4622 spec->private_dimux.num_items +=
4624 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
4626 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4628 if (spec->board_config < 0) {
4629 printk(KERN_WARNING "hda_codec: No auto-config is "
4630 "available, default to model=ref\n");
4631 spec->board_config = STAC_92HD71BXX_REF;
4638 stac92xx_free(codec);
4645 static int patch_stac922x(struct hda_codec *codec)
4647 struct sigmatel_spec *spec;
4650 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4655 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
4656 spec->pin_nids = stac922x_pin_nids;
4657 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4660 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
4661 spec->gpio_mask = spec->gpio_dir = 0x03;
4662 spec->gpio_data = 0x03;
4663 /* Intel Macs have all same PCI SSID, so we need to check
4664 * codec SSID to distinguish the exact models
4666 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
4667 switch (codec->subsystem_id) {
4670 spec->board_config = STAC_INTEL_MAC_V1;
4674 spec->board_config = STAC_INTEL_MAC_V2;
4682 spec->board_config = STAC_INTEL_MAC_V3;
4686 spec->board_config = STAC_INTEL_MAC_V4;
4690 spec->board_config = STAC_INTEL_MAC_V5;
4693 spec->board_config = STAC_INTEL_MAC_V3;
4699 if (spec->board_config < 0) {
4700 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4701 "using BIOS defaults\n");
4702 err = stac92xx_save_bios_config_regs(codec);
4704 stac92xx_free(codec);
4707 spec->pin_configs = spec->bios_pin_configs;
4708 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
4709 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4710 stac92xx_set_config_regs(codec);
4713 spec->adc_nids = stac922x_adc_nids;
4714 spec->mux_nids = stac922x_mux_nids;
4715 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
4716 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
4717 spec->num_dmics = 0;
4720 spec->init = stac922x_core_init;
4721 spec->mixer = stac922x_mixer;
4723 spec->multiout.dac_nids = spec->dac_nids;
4725 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
4727 if (spec->board_config < 0) {
4728 printk(KERN_WARNING "hda_codec: No auto-config is "
4729 "available, default to model=ref\n");
4730 spec->board_config = STAC_D945_REF;
4736 stac92xx_free(codec);
4740 codec->patch_ops = stac92xx_patch_ops;
4742 /* Fix Mux capture level; max to 2 */
4743 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4744 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4745 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4746 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4747 (0 << AC_AMPCAP_MUTE_SHIFT));
4752 static int patch_stac927x(struct hda_codec *codec)
4754 struct sigmatel_spec *spec;
4757 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4762 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
4763 spec->pin_nids = stac927x_pin_nids;
4764 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4768 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4769 if (spec->board_config < 0)
4770 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4771 "STAC927x, using BIOS defaults\n");
4772 err = stac92xx_save_bios_config_regs(codec);
4774 stac92xx_free(codec);
4777 spec->pin_configs = spec->bios_pin_configs;
4779 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4780 stac92xx_set_config_regs(codec);
4783 spec->digbeep_nid = 0x23;
4784 spec->adc_nids = stac927x_adc_nids;
4785 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4786 spec->mux_nids = stac927x_mux_nids;
4787 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
4788 spec->smux_nids = stac927x_smux_nids;
4789 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
4790 spec->spdif_labels = stac927x_spdif_labels;
4791 spec->dac_list = stac927x_dac_nids;
4792 spec->multiout.dac_nids = spec->dac_nids;
4794 switch (spec->board_config) {
4797 /* GPIO0 High = Enable EAPD */
4798 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
4799 spec->gpio_data = 0x01;
4800 spec->num_dmics = 0;
4802 spec->init = d965_core_init;
4803 spec->mixer = stac927x_mixer;
4805 case STAC_DELL_BIOS:
4806 switch (codec->subsystem_id) {
4809 /* correct the device field to SPDIF out */
4810 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4813 /* configure the analog microphone on some laptops */
4814 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
4815 /* correct the front output jack as a hp out */
4816 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
4817 /* correct the front input jack as a mic */
4818 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4821 /* GPIO2 High = Enable EAPD */
4822 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
4823 spec->gpio_data = 0x04;
4824 spec->dmic_nids = stac927x_dmic_nids;
4825 spec->num_dmics = STAC927X_NUM_DMICS;
4827 spec->init = d965_core_init;
4828 spec->mixer = stac927x_mixer;
4829 spec->dmux_nids = stac927x_dmux_nids;
4830 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
4833 if (spec->board_config > STAC_D965_REF) {
4834 /* GPIO0 High = Enable EAPD */
4835 spec->eapd_mask = spec->gpio_mask = 0x01;
4836 spec->gpio_dir = spec->gpio_data = 0x01;
4838 spec->num_dmics = 0;
4840 spec->init = stac927x_core_init;
4841 spec->mixer = stac927x_mixer;
4845 spec->aloopback_mask = 0x40;
4846 spec->aloopback_shift = 0;
4848 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
4850 if (spec->board_config < 0) {
4851 printk(KERN_WARNING "hda_codec: No auto-config is "
4852 "available, default to model=ref\n");
4853 spec->board_config = STAC_D965_REF;
4859 stac92xx_free(codec);
4863 codec->patch_ops = stac92xx_patch_ops;
4867 * The STAC927x seem to require fairly long delays for certain
4868 * command sequences. With too short delays (even if the answer
4869 * is set to RIRB properly), it results in the silence output
4870 * on some hardwares like Dell.
4872 * The below flag enables the longer delay (see get_response
4875 codec->bus->needs_damn_long_delay = 1;
4880 static int patch_stac9205(struct hda_codec *codec)
4882 struct sigmatel_spec *spec;
4885 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4890 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
4891 spec->pin_nids = stac9205_pin_nids;
4892 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4896 if (spec->board_config < 0) {
4897 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4898 err = stac92xx_save_bios_config_regs(codec);
4900 stac92xx_free(codec);
4903 spec->pin_configs = spec->bios_pin_configs;
4905 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4906 stac92xx_set_config_regs(codec);
4909 spec->digbeep_nid = 0x23;
4910 spec->adc_nids = stac9205_adc_nids;
4911 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
4912 spec->mux_nids = stac9205_mux_nids;
4913 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
4914 spec->smux_nids = stac9205_smux_nids;
4915 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
4916 spec->dmic_nids = stac9205_dmic_nids;
4917 spec->num_dmics = STAC9205_NUM_DMICS;
4918 spec->dmux_nids = stac9205_dmux_nids;
4919 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
4922 spec->init = stac9205_core_init;
4923 spec->mixer = stac9205_mixer;
4925 spec->aloopback_mask = 0x40;
4926 spec->aloopback_shift = 0;
4927 spec->multiout.dac_nids = spec->dac_nids;
4929 switch (spec->board_config){
4930 case STAC_9205_DELL_M43:
4931 /* Enable SPDIF in/out */
4932 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4933 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
4935 /* Enable unsol response for GPIO4/Dock HP connection */
4936 snd_hda_codec_write(codec, codec->afg, 0,
4937 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4938 snd_hda_codec_write_cache(codec, codec->afg, 0,
4939 AC_VERB_SET_UNSOLICITED_ENABLE,
4940 (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
4941 err = stac92xx_add_event(spec, codec->afg, 0x01);
4945 spec->gpio_dir = 0x0b;
4946 spec->eapd_mask = 0x01;
4947 spec->gpio_mask = 0x1b;
4948 spec->gpio_mute = 0x10;
4949 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
4952 spec->gpio_data = 0x01;
4955 /* SPDIF-In enabled */
4958 /* GPIO0 High = EAPD */
4959 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4960 spec->gpio_data = 0x01;
4964 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
4966 if (spec->board_config < 0) {
4967 printk(KERN_WARNING "hda_codec: No auto-config is "
4968 "available, default to model=ref\n");
4969 spec->board_config = STAC_9205_REF;
4975 stac92xx_free(codec);
4979 codec->patch_ops = stac92xx_patch_ops;
4988 /* static config for Sony VAIO FE550G and Sony VAIO AR */
4989 static hda_nid_t vaio_dacs[] = { 0x2 };
4990 #define VAIO_HP_DAC 0x5
4991 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4992 static hda_nid_t vaio_mux_nids[] = { 0x15 };
4994 static struct hda_input_mux vaio_mux = {
4997 /* { "HP", 0x0 }, */
4998 { "Mic Jack", 0x1 },
4999 { "Internal Mic", 0x2 },
5004 static struct hda_verb vaio_init[] = {
5005 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5006 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
5007 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5008 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5009 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5011 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5012 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5013 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5014 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5015 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5016 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5020 static struct hda_verb vaio_ar_init[] = {
5021 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5022 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5023 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5024 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5025 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5026 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5027 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5028 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5029 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5030 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5031 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5033 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5037 /* bind volumes of both NID 0x02 and 0x05 */
5038 static struct hda_bind_ctls vaio_bind_master_vol = {
5039 .ops = &snd_hda_bind_vol,
5041 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5042 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5047 /* bind volumes of both NID 0x02 and 0x05 */
5048 static struct hda_bind_ctls vaio_bind_master_sw = {
5049 .ops = &snd_hda_bind_sw,
5051 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5052 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5057 static struct snd_kcontrol_new vaio_mixer[] = {
5058 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5059 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
5060 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5061 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5062 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5065 .name = "Capture Source",
5067 .info = stac92xx_mux_enum_info,
5068 .get = stac92xx_mux_enum_get,
5069 .put = stac92xx_mux_enum_put,
5074 static struct snd_kcontrol_new vaio_ar_mixer[] = {
5075 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5076 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
5077 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5078 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5079 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5080 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5081 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5083 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5084 .name = "Capture Source",
5086 .info = stac92xx_mux_enum_info,
5087 .get = stac92xx_mux_enum_get,
5088 .put = stac92xx_mux_enum_put,
5093 static struct hda_codec_ops stac9872_patch_ops = {
5094 .build_controls = stac92xx_build_controls,
5095 .build_pcms = stac92xx_build_pcms,
5096 .init = stac92xx_init,
5097 .free = stac92xx_free,
5098 #ifdef SND_HDA_NEEDS_RESUME
5099 .resume = stac92xx_resume,
5103 static int stac9872_vaio_init(struct hda_codec *codec)
5107 err = stac92xx_init(codec);
5110 if (codec->patch_ops.unsol_event)
5111 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5115 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5117 if (get_hp_pin_presence(codec, 0x0a)) {
5118 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5119 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5121 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5122 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5126 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5128 switch (res >> 26) {
5130 stac9872_vaio_hp_detect(codec, res);
5135 static struct hda_codec_ops stac9872_vaio_patch_ops = {
5136 .build_controls = stac92xx_build_controls,
5137 .build_pcms = stac92xx_build_pcms,
5138 .init = stac9872_vaio_init,
5139 .free = stac92xx_free,
5140 .unsol_event = stac9872_vaio_unsol_event,
5142 .resume = stac92xx_resume,
5146 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5148 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5150 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5152 /* AR Series. id=0x83847664 and subsys=104D1300 */
5157 static const char *stac9872_models[STAC_9872_MODELS] = {
5158 [CXD9872RD_VAIO] = "vaio",
5159 [CXD9872AKD_VAIO] = "vaio-ar",
5162 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5163 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5164 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5165 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
5166 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
5170 static int patch_stac9872(struct hda_codec *codec)
5172 struct sigmatel_spec *spec;
5175 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5178 if (board_config < 0)
5179 /* unknown config, let generic-parser do its job... */
5180 return snd_hda_parse_generic_codec(codec);
5182 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5187 switch (board_config) {
5188 case CXD9872RD_VAIO:
5189 case STAC9872AK_VAIO:
5190 case STAC9872K_VAIO:
5191 spec->mixer = vaio_mixer;
5192 spec->init = vaio_init;
5193 spec->multiout.max_channels = 2;
5194 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5195 spec->multiout.dac_nids = vaio_dacs;
5196 spec->multiout.hp_nid = VAIO_HP_DAC;
5197 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5198 spec->adc_nids = vaio_adcs;
5200 spec->input_mux = &vaio_mux;
5201 spec->mux_nids = vaio_mux_nids;
5202 codec->patch_ops = stac9872_vaio_patch_ops;
5205 case CXD9872AKD_VAIO:
5206 spec->mixer = vaio_ar_mixer;
5207 spec->init = vaio_ar_init;
5208 spec->multiout.max_channels = 2;
5209 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5210 spec->multiout.dac_nids = vaio_dacs;
5211 spec->multiout.hp_nid = VAIO_HP_DAC;
5212 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5214 spec->adc_nids = vaio_adcs;
5215 spec->input_mux = &vaio_mux;
5216 spec->mux_nids = vaio_mux_nids;
5217 codec->patch_ops = stac9872_patch_ops;
5228 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5229 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5230 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5231 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5232 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5233 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5234 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5235 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5236 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5237 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5238 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5239 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5240 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5241 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5242 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5243 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5244 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5245 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5246 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5247 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5248 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5249 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5250 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5251 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5252 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5253 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5254 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5255 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5256 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5257 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5258 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5259 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5260 /* The following does not take into account .id=0x83847661 when subsys =
5261 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5262 * currently not fully supported.
5264 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5265 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5266 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5267 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5268 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5269 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5270 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5271 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5272 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5273 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5274 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5275 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5276 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5277 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5278 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5279 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5280 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5281 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5282 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5283 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5284 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5285 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5286 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5287 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5288 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5289 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },