2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include <sound/asoundef.h>
33 #include <sound/jack.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
36 #include "hda_patch.h"
39 #define STAC_INSERT_EVENT 0x10
40 #define STAC_PWR_EVENT 0x20
41 #define STAC_HP_EVENT 0x30
42 #define STAC_VREF_EVENT 0x40
107 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
108 * is given, one of the above models will be
109 * chosen according to the subsystem id. */
110 /* for backward compatibility */
134 struct sigmatel_event {
139 struct sigmatel_jack {
142 struct snd_jack *jack;
145 struct sigmatel_spec {
146 struct snd_kcontrol_new *mixers[4];
147 unsigned int num_mixers;
150 unsigned int surr_switch: 1;
151 unsigned int line_switch: 1;
152 unsigned int mic_switch: 1;
153 unsigned int alt_switch: 1;
154 unsigned int hp_detect: 1;
155 unsigned int spdif_mute: 1;
158 unsigned int eapd_mask;
159 unsigned int gpio_mask;
160 unsigned int gpio_dir;
161 unsigned int gpio_data;
162 unsigned int gpio_mute;
165 unsigned int stream_delay;
167 /* analog loopback */
168 unsigned char aloopback_mask;
169 unsigned char aloopback_shift;
171 /* power management */
172 unsigned int num_pwrs;
173 unsigned int *pwr_mapping;
178 struct snd_array jacks;
181 struct snd_array events;
184 struct hda_input_mux *mono_mux;
185 struct hda_input_mux *amp_mux;
186 unsigned int cur_mmux;
187 struct hda_multi_out multiout;
188 hda_nid_t dac_nids[5];
192 unsigned int num_adcs;
194 unsigned int num_muxes;
195 hda_nid_t *dmic_nids;
196 unsigned int num_dmics;
197 hda_nid_t *dmux_nids;
198 unsigned int num_dmuxes;
199 hda_nid_t *smux_nids;
200 unsigned int num_smuxes;
201 const char **spdif_labels;
203 hda_nid_t dig_in_nid;
205 hda_nid_t anabeep_nid;
206 hda_nid_t digbeep_nid;
210 unsigned int num_pins;
211 unsigned int *pin_configs;
212 unsigned int *bios_pin_configs;
214 /* codec specific stuff */
215 struct hda_verb *init;
216 struct snd_kcontrol_new *mixer;
219 struct hda_input_mux *dinput_mux;
220 unsigned int cur_dmux[2];
221 struct hda_input_mux *input_mux;
222 unsigned int cur_mux[3];
223 struct hda_input_mux *sinput_mux;
224 unsigned int cur_smux[2];
225 unsigned int cur_amux;
227 unsigned int num_amps;
228 unsigned int powerdown_adcs;
231 unsigned int io_switch[2];
232 unsigned int clfe_swap;
233 unsigned int hp_switch;
234 unsigned int aloopback;
236 struct hda_pcm pcm_rec[2]; /* PCM information */
238 /* dynamic controls and input_mux */
239 struct auto_pin_cfg autocfg;
240 struct snd_array kctls;
241 struct hda_input_mux private_dimux;
242 struct hda_input_mux private_imux;
243 struct hda_input_mux private_smux;
244 struct hda_input_mux private_amp_mux;
245 struct hda_input_mux private_mono_mux;
248 static hda_nid_t stac9200_adc_nids[1] = {
252 static hda_nid_t stac9200_mux_nids[1] = {
256 static hda_nid_t stac9200_dac_nids[1] = {
260 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
261 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
265 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
269 static hda_nid_t stac92hd73xx_adc_nids[2] = {
273 #define DELL_M6_AMP 2
274 static hda_nid_t stac92hd73xx_amp_nids[3] = {
278 #define STAC92HD73XX_NUM_DMICS 2
279 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
283 #define STAC92HD73_DAC_COUNT 5
284 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
285 0x15, 0x16, 0x17, 0x18, 0x19,
288 static hda_nid_t stac92hd73xx_mux_nids[4] = {
289 0x28, 0x29, 0x2a, 0x2b,
292 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
296 static hda_nid_t stac92hd73xx_smux_nids[2] = {
300 #define STAC92HD83XXX_NUM_DMICS 2
301 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
305 #define STAC92HD81_DAC_COUNT 2
306 #define STAC92HD83_DAC_COUNT 3
307 static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
311 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
315 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
319 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
323 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
327 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
328 0x03, 0x0c, 0x10, 0x40,
331 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
335 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
339 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
343 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
347 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
351 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
355 #define STAC92HD71BXX_NUM_DMICS 2
356 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
360 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
364 static hda_nid_t stac925x_adc_nids[1] = {
368 static hda_nid_t stac925x_mux_nids[1] = {
372 static hda_nid_t stac925x_dac_nids[1] = {
376 #define STAC925X_NUM_DMICS 1
377 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
381 static hda_nid_t stac925x_dmux_nids[1] = {
385 static hda_nid_t stac922x_adc_nids[2] = {
389 static hda_nid_t stac922x_mux_nids[2] = {
393 static hda_nid_t stac927x_adc_nids[3] = {
397 static hda_nid_t stac927x_mux_nids[3] = {
401 static hda_nid_t stac927x_smux_nids[1] = {
405 static hda_nid_t stac927x_dac_nids[6] = {
406 0x02, 0x03, 0x04, 0x05, 0x06, 0
409 static hda_nid_t stac927x_dmux_nids[1] = {
413 #define STAC927X_NUM_DMICS 2
414 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
418 static const char *stac927x_spdif_labels[5] = {
419 "Digital Playback", "ADAT", "Analog Mux 1",
420 "Analog Mux 2", "Analog Mux 3"
423 static hda_nid_t stac9205_adc_nids[2] = {
427 static hda_nid_t stac9205_mux_nids[2] = {
431 static hda_nid_t stac9205_dmux_nids[1] = {
435 static hda_nid_t stac9205_smux_nids[1] = {
439 #define STAC9205_NUM_DMICS 2
440 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
444 static hda_nid_t stac9200_pin_nids[8] = {
445 0x08, 0x09, 0x0d, 0x0e,
446 0x0f, 0x10, 0x11, 0x12,
449 static hda_nid_t stac925x_pin_nids[8] = {
450 0x07, 0x08, 0x0a, 0x0b,
451 0x0c, 0x0d, 0x10, 0x11,
454 static hda_nid_t stac922x_pin_nids[10] = {
455 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
456 0x0f, 0x10, 0x11, 0x15, 0x1b,
459 static hda_nid_t stac92hd73xx_pin_nids[13] = {
460 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
461 0x0f, 0x10, 0x11, 0x12, 0x13,
465 static hda_nid_t stac92hd83xxx_pin_nids[14] = {
466 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
467 0x0f, 0x10, 0x11, 0x12, 0x13,
468 0x1d, 0x1e, 0x1f, 0x20
470 static hda_nid_t stac92hd71bxx_pin_nids[11] = {
471 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
472 0x0f, 0x14, 0x18, 0x19, 0x1e,
476 static hda_nid_t stac927x_pin_nids[14] = {
477 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
478 0x0f, 0x10, 0x11, 0x12, 0x13,
479 0x14, 0x21, 0x22, 0x23,
482 static hda_nid_t stac9205_pin_nids[12] = {
483 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
484 0x0f, 0x14, 0x16, 0x17, 0x18,
488 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
490 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
491 struct snd_ctl_elem_value *ucontrol)
493 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
494 struct sigmatel_spec *spec = codec->spec;
495 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
497 kcontrol->private_value ^= get_amp_nid(kcontrol);
498 kcontrol->private_value |= nid;
500 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
503 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
504 struct snd_ctl_elem_value *ucontrol)
506 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
507 struct sigmatel_spec *spec = codec->spec;
508 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
510 kcontrol->private_value ^= get_amp_nid(kcontrol);
511 kcontrol->private_value |= nid;
513 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
516 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
517 struct snd_ctl_elem_info *uinfo)
519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
520 struct sigmatel_spec *spec = codec->spec;
521 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
524 static int stac92xx_dmux_enum_get(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 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
535 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_value *ucontrol)
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 struct sigmatel_spec *spec = codec->spec;
540 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
542 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
543 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
546 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
547 struct snd_ctl_elem_info *uinfo)
549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
550 struct sigmatel_spec *spec = codec->spec;
551 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
554 static int stac92xx_smux_enum_get(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 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
561 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
565 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
566 struct snd_ctl_elem_value *ucontrol)
568 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
569 struct sigmatel_spec *spec = codec->spec;
570 struct hda_input_mux *smux = &spec->private_smux;
571 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
575 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
576 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
580 if (spec->spdif_mute) {
582 nid = spec->multiout.dig_out_nid;
584 nid = codec->slave_dig_outs[smux_idx - 1];
585 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
588 val = AMP_OUT_UNMUTE;
589 /* un/mute SPDIF out */
590 snd_hda_codec_write_cache(codec, nid, 0,
591 AC_VERB_SET_AMP_GAIN_MUTE, val);
596 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 struct sigmatel_spec *spec = codec->spec;
600 return snd_hda_input_mux_info(spec->input_mux, uinfo);
603 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
606 struct sigmatel_spec *spec = codec->spec;
607 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
609 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
613 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
616 struct sigmatel_spec *spec = codec->spec;
617 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
619 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
620 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
623 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
624 struct snd_ctl_elem_info *uinfo)
626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
627 struct sigmatel_spec *spec = codec->spec;
628 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
631 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
632 struct snd_ctl_elem_value *ucontrol)
634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
635 struct sigmatel_spec *spec = codec->spec;
637 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
641 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 struct sigmatel_spec *spec = codec->spec;
647 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
648 spec->mono_nid, &spec->cur_mmux);
651 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_info *uinfo)
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
656 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
659 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
660 struct snd_ctl_elem_value *ucontrol)
662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
663 struct sigmatel_spec *spec = codec->spec;
665 ucontrol->value.enumerated.item[0] = spec->cur_amux;
669 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
670 struct snd_ctl_elem_value *ucontrol)
672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
673 struct sigmatel_spec *spec = codec->spec;
674 struct snd_kcontrol *ctl =
675 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
679 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
680 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
682 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
686 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
688 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
689 struct snd_ctl_elem_value *ucontrol)
691 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
692 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
693 struct sigmatel_spec *spec = codec->spec;
695 ucontrol->value.integer.value[0] = !!(spec->aloopback &
696 (spec->aloopback_mask << idx));
700 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
701 struct snd_ctl_elem_value *ucontrol)
703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
704 struct sigmatel_spec *spec = codec->spec;
705 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
706 unsigned int dac_mode;
707 unsigned int val, idx_val;
709 idx_val = spec->aloopback_mask << idx;
710 if (ucontrol->value.integer.value[0])
711 val = spec->aloopback | idx_val;
713 val = spec->aloopback & ~idx_val;
714 if (spec->aloopback == val)
717 spec->aloopback = val;
719 /* Only return the bits defined by the shift value of the
720 * first two bytes of the mask
722 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
723 kcontrol->private_value & 0xFFFF, 0x0);
724 dac_mode >>= spec->aloopback_shift;
726 if (spec->aloopback & idx_val) {
727 snd_hda_power_up(codec);
730 snd_hda_power_down(codec);
731 dac_mode &= ~idx_val;
734 snd_hda_codec_write_cache(codec, codec->afg, 0,
735 kcontrol->private_value >> 16, dac_mode);
740 static struct hda_verb stac9200_core_init[] = {
741 /* set dac0mux for dac converter */
742 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
746 static struct hda_verb stac9200_eapd_init[] = {
747 /* set dac0mux for dac converter */
748 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
749 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
753 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
754 /* set master volume and direct control */
755 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
756 /* setup audio connections */
757 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
758 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
759 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
760 /* setup adcs to point to mixer */
761 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
762 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
763 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
764 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
765 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
766 /* setup import muxs */
767 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
768 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
769 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
770 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
774 static struct hda_verb dell_eq_core_init[] = {
775 /* set master volume to max value without distortion
776 * and direct control */
777 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
778 /* setup audio connections */
779 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
780 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
781 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
782 /* setup adcs to point to mixer */
783 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
784 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
785 /* setup import muxs */
786 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
787 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
788 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
789 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
793 static struct hda_verb dell_m6_core_init[] = {
794 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
795 /* setup audio connections */
796 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
797 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
798 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
799 /* setup adcs to point to mixer */
800 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
801 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
802 /* setup import muxs */
803 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
804 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
805 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
806 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
810 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
811 /* set master volume and direct control */
812 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
813 /* setup audio connections */
814 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
815 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
816 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
817 /* connect hp ports to dac3 */
818 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
819 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
820 /* setup adcs to point to mixer */
821 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
822 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
823 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
824 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
825 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
826 /* setup import muxs */
827 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
828 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
829 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
830 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
834 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
835 /* set master volume and direct control */
836 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
837 /* setup audio connections */
838 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
839 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
840 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
841 /* dac3 is connected to import3 mux */
842 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
843 /* connect hp ports to dac4 */
844 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
845 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
846 /* setup adcs to point to mixer */
847 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
848 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
849 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
850 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
851 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
852 /* setup import muxs */
853 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
854 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
855 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
856 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
860 static struct hda_verb stac92hd83xxx_core_init[] = {
861 /* start of config #1 */
862 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
864 /* start of config #2 */
865 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
866 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
867 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
869 /* power state controls amps */
870 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
873 static struct hda_verb stac92hd71bxx_core_init[] = {
874 /* set master volume and direct control */
875 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
876 /* connect headphone jack to dac1 */
877 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
878 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
879 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
880 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
881 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
884 #define HD_DISABLE_PORTF 2
885 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
886 /* start of config #1 */
888 /* connect port 0f to audio mixer */
889 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
890 /* unmute right and left channels for node 0x0f */
891 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
892 /* start of config #2 */
894 /* set master volume and direct control */
895 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
896 /* connect headphone jack to dac1 */
897 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
898 /* unmute right and left channels for nodes 0x0a, 0xd */
899 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
900 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
904 static struct hda_verb stac925x_core_init[] = {
905 /* set dac0mux for dac converter */
906 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
910 static struct hda_verb stac922x_core_init[] = {
911 /* set master volume and direct control */
912 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
916 static struct hda_verb d965_core_init[] = {
917 /* set master volume and direct control */
918 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
919 /* unmute node 0x1b */
920 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
921 /* select node 0x03 as DAC */
922 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
926 static struct hda_verb stac927x_core_init[] = {
927 /* set master volume and direct control */
928 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
929 /* enable analog pc beep path */
930 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
934 static struct hda_verb stac9205_core_init[] = {
935 /* set master volume and direct control */
936 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
937 /* enable analog pc beep path */
938 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
942 #define STAC_MONO_MUX \
944 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
945 .name = "Mono Mux", \
947 .info = stac92xx_mono_mux_enum_info, \
948 .get = stac92xx_mono_mux_enum_get, \
949 .put = stac92xx_mono_mux_enum_put, \
952 #define STAC_AMP_MUX \
954 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
955 .name = "Amp Selector Capture Switch", \
957 .info = stac92xx_amp_mux_enum_info, \
958 .get = stac92xx_amp_mux_enum_get, \
959 .put = stac92xx_amp_mux_enum_put, \
962 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
967 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
968 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
969 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
970 .info = stac92xx_amp_volume_info, \
971 .get = stac92xx_amp_volume_get, \
972 .put = stac92xx_amp_volume_put, \
973 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
974 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
977 #define STAC_INPUT_SOURCE(cnt) \
979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
980 .name = "Input Source", \
982 .info = stac92xx_mux_enum_info, \
983 .get = stac92xx_mux_enum_get, \
984 .put = stac92xx_mux_enum_put, \
987 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
990 .name = "Analog Loopback", \
992 .info = stac92xx_aloopback_info, \
993 .get = stac92xx_aloopback_get, \
994 .put = stac92xx_aloopback_put, \
995 .private_value = verb_read | (verb_write << 16), \
998 static struct snd_kcontrol_new stac9200_mixer[] = {
999 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1000 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
1001 STAC_INPUT_SOURCE(1),
1002 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1003 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1007 #define DELL_M6_MIXER 6
1008 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1009 /* start of config #1 */
1010 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1011 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1013 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1014 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1016 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1017 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1019 /* start of config #2 */
1020 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1021 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1023 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1024 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1026 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1028 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1029 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1031 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1032 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1037 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1038 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1040 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1041 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1043 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1044 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1046 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1047 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1049 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1050 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1052 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1053 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1055 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1056 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1058 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1059 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1063 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1064 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1066 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1067 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1069 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1070 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1072 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1073 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1075 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1076 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1078 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1079 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1081 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1082 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1084 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1085 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1090 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1091 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1092 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1094 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1095 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1097 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1098 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1100 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1101 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1103 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1104 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1106 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1107 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1110 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1111 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1116 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1117 STAC_INPUT_SOURCE(2),
1118 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1120 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1121 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1123 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1124 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1125 /* analog pc-beep replaced with digital beep support */
1127 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1128 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1131 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1132 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1134 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1135 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1137 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1138 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1140 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1141 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1145 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1146 STAC_INPUT_SOURCE(2),
1147 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1149 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1150 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1152 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1153 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1157 static struct snd_kcontrol_new stac925x_mixer[] = {
1158 STAC_INPUT_SOURCE(1),
1159 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1160 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1164 static struct snd_kcontrol_new stac9205_mixer[] = {
1165 STAC_INPUT_SOURCE(2),
1166 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1168 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1169 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1171 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1172 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1176 /* This needs to be generated dynamically based on sequence */
1177 static struct snd_kcontrol_new stac922x_mixer[] = {
1178 STAC_INPUT_SOURCE(2),
1179 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1180 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1182 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1183 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1188 static struct snd_kcontrol_new stac927x_mixer[] = {
1189 STAC_INPUT_SOURCE(3),
1190 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1192 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1193 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1195 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1196 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1198 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1199 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1203 static struct snd_kcontrol_new stac_dmux_mixer = {
1204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1205 .name = "Digital Input Source",
1206 /* count set later */
1207 .info = stac92xx_dmux_enum_info,
1208 .get = stac92xx_dmux_enum_get,
1209 .put = stac92xx_dmux_enum_put,
1212 static struct snd_kcontrol_new stac_smux_mixer = {
1213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1214 .name = "IEC958 Playback Source",
1215 /* count set later */
1216 .info = stac92xx_smux_enum_info,
1217 .get = stac92xx_smux_enum_get,
1218 .put = stac92xx_smux_enum_put,
1221 static const char *slave_vols[] = {
1222 "Front Playback Volume",
1223 "Surround Playback Volume",
1224 "Center Playback Volume",
1225 "LFE Playback Volume",
1226 "Side Playback Volume",
1227 "Headphone Playback Volume",
1228 "Headphone Playback Volume",
1229 "Speaker Playback Volume",
1230 "External Speaker Playback Volume",
1231 "Speaker2 Playback Volume",
1235 static const char *slave_sws[] = {
1236 "Front Playback Switch",
1237 "Surround Playback Switch",
1238 "Center Playback Switch",
1239 "LFE Playback Switch",
1240 "Side Playback Switch",
1241 "Headphone Playback Switch",
1242 "Headphone Playback Switch",
1243 "Speaker Playback Switch",
1244 "External Speaker Playback Switch",
1245 "Speaker2 Playback Switch",
1246 "IEC958 Playback Switch",
1250 static void stac92xx_free_kctls(struct hda_codec *codec);
1252 static int stac92xx_build_controls(struct hda_codec *codec)
1254 struct sigmatel_spec *spec = codec->spec;
1258 err = snd_hda_add_new_ctls(codec, spec->mixer);
1262 for (i = 0; i < spec->num_mixers; i++) {
1263 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1267 if (spec->num_dmuxes > 0) {
1268 stac_dmux_mixer.count = spec->num_dmuxes;
1269 err = snd_hda_ctl_add(codec,
1270 snd_ctl_new1(&stac_dmux_mixer, codec));
1274 if (spec->num_smuxes > 0) {
1275 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1276 struct hda_input_mux *smux = &spec->private_smux;
1277 /* check for mute support on SPDIF out */
1278 if (wcaps & AC_WCAP_OUT_AMP) {
1279 smux->items[smux->num_items].label = "Off";
1280 smux->items[smux->num_items].index = 0;
1282 spec->spdif_mute = 1;
1284 stac_smux_mixer.count = spec->num_smuxes;
1285 err = snd_ctl_add(codec->bus->card,
1286 snd_ctl_new1(&stac_smux_mixer, codec));
1291 if (spec->multiout.dig_out_nid) {
1292 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1295 err = snd_hda_create_spdif_share_sw(codec,
1299 spec->multiout.share_spdif = 1;
1301 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1302 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1307 /* if we have no master control, let's create it */
1308 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1309 unsigned int vmaster_tlv[4];
1310 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1311 HDA_OUTPUT, vmaster_tlv);
1312 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1313 vmaster_tlv, slave_vols);
1317 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1318 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1324 stac92xx_free_kctls(codec); /* no longer needed */
1328 static unsigned int ref9200_pin_configs[8] = {
1329 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1330 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1334 STAC 9200 pin configs for
1339 static unsigned int dell9200_d21_pin_configs[8] = {
1340 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1341 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1345 STAC 9200 pin configs for
1349 static unsigned int dell9200_d22_pin_configs[8] = {
1350 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1351 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1355 STAC 9200 pin configs for
1356 102801C4 (Dell Dimension E310)
1363 static unsigned int dell9200_d23_pin_configs[8] = {
1364 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1365 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1370 STAC 9200-32 pin configs for
1371 102801B5 (Dell Inspiron 630m)
1372 102801D8 (Dell Inspiron 640m)
1374 static unsigned int dell9200_m21_pin_configs[8] = {
1375 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1376 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1380 STAC 9200-32 pin configs for
1381 102801C2 (Dell Latitude D620)
1383 102801CC (Dell Latitude D820)
1387 static unsigned int dell9200_m22_pin_configs[8] = {
1388 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1389 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1393 STAC 9200-32 pin configs for
1394 102801CE (Dell XPS M1710)
1395 102801CF (Dell Precision M90)
1397 static unsigned int dell9200_m23_pin_configs[8] = {
1398 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1399 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1403 STAC 9200-32 pin configs for
1406 102801CB (Dell Latitude 120L)
1409 static unsigned int dell9200_m24_pin_configs[8] = {
1410 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1411 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1415 STAC 9200-32 pin configs for
1416 102801BD (Dell Inspiron E1505n)
1420 static unsigned int dell9200_m25_pin_configs[8] = {
1421 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1422 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1426 STAC 9200-32 pin configs for
1427 102801F5 (Dell Inspiron 1501)
1430 static unsigned int dell9200_m26_pin_configs[8] = {
1431 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1432 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1437 102801CD (Dell Inspiron E1705/9400)
1439 static unsigned int dell9200_m27_pin_configs[8] = {
1440 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1441 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1444 static unsigned int oqo9200_pin_configs[8] = {
1445 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1446 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1450 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1451 [STAC_REF] = ref9200_pin_configs,
1452 [STAC_9200_OQO] = oqo9200_pin_configs,
1453 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1454 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1455 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1456 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1457 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1458 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1459 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1460 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1461 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1462 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1463 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1466 static const char *stac9200_models[STAC_9200_MODELS] = {
1468 [STAC_9200_OQO] = "oqo",
1469 [STAC_9200_DELL_D21] = "dell-d21",
1470 [STAC_9200_DELL_D22] = "dell-d22",
1471 [STAC_9200_DELL_D23] = "dell-d23",
1472 [STAC_9200_DELL_M21] = "dell-m21",
1473 [STAC_9200_DELL_M22] = "dell-m22",
1474 [STAC_9200_DELL_M23] = "dell-m23",
1475 [STAC_9200_DELL_M24] = "dell-m24",
1476 [STAC_9200_DELL_M25] = "dell-m25",
1477 [STAC_9200_DELL_M26] = "dell-m26",
1478 [STAC_9200_DELL_M27] = "dell-m27",
1479 [STAC_9200_GATEWAY] = "gateway",
1480 [STAC_9200_PANASONIC] = "panasonic",
1483 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1484 /* SigmaTel reference board */
1485 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1486 "DFI LanParty", STAC_REF),
1487 /* Dell laptops have BIOS problem */
1488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1489 "unknown Dell", STAC_9200_DELL_D21),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1491 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1493 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1494 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1495 "unknown Dell", STAC_9200_DELL_D22),
1496 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1497 "unknown Dell", STAC_9200_DELL_D22),
1498 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1499 "Dell Latitude D620", STAC_9200_DELL_M22),
1500 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1501 "unknown Dell", STAC_9200_DELL_D23),
1502 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1503 "unknown Dell", STAC_9200_DELL_D23),
1504 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1505 "unknown Dell", STAC_9200_DELL_M22),
1506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1507 "unknown Dell", STAC_9200_DELL_M24),
1508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1509 "unknown Dell", STAC_9200_DELL_M24),
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1511 "Dell Latitude 120L", STAC_9200_DELL_M24),
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1513 "Dell Latitude D820", STAC_9200_DELL_M22),
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1515 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1517 "Dell XPS M1710", STAC_9200_DELL_M23),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1519 "Dell Precision M90", STAC_9200_DELL_M23),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1521 "unknown Dell", STAC_9200_DELL_M22),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1523 "unknown Dell", STAC_9200_DELL_M22),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1525 "unknown Dell", STAC_9200_DELL_M22),
1526 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1527 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1529 "unknown Dell", STAC_9200_DELL_D23),
1530 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1531 "unknown Dell", STAC_9200_DELL_D23),
1532 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1533 "unknown Dell", STAC_9200_DELL_D21),
1534 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1535 "unknown Dell", STAC_9200_DELL_D23),
1536 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1537 "unknown Dell", STAC_9200_DELL_D21),
1538 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1539 "unknown Dell", STAC_9200_DELL_M25),
1540 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1541 "unknown Dell", STAC_9200_DELL_M25),
1542 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1543 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1544 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1545 "unknown Dell", STAC_9200_DELL_M26),
1547 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1548 /* Gateway machines needs EAPD to be set on resume */
1549 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1550 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1552 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1555 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1559 static unsigned int ref925x_pin_configs[8] = {
1560 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1561 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1564 static unsigned int stac925x_MA6_pin_configs[8] = {
1565 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1566 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1569 static unsigned int stac925x_PA6_pin_configs[8] = {
1570 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1571 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1574 static unsigned int stac925xM2_2_pin_configs[8] = {
1575 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1576 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1579 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1580 [STAC_REF] = ref925x_pin_configs,
1581 [STAC_M2_2] = stac925xM2_2_pin_configs,
1582 [STAC_MA6] = stac925x_MA6_pin_configs,
1583 [STAC_PA6] = stac925x_PA6_pin_configs,
1586 static const char *stac925x_models[STAC_925x_MODELS] = {
1588 [STAC_M2_2] = "m2-2",
1593 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1594 /* SigmaTel reference board */
1595 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1596 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1597 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1598 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1599 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1600 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1601 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1605 static unsigned int ref92hd73xx_pin_configs[13] = {
1606 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1607 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1608 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1612 static unsigned int dell_m6_pin_configs[13] = {
1613 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1614 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1615 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1619 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1620 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1621 [STAC_DELL_M6] = dell_m6_pin_configs,
1622 [STAC_DELL_EQ] = dell_m6_pin_configs,
1625 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1626 [STAC_92HD73XX_REF] = "ref",
1627 [STAC_DELL_M6] = "dell-m6",
1628 [STAC_DELL_EQ] = "dell-eq",
1631 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1632 /* SigmaTel reference board */
1633 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1634 "DFI LanParty", STAC_92HD73XX_REF),
1635 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1636 "unknown Dell", STAC_DELL_M6),
1637 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1638 "unknown Dell", STAC_DELL_M6),
1639 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1640 "unknown Dell", STAC_DELL_M6),
1641 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1642 "unknown Dell", STAC_DELL_M6),
1643 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1644 "unknown Dell", STAC_DELL_M6),
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1646 "unknown Dell", STAC_DELL_M6),
1647 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1648 "unknown Dell", STAC_DELL_M6),
1652 static unsigned int ref92hd83xxx_pin_configs[14] = {
1653 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1654 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1655 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1656 0x01451160, 0x98560170,
1659 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1660 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1663 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1664 [STAC_92HD83XXX_REF] = "ref",
1667 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1668 /* SigmaTel reference board */
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1670 "DFI LanParty", STAC_92HD71BXX_REF),
1673 static unsigned int ref92hd71bxx_pin_configs[11] = {
1674 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1675 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1676 0x90a000f0, 0x01452050, 0x01452050,
1679 static unsigned int dell_m4_1_pin_configs[11] = {
1680 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1681 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1682 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
1685 static unsigned int dell_m4_2_pin_configs[11] = {
1686 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1687 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
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_HP_M4] = NULL,
1698 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1699 [STAC_92HD71BXX_REF] = "ref",
1700 [STAC_DELL_M4_1] = "dell-m4-1",
1701 [STAC_DELL_M4_2] = "dell-m4-2",
1702 [STAC_HP_M4] = "hp-m4",
1705 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1706 /* SigmaTel reference board */
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1708 "DFI LanParty", STAC_92HD71BXX_REF),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1710 "unknown HP", STAC_HP_M4),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1712 "unknown Dell", STAC_DELL_M4_1),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1714 "unknown Dell", STAC_DELL_M4_1),
1715 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1716 "unknown Dell", STAC_DELL_M4_1),
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1718 "unknown Dell", STAC_DELL_M4_1),
1719 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1720 "unknown Dell", STAC_DELL_M4_1),
1721 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1722 "unknown Dell", STAC_DELL_M4_1),
1723 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1724 "unknown Dell", STAC_DELL_M4_1),
1725 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1726 "unknown Dell", STAC_DELL_M4_2),
1727 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1728 "unknown Dell", STAC_DELL_M4_2),
1729 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1730 "unknown Dell", STAC_DELL_M4_2),
1731 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1732 "unknown Dell", STAC_DELL_M4_2),
1736 static unsigned int ref922x_pin_configs[10] = {
1737 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1738 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1739 0x40000100, 0x40000100,
1743 STAC 922X pin configs for
1750 static unsigned int dell_922x_d81_pin_configs[10] = {
1751 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1752 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1753 0x01813122, 0x400001f2,
1757 STAC 922X pin configs for
1761 static unsigned int dell_922x_d82_pin_configs[10] = {
1762 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1763 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1764 0x01813122, 0x400001f1,
1768 STAC 922X pin configs for
1771 static unsigned int dell_922x_m81_pin_configs[10] = {
1772 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1773 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1774 0x40C003f1, 0x405003f0,
1778 STAC 9221 A1 pin configs for
1779 102801D7 (Dell XPS M1210)
1781 static unsigned int dell_922x_m82_pin_configs[10] = {
1782 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1783 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1784 0x508003f3, 0x405003f4,
1787 static unsigned int d945gtp3_pin_configs[10] = {
1788 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1789 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1790 0x02a19120, 0x40000100,
1793 static unsigned int d945gtp5_pin_configs[10] = {
1794 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1795 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1796 0x02a19320, 0x40000100,
1799 static unsigned int intel_mac_v1_pin_configs[10] = {
1800 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1801 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1802 0x400000fc, 0x400000fb,
1805 static unsigned int intel_mac_v2_pin_configs[10] = {
1806 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1807 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1808 0x400000fc, 0x400000fb,
1811 static unsigned int intel_mac_v3_pin_configs[10] = {
1812 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1813 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1814 0x400000fc, 0x400000fb,
1817 static unsigned int intel_mac_v4_pin_configs[10] = {
1818 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1819 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1820 0x400000fc, 0x400000fb,
1823 static unsigned int intel_mac_v5_pin_configs[10] = {
1824 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1825 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1826 0x400000fc, 0x400000fb,
1829 static unsigned int ecs202_pin_configs[10] = {
1830 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1831 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1832 0x9037012e, 0x40e000f2,
1835 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1836 [STAC_D945_REF] = ref922x_pin_configs,
1837 [STAC_D945GTP3] = d945gtp3_pin_configs,
1838 [STAC_D945GTP5] = d945gtp5_pin_configs,
1839 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1840 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1841 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1842 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1843 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1844 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1845 /* for backward compatibility */
1846 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1847 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1848 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1849 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1850 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1851 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1852 [STAC_ECS_202] = ecs202_pin_configs,
1853 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1854 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1855 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1856 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1859 static const char *stac922x_models[STAC_922X_MODELS] = {
1860 [STAC_D945_REF] = "ref",
1861 [STAC_D945GTP5] = "5stack",
1862 [STAC_D945GTP3] = "3stack",
1863 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1864 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1865 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1866 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1867 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1868 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1869 /* for backward compatibility */
1870 [STAC_MACMINI] = "macmini",
1871 [STAC_MACBOOK] = "macbook",
1872 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1873 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1874 [STAC_IMAC_INTEL] = "imac-intel",
1875 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1876 [STAC_ECS_202] = "ecs202",
1877 [STAC_922X_DELL_D81] = "dell-d81",
1878 [STAC_922X_DELL_D82] = "dell-d82",
1879 [STAC_922X_DELL_M81] = "dell-m81",
1880 [STAC_922X_DELL_M82] = "dell-m82",
1883 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1884 /* SigmaTel reference board */
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1886 "DFI LanParty", STAC_D945_REF),
1887 /* Intel 945G based systems */
1888 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1889 "Intel D945G", STAC_D945GTP3),
1890 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1891 "Intel D945G", STAC_D945GTP3),
1892 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1893 "Intel D945G", STAC_D945GTP3),
1894 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1895 "Intel D945G", STAC_D945GTP3),
1896 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1897 "Intel D945G", STAC_D945GTP3),
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1899 "Intel D945G", STAC_D945GTP3),
1900 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1901 "Intel D945G", STAC_D945GTP3),
1902 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1903 "Intel D945G", STAC_D945GTP3),
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1905 "Intel D945G", STAC_D945GTP3),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1907 "Intel D945G", STAC_D945GTP3),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1909 "Intel D945G", STAC_D945GTP3),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1911 "Intel D945G", STAC_D945GTP3),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1913 "Intel D945G", STAC_D945GTP3),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1915 "Intel D945G", STAC_D945GTP3),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1917 "Intel D945G", STAC_D945GTP3),
1918 /* Intel D945G 5-stack systems */
1919 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1920 "Intel D945G", STAC_D945GTP5),
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1922 "Intel D945G", STAC_D945GTP5),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1924 "Intel D945G", STAC_D945GTP5),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1926 "Intel D945G", STAC_D945GTP5),
1927 /* Intel 945P based systems */
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1929 "Intel D945P", STAC_D945GTP3),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1931 "Intel D945P", STAC_D945GTP3),
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1933 "Intel D945P", STAC_D945GTP3),
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1935 "Intel D945P", STAC_D945GTP3),
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1937 "Intel D945P", STAC_D945GTP3),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1939 "Intel D945P", STAC_D945GTP5),
1941 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1942 SND_PCI_QUIRK(0x8384, 0x7680,
1943 "Mac", STAC_INTEL_MAC_AUTO),
1945 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1946 "unknown Dell", STAC_922X_DELL_D81),
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1948 "unknown Dell", STAC_922X_DELL_D81),
1949 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1950 "unknown Dell", STAC_922X_DELL_D81),
1951 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1952 "unknown Dell", STAC_922X_DELL_D82),
1953 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1954 "unknown Dell", STAC_922X_DELL_M81),
1955 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1956 "unknown Dell", STAC_922X_DELL_D82),
1957 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1958 "unknown Dell", STAC_922X_DELL_D81),
1959 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1960 "unknown Dell", STAC_922X_DELL_D81),
1961 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1962 "Dell XPS M1210", STAC_922X_DELL_M82),
1963 /* ECS/PC Chips boards */
1964 SND_PCI_QUIRK(0x1019, 0x2144,
1965 "ECS/PC chips", STAC_ECS_202),
1966 SND_PCI_QUIRK(0x1019, 0x2608,
1967 "ECS/PC chips", STAC_ECS_202),
1968 SND_PCI_QUIRK(0x1019, 0x2633,
1969 "ECS/PC chips P17G/1333", STAC_ECS_202),
1970 SND_PCI_QUIRK(0x1019, 0x2811,
1971 "ECS/PC chips", STAC_ECS_202),
1972 SND_PCI_QUIRK(0x1019, 0x2812,
1973 "ECS/PC chips", STAC_ECS_202),
1974 SND_PCI_QUIRK(0x1019, 0x2813,
1975 "ECS/PC chips", STAC_ECS_202),
1976 SND_PCI_QUIRK(0x1019, 0x2814,
1977 "ECS/PC chips", STAC_ECS_202),
1978 SND_PCI_QUIRK(0x1019, 0x2815,
1979 "ECS/PC chips", STAC_ECS_202),
1980 SND_PCI_QUIRK(0x1019, 0x2816,
1981 "ECS/PC chips", STAC_ECS_202),
1982 SND_PCI_QUIRK(0x1019, 0x2817,
1983 "ECS/PC chips", STAC_ECS_202),
1984 SND_PCI_QUIRK(0x1019, 0x2818,
1985 "ECS/PC chips", STAC_ECS_202),
1986 SND_PCI_QUIRK(0x1019, 0x2819,
1987 "ECS/PC chips", STAC_ECS_202),
1988 SND_PCI_QUIRK(0x1019, 0x2820,
1989 "ECS/PC chips", STAC_ECS_202),
1993 static unsigned int ref927x_pin_configs[14] = {
1994 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1995 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1996 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1997 0x01c42190, 0x40000100,
2000 static unsigned int d965_3st_pin_configs[14] = {
2001 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2002 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2003 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2004 0x40000100, 0x40000100
2007 static unsigned int d965_5st_pin_configs[14] = {
2008 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2009 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2010 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2011 0x40000100, 0x40000100
2014 static unsigned int dell_3st_pin_configs[14] = {
2015 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2016 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2017 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2018 0x40c003fc, 0x40000100
2021 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2022 [STAC_D965_REF] = ref927x_pin_configs,
2023 [STAC_D965_3ST] = d965_3st_pin_configs,
2024 [STAC_D965_5ST] = d965_5st_pin_configs,
2025 [STAC_DELL_3ST] = dell_3st_pin_configs,
2026 [STAC_DELL_BIOS] = NULL,
2029 static const char *stac927x_models[STAC_927X_MODELS] = {
2030 [STAC_D965_REF] = "ref",
2031 [STAC_D965_3ST] = "3stack",
2032 [STAC_D965_5ST] = "5stack",
2033 [STAC_DELL_3ST] = "dell-3stack",
2034 [STAC_DELL_BIOS] = "dell-bios",
2037 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2038 /* SigmaTel reference board */
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2040 "DFI LanParty", STAC_D965_REF),
2041 /* Intel 946 based systems */
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2044 /* 965 based 3 stack systems */
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
2061 /* Dell 3 stack systems */
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2066 /* Dell 3 stack systems with verb table in BIOS */
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2068 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2075 /* 965 based 5 stack systems */
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2081 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
2088 static unsigned int ref9205_pin_configs[12] = {
2089 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2090 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2091 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2095 STAC 9205 pin configs for
2102 10280228 (Dell Vostro 1500)
2104 static unsigned int dell_9205_m42_pin_configs[12] = {
2105 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2106 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2107 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2111 STAC 9205 pin configs for
2115 102801FF (Dell Precision M4300)
2120 static unsigned int dell_9205_m43_pin_configs[12] = {
2121 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2122 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2123 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2126 static unsigned int dell_9205_m44_pin_configs[12] = {
2127 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2128 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2129 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2132 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2133 [STAC_9205_REF] = ref9205_pin_configs,
2134 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2135 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2136 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2139 static const char *stac9205_models[STAC_9205_MODELS] = {
2140 [STAC_9205_REF] = "ref",
2141 [STAC_9205_DELL_M42] = "dell-m42",
2142 [STAC_9205_DELL_M43] = "dell-m43",
2143 [STAC_9205_DELL_M44] = "dell-m44",
2146 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2147 /* SigmaTel reference board */
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2149 "DFI LanParty", STAC_9205_REF),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2151 "unknown Dell", STAC_9205_DELL_M42),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2153 "unknown Dell", STAC_9205_DELL_M42),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2155 "Dell Precision", STAC_9205_DELL_M43),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2157 "Dell Precision", STAC_9205_DELL_M43),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2159 "Dell Precision", STAC_9205_DELL_M43),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2161 "unknown Dell", STAC_9205_DELL_M42),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2163 "unknown Dell", STAC_9205_DELL_M42),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2165 "Dell Precision", STAC_9205_DELL_M43),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2167 "Dell Precision M4300", STAC_9205_DELL_M43),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2169 "unknown Dell", STAC_9205_DELL_M42),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2171 "Dell Precision", STAC_9205_DELL_M43),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2173 "Dell Precision", STAC_9205_DELL_M43),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2175 "Dell Precision", STAC_9205_DELL_M43),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2177 "Dell Inspiron", STAC_9205_DELL_M44),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2179 "Dell Vostro 1500", STAC_9205_DELL_M42),
2183 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2186 struct sigmatel_spec *spec = codec->spec;
2188 if (! spec->bios_pin_configs) {
2189 spec->bios_pin_configs = kcalloc(spec->num_pins,
2190 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2191 if (! spec->bios_pin_configs)
2195 for (i = 0; i < spec->num_pins; i++) {
2196 hda_nid_t nid = spec->pin_nids[i];
2197 unsigned int pin_cfg;
2199 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2200 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2201 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2203 spec->bios_pin_configs[i] = pin_cfg;
2209 static void stac92xx_set_config_reg(struct hda_codec *codec,
2210 hda_nid_t pin_nid, unsigned int pin_config)
2213 snd_hda_codec_write(codec, pin_nid, 0,
2214 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2215 pin_config & 0x000000ff);
2216 snd_hda_codec_write(codec, pin_nid, 0,
2217 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2218 (pin_config & 0x0000ff00) >> 8);
2219 snd_hda_codec_write(codec, pin_nid, 0,
2220 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2221 (pin_config & 0x00ff0000) >> 16);
2222 snd_hda_codec_write(codec, pin_nid, 0,
2223 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2225 i = snd_hda_codec_read(codec, pin_nid, 0,
2226 AC_VERB_GET_CONFIG_DEFAULT,
2228 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2232 static void stac92xx_set_config_regs(struct hda_codec *codec)
2235 struct sigmatel_spec *spec = codec->spec;
2237 if (!spec->pin_configs)
2240 for (i = 0; i < spec->num_pins; i++)
2241 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2242 spec->pin_configs[i]);
2246 * Analog playback callbacks
2248 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2249 struct hda_codec *codec,
2250 struct snd_pcm_substream *substream)
2252 struct sigmatel_spec *spec = codec->spec;
2253 if (spec->stream_delay)
2254 msleep(spec->stream_delay);
2255 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2259 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2260 struct hda_codec *codec,
2261 unsigned int stream_tag,
2262 unsigned int format,
2263 struct snd_pcm_substream *substream)
2265 struct sigmatel_spec *spec = codec->spec;
2266 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2269 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2270 struct hda_codec *codec,
2271 struct snd_pcm_substream *substream)
2273 struct sigmatel_spec *spec = codec->spec;
2274 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2278 * Digital playback callbacks
2280 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2281 struct hda_codec *codec,
2282 struct snd_pcm_substream *substream)
2284 struct sigmatel_spec *spec = codec->spec;
2285 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2288 static int stac92xx_dig_playback_pcm_close(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_close(codec, &spec->multiout);
2296 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2297 struct hda_codec *codec,
2298 unsigned int stream_tag,
2299 unsigned int format,
2300 struct snd_pcm_substream *substream)
2302 struct sigmatel_spec *spec = codec->spec;
2303 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2304 stream_tag, format, substream);
2309 * Analog capture callbacks
2311 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2312 struct hda_codec *codec,
2313 unsigned int stream_tag,
2314 unsigned int format,
2315 struct snd_pcm_substream *substream)
2317 struct sigmatel_spec *spec = codec->spec;
2318 hda_nid_t nid = spec->adc_nids[substream->number];
2320 if (spec->powerdown_adcs) {
2322 snd_hda_codec_write_cache(codec, nid, 0,
2323 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2325 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2329 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2330 struct hda_codec *codec,
2331 struct snd_pcm_substream *substream)
2333 struct sigmatel_spec *spec = codec->spec;
2334 hda_nid_t nid = spec->adc_nids[substream->number];
2336 snd_hda_codec_cleanup_stream(codec, nid);
2337 if (spec->powerdown_adcs)
2338 snd_hda_codec_write_cache(codec, nid, 0,
2339 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2343 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2347 /* NID is set in stac92xx_build_pcms */
2349 .open = stac92xx_dig_playback_pcm_open,
2350 .close = stac92xx_dig_playback_pcm_close,
2351 .prepare = stac92xx_dig_playback_pcm_prepare
2355 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2359 /* NID is set in stac92xx_build_pcms */
2362 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2366 .nid = 0x02, /* NID to query formats and rates */
2368 .open = stac92xx_playback_pcm_open,
2369 .prepare = stac92xx_playback_pcm_prepare,
2370 .cleanup = stac92xx_playback_pcm_cleanup
2374 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2378 .nid = 0x06, /* NID to query formats and rates */
2380 .open = stac92xx_playback_pcm_open,
2381 .prepare = stac92xx_playback_pcm_prepare,
2382 .cleanup = stac92xx_playback_pcm_cleanup
2386 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2389 /* NID + .substreams is set in stac92xx_build_pcms */
2391 .prepare = stac92xx_capture_pcm_prepare,
2392 .cleanup = stac92xx_capture_pcm_cleanup
2396 static int stac92xx_build_pcms(struct hda_codec *codec)
2398 struct sigmatel_spec *spec = codec->spec;
2399 struct hda_pcm *info = spec->pcm_rec;
2401 codec->num_pcms = 1;
2402 codec->pcm_info = info;
2404 info->name = "STAC92xx Analog";
2405 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2406 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2407 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2408 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2410 if (spec->alt_switch) {
2413 info->name = "STAC92xx Analog Alt";
2414 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2417 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2420 info->name = "STAC92xx Digital";
2421 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2422 if (spec->multiout.dig_out_nid) {
2423 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2424 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2426 if (spec->dig_in_nid) {
2427 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2428 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2435 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2437 unsigned int pincap = snd_hda_param_read(codec, nid,
2439 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2440 if (pincap & AC_PINCAP_VREF_100)
2441 return AC_PINCTL_VREF_100;
2442 if (pincap & AC_PINCAP_VREF_80)
2443 return AC_PINCTL_VREF_80;
2444 if (pincap & AC_PINCAP_VREF_50)
2445 return AC_PINCTL_VREF_50;
2446 if (pincap & AC_PINCAP_VREF_GRD)
2447 return AC_PINCTL_VREF_GRD;
2451 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2454 snd_hda_codec_write_cache(codec, nid, 0,
2455 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2458 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2460 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2461 struct snd_ctl_elem_value *ucontrol)
2463 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2464 struct sigmatel_spec *spec = codec->spec;
2466 ucontrol->value.integer.value[0] = spec->hp_switch;
2470 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2471 struct snd_ctl_elem_value *ucontrol)
2473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2474 struct sigmatel_spec *spec = codec->spec;
2475 struct auto_pin_cfg *cfg = &spec->autocfg;
2476 int nid = cfg->hp_pins[cfg->hp_outs - 1];
2478 spec->hp_switch = ucontrol->value.integer.value[0];
2480 /* check to be sure that the ports are upto date with
2483 codec->patch_ops.unsol_event(codec, (STAC_HP_EVENT | nid) << 26);
2488 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2490 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2492 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2493 struct sigmatel_spec *spec = codec->spec;
2494 int io_idx = kcontrol-> private_value & 0xff;
2496 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2500 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2503 struct sigmatel_spec *spec = codec->spec;
2504 hda_nid_t nid = kcontrol->private_value >> 8;
2505 int io_idx = kcontrol-> private_value & 0xff;
2506 unsigned short val = !!ucontrol->value.integer.value[0];
2508 spec->io_switch[io_idx] = val;
2511 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2513 unsigned int pinctl = AC_PINCTL_IN_EN;
2514 if (io_idx) /* set VREF for mic */
2515 pinctl |= stac92xx_get_vref(codec, nid);
2516 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2519 /* check the auto-mute again: we need to mute/unmute the speaker
2520 * appropriately according to the pin direction
2522 if (spec->hp_detect)
2523 codec->patch_ops.unsol_event(codec,
2524 (STAC_HP_EVENT | nid) << 26);
2529 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2531 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2532 struct snd_ctl_elem_value *ucontrol)
2534 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2535 struct sigmatel_spec *spec = codec->spec;
2537 ucontrol->value.integer.value[0] = spec->clfe_swap;
2541 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2542 struct snd_ctl_elem_value *ucontrol)
2544 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2545 struct sigmatel_spec *spec = codec->spec;
2546 hda_nid_t nid = kcontrol->private_value & 0xff;
2547 unsigned int val = !!ucontrol->value.integer.value[0];
2549 if (spec->clfe_swap == val)
2552 spec->clfe_swap = val;
2554 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2555 spec->clfe_swap ? 0x4 : 0x0);
2560 #define STAC_CODEC_HP_SWITCH(xname) \
2561 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2564 .info = stac92xx_hp_switch_info, \
2565 .get = stac92xx_hp_switch_get, \
2566 .put = stac92xx_hp_switch_put, \
2569 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2570 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2573 .info = stac92xx_io_switch_info, \
2574 .get = stac92xx_io_switch_get, \
2575 .put = stac92xx_io_switch_put, \
2576 .private_value = xpval, \
2579 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2580 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2583 .info = stac92xx_clfe_switch_info, \
2584 .get = stac92xx_clfe_switch_get, \
2585 .put = stac92xx_clfe_switch_put, \
2586 .private_value = xpval, \
2590 STAC_CTL_WIDGET_VOL,
2591 STAC_CTL_WIDGET_MUTE,
2592 STAC_CTL_WIDGET_MONO_MUX,
2593 STAC_CTL_WIDGET_AMP_MUX,
2594 STAC_CTL_WIDGET_AMP_VOL,
2595 STAC_CTL_WIDGET_HP_SWITCH,
2596 STAC_CTL_WIDGET_IO_SWITCH,
2597 STAC_CTL_WIDGET_CLFE_SWITCH
2600 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2601 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2602 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2605 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2606 STAC_CODEC_HP_SWITCH(NULL),
2607 STAC_CODEC_IO_SWITCH(NULL, 0),
2608 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2611 /* add dynamic controls */
2612 static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2613 int idx, const char *name, unsigned long val)
2615 struct snd_kcontrol_new *knew;
2617 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2618 knew = snd_array_new(&spec->kctls);
2621 *knew = stac92xx_control_templates[type];
2623 knew->name = kstrdup(name, GFP_KERNEL);
2626 knew->private_value = val;
2631 /* add dynamic controls */
2632 static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2633 const char *name, unsigned long val)
2635 return stac92xx_add_control_idx(spec, type, 0, name, val);
2638 /* flag inputs as additional dynamic lineouts */
2639 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2641 struct sigmatel_spec *spec = codec->spec;
2642 unsigned int wcaps, wtype;
2643 int i, num_dacs = 0;
2645 /* use the wcaps cache to count all DACs available for line-outs */
2646 for (i = 0; i < codec->num_nodes; i++) {
2647 wcaps = codec->wcaps[i];
2648 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2650 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2654 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2656 switch (cfg->line_outs) {
2658 /* add line-in as side */
2659 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2660 cfg->line_out_pins[cfg->line_outs] =
2661 cfg->input_pins[AUTO_PIN_LINE];
2662 spec->line_switch = 1;
2667 /* add line-in as clfe and mic as side */
2668 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2669 cfg->line_out_pins[cfg->line_outs] =
2670 cfg->input_pins[AUTO_PIN_LINE];
2671 spec->line_switch = 1;
2674 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2675 cfg->line_out_pins[cfg->line_outs] =
2676 cfg->input_pins[AUTO_PIN_MIC];
2677 spec->mic_switch = 1;
2682 /* add line-in as surr and mic as clfe */
2683 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2684 cfg->line_out_pins[cfg->line_outs] =
2685 cfg->input_pins[AUTO_PIN_LINE];
2686 spec->line_switch = 1;
2689 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2690 cfg->line_out_pins[cfg->line_outs] =
2691 cfg->input_pins[AUTO_PIN_MIC];
2692 spec->mic_switch = 1;
2702 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2706 for (i = 0; i < spec->multiout.num_dacs; i++) {
2707 if (spec->multiout.dac_nids[i] == nid)
2715 * Fill in the dac_nids table from the parsed pin configuration
2716 * This function only works when every pin in line_out_pins[]
2717 * contains atleast one DAC in its connection list. Some 92xx
2718 * codecs are not connected directly to a DAC, such as the 9200
2719 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2721 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2722 struct auto_pin_cfg *cfg)
2724 struct sigmatel_spec *spec = codec->spec;
2725 int i, j, conn_len = 0;
2726 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2727 unsigned int wcaps, wtype;
2729 for (i = 0; i < cfg->line_outs; i++) {
2730 nid = cfg->line_out_pins[i];
2731 conn_len = snd_hda_get_connections(codec, nid, conn,
2732 HDA_MAX_CONNECTIONS);
2733 for (j = 0; j < conn_len; j++) {
2734 wcaps = snd_hda_param_read(codec, conn[j],
2735 AC_PAR_AUDIO_WIDGET_CAP);
2736 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2737 if (wtype != AC_WID_AUD_OUT ||
2738 (wcaps & AC_WCAP_DIGITAL))
2740 /* conn[j] is a DAC routed to this line-out */
2741 if (!is_in_dac_nids(spec, conn[j]))
2745 if (j == conn_len) {
2746 if (spec->multiout.num_dacs > 0) {
2747 /* we have already working output pins,
2748 * so let's drop the broken ones again
2750 cfg->line_outs = spec->multiout.num_dacs;
2753 /* error out, no available DAC found */
2755 "%s: No available DAC for pin 0x%x\n",
2760 spec->multiout.dac_nids[i] = conn[j];
2761 spec->multiout.num_dacs++;
2763 /* select this DAC in the pin's input mux */
2764 snd_hda_codec_write_cache(codec, nid, 0,
2765 AC_VERB_SET_CONNECT_SEL, j);
2770 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2771 spec->multiout.num_dacs,
2772 spec->multiout.dac_nids[0],
2773 spec->multiout.dac_nids[1],
2774 spec->multiout.dac_nids[2],
2775 spec->multiout.dac_nids[3],
2776 spec->multiout.dac_nids[4]);
2780 /* create volume control/switch for the given prefx type */
2781 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2786 sprintf(name, "%s Playback Volume", pfx);
2787 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2788 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2791 sprintf(name, "%s Playback Switch", pfx);
2792 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2793 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2799 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2801 if (!spec->multiout.hp_nid)
2802 spec->multiout.hp_nid = nid;
2803 else if (spec->multiout.num_dacs > 4) {
2804 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2807 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2808 spec->multiout.num_dacs++;
2813 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2815 if (is_in_dac_nids(spec, nid))
2817 if (spec->multiout.hp_nid == nid)
2822 /* add playback controls from the parsed DAC table */
2823 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2824 const struct auto_pin_cfg *cfg)
2826 static const char *chname[4] = {
2827 "Front", "Surround", NULL /*CLFE*/, "Side"
2832 struct sigmatel_spec *spec = codec->spec;
2833 unsigned int wid_caps, pincap;
2836 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2837 if (!spec->multiout.dac_nids[i])
2840 nid = spec->multiout.dac_nids[i];
2844 err = create_controls(spec, "Center", nid, 1);
2847 err = create_controls(spec, "LFE", nid, 2);
2851 wid_caps = get_wcaps(codec, nid);
2853 if (wid_caps & AC_WCAP_LR_SWAP) {
2854 err = stac92xx_add_control(spec,
2855 STAC_CTL_WIDGET_CLFE_SWITCH,
2856 "Swap Center/LFE Playback Switch", nid);
2863 err = create_controls(spec, chname[i], nid, 3);
2869 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2870 cfg->hp_outs && !spec->multiout.hp_nid)
2871 spec->multiout.hp_nid = nid;
2873 if (cfg->hp_outs > 1) {
2874 err = stac92xx_add_control(spec,
2875 STAC_CTL_WIDGET_HP_SWITCH,
2876 "Headphone as Line Out Switch", 0);
2881 if (spec->line_switch) {
2882 nid = cfg->input_pins[AUTO_PIN_LINE];
2883 pincap = snd_hda_param_read(codec, nid,
2885 if (pincap & AC_PINCAP_OUT) {
2886 err = stac92xx_add_control(spec,
2887 STAC_CTL_WIDGET_IO_SWITCH,
2888 "Line In as Output Switch", nid << 8);
2894 if (spec->mic_switch) {
2895 unsigned int def_conf;
2896 unsigned int mic_pin = AUTO_PIN_MIC;
2898 nid = cfg->input_pins[mic_pin];
2899 def_conf = snd_hda_codec_read(codec, nid, 0,
2900 AC_VERB_GET_CONFIG_DEFAULT, 0);
2901 /* some laptops have an internal analog microphone
2902 * which can't be used as a output */
2903 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2904 pincap = snd_hda_param_read(codec, nid,
2906 if (pincap & AC_PINCAP_OUT) {
2907 err = stac92xx_add_control(spec,
2908 STAC_CTL_WIDGET_IO_SWITCH,
2909 "Mic as Output Switch", (nid << 8) | 1);
2910 nid = snd_hda_codec_read(codec, nid, 0,
2911 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2912 if (!check_in_dac_nids(spec, nid))
2913 add_spec_dacs(spec, nid);
2917 } else if (mic_pin == AUTO_PIN_MIC) {
2918 mic_pin = AUTO_PIN_FRONT_MIC;
2926 /* add playback controls for Speaker and HP outputs */
2927 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2928 struct auto_pin_cfg *cfg)
2930 struct sigmatel_spec *spec = codec->spec;
2932 int i, old_num_dacs, err;
2934 old_num_dacs = spec->multiout.num_dacs;
2935 for (i = 0; i < cfg->hp_outs; i++) {
2936 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2937 if (wid_caps & AC_WCAP_UNSOL_CAP)
2938 spec->hp_detect = 1;
2939 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2940 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2941 if (check_in_dac_nids(spec, nid))
2945 add_spec_dacs(spec, nid);
2947 for (i = 0; i < cfg->speaker_outs; i++) {
2948 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2949 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2950 if (check_in_dac_nids(spec, nid))
2954 add_spec_dacs(spec, nid);
2956 for (i = 0; i < cfg->line_outs; i++) {
2957 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2958 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2959 if (check_in_dac_nids(spec, nid))
2963 add_spec_dacs(spec, nid);
2965 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2966 static const char *pfxs[] = {
2967 "Speaker", "External Speaker", "Speaker2",
2969 err = create_controls(spec, pfxs[i - old_num_dacs],
2970 spec->multiout.dac_nids[i], 3);
2974 if (spec->multiout.hp_nid) {
2975 err = create_controls(spec, "Headphone",
2976 spec->multiout.hp_nid, 3);
2984 /* labels for mono mux outputs */
2985 static const char *stac92xx_mono_labels[4] = {
2986 "DAC0", "DAC1", "Mixer", "DAC2"
2989 /* create mono mux for mono out on capable codecs */
2990 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2992 struct sigmatel_spec *spec = codec->spec;
2993 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2995 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2997 num_cons = snd_hda_get_connections(codec,
3000 HDA_MAX_NUM_INPUTS);
3001 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3004 for (i = 0; i < num_cons; i++) {
3005 mono_mux->items[mono_mux->num_items].label =
3006 stac92xx_mono_labels[i];
3007 mono_mux->items[mono_mux->num_items].index = i;
3008 mono_mux->num_items++;
3011 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3012 "Mono Mux", spec->mono_nid);
3015 /* labels for amp mux outputs */
3016 static const char *stac92xx_amp_labels[3] = {
3017 "Front Microphone", "Microphone", "Line In",
3020 /* create amp out controls mux on capable codecs */
3021 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3023 struct sigmatel_spec *spec = codec->spec;
3024 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3027 for (i = 0; i < spec->num_amps; i++) {
3028 amp_mux->items[amp_mux->num_items].label =
3029 stac92xx_amp_labels[i];
3030 amp_mux->items[amp_mux->num_items].index = i;
3031 amp_mux->num_items++;
3034 if (spec->num_amps > 1) {
3035 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3036 "Amp Selector Capture Switch", 0);
3040 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3041 "Amp Capture Volume",
3042 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3046 /* create PC beep volume controls */
3047 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3050 struct sigmatel_spec *spec = codec->spec;
3051 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3054 /* check for mute support for the the amp */
3055 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3056 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3057 "PC Beep Playback Switch",
3058 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3063 /* check to see if there is volume support for the amp */
3064 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3065 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3066 "PC Beep Playback Volume",
3067 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3074 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3076 struct sigmatel_spec *spec = codec->spec;
3077 int wcaps, nid, i, err = 0;
3079 for (i = 0; i < spec->num_muxes; i++) {
3080 nid = spec->mux_nids[i];
3081 wcaps = get_wcaps(codec, nid);
3083 if (wcaps & AC_WCAP_OUT_AMP) {
3084 err = stac92xx_add_control_idx(spec,
3085 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3086 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3094 static const char *stac92xx_spdif_labels[3] = {
3095 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3098 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3100 struct sigmatel_spec *spec = codec->spec;
3101 struct hda_input_mux *spdif_mux = &spec->private_smux;
3102 const char **labels = spec->spdif_labels;
3104 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3106 num_cons = snd_hda_get_connections(codec,
3109 HDA_MAX_NUM_INPUTS);
3114 labels = stac92xx_spdif_labels;
3116 for (i = 0; i < num_cons; i++) {
3117 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3118 spdif_mux->items[spdif_mux->num_items].index = i;
3119 spdif_mux->num_items++;
3125 /* labels for dmic mux inputs */
3126 static const char *stac92xx_dmic_labels[5] = {
3127 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3128 "Digital Mic 3", "Digital Mic 4"
3131 /* create playback/capture controls for input pins on dmic capable codecs */
3132 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3133 const struct auto_pin_cfg *cfg)
3135 struct sigmatel_spec *spec = codec->spec;
3136 struct hda_input_mux *dimux = &spec->private_dimux;
3137 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3141 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3142 dimux->items[dimux->num_items].index = 0;
3145 for (i = 0; i < spec->num_dmics; i++) {
3150 unsigned int def_conf;
3152 def_conf = snd_hda_codec_read(codec,
3155 AC_VERB_GET_CONFIG_DEFAULT,
3157 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3160 nid = spec->dmic_nids[i];
3161 num_cons = snd_hda_get_connections(codec,
3164 HDA_MAX_NUM_INPUTS);
3165 for (j = 0; j < num_cons; j++)
3166 if (con_lst[j] == nid) {
3172 wcaps = get_wcaps(codec, nid) &
3173 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3176 sprintf(name, "%s Capture Volume",
3177 stac92xx_dmic_labels[dimux->num_items]);
3179 err = stac92xx_add_control(spec,
3180 STAC_CTL_WIDGET_VOL,
3182 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3183 (wcaps & AC_WCAP_OUT_AMP) ?
3184 HDA_OUTPUT : HDA_INPUT));
3189 dimux->items[dimux->num_items].label =
3190 stac92xx_dmic_labels[dimux->num_items];
3191 dimux->items[dimux->num_items].index = index;
3198 /* create playback/capture controls for input pins */
3199 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3201 struct sigmatel_spec *spec = codec->spec;
3202 struct hda_input_mux *imux = &spec->private_imux;
3203 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3206 for (i = 0; i < AUTO_PIN_LAST; i++) {
3209 if (!cfg->input_pins[i])
3212 for (j = 0; j < spec->num_muxes; j++) {
3214 num_cons = snd_hda_get_connections(codec,
3217 HDA_MAX_NUM_INPUTS);
3218 for (k = 0; k < num_cons; k++)
3219 if (con_lst[k] == cfg->input_pins[i]) {
3226 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3227 imux->items[imux->num_items].index = index;
3231 if (imux->num_items) {
3233 * Set the current input for the muxes.
3234 * The STAC9221 has two input muxes with identical source
3235 * NID lists. Hopefully this won't get confused.
3237 for (i = 0; i < spec->num_muxes; i++) {
3238 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3239 AC_VERB_SET_CONNECT_SEL,
3240 imux->items[0].index);
3247 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3249 struct sigmatel_spec *spec = codec->spec;
3252 for (i = 0; i < spec->autocfg.line_outs; i++) {
3253 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3254 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3258 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3260 struct sigmatel_spec *spec = codec->spec;
3263 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3265 pin = spec->autocfg.hp_pins[i];
3266 if (pin) /* connect to front */
3267 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3269 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3271 pin = spec->autocfg.speaker_pins[i];
3272 if (pin) /* connect to front */
3273 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3277 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3279 struct sigmatel_spec *spec = codec->spec;
3281 int hp_speaker_swap = 0;
3283 if ((err = snd_hda_parse_pin_def_config(codec,
3285 spec->dmic_nids)) < 0)
3287 if (! spec->autocfg.line_outs)
3288 return 0; /* can't find valid pin config */
3290 /* If we have no real line-out pin and multiple hp-outs, HPs should
3291 * be set up as multi-channel outputs.
3293 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3294 spec->autocfg.hp_outs > 1) {
3295 /* Copy hp_outs to line_outs, backup line_outs in
3296 * speaker_outs so that the following routines can handle
3297 * HP pins as primary outputs.
3299 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3300 sizeof(spec->autocfg.line_out_pins));
3301 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3302 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3303 sizeof(spec->autocfg.hp_pins));
3304 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3305 hp_speaker_swap = 1;
3307 if (spec->autocfg.mono_out_pin) {
3308 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3309 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3310 u32 caps = query_amp_caps(codec,
3311 spec->autocfg.mono_out_pin, dir);
3312 hda_nid_t conn_list[1];
3314 /* get the mixer node and then the mono mux if it exists */
3315 if (snd_hda_get_connections(codec,
3316 spec->autocfg.mono_out_pin, conn_list, 1) &&
3317 snd_hda_get_connections(codec, conn_list[0],
3320 int wcaps = get_wcaps(codec, conn_list[0]);
3321 int wid_type = (wcaps & AC_WCAP_TYPE)
3322 >> AC_WCAP_TYPE_SHIFT;
3323 /* LR swap check, some stac925x have a mux that
3324 * changes the DACs output path instead of the
3327 if (wid_type == AC_WID_AUD_SEL &&
3328 !(wcaps & AC_WCAP_LR_SWAP))
3329 spec->mono_nid = conn_list[0];
3332 hda_nid_t nid = spec->autocfg.mono_out_pin;
3334 /* most mono outs have a least a mute/unmute switch */
3335 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3336 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3337 "Mono Playback Switch",
3338 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3341 /* check for volume support for the amp */
3342 if ((caps & AC_AMPCAP_NUM_STEPS)
3343 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3344 err = stac92xx_add_control(spec,
3345 STAC_CTL_WIDGET_VOL,
3346 "Mono Playback Volume",
3347 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3353 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3357 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3359 if (spec->multiout.num_dacs == 0)
3360 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3363 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3368 /* setup analog beep controls */
3369 if (spec->anabeep_nid > 0) {
3370 err = stac92xx_auto_create_beep_ctls(codec,
3376 /* setup digital beep controls and input device */
3377 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3378 if (spec->digbeep_nid > 0) {
3379 hda_nid_t nid = spec->digbeep_nid;
3381 err = stac92xx_auto_create_beep_ctls(codec, nid);
3384 err = snd_hda_attach_beep_device(codec, nid);
3390 if (hp_speaker_swap == 1) {
3391 /* Restore the hp_outs and line_outs */
3392 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3393 sizeof(spec->autocfg.line_out_pins));
3394 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3395 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3396 sizeof(spec->autocfg.speaker_pins));
3397 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3398 memset(spec->autocfg.speaker_pins, 0,
3399 sizeof(spec->autocfg.speaker_pins));
3400 spec->autocfg.speaker_outs = 0;
3403 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3408 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3413 if (spec->mono_nid > 0) {
3414 err = stac92xx_auto_create_mono_output_ctls(codec);
3418 if (spec->num_amps > 0) {
3419 err = stac92xx_auto_create_amp_output_ctls(codec);
3423 if (spec->num_dmics > 0 && !spec->dinput_mux)
3424 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3425 &spec->autocfg)) < 0)
3427 if (spec->num_muxes > 0) {
3428 err = stac92xx_auto_create_mux_input_ctls(codec);
3432 if (spec->num_smuxes > 0) {
3433 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3438 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3439 if (spec->multiout.max_channels > 2)
3440 spec->surr_switch = 1;
3442 if (spec->autocfg.dig_out_pin)
3443 spec->multiout.dig_out_nid = dig_out;
3444 if (dig_in && spec->autocfg.dig_in_pin)
3445 spec->dig_in_nid = dig_in;
3447 if (spec->kctls.list)
3448 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3450 spec->input_mux = &spec->private_imux;
3451 spec->dinput_mux = &spec->private_dimux;
3452 spec->sinput_mux = &spec->private_smux;
3453 spec->mono_mux = &spec->private_mono_mux;
3454 spec->amp_mux = &spec->private_amp_mux;
3458 /* add playback controls for HP output */
3459 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3460 struct auto_pin_cfg *cfg)
3462 struct sigmatel_spec *spec = codec->spec;
3463 hda_nid_t pin = cfg->hp_pins[0];
3464 unsigned int wid_caps;
3469 wid_caps = get_wcaps(codec, pin);
3470 if (wid_caps & AC_WCAP_UNSOL_CAP)
3471 spec->hp_detect = 1;
3476 /* add playback controls for LFE output */
3477 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3478 struct auto_pin_cfg *cfg)
3480 struct sigmatel_spec *spec = codec->spec;
3482 hda_nid_t lfe_pin = 0x0;
3486 * search speaker outs and line outs for a mono speaker pin
3487 * with an amp. If one is found, add LFE controls
3490 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3491 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3492 unsigned int wcaps = get_wcaps(codec, pin);
3493 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3494 if (wcaps == AC_WCAP_OUT_AMP)
3495 /* found a mono speaker with an amp, must be lfe */
3499 /* if speaker_outs is 0, then speakers may be in line_outs */
3500 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3501 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3502 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3503 unsigned int defcfg;
3504 defcfg = snd_hda_codec_read(codec, pin, 0,
3505 AC_VERB_GET_CONFIG_DEFAULT,
3507 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3508 unsigned int wcaps = get_wcaps(codec, pin);
3509 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3510 if (wcaps == AC_WCAP_OUT_AMP)
3511 /* found a mono speaker with an amp,
3519 err = create_controls(spec, "LFE", lfe_pin, 1);
3527 static int stac9200_parse_auto_config(struct hda_codec *codec)
3529 struct sigmatel_spec *spec = codec->spec;
3532 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3535 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3538 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3541 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3544 if (spec->autocfg.dig_out_pin)
3545 spec->multiout.dig_out_nid = 0x05;
3546 if (spec->autocfg.dig_in_pin)
3547 spec->dig_in_nid = 0x04;
3549 if (spec->kctls.list)
3550 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3552 spec->input_mux = &spec->private_imux;
3553 spec->dinput_mux = &spec->private_dimux;
3559 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3560 * funky external mute control using GPIO pins.
3563 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3564 unsigned int dir_mask, unsigned int data)
3566 unsigned int gpiostate, gpiomask, gpiodir;
3568 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3569 AC_VERB_GET_GPIO_DATA, 0);
3570 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3572 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3573 AC_VERB_GET_GPIO_MASK, 0);
3576 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3577 AC_VERB_GET_GPIO_DIRECTION, 0);
3578 gpiodir |= dir_mask;
3580 /* Configure GPIOx as CMOS */
3581 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3583 snd_hda_codec_write(codec, codec->afg, 0,
3584 AC_VERB_SET_GPIO_MASK, gpiomask);
3585 snd_hda_codec_read(codec, codec->afg, 0,
3586 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3590 snd_hda_codec_read(codec, codec->afg, 0,
3591 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3594 static int stac92xx_add_jack(struct hda_codec *codec,
3595 hda_nid_t nid, int type)
3597 struct sigmatel_spec *spec = codec->spec;
3598 struct sigmatel_jack *jack;
3599 int def_conf = snd_hda_codec_read(codec, nid,
3600 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3601 int connectivity = get_defcfg_connect(def_conf);
3604 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3607 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3608 jack = snd_array_new(&spec->jacks);
3614 sprintf(name, "%s at %s %s Jack",
3615 snd_hda_get_jack_type(def_conf),
3616 snd_hda_get_jack_connectivity(def_conf),
3617 snd_hda_get_jack_location(def_conf));
3619 return snd_jack_new(codec->bus->card, name, type, &jack->jack);
3622 static int stac92xx_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3625 struct sigmatel_event *event;
3627 snd_array_init(&spec->events, sizeof(*event), 32);
3628 event = snd_array_new(&spec->events);
3637 static int stac92xx_event_data(struct hda_codec *codec, hda_nid_t nid)
3639 struct sigmatel_spec *spec = codec->spec;
3640 struct sigmatel_event *events = spec->events.list;
3643 for (i = 0; i < spec->events.used; i++)
3644 if (events[i].nid == nid)
3645 return events[i].data;
3650 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3653 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
3654 snd_hda_codec_write_cache(codec, nid, 0,
3655 AC_VERB_SET_UNSOLICITED_ENABLE,
3656 (AC_USRSP_EN | event | nid));
3660 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3663 for (i = 0; i < cfg->hp_outs; i++)
3664 if (cfg->hp_pins[i] == nid)
3665 return 1; /* nid is a HP-Out */
3667 return 0; /* nid is not a HP-Out */
3670 static void stac92xx_power_down(struct hda_codec *codec)
3672 struct sigmatel_spec *spec = codec->spec;
3674 /* power down inactive DACs */
3676 for (dac = spec->dac_list; *dac; dac++)
3677 if (!is_in_dac_nids(spec, *dac) &&
3678 spec->multiout.hp_nid != *dac)
3679 snd_hda_codec_write_cache(codec, *dac, 0,
3680 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3683 static int stac92xx_init(struct hda_codec *codec)
3685 struct sigmatel_spec *spec = codec->spec;
3686 struct auto_pin_cfg *cfg = &spec->autocfg;
3689 snd_hda_sequence_write(codec, spec->init);
3691 /* power down adcs initially */
3692 if (spec->powerdown_adcs)
3693 for (i = 0; i < spec->num_adcs; i++)
3694 snd_hda_codec_write_cache(codec,
3695 spec->adc_nids[i], 0,
3696 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3698 if (spec->hp_detect) {
3699 /* Enable unsolicited responses on the HP widget */
3700 for (i = 0; i < cfg->hp_outs; i++) {
3701 int type = SND_JACK_HEADPHONE;
3702 hda_nid_t nid = cfg->hp_pins[i];
3703 enable_pin_detect(codec, nid, STAC_HP_EVENT | nid);
3704 /* jack detection */
3705 if (cfg->hp_outs == i)
3706 type |= SND_JACK_LINEOUT;
3707 err = stac92xx_add_jack(codec, nid, type);
3712 /* force to enable the first line-out; the others are set up
3715 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3717 /* fake event to set up pins */
3718 codec->patch_ops.unsol_event(codec,
3719 (STAC_HP_EVENT | spec->autocfg.hp_pins[0]) << 26);
3721 stac92xx_auto_init_multi_out(codec);
3722 stac92xx_auto_init_hp_out(codec);
3724 for (i = 0; i < cfg->line_outs; i++) {
3725 err = stac92xx_add_jack(codec,
3726 cfg->line_out_pins[i], SND_JACK_LINEOUT);
3730 for (i = 0; i < AUTO_PIN_LAST; i++) {
3731 hda_nid_t nid = cfg->input_pins[i];
3733 unsigned int pinctl = snd_hda_codec_read(codec, nid,
3734 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3735 /* if PINCTL already set then skip */
3736 if (pinctl & AC_PINCAP_IN)
3738 pinctl = AC_PINCTL_IN_EN;
3739 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3740 pinctl |= stac92xx_get_vref(codec, nid);
3741 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3742 err = stac92xx_add_jack(codec, nid,
3743 SND_JACK_MICROPHONE);
3746 enable_pin_detect(codec, nid, STAC_INSERT_EVENT | nid);
3749 for (i = 0; i < spec->num_dmics; i++)
3750 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3752 for (i = 0; i < spec->num_pwrs; i++) {
3753 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3754 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3755 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3756 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3757 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3758 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3759 def_conf = get_defcfg_connect(def_conf);
3760 /* outputs are only ports capable of power management
3761 * any attempts on powering down a input port cause the
3762 * referenced VREF to act quirky.
3764 if (pinctl & AC_PINCTL_IN_EN)
3766 /* skip any ports that don't have jacks since presence
3767 * detection is useless */
3768 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
3770 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3771 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3774 stac92xx_power_down(codec);
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,
3782 stac_gpio_set(codec, spec->gpio_mask,
3783 spec->gpio_dir, spec->gpio_data);
3788 static void stac92xx_free_jacks(struct hda_codec *codec)
3790 struct sigmatel_spec *spec = codec->spec;
3791 if (spec->jacks.list) {
3792 struct sigmatel_jack *jacks = spec->jacks.list;
3794 for (i = 0; i < spec->jacks.used; i++)
3795 snd_device_free(codec->bus->card, &jacks[i].jack);
3797 snd_array_free(&spec->jacks);
3800 static void stac92xx_free_kctls(struct hda_codec *codec)
3802 struct sigmatel_spec *spec = codec->spec;
3804 if (spec->kctls.list) {
3805 struct snd_kcontrol_new *kctl = spec->kctls.list;
3807 for (i = 0; i < spec->kctls.used; i++)
3808 kfree(kctl[i].name);
3810 snd_array_free(&spec->kctls);
3813 static void stac92xx_free(struct hda_codec *codec)
3815 struct sigmatel_spec *spec = codec->spec;
3820 if (spec->bios_pin_configs)
3821 kfree(spec->bios_pin_configs);
3822 stac92xx_free_jacks(codec);
3823 snd_array_free(&spec->events);
3826 snd_hda_detach_beep_device(codec);
3829 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3832 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3833 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3835 if (pin_ctl & AC_PINCTL_IN_EN) {
3837 * we need to check the current set-up direction of
3838 * shared input pins since they can be switched via
3839 * "xxx as Output" mixer switch
3841 struct sigmatel_spec *spec = codec->spec;
3842 struct auto_pin_cfg *cfg = &spec->autocfg;
3843 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3844 spec->line_switch) ||
3845 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3850 /* if setting pin direction bits, clear the current
3851 direction bits first */
3852 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3853 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3855 snd_hda_codec_write_cache(codec, nid, 0,
3856 AC_VERB_SET_PIN_WIDGET_CONTROL,
3860 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3863 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3864 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3865 snd_hda_codec_write_cache(codec, nid, 0,
3866 AC_VERB_SET_PIN_WIDGET_CONTROL,
3870 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3874 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3876 unsigned int pinctl;
3877 pinctl = snd_hda_codec_read(codec, nid, 0,
3878 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3879 if (pinctl & AC_PINCTL_IN_EN)
3880 return 0; /* mic- or line-input */
3882 return 1; /* HP-output */
3887 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3889 struct sigmatel_spec *spec = codec->spec;
3890 struct auto_pin_cfg *cfg = &spec->autocfg;
3891 int nid = cfg->hp_pins[cfg->hp_outs - 1];
3895 if (spec->gpio_mute)
3896 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3897 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3899 for (i = 0; i < cfg->hp_outs; i++) {
3902 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3904 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3908 /* disable lineouts, enable hp */
3909 if (spec->hp_switch)
3910 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3911 for (i = 0; i < cfg->line_outs; i++)
3912 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3914 for (i = 0; i < cfg->speaker_outs; i++)
3915 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3917 if (spec->eapd_mask)
3918 stac_gpio_set(codec, spec->gpio_mask,
3919 spec->gpio_dir, spec->gpio_data &
3922 /* enable lineouts, disable hp */
3923 if (spec->hp_switch)
3924 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3925 for (i = 0; i < cfg->line_outs; i++)
3926 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3928 for (i = 0; i < cfg->speaker_outs; i++)
3929 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3931 if (spec->eapd_mask)
3932 stac_gpio_set(codec, spec->gpio_mask,
3933 spec->gpio_dir, spec->gpio_data |
3936 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3937 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3940 static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3942 struct sigmatel_spec *spec = codec->spec;
3943 hda_nid_t nid = spec->pwr_nids[idx];
3945 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3947 presence = get_hp_pin_presence(codec, nid);
3949 /* several codecs have two power down bits */
3950 if (spec->pwr_mapping)
3951 idx = spec->pwr_mapping[idx];
3960 /* power down unused output ports */
3961 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3964 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
3966 struct sigmatel_spec *spec = codec->spec;
3967 struct sigmatel_jack *jacks = spec->jacks.list;
3971 for (i = 0; i < spec->jacks.used; i++) {
3972 if (jacks->nid == nid) {
3973 unsigned int pin_ctl =
3974 snd_hda_codec_read(codec, nid,
3975 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
3977 int type = jacks->type;
3978 if (type == (SND_JACK_LINEOUT
3979 | SND_JACK_HEADPHONE))
3980 type = (pin_ctl & AC_PINCTL_HP_EN)
3981 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
3982 snd_jack_report(jacks->jack,
3983 get_hp_pin_presence(codec, nid)
3991 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3993 struct sigmatel_spec *spec = codec->spec;
3994 int event = (res >> 26) & 0x70;
3995 int nid = res >> 26 & 0x0f;
3999 stac92xx_hp_detect(codec, res);
4001 case STAC_INSERT_EVENT:
4002 case STAC_PWR_EVENT:
4004 if (spec->num_pwrs > 0)
4005 stac92xx_pin_sense(codec, nid);
4006 stac92xx_report_jack(codec, nid);
4009 case STAC_VREF_EVENT: {
4010 int data = snd_hda_codec_read(codec, codec->afg, 0,
4011 AC_VERB_GET_GPIO_DATA, 0);
4012 int idx = stac92xx_event_data(codec, nid);
4013 /* toggle VREF state based on GPIOx status */
4014 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4015 !!(data & (1 << idx)));
4021 #ifdef SND_HDA_NEEDS_RESUME
4022 static int stac92xx_resume(struct hda_codec *codec)
4024 struct sigmatel_spec *spec = codec->spec;
4026 stac92xx_set_config_regs(codec);
4027 snd_hda_sequence_write(codec, spec->init);
4028 stac_gpio_set(codec, spec->gpio_mask,
4029 spec->gpio_dir, spec->gpio_data);
4030 snd_hda_codec_resume_amp(codec);
4031 snd_hda_codec_resume_cache(codec);
4032 /* power down inactive DACs */
4034 stac92xx_power_down(codec);
4035 /* invoke unsolicited event to reset the HP state */
4036 if (spec->hp_detect)
4037 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4042 static struct hda_codec_ops stac92xx_patch_ops = {
4043 .build_controls = stac92xx_build_controls,
4044 .build_pcms = stac92xx_build_pcms,
4045 .init = stac92xx_init,
4046 .free = stac92xx_free,
4047 .unsol_event = stac92xx_unsol_event,
4048 #ifdef SND_HDA_NEEDS_RESUME
4049 .resume = stac92xx_resume,
4053 static int patch_stac9200(struct hda_codec *codec)
4055 struct sigmatel_spec *spec;
4058 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4063 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4064 spec->pin_nids = stac9200_pin_nids;
4065 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4068 if (spec->board_config < 0) {
4069 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4070 err = stac92xx_save_bios_config_regs(codec);
4072 stac92xx_free(codec);
4075 spec->pin_configs = spec->bios_pin_configs;
4077 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4078 stac92xx_set_config_regs(codec);
4081 spec->multiout.max_channels = 2;
4082 spec->multiout.num_dacs = 1;
4083 spec->multiout.dac_nids = stac9200_dac_nids;
4084 spec->adc_nids = stac9200_adc_nids;
4085 spec->mux_nids = stac9200_mux_nids;
4086 spec->num_muxes = 1;
4087 spec->num_dmics = 0;
4091 if (spec->board_config == STAC_9200_GATEWAY ||
4092 spec->board_config == STAC_9200_OQO)
4093 spec->init = stac9200_eapd_init;
4095 spec->init = stac9200_core_init;
4096 spec->mixer = stac9200_mixer;
4098 if (spec->board_config == STAC_9200_PANASONIC) {
4099 spec->gpio_mask = spec->gpio_dir = 0x09;
4100 spec->gpio_data = 0x00;
4103 err = stac9200_parse_auto_config(codec);
4105 stac92xx_free(codec);
4109 codec->patch_ops = stac92xx_patch_ops;
4114 static int patch_stac925x(struct hda_codec *codec)
4116 struct sigmatel_spec *spec;
4119 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4124 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4125 spec->pin_nids = stac925x_pin_nids;
4126 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4130 if (spec->board_config < 0) {
4131 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4132 "using BIOS defaults\n");
4133 err = stac92xx_save_bios_config_regs(codec);
4135 stac92xx_free(codec);
4138 spec->pin_configs = spec->bios_pin_configs;
4139 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4140 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4141 stac92xx_set_config_regs(codec);
4144 spec->multiout.max_channels = 2;
4145 spec->multiout.num_dacs = 1;
4146 spec->multiout.dac_nids = stac925x_dac_nids;
4147 spec->adc_nids = stac925x_adc_nids;
4148 spec->mux_nids = stac925x_mux_nids;
4149 spec->num_muxes = 1;
4152 switch (codec->vendor_id) {
4153 case 0x83847632: /* STAC9202 */
4154 case 0x83847633: /* STAC9202D */
4155 case 0x83847636: /* STAC9251 */
4156 case 0x83847637: /* STAC9251D */
4157 spec->num_dmics = STAC925X_NUM_DMICS;
4158 spec->dmic_nids = stac925x_dmic_nids;
4159 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4160 spec->dmux_nids = stac925x_dmux_nids;
4163 spec->num_dmics = 0;
4167 spec->init = stac925x_core_init;
4168 spec->mixer = stac925x_mixer;
4170 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4172 if (spec->board_config < 0) {
4173 printk(KERN_WARNING "hda_codec: No auto-config is "
4174 "available, default to model=ref\n");
4175 spec->board_config = STAC_925x_REF;
4181 stac92xx_free(codec);
4185 codec->patch_ops = stac92xx_patch_ops;
4190 static struct hda_input_mux stac92hd73xx_dmux = {
4193 { "Analog Inputs", 0x0b },
4194 { "Digital Mic 1", 0x09 },
4195 { "Digital Mic 2", 0x0a },
4200 static int patch_stac92hd73xx(struct hda_codec *codec)
4202 struct sigmatel_spec *spec;
4203 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4206 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4211 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4212 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4213 spec->pin_nids = stac92hd73xx_pin_nids;
4214 spec->board_config = snd_hda_check_board_config(codec,
4215 STAC_92HD73XX_MODELS,
4216 stac92hd73xx_models,
4217 stac92hd73xx_cfg_tbl);
4219 if (spec->board_config < 0) {
4220 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4221 " STAC92HD73XX, using BIOS defaults\n");
4222 err = stac92xx_save_bios_config_regs(codec);
4224 stac92xx_free(codec);
4227 spec->pin_configs = spec->bios_pin_configs;
4229 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4230 stac92xx_set_config_regs(codec);
4233 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4234 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4236 if (spec->multiout.num_dacs < 0) {
4237 printk(KERN_WARNING "hda_codec: Could not determine "
4238 "number of channels defaulting to DAC count\n");
4239 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4242 switch (spec->multiout.num_dacs) {
4243 case 0x3: /* 6 Channel */
4244 spec->mixer = stac92hd73xx_6ch_mixer;
4245 spec->init = stac92hd73xx_6ch_core_init;
4247 case 0x4: /* 8 Channel */
4248 spec->mixer = stac92hd73xx_8ch_mixer;
4249 spec->init = stac92hd73xx_8ch_core_init;
4251 case 0x5: /* 10 Channel */
4252 spec->mixer = stac92hd73xx_10ch_mixer;
4253 spec->init = stac92hd73xx_10ch_core_init;
4256 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4257 spec->aloopback_mask = 0x01;
4258 spec->aloopback_shift = 8;
4260 spec->digbeep_nid = 0x1c;
4261 spec->mux_nids = stac92hd73xx_mux_nids;
4262 spec->adc_nids = stac92hd73xx_adc_nids;
4263 spec->dmic_nids = stac92hd73xx_dmic_nids;
4264 spec->dmux_nids = stac92hd73xx_dmux_nids;
4265 spec->smux_nids = stac92hd73xx_smux_nids;
4266 spec->amp_nids = stac92hd73xx_amp_nids;
4267 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4269 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4270 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4271 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4272 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4273 sizeof(stac92hd73xx_dmux));
4275 switch (spec->board_config) {
4277 spec->init = dell_eq_core_init;
4280 spec->num_smuxes = 0;
4281 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4282 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4286 spec->init = dell_m6_core_init;
4287 switch (codec->subsystem_id) {
4288 case 0x1028025e: /* Analog Mics */
4290 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4291 spec->num_dmics = 0;
4292 spec->private_dimux.num_items = 1;
4294 case 0x10280271: /* Digital Mics */
4298 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4299 spec->num_dmics = 1;
4300 spec->private_dimux.num_items = 2;
4302 case 0x10280256: /* Both */
4304 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4305 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4306 spec->num_dmics = 1;
4307 spec->private_dimux.num_items = 2;
4312 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4313 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4315 if (spec->board_config > STAC_92HD73XX_REF) {
4316 /* GPIO0 High = Enable EAPD */
4317 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4318 spec->gpio_data = 0x01;
4320 spec->dinput_mux = &spec->private_dimux;
4322 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4323 spec->pwr_nids = stac92hd73xx_pwr_nids;
4325 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
4328 if (spec->board_config < 0) {
4329 printk(KERN_WARNING "hda_codec: No auto-config is "
4330 "available, default to model=ref\n");
4331 spec->board_config = STAC_92HD73XX_REF;
4338 stac92xx_free(codec);
4342 codec->patch_ops = stac92xx_patch_ops;
4347 static struct hda_input_mux stac92hd83xxx_dmux = {
4350 { "Analog Inputs", 0x03 },
4351 { "Digital Mic 1", 0x04 },
4352 { "Digital Mic 2", 0x05 },
4356 static int patch_stac92hd83xxx(struct hda_codec *codec)
4358 struct sigmatel_spec *spec;
4361 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4366 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
4367 spec->mono_nid = 0x19;
4368 spec->digbeep_nid = 0x21;
4369 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4370 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4371 spec->adc_nids = stac92hd83xxx_adc_nids;
4372 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4373 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4374 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4375 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4377 spec->init = stac92hd83xxx_core_init;
4378 switch (codec->vendor_id) {
4380 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4384 spec->init++; /* switch to config #2 */
4385 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4388 spec->mixer = stac92hd83xxx_mixer;
4389 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4390 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4391 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4392 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4393 spec->dinput_mux = &stac92hd83xxx_dmux;
4394 spec->pin_nids = stac92hd83xxx_pin_nids;
4395 spec->board_config = snd_hda_check_board_config(codec,
4396 STAC_92HD83XXX_MODELS,
4397 stac92hd83xxx_models,
4398 stac92hd83xxx_cfg_tbl);
4400 if (spec->board_config < 0) {
4401 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4402 " STAC92HD83XXX, using BIOS defaults\n");
4403 err = stac92xx_save_bios_config_regs(codec);
4405 stac92xx_free(codec);
4408 spec->pin_configs = spec->bios_pin_configs;
4410 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4411 stac92xx_set_config_regs(codec);
4414 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4416 if (spec->board_config < 0) {
4417 printk(KERN_WARNING "hda_codec: No auto-config is "
4418 "available, default to model=ref\n");
4419 spec->board_config = STAC_92HD83XXX_REF;
4426 stac92xx_free(codec);
4430 codec->patch_ops = stac92xx_patch_ops;
4435 #ifdef SND_HDA_NEEDS_RESUME
4436 static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4438 struct sigmatel_spec *spec = codec->spec;
4440 snd_hda_codec_write_cache(codec, codec->afg, 0,
4441 AC_VERB_SET_POWER_STATE, pwr);
4444 for (i = 0; i < spec->num_adcs; i++) {
4445 snd_hda_codec_write_cache(codec,
4446 spec->adc_nids[i], 0,
4447 AC_VERB_SET_POWER_STATE, pwr);
4451 static int stac92hd71xx_resume(struct hda_codec *codec)
4453 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4454 return stac92xx_resume(codec);
4457 static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4459 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4465 static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4466 .build_controls = stac92xx_build_controls,
4467 .build_pcms = stac92xx_build_pcms,
4468 .init = stac92xx_init,
4469 .free = stac92xx_free,
4470 .unsol_event = stac92xx_unsol_event,
4471 #ifdef SND_HDA_NEEDS_RESUME
4472 .resume = stac92hd71xx_resume,
4473 .suspend = stac92hd71xx_suspend,
4477 static struct hda_input_mux stac92hd71bxx_dmux = {
4480 { "Analog Inputs", 0x00 },
4482 { "Digital Mic 1", 0x02 },
4483 { "Digital Mic 2", 0x03 },
4487 static int patch_stac92hd71bxx(struct hda_codec *codec)
4489 struct sigmatel_spec *spec;
4492 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4497 codec->patch_ops = stac92xx_patch_ops;
4498 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
4499 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4500 spec->pin_nids = stac92hd71bxx_pin_nids;
4501 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4502 sizeof(stac92hd71bxx_dmux));
4503 spec->board_config = snd_hda_check_board_config(codec,
4504 STAC_92HD71BXX_MODELS,
4505 stac92hd71bxx_models,
4506 stac92hd71bxx_cfg_tbl);
4508 if (spec->board_config < 0) {
4509 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4510 " STAC92HD71BXX, using BIOS defaults\n");
4511 err = stac92xx_save_bios_config_regs(codec);
4513 stac92xx_free(codec);
4516 spec->pin_configs = spec->bios_pin_configs;
4518 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4519 stac92xx_set_config_regs(codec);
4522 switch (codec->vendor_id) {
4523 case 0x111d76b6: /* 4 Port without Analog Mixer */
4525 case 0x111d76b4: /* 6 Port without Analog Mixer */
4527 spec->mixer = stac92hd71bxx_mixer;
4528 spec->init = stac92hd71bxx_core_init;
4529 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4531 case 0x111d7608: /* 5 Port with Analog Mixer */
4532 switch (codec->subsystem_id) {
4534 /* Enable VREF power saving on GPIO1 detect */
4535 snd_hda_codec_write(codec, codec->afg, 0,
4536 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4537 snd_hda_codec_write_cache(codec, codec->afg, 0,
4538 AC_VERB_SET_UNSOLICITED_ENABLE,
4539 (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
4540 err = stac92xx_add_event(spec, codec->afg, 0x02);
4543 spec->gpio_mask |= 0x02;
4546 if ((codec->revision_id & 0xf) == 0 ||
4547 (codec->revision_id & 0xf) == 1) {
4548 #ifdef SND_HDA_NEEDS_RESUME
4549 codec->patch_ops = stac92hd71bxx_patch_ops;
4551 spec->stream_delay = 40; /* 40 milliseconds */
4554 /* no output amps */
4556 spec->mixer = stac92hd71bxx_analog_mixer;
4557 spec->dinput_mux = &spec->private_dimux;
4560 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4561 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4563 case 0x111d7603: /* 6 Port with Analog Mixer */
4564 if ((codec->revision_id & 0xf) == 1) {
4565 #ifdef SND_HDA_NEEDS_RESUME
4566 codec->patch_ops = stac92hd71bxx_patch_ops;
4568 spec->stream_delay = 40; /* 40 milliseconds */
4571 /* no output amps */
4575 spec->dinput_mux = &spec->private_dimux;
4576 spec->mixer = stac92hd71bxx_analog_mixer;
4577 spec->init = stac92hd71bxx_analog_core_init;
4578 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4581 spec->aloopback_mask = 0x50;
4582 spec->aloopback_shift = 0;
4584 if (spec->board_config > STAC_92HD71BXX_REF) {
4586 spec->gpio_mask = 0x01;
4587 spec->gpio_dir = 0x01;
4588 spec->gpio_data = 0x01;
4591 spec->powerdown_adcs = 1;
4592 spec->digbeep_nid = 0x26;
4593 spec->mux_nids = stac92hd71bxx_mux_nids;
4594 spec->adc_nids = stac92hd71bxx_adc_nids;
4595 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4596 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4597 spec->smux_nids = stac92hd71bxx_smux_nids;
4598 spec->pwr_nids = stac92hd71bxx_pwr_nids;
4600 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4601 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
4603 switch (spec->board_config) {
4605 spec->num_dmics = 0;
4606 spec->num_smuxes = 0;
4607 spec->num_dmuxes = 0;
4609 /* enable internal microphone */
4610 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4611 stac92xx_auto_set_pinctl(codec, 0x0e,
4612 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
4615 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4616 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4617 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4620 spec->multiout.num_dacs = 1;
4621 spec->multiout.hp_nid = 0x11;
4622 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4623 if (spec->dinput_mux)
4624 spec->private_dimux.num_items +=
4626 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
4628 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4630 if (spec->board_config < 0) {
4631 printk(KERN_WARNING "hda_codec: No auto-config is "
4632 "available, default to model=ref\n");
4633 spec->board_config = STAC_92HD71BXX_REF;
4640 stac92xx_free(codec);
4647 static int patch_stac922x(struct hda_codec *codec)
4649 struct sigmatel_spec *spec;
4652 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4657 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
4658 spec->pin_nids = stac922x_pin_nids;
4659 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4662 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
4663 spec->gpio_mask = spec->gpio_dir = 0x03;
4664 spec->gpio_data = 0x03;
4665 /* Intel Macs have all same PCI SSID, so we need to check
4666 * codec SSID to distinguish the exact models
4668 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
4669 switch (codec->subsystem_id) {
4672 spec->board_config = STAC_INTEL_MAC_V1;
4676 spec->board_config = STAC_INTEL_MAC_V2;
4684 spec->board_config = STAC_INTEL_MAC_V3;
4688 spec->board_config = STAC_INTEL_MAC_V4;
4692 spec->board_config = STAC_INTEL_MAC_V5;
4695 spec->board_config = STAC_INTEL_MAC_V3;
4701 if (spec->board_config < 0) {
4702 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4703 "using BIOS defaults\n");
4704 err = stac92xx_save_bios_config_regs(codec);
4706 stac92xx_free(codec);
4709 spec->pin_configs = spec->bios_pin_configs;
4710 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
4711 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4712 stac92xx_set_config_regs(codec);
4715 spec->adc_nids = stac922x_adc_nids;
4716 spec->mux_nids = stac922x_mux_nids;
4717 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
4718 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
4719 spec->num_dmics = 0;
4722 spec->init = stac922x_core_init;
4723 spec->mixer = stac922x_mixer;
4725 spec->multiout.dac_nids = spec->dac_nids;
4727 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
4729 if (spec->board_config < 0) {
4730 printk(KERN_WARNING "hda_codec: No auto-config is "
4731 "available, default to model=ref\n");
4732 spec->board_config = STAC_D945_REF;
4738 stac92xx_free(codec);
4742 codec->patch_ops = stac92xx_patch_ops;
4744 /* Fix Mux capture level; max to 2 */
4745 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4746 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4747 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4748 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4749 (0 << AC_AMPCAP_MUTE_SHIFT));
4754 static int patch_stac927x(struct hda_codec *codec)
4756 struct sigmatel_spec *spec;
4759 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4764 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
4765 spec->pin_nids = stac927x_pin_nids;
4766 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4770 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4771 if (spec->board_config < 0)
4772 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4773 "STAC927x, using BIOS defaults\n");
4774 err = stac92xx_save_bios_config_regs(codec);
4776 stac92xx_free(codec);
4779 spec->pin_configs = spec->bios_pin_configs;
4781 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4782 stac92xx_set_config_regs(codec);
4785 spec->digbeep_nid = 0x23;
4786 spec->adc_nids = stac927x_adc_nids;
4787 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4788 spec->mux_nids = stac927x_mux_nids;
4789 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
4790 spec->smux_nids = stac927x_smux_nids;
4791 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
4792 spec->spdif_labels = stac927x_spdif_labels;
4793 spec->dac_list = stac927x_dac_nids;
4794 spec->multiout.dac_nids = spec->dac_nids;
4796 switch (spec->board_config) {
4799 /* GPIO0 High = Enable EAPD */
4800 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
4801 spec->gpio_data = 0x01;
4802 spec->num_dmics = 0;
4804 spec->init = d965_core_init;
4805 spec->mixer = stac927x_mixer;
4807 case STAC_DELL_BIOS:
4808 switch (codec->subsystem_id) {
4811 /* correct the device field to SPDIF out */
4812 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4815 /* configure the analog microphone on some laptops */
4816 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
4817 /* correct the front output jack as a hp out */
4818 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
4819 /* correct the front input jack as a mic */
4820 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4823 /* GPIO2 High = Enable EAPD */
4824 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
4825 spec->gpio_data = 0x04;
4826 spec->dmic_nids = stac927x_dmic_nids;
4827 spec->num_dmics = STAC927X_NUM_DMICS;
4829 spec->init = d965_core_init;
4830 spec->mixer = stac927x_mixer;
4831 spec->dmux_nids = stac927x_dmux_nids;
4832 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
4835 if (spec->board_config > STAC_D965_REF) {
4836 /* GPIO0 High = Enable EAPD */
4837 spec->eapd_mask = spec->gpio_mask = 0x01;
4838 spec->gpio_dir = spec->gpio_data = 0x01;
4840 spec->num_dmics = 0;
4842 spec->init = stac927x_core_init;
4843 spec->mixer = stac927x_mixer;
4847 spec->aloopback_mask = 0x40;
4848 spec->aloopback_shift = 0;
4850 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
4852 if (spec->board_config < 0) {
4853 printk(KERN_WARNING "hda_codec: No auto-config is "
4854 "available, default to model=ref\n");
4855 spec->board_config = STAC_D965_REF;
4861 stac92xx_free(codec);
4865 codec->patch_ops = stac92xx_patch_ops;
4869 * The STAC927x seem to require fairly long delays for certain
4870 * command sequences. With too short delays (even if the answer
4871 * is set to RIRB properly), it results in the silence output
4872 * on some hardwares like Dell.
4874 * The below flag enables the longer delay (see get_response
4877 codec->bus->needs_damn_long_delay = 1;
4882 static int patch_stac9205(struct hda_codec *codec)
4884 struct sigmatel_spec *spec;
4887 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4892 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
4893 spec->pin_nids = stac9205_pin_nids;
4894 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4898 if (spec->board_config < 0) {
4899 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4900 err = stac92xx_save_bios_config_regs(codec);
4902 stac92xx_free(codec);
4905 spec->pin_configs = spec->bios_pin_configs;
4907 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4908 stac92xx_set_config_regs(codec);
4911 spec->digbeep_nid = 0x23;
4912 spec->adc_nids = stac9205_adc_nids;
4913 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
4914 spec->mux_nids = stac9205_mux_nids;
4915 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
4916 spec->smux_nids = stac9205_smux_nids;
4917 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
4918 spec->dmic_nids = stac9205_dmic_nids;
4919 spec->num_dmics = STAC9205_NUM_DMICS;
4920 spec->dmux_nids = stac9205_dmux_nids;
4921 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
4924 spec->init = stac9205_core_init;
4925 spec->mixer = stac9205_mixer;
4927 spec->aloopback_mask = 0x40;
4928 spec->aloopback_shift = 0;
4929 spec->multiout.dac_nids = spec->dac_nids;
4931 switch (spec->board_config){
4932 case STAC_9205_DELL_M43:
4933 /* Enable SPDIF in/out */
4934 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4935 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
4937 /* Enable unsol response for GPIO4/Dock HP connection */
4938 snd_hda_codec_write(codec, codec->afg, 0,
4939 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4940 snd_hda_codec_write_cache(codec, codec->afg, 0,
4941 AC_VERB_SET_UNSOLICITED_ENABLE,
4942 (AC_USRSP_EN | STAC_VREF_EVENT | codec->afg));
4943 err = stac92xx_add_event(spec, codec->afg, 0x01);
4947 spec->gpio_dir = 0x0b;
4948 spec->eapd_mask = 0x01;
4949 spec->gpio_mask = 0x1b;
4950 spec->gpio_mute = 0x10;
4951 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
4954 spec->gpio_data = 0x01;
4957 /* SPDIF-In enabled */
4960 /* GPIO0 High = EAPD */
4961 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4962 spec->gpio_data = 0x01;
4966 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
4968 if (spec->board_config < 0) {
4969 printk(KERN_WARNING "hda_codec: No auto-config is "
4970 "available, default to model=ref\n");
4971 spec->board_config = STAC_9205_REF;
4977 stac92xx_free(codec);
4981 codec->patch_ops = stac92xx_patch_ops;
4990 /* static config for Sony VAIO FE550G and Sony VAIO AR */
4991 static hda_nid_t vaio_dacs[] = { 0x2 };
4992 #define VAIO_HP_DAC 0x5
4993 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4994 static hda_nid_t vaio_mux_nids[] = { 0x15 };
4996 static struct hda_input_mux vaio_mux = {
4999 /* { "HP", 0x0 }, */
5000 { "Mic Jack", 0x1 },
5001 { "Internal Mic", 0x2 },
5006 static struct hda_verb vaio_init[] = {
5007 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5008 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
5009 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5010 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5011 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5012 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5014 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5015 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5016 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5017 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5018 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5022 static struct hda_verb vaio_ar_init[] = {
5023 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5024 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5025 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5026 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5027 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5028 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5029 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5030 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5031 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5032 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5033 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5039 /* bind volumes of both NID 0x02 and 0x05 */
5040 static struct hda_bind_ctls vaio_bind_master_vol = {
5041 .ops = &snd_hda_bind_vol,
5043 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5044 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5049 /* bind volumes of both NID 0x02 and 0x05 */
5050 static struct hda_bind_ctls vaio_bind_master_sw = {
5051 .ops = &snd_hda_bind_sw,
5053 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5054 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5059 static struct snd_kcontrol_new vaio_mixer[] = {
5060 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5061 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
5062 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5063 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5064 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5066 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5067 .name = "Capture Source",
5069 .info = stac92xx_mux_enum_info,
5070 .get = stac92xx_mux_enum_get,
5071 .put = stac92xx_mux_enum_put,
5076 static struct snd_kcontrol_new vaio_ar_mixer[] = {
5077 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5078 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
5079 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5080 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5081 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5082 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5083 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5086 .name = "Capture Source",
5088 .info = stac92xx_mux_enum_info,
5089 .get = stac92xx_mux_enum_get,
5090 .put = stac92xx_mux_enum_put,
5095 static struct hda_codec_ops stac9872_patch_ops = {
5096 .build_controls = stac92xx_build_controls,
5097 .build_pcms = stac92xx_build_pcms,
5098 .init = stac92xx_init,
5099 .free = stac92xx_free,
5100 #ifdef SND_HDA_NEEDS_RESUME
5101 .resume = stac92xx_resume,
5105 static int stac9872_vaio_init(struct hda_codec *codec)
5109 err = stac92xx_init(codec);
5112 if (codec->patch_ops.unsol_event)
5113 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5117 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5119 if (get_hp_pin_presence(codec, 0x0a)) {
5120 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5121 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5123 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5124 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5128 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5130 switch (res >> 26) {
5132 stac9872_vaio_hp_detect(codec, res);
5137 static struct hda_codec_ops stac9872_vaio_patch_ops = {
5138 .build_controls = stac92xx_build_controls,
5139 .build_pcms = stac92xx_build_pcms,
5140 .init = stac9872_vaio_init,
5141 .free = stac92xx_free,
5142 .unsol_event = stac9872_vaio_unsol_event,
5144 .resume = stac92xx_resume,
5148 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5150 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5152 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5154 /* AR Series. id=0x83847664 and subsys=104D1300 */
5159 static const char *stac9872_models[STAC_9872_MODELS] = {
5160 [CXD9872RD_VAIO] = "vaio",
5161 [CXD9872AKD_VAIO] = "vaio-ar",
5164 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5165 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5166 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5167 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
5168 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
5172 static int patch_stac9872(struct hda_codec *codec)
5174 struct sigmatel_spec *spec;
5177 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5180 if (board_config < 0)
5181 /* unknown config, let generic-parser do its job... */
5182 return snd_hda_parse_generic_codec(codec);
5184 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5189 switch (board_config) {
5190 case CXD9872RD_VAIO:
5191 case STAC9872AK_VAIO:
5192 case STAC9872K_VAIO:
5193 spec->mixer = vaio_mixer;
5194 spec->init = vaio_init;
5195 spec->multiout.max_channels = 2;
5196 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5197 spec->multiout.dac_nids = vaio_dacs;
5198 spec->multiout.hp_nid = VAIO_HP_DAC;
5199 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5200 spec->adc_nids = vaio_adcs;
5202 spec->input_mux = &vaio_mux;
5203 spec->mux_nids = vaio_mux_nids;
5204 codec->patch_ops = stac9872_vaio_patch_ops;
5207 case CXD9872AKD_VAIO:
5208 spec->mixer = vaio_ar_mixer;
5209 spec->init = vaio_ar_init;
5210 spec->multiout.max_channels = 2;
5211 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5212 spec->multiout.dac_nids = vaio_dacs;
5213 spec->multiout.hp_nid = VAIO_HP_DAC;
5214 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5216 spec->adc_nids = vaio_adcs;
5217 spec->input_mux = &vaio_mux;
5218 spec->mux_nids = vaio_mux_nids;
5219 codec->patch_ops = stac9872_patch_ops;
5230 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5231 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5232 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5233 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5234 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5235 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5236 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5237 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5238 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5239 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5240 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5241 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5242 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5243 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5244 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5245 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5246 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5247 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5248 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5249 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5250 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5251 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5252 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5253 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5254 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5255 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5256 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5257 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5258 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5259 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5260 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5261 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5262 /* The following does not take into account .id=0x83847661 when subsys =
5263 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5264 * currently not fully supported.
5266 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5267 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5268 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5269 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5270 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5271 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5272 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5273 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5274 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5275 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5276 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5277 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5278 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5279 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5280 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5281 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5282 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5283 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5284 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5285 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5286 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5287 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5288 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5289 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5290 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5291 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },