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 */
93 STAC_92HD83XXX_PWR_REF,
108 STAC_92HD71BXX_MODELS
134 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
135 * is given, one of the above models will be
136 * chosen according to the subsystem id. */
137 /* for backward compatibility */
154 STAC_D965_REF_NO_JD, /* no jack-detection */
170 struct sigmatel_event {
177 struct sigmatel_jack {
180 struct snd_jack *jack;
183 struct sigmatel_mic_route {
185 unsigned char mux_idx;
186 unsigned char dmux_idx;
189 struct sigmatel_spec {
190 struct snd_kcontrol_new *mixers[4];
191 unsigned int num_mixers;
194 unsigned int eapd_switch: 1;
195 unsigned int surr_switch: 1;
196 unsigned int alt_switch: 1;
197 unsigned int hp_detect: 1;
198 unsigned int spdif_mute: 1;
199 unsigned int check_volume_offset:1;
200 unsigned int auto_mic:1;
203 unsigned int eapd_mask;
204 unsigned int gpio_mask;
205 unsigned int gpio_dir;
206 unsigned int gpio_data;
207 unsigned int gpio_mute;
208 unsigned int gpio_led;
211 unsigned int stream_delay;
213 /* analog loopback */
214 struct snd_kcontrol_new *aloopback_ctl;
215 unsigned char aloopback_mask;
216 unsigned char aloopback_shift;
218 /* power management */
219 unsigned int num_pwrs;
220 unsigned int *pwr_mapping;
225 struct snd_array jacks;
228 struct snd_array events;
231 struct hda_input_mux *mono_mux;
232 unsigned int cur_mmux;
233 struct hda_multi_out multiout;
234 hda_nid_t dac_nids[5];
235 hda_nid_t hp_dacs[5];
236 hda_nid_t speaker_dacs[5];
242 unsigned int num_adcs;
244 unsigned int num_muxes;
245 hda_nid_t *dmic_nids;
246 unsigned int num_dmics;
247 hda_nid_t *dmux_nids;
248 unsigned int num_dmuxes;
249 hda_nid_t *smux_nids;
250 unsigned int num_smuxes;
251 unsigned int num_analog_muxes;
253 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
254 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
255 unsigned int num_caps; /* number of capture volume/switch elements */
257 struct sigmatel_mic_route ext_mic;
258 struct sigmatel_mic_route int_mic;
260 const char **spdif_labels;
262 hda_nid_t dig_in_nid;
264 hda_nid_t anabeep_nid;
265 hda_nid_t digbeep_nid;
269 unsigned int num_pins;
271 /* codec specific stuff */
272 struct hda_verb *init;
273 struct snd_kcontrol_new *mixer;
276 struct hda_input_mux *dinput_mux;
277 unsigned int cur_dmux[2];
278 struct hda_input_mux *input_mux;
279 unsigned int cur_mux[3];
280 struct hda_input_mux *sinput_mux;
281 unsigned int cur_smux[2];
282 unsigned int cur_amux;
284 unsigned int powerdown_adcs;
287 unsigned int io_switch[2];
288 unsigned int clfe_swap;
289 hda_nid_t line_switch; /* shared line-in for input and output */
290 hda_nid_t mic_switch; /* shared mic-in for input and output */
291 hda_nid_t hp_switch; /* NID of HP as line-out */
292 unsigned int aloopback;
294 struct hda_pcm pcm_rec[2]; /* PCM information */
296 /* dynamic controls and input_mux */
297 struct auto_pin_cfg autocfg;
298 struct snd_array kctls;
299 struct hda_input_mux private_dimux;
300 struct hda_input_mux private_imux;
301 struct hda_input_mux private_smux;
302 struct hda_input_mux private_mono_mux;
305 static hda_nid_t stac9200_adc_nids[1] = {
309 static hda_nid_t stac9200_mux_nids[1] = {
313 static hda_nid_t stac9200_dac_nids[1] = {
317 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
318 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
322 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
326 static hda_nid_t stac92hd73xx_adc_nids[2] = {
330 #define STAC92HD73XX_NUM_DMICS 2
331 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
335 #define STAC92HD73_DAC_COUNT 5
337 static hda_nid_t stac92hd73xx_mux_nids[2] = {
341 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
345 static hda_nid_t stac92hd73xx_smux_nids[2] = {
349 #define STAC92HD73XX_NUM_CAPS 2
350 static unsigned long stac92hd73xx_capvols[] = {
351 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
352 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
354 #define stac92hd73xx_capsws stac92hd73xx_capvols
356 #define STAC92HD83_DAC_COUNT 3
358 static hda_nid_t stac92hd83xxx_mux_nids[2] = {
362 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
366 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
370 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
374 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
375 0x03, 0x0c, 0x20, 0x40,
378 #define STAC92HD83XXX_NUM_CAPS 2
379 static unsigned long stac92hd83xxx_capvols[] = {
380 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
381 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
383 #define stac92hd83xxx_capsws stac92hd83xxx_capvols
385 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
389 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
393 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
397 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
401 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
405 #define STAC92HD71BXX_NUM_DMICS 2
406 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
410 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
414 #define STAC92HD71BXX_NUM_CAPS 2
415 static unsigned long stac92hd71bxx_capvols[] = {
416 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
417 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
419 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
421 static hda_nid_t stac925x_adc_nids[1] = {
425 static hda_nid_t stac925x_mux_nids[1] = {
429 static hda_nid_t stac925x_dac_nids[1] = {
433 #define STAC925X_NUM_DMICS 1
434 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
438 static hda_nid_t stac925x_dmux_nids[1] = {
442 static unsigned long stac925x_capvols[] = {
443 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
445 static unsigned long stac925x_capsws[] = {
446 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
449 static hda_nid_t stac922x_adc_nids[2] = {
453 static hda_nid_t stac922x_mux_nids[2] = {
457 #define STAC922X_NUM_CAPS 2
458 static unsigned long stac922x_capvols[] = {
459 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
460 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
462 #define stac922x_capsws stac922x_capvols
464 static hda_nid_t stac927x_slave_dig_outs[2] = {
468 static hda_nid_t stac927x_adc_nids[3] = {
472 static hda_nid_t stac927x_mux_nids[3] = {
476 static hda_nid_t stac927x_smux_nids[1] = {
480 static hda_nid_t stac927x_dac_nids[6] = {
481 0x02, 0x03, 0x04, 0x05, 0x06, 0
484 static hda_nid_t stac927x_dmux_nids[1] = {
488 #define STAC927X_NUM_DMICS 2
489 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
493 #define STAC927X_NUM_CAPS 3
494 static unsigned long stac927x_capvols[] = {
495 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
496 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
497 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
499 static unsigned long stac927x_capsws[] = {
500 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
501 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
502 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
505 static const char *stac927x_spdif_labels[5] = {
506 "Digital Playback", "ADAT", "Analog Mux 1",
507 "Analog Mux 2", "Analog Mux 3"
510 static hda_nid_t stac9205_adc_nids[2] = {
514 static hda_nid_t stac9205_mux_nids[2] = {
518 static hda_nid_t stac9205_dmux_nids[1] = {
522 static hda_nid_t stac9205_smux_nids[1] = {
526 #define STAC9205_NUM_DMICS 2
527 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
531 #define STAC9205_NUM_CAPS 2
532 static unsigned long stac9205_capvols[] = {
533 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
534 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
536 static unsigned long stac9205_capsws[] = {
537 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
538 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
541 static hda_nid_t stac9200_pin_nids[8] = {
542 0x08, 0x09, 0x0d, 0x0e,
543 0x0f, 0x10, 0x11, 0x12,
546 static hda_nid_t stac925x_pin_nids[8] = {
547 0x07, 0x08, 0x0a, 0x0b,
548 0x0c, 0x0d, 0x10, 0x11,
551 static hda_nid_t stac922x_pin_nids[10] = {
552 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
553 0x0f, 0x10, 0x11, 0x15, 0x1b,
556 static hda_nid_t stac92hd73xx_pin_nids[13] = {
557 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
558 0x0f, 0x10, 0x11, 0x12, 0x13,
562 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
563 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
564 0x0f, 0x10, 0x11, 0x1f, 0x20,
567 #define STAC92HD71BXX_NUM_PINS 13
568 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
569 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
570 0x00, 0x14, 0x18, 0x19, 0x1e,
573 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
574 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
575 0x0f, 0x14, 0x18, 0x19, 0x1e,
579 static hda_nid_t stac927x_pin_nids[14] = {
580 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
581 0x0f, 0x10, 0x11, 0x12, 0x13,
582 0x14, 0x21, 0x22, 0x23,
585 static hda_nid_t stac9205_pin_nids[12] = {
586 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
587 0x0f, 0x14, 0x16, 0x17, 0x18,
591 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
592 struct snd_ctl_elem_info *uinfo)
594 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
595 struct sigmatel_spec *spec = codec->spec;
596 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
599 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
600 struct snd_ctl_elem_value *ucontrol)
602 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
603 struct sigmatel_spec *spec = codec->spec;
604 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
606 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
610 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
611 struct snd_ctl_elem_value *ucontrol)
613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
614 struct sigmatel_spec *spec = codec->spec;
615 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
617 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
618 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
621 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_info *uinfo)
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct sigmatel_spec *spec = codec->spec;
626 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
629 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
630 struct snd_ctl_elem_value *ucontrol)
632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
633 struct sigmatel_spec *spec = codec->spec;
634 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
636 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
640 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 struct sigmatel_spec *spec = codec->spec;
645 struct hda_input_mux *smux = &spec->private_smux;
646 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
650 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
651 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
655 if (spec->spdif_mute) {
657 nid = spec->multiout.dig_out_nid;
659 nid = codec->slave_dig_outs[smux_idx - 1];
660 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
664 /* un/mute SPDIF out */
665 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
671 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
672 hda_nid_t nid, unsigned int new_vref)
676 pincfg = snd_hda_codec_read(codec, nid, 0,
677 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
680 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
683 if (new_vref == AC_PINCTL_VREF_HIZ)
684 pincfg |= AC_PINCTL_OUT_EN;
686 pincfg |= AC_PINCTL_IN_EN;
688 error = snd_hda_codec_write_cache(codec, nid, 0,
689 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
696 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
699 vref = snd_hda_codec_read(codec, nid, 0,
700 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
701 vref &= AC_PINCTL_VREFEN;
705 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
707 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
708 struct sigmatel_spec *spec = codec->spec;
709 return snd_hda_input_mux_info(spec->input_mux, uinfo);
712 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
714 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
715 struct sigmatel_spec *spec = codec->spec;
716 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
718 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
722 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
724 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
725 struct sigmatel_spec *spec = codec->spec;
726 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
727 const struct hda_input_mux *imux = spec->input_mux;
728 unsigned int idx, prev_idx;
730 idx = ucontrol->value.enumerated.item[0];
731 if (idx >= imux->num_items)
732 idx = imux->num_items - 1;
733 prev_idx = spec->cur_mux[adc_idx];
736 if (idx < spec->num_analog_muxes) {
737 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
738 AC_VERB_SET_CONNECT_SEL,
739 imux->items[idx].index);
740 if (prev_idx >= spec->num_analog_muxes) {
741 imux = spec->dinput_mux;
743 snd_hda_codec_write_cache(codec,
744 spec->dmux_nids[adc_idx], 0,
745 AC_VERB_SET_CONNECT_SEL,
746 imux->items[0].index);
749 imux = spec->dinput_mux;
750 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
751 AC_VERB_SET_CONNECT_SEL,
752 imux->items[idx - 1].index);
754 spec->cur_mux[adc_idx] = idx;
758 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
759 struct snd_ctl_elem_info *uinfo)
761 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
762 struct sigmatel_spec *spec = codec->spec;
763 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
766 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
767 struct snd_ctl_elem_value *ucontrol)
769 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
770 struct sigmatel_spec *spec = codec->spec;
772 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
776 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
777 struct snd_ctl_elem_value *ucontrol)
779 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
780 struct sigmatel_spec *spec = codec->spec;
782 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
783 spec->mono_nid, &spec->cur_mmux);
786 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
788 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
789 struct snd_ctl_elem_value *ucontrol)
791 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
792 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
793 struct sigmatel_spec *spec = codec->spec;
795 ucontrol->value.integer.value[0] = !!(spec->aloopback &
796 (spec->aloopback_mask << idx));
800 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
801 struct snd_ctl_elem_value *ucontrol)
803 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
804 struct sigmatel_spec *spec = codec->spec;
805 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
806 unsigned int dac_mode;
807 unsigned int val, idx_val;
809 idx_val = spec->aloopback_mask << idx;
810 if (ucontrol->value.integer.value[0])
811 val = spec->aloopback | idx_val;
813 val = spec->aloopback & ~idx_val;
814 if (spec->aloopback == val)
817 spec->aloopback = val;
819 /* Only return the bits defined by the shift value of the
820 * first two bytes of the mask
822 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
823 kcontrol->private_value & 0xFFFF, 0x0);
824 dac_mode >>= spec->aloopback_shift;
826 if (spec->aloopback & idx_val) {
827 snd_hda_power_up(codec);
830 snd_hda_power_down(codec);
831 dac_mode &= ~idx_val;
834 snd_hda_codec_write_cache(codec, codec->afg, 0,
835 kcontrol->private_value >> 16, dac_mode);
840 static struct hda_verb stac9200_core_init[] = {
841 /* set dac0mux for dac converter */
842 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
846 static struct hda_verb stac9200_eapd_init[] = {
847 /* set dac0mux for dac converter */
848 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
849 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
853 static struct hda_verb dell_eq_core_init[] = {
854 /* set master volume to max value without distortion
855 * and direct control */
856 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
860 static struct hda_verb stac92hd73xx_core_init[] = {
861 /* set master volume and direct control */
862 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
866 static struct hda_verb stac92hd83xxx_core_init[] = {
867 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
868 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
869 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
871 /* power state controls amps */
872 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
876 static struct hda_verb stac92hd71bxx_core_init[] = {
877 /* set master volume and direct control */
878 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
882 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
883 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
884 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
885 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
886 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
890 static struct hda_verb stac925x_core_init[] = {
891 /* set dac0mux for dac converter */
892 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
893 /* mute the master volume */
894 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
898 static struct hda_verb stac922x_core_init[] = {
899 /* set master volume and direct control */
900 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
904 static struct hda_verb d965_core_init[] = {
905 /* set master volume and direct control */
906 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
907 /* unmute node 0x1b */
908 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
909 /* select node 0x03 as DAC */
910 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
914 static struct hda_verb stac927x_core_init[] = {
915 /* set master volume and direct control */
916 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
917 /* enable analog pc beep path */
918 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
922 static struct hda_verb stac9205_core_init[] = {
923 /* set master volume and direct control */
924 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
925 /* enable analog pc beep path */
926 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
930 #define STAC_MONO_MUX \
932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
933 .name = "Mono Mux", \
935 .info = stac92xx_mono_mux_enum_info, \
936 .get = stac92xx_mono_mux_enum_get, \
937 .put = stac92xx_mono_mux_enum_put, \
940 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
943 .name = "Analog Loopback", \
945 .info = stac92xx_aloopback_info, \
946 .get = stac92xx_aloopback_get, \
947 .put = stac92xx_aloopback_put, \
948 .private_value = verb_read | (verb_write << 16), \
951 #define DC_BIAS(xname, idx, nid) \
953 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
956 .info = stac92xx_dc_bias_info, \
957 .get = stac92xx_dc_bias_get, \
958 .put = stac92xx_dc_bias_put, \
959 .private_value = nid, \
962 static struct snd_kcontrol_new stac9200_mixer[] = {
963 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
964 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
965 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
966 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
970 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
971 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
975 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
976 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
980 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
981 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
986 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
987 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
990 static struct snd_kcontrol_new stac925x_mixer[] = {
991 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
992 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
996 static struct snd_kcontrol_new stac9205_loopback[] = {
997 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1001 static struct snd_kcontrol_new stac927x_loopback[] = {
1002 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1006 static struct snd_kcontrol_new stac_dmux_mixer = {
1007 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1008 .name = "Digital Input Source",
1009 /* count set later */
1010 .info = stac92xx_dmux_enum_info,
1011 .get = stac92xx_dmux_enum_get,
1012 .put = stac92xx_dmux_enum_put,
1015 static struct snd_kcontrol_new stac_smux_mixer = {
1016 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1017 .name = "IEC958 Playback Source",
1018 /* count set later */
1019 .info = stac92xx_smux_enum_info,
1020 .get = stac92xx_smux_enum_get,
1021 .put = stac92xx_smux_enum_put,
1024 static const char *slave_vols[] = {
1025 "Front Playback Volume",
1026 "Surround Playback Volume",
1027 "Center Playback Volume",
1028 "LFE Playback Volume",
1029 "Side Playback Volume",
1030 "Headphone Playback Volume",
1031 "Speaker Playback Volume",
1035 static const char *slave_sws[] = {
1036 "Front Playback Switch",
1037 "Surround Playback Switch",
1038 "Center Playback Switch",
1039 "LFE Playback Switch",
1040 "Side Playback Switch",
1041 "Headphone Playback Switch",
1042 "Speaker Playback Switch",
1043 "IEC958 Playback Switch",
1047 static void stac92xx_free_kctls(struct hda_codec *codec);
1048 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1050 static int stac92xx_build_controls(struct hda_codec *codec)
1052 struct sigmatel_spec *spec = codec->spec;
1053 struct auto_pin_cfg *cfg = &spec->autocfg;
1059 err = snd_hda_add_new_ctls(codec, spec->mixer);
1064 for (i = 0; i < spec->num_mixers; i++) {
1065 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1069 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1070 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1071 stac_dmux_mixer.count = spec->num_dmuxes;
1072 err = snd_hda_ctl_add(codec,
1073 snd_ctl_new1(&stac_dmux_mixer, codec));
1077 if (spec->num_smuxes > 0) {
1078 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1079 struct hda_input_mux *smux = &spec->private_smux;
1080 /* check for mute support on SPDIF out */
1081 if (wcaps & AC_WCAP_OUT_AMP) {
1082 smux->items[smux->num_items].label = "Off";
1083 smux->items[smux->num_items].index = 0;
1085 spec->spdif_mute = 1;
1087 stac_smux_mixer.count = spec->num_smuxes;
1088 err = snd_hda_ctl_add(codec,
1089 snd_ctl_new1(&stac_smux_mixer, codec));
1094 if (spec->multiout.dig_out_nid) {
1095 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1098 err = snd_hda_create_spdif_share_sw(codec,
1102 spec->multiout.share_spdif = 1;
1104 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1105 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1110 /* if we have no master control, let's create it */
1111 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1112 unsigned int vmaster_tlv[4];
1113 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1114 HDA_OUTPUT, vmaster_tlv);
1115 /* correct volume offset */
1116 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1117 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1118 vmaster_tlv, slave_vols);
1122 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1123 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1129 if (spec->aloopback_ctl &&
1130 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1131 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1136 stac92xx_free_kctls(codec); /* no longer needed */
1138 /* create jack input elements */
1139 if (spec->hp_detect) {
1140 for (i = 0; i < cfg->hp_outs; i++) {
1141 int type = SND_JACK_HEADPHONE;
1142 nid = cfg->hp_pins[i];
1143 /* jack detection */
1144 if (cfg->hp_outs == i)
1145 type |= SND_JACK_LINEOUT;
1146 err = stac92xx_add_jack(codec, nid, type);
1151 for (i = 0; i < cfg->line_outs; i++) {
1152 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1157 for (i = 0; i < AUTO_PIN_LAST; i++) {
1158 nid = cfg->input_pins[i];
1160 err = stac92xx_add_jack(codec, nid,
1161 SND_JACK_MICROPHONE);
1170 static unsigned int ref9200_pin_configs[8] = {
1171 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1172 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1175 static unsigned int gateway9200_m4_pin_configs[8] = {
1176 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1177 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1179 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1180 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1181 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1185 STAC 9200 pin configs for
1190 static unsigned int dell9200_d21_pin_configs[8] = {
1191 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1192 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1196 STAC 9200 pin configs for
1200 static unsigned int dell9200_d22_pin_configs[8] = {
1201 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1202 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1206 STAC 9200 pin configs for
1207 102801C4 (Dell Dimension E310)
1214 static unsigned int dell9200_d23_pin_configs[8] = {
1215 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1216 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1221 STAC 9200-32 pin configs for
1222 102801B5 (Dell Inspiron 630m)
1223 102801D8 (Dell Inspiron 640m)
1225 static unsigned int dell9200_m21_pin_configs[8] = {
1226 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1227 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1231 STAC 9200-32 pin configs for
1232 102801C2 (Dell Latitude D620)
1234 102801CC (Dell Latitude D820)
1238 static unsigned int dell9200_m22_pin_configs[8] = {
1239 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1240 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1244 STAC 9200-32 pin configs for
1245 102801CE (Dell XPS M1710)
1246 102801CF (Dell Precision M90)
1248 static unsigned int dell9200_m23_pin_configs[8] = {
1249 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1250 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1254 STAC 9200-32 pin configs for
1257 102801CB (Dell Latitude 120L)
1260 static unsigned int dell9200_m24_pin_configs[8] = {
1261 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1262 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1266 STAC 9200-32 pin configs for
1267 102801BD (Dell Inspiron E1505n)
1271 static unsigned int dell9200_m25_pin_configs[8] = {
1272 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1273 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1277 STAC 9200-32 pin configs for
1278 102801F5 (Dell Inspiron 1501)
1281 static unsigned int dell9200_m26_pin_configs[8] = {
1282 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1283 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1288 102801CD (Dell Inspiron E1705/9400)
1290 static unsigned int dell9200_m27_pin_configs[8] = {
1291 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1292 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1295 static unsigned int oqo9200_pin_configs[8] = {
1296 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1297 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1301 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1302 [STAC_REF] = ref9200_pin_configs,
1303 [STAC_9200_OQO] = oqo9200_pin_configs,
1304 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1305 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1306 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1307 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1308 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1309 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1310 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1311 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1312 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1313 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1314 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1315 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1316 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1319 static const char *stac9200_models[STAC_9200_MODELS] = {
1320 [STAC_AUTO] = "auto",
1322 [STAC_9200_OQO] = "oqo",
1323 [STAC_9200_DELL_D21] = "dell-d21",
1324 [STAC_9200_DELL_D22] = "dell-d22",
1325 [STAC_9200_DELL_D23] = "dell-d23",
1326 [STAC_9200_DELL_M21] = "dell-m21",
1327 [STAC_9200_DELL_M22] = "dell-m22",
1328 [STAC_9200_DELL_M23] = "dell-m23",
1329 [STAC_9200_DELL_M24] = "dell-m24",
1330 [STAC_9200_DELL_M25] = "dell-m25",
1331 [STAC_9200_DELL_M26] = "dell-m26",
1332 [STAC_9200_DELL_M27] = "dell-m27",
1333 [STAC_9200_M4] = "gateway-m4",
1334 [STAC_9200_M4_2] = "gateway-m4-2",
1335 [STAC_9200_PANASONIC] = "panasonic",
1338 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1339 /* SigmaTel reference board */
1340 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1341 "DFI LanParty", STAC_REF),
1342 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1343 "DFI LanParty", STAC_REF),
1344 /* Dell laptops have BIOS problem */
1345 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1346 "unknown Dell", STAC_9200_DELL_D21),
1347 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1348 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1349 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1350 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1351 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1352 "unknown Dell", STAC_9200_DELL_D22),
1353 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1354 "unknown Dell", STAC_9200_DELL_D22),
1355 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1356 "Dell Latitude D620", STAC_9200_DELL_M22),
1357 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1358 "unknown Dell", STAC_9200_DELL_D23),
1359 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1360 "unknown Dell", STAC_9200_DELL_D23),
1361 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1362 "unknown Dell", STAC_9200_DELL_M22),
1363 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1364 "unknown Dell", STAC_9200_DELL_M24),
1365 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1366 "unknown Dell", STAC_9200_DELL_M24),
1367 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1368 "Dell Latitude 120L", STAC_9200_DELL_M24),
1369 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1370 "Dell Latitude D820", STAC_9200_DELL_M22),
1371 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1372 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1373 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1374 "Dell XPS M1710", STAC_9200_DELL_M23),
1375 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1376 "Dell Precision M90", STAC_9200_DELL_M23),
1377 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1378 "unknown Dell", STAC_9200_DELL_M22),
1379 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1380 "unknown Dell", STAC_9200_DELL_M22),
1381 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1382 "unknown Dell", STAC_9200_DELL_M22),
1383 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1384 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1385 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1386 "unknown Dell", STAC_9200_DELL_D23),
1387 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1388 "unknown Dell", STAC_9200_DELL_D23),
1389 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1390 "unknown Dell", STAC_9200_DELL_D21),
1391 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1392 "unknown Dell", STAC_9200_DELL_D23),
1393 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1394 "unknown Dell", STAC_9200_DELL_D21),
1395 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1396 "unknown Dell", STAC_9200_DELL_M25),
1397 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1398 "unknown Dell", STAC_9200_DELL_M25),
1399 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1400 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1401 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1402 "unknown Dell", STAC_9200_DELL_M26),
1404 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1405 /* Gateway machines needs EAPD to be set on resume */
1406 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1407 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1408 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1410 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1414 static unsigned int ref925x_pin_configs[8] = {
1415 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1416 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1419 static unsigned int stac925xM1_pin_configs[8] = {
1420 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1421 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1424 static unsigned int stac925xM1_2_pin_configs[8] = {
1425 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1426 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1429 static unsigned int stac925xM2_pin_configs[8] = {
1430 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1431 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1434 static unsigned int stac925xM2_2_pin_configs[8] = {
1435 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1436 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1439 static unsigned int stac925xM3_pin_configs[8] = {
1440 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1441 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1444 static unsigned int stac925xM5_pin_configs[8] = {
1445 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1446 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1449 static unsigned int stac925xM6_pin_configs[8] = {
1450 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1451 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1454 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1455 [STAC_REF] = ref925x_pin_configs,
1456 [STAC_M1] = stac925xM1_pin_configs,
1457 [STAC_M1_2] = stac925xM1_2_pin_configs,
1458 [STAC_M2] = stac925xM2_pin_configs,
1459 [STAC_M2_2] = stac925xM2_2_pin_configs,
1460 [STAC_M3] = stac925xM3_pin_configs,
1461 [STAC_M5] = stac925xM5_pin_configs,
1462 [STAC_M6] = stac925xM6_pin_configs,
1465 static const char *stac925x_models[STAC_925x_MODELS] = {
1466 [STAC_925x_AUTO] = "auto",
1469 [STAC_M1_2] = "m1-2",
1471 [STAC_M2_2] = "m2-2",
1477 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1478 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1479 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1480 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1481 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1482 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1483 /* Not sure about the brand name for those */
1484 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1485 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1486 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1487 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1491 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1492 /* SigmaTel reference board */
1493 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1494 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1495 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1497 /* Default table for unknown ID */
1498 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1503 static unsigned int ref92hd73xx_pin_configs[13] = {
1504 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1505 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1506 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1510 static unsigned int dell_m6_pin_configs[13] = {
1511 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1512 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1513 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1517 static unsigned int alienware_m17x_pin_configs[13] = {
1518 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1519 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1520 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1524 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1525 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1526 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1527 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1528 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1529 [STAC_DELL_EQ] = dell_m6_pin_configs,
1530 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
1533 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1534 [STAC_92HD73XX_AUTO] = "auto",
1535 [STAC_92HD73XX_NO_JD] = "no-jd",
1536 [STAC_92HD73XX_REF] = "ref",
1537 [STAC_92HD73XX_INTEL] = "intel",
1538 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1539 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1540 [STAC_DELL_M6_BOTH] = "dell-m6",
1541 [STAC_DELL_EQ] = "dell-eq",
1542 [STAC_ALIENWARE_M17X] = "alienware",
1545 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1546 /* SigmaTel reference board */
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1548 "DFI LanParty", STAC_92HD73XX_REF),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1550 "DFI LanParty", STAC_92HD73XX_REF),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1552 "Intel DG45ID", STAC_92HD73XX_INTEL),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1554 "Intel DG45FC", STAC_92HD73XX_INTEL),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1556 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1558 "unknown Dell", STAC_DELL_M6_DMIC),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1560 "unknown Dell", STAC_DELL_M6_BOTH),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1562 "unknown Dell", STAC_DELL_M6_BOTH),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1564 "unknown Dell", STAC_DELL_M6_AMIC),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1566 "unknown Dell", STAC_DELL_M6_AMIC),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1568 "unknown Dell", STAC_DELL_M6_DMIC),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1570 "unknown Dell", STAC_DELL_M6_DMIC),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1572 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1574 "Dell Studio 17", STAC_DELL_M6_DMIC),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1576 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1580 static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1582 "Alienware M17x", STAC_ALIENWARE_M17X),
1586 static unsigned int ref92hd83xxx_pin_configs[10] = {
1587 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1588 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1589 0x01451160, 0x98560170,
1592 static unsigned int dell_s14_pin_configs[10] = {
1593 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1594 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1595 0x40f000f0, 0x40f000f0,
1598 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1599 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1600 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1601 [STAC_DELL_S14] = dell_s14_pin_configs,
1604 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1605 [STAC_92HD83XXX_AUTO] = "auto",
1606 [STAC_92HD83XXX_REF] = "ref",
1607 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1608 [STAC_DELL_S14] = "dell-s14",
1611 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1612 /* SigmaTel reference board */
1613 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1614 "DFI LanParty", STAC_92HD83XXX_REF),
1615 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1616 "DFI LanParty", STAC_92HD83XXX_REF),
1617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1618 "unknown Dell", STAC_DELL_S14),
1622 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1623 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1624 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1625 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1629 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1630 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1631 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1632 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1636 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1637 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1638 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1639 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1643 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1644 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1645 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1646 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1650 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1651 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1652 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1653 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1654 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1655 [STAC_HP_M4] = NULL,
1656 [STAC_HP_DV5] = NULL,
1657 [STAC_HP_HDX] = NULL,
1658 [STAC_HP_DV4_1222NR] = NULL,
1661 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1662 [STAC_92HD71BXX_AUTO] = "auto",
1663 [STAC_92HD71BXX_REF] = "ref",
1664 [STAC_DELL_M4_1] = "dell-m4-1",
1665 [STAC_DELL_M4_2] = "dell-m4-2",
1666 [STAC_DELL_M4_3] = "dell-m4-3",
1667 [STAC_HP_M4] = "hp-m4",
1668 [STAC_HP_DV5] = "hp-dv5",
1669 [STAC_HP_HDX] = "hp-hdx",
1670 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1673 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1674 /* SigmaTel reference board */
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1676 "DFI LanParty", STAC_92HD71BXX_REF),
1677 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1678 "DFI LanParty", STAC_92HD71BXX_REF),
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1680 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1681 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1683 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1684 "HP dv4-7", STAC_HP_DV5),
1685 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1686 "HP dv4-7", STAC_HP_DV5),
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1688 "HP HDX", STAC_HP_HDX), /* HDX18 */
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1690 "HP mini 1000", STAC_HP_M4),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1692 "HP HDX", STAC_HP_HDX), /* HDX16 */
1693 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1696 "unknown Dell", STAC_DELL_M4_1),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1698 "unknown Dell", STAC_DELL_M4_1),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1700 "unknown Dell", STAC_DELL_M4_1),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1702 "unknown Dell", STAC_DELL_M4_1),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1704 "unknown Dell", STAC_DELL_M4_1),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1706 "unknown Dell", STAC_DELL_M4_1),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1708 "unknown Dell", STAC_DELL_M4_1),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1710 "unknown Dell", STAC_DELL_M4_2),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1712 "unknown Dell", STAC_DELL_M4_2),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1714 "unknown Dell", STAC_DELL_M4_2),
1715 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1716 "unknown Dell", STAC_DELL_M4_2),
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1718 "unknown Dell", STAC_DELL_M4_3),
1722 static unsigned int ref922x_pin_configs[10] = {
1723 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1724 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1725 0x40000100, 0x40000100,
1729 STAC 922X pin configs for
1736 static unsigned int dell_922x_d81_pin_configs[10] = {
1737 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1738 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1739 0x01813122, 0x400001f2,
1743 STAC 922X pin configs for
1747 static unsigned int dell_922x_d82_pin_configs[10] = {
1748 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1749 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1750 0x01813122, 0x400001f1,
1754 STAC 922X pin configs for
1757 static unsigned int dell_922x_m81_pin_configs[10] = {
1758 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1759 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1760 0x40C003f1, 0x405003f0,
1764 STAC 9221 A1 pin configs for
1765 102801D7 (Dell XPS M1210)
1767 static unsigned int dell_922x_m82_pin_configs[10] = {
1768 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1769 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1770 0x508003f3, 0x405003f4,
1773 static unsigned int d945gtp3_pin_configs[10] = {
1774 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1775 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1776 0x02a19120, 0x40000100,
1779 static unsigned int d945gtp5_pin_configs[10] = {
1780 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1781 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1782 0x02a19320, 0x40000100,
1785 static unsigned int intel_mac_v1_pin_configs[10] = {
1786 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1787 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1788 0x400000fc, 0x400000fb,
1791 static unsigned int intel_mac_v2_pin_configs[10] = {
1792 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1793 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1794 0x400000fc, 0x400000fb,
1797 static unsigned int intel_mac_v3_pin_configs[10] = {
1798 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1799 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1800 0x400000fc, 0x400000fb,
1803 static unsigned int intel_mac_v4_pin_configs[10] = {
1804 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1805 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1806 0x400000fc, 0x400000fb,
1809 static unsigned int intel_mac_v5_pin_configs[10] = {
1810 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1811 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1812 0x400000fc, 0x400000fb,
1815 static unsigned int ecs202_pin_configs[10] = {
1816 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1817 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1818 0x9037012e, 0x40e000f2,
1821 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1822 [STAC_D945_REF] = ref922x_pin_configs,
1823 [STAC_D945GTP3] = d945gtp3_pin_configs,
1824 [STAC_D945GTP5] = d945gtp5_pin_configs,
1825 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1826 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1827 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1828 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1829 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1830 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1831 /* for backward compatibility */
1832 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1833 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1834 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1835 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1836 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1837 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1838 [STAC_ECS_202] = ecs202_pin_configs,
1839 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1840 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1841 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1842 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1845 static const char *stac922x_models[STAC_922X_MODELS] = {
1846 [STAC_922X_AUTO] = "auto",
1847 [STAC_D945_REF] = "ref",
1848 [STAC_D945GTP5] = "5stack",
1849 [STAC_D945GTP3] = "3stack",
1850 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1851 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1852 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1853 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1854 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1855 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1856 /* for backward compatibility */
1857 [STAC_MACMINI] = "macmini",
1858 [STAC_MACBOOK] = "macbook",
1859 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1860 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1861 [STAC_IMAC_INTEL] = "imac-intel",
1862 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1863 [STAC_ECS_202] = "ecs202",
1864 [STAC_922X_DELL_D81] = "dell-d81",
1865 [STAC_922X_DELL_D82] = "dell-d82",
1866 [STAC_922X_DELL_M81] = "dell-m81",
1867 [STAC_922X_DELL_M82] = "dell-m82",
1870 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1871 /* SigmaTel reference board */
1872 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1873 "DFI LanParty", STAC_D945_REF),
1874 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1875 "DFI LanParty", STAC_D945_REF),
1876 /* Intel 945G based systems */
1877 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1878 "Intel D945G", STAC_D945GTP3),
1879 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1880 "Intel D945G", STAC_D945GTP3),
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1882 "Intel D945G", STAC_D945GTP3),
1883 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1884 "Intel D945G", STAC_D945GTP3),
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1886 "Intel D945G", STAC_D945GTP3),
1887 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1888 "Intel D945G", STAC_D945GTP3),
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1890 "Intel D945G", STAC_D945GTP3),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1892 "Intel D945G", STAC_D945GTP3),
1893 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1894 "Intel D945G", STAC_D945GTP3),
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1896 "Intel D945G", STAC_D945GTP3),
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1898 "Intel D945G", STAC_D945GTP3),
1899 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1900 "Intel D945G", STAC_D945GTP3),
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1902 "Intel D945G", STAC_D945GTP3),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1904 "Intel D945G", STAC_D945GTP3),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1906 "Intel D945G", STAC_D945GTP3),
1907 /* Intel D945G 5-stack systems */
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1909 "Intel D945G", STAC_D945GTP5),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1911 "Intel D945G", STAC_D945GTP5),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1913 "Intel D945G", STAC_D945GTP5),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1915 "Intel D945G", STAC_D945GTP5),
1916 /* Intel 945P based systems */
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1918 "Intel D945P", STAC_D945GTP3),
1919 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1920 "Intel D945P", STAC_D945GTP3),
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1922 "Intel D945P", STAC_D945GTP3),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1924 "Intel D945P", STAC_D945GTP3),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1926 "Intel D945P", STAC_D945GTP3),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1928 "Intel D945P", STAC_D945GTP5),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
1931 "Intel D945", STAC_D945_REF),
1933 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1934 SND_PCI_QUIRK(0x8384, 0x7680,
1935 "Mac", STAC_INTEL_MAC_AUTO),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1938 "unknown Dell", STAC_922X_DELL_D81),
1939 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1940 "unknown Dell", STAC_922X_DELL_D81),
1941 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1942 "unknown Dell", STAC_922X_DELL_D81),
1943 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1944 "unknown Dell", STAC_922X_DELL_D82),
1945 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1946 "unknown Dell", STAC_922X_DELL_M81),
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1948 "unknown Dell", STAC_922X_DELL_D82),
1949 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1950 "unknown Dell", STAC_922X_DELL_D81),
1951 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1952 "unknown Dell", STAC_922X_DELL_D81),
1953 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1954 "Dell XPS M1210", STAC_922X_DELL_M82),
1955 /* ECS/PC Chips boards */
1956 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
1957 "ECS/PC chips", STAC_ECS_202),
1961 static unsigned int ref927x_pin_configs[14] = {
1962 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1963 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1964 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1965 0x01c42190, 0x40000100,
1968 static unsigned int d965_3st_pin_configs[14] = {
1969 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1970 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1971 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1972 0x40000100, 0x40000100
1975 static unsigned int d965_5st_pin_configs[14] = {
1976 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1977 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1978 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1979 0x40000100, 0x40000100
1982 static unsigned int d965_5st_no_fp_pin_configs[14] = {
1983 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
1984 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1985 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1986 0x40000100, 0x40000100
1989 static unsigned int dell_3st_pin_configs[14] = {
1990 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1991 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1992 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1993 0x40c003fc, 0x40000100
1996 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1997 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
1998 [STAC_D965_REF] = ref927x_pin_configs,
1999 [STAC_D965_3ST] = d965_3st_pin_configs,
2000 [STAC_D965_5ST] = d965_5st_pin_configs,
2001 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2002 [STAC_DELL_3ST] = dell_3st_pin_configs,
2003 [STAC_DELL_BIOS] = NULL,
2006 static const char *stac927x_models[STAC_927X_MODELS] = {
2007 [STAC_927X_AUTO] = "auto",
2008 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2009 [STAC_D965_REF] = "ref",
2010 [STAC_D965_3ST] = "3stack",
2011 [STAC_D965_5ST] = "5stack",
2012 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2013 [STAC_DELL_3ST] = "dell-3stack",
2014 [STAC_DELL_BIOS] = "dell-bios",
2017 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2018 /* SigmaTel reference board */
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2020 "DFI LanParty", STAC_D965_REF),
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2022 "DFI LanParty", STAC_D965_REF),
2023 /* Intel 946 based systems */
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2026 /* 965 based 3 stack systems */
2027 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2028 "Intel D965", STAC_D965_3ST),
2029 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2030 "Intel D965", STAC_D965_3ST),
2031 /* Dell 3 stack systems */
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2036 /* Dell 3 stack systems with verb table in BIOS */
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2045 /* 965 based 5 stack systems */
2046 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2047 "Intel D965", STAC_D965_5ST),
2048 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2049 "Intel D965", STAC_D965_5ST),
2053 static unsigned int ref9205_pin_configs[12] = {
2054 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2055 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2056 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2060 STAC 9205 pin configs for
2067 10280228 (Dell Vostro 1500)
2069 static unsigned int dell_9205_m42_pin_configs[12] = {
2070 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2071 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2072 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2076 STAC 9205 pin configs for
2080 102801FF (Dell Precision M4300)
2085 static unsigned int dell_9205_m43_pin_configs[12] = {
2086 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2087 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2088 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2091 static unsigned int dell_9205_m44_pin_configs[12] = {
2092 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2093 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2094 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2097 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2098 [STAC_9205_REF] = ref9205_pin_configs,
2099 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2100 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2101 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2102 [STAC_9205_EAPD] = NULL,
2105 static const char *stac9205_models[STAC_9205_MODELS] = {
2106 [STAC_9205_AUTO] = "auto",
2107 [STAC_9205_REF] = "ref",
2108 [STAC_9205_DELL_M42] = "dell-m42",
2109 [STAC_9205_DELL_M43] = "dell-m43",
2110 [STAC_9205_DELL_M44] = "dell-m44",
2111 [STAC_9205_EAPD] = "eapd",
2114 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2115 /* SigmaTel reference board */
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2117 "DFI LanParty", STAC_9205_REF),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2119 "SigmaTel", STAC_9205_REF),
2120 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2121 "DFI LanParty", STAC_9205_REF),
2123 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2124 "unknown Dell", STAC_9205_DELL_M42),
2125 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2126 "unknown Dell", STAC_9205_DELL_M42),
2127 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2128 "Dell Precision", STAC_9205_DELL_M43),
2129 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2130 "Dell Precision", STAC_9205_DELL_M43),
2131 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2132 "Dell Precision", STAC_9205_DELL_M43),
2133 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2134 "unknown Dell", STAC_9205_DELL_M42),
2135 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2136 "unknown Dell", STAC_9205_DELL_M42),
2137 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2138 "Dell Precision", STAC_9205_DELL_M43),
2139 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2140 "Dell Precision M4300", STAC_9205_DELL_M43),
2141 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2142 "unknown Dell", STAC_9205_DELL_M42),
2143 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2144 "Dell Precision", STAC_9205_DELL_M43),
2145 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2146 "Dell Precision", STAC_9205_DELL_M43),
2147 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2148 "Dell Precision", STAC_9205_DELL_M43),
2149 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2150 "Dell Inspiron", STAC_9205_DELL_M44),
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2152 "Dell Vostro 1500", STAC_9205_DELL_M42),
2154 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2155 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2159 static void stac92xx_set_config_regs(struct hda_codec *codec,
2160 unsigned int *pincfgs)
2163 struct sigmatel_spec *spec = codec->spec;
2168 for (i = 0; i < spec->num_pins; i++)
2169 if (spec->pin_nids[i] && pincfgs[i])
2170 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2175 * Analog playback callbacks
2177 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2178 struct hda_codec *codec,
2179 struct snd_pcm_substream *substream)
2181 struct sigmatel_spec *spec = codec->spec;
2182 if (spec->stream_delay)
2183 msleep(spec->stream_delay);
2184 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2188 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2189 struct hda_codec *codec,
2190 unsigned int stream_tag,
2191 unsigned int format,
2192 struct snd_pcm_substream *substream)
2194 struct sigmatel_spec *spec = codec->spec;
2195 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2198 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2199 struct hda_codec *codec,
2200 struct snd_pcm_substream *substream)
2202 struct sigmatel_spec *spec = codec->spec;
2203 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2207 * Digital playback callbacks
2209 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2210 struct hda_codec *codec,
2211 struct snd_pcm_substream *substream)
2213 struct sigmatel_spec *spec = codec->spec;
2214 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2217 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2218 struct hda_codec *codec,
2219 struct snd_pcm_substream *substream)
2221 struct sigmatel_spec *spec = codec->spec;
2222 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2225 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2226 struct hda_codec *codec,
2227 unsigned int stream_tag,
2228 unsigned int format,
2229 struct snd_pcm_substream *substream)
2231 struct sigmatel_spec *spec = codec->spec;
2232 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2233 stream_tag, format, substream);
2236 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2237 struct hda_codec *codec,
2238 struct snd_pcm_substream *substream)
2240 struct sigmatel_spec *spec = codec->spec;
2241 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2246 * Analog capture callbacks
2248 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2249 struct hda_codec *codec,
2250 unsigned int stream_tag,
2251 unsigned int format,
2252 struct snd_pcm_substream *substream)
2254 struct sigmatel_spec *spec = codec->spec;
2255 hda_nid_t nid = spec->adc_nids[substream->number];
2257 if (spec->powerdown_adcs) {
2259 snd_hda_codec_write(codec, nid, 0,
2260 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2262 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2266 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2267 struct hda_codec *codec,
2268 struct snd_pcm_substream *substream)
2270 struct sigmatel_spec *spec = codec->spec;
2271 hda_nid_t nid = spec->adc_nids[substream->number];
2273 snd_hda_codec_cleanup_stream(codec, nid);
2274 if (spec->powerdown_adcs)
2275 snd_hda_codec_write(codec, nid, 0,
2276 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2280 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2284 /* NID is set in stac92xx_build_pcms */
2286 .open = stac92xx_dig_playback_pcm_open,
2287 .close = stac92xx_dig_playback_pcm_close,
2288 .prepare = stac92xx_dig_playback_pcm_prepare,
2289 .cleanup = stac92xx_dig_playback_pcm_cleanup
2293 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2297 /* NID is set in stac92xx_build_pcms */
2300 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2304 .nid = 0x02, /* NID to query formats and rates */
2306 .open = stac92xx_playback_pcm_open,
2307 .prepare = stac92xx_playback_pcm_prepare,
2308 .cleanup = stac92xx_playback_pcm_cleanup
2312 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2316 .nid = 0x06, /* NID to query formats and rates */
2318 .open = stac92xx_playback_pcm_open,
2319 .prepare = stac92xx_playback_pcm_prepare,
2320 .cleanup = stac92xx_playback_pcm_cleanup
2324 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2327 /* NID + .substreams is set in stac92xx_build_pcms */
2329 .prepare = stac92xx_capture_pcm_prepare,
2330 .cleanup = stac92xx_capture_pcm_cleanup
2334 static int stac92xx_build_pcms(struct hda_codec *codec)
2336 struct sigmatel_spec *spec = codec->spec;
2337 struct hda_pcm *info = spec->pcm_rec;
2339 codec->num_pcms = 1;
2340 codec->pcm_info = info;
2342 info->name = "STAC92xx Analog";
2343 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2344 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2345 spec->multiout.dac_nids[0];
2346 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2347 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2348 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2350 if (spec->alt_switch) {
2353 info->name = "STAC92xx Analog Alt";
2354 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2357 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2360 info->name = "STAC92xx Digital";
2361 info->pcm_type = spec->autocfg.dig_out_type[0];
2362 if (spec->multiout.dig_out_nid) {
2363 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2364 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2366 if (spec->dig_in_nid) {
2367 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2368 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2375 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2378 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2379 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2380 if (pincap & AC_PINCAP_VREF_100)
2381 return AC_PINCTL_VREF_100;
2382 if (pincap & AC_PINCAP_VREF_80)
2383 return AC_PINCTL_VREF_80;
2384 if (pincap & AC_PINCAP_VREF_50)
2385 return AC_PINCTL_VREF_50;
2386 if (pincap & AC_PINCAP_VREF_GRD)
2387 return AC_PINCTL_VREF_GRD;
2391 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2394 snd_hda_codec_write_cache(codec, nid, 0,
2395 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2398 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2400 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2401 struct snd_ctl_elem_value *ucontrol)
2403 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2404 struct sigmatel_spec *spec = codec->spec;
2406 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2410 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2412 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2413 struct snd_ctl_elem_value *ucontrol)
2415 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2416 struct sigmatel_spec *spec = codec->spec;
2417 int nid = kcontrol->private_value;
2419 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2421 /* check to be sure that the ports are upto date with
2424 stac_issue_unsol_event(codec, nid);
2429 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2430 struct snd_ctl_elem_info *uinfo)
2433 static char *texts[] = {
2434 "Mic In", "Line In", "Line Out"
2437 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2438 struct sigmatel_spec *spec = codec->spec;
2439 hda_nid_t nid = kcontrol->private_value;
2441 if (nid == spec->mic_switch || nid == spec->line_switch)
2446 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2447 uinfo->value.enumerated.items = i;
2449 if (uinfo->value.enumerated.item >= i)
2450 uinfo->value.enumerated.item = i-1;
2451 strcpy(uinfo->value.enumerated.name,
2452 texts[uinfo->value.enumerated.item]);
2457 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2458 struct snd_ctl_elem_value *ucontrol)
2460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2461 hda_nid_t nid = kcontrol->private_value;
2462 unsigned int vref = stac92xx_vref_get(codec, nid);
2464 if (vref == stac92xx_get_default_vref(codec, nid))
2465 ucontrol->value.enumerated.item[0] = 0;
2466 else if (vref == AC_PINCTL_VREF_GRD)
2467 ucontrol->value.enumerated.item[0] = 1;
2468 else if (vref == AC_PINCTL_VREF_HIZ)
2469 ucontrol->value.enumerated.item[0] = 2;
2474 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2475 struct snd_ctl_elem_value *ucontrol)
2477 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2478 unsigned int new_vref = 0;
2480 hda_nid_t nid = kcontrol->private_value;
2482 if (ucontrol->value.enumerated.item[0] == 0)
2483 new_vref = stac92xx_get_default_vref(codec, nid);
2484 else if (ucontrol->value.enumerated.item[0] == 1)
2485 new_vref = AC_PINCTL_VREF_GRD;
2486 else if (ucontrol->value.enumerated.item[0] == 2)
2487 new_vref = AC_PINCTL_VREF_HIZ;
2491 if (new_vref != stac92xx_vref_get(codec, nid)) {
2492 error = stac92xx_vref_set(codec, nid, new_vref);
2499 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2500 struct snd_ctl_elem_info *uinfo)
2502 static char *texts[2];
2503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2504 struct sigmatel_spec *spec = codec->spec;
2506 if (kcontrol->private_value == spec->line_switch)
2507 texts[0] = "Line In";
2509 texts[0] = "Mic In";
2510 texts[1] = "Line Out";
2511 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2512 uinfo->value.enumerated.items = 2;
2515 if (uinfo->value.enumerated.item >= 2)
2516 uinfo->value.enumerated.item = 1;
2517 strcpy(uinfo->value.enumerated.name,
2518 texts[uinfo->value.enumerated.item]);
2523 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2525 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2526 struct sigmatel_spec *spec = codec->spec;
2527 hda_nid_t nid = kcontrol->private_value;
2528 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2530 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2534 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2537 struct sigmatel_spec *spec = codec->spec;
2538 hda_nid_t nid = kcontrol->private_value;
2539 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2540 unsigned short val = !!ucontrol->value.enumerated.item[0];
2542 spec->io_switch[io_idx] = val;
2545 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2547 unsigned int pinctl = AC_PINCTL_IN_EN;
2548 if (io_idx) /* set VREF for mic */
2549 pinctl |= stac92xx_get_default_vref(codec, nid);
2550 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2553 /* check the auto-mute again: we need to mute/unmute the speaker
2554 * appropriately according to the pin direction
2556 if (spec->hp_detect)
2557 stac_issue_unsol_event(codec, nid);
2562 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2564 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2565 struct snd_ctl_elem_value *ucontrol)
2567 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2568 struct sigmatel_spec *spec = codec->spec;
2570 ucontrol->value.integer.value[0] = spec->clfe_swap;
2574 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2575 struct snd_ctl_elem_value *ucontrol)
2577 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2578 struct sigmatel_spec *spec = codec->spec;
2579 hda_nid_t nid = kcontrol->private_value & 0xff;
2580 unsigned int val = !!ucontrol->value.integer.value[0];
2582 if (spec->clfe_swap == val)
2585 spec->clfe_swap = val;
2587 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2588 spec->clfe_swap ? 0x4 : 0x0);
2593 #define STAC_CODEC_HP_SWITCH(xname) \
2594 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2597 .info = stac92xx_hp_switch_info, \
2598 .get = stac92xx_hp_switch_get, \
2599 .put = stac92xx_hp_switch_put, \
2602 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2603 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2606 .info = stac92xx_io_switch_info, \
2607 .get = stac92xx_io_switch_get, \
2608 .put = stac92xx_io_switch_put, \
2609 .private_value = xpval, \
2612 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2613 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2616 .info = stac92xx_clfe_switch_info, \
2617 .get = stac92xx_clfe_switch_get, \
2618 .put = stac92xx_clfe_switch_put, \
2619 .private_value = xpval, \
2623 STAC_CTL_WIDGET_VOL,
2624 STAC_CTL_WIDGET_MUTE,
2625 STAC_CTL_WIDGET_MONO_MUX,
2626 STAC_CTL_WIDGET_HP_SWITCH,
2627 STAC_CTL_WIDGET_IO_SWITCH,
2628 STAC_CTL_WIDGET_CLFE_SWITCH,
2629 STAC_CTL_WIDGET_DC_BIAS
2632 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2633 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2634 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2636 STAC_CODEC_HP_SWITCH(NULL),
2637 STAC_CODEC_IO_SWITCH(NULL, 0),
2638 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2639 DC_BIAS(NULL, 0, 0),
2642 /* add dynamic controls */
2643 static struct snd_kcontrol_new *
2644 stac_control_new(struct sigmatel_spec *spec,
2645 struct snd_kcontrol_new *ktemp,
2648 struct snd_kcontrol_new *knew;
2650 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2651 knew = snd_array_new(&spec->kctls);
2655 knew->name = kstrdup(name, GFP_KERNEL);
2658 memset(knew, 0, sizeof(*knew));
2659 spec->kctls.alloced--;
2665 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2666 struct snd_kcontrol_new *ktemp,
2667 int idx, const char *name,
2670 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2674 knew->private_value = val;
2678 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2679 int type, int idx, const char *name,
2682 return stac92xx_add_control_temp(spec,
2683 &stac92xx_control_templates[type],
2688 /* add dynamic controls */
2689 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2690 const char *name, unsigned long val)
2692 return stac92xx_add_control_idx(spec, type, 0, name, val);
2695 static struct snd_kcontrol_new stac_input_src_temp = {
2696 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2697 .name = "Input Source",
2698 .info = stac92xx_mux_enum_info,
2699 .get = stac92xx_mux_enum_get,
2700 .put = stac92xx_mux_enum_put,
2703 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2704 hda_nid_t nid, int idx)
2706 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2708 struct sigmatel_spec *spec = codec->spec;
2711 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2712 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2713 && nid == spec->line_switch)
2714 control = STAC_CTL_WIDGET_IO_SWITCH;
2715 else if (snd_hda_query_pin_caps(codec, nid)
2716 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2717 control = STAC_CTL_WIDGET_DC_BIAS;
2718 else if (nid == spec->mic_switch)
2719 control = STAC_CTL_WIDGET_IO_SWITCH;
2723 strcpy(name, auto_pin_cfg_labels[idx]);
2724 return stac92xx_add_control(codec->spec, control,
2725 strcat(name, " Jack Mode"), nid);
2731 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2733 struct snd_kcontrol_new *knew;
2734 struct hda_input_mux *imux = &spec->private_imux;
2737 return 0; /* no need for input source */
2738 if (!spec->num_adcs || imux->num_items <= 1)
2739 return 0; /* no need for input source control */
2740 knew = stac_control_new(spec, &stac_input_src_temp,
2741 stac_input_src_temp.name);
2744 knew->count = spec->num_adcs;
2748 /* check whether the line-input can be used as line-out */
2749 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2751 struct sigmatel_spec *spec = codec->spec;
2752 struct auto_pin_cfg *cfg = &spec->autocfg;
2754 unsigned int pincap;
2756 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2758 nid = cfg->input_pins[AUTO_PIN_LINE];
2759 pincap = snd_hda_query_pin_caps(codec, nid);
2760 if (pincap & AC_PINCAP_OUT)
2765 /* check whether the mic-input can be used as line-out */
2766 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2768 struct sigmatel_spec *spec = codec->spec;
2769 struct auto_pin_cfg *cfg = &spec->autocfg;
2770 unsigned int def_conf, pincap;
2771 unsigned int mic_pin;
2773 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2775 mic_pin = AUTO_PIN_MIC;
2777 hda_nid_t nid = cfg->input_pins[mic_pin];
2778 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2779 /* some laptops have an internal analog microphone
2780 * which can't be used as a output */
2781 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2782 pincap = snd_hda_query_pin_caps(codec, nid);
2783 if (pincap & AC_PINCAP_OUT)
2786 if (mic_pin == AUTO_PIN_MIC)
2787 mic_pin = AUTO_PIN_FRONT_MIC;
2794 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2798 for (i = 0; i < spec->multiout.num_dacs; i++) {
2799 if (spec->multiout.dac_nids[i] == nid)
2806 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2809 if (is_in_dac_nids(spec, nid))
2811 for (i = 0; i < spec->autocfg.hp_outs; i++)
2812 if (spec->hp_dacs[i] == nid)
2814 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2815 if (spec->speaker_dacs[i] == nid)
2820 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2822 struct sigmatel_spec *spec = codec->spec;
2824 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2825 unsigned int wcaps, wtype;
2827 conn_len = snd_hda_get_connections(codec, nid, conn,
2828 HDA_MAX_CONNECTIONS);
2829 for (j = 0; j < conn_len; j++) {
2830 wcaps = get_wcaps(codec, conn[j]);
2831 wtype = get_wcaps_type(wcaps);
2832 /* we check only analog outputs */
2833 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2835 /* if this route has a free DAC, assign it */
2836 if (!check_all_dac_nids(spec, conn[j])) {
2838 /* select this DAC in the pin's input mux */
2839 snd_hda_codec_write_cache(codec, nid, 0,
2840 AC_VERB_SET_CONNECT_SEL, j);
2845 /* if all DACs are already assigned, connect to the primary DAC */
2847 for (j = 0; j < conn_len; j++) {
2848 if (conn[j] == spec->multiout.dac_nids[0]) {
2849 snd_hda_codec_write_cache(codec, nid, 0,
2850 AC_VERB_SET_CONNECT_SEL, j);
2858 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2859 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2862 * Fill in the dac_nids table from the parsed pin configuration
2863 * This function only works when every pin in line_out_pins[]
2864 * contains atleast one DAC in its connection list. Some 92xx
2865 * codecs are not connected directly to a DAC, such as the 9200
2866 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2868 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2870 struct sigmatel_spec *spec = codec->spec;
2871 struct auto_pin_cfg *cfg = &spec->autocfg;
2875 for (i = 0; i < cfg->line_outs; i++) {
2876 nid = cfg->line_out_pins[i];
2877 dac = get_unassigned_dac(codec, nid);
2879 if (spec->multiout.num_dacs > 0) {
2880 /* we have already working output pins,
2881 * so let's drop the broken ones again
2883 cfg->line_outs = spec->multiout.num_dacs;
2886 /* error out, no available DAC found */
2888 "%s: No available DAC for pin 0x%x\n",
2892 add_spec_dacs(spec, dac);
2895 for (i = 0; i < cfg->hp_outs; i++) {
2896 nid = cfg->hp_pins[i];
2897 dac = get_unassigned_dac(codec, nid);
2899 if (!spec->multiout.hp_nid)
2900 spec->multiout.hp_nid = dac;
2902 add_spec_extra_dacs(spec, dac);
2904 spec->hp_dacs[i] = dac;
2907 for (i = 0; i < cfg->speaker_outs; i++) {
2908 nid = cfg->speaker_pins[i];
2909 dac = get_unassigned_dac(codec, nid);
2911 add_spec_extra_dacs(spec, dac);
2912 spec->speaker_dacs[i] = dac;
2915 /* add line-in as output */
2916 nid = check_line_out_switch(codec);
2918 dac = get_unassigned_dac(codec, nid);
2920 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2921 nid, cfg->line_outs);
2922 cfg->line_out_pins[cfg->line_outs] = nid;
2924 spec->line_switch = nid;
2925 add_spec_dacs(spec, dac);
2928 /* add mic as output */
2929 nid = check_mic_out_switch(codec);
2931 dac = get_unassigned_dac(codec, nid);
2933 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2934 nid, cfg->line_outs);
2935 cfg->line_out_pins[cfg->line_outs] = nid;
2937 spec->mic_switch = nid;
2938 add_spec_dacs(spec, dac);
2942 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2943 spec->multiout.num_dacs,
2944 spec->multiout.dac_nids[0],
2945 spec->multiout.dac_nids[1],
2946 spec->multiout.dac_nids[2],
2947 spec->multiout.dac_nids[3],
2948 spec->multiout.dac_nids[4]);
2953 /* create volume control/switch for the given prefx type */
2954 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
2955 int idx, hda_nid_t nid, int chs)
2957 struct sigmatel_spec *spec = codec->spec;
2961 if (!spec->check_volume_offset) {
2962 unsigned int caps, step, nums, db_scale;
2963 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2964 step = (caps & AC_AMPCAP_STEP_SIZE) >>
2965 AC_AMPCAP_STEP_SIZE_SHIFT;
2966 step = (step + 1) * 25; /* in .01dB unit */
2967 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
2968 AC_AMPCAP_NUM_STEPS_SHIFT;
2969 db_scale = nums * step;
2970 /* if dB scale is over -64dB, and finer enough,
2971 * let's reduce it to half
2973 if (db_scale > 6400 && nums >= 0x1f)
2974 spec->volume_offset = nums / 2;
2975 spec->check_volume_offset = 1;
2978 sprintf(name, "%s Playback Volume", pfx);
2979 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
2980 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
2981 spec->volume_offset));
2984 sprintf(name, "%s Playback Switch", pfx);
2985 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
2986 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2992 #define create_controls(codec, pfx, nid, chs) \
2993 create_controls_idx(codec, pfx, 0, nid, chs)
2995 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2997 if (spec->multiout.num_dacs > 4) {
2998 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3001 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3002 spec->multiout.num_dacs++;
3007 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3010 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3011 if (!spec->multiout.extra_out_nid[i]) {
3012 spec->multiout.extra_out_nid[i] = nid;
3016 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3020 /* Create output controls
3021 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3023 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3024 const hda_nid_t *pins,
3025 const hda_nid_t *dac_nids,
3028 struct sigmatel_spec *spec = codec->spec;
3029 static const char *chname[4] = {
3030 "Front", "Surround", NULL /*CLFE*/, "Side"
3034 unsigned int wid_caps;
3036 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3037 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3038 wid_caps = get_wcaps(codec, pins[i]);
3039 if (wid_caps & AC_WCAP_UNSOL_CAP)
3040 spec->hp_detect = 1;
3045 if (type != AUTO_PIN_HP_OUT && i == 2) {
3047 err = create_controls(codec, "Center", nid, 1);
3050 err = create_controls(codec, "LFE", nid, 2);
3054 wid_caps = get_wcaps(codec, nid);
3056 if (wid_caps & AC_WCAP_LR_SWAP) {
3057 err = stac92xx_add_control(spec,
3058 STAC_CTL_WIDGET_CLFE_SWITCH,
3059 "Swap Center/LFE Playback Switch", nid);
3069 case AUTO_PIN_HP_OUT:
3073 case AUTO_PIN_SPEAKER_OUT:
3082 err = create_controls_idx(codec, name, idx, nid, 3);
3090 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3091 unsigned long sw, int idx)
3094 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3095 "Capture Volume", vol);
3098 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3099 "Capture Switch", sw);
3105 /* add playback controls from the parsed DAC table */
3106 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3107 const struct auto_pin_cfg *cfg)
3109 struct sigmatel_spec *spec = codec->spec;
3114 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3115 spec->multiout.dac_nids,
3116 cfg->line_out_type);
3120 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3121 err = stac92xx_add_control(spec,
3122 STAC_CTL_WIDGET_HP_SWITCH,
3123 "Headphone as Line Out Switch",
3124 cfg->hp_pins[cfg->hp_outs - 1]);
3129 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3130 nid = cfg->input_pins[idx];
3132 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3141 /* add playback controls for Speaker and HP outputs */
3142 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3143 struct auto_pin_cfg *cfg)
3145 struct sigmatel_spec *spec = codec->spec;
3148 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3149 spec->hp_dacs, AUTO_PIN_HP_OUT);
3153 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3154 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3161 /* labels for mono mux outputs */
3162 static const char *stac92xx_mono_labels[4] = {
3163 "DAC0", "DAC1", "Mixer", "DAC2"
3166 /* create mono mux for mono out on capable codecs */
3167 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3169 struct sigmatel_spec *spec = codec->spec;
3170 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3172 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3174 num_cons = snd_hda_get_connections(codec,
3177 HDA_MAX_NUM_INPUTS);
3178 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3181 for (i = 0; i < num_cons; i++) {
3182 mono_mux->items[mono_mux->num_items].label =
3183 stac92xx_mono_labels[i];
3184 mono_mux->items[mono_mux->num_items].index = i;
3185 mono_mux->num_items++;
3188 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3189 "Mono Mux", spec->mono_nid);
3192 /* create PC beep volume controls */
3193 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3196 struct sigmatel_spec *spec = codec->spec;
3197 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3200 /* check for mute support for the the amp */
3201 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3202 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3203 "PC Beep Playback Switch",
3204 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3209 /* check to see if there is volume support for the amp */
3210 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3211 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3212 "PC Beep Playback Volume",
3213 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3220 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3221 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3223 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3224 struct snd_ctl_elem_value *ucontrol)
3226 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3227 ucontrol->value.integer.value[0] = codec->beep->enabled;
3231 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3232 struct snd_ctl_elem_value *ucontrol)
3234 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3235 int enabled = !!ucontrol->value.integer.value[0];
3236 if (codec->beep->enabled != enabled) {
3237 codec->beep->enabled = enabled;
3243 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3244 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3245 .info = stac92xx_dig_beep_switch_info,
3246 .get = stac92xx_dig_beep_switch_get,
3247 .put = stac92xx_dig_beep_switch_put,
3250 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3252 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3253 0, "PC Beep Playback Switch", 0);
3257 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3259 struct sigmatel_spec *spec = codec->spec;
3262 for (i = 0; i < spec->num_muxes; i++) {
3267 nid = spec->mux_nids[i];
3268 wcaps = get_wcaps(codec, nid);
3269 if (!(wcaps & AC_WCAP_OUT_AMP))
3272 /* check whether already the same control was created as
3273 * normal Capture Volume.
3275 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3276 for (j = 0; j < spec->num_caps; j++) {
3277 if (spec->capvols[j] == val)
3280 if (j < spec->num_caps)
3283 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3284 "Mux Capture Volume", val);
3291 static const char *stac92xx_spdif_labels[3] = {
3292 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3295 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3297 struct sigmatel_spec *spec = codec->spec;
3298 struct hda_input_mux *spdif_mux = &spec->private_smux;
3299 const char **labels = spec->spdif_labels;
3301 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3303 num_cons = snd_hda_get_connections(codec,
3306 HDA_MAX_NUM_INPUTS);
3311 labels = stac92xx_spdif_labels;