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 */
91 STAC_92HD83XXX_PWR_REF,
106 STAC_92HD71BXX_MODELS
132 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
133 * is given, one of the above models will be
134 * chosen according to the subsystem id. */
135 /* for backward compatibility */
152 STAC_D965_REF_NO_JD, /* no jack-detection */
168 struct sigmatel_event {
175 struct sigmatel_jack {
178 struct snd_jack *jack;
181 struct sigmatel_mic_route {
183 unsigned char mux_idx;
184 unsigned char dmux_idx;
187 struct sigmatel_spec {
188 struct snd_kcontrol_new *mixers[4];
189 unsigned int num_mixers;
192 unsigned int eapd_switch: 1;
193 unsigned int surr_switch: 1;
194 unsigned int alt_switch: 1;
195 unsigned int hp_detect: 1;
196 unsigned int spdif_mute: 1;
197 unsigned int check_volume_offset:1;
198 unsigned int auto_mic:1;
201 unsigned int eapd_mask;
202 unsigned int gpio_mask;
203 unsigned int gpio_dir;
204 unsigned int gpio_data;
205 unsigned int gpio_mute;
206 unsigned int gpio_led;
209 unsigned int stream_delay;
211 /* analog loopback */
212 struct snd_kcontrol_new *aloopback_ctl;
213 unsigned char aloopback_mask;
214 unsigned char aloopback_shift;
216 /* power management */
217 unsigned int num_pwrs;
218 unsigned int *pwr_mapping;
223 struct snd_array jacks;
226 struct snd_array events;
229 struct hda_input_mux *mono_mux;
230 struct hda_input_mux *amp_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 num_amps;
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_amp_mux;
303 struct hda_input_mux private_mono_mux;
306 static hda_nid_t stac9200_adc_nids[1] = {
310 static hda_nid_t stac9200_mux_nids[1] = {
314 static hda_nid_t stac9200_dac_nids[1] = {
318 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
319 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
323 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
327 static hda_nid_t stac92hd73xx_adc_nids[2] = {
331 #define DELL_M6_AMP 2
332 static hda_nid_t stac92hd73xx_amp_nids[3] = {
336 #define STAC92HD73XX_NUM_DMICS 2
337 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
341 #define STAC92HD73_DAC_COUNT 5
343 static hda_nid_t stac92hd73xx_mux_nids[4] = {
344 0x28, 0x29, 0x2a, 0x2b,
347 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
351 static hda_nid_t stac92hd73xx_smux_nids[2] = {
355 #define STAC92HD73XX_NUM_CAPS 2
356 static unsigned long stac92hd73xx_capvols[] = {
357 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
358 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
360 #define stac92hd73xx_capsws stac92hd73xx_capvols
362 #define STAC92HD83_DAC_COUNT 3
364 static hda_nid_t stac92hd83xxx_mux_nids[2] = {
368 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
372 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
376 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
380 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
381 0x03, 0x0c, 0x20, 0x40,
384 #define STAC92HD83XXX_NUM_CAPS 2
385 static unsigned long stac92hd83xxx_capvols[] = {
386 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
387 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
389 #define stac92hd83xxx_capsws stac92hd83xxx_capvols
391 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
395 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
399 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
403 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
407 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
411 #define STAC92HD71BXX_NUM_DMICS 2
412 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
416 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
420 #define STAC92HD71BXX_NUM_CAPS 2
421 static unsigned long stac92hd71bxx_capvols[] = {
422 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
423 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
425 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
427 static hda_nid_t stac925x_adc_nids[1] = {
431 static hda_nid_t stac925x_mux_nids[1] = {
435 static hda_nid_t stac925x_dac_nids[1] = {
439 #define STAC925X_NUM_DMICS 1
440 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
444 static hda_nid_t stac925x_dmux_nids[1] = {
448 static unsigned long stac925x_capvols[] = {
449 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
451 static unsigned long stac925x_capsws[] = {
452 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
455 static hda_nid_t stac922x_adc_nids[2] = {
459 static hda_nid_t stac922x_mux_nids[2] = {
463 #define STAC922X_NUM_CAPS 2
464 static unsigned long stac922x_capvols[] = {
465 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
466 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
468 #define stac922x_capsws stac922x_capvols
470 static hda_nid_t stac927x_slave_dig_outs[2] = {
474 static hda_nid_t stac927x_adc_nids[3] = {
478 static hda_nid_t stac927x_mux_nids[3] = {
482 static hda_nid_t stac927x_smux_nids[1] = {
486 static hda_nid_t stac927x_dac_nids[6] = {
487 0x02, 0x03, 0x04, 0x05, 0x06, 0
490 static hda_nid_t stac927x_dmux_nids[1] = {
494 #define STAC927X_NUM_DMICS 2
495 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
499 #define STAC927X_NUM_CAPS 3
500 static unsigned long stac927x_capvols[] = {
501 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
502 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
503 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
505 static unsigned long stac927x_capsws[] = {
506 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
507 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
508 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
511 static const char *stac927x_spdif_labels[5] = {
512 "Digital Playback", "ADAT", "Analog Mux 1",
513 "Analog Mux 2", "Analog Mux 3"
516 static hda_nid_t stac9205_adc_nids[2] = {
520 static hda_nid_t stac9205_mux_nids[2] = {
524 static hda_nid_t stac9205_dmux_nids[1] = {
528 static hda_nid_t stac9205_smux_nids[1] = {
532 #define STAC9205_NUM_DMICS 2
533 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
537 #define STAC9205_NUM_CAPS 2
538 static unsigned long stac9205_capvols[] = {
539 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
540 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
542 static unsigned long stac9205_capsws[] = {
543 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
544 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
547 static hda_nid_t stac9200_pin_nids[8] = {
548 0x08, 0x09, 0x0d, 0x0e,
549 0x0f, 0x10, 0x11, 0x12,
552 static hda_nid_t stac925x_pin_nids[8] = {
553 0x07, 0x08, 0x0a, 0x0b,
554 0x0c, 0x0d, 0x10, 0x11,
557 static hda_nid_t stac922x_pin_nids[10] = {
558 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
559 0x0f, 0x10, 0x11, 0x15, 0x1b,
562 static hda_nid_t stac92hd73xx_pin_nids[13] = {
563 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
564 0x0f, 0x10, 0x11, 0x12, 0x13,
568 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
569 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
570 0x0f, 0x10, 0x11, 0x1f, 0x20,
573 #define STAC92HD71BXX_NUM_PINS 13
574 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
575 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
576 0x00, 0x14, 0x18, 0x19, 0x1e,
579 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
580 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
581 0x0f, 0x14, 0x18, 0x19, 0x1e,
585 static hda_nid_t stac927x_pin_nids[14] = {
586 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
587 0x0f, 0x10, 0x11, 0x12, 0x13,
588 0x14, 0x21, 0x22, 0x23,
591 static hda_nid_t stac9205_pin_nids[12] = {
592 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
593 0x0f, 0x14, 0x16, 0x17, 0x18,
597 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
599 static int stac92xx_amp_volume_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 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
606 kcontrol->private_value ^= get_amp_nid(kcontrol);
607 kcontrol->private_value |= nid;
609 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
612 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
613 struct snd_ctl_elem_value *ucontrol)
615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
616 struct sigmatel_spec *spec = codec->spec;
617 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
619 kcontrol->private_value ^= get_amp_nid(kcontrol);
620 kcontrol->private_value |= nid;
622 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
625 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
626 struct snd_ctl_elem_info *uinfo)
628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
629 struct sigmatel_spec *spec = codec->spec;
630 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
633 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
634 struct snd_ctl_elem_value *ucontrol)
636 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
637 struct sigmatel_spec *spec = codec->spec;
638 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
640 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
644 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
645 struct snd_ctl_elem_value *ucontrol)
647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 struct sigmatel_spec *spec = codec->spec;
649 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
651 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
652 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
655 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_info *uinfo)
658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
659 struct sigmatel_spec *spec = codec->spec;
660 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
663 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
664 struct snd_ctl_elem_value *ucontrol)
666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
667 struct sigmatel_spec *spec = codec->spec;
668 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
670 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
674 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
675 struct snd_ctl_elem_value *ucontrol)
677 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
678 struct sigmatel_spec *spec = codec->spec;
679 struct hda_input_mux *smux = &spec->private_smux;
680 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
684 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
685 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
689 if (spec->spdif_mute) {
691 nid = spec->multiout.dig_out_nid;
693 nid = codec->slave_dig_outs[smux_idx - 1];
694 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
698 /* un/mute SPDIF out */
699 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
705 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
706 hda_nid_t nid, unsigned int new_vref)
710 pincfg = snd_hda_codec_read(codec, nid, 0,
711 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
714 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
717 if (new_vref == AC_PINCTL_VREF_HIZ)
718 pincfg |= AC_PINCTL_OUT_EN;
720 pincfg |= AC_PINCTL_IN_EN;
722 error = snd_hda_codec_write_cache(codec, nid, 0,
723 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
730 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
733 vref = snd_hda_codec_read(codec, nid, 0,
734 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
735 vref &= AC_PINCTL_VREFEN;
739 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
741 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
742 struct sigmatel_spec *spec = codec->spec;
743 return snd_hda_input_mux_info(spec->input_mux, uinfo);
746 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
748 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
749 struct sigmatel_spec *spec = codec->spec;
750 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
752 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
756 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
758 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
759 struct sigmatel_spec *spec = codec->spec;
760 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
761 const struct hda_input_mux *imux = spec->input_mux;
762 unsigned int idx, prev_idx;
764 idx = ucontrol->value.enumerated.item[0];
765 if (idx >= imux->num_items)
766 idx = imux->num_items - 1;
767 prev_idx = spec->cur_mux[adc_idx];
770 if (idx < spec->num_analog_muxes) {
771 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
772 AC_VERB_SET_CONNECT_SEL,
773 imux->items[idx].index);
774 if (prev_idx >= spec->num_analog_muxes) {
775 imux = spec->dinput_mux;
777 snd_hda_codec_write_cache(codec,
778 spec->dmux_nids[adc_idx], 0,
779 AC_VERB_SET_CONNECT_SEL,
780 imux->items[0].index);
783 imux = spec->dinput_mux;
784 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
785 AC_VERB_SET_CONNECT_SEL,
786 imux->items[idx - 1].index);
788 spec->cur_mux[adc_idx] = idx;
792 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
793 struct snd_ctl_elem_info *uinfo)
795 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
796 struct sigmatel_spec *spec = codec->spec;
797 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
800 static int stac92xx_mono_mux_enum_get(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;
806 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
810 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
811 struct snd_ctl_elem_value *ucontrol)
813 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
814 struct sigmatel_spec *spec = codec->spec;
816 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
817 spec->mono_nid, &spec->cur_mmux);
820 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
821 struct snd_ctl_elem_info *uinfo)
823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
824 struct sigmatel_spec *spec = codec->spec;
825 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
828 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
829 struct snd_ctl_elem_value *ucontrol)
831 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
832 struct sigmatel_spec *spec = codec->spec;
834 ucontrol->value.enumerated.item[0] = spec->cur_amux;
838 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
839 struct snd_ctl_elem_value *ucontrol)
841 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
842 struct sigmatel_spec *spec = codec->spec;
843 struct snd_kcontrol *ctl =
844 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
848 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
849 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
851 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
855 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
857 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
858 struct snd_ctl_elem_value *ucontrol)
860 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
861 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
862 struct sigmatel_spec *spec = codec->spec;
864 ucontrol->value.integer.value[0] = !!(spec->aloopback &
865 (spec->aloopback_mask << idx));
869 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
870 struct snd_ctl_elem_value *ucontrol)
872 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
873 struct sigmatel_spec *spec = codec->spec;
874 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
875 unsigned int dac_mode;
876 unsigned int val, idx_val;
878 idx_val = spec->aloopback_mask << idx;
879 if (ucontrol->value.integer.value[0])
880 val = spec->aloopback | idx_val;
882 val = spec->aloopback & ~idx_val;
883 if (spec->aloopback == val)
886 spec->aloopback = val;
888 /* Only return the bits defined by the shift value of the
889 * first two bytes of the mask
891 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
892 kcontrol->private_value & 0xFFFF, 0x0);
893 dac_mode >>= spec->aloopback_shift;
895 if (spec->aloopback & idx_val) {
896 snd_hda_power_up(codec);
899 snd_hda_power_down(codec);
900 dac_mode &= ~idx_val;
903 snd_hda_codec_write_cache(codec, codec->afg, 0,
904 kcontrol->private_value >> 16, dac_mode);
909 static struct hda_verb stac9200_core_init[] = {
910 /* set dac0mux for dac converter */
911 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
915 static struct hda_verb stac9200_eapd_init[] = {
916 /* set dac0mux for dac converter */
917 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
918 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
922 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
923 /* set master volume and direct control */
924 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
925 /* setup adcs to point to mixer */
926 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
927 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
928 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
929 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
930 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
931 /* setup import muxs */
932 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
933 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
934 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
935 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
939 static struct hda_verb dell_eq_core_init[] = {
940 /* set master volume to max value without distortion
941 * and direct control */
942 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
943 /* setup adcs to point to mixer */
944 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
945 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
946 /* setup import muxs */
947 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
948 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
949 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
950 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
954 static struct hda_verb dell_m6_core_init[] = {
955 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
956 /* setup adcs to point to mixer */
957 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
958 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
959 /* setup import muxs */
960 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
961 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
962 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
963 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
967 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
968 /* set master volume and direct control */
969 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
970 /* setup adcs to point to mixer */
971 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
972 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
973 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
974 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
975 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
976 /* setup import muxs */
977 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
978 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
979 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
980 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
984 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
985 /* set master volume and direct control */
986 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
987 /* dac3 is connected to import3 mux */
988 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
989 /* setup adcs to point to mixer */
990 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
991 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
992 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
993 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
994 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
995 /* setup import muxs */
996 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
997 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
998 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
999 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
1003 static struct hda_verb stac92hd83xxx_core_init[] = {
1004 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
1005 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
1006 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
1008 /* power state controls amps */
1009 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
1013 static struct hda_verb stac92hd71bxx_core_init[] = {
1014 /* set master volume and direct control */
1015 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1019 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
1020 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
1021 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1022 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1023 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1027 static struct hda_verb stac925x_core_init[] = {
1028 /* set dac0mux for dac converter */
1029 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
1030 /* mute the master volume */
1031 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1035 static struct hda_verb stac922x_core_init[] = {
1036 /* set master volume and direct control */
1037 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1041 static struct hda_verb d965_core_init[] = {
1042 /* set master volume and direct control */
1043 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1044 /* unmute node 0x1b */
1045 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1046 /* select node 0x03 as DAC */
1047 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
1051 static struct hda_verb stac927x_core_init[] = {
1052 /* set master volume and direct control */
1053 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1054 /* enable analog pc beep path */
1055 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
1059 static struct hda_verb stac9205_core_init[] = {
1060 /* set master volume and direct control */
1061 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1062 /* enable analog pc beep path */
1063 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
1067 #define STAC_MONO_MUX \
1069 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1070 .name = "Mono Mux", \
1072 .info = stac92xx_mono_mux_enum_info, \
1073 .get = stac92xx_mono_mux_enum_get, \
1074 .put = stac92xx_mono_mux_enum_put, \
1077 #define STAC_AMP_MUX \
1079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1080 .name = "Amp Selector Capture Switch", \
1082 .info = stac92xx_amp_mux_enum_info, \
1083 .get = stac92xx_amp_mux_enum_get, \
1084 .put = stac92xx_amp_mux_enum_put, \
1087 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1089 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1092 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1093 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1094 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1095 .info = stac92xx_amp_volume_info, \
1096 .get = stac92xx_amp_volume_get, \
1097 .put = stac92xx_amp_volume_put, \
1098 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1099 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1102 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
1104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1105 .name = "Analog Loopback", \
1107 .info = stac92xx_aloopback_info, \
1108 .get = stac92xx_aloopback_get, \
1109 .put = stac92xx_aloopback_put, \
1110 .private_value = verb_read | (verb_write << 16), \
1113 #define DC_BIAS(xname, idx, nid) \
1115 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1118 .info = stac92xx_dc_bias_info, \
1119 .get = stac92xx_dc_bias_get, \
1120 .put = stac92xx_dc_bias_put, \
1121 .private_value = nid, \
1124 static struct snd_kcontrol_new stac9200_mixer[] = {
1125 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1126 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
1127 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1128 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1132 #define DELL_M6_MIXER 6
1133 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1134 /* start of config #1 */
1135 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1136 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1138 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1139 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1141 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1142 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1144 /* start of config #2 */
1145 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1146 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1148 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1149 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1154 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1155 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1159 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1160 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1164 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1165 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1169 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1170 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1171 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1173 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1174 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1176 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1177 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1179 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1180 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1182 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1183 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1187 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1188 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1189 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1191 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1192 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1194 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1195 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1197 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1198 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1200 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1201 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1206 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1207 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1210 static struct snd_kcontrol_new stac925x_mixer[] = {
1211 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1212 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1216 static struct snd_kcontrol_new stac9205_loopback[] = {
1217 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1221 static struct snd_kcontrol_new stac927x_loopback[] = {
1222 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1226 static struct snd_kcontrol_new stac_dmux_mixer = {
1227 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1228 .name = "Digital Input Source",
1229 /* count set later */
1230 .info = stac92xx_dmux_enum_info,
1231 .get = stac92xx_dmux_enum_get,
1232 .put = stac92xx_dmux_enum_put,
1235 static struct snd_kcontrol_new stac_smux_mixer = {
1236 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1237 .name = "IEC958 Playback Source",
1238 /* count set later */
1239 .info = stac92xx_smux_enum_info,
1240 .get = stac92xx_smux_enum_get,
1241 .put = stac92xx_smux_enum_put,
1244 static const char *slave_vols[] = {
1245 "Front Playback Volume",
1246 "Surround Playback Volume",
1247 "Center Playback Volume",
1248 "LFE Playback Volume",
1249 "Side Playback Volume",
1250 "Headphone Playback Volume",
1251 "Speaker Playback Volume",
1255 static const char *slave_sws[] = {
1256 "Front Playback Switch",
1257 "Surround Playback Switch",
1258 "Center Playback Switch",
1259 "LFE Playback Switch",
1260 "Side Playback Switch",
1261 "Headphone Playback Switch",
1262 "Speaker Playback Switch",
1263 "IEC958 Playback Switch",
1267 static void stac92xx_free_kctls(struct hda_codec *codec);
1268 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1270 static int stac92xx_build_controls(struct hda_codec *codec)
1272 struct sigmatel_spec *spec = codec->spec;
1273 struct auto_pin_cfg *cfg = &spec->autocfg;
1279 err = snd_hda_add_new_ctls(codec, spec->mixer);
1284 for (i = 0; i < spec->num_mixers; i++) {
1285 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1289 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1290 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1291 stac_dmux_mixer.count = spec->num_dmuxes;
1292 err = snd_hda_ctl_add(codec,
1293 snd_ctl_new1(&stac_dmux_mixer, codec));
1297 if (spec->num_smuxes > 0) {
1298 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1299 struct hda_input_mux *smux = &spec->private_smux;
1300 /* check for mute support on SPDIF out */
1301 if (wcaps & AC_WCAP_OUT_AMP) {
1302 smux->items[smux->num_items].label = "Off";
1303 smux->items[smux->num_items].index = 0;
1305 spec->spdif_mute = 1;
1307 stac_smux_mixer.count = spec->num_smuxes;
1308 err = snd_hda_ctl_add(codec,
1309 snd_ctl_new1(&stac_smux_mixer, codec));
1314 if (spec->multiout.dig_out_nid) {
1315 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1318 err = snd_hda_create_spdif_share_sw(codec,
1322 spec->multiout.share_spdif = 1;
1324 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1325 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1330 /* if we have no master control, let's create it */
1331 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1332 unsigned int vmaster_tlv[4];
1333 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1334 HDA_OUTPUT, vmaster_tlv);
1335 /* correct volume offset */
1336 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1337 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1338 vmaster_tlv, slave_vols);
1342 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1343 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1349 if (spec->aloopback_ctl &&
1350 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1351 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1356 stac92xx_free_kctls(codec); /* no longer needed */
1358 /* create jack input elements */
1359 if (spec->hp_detect) {
1360 for (i = 0; i < cfg->hp_outs; i++) {
1361 int type = SND_JACK_HEADPHONE;
1362 nid = cfg->hp_pins[i];
1363 /* jack detection */
1364 if (cfg->hp_outs == i)
1365 type |= SND_JACK_LINEOUT;
1366 err = stac92xx_add_jack(codec, nid, type);
1371 for (i = 0; i < cfg->line_outs; i++) {
1372 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1377 for (i = 0; i < AUTO_PIN_LAST; i++) {
1378 nid = cfg->input_pins[i];
1380 err = stac92xx_add_jack(codec, nid,
1381 SND_JACK_MICROPHONE);
1390 static unsigned int ref9200_pin_configs[8] = {
1391 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1392 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1395 static unsigned int gateway9200_m4_pin_configs[8] = {
1396 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1397 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1399 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1400 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1401 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1405 STAC 9200 pin configs for
1410 static unsigned int dell9200_d21_pin_configs[8] = {
1411 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1412 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1416 STAC 9200 pin configs for
1420 static unsigned int dell9200_d22_pin_configs[8] = {
1421 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1422 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1426 STAC 9200 pin configs for
1427 102801C4 (Dell Dimension E310)
1434 static unsigned int dell9200_d23_pin_configs[8] = {
1435 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1436 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1441 STAC 9200-32 pin configs for
1442 102801B5 (Dell Inspiron 630m)
1443 102801D8 (Dell Inspiron 640m)
1445 static unsigned int dell9200_m21_pin_configs[8] = {
1446 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1447 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1451 STAC 9200-32 pin configs for
1452 102801C2 (Dell Latitude D620)
1454 102801CC (Dell Latitude D820)
1458 static unsigned int dell9200_m22_pin_configs[8] = {
1459 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1460 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1464 STAC 9200-32 pin configs for
1465 102801CE (Dell XPS M1710)
1466 102801CF (Dell Precision M90)
1468 static unsigned int dell9200_m23_pin_configs[8] = {
1469 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1470 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1474 STAC 9200-32 pin configs for
1477 102801CB (Dell Latitude 120L)
1480 static unsigned int dell9200_m24_pin_configs[8] = {
1481 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1482 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1486 STAC 9200-32 pin configs for
1487 102801BD (Dell Inspiron E1505n)
1491 static unsigned int dell9200_m25_pin_configs[8] = {
1492 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1493 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1497 STAC 9200-32 pin configs for
1498 102801F5 (Dell Inspiron 1501)
1501 static unsigned int dell9200_m26_pin_configs[8] = {
1502 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1503 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1508 102801CD (Dell Inspiron E1705/9400)
1510 static unsigned int dell9200_m27_pin_configs[8] = {
1511 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1512 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1515 static unsigned int oqo9200_pin_configs[8] = {
1516 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1517 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1521 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1522 [STAC_REF] = ref9200_pin_configs,
1523 [STAC_9200_OQO] = oqo9200_pin_configs,
1524 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1525 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1526 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1527 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1528 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1529 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1530 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1531 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1532 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1533 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1534 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1535 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1536 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1539 static const char *stac9200_models[STAC_9200_MODELS] = {
1540 [STAC_AUTO] = "auto",
1542 [STAC_9200_OQO] = "oqo",
1543 [STAC_9200_DELL_D21] = "dell-d21",
1544 [STAC_9200_DELL_D22] = "dell-d22",
1545 [STAC_9200_DELL_D23] = "dell-d23",
1546 [STAC_9200_DELL_M21] = "dell-m21",
1547 [STAC_9200_DELL_M22] = "dell-m22",
1548 [STAC_9200_DELL_M23] = "dell-m23",
1549 [STAC_9200_DELL_M24] = "dell-m24",
1550 [STAC_9200_DELL_M25] = "dell-m25",
1551 [STAC_9200_DELL_M26] = "dell-m26",
1552 [STAC_9200_DELL_M27] = "dell-m27",
1553 [STAC_9200_M4] = "gateway-m4",
1554 [STAC_9200_M4_2] = "gateway-m4-2",
1555 [STAC_9200_PANASONIC] = "panasonic",
1558 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1559 /* SigmaTel reference board */
1560 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1561 "DFI LanParty", STAC_REF),
1562 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1563 "DFI LanParty", STAC_REF),
1564 /* Dell laptops have BIOS problem */
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1566 "unknown Dell", STAC_9200_DELL_D21),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1568 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1570 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1572 "unknown Dell", STAC_9200_DELL_D22),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1574 "unknown Dell", STAC_9200_DELL_D22),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1576 "Dell Latitude D620", STAC_9200_DELL_M22),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1578 "unknown Dell", STAC_9200_DELL_D23),
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1580 "unknown Dell", STAC_9200_DELL_D23),
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1582 "unknown Dell", STAC_9200_DELL_M22),
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1584 "unknown Dell", STAC_9200_DELL_M24),
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1586 "unknown Dell", STAC_9200_DELL_M24),
1587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1588 "Dell Latitude 120L", STAC_9200_DELL_M24),
1589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1590 "Dell Latitude D820", STAC_9200_DELL_M22),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1592 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1594 "Dell XPS M1710", STAC_9200_DELL_M23),
1595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1596 "Dell Precision M90", STAC_9200_DELL_M23),
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1598 "unknown Dell", STAC_9200_DELL_M22),
1599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1600 "unknown Dell", STAC_9200_DELL_M22),
1601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1602 "unknown Dell", STAC_9200_DELL_M22),
1603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1604 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1605 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1606 "unknown Dell", STAC_9200_DELL_D23),
1607 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1608 "unknown Dell", STAC_9200_DELL_D23),
1609 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1610 "unknown Dell", STAC_9200_DELL_D21),
1611 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1612 "unknown Dell", STAC_9200_DELL_D23),
1613 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1614 "unknown Dell", STAC_9200_DELL_D21),
1615 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1616 "unknown Dell", STAC_9200_DELL_M25),
1617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1618 "unknown Dell", STAC_9200_DELL_M25),
1619 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1620 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1621 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1622 "unknown Dell", STAC_9200_DELL_M26),
1624 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1625 /* Gateway machines needs EAPD to be set on resume */
1626 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1627 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1628 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1630 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1634 static unsigned int ref925x_pin_configs[8] = {
1635 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1636 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1639 static unsigned int stac925xM1_pin_configs[8] = {
1640 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1641 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1644 static unsigned int stac925xM1_2_pin_configs[8] = {
1645 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1646 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1649 static unsigned int stac925xM2_pin_configs[8] = {
1650 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1651 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1654 static unsigned int stac925xM2_2_pin_configs[8] = {
1655 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1656 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1659 static unsigned int stac925xM3_pin_configs[8] = {
1660 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1661 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1664 static unsigned int stac925xM5_pin_configs[8] = {
1665 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1666 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1669 static unsigned int stac925xM6_pin_configs[8] = {
1670 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1671 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1674 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1675 [STAC_REF] = ref925x_pin_configs,
1676 [STAC_M1] = stac925xM1_pin_configs,
1677 [STAC_M1_2] = stac925xM1_2_pin_configs,
1678 [STAC_M2] = stac925xM2_pin_configs,
1679 [STAC_M2_2] = stac925xM2_2_pin_configs,
1680 [STAC_M3] = stac925xM3_pin_configs,
1681 [STAC_M5] = stac925xM5_pin_configs,
1682 [STAC_M6] = stac925xM6_pin_configs,
1685 static const char *stac925x_models[STAC_925x_MODELS] = {
1686 [STAC_925x_AUTO] = "auto",
1689 [STAC_M1_2] = "m1-2",
1691 [STAC_M2_2] = "m2-2",
1697 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1698 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1699 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1700 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1701 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1702 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1703 /* Not sure about the brand name for those */
1704 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1705 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1706 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1707 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1711 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1712 /* SigmaTel reference board */
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1715 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1717 /* Default table for unknown ID */
1718 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1723 static unsigned int ref92hd73xx_pin_configs[13] = {
1724 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1725 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1726 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1730 static unsigned int dell_m6_pin_configs[13] = {
1731 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1732 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1733 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1737 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1738 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1739 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1740 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1741 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1742 [STAC_DELL_EQ] = dell_m6_pin_configs,
1745 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1746 [STAC_92HD73XX_AUTO] = "auto",
1747 [STAC_92HD73XX_NO_JD] = "no-jd",
1748 [STAC_92HD73XX_REF] = "ref",
1749 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1750 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1751 [STAC_DELL_M6_BOTH] = "dell-m6",
1752 [STAC_DELL_EQ] = "dell-eq",
1755 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1756 /* SigmaTel reference board */
1757 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1758 "DFI LanParty", STAC_92HD73XX_REF),
1759 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1760 "DFI LanParty", STAC_92HD73XX_REF),
1761 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1762 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1763 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1764 "unknown Dell", STAC_DELL_M6_DMIC),
1765 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1766 "unknown Dell", STAC_DELL_M6_BOTH),
1767 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1768 "unknown Dell", STAC_DELL_M6_BOTH),
1769 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1770 "unknown Dell", STAC_DELL_M6_AMIC),
1771 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1772 "unknown Dell", STAC_DELL_M6_AMIC),
1773 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1774 "unknown Dell", STAC_DELL_M6_DMIC),
1775 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1776 "unknown Dell", STAC_DELL_M6_DMIC),
1777 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1778 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1779 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1780 "Dell Studio 17", STAC_DELL_M6_DMIC),
1781 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1782 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1786 static unsigned int ref92hd83xxx_pin_configs[10] = {
1787 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1788 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1789 0x01451160, 0x98560170,
1792 static unsigned int dell_s14_pin_configs[10] = {
1793 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1794 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1795 0x40f000f0, 0x40f000f0,
1798 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1799 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1800 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1801 [STAC_DELL_S14] = dell_s14_pin_configs,
1804 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1805 [STAC_92HD83XXX_AUTO] = "auto",
1806 [STAC_92HD83XXX_REF] = "ref",
1807 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1808 [STAC_DELL_S14] = "dell-s14",
1811 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1812 /* SigmaTel reference board */
1813 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1814 "DFI LanParty", STAC_92HD83XXX_REF),
1815 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1816 "DFI LanParty", STAC_92HD83XXX_REF),
1817 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1818 "unknown Dell", STAC_DELL_S14),
1822 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1823 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1824 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1825 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1829 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1830 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1831 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1832 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1836 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1837 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1838 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1839 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1843 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1844 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1845 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1846 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1850 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1851 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1852 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1853 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1854 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1855 [STAC_HP_M4] = NULL,
1856 [STAC_HP_DV5] = NULL,
1857 [STAC_HP_HDX] = NULL,
1858 [STAC_HP_DV4_1222NR] = NULL,
1861 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1862 [STAC_92HD71BXX_AUTO] = "auto",
1863 [STAC_92HD71BXX_REF] = "ref",
1864 [STAC_DELL_M4_1] = "dell-m4-1",
1865 [STAC_DELL_M4_2] = "dell-m4-2",
1866 [STAC_DELL_M4_3] = "dell-m4-3",
1867 [STAC_HP_M4] = "hp-m4",
1868 [STAC_HP_DV5] = "hp-dv5",
1869 [STAC_HP_HDX] = "hp-hdx",
1870 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1873 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1874 /* SigmaTel reference board */
1875 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1876 "DFI LanParty", STAC_92HD71BXX_REF),
1877 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1878 "DFI LanParty", STAC_92HD71BXX_REF),
1879 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1880 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1881 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1883 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1884 "HP dv4-7", STAC_HP_DV5),
1885 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1886 "HP dv4-7", STAC_HP_DV5),
1887 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1888 "HP HDX", STAC_HP_HDX), /* HDX18 */
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1890 "HP mini 1000", STAC_HP_M4),
1891 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1892 "HP HDX", STAC_HP_HDX), /* HDX16 */
1893 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1896 "unknown Dell", STAC_DELL_M4_1),
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1898 "unknown Dell", STAC_DELL_M4_1),
1899 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1900 "unknown Dell", STAC_DELL_M4_1),
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1902 "unknown Dell", STAC_DELL_M4_1),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1904 "unknown Dell", STAC_DELL_M4_1),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1906 "unknown Dell", STAC_DELL_M4_1),
1907 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1908 "unknown Dell", STAC_DELL_M4_1),
1909 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1910 "unknown Dell", STAC_DELL_M4_2),
1911 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1912 "unknown Dell", STAC_DELL_M4_2),
1913 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1914 "unknown Dell", STAC_DELL_M4_2),
1915 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1916 "unknown Dell", STAC_DELL_M4_2),
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1918 "unknown Dell", STAC_DELL_M4_3),
1922 static unsigned int ref922x_pin_configs[10] = {
1923 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1924 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1925 0x40000100, 0x40000100,
1929 STAC 922X pin configs for
1936 static unsigned int dell_922x_d81_pin_configs[10] = {
1937 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1938 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1939 0x01813122, 0x400001f2,
1943 STAC 922X pin configs for
1947 static unsigned int dell_922x_d82_pin_configs[10] = {
1948 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1949 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1950 0x01813122, 0x400001f1,
1954 STAC 922X pin configs for
1957 static unsigned int dell_922x_m81_pin_configs[10] = {
1958 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1959 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1960 0x40C003f1, 0x405003f0,
1964 STAC 9221 A1 pin configs for
1965 102801D7 (Dell XPS M1210)
1967 static unsigned int dell_922x_m82_pin_configs[10] = {
1968 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1969 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1970 0x508003f3, 0x405003f4,
1973 static unsigned int d945gtp3_pin_configs[10] = {
1974 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1975 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1976 0x02a19120, 0x40000100,
1979 static unsigned int d945gtp5_pin_configs[10] = {
1980 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1981 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1982 0x02a19320, 0x40000100,
1985 static unsigned int intel_mac_v1_pin_configs[10] = {
1986 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1987 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1988 0x400000fc, 0x400000fb,
1991 static unsigned int intel_mac_v2_pin_configs[10] = {
1992 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1993 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1994 0x400000fc, 0x400000fb,
1997 static unsigned int intel_mac_v3_pin_configs[10] = {
1998 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1999 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
2000 0x400000fc, 0x400000fb,
2003 static unsigned int intel_mac_v4_pin_configs[10] = {
2004 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2005 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2006 0x400000fc, 0x400000fb,
2009 static unsigned int intel_mac_v5_pin_configs[10] = {
2010 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2011 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2012 0x400000fc, 0x400000fb,
2015 static unsigned int ecs202_pin_configs[10] = {
2016 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
2017 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
2018 0x9037012e, 0x40e000f2,
2021 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
2022 [STAC_D945_REF] = ref922x_pin_configs,
2023 [STAC_D945GTP3] = d945gtp3_pin_configs,
2024 [STAC_D945GTP5] = d945gtp5_pin_configs,
2025 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
2026 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
2027 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
2028 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
2029 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
2030 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
2031 /* for backward compatibility */
2032 [STAC_MACMINI] = intel_mac_v3_pin_configs,
2033 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
2034 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
2035 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
2036 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
2037 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
2038 [STAC_ECS_202] = ecs202_pin_configs,
2039 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
2040 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
2041 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
2042 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
2045 static const char *stac922x_models[STAC_922X_MODELS] = {
2046 [STAC_922X_AUTO] = "auto",
2047 [STAC_D945_REF] = "ref",
2048 [STAC_D945GTP5] = "5stack",
2049 [STAC_D945GTP3] = "3stack",
2050 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
2051 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
2052 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
2053 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
2054 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
2055 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
2056 /* for backward compatibility */
2057 [STAC_MACMINI] = "macmini",
2058 [STAC_MACBOOK] = "macbook",
2059 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2060 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
2061 [STAC_IMAC_INTEL] = "imac-intel",
2062 [STAC_IMAC_INTEL_20] = "imac-intel-20",
2063 [STAC_ECS_202] = "ecs202",
2064 [STAC_922X_DELL_D81] = "dell-d81",
2065 [STAC_922X_DELL_D82] = "dell-d82",
2066 [STAC_922X_DELL_M81] = "dell-m81",
2067 [STAC_922X_DELL_M82] = "dell-m82",
2070 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2071 /* SigmaTel reference board */
2072 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2073 "DFI LanParty", STAC_D945_REF),
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2075 "DFI LanParty", STAC_D945_REF),
2076 /* Intel 945G based systems */
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2078 "Intel D945G", STAC_D945GTP3),
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2080 "Intel D945G", STAC_D945GTP3),
2081 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2082 "Intel D945G", STAC_D945GTP3),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2084 "Intel D945G", STAC_D945GTP3),
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2086 "Intel D945G", STAC_D945GTP3),
2087 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2088 "Intel D945G", STAC_D945GTP3),
2089 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2090 "Intel D945G", STAC_D945GTP3),
2091 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2092 "Intel D945G", STAC_D945GTP3),
2093 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2094 "Intel D945G", STAC_D945GTP3),
2095 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2096 "Intel D945G", STAC_D945GTP3),
2097 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2098 "Intel D945G", STAC_D945GTP3),
2099 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2100 "Intel D945G", STAC_D945GTP3),
2101 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2102 "Intel D945G", STAC_D945GTP3),
2103 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2104 "Intel D945G", STAC_D945GTP3),
2105 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2106 "Intel D945G", STAC_D945GTP3),
2107 /* Intel D945G 5-stack systems */
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2109 "Intel D945G", STAC_D945GTP5),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2111 "Intel D945G", STAC_D945GTP5),
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2113 "Intel D945G", STAC_D945GTP5),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2115 "Intel D945G", STAC_D945GTP5),
2116 /* Intel 945P based systems */
2117 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2118 "Intel D945P", STAC_D945GTP3),
2119 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2120 "Intel D945P", STAC_D945GTP3),
2121 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2122 "Intel D945P", STAC_D945GTP3),
2123 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2124 "Intel D945P", STAC_D945GTP3),
2125 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2126 "Intel D945P", STAC_D945GTP3),
2127 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2128 "Intel D945P", STAC_D945GTP5),
2130 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2131 "Intel D945", STAC_D945_REF),
2133 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2134 SND_PCI_QUIRK(0x8384, 0x7680,
2135 "Mac", STAC_INTEL_MAC_AUTO),
2137 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2138 "unknown Dell", STAC_922X_DELL_D81),
2139 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2140 "unknown Dell", STAC_922X_DELL_D81),
2141 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2142 "unknown Dell", STAC_922X_DELL_D81),
2143 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2144 "unknown Dell", STAC_922X_DELL_D82),
2145 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2146 "unknown Dell", STAC_922X_DELL_M81),
2147 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2148 "unknown Dell", STAC_922X_DELL_D82),
2149 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2150 "unknown Dell", STAC_922X_DELL_D81),
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2152 "unknown Dell", STAC_922X_DELL_D81),
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2154 "Dell XPS M1210", STAC_922X_DELL_M82),
2155 /* ECS/PC Chips boards */
2156 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2157 "ECS/PC chips", STAC_ECS_202),
2161 static unsigned int ref927x_pin_configs[14] = {
2162 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2163 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2164 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2165 0x01c42190, 0x40000100,
2168 static unsigned int d965_3st_pin_configs[14] = {
2169 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2170 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2171 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2172 0x40000100, 0x40000100
2175 static unsigned int d965_5st_pin_configs[14] = {
2176 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2177 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2178 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2179 0x40000100, 0x40000100
2182 static unsigned int d965_5st_no_fp_pin_configs[14] = {
2183 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2184 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2185 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2186 0x40000100, 0x40000100
2189 static unsigned int dell_3st_pin_configs[14] = {
2190 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2191 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2192 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2193 0x40c003fc, 0x40000100
2196 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2197 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2198 [STAC_D965_REF] = ref927x_pin_configs,
2199 [STAC_D965_3ST] = d965_3st_pin_configs,
2200 [STAC_D965_5ST] = d965_5st_pin_configs,
2201 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2202 [STAC_DELL_3ST] = dell_3st_pin_configs,
2203 [STAC_DELL_BIOS] = NULL,
2206 static const char *stac927x_models[STAC_927X_MODELS] = {
2207 [STAC_927X_AUTO] = "auto",
2208 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2209 [STAC_D965_REF] = "ref",
2210 [STAC_D965_3ST] = "3stack",
2211 [STAC_D965_5ST] = "5stack",
2212 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2213 [STAC_DELL_3ST] = "dell-3stack",
2214 [STAC_DELL_BIOS] = "dell-bios",
2217 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2218 /* SigmaTel reference board */
2219 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2220 "DFI LanParty", STAC_D965_REF),
2221 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2222 "DFI LanParty", STAC_D965_REF),
2223 /* Intel 946 based systems */
2224 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2225 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2226 /* 965 based 3 stack systems */
2227 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2228 "Intel D965", STAC_D965_3ST),
2229 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2230 "Intel D965", STAC_D965_3ST),
2231 /* Dell 3 stack systems */
2232 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2233 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2234 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2235 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2236 /* Dell 3 stack systems with verb table in BIOS */
2237 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2238 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2239 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2240 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2241 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2242 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2243 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2244 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2245 /* 965 based 5 stack systems */
2246 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2247 "Intel D965", STAC_D965_5ST),
2248 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2249 "Intel D965", STAC_D965_5ST),
2253 static unsigned int ref9205_pin_configs[12] = {
2254 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2255 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2256 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2260 STAC 9205 pin configs for
2267 10280228 (Dell Vostro 1500)
2269 static unsigned int dell_9205_m42_pin_configs[12] = {
2270 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2271 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2272 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2276 STAC 9205 pin configs for
2280 102801FF (Dell Precision M4300)
2285 static unsigned int dell_9205_m43_pin_configs[12] = {
2286 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2287 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2288 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2291 static unsigned int dell_9205_m44_pin_configs[12] = {
2292 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2293 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2294 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2297 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2298 [STAC_9205_REF] = ref9205_pin_configs,
2299 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2300 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2301 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2302 [STAC_9205_EAPD] = NULL,
2305 static const char *stac9205_models[STAC_9205_MODELS] = {
2306 [STAC_9205_AUTO] = "auto",
2307 [STAC_9205_REF] = "ref",
2308 [STAC_9205_DELL_M42] = "dell-m42",
2309 [STAC_9205_DELL_M43] = "dell-m43",
2310 [STAC_9205_DELL_M44] = "dell-m44",
2311 [STAC_9205_EAPD] = "eapd",
2314 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2315 /* SigmaTel reference board */
2316 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2317 "DFI LanParty", STAC_9205_REF),
2318 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2319 "SigmaTel", STAC_9205_REF),
2320 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2321 "DFI LanParty", STAC_9205_REF),
2323 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2324 "unknown Dell", STAC_9205_DELL_M42),
2325 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2326 "unknown Dell", STAC_9205_DELL_M42),
2327 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2328 "Dell Precision", STAC_9205_DELL_M43),
2329 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2330 "Dell Precision", STAC_9205_DELL_M43),
2331 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2332 "Dell Precision", STAC_9205_DELL_M43),
2333 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2334 "unknown Dell", STAC_9205_DELL_M42),
2335 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2336 "unknown Dell", STAC_9205_DELL_M42),
2337 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2338 "Dell Precision", STAC_9205_DELL_M43),
2339 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2340 "Dell Precision M4300", STAC_9205_DELL_M43),
2341 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2342 "unknown Dell", STAC_9205_DELL_M42),
2343 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2344 "Dell Precision", STAC_9205_DELL_M43),
2345 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2346 "Dell Precision", STAC_9205_DELL_M43),
2347 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2348 "Dell Precision", STAC_9205_DELL_M43),
2349 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2350 "Dell Inspiron", STAC_9205_DELL_M44),
2351 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2352 "Dell Vostro 1500", STAC_9205_DELL_M42),
2354 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2355 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2359 static void stac92xx_set_config_regs(struct hda_codec *codec,
2360 unsigned int *pincfgs)
2363 struct sigmatel_spec *spec = codec->spec;
2368 for (i = 0; i < spec->num_pins; i++)
2369 if (spec->pin_nids[i] && pincfgs[i])
2370 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2375 * Analog playback callbacks
2377 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2378 struct hda_codec *codec,
2379 struct snd_pcm_substream *substream)
2381 struct sigmatel_spec *spec = codec->spec;
2382 if (spec->stream_delay)
2383 msleep(spec->stream_delay);
2384 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2388 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2389 struct hda_codec *codec,
2390 unsigned int stream_tag,
2391 unsigned int format,
2392 struct snd_pcm_substream *substream)
2394 struct sigmatel_spec *spec = codec->spec;
2395 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2398 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2399 struct hda_codec *codec,
2400 struct snd_pcm_substream *substream)
2402 struct sigmatel_spec *spec = codec->spec;
2403 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2407 * Digital playback callbacks
2409 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2410 struct hda_codec *codec,
2411 struct snd_pcm_substream *substream)
2413 struct sigmatel_spec *spec = codec->spec;
2414 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2417 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2418 struct hda_codec *codec,
2419 struct snd_pcm_substream *substream)
2421 struct sigmatel_spec *spec = codec->spec;
2422 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2425 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2426 struct hda_codec *codec,
2427 unsigned int stream_tag,
2428 unsigned int format,
2429 struct snd_pcm_substream *substream)
2431 struct sigmatel_spec *spec = codec->spec;
2432 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2433 stream_tag, format, substream);
2436 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2437 struct hda_codec *codec,
2438 struct snd_pcm_substream *substream)
2440 struct sigmatel_spec *spec = codec->spec;
2441 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2446 * Analog capture callbacks
2448 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2449 struct hda_codec *codec,
2450 unsigned int stream_tag,
2451 unsigned int format,
2452 struct snd_pcm_substream *substream)
2454 struct sigmatel_spec *spec = codec->spec;
2455 hda_nid_t nid = spec->adc_nids[substream->number];
2457 if (spec->powerdown_adcs) {
2459 snd_hda_codec_write(codec, nid, 0,
2460 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2462 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2466 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2467 struct hda_codec *codec,
2468 struct snd_pcm_substream *substream)
2470 struct sigmatel_spec *spec = codec->spec;
2471 hda_nid_t nid = spec->adc_nids[substream->number];
2473 snd_hda_codec_cleanup_stream(codec, nid);
2474 if (spec->powerdown_adcs)
2475 snd_hda_codec_write(codec, nid, 0,
2476 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2480 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2484 /* NID is set in stac92xx_build_pcms */
2486 .open = stac92xx_dig_playback_pcm_open,
2487 .close = stac92xx_dig_playback_pcm_close,
2488 .prepare = stac92xx_dig_playback_pcm_prepare,
2489 .cleanup = stac92xx_dig_playback_pcm_cleanup
2493 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2497 /* NID is set in stac92xx_build_pcms */
2500 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2504 .nid = 0x02, /* NID to query formats and rates */
2506 .open = stac92xx_playback_pcm_open,
2507 .prepare = stac92xx_playback_pcm_prepare,
2508 .cleanup = stac92xx_playback_pcm_cleanup
2512 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2516 .nid = 0x06, /* NID to query formats and rates */
2518 .open = stac92xx_playback_pcm_open,
2519 .prepare = stac92xx_playback_pcm_prepare,
2520 .cleanup = stac92xx_playback_pcm_cleanup
2524 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2527 /* NID + .substreams is set in stac92xx_build_pcms */
2529 .prepare = stac92xx_capture_pcm_prepare,
2530 .cleanup = stac92xx_capture_pcm_cleanup
2534 static int stac92xx_build_pcms(struct hda_codec *codec)
2536 struct sigmatel_spec *spec = codec->spec;
2537 struct hda_pcm *info = spec->pcm_rec;
2539 codec->num_pcms = 1;
2540 codec->pcm_info = info;
2542 info->name = "STAC92xx Analog";
2543 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2544 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2545 spec->multiout.dac_nids[0];
2546 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2547 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2548 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2550 if (spec->alt_switch) {
2553 info->name = "STAC92xx Analog Alt";
2554 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2557 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2560 info->name = "STAC92xx Digital";
2561 info->pcm_type = spec->autocfg.dig_out_type[0];
2562 if (spec->multiout.dig_out_nid) {
2563 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2564 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2566 if (spec->dig_in_nid) {
2567 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2568 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2575 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2578 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2579 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2580 if (pincap & AC_PINCAP_VREF_100)
2581 return AC_PINCTL_VREF_100;
2582 if (pincap & AC_PINCAP_VREF_80)
2583 return AC_PINCTL_VREF_80;
2584 if (pincap & AC_PINCAP_VREF_50)
2585 return AC_PINCTL_VREF_50;
2586 if (pincap & AC_PINCAP_VREF_GRD)
2587 return AC_PINCTL_VREF_GRD;
2591 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2594 snd_hda_codec_write_cache(codec, nid, 0,
2595 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2598 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2600 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2601 struct snd_ctl_elem_value *ucontrol)
2603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2604 struct sigmatel_spec *spec = codec->spec;
2606 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2610 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2612 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2613 struct snd_ctl_elem_value *ucontrol)
2615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2616 struct sigmatel_spec *spec = codec->spec;
2617 int nid = kcontrol->private_value;
2619 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2621 /* check to be sure that the ports are upto date with
2624 stac_issue_unsol_event(codec, nid);
2629 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2630 struct snd_ctl_elem_info *uinfo)
2633 static char *texts[] = {
2634 "Mic In", "Line In", "Line Out"
2637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2638 struct sigmatel_spec *spec = codec->spec;
2639 hda_nid_t nid = kcontrol->private_value;
2641 if (nid == spec->mic_switch || nid == spec->line_switch)
2646 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2647 uinfo->value.enumerated.items = i;
2649 if (uinfo->value.enumerated.item >= i)
2650 uinfo->value.enumerated.item = i-1;
2651 strcpy(uinfo->value.enumerated.name,
2652 texts[uinfo->value.enumerated.item]);
2657 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2658 struct snd_ctl_elem_value *ucontrol)
2660 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2661 hda_nid_t nid = kcontrol->private_value;
2662 unsigned int vref = stac92xx_vref_get(codec, nid);
2664 if (vref == stac92xx_get_default_vref(codec, nid))
2665 ucontrol->value.enumerated.item[0] = 0;
2666 else if (vref == AC_PINCTL_VREF_GRD)
2667 ucontrol->value.enumerated.item[0] = 1;
2668 else if (vref == AC_PINCTL_VREF_HIZ)
2669 ucontrol->value.enumerated.item[0] = 2;
2674 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2675 struct snd_ctl_elem_value *ucontrol)
2677 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2678 unsigned int new_vref = 0;
2680 hda_nid_t nid = kcontrol->private_value;
2682 if (ucontrol->value.enumerated.item[0] == 0)
2683 new_vref = stac92xx_get_default_vref(codec, nid);
2684 else if (ucontrol->value.enumerated.item[0] == 1)
2685 new_vref = AC_PINCTL_VREF_GRD;
2686 else if (ucontrol->value.enumerated.item[0] == 2)
2687 new_vref = AC_PINCTL_VREF_HIZ;
2691 if (new_vref != stac92xx_vref_get(codec, nid)) {
2692 error = stac92xx_vref_set(codec, nid, new_vref);
2699 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2700 struct snd_ctl_elem_info *uinfo)
2702 static char *texts[2];
2703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2704 struct sigmatel_spec *spec = codec->spec;
2706 if (kcontrol->private_value == spec->line_switch)
2707 texts[0] = "Line In";
2709 texts[0] = "Mic In";
2710 texts[1] = "Line Out";
2711 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2712 uinfo->value.enumerated.items = 2;
2715 if (uinfo->value.enumerated.item >= 2)
2716 uinfo->value.enumerated.item = 1;
2717 strcpy(uinfo->value.enumerated.name,
2718 texts[uinfo->value.enumerated.item]);
2723 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2725 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2726 struct sigmatel_spec *spec = codec->spec;
2727 hda_nid_t nid = kcontrol->private_value;
2728 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2730 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2734 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2736 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2737 struct sigmatel_spec *spec = codec->spec;
2738 hda_nid_t nid = kcontrol->private_value;
2739 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2740 unsigned short val = !!ucontrol->value.enumerated.item[0];
2742 spec->io_switch[io_idx] = val;
2745 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2747 unsigned int pinctl = AC_PINCTL_IN_EN;
2748 if (io_idx) /* set VREF for mic */
2749 pinctl |= stac92xx_get_default_vref(codec, nid);
2750 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2753 /* check the auto-mute again: we need to mute/unmute the speaker
2754 * appropriately according to the pin direction
2756 if (spec->hp_detect)
2757 stac_issue_unsol_event(codec, nid);
2762 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2764 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2765 struct snd_ctl_elem_value *ucontrol)
2767 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2768 struct sigmatel_spec *spec = codec->spec;
2770 ucontrol->value.integer.value[0] = spec->clfe_swap;
2774 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2775 struct snd_ctl_elem_value *ucontrol)
2777 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2778 struct sigmatel_spec *spec = codec->spec;
2779 hda_nid_t nid = kcontrol->private_value & 0xff;
2780 unsigned int val = !!ucontrol->value.integer.value[0];
2782 if (spec->clfe_swap == val)
2785 spec->clfe_swap = val;
2787 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2788 spec->clfe_swap ? 0x4 : 0x0);
2793 #define STAC_CODEC_HP_SWITCH(xname) \
2794 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2797 .info = stac92xx_hp_switch_info, \
2798 .get = stac92xx_hp_switch_get, \
2799 .put = stac92xx_hp_switch_put, \
2802 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2803 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2806 .info = stac92xx_io_switch_info, \
2807 .get = stac92xx_io_switch_get, \
2808 .put = stac92xx_io_switch_put, \
2809 .private_value = xpval, \
2812 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2813 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2816 .info = stac92xx_clfe_switch_info, \
2817 .get = stac92xx_clfe_switch_get, \
2818 .put = stac92xx_clfe_switch_put, \
2819 .private_value = xpval, \
2823 STAC_CTL_WIDGET_VOL,
2824 STAC_CTL_WIDGET_MUTE,
2825 STAC_CTL_WIDGET_MONO_MUX,
2826 STAC_CTL_WIDGET_AMP_MUX,
2827 STAC_CTL_WIDGET_AMP_VOL,
2828 STAC_CTL_WIDGET_HP_SWITCH,
2829 STAC_CTL_WIDGET_IO_SWITCH,
2830 STAC_CTL_WIDGET_CLFE_SWITCH,
2831 STAC_CTL_WIDGET_DC_BIAS
2834 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2835 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2836 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2839 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2840 STAC_CODEC_HP_SWITCH(NULL),
2841 STAC_CODEC_IO_SWITCH(NULL, 0),
2842 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2843 DC_BIAS(NULL, 0, 0),
2846 /* add dynamic controls */
2847 static struct snd_kcontrol_new *
2848 stac_control_new(struct sigmatel_spec *spec,
2849 struct snd_kcontrol_new *ktemp,
2852 struct snd_kcontrol_new *knew;
2854 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2855 knew = snd_array_new(&spec->kctls);
2859 knew->name = kstrdup(name, GFP_KERNEL);
2862 memset(knew, 0, sizeof(*knew));
2863 spec->kctls.alloced--;
2869 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2870 struct snd_kcontrol_new *ktemp,
2871 int idx, const char *name,
2874 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2878 knew->private_value = val;
2882 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2883 int type, int idx, const char *name,
2886 return stac92xx_add_control_temp(spec,
2887 &stac92xx_control_templates[type],
2892 /* add dynamic controls */
2893 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2894 const char *name, unsigned long val)
2896 return stac92xx_add_control_idx(spec, type, 0, name, val);
2899 static struct snd_kcontrol_new stac_input_src_temp = {
2900 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2901 .name = "Input Source",
2902 .info = stac92xx_mux_enum_info,
2903 .get = stac92xx_mux_enum_get,
2904 .put = stac92xx_mux_enum_put,
2907 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2908 hda_nid_t nid, int idx)
2910 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2912 struct sigmatel_spec *spec = codec->spec;
2915 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2916 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2917 && nid == spec->line_switch)
2918 control = STAC_CTL_WIDGET_IO_SWITCH;
2919 else if (snd_hda_query_pin_caps(codec, nid)
2920 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2921 control = STAC_CTL_WIDGET_DC_BIAS;
2922 else if (nid == spec->mic_switch)
2923 control = STAC_CTL_WIDGET_IO_SWITCH;
2927 strcpy(name, auto_pin_cfg_labels[idx]);
2928 return stac92xx_add_control(codec->spec, control,
2929 strcat(name, " Jack Mode"), nid);
2935 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2937 struct snd_kcontrol_new *knew;
2938 struct hda_input_mux *imux = &spec->private_imux;
2941 return 0; /* no need for input source */
2942 if (!spec->num_adcs || imux->num_items <= 1)
2943 return 0; /* no need for input source control */
2944 knew = stac_control_new(spec, &stac_input_src_temp,
2945 stac_input_src_temp.name);
2948 knew->count = spec->num_adcs;
2952 /* check whether the line-input can be used as line-out */
2953 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2955 struct sigmatel_spec *spec = codec->spec;
2956 struct auto_pin_cfg *cfg = &spec->autocfg;
2958 unsigned int pincap;
2960 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2962 nid = cfg->input_pins[AUTO_PIN_LINE];
2963 pincap = snd_hda_query_pin_caps(codec, nid);
2964 if (pincap & AC_PINCAP_OUT)
2969 /* check whether the mic-input can be used as line-out */
2970 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2972 struct sigmatel_spec *spec = codec->spec;
2973 struct auto_pin_cfg *cfg = &spec->autocfg;
2974 unsigned int def_conf, pincap;
2975 unsigned int mic_pin;
2977 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2979 mic_pin = AUTO_PIN_MIC;
2981 hda_nid_t nid = cfg->input_pins[mic_pin];
2982 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2983 /* some laptops have an internal analog microphone
2984 * which can't be used as a output */
2985 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2986 pincap = snd_hda_query_pin_caps(codec, nid);
2987 if (pincap & AC_PINCAP_OUT)
2990 if (mic_pin == AUTO_PIN_MIC)
2991 mic_pin = AUTO_PIN_FRONT_MIC;
2998 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3002 for (i = 0; i < spec->multiout.num_dacs; i++) {
3003 if (spec->multiout.dac_nids[i] == nid)
3010 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3013 if (is_in_dac_nids(spec, nid))
3015 for (i = 0; i < spec->autocfg.hp_outs; i++)
3016 if (spec->hp_dacs[i] == nid)
3018 for (i = 0; i < spec->autocfg.speaker_outs; i++)
3019 if (spec->speaker_dacs[i] == nid)
3024 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
3026 struct sigmatel_spec *spec = codec->spec;
3028 hda_nid_t conn[HDA_MAX_CONNECTIONS];
3029 unsigned int wcaps, wtype;
3031 conn_len = snd_hda_get_connections(codec, nid, conn,
3032 HDA_MAX_CONNECTIONS);
3033 for (j = 0; j < conn_len; j++) {
3034 wcaps = get_wcaps(codec, conn[j]);
3035 wtype = get_wcaps_type(wcaps);
3036 /* we check only analog outputs */
3037 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
3039 /* if this route has a free DAC, assign it */
3040 if (!check_all_dac_nids(spec, conn[j])) {
3042 /* select this DAC in the pin's input mux */
3043 snd_hda_codec_write_cache(codec, nid, 0,
3044 AC_VERB_SET_CONNECT_SEL, j);
3049 /* if all DACs are already assigned, connect to the primary DAC */
3051 for (j = 0; j < conn_len; j++) {
3052 if (conn[j] == spec->multiout.dac_nids[0]) {
3053 snd_hda_codec_write_cache(codec, nid, 0,
3054 AC_VERB_SET_CONNECT_SEL, j);
3062 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3063 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3066 * Fill in the dac_nids table from the parsed pin configuration
3067 * This function only works when every pin in line_out_pins[]
3068 * contains atleast one DAC in its connection list. Some 92xx
3069 * codecs are not connected directly to a DAC, such as the 9200
3070 * and 9202/925x. For those, dac_nids[] must be hard-coded.
3072 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
3074 struct sigmatel_spec *spec = codec->spec;
3075 struct auto_pin_cfg *cfg = &spec->autocfg;
3079 for (i = 0; i < cfg->line_outs; i++) {
3080 nid = cfg->line_out_pins[i];
3081 dac = get_unassigned_dac(codec, nid);
3083 if (spec->multiout.num_dacs > 0) {
3084 /* we have already working output pins,
3085 * so let's drop the broken ones again
3087 cfg->line_outs = spec->multiout.num_dacs;
3090 /* error out, no available DAC found */
3092 "%s: No available DAC for pin 0x%x\n",
3096 add_spec_dacs(spec, dac);
3099 for (i = 0; i < cfg->hp_outs; i++) {
3100 nid = cfg->hp_pins[i];
3101 dac = get_unassigned_dac(codec, nid);
3103 if (!spec->multiout.hp_nid)
3104 spec->multiout.hp_nid = dac;
3106 add_spec_extra_dacs(spec, dac);
3108 spec->hp_dacs[i] = dac;
3111 for (i = 0; i < cfg->speaker_outs; i++) {
3112 nid = cfg->speaker_pins[i];
3113 dac = get_unassigned_dac(codec, nid);
3115 add_spec_extra_dacs(spec, dac);
3116 spec->speaker_dacs[i] = dac;
3119 /* add line-in as output */
3120 nid = check_line_out_switch(codec);
3122 dac = get_unassigned_dac(codec, nid);
3124 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3125 nid, cfg->line_outs);
3126 cfg->line_out_pins[cfg->line_outs] = nid;
3128 spec->line_switch = nid;
3129 add_spec_dacs(spec, dac);
3132 /* add mic as output */
3133 nid = check_mic_out_switch(codec);
3135 dac = get_unassigned_dac(codec, nid);
3137 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3138 nid, cfg->line_outs);
3139 cfg->line_out_pins[cfg->line_outs] = nid;
3141 spec->mic_switch = nid;
3142 add_spec_dacs(spec, dac);
3146 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3147 spec->multiout.num_dacs,
3148 spec->multiout.dac_nids[0],
3149 spec->multiout.dac_nids[1],
3150 spec->multiout.dac_nids[2],
3151 spec->multiout.dac_nids[3],
3152 spec->multiout.dac_nids[4]);
3157 /* create volume control/switch for the given prefx type */
3158 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3159 int idx, hda_nid_t nid, int chs)
3161 struct sigmatel_spec *spec = codec->spec;
3165 if (!spec->check_volume_offset) {
3166 unsigned int caps, step, nums, db_scale;
3167 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3168 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3169 AC_AMPCAP_STEP_SIZE_SHIFT;
3170 step = (step + 1) * 25; /* in .01dB unit */
3171 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3172 AC_AMPCAP_NUM_STEPS_SHIFT;
3173 db_scale = nums * step;
3174 /* if dB scale is over -64dB, and finer enough,