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"
79 STAC_92HD73XX_NO_JD, /* no jack-detection */
92 STAC_92HD83XXX_PWR_REF,
107 STAC_92HD71BXX_MODELS
133 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
134 * is given, one of the above models will be
135 * chosen according to the subsystem id. */
136 /* for backward compatibility */
153 STAC_D965_REF_NO_JD, /* no jack-detection */
169 struct sigmatel_event {
176 struct sigmatel_jack {
179 struct snd_jack *jack;
182 struct sigmatel_mic_route {
184 unsigned char mux_idx;
185 unsigned char dmux_idx;
188 struct sigmatel_spec {
189 struct snd_kcontrol_new *mixers[4];
190 unsigned int num_mixers;
193 unsigned int eapd_switch: 1;
194 unsigned int surr_switch: 1;
195 unsigned int alt_switch: 1;
196 unsigned int hp_detect: 1;
197 unsigned int spdif_mute: 1;
198 unsigned int check_volume_offset:1;
199 unsigned int auto_mic:1;
202 unsigned int eapd_mask;
203 unsigned int gpio_mask;
204 unsigned int gpio_dir;
205 unsigned int gpio_data;
206 unsigned int gpio_mute;
207 unsigned int gpio_led;
210 unsigned int stream_delay;
212 /* analog loopback */
213 struct snd_kcontrol_new *aloopback_ctl;
214 unsigned char aloopback_mask;
215 unsigned char aloopback_shift;
217 /* power management */
218 unsigned int num_pwrs;
219 unsigned int *pwr_mapping;
224 struct snd_array jacks;
227 struct snd_array events;
230 struct hda_input_mux *mono_mux;
231 unsigned int cur_mmux;
232 struct hda_multi_out multiout;
233 hda_nid_t dac_nids[5];
234 hda_nid_t hp_dacs[5];
235 hda_nid_t speaker_dacs[5];
241 unsigned int num_adcs;
243 unsigned int num_muxes;
244 hda_nid_t *dmic_nids;
245 unsigned int num_dmics;
246 hda_nid_t *dmux_nids;
247 unsigned int num_dmuxes;
248 hda_nid_t *smux_nids;
249 unsigned int num_smuxes;
250 unsigned int num_analog_muxes;
252 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
253 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
254 unsigned int num_caps; /* number of capture volume/switch elements */
256 struct sigmatel_mic_route ext_mic;
257 struct sigmatel_mic_route int_mic;
259 const char **spdif_labels;
261 hda_nid_t dig_in_nid;
263 hda_nid_t anabeep_nid;
264 hda_nid_t digbeep_nid;
268 unsigned int num_pins;
270 /* codec specific stuff */
271 struct hda_verb *init;
272 struct snd_kcontrol_new *mixer;
275 struct hda_input_mux *dinput_mux;
276 unsigned int cur_dmux[2];
277 struct hda_input_mux *input_mux;
278 unsigned int cur_mux[3];
279 struct hda_input_mux *sinput_mux;
280 unsigned int cur_smux[2];
281 unsigned int cur_amux;
283 unsigned int powerdown_adcs;
286 unsigned int io_switch[2];
287 unsigned int clfe_swap;
288 hda_nid_t line_switch; /* shared line-in for input and output */
289 hda_nid_t mic_switch; /* shared mic-in for input and output */
290 hda_nid_t hp_switch; /* NID of HP as line-out */
291 unsigned int aloopback;
293 struct hda_pcm pcm_rec[2]; /* PCM information */
295 /* dynamic controls and input_mux */
296 struct auto_pin_cfg autocfg;
297 struct snd_array kctls;
298 struct hda_input_mux private_dimux;
299 struct hda_input_mux private_imux;
300 struct hda_input_mux private_smux;
301 struct hda_input_mux private_mono_mux;
304 static hda_nid_t stac9200_adc_nids[1] = {
308 static hda_nid_t stac9200_mux_nids[1] = {
312 static hda_nid_t stac9200_dac_nids[1] = {
316 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
317 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
321 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
325 static hda_nid_t stac92hd73xx_adc_nids[2] = {
329 #define STAC92HD73XX_NUM_DMICS 2
330 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
334 #define STAC92HD73_DAC_COUNT 5
336 static hda_nid_t stac92hd73xx_mux_nids[2] = {
340 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
344 static hda_nid_t stac92hd73xx_smux_nids[2] = {
348 #define STAC92HD73XX_NUM_CAPS 2
349 static unsigned long stac92hd73xx_capvols[] = {
350 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
351 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
353 #define stac92hd73xx_capsws stac92hd73xx_capvols
355 #define STAC92HD83_DAC_COUNT 3
357 static hda_nid_t stac92hd83xxx_mux_nids[2] = {
361 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
365 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
369 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
373 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
374 0x03, 0x0c, 0x20, 0x40,
377 #define STAC92HD83XXX_NUM_CAPS 2
378 static unsigned long stac92hd83xxx_capvols[] = {
379 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
380 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
382 #define stac92hd83xxx_capsws stac92hd83xxx_capvols
384 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
388 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
392 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
396 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
400 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
404 #define STAC92HD71BXX_NUM_DMICS 2
405 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
409 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
413 #define STAC92HD71BXX_NUM_CAPS 2
414 static unsigned long stac92hd71bxx_capvols[] = {
415 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
416 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
418 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
420 static hda_nid_t stac925x_adc_nids[1] = {
424 static hda_nid_t stac925x_mux_nids[1] = {
428 static hda_nid_t stac925x_dac_nids[1] = {
432 #define STAC925X_NUM_DMICS 1
433 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
437 static hda_nid_t stac925x_dmux_nids[1] = {
441 static unsigned long stac925x_capvols[] = {
442 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
444 static unsigned long stac925x_capsws[] = {
445 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
448 static hda_nid_t stac922x_adc_nids[2] = {
452 static hda_nid_t stac922x_mux_nids[2] = {
456 #define STAC922X_NUM_CAPS 2
457 static unsigned long stac922x_capvols[] = {
458 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
459 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
461 #define stac922x_capsws stac922x_capvols
463 static hda_nid_t stac927x_slave_dig_outs[2] = {
467 static hda_nid_t stac927x_adc_nids[3] = {
471 static hda_nid_t stac927x_mux_nids[3] = {
475 static hda_nid_t stac927x_smux_nids[1] = {
479 static hda_nid_t stac927x_dac_nids[6] = {
480 0x02, 0x03, 0x04, 0x05, 0x06, 0
483 static hda_nid_t stac927x_dmux_nids[1] = {
487 #define STAC927X_NUM_DMICS 2
488 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
492 #define STAC927X_NUM_CAPS 3
493 static unsigned long stac927x_capvols[] = {
494 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
495 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
496 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
498 static unsigned long stac927x_capsws[] = {
499 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
500 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
501 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
504 static const char *stac927x_spdif_labels[5] = {
505 "Digital Playback", "ADAT", "Analog Mux 1",
506 "Analog Mux 2", "Analog Mux 3"
509 static hda_nid_t stac9205_adc_nids[2] = {
513 static hda_nid_t stac9205_mux_nids[2] = {
517 static hda_nid_t stac9205_dmux_nids[1] = {
521 static hda_nid_t stac9205_smux_nids[1] = {
525 #define STAC9205_NUM_DMICS 2
526 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
530 #define STAC9205_NUM_CAPS 2
531 static unsigned long stac9205_capvols[] = {
532 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
533 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
535 static unsigned long stac9205_capsws[] = {
536 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
537 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
540 static hda_nid_t stac9200_pin_nids[8] = {
541 0x08, 0x09, 0x0d, 0x0e,
542 0x0f, 0x10, 0x11, 0x12,
545 static hda_nid_t stac925x_pin_nids[8] = {
546 0x07, 0x08, 0x0a, 0x0b,
547 0x0c, 0x0d, 0x10, 0x11,
550 static hda_nid_t stac922x_pin_nids[10] = {
551 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
552 0x0f, 0x10, 0x11, 0x15, 0x1b,
555 static hda_nid_t stac92hd73xx_pin_nids[13] = {
556 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
557 0x0f, 0x10, 0x11, 0x12, 0x13,
561 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
562 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
563 0x0f, 0x10, 0x11, 0x1f, 0x20,
566 #define STAC92HD71BXX_NUM_PINS 13
567 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
568 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
569 0x00, 0x14, 0x18, 0x19, 0x1e,
572 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
573 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
574 0x0f, 0x14, 0x18, 0x19, 0x1e,
578 static hda_nid_t stac927x_pin_nids[14] = {
579 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
580 0x0f, 0x10, 0x11, 0x12, 0x13,
581 0x14, 0x21, 0x22, 0x23,
584 static hda_nid_t stac9205_pin_nids[12] = {
585 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
586 0x0f, 0x14, 0x16, 0x17, 0x18,
590 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
591 struct snd_ctl_elem_info *uinfo)
593 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
594 struct sigmatel_spec *spec = codec->spec;
595 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
598 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
599 struct snd_ctl_elem_value *ucontrol)
601 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
602 struct sigmatel_spec *spec = codec->spec;
603 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
605 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
609 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
610 struct snd_ctl_elem_value *ucontrol)
612 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
613 struct sigmatel_spec *spec = codec->spec;
614 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
616 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
617 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
620 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
621 struct snd_ctl_elem_info *uinfo)
623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
624 struct sigmatel_spec *spec = codec->spec;
625 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
628 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
629 struct snd_ctl_elem_value *ucontrol)
631 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
632 struct sigmatel_spec *spec = codec->spec;
633 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
635 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
639 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
640 struct snd_ctl_elem_value *ucontrol)
642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
643 struct sigmatel_spec *spec = codec->spec;
644 struct hda_input_mux *smux = &spec->private_smux;
645 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
649 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
650 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
654 if (spec->spdif_mute) {
656 nid = spec->multiout.dig_out_nid;
658 nid = codec->slave_dig_outs[smux_idx - 1];
659 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
663 /* un/mute SPDIF out */
664 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
670 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
671 hda_nid_t nid, unsigned int new_vref)
675 pincfg = snd_hda_codec_read(codec, nid, 0,
676 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
679 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
682 if (new_vref == AC_PINCTL_VREF_HIZ)
683 pincfg |= AC_PINCTL_OUT_EN;
685 pincfg |= AC_PINCTL_IN_EN;
687 error = snd_hda_codec_write_cache(codec, nid, 0,
688 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
695 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
698 vref = snd_hda_codec_read(codec, nid, 0,
699 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
700 vref &= AC_PINCTL_VREFEN;
704 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
706 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
707 struct sigmatel_spec *spec = codec->spec;
708 return snd_hda_input_mux_info(spec->input_mux, uinfo);
711 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
714 struct sigmatel_spec *spec = codec->spec;
715 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
717 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
721 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
723 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
724 struct sigmatel_spec *spec = codec->spec;
725 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
726 const struct hda_input_mux *imux = spec->input_mux;
727 unsigned int idx, prev_idx;
729 idx = ucontrol->value.enumerated.item[0];
730 if (idx >= imux->num_items)
731 idx = imux->num_items - 1;
732 prev_idx = spec->cur_mux[adc_idx];
735 if (idx < spec->num_analog_muxes) {
736 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
737 AC_VERB_SET_CONNECT_SEL,
738 imux->items[idx].index);
739 if (prev_idx >= spec->num_analog_muxes) {
740 imux = spec->dinput_mux;
742 snd_hda_codec_write_cache(codec,
743 spec->dmux_nids[adc_idx], 0,
744 AC_VERB_SET_CONNECT_SEL,
745 imux->items[0].index);
748 imux = spec->dinput_mux;
749 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
750 AC_VERB_SET_CONNECT_SEL,
751 imux->items[idx - 1].index);
753 spec->cur_mux[adc_idx] = idx;
757 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
758 struct snd_ctl_elem_info *uinfo)
760 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
761 struct sigmatel_spec *spec = codec->spec;
762 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
765 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value *ucontrol)
768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
769 struct sigmatel_spec *spec = codec->spec;
771 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
775 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
776 struct snd_ctl_elem_value *ucontrol)
778 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
779 struct sigmatel_spec *spec = codec->spec;
781 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
782 spec->mono_nid, &spec->cur_mmux);
785 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
787 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
788 struct snd_ctl_elem_value *ucontrol)
790 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
791 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
792 struct sigmatel_spec *spec = codec->spec;
794 ucontrol->value.integer.value[0] = !!(spec->aloopback &
795 (spec->aloopback_mask << idx));
799 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
800 struct snd_ctl_elem_value *ucontrol)
802 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
803 struct sigmatel_spec *spec = codec->spec;
804 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
805 unsigned int dac_mode;
806 unsigned int val, idx_val;
808 idx_val = spec->aloopback_mask << idx;
809 if (ucontrol->value.integer.value[0])
810 val = spec->aloopback | idx_val;
812 val = spec->aloopback & ~idx_val;
813 if (spec->aloopback == val)
816 spec->aloopback = val;
818 /* Only return the bits defined by the shift value of the
819 * first two bytes of the mask
821 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
822 kcontrol->private_value & 0xFFFF, 0x0);
823 dac_mode >>= spec->aloopback_shift;
825 if (spec->aloopback & idx_val) {
826 snd_hda_power_up(codec);
829 snd_hda_power_down(codec);
830 dac_mode &= ~idx_val;
833 snd_hda_codec_write_cache(codec, codec->afg, 0,
834 kcontrol->private_value >> 16, dac_mode);
839 static struct hda_verb stac9200_core_init[] = {
840 /* set dac0mux for dac converter */
841 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
845 static struct hda_verb stac9200_eapd_init[] = {
846 /* set dac0mux for dac converter */
847 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
848 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
852 static struct hda_verb dell_eq_core_init[] = {
853 /* set master volume to max value without distortion
854 * and direct control */
855 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
859 static struct hda_verb stac92hd73xx_core_init[] = {
860 /* set master volume and direct control */
861 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
865 static struct hda_verb stac92hd83xxx_core_init[] = {
866 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
867 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
868 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
870 /* power state controls amps */
871 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
875 static struct hda_verb stac92hd71bxx_core_init[] = {
876 /* set master volume and direct control */
877 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
881 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
882 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
883 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
884 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
885 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
889 static struct hda_verb stac925x_core_init[] = {
890 /* set dac0mux for dac converter */
891 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
892 /* mute the master volume */
893 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
897 static struct hda_verb stac922x_core_init[] = {
898 /* set master volume and direct control */
899 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
903 static struct hda_verb d965_core_init[] = {
904 /* set master volume and direct control */
905 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
906 /* unmute node 0x1b */
907 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
908 /* select node 0x03 as DAC */
909 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
913 static struct hda_verb stac927x_core_init[] = {
914 /* set master volume and direct control */
915 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
916 /* enable analog pc beep path */
917 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
921 static struct hda_verb stac9205_core_init[] = {
922 /* set master volume and direct control */
923 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
924 /* enable analog pc beep path */
925 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
929 #define STAC_MONO_MUX \
931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
932 .name = "Mono Mux", \
934 .info = stac92xx_mono_mux_enum_info, \
935 .get = stac92xx_mono_mux_enum_get, \
936 .put = stac92xx_mono_mux_enum_put, \
939 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
941 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
942 .name = "Analog Loopback", \
944 .info = stac92xx_aloopback_info, \
945 .get = stac92xx_aloopback_get, \
946 .put = stac92xx_aloopback_put, \
947 .private_value = verb_read | (verb_write << 16), \
950 #define DC_BIAS(xname, idx, nid) \
952 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
955 .info = stac92xx_dc_bias_info, \
956 .get = stac92xx_dc_bias_get, \
957 .put = stac92xx_dc_bias_put, \
958 .private_value = nid, \
961 static struct snd_kcontrol_new stac9200_mixer[] = {
962 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
963 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
964 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
965 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
969 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
970 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
974 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
975 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
979 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
980 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
985 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
986 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
989 static struct snd_kcontrol_new stac925x_mixer[] = {
990 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
991 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
995 static struct snd_kcontrol_new stac9205_loopback[] = {
996 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1000 static struct snd_kcontrol_new stac927x_loopback[] = {
1001 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1005 static struct snd_kcontrol_new stac_dmux_mixer = {
1006 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1007 .name = "Digital Input Source",
1008 /* count set later */
1009 .info = stac92xx_dmux_enum_info,
1010 .get = stac92xx_dmux_enum_get,
1011 .put = stac92xx_dmux_enum_put,
1014 static struct snd_kcontrol_new stac_smux_mixer = {
1015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1016 .name = "IEC958 Playback Source",
1017 /* count set later */
1018 .info = stac92xx_smux_enum_info,
1019 .get = stac92xx_smux_enum_get,
1020 .put = stac92xx_smux_enum_put,
1023 static const char *slave_vols[] = {
1024 "Front Playback Volume",
1025 "Surround Playback Volume",
1026 "Center Playback Volume",
1027 "LFE Playback Volume",
1028 "Side Playback Volume",
1029 "Headphone Playback Volume",
1030 "Speaker Playback Volume",
1034 static const char *slave_sws[] = {
1035 "Front Playback Switch",
1036 "Surround Playback Switch",
1037 "Center Playback Switch",
1038 "LFE Playback Switch",
1039 "Side Playback Switch",
1040 "Headphone Playback Switch",
1041 "Speaker Playback Switch",
1042 "IEC958 Playback Switch",
1046 static void stac92xx_free_kctls(struct hda_codec *codec);
1047 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1049 static int stac92xx_build_controls(struct hda_codec *codec)
1051 struct sigmatel_spec *spec = codec->spec;
1052 struct auto_pin_cfg *cfg = &spec->autocfg;
1058 err = snd_hda_add_new_ctls(codec, spec->mixer);
1063 for (i = 0; i < spec->num_mixers; i++) {
1064 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1068 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1069 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1070 stac_dmux_mixer.count = spec->num_dmuxes;
1071 err = snd_hda_ctl_add(codec,
1072 snd_ctl_new1(&stac_dmux_mixer, codec));
1076 if (spec->num_smuxes > 0) {
1077 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1078 struct hda_input_mux *smux = &spec->private_smux;
1079 /* check for mute support on SPDIF out */
1080 if (wcaps & AC_WCAP_OUT_AMP) {
1081 smux->items[smux->num_items].label = "Off";
1082 smux->items[smux->num_items].index = 0;
1084 spec->spdif_mute = 1;
1086 stac_smux_mixer.count = spec->num_smuxes;
1087 err = snd_hda_ctl_add(codec,
1088 snd_ctl_new1(&stac_smux_mixer, codec));
1093 if (spec->multiout.dig_out_nid) {
1094 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1097 err = snd_hda_create_spdif_share_sw(codec,
1101 spec->multiout.share_spdif = 1;
1103 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1104 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1109 /* if we have no master control, let's create it */
1110 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1111 unsigned int vmaster_tlv[4];
1112 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1113 HDA_OUTPUT, vmaster_tlv);
1114 /* correct volume offset */
1115 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1116 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1117 vmaster_tlv, slave_vols);
1121 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1122 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1128 if (spec->aloopback_ctl &&
1129 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1130 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1135 stac92xx_free_kctls(codec); /* no longer needed */
1137 /* create jack input elements */
1138 if (spec->hp_detect) {
1139 for (i = 0; i < cfg->hp_outs; i++) {
1140 int type = SND_JACK_HEADPHONE;
1141 nid = cfg->hp_pins[i];
1142 /* jack detection */
1143 if (cfg->hp_outs == i)
1144 type |= SND_JACK_LINEOUT;
1145 err = stac92xx_add_jack(codec, nid, type);
1150 for (i = 0; i < cfg->line_outs; i++) {
1151 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1156 for (i = 0; i < AUTO_PIN_LAST; i++) {
1157 nid = cfg->input_pins[i];
1159 err = stac92xx_add_jack(codec, nid,
1160 SND_JACK_MICROPHONE);
1169 static unsigned int ref9200_pin_configs[8] = {
1170 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1171 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1174 static unsigned int gateway9200_m4_pin_configs[8] = {
1175 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1176 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1178 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1179 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1180 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1184 STAC 9200 pin configs for
1189 static unsigned int dell9200_d21_pin_configs[8] = {
1190 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1191 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1195 STAC 9200 pin configs for
1199 static unsigned int dell9200_d22_pin_configs[8] = {
1200 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1201 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1205 STAC 9200 pin configs for
1206 102801C4 (Dell Dimension E310)
1213 static unsigned int dell9200_d23_pin_configs[8] = {
1214 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1215 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1220 STAC 9200-32 pin configs for
1221 102801B5 (Dell Inspiron 630m)
1222 102801D8 (Dell Inspiron 640m)
1224 static unsigned int dell9200_m21_pin_configs[8] = {
1225 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1226 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1230 STAC 9200-32 pin configs for
1231 102801C2 (Dell Latitude D620)
1233 102801CC (Dell Latitude D820)
1237 static unsigned int dell9200_m22_pin_configs[8] = {
1238 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1239 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1243 STAC 9200-32 pin configs for
1244 102801CE (Dell XPS M1710)
1245 102801CF (Dell Precision M90)
1247 static unsigned int dell9200_m23_pin_configs[8] = {
1248 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1249 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1253 STAC 9200-32 pin configs for
1256 102801CB (Dell Latitude 120L)
1259 static unsigned int dell9200_m24_pin_configs[8] = {
1260 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1261 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1265 STAC 9200-32 pin configs for
1266 102801BD (Dell Inspiron E1505n)
1270 static unsigned int dell9200_m25_pin_configs[8] = {
1271 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1272 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1276 STAC 9200-32 pin configs for
1277 102801F5 (Dell Inspiron 1501)
1280 static unsigned int dell9200_m26_pin_configs[8] = {
1281 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1282 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1287 102801CD (Dell Inspiron E1705/9400)
1289 static unsigned int dell9200_m27_pin_configs[8] = {
1290 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1291 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1294 static unsigned int oqo9200_pin_configs[8] = {
1295 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1296 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1300 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1301 [STAC_REF] = ref9200_pin_configs,
1302 [STAC_9200_OQO] = oqo9200_pin_configs,
1303 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1304 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1305 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1306 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1307 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1308 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1309 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1310 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1311 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1312 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1313 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1314 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1315 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1318 static const char *stac9200_models[STAC_9200_MODELS] = {
1319 [STAC_AUTO] = "auto",
1321 [STAC_9200_OQO] = "oqo",
1322 [STAC_9200_DELL_D21] = "dell-d21",
1323 [STAC_9200_DELL_D22] = "dell-d22",
1324 [STAC_9200_DELL_D23] = "dell-d23",
1325 [STAC_9200_DELL_M21] = "dell-m21",
1326 [STAC_9200_DELL_M22] = "dell-m22",
1327 [STAC_9200_DELL_M23] = "dell-m23",
1328 [STAC_9200_DELL_M24] = "dell-m24",
1329 [STAC_9200_DELL_M25] = "dell-m25",
1330 [STAC_9200_DELL_M26] = "dell-m26",
1331 [STAC_9200_DELL_M27] = "dell-m27",
1332 [STAC_9200_M4] = "gateway-m4",
1333 [STAC_9200_M4_2] = "gateway-m4-2",
1334 [STAC_9200_PANASONIC] = "panasonic",
1337 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1338 /* SigmaTel reference board */
1339 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1340 "DFI LanParty", STAC_REF),
1341 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1342 "DFI LanParty", STAC_REF),
1343 /* Dell laptops have BIOS problem */
1344 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1345 "unknown Dell", STAC_9200_DELL_D21),
1346 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1347 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1348 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1349 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1350 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1351 "unknown Dell", STAC_9200_DELL_D22),
1352 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1353 "unknown Dell", STAC_9200_DELL_D22),
1354 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1355 "Dell Latitude D620", STAC_9200_DELL_M22),
1356 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1357 "unknown Dell", STAC_9200_DELL_D23),
1358 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1359 "unknown Dell", STAC_9200_DELL_D23),
1360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1361 "unknown Dell", STAC_9200_DELL_M22),
1362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1363 "unknown Dell", STAC_9200_DELL_M24),
1364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1365 "unknown Dell", STAC_9200_DELL_M24),
1366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1367 "Dell Latitude 120L", STAC_9200_DELL_M24),
1368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1369 "Dell Latitude D820", STAC_9200_DELL_M22),
1370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1371 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1373 "Dell XPS M1710", STAC_9200_DELL_M23),
1374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1375 "Dell Precision M90", STAC_9200_DELL_M23),
1376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1377 "unknown Dell", STAC_9200_DELL_M22),
1378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1379 "unknown Dell", STAC_9200_DELL_M22),
1380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1381 "unknown Dell", STAC_9200_DELL_M22),
1382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1383 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1384 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1385 "unknown Dell", STAC_9200_DELL_D23),
1386 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1387 "unknown Dell", STAC_9200_DELL_D23),
1388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1389 "unknown Dell", STAC_9200_DELL_D21),
1390 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1391 "unknown Dell", STAC_9200_DELL_D23),
1392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1393 "unknown Dell", STAC_9200_DELL_D21),
1394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1395 "unknown Dell", STAC_9200_DELL_M25),
1396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1397 "unknown Dell", STAC_9200_DELL_M25),
1398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1399 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1401 "unknown Dell", STAC_9200_DELL_M26),
1403 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1404 /* Gateway machines needs EAPD to be set on resume */
1405 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1406 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1407 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1409 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1413 static unsigned int ref925x_pin_configs[8] = {
1414 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1415 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1418 static unsigned int stac925xM1_pin_configs[8] = {
1419 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1420 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1423 static unsigned int stac925xM1_2_pin_configs[8] = {
1424 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1425 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1428 static unsigned int stac925xM2_pin_configs[8] = {
1429 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1430 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1433 static unsigned int stac925xM2_2_pin_configs[8] = {
1434 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1435 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1438 static unsigned int stac925xM3_pin_configs[8] = {
1439 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1440 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1443 static unsigned int stac925xM5_pin_configs[8] = {
1444 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1445 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1448 static unsigned int stac925xM6_pin_configs[8] = {
1449 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1450 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1453 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1454 [STAC_REF] = ref925x_pin_configs,
1455 [STAC_M1] = stac925xM1_pin_configs,
1456 [STAC_M1_2] = stac925xM1_2_pin_configs,
1457 [STAC_M2] = stac925xM2_pin_configs,
1458 [STAC_M2_2] = stac925xM2_2_pin_configs,
1459 [STAC_M3] = stac925xM3_pin_configs,
1460 [STAC_M5] = stac925xM5_pin_configs,
1461 [STAC_M6] = stac925xM6_pin_configs,
1464 static const char *stac925x_models[STAC_925x_MODELS] = {
1465 [STAC_925x_AUTO] = "auto",
1468 [STAC_M1_2] = "m1-2",
1470 [STAC_M2_2] = "m2-2",
1476 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1477 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1478 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1479 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1480 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1481 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1482 /* Not sure about the brand name for those */
1483 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1484 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1485 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1486 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1490 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1491 /* SigmaTel reference board */
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1493 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1494 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1496 /* Default table for unknown ID */
1497 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1502 static unsigned int ref92hd73xx_pin_configs[13] = {
1503 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1504 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1505 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1509 static unsigned int dell_m6_pin_configs[13] = {
1510 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1511 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1512 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1516 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1517 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1518 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1519 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1520 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1521 [STAC_DELL_EQ] = dell_m6_pin_configs,
1524 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1525 [STAC_92HD73XX_AUTO] = "auto",
1526 [STAC_92HD73XX_NO_JD] = "no-jd",
1527 [STAC_92HD73XX_REF] = "ref",
1528 [STAC_92HD73XX_INTEL] = "intel",
1529 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1530 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1531 [STAC_DELL_M6_BOTH] = "dell-m6",
1532 [STAC_DELL_EQ] = "dell-eq",
1535 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1536 /* SigmaTel reference board */
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1538 "DFI LanParty", STAC_92HD73XX_REF),
1539 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1540 "DFI LanParty", STAC_92HD73XX_REF),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1542 "Intel DG45ID", STAC_92HD73XX_INTEL),
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1544 "Intel DG45FC", STAC_92HD73XX_INTEL),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1546 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1548 "unknown Dell", STAC_DELL_M6_DMIC),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1550 "unknown Dell", STAC_DELL_M6_BOTH),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1552 "unknown Dell", STAC_DELL_M6_BOTH),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1554 "unknown Dell", STAC_DELL_M6_AMIC),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1556 "unknown Dell", STAC_DELL_M6_AMIC),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1558 "unknown Dell", STAC_DELL_M6_DMIC),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1560 "unknown Dell", STAC_DELL_M6_DMIC),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1562 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1564 "Dell Studio 17", STAC_DELL_M6_DMIC),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1566 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1570 static unsigned int ref92hd83xxx_pin_configs[10] = {
1571 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1572 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1573 0x01451160, 0x98560170,
1576 static unsigned int dell_s14_pin_configs[10] = {
1577 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1578 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1579 0x40f000f0, 0x40f000f0,
1582 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1583 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1584 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1585 [STAC_DELL_S14] = dell_s14_pin_configs,
1588 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1589 [STAC_92HD83XXX_AUTO] = "auto",
1590 [STAC_92HD83XXX_REF] = "ref",
1591 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1592 [STAC_DELL_S14] = "dell-s14",
1595 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1596 /* SigmaTel reference board */
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1598 "DFI LanParty", STAC_92HD83XXX_REF),
1599 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1600 "DFI LanParty", STAC_92HD83XXX_REF),
1601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1602 "unknown Dell", STAC_DELL_S14),
1606 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1607 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1608 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1609 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1613 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1614 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1615 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1616 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1620 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1621 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1622 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1623 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1627 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1628 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1629 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1630 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1634 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1635 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1636 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1637 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1638 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1639 [STAC_HP_M4] = NULL,
1640 [STAC_HP_DV5] = NULL,
1641 [STAC_HP_HDX] = NULL,
1642 [STAC_HP_DV4_1222NR] = NULL,
1645 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1646 [STAC_92HD71BXX_AUTO] = "auto",
1647 [STAC_92HD71BXX_REF] = "ref",
1648 [STAC_DELL_M4_1] = "dell-m4-1",
1649 [STAC_DELL_M4_2] = "dell-m4-2",
1650 [STAC_DELL_M4_3] = "dell-m4-3",
1651 [STAC_HP_M4] = "hp-m4",
1652 [STAC_HP_DV5] = "hp-dv5",
1653 [STAC_HP_HDX] = "hp-hdx",
1654 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1657 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1658 /* SigmaTel reference board */
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1660 "DFI LanParty", STAC_92HD71BXX_REF),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1662 "DFI LanParty", STAC_92HD71BXX_REF),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1664 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1665 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1667 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1668 "HP dv4-7", STAC_HP_DV5),
1669 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1670 "HP dv4-7", STAC_HP_DV5),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1672 "HP HDX", STAC_HP_HDX), /* HDX18 */
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1674 "HP mini 1000", STAC_HP_M4),
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1676 "HP HDX", STAC_HP_HDX), /* HDX16 */
1677 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1680 "unknown Dell", STAC_DELL_M4_1),
1681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1682 "unknown Dell", STAC_DELL_M4_1),
1683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1684 "unknown Dell", STAC_DELL_M4_1),
1685 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1686 "unknown Dell", STAC_DELL_M4_1),
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1688 "unknown Dell", STAC_DELL_M4_1),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1690 "unknown Dell", STAC_DELL_M4_1),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1692 "unknown Dell", STAC_DELL_M4_1),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1694 "unknown Dell", STAC_DELL_M4_2),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1696 "unknown Dell", STAC_DELL_M4_2),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1698 "unknown Dell", STAC_DELL_M4_2),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1700 "unknown Dell", STAC_DELL_M4_2),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1702 "unknown Dell", STAC_DELL_M4_3),
1706 static unsigned int ref922x_pin_configs[10] = {
1707 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1708 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1709 0x40000100, 0x40000100,
1713 STAC 922X pin configs for
1720 static unsigned int dell_922x_d81_pin_configs[10] = {
1721 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1722 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1723 0x01813122, 0x400001f2,
1727 STAC 922X pin configs for
1731 static unsigned int dell_922x_d82_pin_configs[10] = {
1732 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1733 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1734 0x01813122, 0x400001f1,
1738 STAC 922X pin configs for
1741 static unsigned int dell_922x_m81_pin_configs[10] = {
1742 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1743 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1744 0x40C003f1, 0x405003f0,
1748 STAC 9221 A1 pin configs for
1749 102801D7 (Dell XPS M1210)
1751 static unsigned int dell_922x_m82_pin_configs[10] = {
1752 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1753 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1754 0x508003f3, 0x405003f4,
1757 static unsigned int d945gtp3_pin_configs[10] = {
1758 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1759 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1760 0x02a19120, 0x40000100,
1763 static unsigned int d945gtp5_pin_configs[10] = {
1764 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1765 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1766 0x02a19320, 0x40000100,
1769 static unsigned int intel_mac_v1_pin_configs[10] = {
1770 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1771 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1772 0x400000fc, 0x400000fb,
1775 static unsigned int intel_mac_v2_pin_configs[10] = {
1776 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1777 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1778 0x400000fc, 0x400000fb,
1781 static unsigned int intel_mac_v3_pin_configs[10] = {
1782 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1783 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1784 0x400000fc, 0x400000fb,
1787 static unsigned int intel_mac_v4_pin_configs[10] = {
1788 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1789 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1790 0x400000fc, 0x400000fb,
1793 static unsigned int intel_mac_v5_pin_configs[10] = {
1794 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1795 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1796 0x400000fc, 0x400000fb,
1799 static unsigned int ecs202_pin_configs[10] = {
1800 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1801 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1802 0x9037012e, 0x40e000f2,
1805 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1806 [STAC_D945_REF] = ref922x_pin_configs,
1807 [STAC_D945GTP3] = d945gtp3_pin_configs,
1808 [STAC_D945GTP5] = d945gtp5_pin_configs,
1809 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1810 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1811 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1812 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1813 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1814 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1815 /* for backward compatibility */
1816 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1817 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1818 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1819 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1820 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1821 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1822 [STAC_ECS_202] = ecs202_pin_configs,
1823 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1824 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1825 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1826 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1829 static const char *stac922x_models[STAC_922X_MODELS] = {
1830 [STAC_922X_AUTO] = "auto",
1831 [STAC_D945_REF] = "ref",
1832 [STAC_D945GTP5] = "5stack",
1833 [STAC_D945GTP3] = "3stack",
1834 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1835 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1836 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1837 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1838 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1839 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1840 /* for backward compatibility */
1841 [STAC_MACMINI] = "macmini",
1842 [STAC_MACBOOK] = "macbook",
1843 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1844 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1845 [STAC_IMAC_INTEL] = "imac-intel",
1846 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1847 [STAC_ECS_202] = "ecs202",
1848 [STAC_922X_DELL_D81] = "dell-d81",
1849 [STAC_922X_DELL_D82] = "dell-d82",
1850 [STAC_922X_DELL_M81] = "dell-m81",
1851 [STAC_922X_DELL_M82] = "dell-m82",
1854 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1855 /* SigmaTel reference board */
1856 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1857 "DFI LanParty", STAC_D945_REF),
1858 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1859 "DFI LanParty", STAC_D945_REF),
1860 /* Intel 945G based systems */
1861 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1862 "Intel D945G", STAC_D945GTP3),
1863 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1864 "Intel D945G", STAC_D945GTP3),
1865 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1866 "Intel D945G", STAC_D945GTP3),
1867 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1868 "Intel D945G", STAC_D945GTP3),
1869 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1870 "Intel D945G", STAC_D945GTP3),
1871 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1872 "Intel D945G", STAC_D945GTP3),
1873 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1874 "Intel D945G", STAC_D945GTP3),
1875 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1876 "Intel D945G", STAC_D945GTP3),
1877 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1878 "Intel D945G", STAC_D945GTP3),
1879 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1880 "Intel D945G", STAC_D945GTP3),
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1882 "Intel D945G", STAC_D945GTP3),
1883 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1884 "Intel D945G", STAC_D945GTP3),
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1886 "Intel D945G", STAC_D945GTP3),
1887 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1888 "Intel D945G", STAC_D945GTP3),
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1890 "Intel D945G", STAC_D945GTP3),
1891 /* Intel D945G 5-stack systems */
1892 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1893 "Intel D945G", STAC_D945GTP5),
1894 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1895 "Intel D945G", STAC_D945GTP5),
1896 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1897 "Intel D945G", STAC_D945GTP5),
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1899 "Intel D945G", STAC_D945GTP5),
1900 /* Intel 945P based systems */
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1902 "Intel D945P", STAC_D945GTP3),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1904 "Intel D945P", STAC_D945GTP3),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1906 "Intel D945P", STAC_D945GTP3),
1907 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1908 "Intel D945P", STAC_D945GTP3),
1909 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1910 "Intel D945P", STAC_D945GTP3),
1911 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1912 "Intel D945P", STAC_D945GTP5),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
1915 "Intel D945", STAC_D945_REF),
1917 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1918 SND_PCI_QUIRK(0x8384, 0x7680,
1919 "Mac", STAC_INTEL_MAC_AUTO),
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1922 "unknown Dell", STAC_922X_DELL_D81),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1924 "unknown Dell", STAC_922X_DELL_D81),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1926 "unknown Dell", STAC_922X_DELL_D81),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1928 "unknown Dell", STAC_922X_DELL_D82),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1930 "unknown Dell", STAC_922X_DELL_M81),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1932 "unknown Dell", STAC_922X_DELL_D82),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1934 "unknown Dell", STAC_922X_DELL_D81),
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1936 "unknown Dell", STAC_922X_DELL_D81),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1938 "Dell XPS M1210", STAC_922X_DELL_M82),
1939 /* ECS/PC Chips boards */
1940 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
1941 "ECS/PC chips", STAC_ECS_202),
1945 static unsigned int ref927x_pin_configs[14] = {
1946 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1947 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1948 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1949 0x01c42190, 0x40000100,
1952 static unsigned int d965_3st_pin_configs[14] = {
1953 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1954 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1955 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1956 0x40000100, 0x40000100
1959 static unsigned int d965_5st_pin_configs[14] = {
1960 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1961 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1962 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1963 0x40000100, 0x40000100
1966 static unsigned int d965_5st_no_fp_pin_configs[14] = {
1967 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
1968 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1969 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1970 0x40000100, 0x40000100
1973 static unsigned int dell_3st_pin_configs[14] = {
1974 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1975 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1976 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1977 0x40c003fc, 0x40000100
1980 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1981 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
1982 [STAC_D965_REF] = ref927x_pin_configs,
1983 [STAC_D965_3ST] = d965_3st_pin_configs,
1984 [STAC_D965_5ST] = d965_5st_pin_configs,
1985 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
1986 [STAC_DELL_3ST] = dell_3st_pin_configs,
1987 [STAC_DELL_BIOS] = NULL,
1990 static const char *stac927x_models[STAC_927X_MODELS] = {
1991 [STAC_927X_AUTO] = "auto",
1992 [STAC_D965_REF_NO_JD] = "ref-no-jd",
1993 [STAC_D965_REF] = "ref",
1994 [STAC_D965_3ST] = "3stack",
1995 [STAC_D965_5ST] = "5stack",
1996 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
1997 [STAC_DELL_3ST] = "dell-3stack",
1998 [STAC_DELL_BIOS] = "dell-bios",
2001 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2002 /* SigmaTel reference board */
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2004 "DFI LanParty", STAC_D965_REF),
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2006 "DFI LanParty", STAC_D965_REF),
2007 /* Intel 946 based systems */
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2010 /* 965 based 3 stack systems */
2011 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2012 "Intel D965", STAC_D965_3ST),
2013 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2014 "Intel D965", STAC_D965_3ST),
2015 /* Dell 3 stack systems */
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2020 /* Dell 3 stack systems with verb table in BIOS */
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2029 /* 965 based 5 stack systems */
2030 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2031 "Intel D965", STAC_D965_5ST),
2032 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2033 "Intel D965", STAC_D965_5ST),
2037 static unsigned int ref9205_pin_configs[12] = {
2038 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2039 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2040 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2044 STAC 9205 pin configs for
2051 10280228 (Dell Vostro 1500)
2053 static unsigned int dell_9205_m42_pin_configs[12] = {
2054 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2055 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2056 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2060 STAC 9205 pin configs for
2064 102801FF (Dell Precision M4300)
2069 static unsigned int dell_9205_m43_pin_configs[12] = {
2070 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2071 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2072 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2075 static unsigned int dell_9205_m44_pin_configs[12] = {
2076 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2077 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2078 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2081 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2082 [STAC_9205_REF] = ref9205_pin_configs,
2083 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2084 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2085 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2086 [STAC_9205_EAPD] = NULL,
2089 static const char *stac9205_models[STAC_9205_MODELS] = {
2090 [STAC_9205_AUTO] = "auto",
2091 [STAC_9205_REF] = "ref",
2092 [STAC_9205_DELL_M42] = "dell-m42",
2093 [STAC_9205_DELL_M43] = "dell-m43",
2094 [STAC_9205_DELL_M44] = "dell-m44",
2095 [STAC_9205_EAPD] = "eapd",
2098 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2099 /* SigmaTel reference board */
2100 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2101 "DFI LanParty", STAC_9205_REF),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2103 "SigmaTel", STAC_9205_REF),
2104 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2105 "DFI LanParty", STAC_9205_REF),
2107 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2108 "unknown Dell", STAC_9205_DELL_M42),
2109 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2110 "unknown Dell", STAC_9205_DELL_M42),
2111 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2112 "Dell Precision", STAC_9205_DELL_M43),
2113 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2114 "Dell Precision", STAC_9205_DELL_M43),
2115 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2116 "Dell Precision", STAC_9205_DELL_M43),
2117 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2118 "unknown Dell", STAC_9205_DELL_M42),
2119 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2120 "unknown Dell", STAC_9205_DELL_M42),
2121 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2122 "Dell Precision", STAC_9205_DELL_M43),
2123 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2124 "Dell Precision M4300", STAC_9205_DELL_M43),
2125 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2126 "unknown Dell", STAC_9205_DELL_M42),
2127 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2128 "Dell Precision", STAC_9205_DELL_M43),
2129 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2130 "Dell Precision", STAC_9205_DELL_M43),
2131 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2132 "Dell Precision", STAC_9205_DELL_M43),
2133 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2134 "Dell Inspiron", STAC_9205_DELL_M44),
2135 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2136 "Dell Vostro 1500", STAC_9205_DELL_M42),
2138 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2139 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2143 static void stac92xx_set_config_regs(struct hda_codec *codec,
2144 unsigned int *pincfgs)
2147 struct sigmatel_spec *spec = codec->spec;
2152 for (i = 0; i < spec->num_pins; i++)
2153 if (spec->pin_nids[i] && pincfgs[i])
2154 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2159 * Analog playback callbacks
2161 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2162 struct hda_codec *codec,
2163 struct snd_pcm_substream *substream)
2165 struct sigmatel_spec *spec = codec->spec;
2166 if (spec->stream_delay)
2167 msleep(spec->stream_delay);
2168 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2172 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2173 struct hda_codec *codec,
2174 unsigned int stream_tag,
2175 unsigned int format,
2176 struct snd_pcm_substream *substream)
2178 struct sigmatel_spec *spec = codec->spec;
2179 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2182 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2183 struct hda_codec *codec,
2184 struct snd_pcm_substream *substream)
2186 struct sigmatel_spec *spec = codec->spec;
2187 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2191 * Digital playback callbacks
2193 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2194 struct hda_codec *codec,
2195 struct snd_pcm_substream *substream)
2197 struct sigmatel_spec *spec = codec->spec;
2198 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2201 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2202 struct hda_codec *codec,
2203 struct snd_pcm_substream *substream)
2205 struct sigmatel_spec *spec = codec->spec;
2206 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2209 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2210 struct hda_codec *codec,
2211 unsigned int stream_tag,
2212 unsigned int format,
2213 struct snd_pcm_substream *substream)
2215 struct sigmatel_spec *spec = codec->spec;
2216 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2217 stream_tag, format, substream);
2220 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2221 struct hda_codec *codec,
2222 struct snd_pcm_substream *substream)
2224 struct sigmatel_spec *spec = codec->spec;
2225 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2230 * Analog capture callbacks
2232 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2233 struct hda_codec *codec,
2234 unsigned int stream_tag,
2235 unsigned int format,
2236 struct snd_pcm_substream *substream)
2238 struct sigmatel_spec *spec = codec->spec;
2239 hda_nid_t nid = spec->adc_nids[substream->number];
2241 if (spec->powerdown_adcs) {
2243 snd_hda_codec_write(codec, nid, 0,
2244 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2246 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2250 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2251 struct hda_codec *codec,
2252 struct snd_pcm_substream *substream)
2254 struct sigmatel_spec *spec = codec->spec;
2255 hda_nid_t nid = spec->adc_nids[substream->number];
2257 snd_hda_codec_cleanup_stream(codec, nid);
2258 if (spec->powerdown_adcs)
2259 snd_hda_codec_write(codec, nid, 0,
2260 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2264 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2268 /* NID is set in stac92xx_build_pcms */
2270 .open = stac92xx_dig_playback_pcm_open,
2271 .close = stac92xx_dig_playback_pcm_close,
2272 .prepare = stac92xx_dig_playback_pcm_prepare,
2273 .cleanup = stac92xx_dig_playback_pcm_cleanup
2277 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2281 /* NID is set in stac92xx_build_pcms */
2284 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2288 .nid = 0x02, /* NID to query formats and rates */
2290 .open = stac92xx_playback_pcm_open,
2291 .prepare = stac92xx_playback_pcm_prepare,
2292 .cleanup = stac92xx_playback_pcm_cleanup
2296 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2300 .nid = 0x06, /* NID to query formats and rates */
2302 .open = stac92xx_playback_pcm_open,
2303 .prepare = stac92xx_playback_pcm_prepare,
2304 .cleanup = stac92xx_playback_pcm_cleanup
2308 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2311 /* NID + .substreams is set in stac92xx_build_pcms */
2313 .prepare = stac92xx_capture_pcm_prepare,
2314 .cleanup = stac92xx_capture_pcm_cleanup
2318 static int stac92xx_build_pcms(struct hda_codec *codec)
2320 struct sigmatel_spec *spec = codec->spec;
2321 struct hda_pcm *info = spec->pcm_rec;
2323 codec->num_pcms = 1;
2324 codec->pcm_info = info;
2326 info->name = "STAC92xx Analog";
2327 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2328 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2329 spec->multiout.dac_nids[0];
2330 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2331 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2332 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2334 if (spec->alt_switch) {
2337 info->name = "STAC92xx Analog Alt";
2338 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2341 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2344 info->name = "STAC92xx Digital";
2345 info->pcm_type = spec->autocfg.dig_out_type[0];
2346 if (spec->multiout.dig_out_nid) {
2347 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2348 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2350 if (spec->dig_in_nid) {
2351 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2352 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2359 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2362 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2363 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2364 if (pincap & AC_PINCAP_VREF_100)
2365 return AC_PINCTL_VREF_100;
2366 if (pincap & AC_PINCAP_VREF_80)
2367 return AC_PINCTL_VREF_80;
2368 if (pincap & AC_PINCAP_VREF_50)
2369 return AC_PINCTL_VREF_50;
2370 if (pincap & AC_PINCAP_VREF_GRD)
2371 return AC_PINCTL_VREF_GRD;
2375 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2378 snd_hda_codec_write_cache(codec, nid, 0,
2379 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2382 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2384 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2385 struct snd_ctl_elem_value *ucontrol)
2387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2388 struct sigmatel_spec *spec = codec->spec;
2390 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2394 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2396 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2397 struct snd_ctl_elem_value *ucontrol)
2399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2400 struct sigmatel_spec *spec = codec->spec;
2401 int nid = kcontrol->private_value;
2403 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2405 /* check to be sure that the ports are upto date with
2408 stac_issue_unsol_event(codec, nid);
2413 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2414 struct snd_ctl_elem_info *uinfo)
2417 static char *texts[] = {
2418 "Mic In", "Line In", "Line Out"
2421 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2422 struct sigmatel_spec *spec = codec->spec;
2423 hda_nid_t nid = kcontrol->private_value;
2425 if (nid == spec->mic_switch || nid == spec->line_switch)
2430 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2431 uinfo->value.enumerated.items = i;
2433 if (uinfo->value.enumerated.item >= i)
2434 uinfo->value.enumerated.item = i-1;
2435 strcpy(uinfo->value.enumerated.name,
2436 texts[uinfo->value.enumerated.item]);
2441 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2442 struct snd_ctl_elem_value *ucontrol)
2444 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2445 hda_nid_t nid = kcontrol->private_value;
2446 unsigned int vref = stac92xx_vref_get(codec, nid);
2448 if (vref == stac92xx_get_default_vref(codec, nid))
2449 ucontrol->value.enumerated.item[0] = 0;
2450 else if (vref == AC_PINCTL_VREF_GRD)
2451 ucontrol->value.enumerated.item[0] = 1;
2452 else if (vref == AC_PINCTL_VREF_HIZ)
2453 ucontrol->value.enumerated.item[0] = 2;
2458 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2459 struct snd_ctl_elem_value *ucontrol)
2461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2462 unsigned int new_vref = 0;
2464 hda_nid_t nid = kcontrol->private_value;
2466 if (ucontrol->value.enumerated.item[0] == 0)
2467 new_vref = stac92xx_get_default_vref(codec, nid);
2468 else if (ucontrol->value.enumerated.item[0] == 1)
2469 new_vref = AC_PINCTL_VREF_GRD;
2470 else if (ucontrol->value.enumerated.item[0] == 2)
2471 new_vref = AC_PINCTL_VREF_HIZ;
2475 if (new_vref != stac92xx_vref_get(codec, nid)) {
2476 error = stac92xx_vref_set(codec, nid, new_vref);
2483 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2484 struct snd_ctl_elem_info *uinfo)
2486 static char *texts[2];
2487 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2488 struct sigmatel_spec *spec = codec->spec;
2490 if (kcontrol->private_value == spec->line_switch)
2491 texts[0] = "Line In";
2493 texts[0] = "Mic In";
2494 texts[1] = "Line Out";
2495 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2496 uinfo->value.enumerated.items = 2;
2499 if (uinfo->value.enumerated.item >= 2)
2500 uinfo->value.enumerated.item = 1;
2501 strcpy(uinfo->value.enumerated.name,
2502 texts[uinfo->value.enumerated.item]);
2507 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2509 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2510 struct sigmatel_spec *spec = codec->spec;
2511 hda_nid_t nid = kcontrol->private_value;
2512 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2514 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2518 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2521 struct sigmatel_spec *spec = codec->spec;
2522 hda_nid_t nid = kcontrol->private_value;
2523 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2524 unsigned short val = !!ucontrol->value.enumerated.item[0];
2526 spec->io_switch[io_idx] = val;
2529 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2531 unsigned int pinctl = AC_PINCTL_IN_EN;
2532 if (io_idx) /* set VREF for mic */
2533 pinctl |= stac92xx_get_default_vref(codec, nid);
2534 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2537 /* check the auto-mute again: we need to mute/unmute the speaker
2538 * appropriately according to the pin direction
2540 if (spec->hp_detect)
2541 stac_issue_unsol_event(codec, nid);
2546 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2548 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2549 struct snd_ctl_elem_value *ucontrol)
2551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2552 struct sigmatel_spec *spec = codec->spec;
2554 ucontrol->value.integer.value[0] = spec->clfe_swap;
2558 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2559 struct snd_ctl_elem_value *ucontrol)
2561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2562 struct sigmatel_spec *spec = codec->spec;
2563 hda_nid_t nid = kcontrol->private_value & 0xff;
2564 unsigned int val = !!ucontrol->value.integer.value[0];
2566 if (spec->clfe_swap == val)
2569 spec->clfe_swap = val;
2571 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2572 spec->clfe_swap ? 0x4 : 0x0);
2577 #define STAC_CODEC_HP_SWITCH(xname) \
2578 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2581 .info = stac92xx_hp_switch_info, \
2582 .get = stac92xx_hp_switch_get, \
2583 .put = stac92xx_hp_switch_put, \
2586 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2587 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2590 .info = stac92xx_io_switch_info, \
2591 .get = stac92xx_io_switch_get, \
2592 .put = stac92xx_io_switch_put, \
2593 .private_value = xpval, \
2596 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2597 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2600 .info = stac92xx_clfe_switch_info, \
2601 .get = stac92xx_clfe_switch_get, \
2602 .put = stac92xx_clfe_switch_put, \
2603 .private_value = xpval, \
2607 STAC_CTL_WIDGET_VOL,
2608 STAC_CTL_WIDGET_MUTE,
2609 STAC_CTL_WIDGET_MONO_MUX,
2610 STAC_CTL_WIDGET_HP_SWITCH,
2611 STAC_CTL_WIDGET_IO_SWITCH,
2612 STAC_CTL_WIDGET_CLFE_SWITCH,
2613 STAC_CTL_WIDGET_DC_BIAS
2616 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2617 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2618 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2620 STAC_CODEC_HP_SWITCH(NULL),
2621 STAC_CODEC_IO_SWITCH(NULL, 0),
2622 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2623 DC_BIAS(NULL, 0, 0),
2626 /* add dynamic controls */
2627 static struct snd_kcontrol_new *
2628 stac_control_new(struct sigmatel_spec *spec,
2629 struct snd_kcontrol_new *ktemp,
2632 struct snd_kcontrol_new *knew;
2634 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2635 knew = snd_array_new(&spec->kctls);
2639 knew->name = kstrdup(name, GFP_KERNEL);
2642 memset(knew, 0, sizeof(*knew));
2643 spec->kctls.alloced--;
2649 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2650 struct snd_kcontrol_new *ktemp,
2651 int idx, const char *name,
2654 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2658 knew->private_value = val;
2662 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2663 int type, int idx, const char *name,
2666 return stac92xx_add_control_temp(spec,
2667 &stac92xx_control_templates[type],
2672 /* add dynamic controls */
2673 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2674 const char *name, unsigned long val)
2676 return stac92xx_add_control_idx(spec, type, 0, name, val);
2679 static struct snd_kcontrol_new stac_input_src_temp = {
2680 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2681 .name = "Input Source",
2682 .info = stac92xx_mux_enum_info,
2683 .get = stac92xx_mux_enum_get,
2684 .put = stac92xx_mux_enum_put,
2687 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2688 hda_nid_t nid, int idx)
2690 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2692 struct sigmatel_spec *spec = codec->spec;
2695 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2696 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2697 && nid == spec->line_switch)
2698 control = STAC_CTL_WIDGET_IO_SWITCH;
2699 else if (snd_hda_query_pin_caps(codec, nid)
2700 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2701 control = STAC_CTL_WIDGET_DC_BIAS;
2702 else if (nid == spec->mic_switch)
2703 control = STAC_CTL_WIDGET_IO_SWITCH;
2707 strcpy(name, auto_pin_cfg_labels[idx]);
2708 return stac92xx_add_control(codec->spec, control,
2709 strcat(name, " Jack Mode"), nid);
2715 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2717 struct snd_kcontrol_new *knew;
2718 struct hda_input_mux *imux = &spec->private_imux;
2721 return 0; /* no need for input source */
2722 if (!spec->num_adcs || imux->num_items <= 1)
2723 return 0; /* no need for input source control */
2724 knew = stac_control_new(spec, &stac_input_src_temp,
2725 stac_input_src_temp.name);
2728 knew->count = spec->num_adcs;
2732 /* check whether the line-input can be used as line-out */
2733 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2735 struct sigmatel_spec *spec = codec->spec;
2736 struct auto_pin_cfg *cfg = &spec->autocfg;
2738 unsigned int pincap;
2740 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2742 nid = cfg->input_pins[AUTO_PIN_LINE];
2743 pincap = snd_hda_query_pin_caps(codec, nid);
2744 if (pincap & AC_PINCAP_OUT)
2749 /* check whether the mic-input can be used as line-out */
2750 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2752 struct sigmatel_spec *spec = codec->spec;
2753 struct auto_pin_cfg *cfg = &spec->autocfg;
2754 unsigned int def_conf, pincap;
2755 unsigned int mic_pin;
2757 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2759 mic_pin = AUTO_PIN_MIC;
2761 hda_nid_t nid = cfg->input_pins[mic_pin];
2762 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2763 /* some laptops have an internal analog microphone
2764 * which can't be used as a output */
2765 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2766 pincap = snd_hda_query_pin_caps(codec, nid);
2767 if (pincap & AC_PINCAP_OUT)
2770 if (mic_pin == AUTO_PIN_MIC)
2771 mic_pin = AUTO_PIN_FRONT_MIC;
2778 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2782 for (i = 0; i < spec->multiout.num_dacs; i++) {
2783 if (spec->multiout.dac_nids[i] == nid)
2790 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2793 if (is_in_dac_nids(spec, nid))
2795 for (i = 0; i < spec->autocfg.hp_outs; i++)
2796 if (spec->hp_dacs[i] == nid)
2798 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2799 if (spec->speaker_dacs[i] == nid)
2804 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2806 struct sigmatel_spec *spec = codec->spec;
2808 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2809 unsigned int wcaps, wtype;
2811 conn_len = snd_hda_get_connections(codec, nid, conn,
2812 HDA_MAX_CONNECTIONS);
2813 for (j = 0; j < conn_len; j++) {
2814 wcaps = get_wcaps(codec, conn[j]);
2815 wtype = get_wcaps_type(wcaps);
2816 /* we check only analog outputs */
2817 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2819 /* if this route has a free DAC, assign it */
2820 if (!check_all_dac_nids(spec, conn[j])) {
2822 /* select this DAC in the pin's input mux */
2823 snd_hda_codec_write_cache(codec, nid, 0,
2824 AC_VERB_SET_CONNECT_SEL, j);
2829 /* if all DACs are already assigned, connect to the primary DAC */
2831 for (j = 0; j < conn_len; j++) {
2832 if (conn[j] == spec->multiout.dac_nids[0]) {
2833 snd_hda_codec_write_cache(codec, nid, 0,
2834 AC_VERB_SET_CONNECT_SEL, j);
2842 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2843 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2846 * Fill in the dac_nids table from the parsed pin configuration
2847 * This function only works when every pin in line_out_pins[]
2848 * contains atleast one DAC in its connection list. Some 92xx
2849 * codecs are not connected directly to a DAC, such as the 9200
2850 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2852 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2854 struct sigmatel_spec *spec = codec->spec;
2855 struct auto_pin_cfg *cfg = &spec->autocfg;
2859 for (i = 0; i < cfg->line_outs; i++) {
2860 nid = cfg->line_out_pins[i];
2861 dac = get_unassigned_dac(codec, nid);
2863 if (spec->multiout.num_dacs > 0) {
2864 /* we have already working output pins,
2865 * so let's drop the broken ones again
2867 cfg->line_outs = spec->multiout.num_dacs;
2870 /* error out, no available DAC found */
2872 "%s: No available DAC for pin 0x%x\n",
2876 add_spec_dacs(spec, dac);
2879 for (i = 0; i < cfg->hp_outs; i++) {
2880 nid = cfg->hp_pins[i];
2881 dac = get_unassigned_dac(codec, nid);
2883 if (!spec->multiout.hp_nid)
2884 spec->multiout.hp_nid = dac;
2886 add_spec_extra_dacs(spec, dac);
2888 spec->hp_dacs[i] = dac;
2891 for (i = 0; i < cfg->speaker_outs; i++) {
2892 nid = cfg->speaker_pins[i];
2893 dac = get_unassigned_dac(codec, nid);
2895 add_spec_extra_dacs(spec, dac);
2896 spec->speaker_dacs[i] = dac;
2899 /* add line-in as output */
2900 nid = check_line_out_switch(codec);
2902 dac = get_unassigned_dac(codec, nid);
2904 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2905 nid, cfg->line_outs);
2906 cfg->line_out_pins[cfg->line_outs] = nid;
2908 spec->line_switch = nid;
2909 add_spec_dacs(spec, dac);
2912 /* add mic as output */
2913 nid = check_mic_out_switch(codec);
2915 dac = get_unassigned_dac(codec, nid);
2917 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2918 nid, cfg->line_outs);
2919 cfg->line_out_pins[cfg->line_outs] = nid;
2921 spec->mic_switch = nid;
2922 add_spec_dacs(spec, dac);
2926 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2927 spec->multiout.num_dacs,
2928 spec->multiout.dac_nids[0],
2929 spec->multiout.dac_nids[1],
2930 spec->multiout.dac_nids[2],
2931 spec->multiout.dac_nids[3],
2932 spec->multiout.dac_nids[4]);
2937 /* create volume control/switch for the given prefx type */
2938 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
2939 int idx, hda_nid_t nid, int chs)
2941 struct sigmatel_spec *spec = codec->spec;
2945 if (!spec->check_volume_offset) {
2946 unsigned int caps, step, nums, db_scale;
2947 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2948 step = (caps & AC_AMPCAP_STEP_SIZE) >>
2949 AC_AMPCAP_STEP_SIZE_SHIFT;
2950 step = (step + 1) * 25; /* in .01dB unit */
2951 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
2952 AC_AMPCAP_NUM_STEPS_SHIFT;
2953 db_scale = nums * step;
2954 /* if dB scale is over -64dB, and finer enough,
2955 * let's reduce it to half
2957 if (db_scale > 6400 && nums >= 0x1f)
2958 spec->volume_offset = nums / 2;
2959 spec->check_volume_offset = 1;
2962 sprintf(name, "%s Playback Volume", pfx);
2963 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
2964 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
2965 spec->volume_offset));
2968 sprintf(name, "%s Playback Switch", pfx);
2969 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
2970 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2976 #define create_controls(codec, pfx, nid, chs) \
2977 create_controls_idx(codec, pfx, 0, nid, chs)
2979 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2981 if (spec->multiout.num_dacs > 4) {
2982 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2985 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2986 spec->multiout.num_dacs++;
2991 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2994 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
2995 if (!spec->multiout.extra_out_nid[i]) {
2996 spec->multiout.extra_out_nid[i] = nid;
3000 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3004 /* Create output controls
3005 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3007 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3008 const hda_nid_t *pins,
3009 const hda_nid_t *dac_nids,
3012 struct sigmatel_spec *spec = codec->spec;
3013 static const char *chname[4] = {
3014 "Front", "Surround", NULL /*CLFE*/, "Side"
3018 unsigned int wid_caps;
3020 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3021 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3022 wid_caps = get_wcaps(codec, pins[i]);
3023 if (wid_caps & AC_WCAP_UNSOL_CAP)
3024 spec->hp_detect = 1;
3029 if (type != AUTO_PIN_HP_OUT && i == 2) {
3031 err = create_controls(codec, "Center", nid, 1);
3034 err = create_controls(codec, "LFE", nid, 2);
3038 wid_caps = get_wcaps(codec, nid);
3040 if (wid_caps & AC_WCAP_LR_SWAP) {
3041 err = stac92xx_add_control(spec,
3042 STAC_CTL_WIDGET_CLFE_SWITCH,
3043 "Swap Center/LFE Playback Switch", nid);
3053 case AUTO_PIN_HP_OUT:
3057 case AUTO_PIN_SPEAKER_OUT:
3066 err = create_controls_idx(codec, name, idx, nid, 3);
3074 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3075 unsigned long sw, int idx)
3078 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3079 "Capture Volume", vol);
3082 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3083 "Capture Switch", sw);
3089 /* add playback controls from the parsed DAC table */
3090 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3091 const struct auto_pin_cfg *cfg)
3093 struct sigmatel_spec *spec = codec->spec;
3098 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3099 spec->multiout.dac_nids,
3100 cfg->line_out_type);
3104 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3105 err = stac92xx_add_control(spec,
3106 STAC_CTL_WIDGET_HP_SWITCH,
3107 "Headphone as Line Out Switch",
3108 cfg->hp_pins[cfg->hp_outs - 1]);
3113 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3114 nid = cfg->input_pins[idx];
3116 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3125 /* add playback controls for Speaker and HP outputs */
3126 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3127 struct auto_pin_cfg *cfg)
3129 struct sigmatel_spec *spec = codec->spec;
3132 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3133 spec->hp_dacs, AUTO_PIN_HP_OUT);
3137 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3138 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3145 /* labels for mono mux outputs */
3146 static const char *stac92xx_mono_labels[4] = {
3147 "DAC0", "DAC1", "Mixer", "DAC2"
3150 /* create mono mux for mono out on capable codecs */
3151 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3153 struct sigmatel_spec *spec = codec->spec;
3154 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3156 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3158 num_cons = snd_hda_get_connections(codec,
3161 HDA_MAX_NUM_INPUTS);
3162 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3165 for (i = 0; i < num_cons; i++) {
3166 mono_mux->items[mono_mux->num_items].label =
3167 stac92xx_mono_labels[i];
3168 mono_mux->items[mono_mux->num_items].index = i;
3169 mono_mux->num_items++;
3172 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3173 "Mono Mux", spec->mono_nid);
3176 /* create PC beep volume controls */
3177 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3180 struct sigmatel_spec *spec = codec->spec;
3181 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3184 /* check for mute support for the the amp */
3185 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3186 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3187 "PC Beep Playback Switch",
3188 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3193 /* check to see if there is volume support for the amp */
3194 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3195 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3196 "PC Beep Playback Volume",
3197 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3204 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3205 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3207 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3208 struct snd_ctl_elem_value *ucontrol)
3210 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3211 ucontrol->value.integer.value[0] = codec->beep->enabled;
3215 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3216 struct snd_ctl_elem_value *ucontrol)
3218 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3219 int enabled = !!ucontrol->value.integer.value[0];
3220 if (codec->beep->enabled != enabled) {
3221 codec->beep->enabled = enabled;
3227 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3228 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3229 .info = stac92xx_dig_beep_switch_info,
3230 .get = stac92xx_dig_beep_switch_get,
3231 .put = stac92xx_dig_beep_switch_put,
3234 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3236 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3237 0, "PC Beep Playback Switch", 0);
3241 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3243 struct sigmatel_spec *spec = codec->spec;
3246 for (i = 0; i < spec->num_muxes; i++) {
3251 nid = spec->mux_nids[i];
3252 wcaps = get_wcaps(codec, nid);
3253 if (!(wcaps & AC_WCAP_OUT_AMP))
3256 /* check whether already the same control was created as
3257 * normal Capture Volume.
3259 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3260 for (j = 0; j < spec->num_caps; j++) {
3261 if (spec->capvols[j] == val)
3264 if (j < spec->num_caps)
3267 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3268 "Mux Capture Volume", val);
3275 static const char *stac92xx_spdif_labels[3] = {
3276 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3279 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3281 struct sigmatel_spec *spec = codec->spec;
3282 struct hda_input_mux *spdif_mux = &spec->private_smux;
3283 const char **labels = spec->spdif_labels;
3285 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3287 num_cons = snd_hda_get_connections(codec,
3290 HDA_MAX_NUM_INPUTS);
3295 labels = stac92xx_spdif_labels;
3297 for (i = 0; i < num_cons; i++) {
3298 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3299 spdif_mux->items[spdif_mux->num_items].index = i;
3300 spdif_mux->num_items++;
3306 /* labels for dmic mux inputs */
3307 static const char *stac92xx_dmic_labels[5] = {
3308 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3309 "Digital Mic 3", "Digital Mic 4"
3312 static int get_connection_index(struct hda_codec *cod