2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include <sound/asoundef.h>
33 #include "hda_codec.h"
34 #include "hda_local.h"
35 #include "hda_patch.h"
38 #define NUM_CONTROL_ALLOC 32
40 #define STAC_VREF_EVENT 0x00
41 #define STAC_INSERT_EVENT 0x10
42 #define STAC_PWR_EVENT 0x20
43 #define STAC_HP_EVENT 0x30
111 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
112 * is given, one of the above models will be
113 * chosen according to the subsystem id. */
114 /* for backward compatibility */
138 struct sigmatel_spec {
139 struct snd_kcontrol_new *mixers[4];
140 unsigned int num_mixers;
143 unsigned int eapd_switch: 1;
144 unsigned int surr_switch: 1;
145 unsigned int line_switch: 1;
146 unsigned int mic_switch: 1;
147 unsigned int alt_switch: 1;
148 unsigned int hp_detect: 1;
149 unsigned int spdif_mute: 1;
152 unsigned int eapd_mask;
153 unsigned int gpio_mask;
154 unsigned int gpio_dir;
155 unsigned int gpio_data;
156 unsigned int gpio_mute;
159 unsigned int stream_delay;
161 /* analog loopback */
162 unsigned char aloopback_mask;
163 unsigned char aloopback_shift;
165 /* power management */
166 unsigned int num_pwrs;
167 unsigned int *pwr_mapping;
172 struct hda_input_mux *mono_mux;
173 struct hda_input_mux *amp_mux;
174 unsigned int cur_mmux;
175 struct hda_multi_out multiout;
176 hda_nid_t dac_nids[5];
180 unsigned int num_adcs;
182 unsigned int num_muxes;
183 hda_nid_t *dmic_nids;
184 unsigned int num_dmics;
185 hda_nid_t *dmux_nids;
186 unsigned int num_dmuxes;
187 hda_nid_t *smux_nids;
188 unsigned int num_smuxes;
189 const char **spdif_labels;
191 hda_nid_t dig_in_nid;
193 hda_nid_t anabeep_nid;
194 hda_nid_t digbeep_nid;
198 unsigned int num_pins;
199 unsigned int *pin_configs;
200 unsigned int *bios_pin_configs;
202 /* codec specific stuff */
203 struct hda_verb *init;
204 struct snd_kcontrol_new *mixer;
207 struct hda_input_mux *dinput_mux;
208 unsigned int cur_dmux[2];
209 struct hda_input_mux *input_mux;
210 unsigned int cur_mux[3];
211 struct hda_input_mux *sinput_mux;
212 unsigned int cur_smux[2];
213 unsigned int cur_amux;
215 unsigned int num_amps;
216 unsigned int powerdown_adcs;
219 unsigned int io_switch[2];
220 unsigned int clfe_swap;
221 unsigned int hp_switch; /* NID of HP as line-out */
222 unsigned int aloopback;
224 struct hda_pcm pcm_rec[2]; /* PCM information */
226 /* dynamic controls and input_mux */
227 struct auto_pin_cfg autocfg;
228 unsigned int num_kctl_alloc, num_kctl_used;
229 struct snd_kcontrol_new *kctl_alloc;
230 struct hda_input_mux private_dimux;
231 struct hda_input_mux private_imux;
232 struct hda_input_mux private_smux;
233 struct hda_input_mux private_amp_mux;
234 struct hda_input_mux private_mono_mux;
237 static hda_nid_t stac9200_adc_nids[1] = {
241 static hda_nid_t stac9200_mux_nids[1] = {
245 static hda_nid_t stac9200_dac_nids[1] = {
249 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
250 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
254 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
258 static hda_nid_t stac92hd73xx_adc_nids[2] = {
262 #define DELL_M6_AMP 2
263 static hda_nid_t stac92hd73xx_amp_nids[3] = {
267 #define STAC92HD73XX_NUM_DMICS 2
268 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
272 #define STAC92HD73_DAC_COUNT 5
273 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
274 0x15, 0x16, 0x17, 0x18, 0x19,
277 static hda_nid_t stac92hd73xx_mux_nids[4] = {
278 0x28, 0x29, 0x2a, 0x2b,
281 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
285 static hda_nid_t stac92hd73xx_smux_nids[2] = {
289 #define STAC92HD83XXX_NUM_DMICS 2
290 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
294 #define STAC92HD81_DAC_COUNT 2
295 #define STAC92HD83_DAC_COUNT 3
296 static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
300 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
304 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
308 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
312 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
316 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
317 0x03, 0x0c, 0x10, 0x40,
320 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
324 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
328 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
332 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
336 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
340 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
344 #define STAC92HD71BXX_NUM_DMICS 2
345 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
349 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
353 static hda_nid_t stac925x_adc_nids[1] = {
357 static hda_nid_t stac925x_mux_nids[1] = {
361 static hda_nid_t stac925x_dac_nids[1] = {
365 #define STAC925X_NUM_DMICS 1
366 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
370 static hda_nid_t stac925x_dmux_nids[1] = {
374 static hda_nid_t stac922x_adc_nids[2] = {
378 static hda_nid_t stac922x_mux_nids[2] = {
382 static hda_nid_t stac927x_adc_nids[3] = {
386 static hda_nid_t stac927x_mux_nids[3] = {
390 static hda_nid_t stac927x_smux_nids[1] = {
394 static hda_nid_t stac927x_dac_nids[6] = {
395 0x02, 0x03, 0x04, 0x05, 0x06, 0
398 static hda_nid_t stac927x_dmux_nids[1] = {
402 #define STAC927X_NUM_DMICS 2
403 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
407 static const char *stac927x_spdif_labels[5] = {
408 "Digital Playback", "ADAT", "Analog Mux 1",
409 "Analog Mux 2", "Analog Mux 3"
412 static hda_nid_t stac9205_adc_nids[2] = {
416 static hda_nid_t stac9205_mux_nids[2] = {
420 static hda_nid_t stac9205_dmux_nids[1] = {
424 static hda_nid_t stac9205_smux_nids[1] = {
428 #define STAC9205_NUM_DMICS 2
429 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
433 static hda_nid_t stac9200_pin_nids[8] = {
434 0x08, 0x09, 0x0d, 0x0e,
435 0x0f, 0x10, 0x11, 0x12,
438 static hda_nid_t stac925x_pin_nids[8] = {
439 0x07, 0x08, 0x0a, 0x0b,
440 0x0c, 0x0d, 0x10, 0x11,
443 static hda_nid_t stac922x_pin_nids[10] = {
444 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
445 0x0f, 0x10, 0x11, 0x15, 0x1b,
448 static hda_nid_t stac92hd73xx_pin_nids[13] = {
449 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
450 0x0f, 0x10, 0x11, 0x12, 0x13,
454 static hda_nid_t stac92hd83xxx_pin_nids[14] = {
455 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
456 0x0f, 0x10, 0x11, 0x12, 0x13,
457 0x1d, 0x1e, 0x1f, 0x20
459 static hda_nid_t stac92hd71bxx_pin_nids[11] = {
460 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
461 0x0f, 0x14, 0x18, 0x19, 0x1e,
465 static hda_nid_t stac927x_pin_nids[14] = {
466 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
467 0x0f, 0x10, 0x11, 0x12, 0x13,
468 0x14, 0x21, 0x22, 0x23,
471 static hda_nid_t stac9205_pin_nids[12] = {
472 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
473 0x0f, 0x14, 0x16, 0x17, 0x18,
477 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
479 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
480 struct snd_ctl_elem_value *ucontrol)
482 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
483 struct sigmatel_spec *spec = codec->spec;
484 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
486 kcontrol->private_value ^= get_amp_nid(kcontrol);
487 kcontrol->private_value |= nid;
489 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
492 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
493 struct snd_ctl_elem_value *ucontrol)
495 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
496 struct sigmatel_spec *spec = codec->spec;
497 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
499 kcontrol->private_value ^= get_amp_nid(kcontrol);
500 kcontrol->private_value |= nid;
502 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
505 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
506 struct snd_ctl_elem_info *uinfo)
508 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
509 struct sigmatel_spec *spec = codec->spec;
510 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
513 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
514 struct snd_ctl_elem_value *ucontrol)
516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
517 struct sigmatel_spec *spec = codec->spec;
518 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
520 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
524 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 struct sigmatel_spec *spec = codec->spec;
529 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
531 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
532 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
535 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_info *uinfo)
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 struct sigmatel_spec *spec = codec->spec;
540 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
543 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
544 struct snd_ctl_elem_value *ucontrol)
546 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
547 struct sigmatel_spec *spec = codec->spec;
548 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
550 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
554 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
555 struct snd_ctl_elem_value *ucontrol)
557 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
558 struct sigmatel_spec *spec = codec->spec;
559 struct hda_input_mux *smux = &spec->private_smux;
560 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
564 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
565 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
569 if (spec->spdif_mute) {
571 nid = spec->multiout.dig_out_nid;
573 nid = codec->slave_dig_outs[smux_idx - 1];
574 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
577 val = AMP_OUT_UNMUTE;
578 /* un/mute SPDIF out */
579 snd_hda_codec_write_cache(codec, nid, 0,
580 AC_VERB_SET_AMP_GAIN_MUTE, val);
585 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
587 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
588 struct sigmatel_spec *spec = codec->spec;
589 return snd_hda_input_mux_info(spec->input_mux, uinfo);
592 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
594 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
595 struct sigmatel_spec *spec = codec->spec;
596 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
598 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
602 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
604 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
605 struct sigmatel_spec *spec = codec->spec;
606 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
608 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
609 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
612 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
613 struct snd_ctl_elem_info *uinfo)
615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
616 struct sigmatel_spec *spec = codec->spec;
617 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
620 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
621 struct snd_ctl_elem_value *ucontrol)
623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
624 struct sigmatel_spec *spec = codec->spec;
626 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
630 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
634 struct sigmatel_spec *spec = codec->spec;
636 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
637 spec->mono_nid, &spec->cur_mmux);
640 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_info *uinfo)
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 struct sigmatel_spec *spec = codec->spec;
645 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
648 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
649 struct snd_ctl_elem_value *ucontrol)
651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
652 struct sigmatel_spec *spec = codec->spec;
654 ucontrol->value.enumerated.item[0] = spec->cur_amux;
658 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
659 struct snd_ctl_elem_value *ucontrol)
661 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
662 struct sigmatel_spec *spec = codec->spec;
663 struct snd_kcontrol *ctl =
664 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
668 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
669 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
671 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
675 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
677 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
678 struct snd_ctl_elem_value *ucontrol)
680 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
681 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
682 struct sigmatel_spec *spec = codec->spec;
684 ucontrol->value.integer.value[0] = !!(spec->aloopback &
685 (spec->aloopback_mask << idx));
689 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
690 struct snd_ctl_elem_value *ucontrol)
692 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
693 struct sigmatel_spec *spec = codec->spec;
694 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
695 unsigned int dac_mode;
696 unsigned int val, idx_val;
698 idx_val = spec->aloopback_mask << idx;
699 if (ucontrol->value.integer.value[0])
700 val = spec->aloopback | idx_val;
702 val = spec->aloopback & ~idx_val;
703 if (spec->aloopback == val)
706 spec->aloopback = val;
708 /* Only return the bits defined by the shift value of the
709 * first two bytes of the mask
711 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
712 kcontrol->private_value & 0xFFFF, 0x0);
713 dac_mode >>= spec->aloopback_shift;
715 if (spec->aloopback & idx_val) {
716 snd_hda_power_up(codec);
719 snd_hda_power_down(codec);
720 dac_mode &= ~idx_val;
723 snd_hda_codec_write_cache(codec, codec->afg, 0,
724 kcontrol->private_value >> 16, dac_mode);
729 static struct hda_verb stac9200_core_init[] = {
730 /* set dac0mux for dac converter */
731 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
735 static struct hda_verb stac9200_eapd_init[] = {
736 /* set dac0mux for dac converter */
737 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
738 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
742 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
743 /* set master volume and direct control */
744 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
745 /* setup audio connections */
746 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
747 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
748 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
749 /* setup adcs to point to mixer */
750 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
751 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
752 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
753 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
754 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
755 /* setup import muxs */
756 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
757 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
758 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
759 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
763 static struct hda_verb dell_eq_core_init[] = {
764 /* set master volume to max value without distortion
765 * and direct control */
766 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
767 /* setup audio connections */
768 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
769 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
770 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
771 /* setup adcs to point to mixer */
772 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
773 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
774 /* setup import muxs */
775 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
776 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
777 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
778 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
782 static struct hda_verb dell_m6_core_init[] = {
783 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
784 /* setup audio connections */
785 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
786 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
787 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
788 /* setup adcs to point to mixer */
789 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
790 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
791 /* setup import muxs */
792 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
793 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
794 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
795 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
799 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
800 /* set master volume and direct control */
801 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
802 /* setup audio connections */
803 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
804 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
805 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
806 /* connect hp ports to dac3 */
807 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
808 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
809 /* setup adcs to point to mixer */
810 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
811 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
812 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
813 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
814 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
815 /* setup import muxs */
816 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
817 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
818 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
819 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
823 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
824 /* set master volume and direct control */
825 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
826 /* setup audio connections */
827 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
828 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
829 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
830 /* dac3 is connected to import3 mux */
831 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
832 /* connect hp ports to dac4 */
833 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
834 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
835 /* setup adcs to point to mixer */
836 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
837 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
838 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
839 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
840 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
841 /* setup import muxs */
842 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
843 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
844 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
845 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
849 static struct hda_verb stac92hd83xxx_core_init[] = {
850 /* start of config #1 */
851 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
853 /* start of config #2 */
854 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
855 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
856 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
858 /* power state controls amps */
859 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
862 static struct hda_verb stac92hd71bxx_core_init[] = {
863 /* set master volume and direct control */
864 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
865 /* connect headphone jack to dac1 */
866 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
867 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
868 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
869 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
870 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
873 #define HD_DISABLE_PORTF 2
874 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
875 /* start of config #1 */
877 /* connect port 0f to audio mixer */
878 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
879 /* unmute right and left channels for node 0x0f */
880 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
881 /* start of config #2 */
883 /* set master volume and direct control */
884 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
885 /* connect headphone jack to dac1 */
886 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
887 /* unmute right and left channels for nodes 0x0a, 0xd */
888 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
889 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
893 static struct hda_verb stac925x_core_init[] = {
894 /* set dac0mux for dac converter */
895 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
899 static struct hda_verb stac922x_core_init[] = {
900 /* set master volume and direct control */
901 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
905 static struct hda_verb d965_core_init[] = {
906 /* set master volume and direct control */
907 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
908 /* unmute node 0x1b */
909 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
910 /* select node 0x03 as DAC */
911 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
915 static struct hda_verb stac927x_core_init[] = {
916 /* set master volume and direct control */
917 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
918 /* enable analog pc beep path */
919 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
923 static struct hda_verb stac9205_core_init[] = {
924 /* set master volume and direct control */
925 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
926 /* enable analog pc beep path */
927 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
931 #define STAC_MONO_MUX \
933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
934 .name = "Mono Mux", \
936 .info = stac92xx_mono_mux_enum_info, \
937 .get = stac92xx_mono_mux_enum_get, \
938 .put = stac92xx_mono_mux_enum_put, \
941 #define STAC_AMP_MUX \
943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
944 .name = "Amp Selector Capture Switch", \
946 .info = stac92xx_amp_mux_enum_info, \
947 .get = stac92xx_amp_mux_enum_get, \
948 .put = stac92xx_amp_mux_enum_put, \
951 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
953 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
956 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
957 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
958 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
959 .info = stac92xx_amp_volume_info, \
960 .get = stac92xx_amp_volume_get, \
961 .put = stac92xx_amp_volume_put, \
962 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
963 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
966 #define STAC_INPUT_SOURCE(cnt) \
968 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
969 .name = "Input Source", \
971 .info = stac92xx_mux_enum_info, \
972 .get = stac92xx_mux_enum_get, \
973 .put = stac92xx_mux_enum_put, \
976 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
978 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
979 .name = "Analog Loopback", \
981 .info = stac92xx_aloopback_info, \
982 .get = stac92xx_aloopback_get, \
983 .put = stac92xx_aloopback_put, \
984 .private_value = verb_read | (verb_write << 16), \
987 static struct snd_kcontrol_new stac9200_mixer[] = {
988 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
989 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
990 STAC_INPUT_SOURCE(1),
991 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
992 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
996 #define DELL_M6_MIXER 6
997 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
998 /* start of config #1 */
999 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1000 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1002 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1003 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1005 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1006 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1008 /* start of config #2 */
1009 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1010 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1012 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1013 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1015 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1017 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1018 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1020 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1021 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1026 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1027 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1029 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1030 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1032 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1033 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1035 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1036 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1038 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1039 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1041 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1042 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1044 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1045 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1047 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1048 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1052 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1053 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1055 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1056 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1058 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1059 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1061 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1062 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1064 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1065 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1067 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1068 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1070 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1071 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1073 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1074 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1079 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1080 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1081 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1083 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1084 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1086 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1087 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1089 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1090 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1092 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1093 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1095 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1096 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1099 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1100 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1105 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1106 STAC_INPUT_SOURCE(2),
1107 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1109 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1110 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1112 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1113 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1114 /* analog pc-beep replaced with digital beep support */
1116 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1117 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1120 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1121 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1123 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1124 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1126 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1127 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1129 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1130 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1134 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1135 STAC_INPUT_SOURCE(2),
1136 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1138 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1139 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1141 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1142 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1146 static struct snd_kcontrol_new stac925x_mixer[] = {
1147 STAC_INPUT_SOURCE(1),
1148 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1149 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1153 static struct snd_kcontrol_new stac9205_mixer[] = {
1154 STAC_INPUT_SOURCE(2),
1155 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1157 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1158 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1160 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1161 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1165 /* This needs to be generated dynamically based on sequence */
1166 static struct snd_kcontrol_new stac922x_mixer[] = {
1167 STAC_INPUT_SOURCE(2),
1168 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1169 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1171 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1172 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1177 static struct snd_kcontrol_new stac927x_mixer[] = {
1178 STAC_INPUT_SOURCE(3),
1179 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1181 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1182 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1184 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1185 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1187 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1188 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1192 static struct snd_kcontrol_new stac_dmux_mixer = {
1193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1194 .name = "Digital Input Source",
1195 /* count set later */
1196 .info = stac92xx_dmux_enum_info,
1197 .get = stac92xx_dmux_enum_get,
1198 .put = stac92xx_dmux_enum_put,
1201 static struct snd_kcontrol_new stac_smux_mixer = {
1202 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1203 .name = "IEC958 Playback Source",
1204 /* count set later */
1205 .info = stac92xx_smux_enum_info,
1206 .get = stac92xx_smux_enum_get,
1207 .put = stac92xx_smux_enum_put,
1210 static const char *slave_vols[] = {
1211 "Front Playback Volume",
1212 "Surround Playback Volume",
1213 "Center Playback Volume",
1214 "LFE Playback Volume",
1215 "Side Playback Volume",
1216 "Headphone Playback Volume",
1217 "Headphone Playback Volume",
1218 "Speaker Playback Volume",
1219 "External Speaker Playback Volume",
1220 "Speaker2 Playback Volume",
1224 static const char *slave_sws[] = {
1225 "Front Playback Switch",
1226 "Surround Playback Switch",
1227 "Center Playback Switch",
1228 "LFE Playback Switch",
1229 "Side Playback Switch",
1230 "Headphone Playback Switch",
1231 "Headphone Playback Switch",
1232 "Speaker Playback Switch",
1233 "External Speaker Playback Switch",
1234 "Speaker2 Playback Switch",
1235 "IEC958 Playback Switch",
1239 static int stac92xx_build_controls(struct hda_codec *codec)
1241 struct sigmatel_spec *spec = codec->spec;
1245 err = snd_hda_add_new_ctls(codec, spec->mixer);
1249 for (i = 0; i < spec->num_mixers; i++) {
1250 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1254 if (spec->num_dmuxes > 0) {
1255 stac_dmux_mixer.count = spec->num_dmuxes;
1256 err = snd_ctl_add(codec->bus->card,
1257 snd_ctl_new1(&stac_dmux_mixer, codec));
1261 if (spec->num_smuxes > 0) {
1262 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1263 struct hda_input_mux *smux = &spec->private_smux;
1264 /* check for mute support on SPDIF out */
1265 if (wcaps & AC_WCAP_OUT_AMP) {
1266 smux->items[smux->num_items].label = "Off";
1267 smux->items[smux->num_items].index = 0;
1269 spec->spdif_mute = 1;
1271 stac_smux_mixer.count = spec->num_smuxes;
1272 err = snd_ctl_add(codec->bus->card,
1273 snd_ctl_new1(&stac_smux_mixer, codec));
1278 if (spec->multiout.dig_out_nid) {
1279 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1282 err = snd_hda_create_spdif_share_sw(codec,
1286 spec->multiout.share_spdif = 1;
1288 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1289 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1294 /* if we have no master control, let's create it */
1295 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1296 unsigned int vmaster_tlv[4];
1297 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1298 HDA_OUTPUT, vmaster_tlv);
1299 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1300 vmaster_tlv, slave_vols);
1304 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1305 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1314 static unsigned int ref9200_pin_configs[8] = {
1315 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1316 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1320 STAC 9200 pin configs for
1325 static unsigned int dell9200_d21_pin_configs[8] = {
1326 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1327 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1331 STAC 9200 pin configs for
1335 static unsigned int dell9200_d22_pin_configs[8] = {
1336 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1337 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1341 STAC 9200 pin configs for
1342 102801C4 (Dell Dimension E310)
1349 static unsigned int dell9200_d23_pin_configs[8] = {
1350 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1351 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1356 STAC 9200-32 pin configs for
1357 102801B5 (Dell Inspiron 630m)
1358 102801D8 (Dell Inspiron 640m)
1360 static unsigned int dell9200_m21_pin_configs[8] = {
1361 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1362 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1366 STAC 9200-32 pin configs for
1367 102801C2 (Dell Latitude D620)
1369 102801CC (Dell Latitude D820)
1373 static unsigned int dell9200_m22_pin_configs[8] = {
1374 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1375 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1379 STAC 9200-32 pin configs for
1380 102801CE (Dell XPS M1710)
1381 102801CF (Dell Precision M90)
1383 static unsigned int dell9200_m23_pin_configs[8] = {
1384 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1385 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1389 STAC 9200-32 pin configs for
1392 102801CB (Dell Latitude 120L)
1395 static unsigned int dell9200_m24_pin_configs[8] = {
1396 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1397 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1401 STAC 9200-32 pin configs for
1402 102801BD (Dell Inspiron E1505n)
1406 static unsigned int dell9200_m25_pin_configs[8] = {
1407 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1408 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1412 STAC 9200-32 pin configs for
1413 102801F5 (Dell Inspiron 1501)
1416 static unsigned int dell9200_m26_pin_configs[8] = {
1417 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1418 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1423 102801CD (Dell Inspiron E1705/9400)
1425 static unsigned int dell9200_m27_pin_configs[8] = {
1426 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1427 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1430 static unsigned int oqo9200_pin_configs[8] = {
1431 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1432 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1436 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1437 [STAC_REF] = ref9200_pin_configs,
1438 [STAC_9200_OQO] = oqo9200_pin_configs,
1439 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1440 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1441 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1442 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1443 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1444 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1445 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1446 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1447 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1448 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1449 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1452 static const char *stac9200_models[STAC_9200_MODELS] = {
1454 [STAC_9200_OQO] = "oqo",
1455 [STAC_9200_DELL_D21] = "dell-d21",
1456 [STAC_9200_DELL_D22] = "dell-d22",
1457 [STAC_9200_DELL_D23] = "dell-d23",
1458 [STAC_9200_DELL_M21] = "dell-m21",
1459 [STAC_9200_DELL_M22] = "dell-m22",
1460 [STAC_9200_DELL_M23] = "dell-m23",
1461 [STAC_9200_DELL_M24] = "dell-m24",
1462 [STAC_9200_DELL_M25] = "dell-m25",
1463 [STAC_9200_DELL_M26] = "dell-m26",
1464 [STAC_9200_DELL_M27] = "dell-m27",
1465 [STAC_9200_GATEWAY] = "gateway",
1466 [STAC_9200_PANASONIC] = "panasonic",
1469 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1470 /* SigmaTel reference board */
1471 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1472 "DFI LanParty", STAC_REF),
1473 /* Dell laptops have BIOS problem */
1474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1475 "unknown Dell", STAC_9200_DELL_D21),
1476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1477 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1479 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1481 "unknown Dell", STAC_9200_DELL_D22),
1482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1483 "unknown Dell", STAC_9200_DELL_D22),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1485 "Dell Latitude D620", STAC_9200_DELL_M22),
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1487 "unknown Dell", STAC_9200_DELL_D23),
1488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1489 "unknown Dell", STAC_9200_DELL_D23),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1491 "unknown Dell", STAC_9200_DELL_M22),
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1493 "unknown Dell", STAC_9200_DELL_M24),
1494 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1495 "unknown Dell", STAC_9200_DELL_M24),
1496 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1497 "Dell Latitude 120L", STAC_9200_DELL_M24),
1498 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1499 "Dell Latitude D820", STAC_9200_DELL_M22),
1500 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1501 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1502 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1503 "Dell XPS M1710", STAC_9200_DELL_M23),
1504 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1505 "Dell Precision M90", STAC_9200_DELL_M23),
1506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1507 "unknown Dell", STAC_9200_DELL_M22),
1508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1509 "unknown Dell", STAC_9200_DELL_M22),
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1511 "unknown Dell", STAC_9200_DELL_M22),
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1513 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1515 "unknown Dell", STAC_9200_DELL_D23),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1517 "unknown Dell", STAC_9200_DELL_D23),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1519 "unknown Dell", STAC_9200_DELL_D21),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1521 "unknown Dell", STAC_9200_DELL_D23),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1523 "unknown Dell", STAC_9200_DELL_D21),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1525 "unknown Dell", STAC_9200_DELL_M25),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1527 "unknown Dell", STAC_9200_DELL_M25),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1529 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1531 "unknown Dell", STAC_9200_DELL_M26),
1533 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1534 /* Gateway machines needs EAPD to be set on resume */
1535 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1536 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1538 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1541 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1545 static unsigned int ref925x_pin_configs[8] = {
1546 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1547 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1550 static unsigned int stac925x_MA6_pin_configs[8] = {
1551 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1552 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1555 static unsigned int stac925x_PA6_pin_configs[8] = {
1556 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1557 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1560 static unsigned int stac925xM2_2_pin_configs[8] = {
1561 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1562 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1565 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1566 [STAC_REF] = ref925x_pin_configs,
1567 [STAC_M2_2] = stac925xM2_2_pin_configs,
1568 [STAC_MA6] = stac925x_MA6_pin_configs,
1569 [STAC_PA6] = stac925x_PA6_pin_configs,
1572 static const char *stac925x_models[STAC_925x_MODELS] = {
1574 [STAC_M2_2] = "m2-2",
1579 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1580 /* SigmaTel reference board */
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1582 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1583 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1584 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1585 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1586 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1587 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1591 static unsigned int ref92hd73xx_pin_configs[13] = {
1592 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1593 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1594 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1598 static unsigned int dell_m6_pin_configs[13] = {
1599 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1600 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1601 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1605 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1606 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1607 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1608 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1609 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1610 [STAC_DELL_EQ] = dell_m6_pin_configs,
1613 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1614 [STAC_92HD73XX_REF] = "ref",
1615 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1616 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1617 [STAC_DELL_M6_BOTH] = "dell-m6",
1618 [STAC_DELL_EQ] = "dell-eq",
1621 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1622 /* SigmaTel reference board */
1623 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1624 "DFI LanParty", STAC_92HD73XX_REF),
1625 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1626 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1627 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1628 "unknown Dell", STAC_DELL_M6_DMIC),
1629 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1630 "unknown Dell", STAC_DELL_M6_BOTH),
1631 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1632 "unknown Dell", STAC_DELL_M6_BOTH),
1633 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1634 "unknown Dell", STAC_DELL_M6_AMIC),
1635 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1636 "unknown Dell", STAC_DELL_M6_AMIC),
1637 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1638 "unknown Dell", STAC_DELL_M6_DMIC),
1639 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1640 "unknown Dell", STAC_DELL_M6_DMIC),
1641 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1642 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1646 static unsigned int ref92hd83xxx_pin_configs[14] = {
1647 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1648 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1649 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1650 0x01451160, 0x98560170,
1653 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1654 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1657 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1658 [STAC_92HD83XXX_REF] = "ref",
1661 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1662 /* SigmaTel reference board */
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1664 "DFI LanParty", STAC_92HD71BXX_REF),
1667 static unsigned int ref92hd71bxx_pin_configs[11] = {
1668 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1669 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1670 0x90a000f0, 0x01452050, 0x01452050,
1673 static unsigned int dell_m4_1_pin_configs[11] = {
1674 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1675 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1676 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
1679 static unsigned int dell_m4_2_pin_configs[11] = {
1680 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1681 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1682 0x40f000f0, 0x044413b0, 0x044413b0,
1685 static unsigned int dell_m4_3_pin_configs[11] = {
1686 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1687 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1688 0x40f000f0, 0x044413b0, 0x044413b0,
1691 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1692 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1693 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1694 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1695 [STAC_DELL_M4_3] = dell_m4_3_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_DELL_M4_3] = "dell-m4-3",
1704 [STAC_HP_M4] = "hp-m4",
1707 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1708 /* SigmaTel reference board */
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1710 "DFI LanParty", STAC_92HD71BXX_REF),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
1712 "HP dv5", STAC_HP_M4),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
1714 "HP dv7", STAC_HP_M4),
1715 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1716 "unknown HP", STAC_HP_M4),
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1718 "unknown Dell", STAC_DELL_M4_1),
1719 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1720 "unknown Dell", STAC_DELL_M4_1),
1721 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1722 "unknown Dell", STAC_DELL_M4_1),
1723 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1724 "unknown Dell", STAC_DELL_M4_1),
1725 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1726 "unknown Dell", STAC_DELL_M4_1),
1727 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1728 "unknown Dell", STAC_DELL_M4_1),
1729 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1730 "unknown Dell", STAC_DELL_M4_1),
1731 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1732 "unknown Dell", STAC_DELL_M4_2),
1733 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1734 "unknown Dell", STAC_DELL_M4_2),
1735 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1736 "unknown Dell", STAC_DELL_M4_2),
1737 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1738 "unknown Dell", STAC_DELL_M4_2),
1739 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1740 "unknown Dell", STAC_DELL_M4_3),
1744 static unsigned int ref922x_pin_configs[10] = {
1745 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1746 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1747 0x40000100, 0x40000100,
1751 STAC 922X pin configs for
1758 static unsigned int dell_922x_d81_pin_configs[10] = {
1759 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1760 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1761 0x01813122, 0x400001f2,
1765 STAC 922X pin configs for
1769 static unsigned int dell_922x_d82_pin_configs[10] = {
1770 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1771 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1772 0x01813122, 0x400001f1,
1776 STAC 922X pin configs for
1779 static unsigned int dell_922x_m81_pin_configs[10] = {
1780 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1781 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1782 0x40C003f1, 0x405003f0,
1786 STAC 9221 A1 pin configs for
1787 102801D7 (Dell XPS M1210)
1789 static unsigned int dell_922x_m82_pin_configs[10] = {
1790 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1791 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1792 0x508003f3, 0x405003f4,
1795 static unsigned int d945gtp3_pin_configs[10] = {
1796 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1797 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1798 0x02a19120, 0x40000100,
1801 static unsigned int d945gtp5_pin_configs[10] = {
1802 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1803 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1804 0x02a19320, 0x40000100,
1807 static unsigned int intel_mac_v1_pin_configs[10] = {
1808 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1809 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1810 0x400000fc, 0x400000fb,
1813 static unsigned int intel_mac_v2_pin_configs[10] = {
1814 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1815 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1816 0x400000fc, 0x400000fb,
1819 static unsigned int intel_mac_v3_pin_configs[10] = {
1820 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1821 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1822 0x400000fc, 0x400000fb,
1825 static unsigned int intel_mac_v4_pin_configs[10] = {
1826 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1827 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1828 0x400000fc, 0x400000fb,
1831 static unsigned int intel_mac_v5_pin_configs[10] = {
1832 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1833 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1834 0x400000fc, 0x400000fb,
1837 static unsigned int ecs202_pin_configs[10] = {
1838 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1839 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1840 0x9037012e, 0x40e000f2,
1843 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1844 [STAC_D945_REF] = ref922x_pin_configs,
1845 [STAC_D945GTP3] = d945gtp3_pin_configs,
1846 [STAC_D945GTP5] = d945gtp5_pin_configs,
1847 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1848 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1849 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1850 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1851 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1852 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1853 /* for backward compatibility */
1854 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1855 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1856 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1857 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1858 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1859 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1860 [STAC_ECS_202] = ecs202_pin_configs,
1861 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1862 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1863 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1864 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1867 static const char *stac922x_models[STAC_922X_MODELS] = {
1868 [STAC_D945_REF] = "ref",
1869 [STAC_D945GTP5] = "5stack",
1870 [STAC_D945GTP3] = "3stack",
1871 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1872 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1873 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1874 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1875 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1876 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1877 /* for backward compatibility */
1878 [STAC_MACMINI] = "macmini",
1879 [STAC_MACBOOK] = "macbook",
1880 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1881 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1882 [STAC_IMAC_INTEL] = "imac-intel",
1883 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1884 [STAC_ECS_202] = "ecs202",
1885 [STAC_922X_DELL_D81] = "dell-d81",
1886 [STAC_922X_DELL_D82] = "dell-d82",
1887 [STAC_922X_DELL_M81] = "dell-m81",
1888 [STAC_922X_DELL_M82] = "dell-m82",
1891 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1892 /* SigmaTel reference board */
1893 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1894 "DFI LanParty", STAC_D945_REF),
1895 /* Intel 945G based systems */
1896 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1897 "Intel D945G", STAC_D945GTP3),
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1899 "Intel D945G", STAC_D945GTP3),
1900 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1901 "Intel D945G", STAC_D945GTP3),
1902 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1903 "Intel D945G", STAC_D945GTP3),
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1905 "Intel D945G", STAC_D945GTP3),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1907 "Intel D945G", STAC_D945GTP3),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1909 "Intel D945G", STAC_D945GTP3),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1911 "Intel D945G", STAC_D945GTP3),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1913 "Intel D945G", STAC_D945GTP3),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1915 "Intel D945G", STAC_D945GTP3),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1917 "Intel D945G", STAC_D945GTP3),
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1919 "Intel D945G", STAC_D945GTP3),
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1921 "Intel D945G", STAC_D945GTP3),
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1923 "Intel D945G", STAC_D945GTP3),
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1925 "Intel D945G", STAC_D945GTP3),
1926 /* Intel D945G 5-stack systems */
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1928 "Intel D945G", STAC_D945GTP5),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1930 "Intel D945G", STAC_D945GTP5),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1932 "Intel D945G", STAC_D945GTP5),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1934 "Intel D945G", STAC_D945GTP5),
1935 /* Intel 945P based systems */
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1937 "Intel D945P", STAC_D945GTP3),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1939 "Intel D945P", STAC_D945GTP3),
1940 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1941 "Intel D945P", STAC_D945GTP3),
1942 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1943 "Intel D945P", STAC_D945GTP3),
1944 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1945 "Intel D945P", STAC_D945GTP3),
1946 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1947 "Intel D945P", STAC_D945GTP5),
1949 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1950 SND_PCI_QUIRK(0x8384, 0x7680,
1951 "Mac", STAC_INTEL_MAC_AUTO),
1953 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1954 "unknown Dell", STAC_922X_DELL_D81),
1955 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1956 "unknown Dell", STAC_922X_DELL_D81),
1957 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1958 "unknown Dell", STAC_922X_DELL_D81),
1959 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1960 "unknown Dell", STAC_922X_DELL_D82),
1961 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1962 "unknown Dell", STAC_922X_DELL_M81),
1963 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1964 "unknown Dell", STAC_922X_DELL_D82),
1965 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1966 "unknown Dell", STAC_922X_DELL_D81),
1967 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1968 "unknown Dell", STAC_922X_DELL_D81),
1969 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1970 "Dell XPS M1210", STAC_922X_DELL_M82),
1971 /* ECS/PC Chips boards */
1972 SND_PCI_QUIRK(0x1019, 0x2144,
1973 "ECS/PC chips", STAC_ECS_202),
1974 SND_PCI_QUIRK(0x1019, 0x2608,
1975 "ECS/PC chips", STAC_ECS_202),
1976 SND_PCI_QUIRK(0x1019, 0x2633,
1977 "ECS/PC chips P17G/1333", STAC_ECS_202),
1978 SND_PCI_QUIRK(0x1019, 0x2811,
1979 "ECS/PC chips", STAC_ECS_202),
1980 SND_PCI_QUIRK(0x1019, 0x2812,
1981 "ECS/PC chips", STAC_ECS_202),
1982 SND_PCI_QUIRK(0x1019, 0x2813,
1983 "ECS/PC chips", STAC_ECS_202),
1984 SND_PCI_QUIRK(0x1019, 0x2814,
1985 "ECS/PC chips", STAC_ECS_202),
1986 SND_PCI_QUIRK(0x1019, 0x2815,
1987 "ECS/PC chips", STAC_ECS_202),
1988 SND_PCI_QUIRK(0x1019, 0x2816,
1989 "ECS/PC chips", STAC_ECS_202),
1990 SND_PCI_QUIRK(0x1019, 0x2817,
1991 "ECS/PC chips", STAC_ECS_202),
1992 SND_PCI_QUIRK(0x1019, 0x2818,
1993 "ECS/PC chips", STAC_ECS_202),
1994 SND_PCI_QUIRK(0x1019, 0x2819,
1995 "ECS/PC chips", STAC_ECS_202),
1996 SND_PCI_QUIRK(0x1019, 0x2820,
1997 "ECS/PC chips", STAC_ECS_202),
2001 static unsigned int ref927x_pin_configs[14] = {
2002 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2003 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2004 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2005 0x01c42190, 0x40000100,
2008 static unsigned int d965_3st_pin_configs[14] = {
2009 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2010 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2011 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2012 0x40000100, 0x40000100
2015 static unsigned int d965_5st_pin_configs[14] = {
2016 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2017 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2018 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2019 0x40000100, 0x40000100
2022 static unsigned int dell_3st_pin_configs[14] = {
2023 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2024 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2025 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2026 0x40c003fc, 0x40000100
2029 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2030 [STAC_D965_REF] = ref927x_pin_configs,
2031 [STAC_D965_3ST] = d965_3st_pin_configs,
2032 [STAC_D965_5ST] = d965_5st_pin_configs,
2033 [STAC_DELL_3ST] = dell_3st_pin_configs,
2034 [STAC_DELL_BIOS] = NULL,
2037 static const char *stac927x_models[STAC_927X_MODELS] = {
2038 [STAC_D965_REF] = "ref",
2039 [STAC_D965_3ST] = "3stack",
2040 [STAC_D965_5ST] = "5stack",
2041 [STAC_DELL_3ST] = "dell-3stack",
2042 [STAC_DELL_BIOS] = "dell-bios",
2045 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2046 /* SigmaTel reference board */
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2048 "DFI LanParty", STAC_D965_REF),
2049 /* Intel 946 based systems */
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2052 /* 965 based 3 stack systems */
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
2069 /* Dell 3 stack systems */
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2074 /* Dell 3 stack systems with verb table in BIOS */
2075 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2081 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2083 /* 965 based 5 stack systems */
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2087 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2089 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2091 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
2096 static unsigned int ref9205_pin_configs[12] = {
2097 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2098 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2099 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2103 STAC 9205 pin configs for
2110 10280228 (Dell Vostro 1500)
2112 static unsigned int dell_9205_m42_pin_configs[12] = {
2113 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2114 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2115 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2119 STAC 9205 pin configs for
2123 102801FF (Dell Precision M4300)
2128 static unsigned int dell_9205_m43_pin_configs[12] = {
2129 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2130 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2131 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2134 static unsigned int dell_9205_m44_pin_configs[12] = {
2135 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2136 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2137 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2140 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2141 [STAC_9205_REF] = ref9205_pin_configs,
2142 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2143 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2144 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2147 static const char *stac9205_models[STAC_9205_MODELS] = {
2148 [STAC_9205_REF] = "ref",
2149 [STAC_9205_DELL_M42] = "dell-m42",
2150 [STAC_9205_DELL_M43] = "dell-m43",
2151 [STAC_9205_DELL_M44] = "dell-m44",
2154 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2155 /* SigmaTel reference board */
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2157 "DFI LanParty", STAC_9205_REF),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2159 "unknown Dell", STAC_9205_DELL_M42),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2161 "unknown Dell", STAC_9205_DELL_M42),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2163 "Dell Precision", STAC_9205_DELL_M43),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2165 "Dell Precision", STAC_9205_DELL_M43),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2167 "Dell Precision", STAC_9205_DELL_M43),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2169 "unknown Dell", STAC_9205_DELL_M42),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2171 "unknown Dell", STAC_9205_DELL_M42),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2173 "Dell Precision", STAC_9205_DELL_M43),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2175 "Dell Precision M4300", STAC_9205_DELL_M43),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2177 "unknown Dell", STAC_9205_DELL_M42),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2179 "Dell Precision", STAC_9205_DELL_M43),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2181 "Dell Precision", STAC_9205_DELL_M43),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2183 "Dell Precision", STAC_9205_DELL_M43),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2185 "Dell Inspiron", STAC_9205_DELL_M44),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2187 "Dell Vostro 1500", STAC_9205_DELL_M42),
2191 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2194 struct sigmatel_spec *spec = codec->spec;
2196 if (! spec->bios_pin_configs) {
2197 spec->bios_pin_configs = kcalloc(spec->num_pins,
2198 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2199 if (! spec->bios_pin_configs)
2203 for (i = 0; i < spec->num_pins; i++) {
2204 hda_nid_t nid = spec->pin_nids[i];
2205 unsigned int pin_cfg;
2207 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2208 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2209 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2211 spec->bios_pin_configs[i] = pin_cfg;
2217 static void stac92xx_set_config_reg(struct hda_codec *codec,
2218 hda_nid_t pin_nid, unsigned int pin_config)
2221 snd_hda_codec_write(codec, pin_nid, 0,
2222 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2223 pin_config & 0x000000ff);
2224 snd_hda_codec_write(codec, pin_nid, 0,
2225 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2226 (pin_config & 0x0000ff00) >> 8);
2227 snd_hda_codec_write(codec, pin_nid, 0,
2228 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2229 (pin_config & 0x00ff0000) >> 16);
2230 snd_hda_codec_write(codec, pin_nid, 0,
2231 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2233 i = snd_hda_codec_read(codec, pin_nid, 0,
2234 AC_VERB_GET_CONFIG_DEFAULT,
2236 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2240 static void stac92xx_set_config_regs(struct hda_codec *codec)
2243 struct sigmatel_spec *spec = codec->spec;
2245 if (!spec->pin_configs)
2248 for (i = 0; i < spec->num_pins; i++)
2249 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2250 spec->pin_configs[i]);
2254 * Analog playback callbacks
2256 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2257 struct hda_codec *codec,
2258 struct snd_pcm_substream *substream)
2260 struct sigmatel_spec *spec = codec->spec;
2261 if (spec->stream_delay)
2262 msleep(spec->stream_delay);
2263 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2267 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2268 struct hda_codec *codec,
2269 unsigned int stream_tag,
2270 unsigned int format,
2271 struct snd_pcm_substream *substream)
2273 struct sigmatel_spec *spec = codec->spec;
2274 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2277 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2278 struct hda_codec *codec,
2279 struct snd_pcm_substream *substream)
2281 struct sigmatel_spec *spec = codec->spec;
2282 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2286 * Digital playback callbacks
2288 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2289 struct hda_codec *codec,
2290 struct snd_pcm_substream *substream)
2292 struct sigmatel_spec *spec = codec->spec;
2293 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2296 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2297 struct hda_codec *codec,
2298 struct snd_pcm_substream *substream)
2300 struct sigmatel_spec *spec = codec->spec;
2301 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2304 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2305 struct hda_codec *codec,
2306 unsigned int stream_tag,
2307 unsigned int format,
2308 struct snd_pcm_substream *substream)
2310 struct sigmatel_spec *spec = codec->spec;
2311 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2312 stream_tag, format, substream);
2317 * Analog capture callbacks
2319 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2320 struct hda_codec *codec,
2321 unsigned int stream_tag,
2322 unsigned int format,
2323 struct snd_pcm_substream *substream)
2325 struct sigmatel_spec *spec = codec->spec;
2326 hda_nid_t nid = spec->adc_nids[substream->number];
2328 if (spec->powerdown_adcs) {
2330 snd_hda_codec_write_cache(codec, nid, 0,
2331 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2333 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2337 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2338 struct hda_codec *codec,
2339 struct snd_pcm_substream *substream)
2341 struct sigmatel_spec *spec = codec->spec;
2342 hda_nid_t nid = spec->adc_nids[substream->number];
2344 snd_hda_codec_cleanup_stream(codec, nid);
2345 if (spec->powerdown_adcs)
2346 snd_hda_codec_write_cache(codec, nid, 0,
2347 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2351 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2355 /* NID is set in stac92xx_build_pcms */
2357 .open = stac92xx_dig_playback_pcm_open,
2358 .close = stac92xx_dig_playback_pcm_close,
2359 .prepare = stac92xx_dig_playback_pcm_prepare
2363 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2367 /* NID is set in stac92xx_build_pcms */
2370 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2374 .nid = 0x02, /* NID to query formats and rates */
2376 .open = stac92xx_playback_pcm_open,
2377 .prepare = stac92xx_playback_pcm_prepare,
2378 .cleanup = stac92xx_playback_pcm_cleanup
2382 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2386 .nid = 0x06, /* NID to query formats and rates */
2388 .open = stac92xx_playback_pcm_open,
2389 .prepare = stac92xx_playback_pcm_prepare,
2390 .cleanup = stac92xx_playback_pcm_cleanup
2394 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2397 /* NID + .substreams is set in stac92xx_build_pcms */
2399 .prepare = stac92xx_capture_pcm_prepare,
2400 .cleanup = stac92xx_capture_pcm_cleanup
2404 static int stac92xx_build_pcms(struct hda_codec *codec)
2406 struct sigmatel_spec *spec = codec->spec;
2407 struct hda_pcm *info = spec->pcm_rec;
2409 codec->num_pcms = 1;
2410 codec->pcm_info = info;
2412 info->name = "STAC92xx Analog";
2413 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2414 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2415 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2416 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2418 if (spec->alt_switch) {
2421 info->name = "STAC92xx Analog Alt";
2422 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2425 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2428 info->name = "STAC92xx Digital";
2429 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2430 if (spec->multiout.dig_out_nid) {
2431 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2432 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2434 if (spec->dig_in_nid) {
2435 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2436 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2443 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2445 unsigned int pincap = snd_hda_param_read(codec, nid,
2447 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2448 if (pincap & AC_PINCAP_VREF_100)
2449 return AC_PINCTL_VREF_100;
2450 if (pincap & AC_PINCAP_VREF_80)
2451 return AC_PINCTL_VREF_80;
2452 if (pincap & AC_PINCAP_VREF_50)
2453 return AC_PINCTL_VREF_50;
2454 if (pincap & AC_PINCAP_VREF_GRD)
2455 return AC_PINCTL_VREF_GRD;
2459 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2462 snd_hda_codec_write_cache(codec, nid, 0,
2463 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2466 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2468 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2469 struct snd_ctl_elem_value *ucontrol)
2471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2472 struct sigmatel_spec *spec = codec->spec;
2474 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2478 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2479 struct snd_ctl_elem_value *ucontrol)
2481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2482 struct sigmatel_spec *spec = codec->spec;
2483 int nid = kcontrol->private_value;
2485 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2487 /* check to be sure that the ports are upto date with
2490 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2495 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2497 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2499 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2500 struct sigmatel_spec *spec = codec->spec;
2501 int io_idx = kcontrol-> private_value & 0xff;
2503 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2507 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2509 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2510 struct sigmatel_spec *spec = codec->spec;
2511 hda_nid_t nid = kcontrol->private_value >> 8;
2512 int io_idx = kcontrol-> private_value & 0xff;
2513 unsigned short val = !!ucontrol->value.integer.value[0];
2515 spec->io_switch[io_idx] = val;
2518 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2520 unsigned int pinctl = AC_PINCTL_IN_EN;
2521 if (io_idx) /* set VREF for mic */
2522 pinctl |= stac92xx_get_vref(codec, nid);
2523 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2526 /* check the auto-mute again: we need to mute/unmute the speaker
2527 * appropriately according to the pin direction
2529 if (spec->hp_detect)
2530 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2535 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2537 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2538 struct snd_ctl_elem_value *ucontrol)
2540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2541 struct sigmatel_spec *spec = codec->spec;
2543 ucontrol->value.integer.value[0] = spec->clfe_swap;
2547 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2548 struct snd_ctl_elem_value *ucontrol)
2550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2551 struct sigmatel_spec *spec = codec->spec;
2552 hda_nid_t nid = kcontrol->private_value & 0xff;
2553 unsigned int val = !!ucontrol->value.integer.value[0];
2555 if (spec->clfe_swap == val)
2558 spec->clfe_swap = val;
2560 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2561 spec->clfe_swap ? 0x4 : 0x0);
2566 #define STAC_CODEC_HP_SWITCH(xname) \
2567 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2570 .info = stac92xx_hp_switch_info, \
2571 .get = stac92xx_hp_switch_get, \
2572 .put = stac92xx_hp_switch_put, \
2575 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2576 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2579 .info = stac92xx_io_switch_info, \
2580 .get = stac92xx_io_switch_get, \
2581 .put = stac92xx_io_switch_put, \
2582 .private_value = xpval, \
2585 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2586 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2589 .info = stac92xx_clfe_switch_info, \
2590 .get = stac92xx_clfe_switch_get, \
2591 .put = stac92xx_clfe_switch_put, \
2592 .private_value = xpval, \
2596 STAC_CTL_WIDGET_VOL,
2597 STAC_CTL_WIDGET_MUTE,
2598 STAC_CTL_WIDGET_MONO_MUX,
2599 STAC_CTL_WIDGET_AMP_MUX,
2600 STAC_CTL_WIDGET_AMP_VOL,
2601 STAC_CTL_WIDGET_HP_SWITCH,
2602 STAC_CTL_WIDGET_IO_SWITCH,
2603 STAC_CTL_WIDGET_CLFE_SWITCH
2606 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2607 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2608 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2611 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2612 STAC_CODEC_HP_SWITCH(NULL),
2613 STAC_CODEC_IO_SWITCH(NULL, 0),
2614 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2617 /* add dynamic controls */
2618 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2619 struct snd_kcontrol_new *ktemp,
2620 int idx, const char *name,
2623 struct snd_kcontrol_new *knew;
2625 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2626 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2628 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2631 if (spec->kctl_alloc) {
2632 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2633 kfree(spec->kctl_alloc);
2635 spec->kctl_alloc = knew;
2636 spec->num_kctl_alloc = num;
2639 knew = &spec->kctl_alloc[spec->num_kctl_used];
2642 knew->name = kstrdup(name, GFP_KERNEL);
2645 knew->private_value = val;
2646 spec->num_kctl_used++;
2650 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2651 int type, int idx, const char *name,
2654 return stac92xx_add_control_temp(spec,
2655 &stac92xx_control_templates[type],
2660 /* add dynamic controls */
2661 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2662 const char *name, unsigned long val)
2664 return stac92xx_add_control_idx(spec, type, 0, name, val);
2667 /* flag inputs as additional dynamic lineouts */
2668 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2670 struct sigmatel_spec *spec = codec->spec;
2671 unsigned int wcaps, wtype;
2672 int i, num_dacs = 0;
2674 /* use the wcaps cache to count all DACs available for line-outs */
2675 for (i = 0; i < codec->num_nodes; i++) {
2676 wcaps = codec->wcaps[i];
2677 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2679 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2683 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2685 switch (cfg->line_outs) {
2687 /* add line-in as side */
2688 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2689 cfg->line_out_pins[cfg->line_outs] =
2690 cfg->input_pins[AUTO_PIN_LINE];
2691 spec->line_switch = 1;
2696 /* add line-in as clfe and mic as side */
2697 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2698 cfg->line_out_pins[cfg->line_outs] =
2699 cfg->input_pins[AUTO_PIN_LINE];
2700 spec->line_switch = 1;
2703 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2704 cfg->line_out_pins[cfg->line_outs] =
2705 cfg->input_pins[AUTO_PIN_MIC];
2706 spec->mic_switch = 1;
2711 /* add line-in as surr and mic as clfe */
2712 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2713 cfg->line_out_pins[cfg->line_outs] =
2714 cfg->input_pins[AUTO_PIN_LINE];
2715 spec->line_switch = 1;
2718 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2719 cfg->line_out_pins[cfg->line_outs] =
2720 cfg->input_pins[AUTO_PIN_MIC];
2721 spec->mic_switch = 1;
2731 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2735 for (i = 0; i < spec->multiout.num_dacs; i++) {
2736 if (spec->multiout.dac_nids[i] == nid)
2744 * Fill in the dac_nids table from the parsed pin configuration
2745 * This function only works when every pin in line_out_pins[]
2746 * contains atleast one DAC in its connection list. Some 92xx
2747 * codecs are not connected directly to a DAC, such as the 9200
2748 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2750 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2751 struct auto_pin_cfg *cfg)
2753 struct sigmatel_spec *spec = codec->spec;
2754 int i, j, conn_len = 0;
2755 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2756 unsigned int wcaps, wtype;
2758 for (i = 0; i < cfg->line_outs; i++) {
2759 nid = cfg->line_out_pins[i];
2760 conn_len = snd_hda_get_connections(codec, nid, conn,
2761 HDA_MAX_CONNECTIONS);
2762 for (j = 0; j < conn_len; j++) {
2763 wcaps = snd_hda_param_read(codec, conn[j],
2764 AC_PAR_AUDIO_WIDGET_CAP);
2765 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2766 if (wtype != AC_WID_AUD_OUT ||
2767 (wcaps & AC_WCAP_DIGITAL))
2769 /* conn[j] is a DAC routed to this line-out */
2770 if (!is_in_dac_nids(spec, conn[j]))
2774 if (j == conn_len) {
2775 if (spec->multiout.num_dacs > 0) {
2776 /* we have already working output pins,
2777 * so let's drop the broken ones again
2779 cfg->line_outs = spec->multiout.num_dacs;
2782 /* error out, no available DAC found */
2784 "%s: No available DAC for pin 0x%x\n",
2789 spec->multiout.dac_nids[i] = conn[j];
2790 spec->multiout.num_dacs++;
2792 /* select this DAC in the pin's input mux */
2793 snd_hda_codec_write_cache(codec, nid, 0,
2794 AC_VERB_SET_CONNECT_SEL, j);
2799 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2800 spec->multiout.num_dacs,
2801 spec->multiout.dac_nids[0],
2802 spec->multiout.dac_nids[1],
2803 spec->multiout.dac_nids[2],
2804 spec->multiout.dac_nids[3],
2805 spec->multiout.dac_nids[4]);
2809 /* create volume control/switch for the given prefx type */
2810 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2815 sprintf(name, "%s Playback Volume", pfx);
2816 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2817 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2820 sprintf(name, "%s Playback Switch", pfx);
2821 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2822 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2828 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2830 if (!spec->multiout.hp_nid)
2831 spec->multiout.hp_nid = nid;
2832 else if (spec->multiout.num_dacs > 4) {
2833 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2836 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2837 spec->multiout.num_dacs++;
2842 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2844 if (is_in_dac_nids(spec, nid))
2846 if (spec->multiout.hp_nid == nid)
2851 /* add playback controls from the parsed DAC table */
2852 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2853 const struct auto_pin_cfg *cfg)
2855 static const char *chname[4] = {
2856 "Front", "Surround", NULL /*CLFE*/, "Side"
2861 struct sigmatel_spec *spec = codec->spec;
2862 unsigned int wid_caps, pincap;
2865 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2866 if (!spec->multiout.dac_nids[i])
2869 nid = spec->multiout.dac_nids[i];
2873 err = create_controls(spec, "Center", nid, 1);
2876 err = create_controls(spec, "LFE", nid, 2);
2880 wid_caps = get_wcaps(codec, nid);
2882 if (wid_caps & AC_WCAP_LR_SWAP) {
2883 err = stac92xx_add_control(spec,
2884 STAC_CTL_WIDGET_CLFE_SWITCH,
2885 "Swap Center/LFE Playback Switch", nid);
2892 err = create_controls(spec, chname[i], nid, 3);
2898 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2899 cfg->hp_outs && !spec->multiout.hp_nid)
2900 spec->multiout.hp_nid = nid;
2902 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
2903 err = stac92xx_add_control(spec,
2904 STAC_CTL_WIDGET_HP_SWITCH,
2905 "Headphone as Line Out Switch",
2906 cfg->hp_pins[cfg->hp_outs - 1]);
2911 if (spec->line_switch) {
2912 nid = cfg->input_pins[AUTO_PIN_LINE];
2913 pincap = snd_hda_param_read(codec, nid,
2915 if (pincap & AC_PINCAP_OUT) {
2916 err = stac92xx_add_control(spec,
2917 STAC_CTL_WIDGET_IO_SWITCH,
2918 "Line In as Output Switch", nid << 8);
2924 if (spec->mic_switch) {
2925 unsigned int def_conf;
2926 unsigned int mic_pin = AUTO_PIN_MIC;
2928 nid = cfg->input_pins[mic_pin];
2929 def_conf = snd_hda_codec_read(codec, nid, 0,
2930 AC_VERB_GET_CONFIG_DEFAULT, 0);
2931 /* some laptops have an internal analog microphone
2932 * which can't be used as a output */
2933 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2934 pincap = snd_hda_param_read(codec, nid,
2936 if (pincap & AC_PINCAP_OUT) {
2937 err = stac92xx_add_control(spec,
2938 STAC_CTL_WIDGET_IO_SWITCH,
2939 "Mic as Output Switch", (nid << 8) | 1);
2940 nid = snd_hda_codec_read(codec, nid, 0,
2941 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2942 if (!check_in_dac_nids(spec, nid))
2943 add_spec_dacs(spec, nid);
2947 } else if (mic_pin == AUTO_PIN_MIC) {
2948 mic_pin = AUTO_PIN_FRONT_MIC;
2956 /* add playback controls for Speaker and HP outputs */
2957 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2958 struct auto_pin_cfg *cfg)
2960 struct sigmatel_spec *spec = codec->spec;
2962 int i, old_num_dacs, err;
2964 old_num_dacs = spec->multiout.num_dacs;
2965 for (i = 0; i < cfg->hp_outs; i++) {
2966 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2967 if (wid_caps & AC_WCAP_UNSOL_CAP)
2968 spec->hp_detect = 1;
2969 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2970 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2971 if (check_in_dac_nids(spec, nid))
2975 add_spec_dacs(spec, nid);
2977 for (i = 0; i < cfg->speaker_outs; i++) {
2978 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2979 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2980 if (check_in_dac_nids(spec, nid))
2984 add_spec_dacs(spec, nid);
2986 for (i = 0; i < cfg->line_outs; i++) {
2987 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2988 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2989 if (check_in_dac_nids(spec, nid))
2993 add_spec_dacs(spec, nid);
2995 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2996 static const char *pfxs[] = {
2997 "Speaker", "External Speaker", "Speaker2",
2999 err = create_controls(spec, pfxs[i - old_num_dacs],
3000 spec->multiout.dac_nids[i], 3);
3004 if (spec->multiout.hp_nid) {
3005 err = create_controls(spec, "Headphone",
3006 spec->multiout.hp_nid, 3);
3014 /* labels for mono mux outputs */
3015 static const char *stac92xx_mono_labels[4] = {
3016 "DAC0", "DAC1", "Mixer", "DAC2"
3019 /* create mono mux for mono out on capable codecs */
3020 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3022 struct sigmatel_spec *spec = codec->spec;
3023 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3025 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3027 num_cons = snd_hda_get_connections(codec,
3030 HDA_MAX_NUM_INPUTS);
3031 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3034 for (i = 0; i < num_cons; i++) {
3035 mono_mux->items[mono_mux->num_items].label =
3036 stac92xx_mono_labels[i];
3037 mono_mux->items[mono_mux->num_items].index = i;
3038 mono_mux->num_items++;
3041 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3042 "Mono Mux", spec->mono_nid);
3045 /* labels for amp mux outputs */
3046 static const char *stac92xx_amp_labels[3] = {
3047 "Front Microphone", "Microphone", "Line In",
3050 /* create amp out controls mux on capable codecs */
3051 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3053 struct sigmatel_spec *spec = codec->spec;
3054 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3057 for (i = 0; i < spec->num_amps; i++) {
3058 amp_mux->items[amp_mux->num_items].label =
3059 stac92xx_amp_labels[i];
3060 amp_mux->items[amp_mux->num_items].index = i;
3061 amp_mux->num_items++;
3064 if (spec->num_amps > 1) {
3065 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3066 "Amp Selector Capture Switch", 0);
3070 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3071 "Amp Capture Volume",
3072 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3076 /* create PC beep volume controls */
3077 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3080 struct sigmatel_spec *spec = codec->spec;
3081 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3084 /* check for mute support for the the amp */
3085 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3086 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3087 "PC Beep Playback Switch",
3088 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3093 /* check to see if there is volume support for the amp */
3094 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3095 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3096 "PC Beep Playback Volume",
3097 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3104 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3105 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3107 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3108 struct snd_ctl_elem_value *ucontrol)
3110 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3111 ucontrol->value.integer.value[0] = codec->beep->enabled;
3115 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3116 struct snd_ctl_elem_value *ucontrol)
3118 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3119 int enabled = !!ucontrol->value.integer.value[0];
3120 if (codec->beep->enabled != enabled) {
3121 codec->beep->enabled = enabled;
3127 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3129 .info = stac92xx_dig_beep_switch_info,
3130 .get = stac92xx_dig_beep_switch_get,
3131 .put = stac92xx_dig_beep_switch_put,
3134 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3136 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3137 0, "PC Beep Playback Switch", 0);
3141 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3143 struct sigmatel_spec *spec = codec->spec;
3144 int wcaps, nid, i, err = 0;
3146 for (i = 0; i < spec->num_muxes; i++) {
3147 nid = spec->mux_nids[i];
3148 wcaps = get_wcaps(codec, nid);
3150 if (wcaps & AC_WCAP_OUT_AMP) {
3151 err = stac92xx_add_control_idx(spec,
3152 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3153 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3161 static const char *stac92xx_spdif_labels[3] = {
3162 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3165 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3167 struct sigmatel_spec *spec = codec->spec;
3168 struct hda_input_mux *spdif_mux = &spec->private_smux;
3169 const char **labels = spec->spdif_labels;
3171 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3173 num_cons = snd_hda_get_connections(codec,
3176 HDA_MAX_NUM_INPUTS);
3181 labels = stac92xx_spdif_labels;
3183 for (i = 0; i < num_cons; i++) {
3184 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3185 spdif_mux->items[spdif_mux->num_items].index = i;
3186 spdif_mux->num_items++;
3192 /* labels for dmic mux inputs */
3193 static const char *stac92xx_dmic_labels[5] = {
3194 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3195 "Digital Mic 3", "Digital Mic 4"
3198 /* create playback/capture controls for input pins on dmic capable codecs */
3199 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3200 const struct auto_pin_cfg *cfg)
3202 struct sigmatel_spec *spec = codec->spec;
3203 struct hda_input_mux *dimux = &spec->private_dimux;
3204 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3208 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3209 dimux->items[dimux->num_items].index = 0;
3212 for (i = 0; i < spec->num_dmics; i++) {
3217 unsigned int def_conf;
3219 def_conf = snd_hda_codec_read(codec,
3222 AC_VERB_GET_CONFIG_DEFAULT,
3224 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3227 nid = spec->dmic_nids[i];
3228 num_cons = snd_hda_get_connections(codec,
3231 HDA_MAX_NUM_INPUTS);
3232 for (j = 0; j < num_cons; j++)
3233 if (con_lst[j] == nid) {
3239 wcaps = get_wcaps(codec, nid) &
3240 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3243 sprintf(name, "%s Capture Volume",
3244 stac92xx_dmic_labels[dimux->num_items]);
3246 err = stac92xx_add_control(spec,
3247 STAC_CTL_WIDGET_VOL,
3249 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3250 (wcaps & AC_WCAP_OUT_AMP) ?
3251 HDA_OUTPUT : HDA_INPUT));
3256 dimux->items[dimux->num_items].label =
3257 stac92xx_dmic_labels[dimux->num_items];
3258 dimux->items[dimux->num_items].index = index;
3265 /* create playback/capture controls for input pins */
3266 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3268 struct sigmatel_spec *spec = codec->spec;
3269 struct hda_input_mux *imux = &spec->private_imux;
3270 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3273 for (i = 0; i < AUTO_PIN_LAST; i++) {
3276 if (!cfg->input_pins[i])
3279 for (j = 0; j < spec->num_muxes; j++) {
3281 num_cons = snd_hda_get_connections(codec,
3284 HDA_MAX_NUM_INPUTS);
3285 for (k = 0; k < num_cons; k++)
3286 if (con_lst[k] == cfg->input_pins[i]) {
3293 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3294 imux->items[imux->num_items].index = index;
3298 if (imux->num_items) {
3300 * Set the current input for the muxes.
3301 * The STAC9221 has two input muxes with identical source
3302 * NID lists. Hopefully this won't get confused.
3304 for (i = 0; i < spec->num_muxes; i++) {
3305 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3306 AC_VERB_SET_CONNECT_SEL,
3307 imux->items[0].index);
3314 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3316 struct sigmatel_spec *spec = codec->spec;
3319 for (i = 0; i < spec->autocfg.line_outs; i++) {
3320 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3321 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3325 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3327 struct sigmatel_spec *spec = codec->spec;
3330 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3332 pin = spec->autocfg.hp_pins[i];
3333 if (pin) /* connect to front */
3334 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3336 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3338 pin = spec->autocfg.speaker_pins[i];
3339 if (pin) /* connect to front */
3340 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3344 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3346 struct sigmatel_spec *spec = codec->spec;
3348 int hp_speaker_swap = 0;
3350 if ((err = snd_hda_parse_pin_def_config(codec,
3352 spec->dmic_nids)) < 0)
3354 if (! spec->autocfg.line_outs)
3355 return 0; /* can't find valid pin config */
3357 /* If we have no real line-out pin and multiple hp-outs, HPs should
3358 * be set up as multi-channel outputs.
3360 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3361 spec->autocfg.hp_outs > 1) {
3362 /* Copy hp_outs to line_outs, backup line_outs in
3363 * speaker_outs so that the following routines can handle
3364 * HP pins as primary outputs.
3366 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3367 sizeof(spec->autocfg.line_out_pins));
3368 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3369 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3370 sizeof(spec->autocfg.hp_pins));
3371 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3372 hp_speaker_swap = 1;
3374 if (spec->autocfg.mono_out_pin) {
3375 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3376 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3377 u32 caps = query_amp_caps(codec,
3378 spec->autocfg.mono_out_pin, dir);
3379 hda_nid_t conn_list[1];
3381 /* get the mixer node and then the mono mux if it exists */
3382 if (snd_hda_get_connections(codec,
3383 spec->autocfg.mono_out_pin, conn_list, 1) &&
3384 snd_hda_get_connections(codec, conn_list[0],
3387 int wcaps = get_wcaps(codec, conn_list[0]);
3388 int wid_type = (wcaps & AC_WCAP_TYPE)
3389 >> AC_WCAP_TYPE_SHIFT;
3390 /* LR swap check, some stac925x have a mux that
3391 * changes the DACs output path instead of the
3394 if (wid_type == AC_WID_AUD_SEL &&
3395 !(wcaps & AC_WCAP_LR_SWAP))
3396 spec->mono_nid = conn_list[0];
3399 hda_nid_t nid = spec->autocfg.mono_out_pin;
3401 /* most mono outs have a least a mute/unmute switch */
3402 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3403 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3404 "Mono Playback Switch",
3405 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3408 /* check for volume support for the amp */
3409 if ((caps & AC_AMPCAP_NUM_STEPS)
3410 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3411 err = stac92xx_add_control(spec,
3412 STAC_CTL_WIDGET_VOL,
3413 "Mono Playback Volume",
3414 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3420 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3424 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3426 if (spec->multiout.num_dacs == 0)
3427 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3430 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3435 /* setup analog beep controls */
3436 if (spec->anabeep_nid > 0) {
3437 err = stac92xx_auto_create_beep_ctls(codec,
3443 /* setup digital beep controls and input device */
3444 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3445 if (spec->digbeep_nid > 0) {
3446 hda_nid_t nid = spec->digbeep_nid;
3449 err = stac92xx_auto_create_beep_ctls(codec, nid);
3452 err = snd_hda_attach_beep_device(codec, nid);
3455 /* if no beep switch is available, make its own one */
3456 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3458 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3459 err = stac92xx_beep_switch_ctl(codec);
3466 if (hp_speaker_swap == 1) {
3467 /* Restore the hp_outs and line_outs */
3468 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3469 sizeof(spec->autocfg.line_out_pins));
3470 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3471 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3472 sizeof(spec->autocfg.speaker_pins));
3473 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3474 memset(spec->autocfg.speaker_pins, 0,
3475 sizeof(spec->autocfg.speaker_pins));
3476 spec->autocfg.speaker_outs = 0;
3479 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3484 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3489 if (spec->mono_nid > 0) {
3490 err = stac92xx_auto_create_mono_output_ctls(codec);
3494 if (spec->num_amps > 0) {
3495 err = stac92xx_auto_create_amp_output_ctls(codec);
3499 if (spec->num_dmics > 0 && !spec->dinput_mux)
3500 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3501 &spec->autocfg)) < 0)
3503 if (spec->num_muxes > 0) {
3504 err = stac92xx_auto_create_mux_input_ctls(codec);
3508 if (spec->num_smuxes > 0) {
3509 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3514 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3515 if (spec->multiout.max_channels > 2)
3516 spec->surr_switch = 1;
3518 if (spec->autocfg.dig_out_pin)
3519 spec->multiout.dig_out_nid = dig_out;
3520 if (dig_in && spec->autocfg.dig_in_pin)
3521 spec->dig_in_nid = dig_in;
3523 if (spec->kctl_alloc)
3524 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3526 spec->input_mux = &spec->private_imux;
3527 spec->dinput_mux = &spec->private_dimux;
3528 spec->sinput_mux = &spec->private_smux;
3529 spec->mono_mux = &spec->private_mono_mux;
3530 spec->amp_mux = &spec->private_amp_mux;
3534 /* add playback controls for HP output */
3535 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3536 struct auto_pin_cfg *cfg)
3538 struct sigmatel_spec *spec = codec->spec;
3539 hda_nid_t pin = cfg->hp_pins[0];
3540 unsigned int wid_caps;
3545 wid_caps = get_wcaps(codec, pin);
3546 if (wid_caps & AC_WCAP_UNSOL_CAP)
3547 spec->hp_detect = 1;
3552 /* add playback controls for LFE output */
3553 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3554 struct auto_pin_cfg *cfg)
3556 struct sigmatel_spec *spec = codec->spec;
3558 hda_nid_t lfe_pin = 0x0;
3562 * search speaker outs and line outs for a mono speaker pin
3563 * with an amp. If one is found, add LFE controls
3566 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3567 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3568 unsigned int wcaps = get_wcaps(codec, pin);
3569 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3570 if (wcaps == AC_WCAP_OUT_AMP)
3571 /* found a mono speaker with an amp, must be lfe */
3575 /* if speaker_outs is 0, then speakers may be in line_outs */
3576 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3577 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3578 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3579 unsigned int defcfg;
3580 defcfg = snd_hda_codec_read(codec, pin, 0,
3581 AC_VERB_GET_CONFIG_DEFAULT,
3583 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3584 unsigned int wcaps = get_wcaps(codec, pin);
3585 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3586 if (wcaps == AC_WCAP_OUT_AMP)
3587 /* found a mono speaker with an amp,
3595 err = create_controls(spec, "LFE", lfe_pin, 1);
3603 static int stac9200_parse_auto_config(struct hda_codec *codec)
3605 struct sigmatel_spec *spec = codec->spec;
3608 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3611 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3614 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3617 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3620 if (spec->num_muxes > 0) {
3621 err = stac92xx_auto_create_mux_input_ctls(codec);
3626 if (spec->autocfg.dig_out_pin)
3627 spec->multiout.dig_out_nid = 0x05;
3628 if (spec->autocfg.dig_in_pin)
3629 spec->dig_in_nid = 0x04;
3631 if (spec->kctl_alloc)
3632 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3634 spec->input_mux = &spec->private_imux;
3635 spec->dinput_mux = &spec->private_dimux;
3641 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3642 * funky external mute control using GPIO pins.
3645 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3646 unsigned int dir_mask, unsigned int data)
3648 unsigned int gpiostate, gpiomask, gpiodir;
3650 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3651 AC_VERB_GET_GPIO_DATA, 0);
3652 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3654 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3655 AC_VERB_GET_GPIO_MASK, 0);
3658 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3659 AC_VERB_GET_GPIO_DIRECTION, 0);
3660 gpiodir |= dir_mask;
3662 /* Configure GPIOx as CMOS */
3663 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3665 snd_hda_codec_write(codec, codec->afg, 0,
3666 AC_VERB_SET_GPIO_MASK, gpiomask);
3667 snd_hda_codec_read(codec, codec->afg, 0,
3668 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3672 snd_hda_codec_read(codec, codec->afg, 0,
3673 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3676 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3679 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
3680 snd_hda_codec_write_cache(codec, nid, 0,
3681 AC_VERB_SET_UNSOLICITED_ENABLE,
3682 (AC_USRSP_EN | event));
3685 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3688 for (i = 0; i < cfg->hp_outs; i++)
3689 if (cfg->hp_pins[i] == nid)
3690 return 1; /* nid is a HP-Out */
3692 return 0; /* nid is not a HP-Out */
3695 static void stac92xx_power_down(struct hda_codec *codec)
3697 struct sigmatel_spec *spec = codec->spec;
3699 /* power down inactive DACs */
3701 for (dac = spec->dac_list; *dac; dac++)
3702 if (!is_in_dac_nids(spec, *dac) &&
3703 spec->multiout.hp_nid != *dac)
3704 snd_hda_codec_write_cache(codec, *dac, 0,
3705 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3708 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3711 static int stac92xx_init(struct hda_codec *codec)
3713 struct sigmatel_spec *spec = codec->spec;
3714 struct auto_pin_cfg *cfg = &spec->autocfg;
3718 snd_hda_sequence_write(codec, spec->init);
3720 /* power down adcs initially */
3721 if (spec->powerdown_adcs)
3722 for (i = 0; i < spec->num_adcs; i++)
3723 snd_hda_codec_write_cache(codec,
3724 spec->adc_nids[i], 0,
3725 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3728 gpio = spec->gpio_data;
3729 /* turn on EAPD statically when spec->eapd_switch isn't set.
3730 * otherwise, unsol event will turn it on/off dynamically
3732 if (!spec->eapd_switch)
3733 gpio |= spec->eapd_mask;
3734 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
3737 if (spec->hp_detect) {
3738 /* Enable unsolicited responses on the HP widget */
3739 for (i = 0; i < cfg->hp_outs; i++)
3740 enable_pin_detect(codec, cfg->hp_pins[i],
3742 /* force to enable the first line-out; the others are set up
3745 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3747 stac92xx_auto_init_hp_out(codec);
3748 /* fake event to set up pins */
3749 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3751 stac92xx_auto_init_multi_out(codec);
3752 stac92xx_auto_init_hp_out(codec);
3754 for (i = 0; i < AUTO_PIN_LAST; i++) {
3755 hda_nid_t nid = cfg->input_pins[i];
3757 unsigned int pinctl;
3758 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3759 /* for mic pins, force to initialize */
3760 pinctl = stac92xx_get_vref(codec, nid);
3762 pinctl = snd_hda_codec_read(codec, nid, 0,
3763 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3764 /* if PINCTL already set then skip */
3765 if (pinctl & AC_PINCTL_IN_EN)
3768 pinctl |= AC_PINCTL_IN_EN;
3769 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3772 for (i = 0; i < spec->num_dmics; i++)
3773 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3775 if (cfg->dig_out_pin)
3776 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3778 if (cfg->dig_in_pin)
3779 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3781 for (i = 0; i < spec->num_pwrs; i++) {
3782 hda_nid_t nid = spec->pwr_nids[i];
3783 int pinctl, def_conf;
3784 int event = STAC_PWR_EVENT;
3786 if (is_nid_hp_pin(cfg, nid) && spec->hp_detect)
3787 continue; /* already has an unsol event */
3789 pinctl = snd_hda_codec_read(codec, nid, 0,
3790 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3791 /* outputs are only ports capable of power management
3792 * any attempts on powering down a input port cause the
3793 * referenced VREF to act quirky.
3795 if (pinctl & AC_PINCTL_IN_EN)
3797 def_conf = snd_hda_codec_read(codec, nid, 0,
3798 AC_VERB_GET_CONFIG_DEFAULT, 0);
3799 def_conf = get_defcfg_connect(def_conf);
3800 /* skip any ports that don't have jacks since presence
3801 * detection is useless */
3802 if (def_conf != AC_JACK_PORT_COMPLEX) {
3803 if (def_conf != AC_JACK_PORT_NONE)
3804 stac_toggle_power_map(codec, nid, 1);
3807 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3808 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3811 stac92xx_power_down(codec);
3815 static void stac92xx_free(struct hda_codec *codec)
3817 struct sigmatel_spec *spec = codec->spec;
3823 if (spec->kctl_alloc) {
3824 for (i = 0; i < spec->num_kctl_used; i++)
3825 kfree(spec->kctl_alloc[i].name);
3826 kfree(spec->kctl_alloc);
3829 if (spec->bios_pin_configs)
3830 kfree(spec->bios_pin_configs);
3833 snd_hda_detach_beep_device(codec);
3836 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3839 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3840 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3842 if (pin_ctl & AC_PINCTL_IN_EN) {
3844 * we need to check the current set-up direction of
3845 * shared input pins since they can be switched via
3846 * "xxx as Output" mixer switch
3848 struct sigmatel_spec *spec = codec->spec;
3849 struct auto_pin_cfg *cfg = &spec->autocfg;
3850 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3851 spec->line_switch) ||
3852 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3857 /* if setting pin direction bits, clear the current
3858 direction bits first */
3859 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3860 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3862 snd_hda_codec_write_cache(codec, nid, 0,
3863 AC_VERB_SET_PIN_WIDGET_CONTROL,
3867 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3870 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3871 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3872 snd_hda_codec_write_cache(codec, nid, 0,
3873 AC_VERB_SET_PIN_WIDGET_CONTROL,
3877 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3881 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3883 unsigned int pinctl;
3884 pinctl = snd_hda_codec_read(codec, nid, 0,
3885 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3886 if (pinctl & AC_PINCTL_IN_EN)
3887 return 0; /* mic- or line-input */
3889 return 1; /* HP-output */
3894 /* return non-zero if the hp-pin of the given array index isn't
3895 * a jack-detection target
3897 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
3899 struct auto_pin_cfg *cfg = &spec->autocfg;
3901 /* ignore sensing of shared line and mic jacks */
3902 if (spec->line_switch &&
3903 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
3905 if (spec->mic_switch &&
3906 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
3908 /* ignore if the pin is set as line-out */
3909 if (cfg->hp_pins[i] == spec->hp_switch)
3914 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3916 struct sigmatel_spec *spec = codec->spec;
3917 struct auto_pin_cfg *cfg = &spec->autocfg;
3921 if (spec->gpio_mute)
3922 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3923 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3925 for (i = 0; i < cfg->hp_outs; i++) {
3928 if (no_hp_sensing(spec, i))
3930 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3934 /* disable lineouts */
3935 if (spec->hp_switch)
3936 stac92xx_reset_pinctl(codec, spec->hp_switch,
3938 for (i = 0; i < cfg->line_outs; i++)
3939 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3941 for (i = 0; i < cfg->speaker_outs; i++)
3942 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3944 if (spec->eapd_mask && spec->eapd_switch)
3945 stac_gpio_set(codec, spec->gpio_mask,
3946 spec->gpio_dir, spec->gpio_data &
3949 /* enable lineouts */
3950 if (spec->hp_switch)
3951 stac92xx_set_pinctl(codec, spec->hp_switch,
3953 for (i = 0; i < cfg->line_outs; i++)
3954 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3956 for (i = 0; i < cfg->speaker_outs; i++)
3957 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3959 if (spec->eapd_mask && spec->eapd_switch)
3960 stac_gpio_set(codec, spec->gpio_mask,
3961 spec->gpio_dir, spec->gpio_data |
3964 /* toggle hp outs */
3965 for (i = 0; i < cfg->hp_outs; i++) {
3966 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
3967 if (no_hp_sensing(spec, i))
3970 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
3972 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
3976 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3979 struct sigmatel_spec *spec = codec->spec;
3980 unsigned int idx, val;
3982 for (idx = 0; idx < spec->num_pwrs; idx++) {
3983 if (spec->pwr_nids[idx] == nid)
3986 if (idx >= spec->num_pwrs)
3989 /* several codecs have two power down bits */
3990 if (spec->pwr_mapping)
3991 idx = spec->pwr_mapping[idx];
3995 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4001 /* power down unused output ports */
4002 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4005 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4007 stac_toggle_power_map(codec, nid, get_hp_pin_presence(codec, nid));
4010 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4012 struct sigmatel_spec *spec = codec->spec;
4013 int idx = res >> 26 & 0x0f;
4015 switch ((res >> 26) & 0x70) {
4017 stac92xx_hp_detect(codec, res);
4019 case STAC_PWR_EVENT:
4020 if (spec->num_pwrs > 0)
4021 stac92xx_pin_sense(codec, idx);
4023 case STAC_VREF_EVENT: {
4024 int data = snd_hda_codec_read(codec, codec->afg, 0,
4025 AC_VERB_GET_GPIO_DATA, 0);
4026 /* toggle VREF state based on GPIOx status */
4027 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4028 !!(data & (1 << idx)));
4034 #ifdef SND_HDA_NEEDS_RESUME
4035 static int stac92xx_resume(struct hda_codec *codec)
4037 struct sigmatel_spec *spec = codec->spec;
4039 stac92xx_set_config_regs(codec);
4040 snd_hda_sequence_write(codec, spec->init);
4041 stac_gpio_set(codec, spec->gpio_mask,
4042 spec->gpio_dir, spec->gpio_data);
4043 snd_hda_codec_resume_amp(codec);
4044 snd_hda_codec_resume_cache(codec);
4045 /* power down inactive DACs */
4047 stac92xx_power_down(codec);
4048 /* invoke unsolicited event to reset the HP state */
4049 if (spec->hp_detect)
4050 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4055 static struct hda_codec_ops stac92xx_patch_ops = {
4056 .build_controls = stac92xx_build_controls,
4057 .build_pcms = stac92xx_build_pcms,
4058 .init = stac92xx_init,
4059 .free = stac92xx_free,
4060 .unsol_event = stac92xx_unsol_event,
4061 #ifdef SND_HDA_NEEDS_RESUME
4062 .resume = stac92xx_resume,
4066 static int patch_stac9200(struct hda_codec *codec)
4068 struct sigmatel_spec *spec;
4071 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4076 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4077 spec->pin_nids = stac9200_pin_nids;
4078 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4081 if (spec->board_config < 0) {
4082 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4083 err = stac92xx_save_bios_config_regs(codec);
4085 stac92xx_free(codec);
4088 spec->pin_configs = spec->bios_pin_configs;
4090 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4091 stac92xx_set_config_regs(codec);
4094 spec->multiout.max_channels = 2;
4095 spec->multiout.num_dacs = 1;
4096 spec->multiout.dac_nids = stac9200_dac_nids;
4097 spec->adc_nids = stac9200_adc_nids;
4098 spec->mux_nids = stac9200_mux_nids;
4099 spec->num_muxes = 1;
4100 spec->num_dmics = 0;
4104 if (spec->board_config == STAC_9200_GATEWAY ||
4105 spec->board_config == STAC_9200_OQO)
4106 spec->init = stac9200_eapd_init;
4108 spec->init = stac9200_core_init;
4109 spec->mixer = stac9200_mixer;
4111 if (spec->board_config == STAC_9200_PANASONIC) {
4112 spec->gpio_mask = spec->gpio_dir = 0x09;
4113 spec->gpio_data = 0x00;
4116 err = stac9200_parse_auto_config(codec);
4118 stac92xx_free(codec);
4122 codec->patch_ops = stac92xx_patch_ops;
4127 static int patch_stac925x(struct hda_codec *codec)
4129 struct sigmatel_spec *spec;
4132 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4137 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4138 spec->pin_nids = stac925x_pin_nids;
4139 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4143 if (spec->board_config < 0) {
4144 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4145 "using BIOS defaults\n");
4146 err = stac92xx_save_bios_config_regs(codec);
4148 stac92xx_free(codec);
4151 spec->pin_configs = spec->bios_pin_configs;
4152 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4153 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4154 stac92xx_set_config_regs(codec);
4157 spec->multiout.max_channels = 2;
4158 spec->multiout.num_dacs = 1;
4159 spec->multiout.dac_nids = stac925x_dac_nids;
4160 spec->adc_nids = stac925x_adc_nids;
4161 spec->mux_nids = stac925x_mux_nids;
4162 spec->num_muxes = 1;
4165 switch (codec->vendor_id) {
4166 case 0x83847632: /* STAC9202 */
4167 case 0x83847633: /* STAC9202D */
4168 case 0x83847636: /* STAC9251 */
4169 case 0x83847637: /* STAC9251D */
4170 spec->num_dmics = STAC925X_NUM_DMICS;
4171 spec->dmic_nids = stac925x_dmic_nids;
4172 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4173 spec->dmux_nids = stac925x_dmux_nids;
4176 spec->num_dmics = 0;
4180 spec->init = stac925x_core_init;
4181 spec->mixer = stac925x_mixer;
4183 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4185 if (spec->board_config < 0) {
4186 printk(KERN_WARNING "hda_codec: No auto-config is "
4187 "available, default to model=ref\n");
4188 spec->board_config = STAC_925x_REF;
4194 stac92xx_free(codec);
4198 codec->patch_ops = stac92xx_patch_ops;
4203 static struct hda_input_mux stac92hd73xx_dmux = {
4206 { "Analog Inputs", 0x0b },
4207 { "Digital Mic 1", 0x09 },
4208 { "Digital Mic 2", 0x0a },
4213 static int patch_stac92hd73xx(struct hda_codec *codec)
4215 struct sigmatel_spec *spec;
4216 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4219 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4224 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4225 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4226 spec->pin_nids = stac92hd73xx_pin_nids;
4227 spec->board_config = snd_hda_check_board_config(codec,
4228 STAC_92HD73XX_MODELS,
4229 stac92hd73xx_models,
4230 stac92hd73xx_cfg_tbl);
4232 if (spec->board_config < 0) {
4233 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4234 " STAC92HD73XX, using BIOS defaults\n");
4235 err = stac92xx_save_bios_config_regs(codec);
4237 stac92xx_free(codec);
4240 spec->pin_configs = spec->bios_pin_configs;
4242 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4243 stac92xx_set_config_regs(codec);
4246 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4247 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4249 if (spec->multiout.num_dacs < 0) {
4250 printk(KERN_WARNING "hda_codec: Could not determine "
4251 "number of channels defaulting to DAC count\n");
4252 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4255 switch (spec->multiout.num_dacs) {
4256 case 0x3: /* 6 Channel */
4257 spec->mixer = stac92hd73xx_6ch_mixer;
4258 spec->init = stac92hd73xx_6ch_core_init;
4260 case 0x4: /* 8 Channel */
4261 spec->mixer = stac92hd73xx_8ch_mixer;
4262 spec->init = stac92hd73xx_8ch_core_init;
4264 case 0x5: /* 10 Channel */
4265 spec->mixer = stac92hd73xx_10ch_mixer;
4266 spec->init = stac92hd73xx_10ch_core_init;
4269 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4270 spec->aloopback_mask = 0x01;
4271 spec->aloopback_shift = 8;
4273 spec->digbeep_nid = 0x1c;
4274 spec->mux_nids = stac92hd73xx_mux_nids;
4275 spec->adc_nids = stac92hd73xx_adc_nids;
4276 spec->dmic_nids = stac92hd73xx_dmic_nids;
4277 spec->dmux_nids = stac92hd73xx_dmux_nids;
4278 spec->smux_nids = stac92hd73xx_smux_nids;
4279 spec->amp_nids = stac92hd73xx_amp_nids;
4280 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4282 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4283 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4284 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4285 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4286 sizeof(stac92hd73xx_dmux));
4288 switch (spec->board_config) {
4290 spec->init = dell_eq_core_init;
4292 case STAC_DELL_M6_AMIC:
4293 case STAC_DELL_M6_DMIC:
4294 case STAC_DELL_M6_BOTH:
4295 spec->num_smuxes = 0;
4296 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4297 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4298 spec->eapd_switch = 0;
4302 spec->init = dell_m6_core_init;
4303 switch (spec->board_config) {
4304 case STAC_DELL_M6_AMIC: /* Analog Mics */
4305 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4306 spec->num_dmics = 0;
4307 spec->private_dimux.num_items = 1;
4309 case STAC_DELL_M6_DMIC: /* Digital Mics */
4310 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4311 spec->num_dmics = 1;
4312 spec->private_dimux.num_items = 2;
4314 case STAC_DELL_M6_BOTH: /* Both */
4315 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4316 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4317 spec->num_dmics = 1;
4318 spec->private_dimux.num_items = 2;
4323 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4324 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4325 spec->eapd_switch = 1;
4327 if (spec->board_config > STAC_92HD73XX_REF) {
4328 /* GPIO0 High = Enable EAPD */
4329 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4330 spec->gpio_data = 0x01;
4332 spec->dinput_mux = &spec->private_dimux;
4334 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4335 spec->pwr_nids = stac92hd73xx_pwr_nids;
4337 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
4340 if (spec->board_config < 0) {
4341 printk(KERN_WARNING "hda_codec: No auto-config is "
4342 "available, default to model=ref\n");
4343 spec->board_config = STAC_92HD73XX_REF;
4350 stac92xx_free(codec);
4354 codec->patch_ops = stac92xx_patch_ops;
4359 static struct hda_input_mux stac92hd83xxx_dmux = {
4362 { "Analog Inputs", 0x03 },
4363 { "Digital Mic 1", 0x04 },
4364 { "Digital Mic 2", 0x05 },
4368 static int patch_stac92hd83xxx(struct hda_codec *codec)
4370 struct sigmatel_spec *spec;
4373 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4378 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
4379 spec->mono_nid = 0x19;
4380 spec->digbeep_nid = 0x21;
4381 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4382 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4383 spec->adc_nids = stac92hd83xxx_adc_nids;
4384 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4385 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4386 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4387 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4389 spec->init = stac92hd83xxx_core_init;
4390 switch (codec->vendor_id) {
4392 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4396 spec->init++; /* switch to config #2 */
4397 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4400 spec->mixer = stac92hd83xxx_mixer;
4401 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4402 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4403 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4404 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4405 spec->dinput_mux = &stac92hd83xxx_dmux;
4406 spec->pin_nids = stac92hd83xxx_pin_nids;
4407 spec->board_config = snd_hda_check_board_config(codec,
4408 STAC_92HD83XXX_MODELS,
4409 stac92hd83xxx_models,
4410 stac92hd83xxx_cfg_tbl);
4412 if (spec->board_config < 0) {
4413 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4414 " STAC92HD83XXX, using BIOS defaults\n");
4415 err = stac92xx_save_bios_config_regs(codec);
4417 stac92xx_free(codec);
4420 spec->pin_configs = spec->bios_pin_configs;
4422 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4423 stac92xx_set_config_regs(codec);
4426 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4428 if (spec->board_config < 0) {
4429 printk(KERN_WARNING "hda_codec: No auto-config is "
4430 "available, default to model=ref\n");
4431 spec->board_config = STAC_92HD83XXX_REF;
4438 stac92xx_free(codec);
4442 codec->patch_ops = stac92xx_patch_ops;
4447 #ifdef SND_HDA_NEEDS_RESUME
4448 static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4450 struct sigmatel_spec *spec = codec->spec;
4452 snd_hda_codec_write_cache(codec, codec->afg, 0,
4453 AC_VERB_SET_POWER_STATE, pwr);
4456 for (i = 0; i < spec->num_adcs; i++) {
4457 snd_hda_codec_write_cache(codec,
4458 spec->adc_nids[i], 0,
4459 AC_VERB_SET_POWER_STATE, pwr);
4463 static int stac92hd71xx_resume(struct hda_codec *codec)
4465 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4466 return stac92xx_resume(codec);
4469 static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4471 struct sigmatel_spec *spec = codec->spec;
4473 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4474 if (spec->eapd_mask)
4475 stac_gpio_set(codec, spec->gpio_mask,
4476 spec->gpio_dir, spec->gpio_data &
4483 static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4484 .build_controls = stac92xx_build_controls,
4485 .build_pcms = stac92xx_build_pcms,
4486 .init = stac92xx_init,
4487 .free = stac92xx_free,
4488 .unsol_event = stac92xx_unsol_event,
4489 #ifdef SND_HDA_NEEDS_RESUME
4490 .resume = stac92hd71xx_resume,
4491 .suspend = stac92hd71xx_suspend,
4495 static struct hda_input_mux stac92hd71bxx_dmux = {
4498 { "Analog Inputs", 0x00 },
4500 { "Digital Mic 1", 0x02 },
4501 { "Digital Mic 2", 0x03 },
4505 static int patch_stac92hd71bxx(struct hda_codec *codec)
4507 struct sigmatel_spec *spec;
4510 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4515 codec->patch_ops = stac92xx_patch_ops;
4516 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
4517 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4518 spec->pin_nids = stac92hd71bxx_pin_nids;
4519 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4520 sizeof(stac92hd71bxx_dmux));
4521 spec->board_config = snd_hda_check_board_config(codec,
4522 STAC_92HD71BXX_MODELS,
4523 stac92hd71bxx_models,
4524 stac92hd71bxx_cfg_tbl);
4526 if (spec->board_config < 0) {
4527 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4528 " STAC92HD71BXX, using BIOS defaults\n");
4529 err = stac92xx_save_bios_config_regs(codec);
4531 stac92xx_free(codec);
4534 spec->pin_configs = spec->bios_pin_configs;
4536 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4537 stac92xx_set_config_regs(codec);
4540 if (spec->board_config > STAC_92HD71BXX_REF) {
4542 spec->gpio_mask = 0x01;
4543 spec->gpio_dir = 0x01;
4544 spec->gpio_data = 0x01;
4547 switch (codec->vendor_id) {
4548 case 0x111d76b6: /* 4 Port without Analog Mixer */
4550 case 0x111d76b4: /* 6 Port without Analog Mixer */
4552 spec->mixer = stac92hd71bxx_mixer;
4553 spec->init = stac92hd71bxx_core_init;
4554 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4556 case 0x111d7608: /* 5 Port with Analog Mixer */
4557 switch (spec->board_config) {
4559 /* Enable VREF power saving on GPIO1 detect */
4560 snd_hda_codec_write_cache(codec, codec->afg, 0,
4561 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4562 snd_hda_codec_write_cache(codec, codec->afg, 0,
4563 AC_VERB_SET_UNSOLICITED_ENABLE,
4564 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4565 spec->gpio_mask |= 0x02;
4568 if ((codec->revision_id & 0xf) == 0 ||
4569 (codec->revision_id & 0xf) == 1) {
4570 #ifdef SND_HDA_NEEDS_RESUME
4571 codec->patch_ops = stac92hd71bxx_patch_ops;
4573 spec->stream_delay = 40; /* 40 milliseconds */
4576 /* no output amps */
4578 spec->mixer = stac92hd71bxx_analog_mixer;
4579 spec->dinput_mux = &spec->private_dimux;
4582 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4583 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4585 case 0x111d7603: /* 6 Port with Analog Mixer */
4586 if ((codec->revision_id & 0xf) == 1) {
4587 #ifdef SND_HDA_NEEDS_RESUME
4588 codec->patch_ops = stac92hd71bxx_patch_ops;
4590 spec->stream_delay = 40; /* 40 milliseconds */
4593 /* no output amps */
4597 spec->dinput_mux = &spec->private_dimux;
4598 spec->mixer = stac92hd71bxx_analog_mixer;
4599 spec->init = stac92hd71bxx_analog_core_init;
4600 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4603 spec->aloopback_mask = 0x50;
4604 spec->aloopback_shift = 0;
4606 spec->powerdown_adcs = 1;
4607 spec->digbeep_nid = 0x26;
4608 spec->mux_nids = stac92hd71bxx_mux_nids;
4609 spec->adc_nids = stac92hd71bxx_adc_nids;
4610 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4611 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4612 spec->smux_nids = stac92hd71bxx_smux_nids;
4613 spec->pwr_nids = stac92hd71bxx_pwr_nids;
4615 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4616 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
4618 switch (spec->board_config) {
4620 /* enable internal microphone */
4621 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4622 stac92xx_auto_set_pinctl(codec, 0x0e,
4623 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
4625 case STAC_DELL_M4_2:
4626 spec->num_dmics = 0;
4627 spec->num_smuxes = 0;
4628 spec->num_dmuxes = 0;
4630 case STAC_DELL_M4_1:
4631 case STAC_DELL_M4_3:
4632 spec->num_dmics = 1;
4633 spec->num_smuxes = 0;
4634 spec->num_dmuxes = 0;
4637 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4638 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4639 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4642 spec->multiout.num_dacs = 1;
4643 spec->multiout.hp_nid = 0x11;
4644 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4645 if (spec->dinput_mux)
4646 spec->private_dimux.num_items +=
4648 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
4650 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4652 if (spec->board_config < 0) {
4653 printk(KERN_WARNING "hda_codec: No auto-config is "
4654 "available, default to model=ref\n");
4655 spec->board_config = STAC_92HD71BXX_REF;
4662 stac92xx_free(codec);
4669 static int patch_stac922x(struct hda_codec *codec)
4671 struct sigmatel_spec *spec;
4674 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4679 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
4680 spec->pin_nids = stac922x_pin_nids;
4681 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4684 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
4685 spec->gpio_mask = spec->gpio_dir = 0x03;
4686 spec->gpio_data = 0x03;
4687 /* Intel Macs have all same PCI SSID, so we need to check
4688 * codec SSID to distinguish the exact models
4690 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
4691 switch (codec->subsystem_id) {
4694 spec->board_config = STAC_INTEL_MAC_V1;
4698 spec->board_config = STAC_INTEL_MAC_V2;
4706 spec->board_config = STAC_INTEL_MAC_V3;
4710 spec->board_config = STAC_INTEL_MAC_V4;
4714 spec->board_config = STAC_INTEL_MAC_V5;
4717 spec->board_config = STAC_INTEL_MAC_V3;
4723 if (spec->board_config < 0) {
4724 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4725 "using BIOS defaults\n");
4726 err = stac92xx_save_bios_config_regs(codec);
4728 stac92xx_free(codec);
4731 spec->pin_configs = spec->bios_pin_configs;
4732 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
4733 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4734 stac92xx_set_config_regs(codec);
4737 spec->adc_nids = stac922x_adc_nids;
4738 spec->mux_nids = stac922x_mux_nids;
4739 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
4740 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
4741 spec->num_dmics = 0;
4744 spec->init = stac922x_core_init;
4745 spec->mixer = stac922x_mixer;
4747 spec->multiout.dac_nids = spec->dac_nids;
4749 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
4751 if (spec->board_config < 0) {
4752 printk(KERN_WARNING "hda_codec: No auto-config is "
4753 "available, default to model=ref\n");
4754 spec->board_config = STAC_D945_REF;
4760 stac92xx_free(codec);
4764 codec->patch_ops = stac92xx_patch_ops;
4766 /* Fix Mux capture level; max to 2 */
4767 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4768 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4769 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4770 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4771 (0 << AC_AMPCAP_MUTE_SHIFT));
4776 static int patch_stac927x(struct hda_codec *codec)
4778 struct sigmatel_spec *spec;
4781 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4786 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
4787 spec->pin_nids = stac927x_pin_nids;
4788 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4792 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4793 if (spec->board_config < 0)
4794 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4795 "STAC927x, using BIOS defaults\n");
4796 err = stac92xx_save_bios_config_regs(codec);
4798 stac92xx_free(codec);
4801 spec->pin_configs = spec->bios_pin_configs;
4803 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4804 stac92xx_set_config_regs(codec);
4807 spec->digbeep_nid = 0x23;
4808 spec->adc_nids = stac927x_adc_nids;
4809 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4810 spec->mux_nids = stac927x_mux_nids;
4811 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
4812 spec->smux_nids = stac927x_smux_nids;
4813 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
4814 spec->spdif_labels = stac927x_spdif_labels;
4815 spec->dac_list = stac927x_dac_nids;
4816 spec->multiout.dac_nids = spec->dac_nids;
4818 switch (spec->board_config) {
4821 /* GPIO0 High = Enable EAPD */
4822 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
4823 spec->gpio_data = 0x01;
4824 spec->num_dmics = 0;
4826 spec->init = d965_core_init;
4827 spec->mixer = stac927x_mixer;
4829 case STAC_DELL_BIOS:
4830 switch (codec->subsystem_id) {
4833 /* correct the device field to SPDIF out */
4834 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4837 /* configure the analog microphone on some laptops */
4838 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
4839 /* correct the front output jack as a hp out */
4840 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
4841 /* correct the front input jack as a mic */
4842 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4845 /* GPIO2 High = Enable EAPD */
4846 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
4847 spec->gpio_data = 0x04;
4848 spec->dmic_nids = stac927x_dmic_nids;
4849 spec->num_dmics = STAC927X_NUM_DMICS;
4851 spec->init = d965_core_init;
4852 spec->mixer = stac927x_mixer;
4853 spec->dmux_nids = stac927x_dmux_nids;
4854 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
4857 if (spec->board_config > STAC_D965_REF) {
4858 /* GPIO0 High = Enable EAPD */
4859 spec->eapd_mask = spec->gpio_mask = 0x01;
4860 spec->gpio_dir = spec->gpio_data = 0x01;
4862 spec->num_dmics = 0;
4864 spec->init = stac927x_core_init;
4865 spec->mixer = stac927x_mixer;
4869 spec->aloopback_mask = 0x40;
4870 spec->aloopback_shift = 0;
4871 spec->eapd_switch = 1;
4873 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
4875 if (spec->board_config < 0) {
4876 printk(KERN_WARNING "hda_codec: No auto-config is "
4877 "available, default to model=ref\n");
4878 spec->board_config = STAC_D965_REF;
4884 stac92xx_free(codec);
4888 codec->patch_ops = stac92xx_patch_ops;
4892 * The STAC927x seem to require fairly long delays for certain
4893 * command sequences. With too short delays (even if the answer
4894 * is set to RIRB properly), it results in the silence output
4895 * on some hardwares like Dell.
4897 * The below flag enables the longer delay (see get_response
4900 codec->bus->needs_damn_long_delay = 1;
4905 static int patch_stac9205(struct hda_codec *codec)
4907 struct sigmatel_spec *spec;
4910 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4915 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
4916 spec->pin_nids = stac9205_pin_nids;
4917 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4921 if (spec->board_config < 0) {
4922 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4923 err = stac92xx_save_bios_config_regs(codec);
4925 stac92xx_free(codec);
4928 spec->pin_configs = spec->bios_pin_configs;
4930 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4931 stac92xx_set_config_regs(codec);
4934 spec->digbeep_nid = 0x23;
4935 spec->adc_nids = stac9205_adc_nids;
4936 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
4937 spec->mux_nids = stac9205_mux_nids;
4938 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
4939 spec->smux_nids = stac9205_smux_nids;
4940 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
4941 spec->dmic_nids = stac9205_dmic_nids;
4942 spec->num_dmics = STAC9205_NUM_DMICS;
4943 spec->dmux_nids = stac9205_dmux_nids;
4944 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
4947 spec->init = stac9205_core_init;
4948 spec->mixer = stac9205_mixer;
4950 spec->aloopback_mask = 0x40;
4951 spec->aloopback_shift = 0;
4952 spec->eapd_switch = 1;
4953 spec->multiout.dac_nids = spec->dac_nids;
4955 switch (spec->board_config){
4956 case STAC_9205_DELL_M43:
4957 /* Enable SPDIF in/out */
4958 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4959 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
4961 /* Enable unsol response for GPIO4/Dock HP connection */
4962 snd_hda_codec_write_cache(codec, codec->afg, 0,
4963 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4964 snd_hda_codec_write_cache(codec, codec->afg, 0,
4965 AC_VERB_SET_UNSOLICITED_ENABLE,
4966 (AC_USRSP_EN | STAC_HP_EVENT));
4968 spec->gpio_dir = 0x0b;
4969 spec->eapd_mask = 0x01;
4970 spec->gpio_mask = 0x1b;
4971 spec->gpio_mute = 0x10;
4972 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
4975 spec->gpio_data = 0x01;
4978 /* SPDIF-In enabled */
4981 /* GPIO0 High = EAPD */
4982 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4983 spec->gpio_data = 0x01;
4987 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
4989 if (spec->board_config < 0) {
4990 printk(KERN_WARNING "hda_codec: No auto-config is "
4991 "available, default to model=ref\n");
4992 spec->board_config = STAC_9205_REF;
4998 stac92xx_free(codec);
5002 codec->patch_ops = stac92xx_patch_ops;
5011 /* static config for Sony VAIO FE550G and Sony VAIO AR */
5012 static hda_nid_t vaio_dacs[] = { 0x2 };
5013 #define VAIO_HP_DAC 0x5
5014 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5015 static hda_nid_t vaio_mux_nids[] = { 0x15 };
5017 static struct hda_input_mux vaio_mux = {
5020 /* { "HP", 0x0 }, */
5021 { "Mic Jack", 0x1 },
5022 { "Internal Mic", 0x2 },
5027 static struct hda_verb vaio_init[] = {
5028 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5029 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
5030 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5031 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5032 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5033 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5034 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5035 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5036 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5037 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5038 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5039 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5043 static struct hda_verb vaio_ar_init[] = {
5044 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5045 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5046 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5047 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5048 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5050 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5051 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5052 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5053 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5054 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5060 /* bind volumes of both NID 0x02 and 0x05 */
5061 static struct hda_bind_ctls vaio_bind_master_vol = {
5062 .ops = &snd_hda_bind_vol,
5064 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5065 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5070 /* bind volumes of both NID 0x02 and 0x05 */
5071 static struct hda_bind_ctls vaio_bind_master_sw = {
5072 .ops = &snd_hda_bind_sw,
5074 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5075 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5080 static struct snd_kcontrol_new vaio_mixer[] = {
5081 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5082 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
5083 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5084 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5085 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5088 .name = "Capture Source",
5090 .info = stac92xx_mux_enum_info,
5091 .get = stac92xx_mux_enum_get,
5092 .put = stac92xx_mux_enum_put,
5097 static struct snd_kcontrol_new vaio_ar_mixer[] = {
5098 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5099 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
5100 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5101 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5102 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5103 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5104 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5107 .name = "Capture Source",
5109 .info = stac92xx_mux_enum_info,
5110 .get = stac92xx_mux_enum_get,
5111 .put = stac92xx_mux_enum_put,
5116 static struct hda_codec_ops stac9872_patch_ops = {
5117 .build_controls = stac92xx_build_controls,
5118 .build_pcms = stac92xx_build_pcms,
5119 .init = stac92xx_init,
5120 .free = stac92xx_free,
5121 #ifdef SND_HDA_NEEDS_RESUME
5122 .resume = stac92xx_resume,
5126 static int stac9872_vaio_init(struct hda_codec *codec)
5130 err = stac92xx_init(codec);
5133 if (codec->patch_ops.unsol_event)
5134 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5138 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5140 if (get_hp_pin_presence(codec, 0x0a)) {
5141 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5142 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5144 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5145 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5149 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5151 switch (res >> 26) {
5153 stac9872_vaio_hp_detect(codec, res);
5158 static struct hda_codec_ops stac9872_vaio_patch_ops = {
5159 .build_controls = stac92xx_build_controls,
5160 .build_pcms = stac92xx_build_pcms,
5161 .init = stac9872_vaio_init,
5162 .free = stac92xx_free,
5163 .unsol_event = stac9872_vaio_unsol_event,
5165 .resume = stac92xx_resume,
5169 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5171 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5173 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5175 /* AR Series. id=0x83847664 and subsys=104D1300 */
5180 static const char *stac9872_models[STAC_9872_MODELS] = {
5181 [CXD9872RD_VAIO] = "vaio",
5182 [CXD9872AKD_VAIO] = "vaio-ar",
5185 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5186 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5187 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5188 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
5189 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
5193 static int patch_stac9872(struct hda_codec *codec)
5195 struct sigmatel_spec *spec;
5198 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5201 if (board_config < 0)
5202 /* unknown config, let generic-parser do its job... */
5203 return snd_hda_parse_generic_codec(codec);
5205 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5210 switch (board_config) {
5211 case CXD9872RD_VAIO:
5212 case STAC9872AK_VAIO:
5213 case STAC9872K_VAIO:
5214 spec->mixer = vaio_mixer;
5215 spec->init = vaio_init;
5216 spec->multiout.max_channels = 2;
5217 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5218 spec->multiout.dac_nids = vaio_dacs;
5219 spec->multiout.hp_nid = VAIO_HP_DAC;
5220 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5221 spec->adc_nids = vaio_adcs;
5223 spec->input_mux = &vaio_mux;
5224 spec->mux_nids = vaio_mux_nids;
5225 codec->patch_ops = stac9872_vaio_patch_ops;
5228 case CXD9872AKD_VAIO:
5229 spec->mixer = vaio_ar_mixer;
5230 spec->init = vaio_ar_init;
5231 spec->multiout.max_channels = 2;
5232 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5233 spec->multiout.dac_nids = vaio_dacs;
5234 spec->multiout.hp_nid = VAIO_HP_DAC;
5235 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5237 spec->adc_nids = vaio_adcs;
5238 spec->input_mux = &vaio_mux;
5239 spec->mux_nids = vaio_mux_nids;
5240 codec->patch_ops = stac9872_patch_ops;
5251 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5252 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5253 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5254 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5255 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5256 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5257 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5258 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5259 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5260 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5261 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5262 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5263 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5264 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5265 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5266 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5267 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5268 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5269 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5270 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5271 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5272 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5273 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5274 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5275 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5276 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5277 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5278 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5279 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5280 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5281 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5282 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5283 /* The following does not take into account .id=0x83847661 when subsys =
5284 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5285 * currently not fully supported.
5287 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5288 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5289 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5290 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5291 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5292 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5293 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5294 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5295 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5296 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5297 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5298 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5299 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5300 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5301 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5302 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5303 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5304 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5305 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5306 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5307 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5308 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5309 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5310 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5311 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5312 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },