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"
78 STAC_92HD73XX_NO_JD, /* no jack-detection */
90 STAC_92HD83XXX_PWR_REF,
105 STAC_92HD71BXX_MODELS
131 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
132 * is given, one of the above models will be
133 * chosen according to the subsystem id. */
134 /* for backward compatibility */
151 STAC_D965_REF_NO_JD, /* no jack-detection */
167 struct sigmatel_event {
174 struct sigmatel_jack {
177 struct snd_jack *jack;
180 struct sigmatel_mic_route {
182 unsigned char mux_idx;
183 unsigned char dmux_idx;
186 struct sigmatel_spec {
187 struct snd_kcontrol_new *mixers[4];
188 unsigned int num_mixers;
191 unsigned int eapd_switch: 1;
192 unsigned int surr_switch: 1;
193 unsigned int alt_switch: 1;
194 unsigned int hp_detect: 1;
195 unsigned int spdif_mute: 1;
196 unsigned int check_volume_offset:1;
197 unsigned int auto_mic:1;
200 unsigned int eapd_mask;
201 unsigned int gpio_mask;
202 unsigned int gpio_dir;
203 unsigned int gpio_data;
204 unsigned int gpio_mute;
205 unsigned int gpio_led;
208 unsigned int stream_delay;
210 /* analog loopback */
211 struct snd_kcontrol_new *aloopback_ctl;
212 unsigned char aloopback_mask;
213 unsigned char aloopback_shift;
215 /* power management */
216 unsigned int num_pwrs;
217 unsigned int *pwr_mapping;
222 struct snd_array jacks;
225 struct snd_array events;
228 struct hda_input_mux *mono_mux;
229 struct hda_input_mux *amp_mux;
230 unsigned int cur_mmux;
231 struct hda_multi_out multiout;
232 hda_nid_t dac_nids[5];
233 hda_nid_t hp_dacs[5];
234 hda_nid_t speaker_dacs[5];
240 unsigned int num_adcs;
242 unsigned int num_muxes;
243 hda_nid_t *dmic_nids;
244 unsigned int num_dmics;
245 hda_nid_t *dmux_nids;
246 unsigned int num_dmuxes;
247 hda_nid_t *smux_nids;
248 unsigned int num_smuxes;
250 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
251 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
252 unsigned int num_caps; /* number of capture volume/switch elements */
254 struct sigmatel_mic_route ext_mic;
255 struct sigmatel_mic_route int_mic;
257 const char **spdif_labels;
259 hda_nid_t dig_in_nid;
261 hda_nid_t anabeep_nid;
262 hda_nid_t digbeep_nid;
266 unsigned int num_pins;
268 /* codec specific stuff */
269 struct hda_verb *init;
270 struct snd_kcontrol_new *mixer;
273 struct hda_input_mux *dinput_mux;
274 unsigned int cur_dmux[2];
275 struct hda_input_mux *input_mux;
276 unsigned int cur_mux[3];
277 struct hda_input_mux *sinput_mux;
278 unsigned int cur_smux[2];
279 unsigned int cur_amux;
281 unsigned int num_amps;
282 unsigned int powerdown_adcs;
285 unsigned int io_switch[2];
286 unsigned int clfe_swap;
287 hda_nid_t line_switch; /* shared line-in for input and output */
288 hda_nid_t mic_switch; /* shared mic-in for input and output */
289 hda_nid_t hp_switch; /* NID of HP as line-out */
290 unsigned int aloopback;
292 struct hda_pcm pcm_rec[2]; /* PCM information */
294 /* dynamic controls and input_mux */
295 struct auto_pin_cfg autocfg;
296 struct snd_array kctls;
297 struct hda_input_mux private_dimux;
298 struct hda_input_mux private_imux;
299 struct hda_input_mux private_smux;
300 struct hda_input_mux private_amp_mux;
301 struct hda_input_mux private_mono_mux;
304 static hda_nid_t stac9200_adc_nids[1] = {
308 static hda_nid_t stac9200_mux_nids[1] = {
312 static hda_nid_t stac9200_dac_nids[1] = {
316 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
317 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
321 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
325 static hda_nid_t stac92hd73xx_adc_nids[2] = {
329 #define DELL_M6_AMP 2
330 static hda_nid_t stac92hd73xx_amp_nids[3] = {
334 #define STAC92HD73XX_NUM_DMICS 2
335 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
339 #define STAC92HD73_DAC_COUNT 5
341 static hda_nid_t stac92hd73xx_mux_nids[4] = {
342 0x28, 0x29, 0x2a, 0x2b,
345 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
349 static hda_nid_t stac92hd73xx_smux_nids[2] = {
353 #define STAC92HD73XX_NUM_CAPS 2
354 static unsigned long stac92hd73xx_capvols[] = {
355 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
356 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
358 #define stac92hd73xx_capsws stac92hd73xx_capvols
360 #define STAC92HD83XXX_NUM_DMICS 2
361 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
365 #define STAC92HD83_DAC_COUNT 3
367 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
371 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
375 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
379 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
383 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
384 0x03, 0x0c, 0x20, 0x40,
387 static hda_nid_t stac92hd83xxx_amp_nids[1] = {
391 #define STAC92HD83XXX_NUM_CAPS 2
392 static unsigned long stac92hd83xxx_capvols[] = {
393 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
394 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
396 #define stac92hd83xxx_capsws stac92hd83xxx_capvols
398 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
402 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
406 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
410 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
414 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
418 #define STAC92HD71BXX_NUM_DMICS 2
419 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
423 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
427 #define STAC92HD71BXX_NUM_CAPS 2
428 static unsigned long stac92hd71bxx_capvols[] = {
429 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
430 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
432 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
434 static hda_nid_t stac925x_adc_nids[1] = {
438 static hda_nid_t stac925x_mux_nids[1] = {
442 static hda_nid_t stac925x_dac_nids[1] = {
446 #define STAC925X_NUM_DMICS 1
447 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
451 static hda_nid_t stac925x_dmux_nids[1] = {
455 static unsigned long stac925x_capvols[] = {
456 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
458 static unsigned long stac925x_capsws[] = {
459 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
462 static hda_nid_t stac922x_adc_nids[2] = {
466 static hda_nid_t stac922x_mux_nids[2] = {
470 #define STAC922X_NUM_CAPS 2
471 static unsigned long stac922x_capvols[] = {
472 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
473 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
475 #define stac922x_capsws stac922x_capvols
477 static hda_nid_t stac927x_slave_dig_outs[2] = {
481 static hda_nid_t stac927x_adc_nids[3] = {
485 static hda_nid_t stac927x_mux_nids[3] = {
489 static hda_nid_t stac927x_smux_nids[1] = {
493 static hda_nid_t stac927x_dac_nids[6] = {
494 0x02, 0x03, 0x04, 0x05, 0x06, 0
497 static hda_nid_t stac927x_dmux_nids[1] = {
501 #define STAC927X_NUM_DMICS 2
502 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
506 #define STAC927X_NUM_CAPS 3
507 static unsigned long stac927x_capvols[] = {
508 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
509 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
510 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
512 static unsigned long stac927x_capsws[] = {
513 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
514 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
515 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
518 static const char *stac927x_spdif_labels[5] = {
519 "Digital Playback", "ADAT", "Analog Mux 1",
520 "Analog Mux 2", "Analog Mux 3"
523 static hda_nid_t stac9205_adc_nids[2] = {
527 static hda_nid_t stac9205_mux_nids[2] = {
531 static hda_nid_t stac9205_dmux_nids[1] = {
535 static hda_nid_t stac9205_smux_nids[1] = {
539 #define STAC9205_NUM_DMICS 2
540 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
544 #define STAC9205_NUM_CAPS 2
545 static unsigned long stac9205_capvols[] = {
546 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
547 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
549 static unsigned long stac9205_capsws[] = {
550 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
551 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
554 static hda_nid_t stac9200_pin_nids[8] = {
555 0x08, 0x09, 0x0d, 0x0e,
556 0x0f, 0x10, 0x11, 0x12,
559 static hda_nid_t stac925x_pin_nids[8] = {
560 0x07, 0x08, 0x0a, 0x0b,
561 0x0c, 0x0d, 0x10, 0x11,
564 static hda_nid_t stac922x_pin_nids[10] = {
565 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
566 0x0f, 0x10, 0x11, 0x15, 0x1b,
569 static hda_nid_t stac92hd73xx_pin_nids[13] = {
570 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
571 0x0f, 0x10, 0x11, 0x12, 0x13,
575 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
576 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
577 0x0f, 0x10, 0x11, 0x1f, 0x20,
580 #define STAC92HD71BXX_NUM_PINS 13
581 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
582 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
583 0x00, 0x14, 0x18, 0x19, 0x1e,
586 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
587 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
588 0x0f, 0x14, 0x18, 0x19, 0x1e,
592 static hda_nid_t stac927x_pin_nids[14] = {
593 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
594 0x0f, 0x10, 0x11, 0x12, 0x13,
595 0x14, 0x21, 0x22, 0x23,
598 static hda_nid_t stac9205_pin_nids[12] = {
599 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
600 0x0f, 0x14, 0x16, 0x17, 0x18,
604 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
606 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
607 struct snd_ctl_elem_value *ucontrol)
609 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
610 struct sigmatel_spec *spec = codec->spec;
611 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
613 kcontrol->private_value ^= get_amp_nid(kcontrol);
614 kcontrol->private_value |= nid;
616 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
619 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
620 struct snd_ctl_elem_value *ucontrol)
622 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
623 struct sigmatel_spec *spec = codec->spec;
624 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
626 kcontrol->private_value ^= get_amp_nid(kcontrol);
627 kcontrol->private_value |= nid;
629 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
632 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_info *uinfo)
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 struct sigmatel_spec *spec = codec->spec;
637 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
640 static int stac92xx_dmux_enum_get(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 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
647 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
651 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_value *ucontrol)
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
656 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
658 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
659 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
662 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
663 struct snd_ctl_elem_info *uinfo)
665 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
666 struct sigmatel_spec *spec = codec->spec;
667 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
670 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
671 struct snd_ctl_elem_value *ucontrol)
673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
674 struct sigmatel_spec *spec = codec->spec;
675 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
677 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
681 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
682 struct snd_ctl_elem_value *ucontrol)
684 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
685 struct sigmatel_spec *spec = codec->spec;
686 struct hda_input_mux *smux = &spec->private_smux;
687 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
691 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
692 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
696 if (spec->spdif_mute) {
698 nid = spec->multiout.dig_out_nid;
700 nid = codec->slave_dig_outs[smux_idx - 1];
701 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
705 /* un/mute SPDIF out */
706 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
712 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
713 hda_nid_t nid, unsigned int new_vref)
717 pincfg = snd_hda_codec_read(codec, nid, 0,
718 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
721 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
724 if (new_vref == AC_PINCTL_VREF_HIZ)
725 pincfg |= AC_PINCTL_OUT_EN;
727 pincfg |= AC_PINCTL_IN_EN;
729 error = snd_hda_codec_write_cache(codec, nid, 0,
730 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
737 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
740 vref = snd_hda_codec_read(codec, nid, 0,
741 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
742 vref &= AC_PINCTL_VREFEN;
746 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
748 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
749 struct sigmatel_spec *spec = codec->spec;
750 return snd_hda_input_mux_info(spec->input_mux, uinfo);
753 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
755 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
756 struct sigmatel_spec *spec = codec->spec;
757 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
759 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
763 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
765 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
766 struct sigmatel_spec *spec = codec->spec;
767 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
769 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
770 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
773 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
774 struct snd_ctl_elem_info *uinfo)
776 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
777 struct sigmatel_spec *spec = codec->spec;
778 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
781 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
782 struct snd_ctl_elem_value *ucontrol)
784 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
785 struct sigmatel_spec *spec = codec->spec;
787 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
791 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
792 struct snd_ctl_elem_value *ucontrol)
794 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
795 struct sigmatel_spec *spec = codec->spec;
797 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
798 spec->mono_nid, &spec->cur_mmux);
801 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
802 struct snd_ctl_elem_info *uinfo)
804 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
805 struct sigmatel_spec *spec = codec->spec;
806 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
809 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
810 struct snd_ctl_elem_value *ucontrol)
812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
813 struct sigmatel_spec *spec = codec->spec;
815 ucontrol->value.enumerated.item[0] = spec->cur_amux;
819 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
820 struct snd_ctl_elem_value *ucontrol)
822 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
823 struct sigmatel_spec *spec = codec->spec;
824 struct snd_kcontrol *ctl =
825 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
829 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
830 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
832 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
836 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
838 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
839 struct snd_ctl_elem_value *ucontrol)
841 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
842 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
843 struct sigmatel_spec *spec = codec->spec;
845 ucontrol->value.integer.value[0] = !!(spec->aloopback &
846 (spec->aloopback_mask << idx));
850 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
851 struct snd_ctl_elem_value *ucontrol)
853 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
854 struct sigmatel_spec *spec = codec->spec;
855 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
856 unsigned int dac_mode;
857 unsigned int val, idx_val;
859 idx_val = spec->aloopback_mask << idx;
860 if (ucontrol->value.integer.value[0])
861 val = spec->aloopback | idx_val;
863 val = spec->aloopback & ~idx_val;
864 if (spec->aloopback == val)
867 spec->aloopback = val;
869 /* Only return the bits defined by the shift value of the
870 * first two bytes of the mask
872 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
873 kcontrol->private_value & 0xFFFF, 0x0);
874 dac_mode >>= spec->aloopback_shift;
876 if (spec->aloopback & idx_val) {
877 snd_hda_power_up(codec);
880 snd_hda_power_down(codec);
881 dac_mode &= ~idx_val;
884 snd_hda_codec_write_cache(codec, codec->afg, 0,
885 kcontrol->private_value >> 16, dac_mode);
890 static struct hda_verb stac9200_core_init[] = {
891 /* set dac0mux for dac converter */
892 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
896 static struct hda_verb stac9200_eapd_init[] = {
897 /* set dac0mux for dac converter */
898 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
899 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
903 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
904 /* set master volume and direct control */
905 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
906 /* setup adcs to point to mixer */
907 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
908 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
909 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
910 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
911 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
912 /* setup import muxs */
913 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
914 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
915 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
916 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
920 static struct hda_verb dell_eq_core_init[] = {
921 /* set master volume to max value without distortion
922 * and direct control */
923 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
924 /* setup adcs to point to mixer */
925 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
926 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
927 /* setup import muxs */
928 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
929 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
930 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
931 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
935 static struct hda_verb dell_m6_core_init[] = {
936 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
937 /* setup adcs to point to mixer */
938 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
939 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
940 /* setup import muxs */
941 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
942 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
943 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
944 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
948 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
949 /* set master volume and direct control */
950 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
951 /* setup adcs to point to mixer */
952 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
953 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
954 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
955 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
956 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
957 /* setup import muxs */
958 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
959 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
960 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
961 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
965 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
966 /* set master volume and direct control */
967 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
968 /* dac3 is connected to import3 mux */
969 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
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 stac92hd83xxx_core_init[] = {
985 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
986 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
987 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
989 /* power state controls amps */
990 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
994 static struct hda_verb stac92hd71bxx_core_init[] = {
995 /* set master volume and direct control */
996 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1000 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
1001 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
1002 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1003 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1004 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1008 static struct hda_verb stac925x_core_init[] = {
1009 /* set dac0mux for dac converter */
1010 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
1011 /* mute the master volume */
1012 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1016 static struct hda_verb stac922x_core_init[] = {
1017 /* set master volume and direct control */
1018 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1022 static struct hda_verb d965_core_init[] = {
1023 /* set master volume and direct control */
1024 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1025 /* unmute node 0x1b */
1026 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1027 /* select node 0x03 as DAC */
1028 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
1032 static struct hda_verb stac927x_core_init[] = {
1033 /* set master volume and direct control */
1034 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1035 /* enable analog pc beep path */
1036 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
1040 static struct hda_verb stac9205_core_init[] = {
1041 /* set master volume and direct control */
1042 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1043 /* enable analog pc beep path */
1044 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
1048 #define STAC_MONO_MUX \
1050 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1051 .name = "Mono Mux", \
1053 .info = stac92xx_mono_mux_enum_info, \
1054 .get = stac92xx_mono_mux_enum_get, \
1055 .put = stac92xx_mono_mux_enum_put, \
1058 #define STAC_AMP_MUX \
1060 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1061 .name = "Amp Selector Capture Switch", \
1063 .info = stac92xx_amp_mux_enum_info, \
1064 .get = stac92xx_amp_mux_enum_get, \
1065 .put = stac92xx_amp_mux_enum_put, \
1068 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1070 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1073 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1074 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1075 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1076 .info = stac92xx_amp_volume_info, \
1077 .get = stac92xx_amp_volume_get, \
1078 .put = stac92xx_amp_volume_put, \
1079 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1080 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1083 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
1085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1086 .name = "Analog Loopback", \
1088 .info = stac92xx_aloopback_info, \
1089 .get = stac92xx_aloopback_get, \
1090 .put = stac92xx_aloopback_put, \
1091 .private_value = verb_read | (verb_write << 16), \
1094 #define DC_BIAS(xname, idx, nid) \
1096 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1099 .info = stac92xx_dc_bias_info, \
1100 .get = stac92xx_dc_bias_get, \
1101 .put = stac92xx_dc_bias_put, \
1102 .private_value = nid, \
1105 static struct snd_kcontrol_new stac9200_mixer[] = {
1106 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1107 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
1108 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1109 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1113 #define DELL_M6_MIXER 6
1114 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1115 /* start of config #1 */
1116 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1117 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1119 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1120 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1122 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1123 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1125 /* start of config #2 */
1126 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1127 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1129 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1130 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1135 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1136 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1140 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1141 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1145 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1146 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1150 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1151 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1152 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1154 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1155 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1157 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1158 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1160 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1161 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1163 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1164 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1168 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1169 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1170 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1172 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1173 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1175 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1176 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1178 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1179 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1181 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1182 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1187 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1188 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1189 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
1191 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1192 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
1194 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1195 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
1197 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1198 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
1201 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1202 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
1207 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1208 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1209 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1211 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1212 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1214 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1215 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1217 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1218 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1222 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1223 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1226 static struct snd_kcontrol_new stac925x_mixer[] = {
1227 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1228 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1232 static struct snd_kcontrol_new stac9205_loopback[] = {
1233 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1237 static struct snd_kcontrol_new stac927x_loopback[] = {
1238 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1242 static struct snd_kcontrol_new stac_dmux_mixer = {
1243 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1244 .name = "Digital Input Source",
1245 /* count set later */
1246 .info = stac92xx_dmux_enum_info,
1247 .get = stac92xx_dmux_enum_get,
1248 .put = stac92xx_dmux_enum_put,
1251 static struct snd_kcontrol_new stac_smux_mixer = {
1252 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1253 .name = "IEC958 Playback Source",
1254 /* count set later */
1255 .info = stac92xx_smux_enum_info,
1256 .get = stac92xx_smux_enum_get,
1257 .put = stac92xx_smux_enum_put,
1260 static const char *slave_vols[] = {
1261 "Front Playback Volume",
1262 "Surround Playback Volume",
1263 "Center Playback Volume",
1264 "LFE Playback Volume",
1265 "Side Playback Volume",
1266 "Headphone Playback Volume",
1267 "Speaker Playback Volume",
1271 static const char *slave_sws[] = {
1272 "Front Playback Switch",
1273 "Surround Playback Switch",
1274 "Center Playback Switch",
1275 "LFE Playback Switch",
1276 "Side Playback Switch",
1277 "Headphone Playback Switch",
1278 "Speaker Playback Switch",
1279 "IEC958 Playback Switch",
1283 static void stac92xx_free_kctls(struct hda_codec *codec);
1284 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1286 static int stac92xx_build_controls(struct hda_codec *codec)
1288 struct sigmatel_spec *spec = codec->spec;
1289 struct auto_pin_cfg *cfg = &spec->autocfg;
1295 err = snd_hda_add_new_ctls(codec, spec->mixer);
1300 for (i = 0; i < spec->num_mixers; i++) {
1301 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1305 if (!spec->auto_mic && spec->num_dmuxes > 0) {
1306 stac_dmux_mixer.count = spec->num_dmuxes;
1307 err = snd_hda_ctl_add(codec,
1308 snd_ctl_new1(&stac_dmux_mixer, codec));
1312 if (spec->num_smuxes > 0) {
1313 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1314 struct hda_input_mux *smux = &spec->private_smux;
1315 /* check for mute support on SPDIF out */
1316 if (wcaps & AC_WCAP_OUT_AMP) {
1317 smux->items[smux->num_items].label = "Off";
1318 smux->items[smux->num_items].index = 0;
1320 spec->spdif_mute = 1;
1322 stac_smux_mixer.count = spec->num_smuxes;
1323 err = snd_hda_ctl_add(codec,
1324 snd_ctl_new1(&stac_smux_mixer, codec));
1329 if (spec->multiout.dig_out_nid) {
1330 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1333 err = snd_hda_create_spdif_share_sw(codec,
1337 spec->multiout.share_spdif = 1;
1339 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1340 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1345 /* if we have no master control, let's create it */
1346 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1347 unsigned int vmaster_tlv[4];
1348 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1349 HDA_OUTPUT, vmaster_tlv);
1350 /* correct volume offset */
1351 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1352 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1353 vmaster_tlv, slave_vols);
1357 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1358 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1364 if (spec->aloopback_ctl &&
1365 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1366 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1371 stac92xx_free_kctls(codec); /* no longer needed */
1373 /* create jack input elements */
1374 if (spec->hp_detect) {
1375 for (i = 0; i < cfg->hp_outs; i++) {
1376 int type = SND_JACK_HEADPHONE;
1377 nid = cfg->hp_pins[i];
1378 /* jack detection */
1379 if (cfg->hp_outs == i)
1380 type |= SND_JACK_LINEOUT;
1381 err = stac92xx_add_jack(codec, nid, type);
1386 for (i = 0; i < cfg->line_outs; i++) {
1387 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1392 for (i = 0; i < AUTO_PIN_LAST; i++) {
1393 nid = cfg->input_pins[i];
1395 err = stac92xx_add_jack(codec, nid,
1396 SND_JACK_MICROPHONE);
1405 static unsigned int ref9200_pin_configs[8] = {
1406 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1407 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1410 static unsigned int gateway9200_m4_pin_configs[8] = {
1411 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1412 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1414 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1415 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1416 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1420 STAC 9200 pin configs for
1425 static unsigned int dell9200_d21_pin_configs[8] = {
1426 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1427 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1431 STAC 9200 pin configs for
1435 static unsigned int dell9200_d22_pin_configs[8] = {
1436 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1437 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1441 STAC 9200 pin configs for
1442 102801C4 (Dell Dimension E310)
1449 static unsigned int dell9200_d23_pin_configs[8] = {
1450 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1451 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1456 STAC 9200-32 pin configs for
1457 102801B5 (Dell Inspiron 630m)
1458 102801D8 (Dell Inspiron 640m)
1460 static unsigned int dell9200_m21_pin_configs[8] = {
1461 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1462 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1466 STAC 9200-32 pin configs for
1467 102801C2 (Dell Latitude D620)
1469 102801CC (Dell Latitude D820)
1473 static unsigned int dell9200_m22_pin_configs[8] = {
1474 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1475 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1479 STAC 9200-32 pin configs for
1480 102801CE (Dell XPS M1710)
1481 102801CF (Dell Precision M90)
1483 static unsigned int dell9200_m23_pin_configs[8] = {
1484 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1485 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1489 STAC 9200-32 pin configs for
1492 102801CB (Dell Latitude 120L)
1495 static unsigned int dell9200_m24_pin_configs[8] = {
1496 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1497 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1501 STAC 9200-32 pin configs for
1502 102801BD (Dell Inspiron E1505n)
1506 static unsigned int dell9200_m25_pin_configs[8] = {
1507 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1508 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1512 STAC 9200-32 pin configs for
1513 102801F5 (Dell Inspiron 1501)
1516 static unsigned int dell9200_m26_pin_configs[8] = {
1517 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1518 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1523 102801CD (Dell Inspiron E1705/9400)
1525 static unsigned int dell9200_m27_pin_configs[8] = {
1526 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1527 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1530 static unsigned int oqo9200_pin_configs[8] = {
1531 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1532 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1536 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1537 [STAC_REF] = ref9200_pin_configs,
1538 [STAC_9200_OQO] = oqo9200_pin_configs,
1539 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1540 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1541 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1542 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1543 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1544 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1545 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1546 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1547 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1548 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1549 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1550 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1551 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1554 static const char *stac9200_models[STAC_9200_MODELS] = {
1555 [STAC_AUTO] = "auto",
1557 [STAC_9200_OQO] = "oqo",
1558 [STAC_9200_DELL_D21] = "dell-d21",
1559 [STAC_9200_DELL_D22] = "dell-d22",
1560 [STAC_9200_DELL_D23] = "dell-d23",
1561 [STAC_9200_DELL_M21] = "dell-m21",
1562 [STAC_9200_DELL_M22] = "dell-m22",
1563 [STAC_9200_DELL_M23] = "dell-m23",
1564 [STAC_9200_DELL_M24] = "dell-m24",
1565 [STAC_9200_DELL_M25] = "dell-m25",
1566 [STAC_9200_DELL_M26] = "dell-m26",
1567 [STAC_9200_DELL_M27] = "dell-m27",
1568 [STAC_9200_M4] = "gateway-m4",
1569 [STAC_9200_M4_2] = "gateway-m4-2",
1570 [STAC_9200_PANASONIC] = "panasonic",
1573 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1574 /* SigmaTel reference board */
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1576 "DFI LanParty", STAC_REF),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1578 "DFI LanParty", STAC_REF),
1579 /* Dell laptops have BIOS problem */
1580 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1581 "unknown Dell", STAC_9200_DELL_D21),
1582 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1583 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1584 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1585 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1586 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1587 "unknown Dell", STAC_9200_DELL_D22),
1588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1589 "unknown Dell", STAC_9200_DELL_D22),
1590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1591 "Dell Latitude D620", STAC_9200_DELL_M22),
1592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1593 "unknown Dell", STAC_9200_DELL_D23),
1594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1595 "unknown Dell", STAC_9200_DELL_D23),
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1597 "unknown Dell", STAC_9200_DELL_M22),
1598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1599 "unknown Dell", STAC_9200_DELL_M24),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1601 "unknown Dell", STAC_9200_DELL_M24),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1603 "Dell Latitude 120L", STAC_9200_DELL_M24),
1604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1605 "Dell Latitude D820", STAC_9200_DELL_M22),
1606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1607 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1609 "Dell XPS M1710", STAC_9200_DELL_M23),
1610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1611 "Dell Precision M90", STAC_9200_DELL_M23),
1612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1613 "unknown Dell", STAC_9200_DELL_M22),
1614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1615 "unknown Dell", STAC_9200_DELL_M22),
1616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1617 "unknown Dell", STAC_9200_DELL_M22),
1618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1619 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1621 "unknown Dell", STAC_9200_DELL_D23),
1622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1623 "unknown Dell", STAC_9200_DELL_D23),
1624 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1625 "unknown Dell", STAC_9200_DELL_D21),
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1627 "unknown Dell", STAC_9200_DELL_D23),
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1629 "unknown Dell", STAC_9200_DELL_D21),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1631 "unknown Dell", STAC_9200_DELL_M25),
1632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1633 "unknown Dell", STAC_9200_DELL_M25),
1634 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1635 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1637 "unknown Dell", STAC_9200_DELL_M26),
1639 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1640 /* Gateway machines needs EAPD to be set on resume */
1641 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1642 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1643 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1645 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1649 static unsigned int ref925x_pin_configs[8] = {
1650 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1651 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1654 static unsigned int stac925xM1_pin_configs[8] = {
1655 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1656 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1659 static unsigned int stac925xM1_2_pin_configs[8] = {
1660 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1661 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1664 static unsigned int stac925xM2_pin_configs[8] = {
1665 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1666 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1669 static unsigned int stac925xM2_2_pin_configs[8] = {
1670 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1671 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1674 static unsigned int stac925xM3_pin_configs[8] = {
1675 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1676 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1679 static unsigned int stac925xM5_pin_configs[8] = {
1680 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1681 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1684 static unsigned int stac925xM6_pin_configs[8] = {
1685 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1686 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1689 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1690 [STAC_REF] = ref925x_pin_configs,
1691 [STAC_M1] = stac925xM1_pin_configs,
1692 [STAC_M1_2] = stac925xM1_2_pin_configs,
1693 [STAC_M2] = stac925xM2_pin_configs,
1694 [STAC_M2_2] = stac925xM2_2_pin_configs,
1695 [STAC_M3] = stac925xM3_pin_configs,
1696 [STAC_M5] = stac925xM5_pin_configs,
1697 [STAC_M6] = stac925xM6_pin_configs,
1700 static const char *stac925x_models[STAC_925x_MODELS] = {
1701 [STAC_925x_AUTO] = "auto",
1704 [STAC_M1_2] = "m1-2",
1706 [STAC_M2_2] = "m2-2",
1712 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1713 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1714 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1715 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1716 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1717 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1718 /* Not sure about the brand name for those */
1719 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1720 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1721 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1722 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1726 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1727 /* SigmaTel reference board */
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1729 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1730 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1732 /* Default table for unknown ID */
1733 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1738 static unsigned int ref92hd73xx_pin_configs[13] = {
1739 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1740 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1741 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1745 static unsigned int dell_m6_pin_configs[13] = {
1746 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1747 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1748 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1752 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1753 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1754 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1755 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1756 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1757 [STAC_DELL_EQ] = dell_m6_pin_configs,
1760 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1761 [STAC_92HD73XX_AUTO] = "auto",
1762 [STAC_92HD73XX_NO_JD] = "no-jd",
1763 [STAC_92HD73XX_REF] = "ref",
1764 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1765 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1766 [STAC_DELL_M6_BOTH] = "dell-m6",
1767 [STAC_DELL_EQ] = "dell-eq",
1770 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1771 /* SigmaTel reference board */
1772 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1773 "DFI LanParty", STAC_92HD73XX_REF),
1774 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1775 "DFI LanParty", STAC_92HD73XX_REF),
1776 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1777 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1778 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1779 "unknown Dell", STAC_DELL_M6_DMIC),
1780 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1781 "unknown Dell", STAC_DELL_M6_BOTH),
1782 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1783 "unknown Dell", STAC_DELL_M6_BOTH),
1784 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1785 "unknown Dell", STAC_DELL_M6_AMIC),
1786 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1787 "unknown Dell", STAC_DELL_M6_AMIC),
1788 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1789 "unknown Dell", STAC_DELL_M6_DMIC),
1790 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1791 "unknown Dell", STAC_DELL_M6_DMIC),
1792 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1793 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1794 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1795 "Dell Studio 17", STAC_DELL_M6_DMIC),
1799 static unsigned int ref92hd83xxx_pin_configs[10] = {
1800 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1801 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1802 0x01451160, 0x98560170,
1805 static unsigned int dell_s14_pin_configs[10] = {
1806 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1807 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1808 0x40f000f0, 0x40f000f0,
1811 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1812 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1813 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1814 [STAC_DELL_S14] = dell_s14_pin_configs,
1817 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1818 [STAC_92HD83XXX_AUTO] = "auto",
1819 [STAC_92HD83XXX_REF] = "ref",
1820 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1821 [STAC_DELL_S14] = "dell-s14",
1824 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1825 /* SigmaTel reference board */
1826 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1827 "DFI LanParty", STAC_92HD83XXX_REF),
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1829 "DFI LanParty", STAC_92HD83XXX_REF),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1831 "unknown Dell", STAC_DELL_S14),
1835 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1836 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1837 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1838 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1842 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1843 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1844 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1845 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1849 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1850 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1851 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1852 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1856 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1857 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1858 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1859 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1863 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1864 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1865 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1866 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1867 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1868 [STAC_HP_M4] = NULL,
1869 [STAC_HP_DV5] = NULL,
1870 [STAC_HP_HDX] = NULL,
1871 [STAC_HP_DV4_1222NR] = NULL,
1874 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1875 [STAC_92HD71BXX_AUTO] = "auto",
1876 [STAC_92HD71BXX_REF] = "ref",
1877 [STAC_DELL_M4_1] = "dell-m4-1",
1878 [STAC_DELL_M4_2] = "dell-m4-2",
1879 [STAC_DELL_M4_3] = "dell-m4-3",
1880 [STAC_HP_M4] = "hp-m4",
1881 [STAC_HP_DV5] = "hp-dv5",
1882 [STAC_HP_HDX] = "hp-hdx",
1883 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1886 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1887 /* SigmaTel reference board */
1888 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1889 "DFI LanParty", STAC_92HD71BXX_REF),
1890 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1891 "DFI LanParty", STAC_92HD71BXX_REF),
1892 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1893 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1894 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1896 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1897 "HP dv4-7", STAC_HP_DV5),
1898 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1899 "HP dv4-7", STAC_HP_DV5),
1900 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1901 "HP HDX", STAC_HP_HDX), /* HDX18 */
1902 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1903 "HP mini 1000", STAC_HP_M4),
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1905 "HP HDX", STAC_HP_HDX), /* HDX16 */
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1907 "unknown Dell", STAC_DELL_M4_1),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1909 "unknown Dell", STAC_DELL_M4_1),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1911 "unknown Dell", STAC_DELL_M4_1),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1913 "unknown Dell", STAC_DELL_M4_1),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1915 "unknown Dell", STAC_DELL_M4_1),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1917 "unknown Dell", STAC_DELL_M4_1),
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1919 "unknown Dell", STAC_DELL_M4_1),
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1921 "unknown Dell", STAC_DELL_M4_2),
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1923 "unknown Dell", STAC_DELL_M4_2),
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1925 "unknown Dell", STAC_DELL_M4_2),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1927 "unknown Dell", STAC_DELL_M4_2),
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1929 "unknown Dell", STAC_DELL_M4_3),
1933 static unsigned int ref922x_pin_configs[10] = {
1934 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1935 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1936 0x40000100, 0x40000100,
1940 STAC 922X pin configs for
1947 static unsigned int dell_922x_d81_pin_configs[10] = {
1948 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1949 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1950 0x01813122, 0x400001f2,
1954 STAC 922X pin configs for
1958 static unsigned int dell_922x_d82_pin_configs[10] = {
1959 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1960 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1961 0x01813122, 0x400001f1,
1965 STAC 922X pin configs for
1968 static unsigned int dell_922x_m81_pin_configs[10] = {
1969 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1970 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1971 0x40C003f1, 0x405003f0,
1975 STAC 9221 A1 pin configs for
1976 102801D7 (Dell XPS M1210)
1978 static unsigned int dell_922x_m82_pin_configs[10] = {
1979 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1980 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1981 0x508003f3, 0x405003f4,
1984 static unsigned int d945gtp3_pin_configs[10] = {
1985 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1986 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1987 0x02a19120, 0x40000100,
1990 static unsigned int d945gtp5_pin_configs[10] = {
1991 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1992 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1993 0x02a19320, 0x40000100,
1996 static unsigned int intel_mac_v1_pin_configs[10] = {
1997 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1998 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1999 0x400000fc, 0x400000fb,
2002 static unsigned int intel_mac_v2_pin_configs[10] = {
2003 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2004 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
2005 0x400000fc, 0x400000fb,
2008 static unsigned int intel_mac_v3_pin_configs[10] = {
2009 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2010 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
2011 0x400000fc, 0x400000fb,
2014 static unsigned int intel_mac_v4_pin_configs[10] = {
2015 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2016 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2017 0x400000fc, 0x400000fb,
2020 static unsigned int intel_mac_v5_pin_configs[10] = {
2021 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2022 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2023 0x400000fc, 0x400000fb,
2026 static unsigned int ecs202_pin_configs[10] = {
2027 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
2028 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
2029 0x9037012e, 0x40e000f2,
2032 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
2033 [STAC_D945_REF] = ref922x_pin_configs,
2034 [STAC_D945GTP3] = d945gtp3_pin_configs,
2035 [STAC_D945GTP5] = d945gtp5_pin_configs,
2036 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
2037 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
2038 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
2039 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
2040 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
2041 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
2042 /* for backward compatibility */
2043 [STAC_MACMINI] = intel_mac_v3_pin_configs,
2044 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
2045 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
2046 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
2047 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
2048 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
2049 [STAC_ECS_202] = ecs202_pin_configs,
2050 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
2051 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
2052 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
2053 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
2056 static const char *stac922x_models[STAC_922X_MODELS] = {
2057 [STAC_922X_AUTO] = "auto",
2058 [STAC_D945_REF] = "ref",
2059 [STAC_D945GTP5] = "5stack",
2060 [STAC_D945GTP3] = "3stack",
2061 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
2062 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
2063 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
2064 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
2065 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
2066 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
2067 /* for backward compatibility */
2068 [STAC_MACMINI] = "macmini",
2069 [STAC_MACBOOK] = "macbook",
2070 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2071 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
2072 [STAC_IMAC_INTEL] = "imac-intel",
2073 [STAC_IMAC_INTEL_20] = "imac-intel-20",
2074 [STAC_ECS_202] = "ecs202",
2075 [STAC_922X_DELL_D81] = "dell-d81",
2076 [STAC_922X_DELL_D82] = "dell-d82",
2077 [STAC_922X_DELL_M81] = "dell-m81",
2078 [STAC_922X_DELL_M82] = "dell-m82",
2081 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2082 /* SigmaTel reference board */
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2084 "DFI LanParty", STAC_D945_REF),
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2086 "DFI LanParty", STAC_D945_REF),
2087 /* Intel 945G based systems */
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2089 "Intel D945G", STAC_D945GTP3),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2091 "Intel D945G", STAC_D945GTP3),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2093 "Intel D945G", STAC_D945GTP3),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2095 "Intel D945G", STAC_D945GTP3),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2097 "Intel D945G", STAC_D945GTP3),
2098 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2099 "Intel D945G", STAC_D945GTP3),
2100 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2101 "Intel D945G", STAC_D945GTP3),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2103 "Intel D945G", STAC_D945GTP3),
2104 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2105 "Intel D945G", STAC_D945GTP3),
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2107 "Intel D945G", STAC_D945GTP3),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2109 "Intel D945G", STAC_D945GTP3),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2111 "Intel D945G", STAC_D945GTP3),
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2113 "Intel D945G", STAC_D945GTP3),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2115 "Intel D945G", STAC_D945GTP3),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2117 "Intel D945G", STAC_D945GTP3),
2118 /* Intel D945G 5-stack systems */
2119 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2120 "Intel D945G", STAC_D945GTP5),
2121 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2122 "Intel D945G", STAC_D945GTP5),
2123 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2124 "Intel D945G", STAC_D945GTP5),
2125 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2126 "Intel D945G", STAC_D945GTP5),
2127 /* Intel 945P based systems */
2128 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2129 "Intel D945P", STAC_D945GTP3),
2130 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2131 "Intel D945P", STAC_D945GTP3),
2132 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2133 "Intel D945P", STAC_D945GTP3),
2134 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2135 "Intel D945P", STAC_D945GTP3),
2136 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2137 "Intel D945P", STAC_D945GTP3),
2138 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2139 "Intel D945P", STAC_D945GTP5),
2141 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2142 "Intel D945", STAC_D945_REF),
2144 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2145 SND_PCI_QUIRK(0x8384, 0x7680,
2146 "Mac", STAC_INTEL_MAC_AUTO),
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2149 "unknown Dell", STAC_922X_DELL_D81),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2151 "unknown Dell", STAC_922X_DELL_D81),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2153 "unknown Dell", STAC_922X_DELL_D81),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2155 "unknown Dell", STAC_922X_DELL_D82),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2157 "unknown Dell", STAC_922X_DELL_M81),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2159 "unknown Dell", STAC_922X_DELL_D82),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2161 "unknown Dell", STAC_922X_DELL_D81),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2163 "unknown Dell", STAC_922X_DELL_D81),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2165 "Dell XPS M1210", STAC_922X_DELL_M82),
2166 /* ECS/PC Chips boards */
2167 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2168 "ECS/PC chips", STAC_ECS_202),
2172 static unsigned int ref927x_pin_configs[14] = {
2173 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2174 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2175 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2176 0x01c42190, 0x40000100,
2179 static unsigned int d965_3st_pin_configs[14] = {
2180 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2181 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2182 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2183 0x40000100, 0x40000100
2186 static unsigned int d965_5st_pin_configs[14] = {
2187 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2188 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2189 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2190 0x40000100, 0x40000100
2193 static unsigned int d965_5st_no_fp_pin_configs[14] = {
2194 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2195 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2196 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2197 0x40000100, 0x40000100
2200 static unsigned int dell_3st_pin_configs[14] = {
2201 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2202 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2203 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2204 0x40c003fc, 0x40000100
2207 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2208 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2209 [STAC_D965_REF] = ref927x_pin_configs,
2210 [STAC_D965_3ST] = d965_3st_pin_configs,
2211 [STAC_D965_5ST] = d965_5st_pin_configs,
2212 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2213 [STAC_DELL_3ST] = dell_3st_pin_configs,
2214 [STAC_DELL_BIOS] = NULL,
2217 static const char *stac927x_models[STAC_927X_MODELS] = {
2218 [STAC_927X_AUTO] = "auto",
2219 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2220 [STAC_D965_REF] = "ref",
2221 [STAC_D965_3ST] = "3stack",
2222 [STAC_D965_5ST] = "5stack",
2223 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2224 [STAC_DELL_3ST] = "dell-3stack",
2225 [STAC_DELL_BIOS] = "dell-bios",
2228 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2229 /* SigmaTel reference board */
2230 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2231 "DFI LanParty", STAC_D965_REF),
2232 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2233 "DFI LanParty", STAC_D965_REF),
2234 /* Intel 946 based systems */
2235 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2236 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2237 /* 965 based 3 stack systems */
2238 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2239 "Intel D965", STAC_D965_3ST),
2240 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2241 "Intel D965", STAC_D965_3ST),
2242 /* Dell 3 stack systems */
2243 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2244 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2245 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2246 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2247 /* Dell 3 stack systems with verb table in BIOS */
2248 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2249 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2250 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2251 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2252 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2253 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2254 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2255 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2256 /* 965 based 5 stack systems */
2257 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2258 "Intel D965", STAC_D965_5ST),
2259 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2260 "Intel D965", STAC_D965_5ST),
2264 static unsigned int ref9205_pin_configs[12] = {
2265 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2266 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2267 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2271 STAC 9205 pin configs for
2278 10280228 (Dell Vostro 1500)
2280 static unsigned int dell_9205_m42_pin_configs[12] = {
2281 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2282 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2283 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2287 STAC 9205 pin configs for
2291 102801FF (Dell Precision M4300)
2296 static unsigned int dell_9205_m43_pin_configs[12] = {
2297 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2298 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2299 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2302 static unsigned int dell_9205_m44_pin_configs[12] = {
2303 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2304 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2305 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2308 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2309 [STAC_9205_REF] = ref9205_pin_configs,
2310 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2311 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2312 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2313 [STAC_9205_EAPD] = NULL,
2316 static const char *stac9205_models[STAC_9205_MODELS] = {
2317 [STAC_9205_AUTO] = "auto",
2318 [STAC_9205_REF] = "ref",
2319 [STAC_9205_DELL_M42] = "dell-m42",
2320 [STAC_9205_DELL_M43] = "dell-m43",
2321 [STAC_9205_DELL_M44] = "dell-m44",
2322 [STAC_9205_EAPD] = "eapd",
2325 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2326 /* SigmaTel reference board */
2327 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2328 "DFI LanParty", STAC_9205_REF),
2329 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2330 "SigmaTel", STAC_9205_REF),
2331 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2332 "DFI LanParty", STAC_9205_REF),
2334 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2335 "unknown Dell", STAC_9205_DELL_M42),
2336 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2337 "unknown Dell", STAC_9205_DELL_M42),
2338 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2339 "Dell Precision", STAC_9205_DELL_M43),
2340 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2341 "Dell Precision", STAC_9205_DELL_M43),
2342 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2343 "Dell Precision", STAC_9205_DELL_M43),
2344 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2345 "unknown Dell", STAC_9205_DELL_M42),
2346 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2347 "unknown Dell", STAC_9205_DELL_M42),
2348 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2349 "Dell Precision", STAC_9205_DELL_M43),
2350 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2351 "Dell Precision M4300", STAC_9205_DELL_M43),
2352 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2353 "unknown Dell", STAC_9205_DELL_M42),
2354 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2355 "Dell Precision", STAC_9205_DELL_M43),
2356 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2357 "Dell Precision", STAC_9205_DELL_M43),
2358 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2359 "Dell Precision", STAC_9205_DELL_M43),
2360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2361 "Dell Inspiron", STAC_9205_DELL_M44),
2362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2363 "Dell Vostro 1500", STAC_9205_DELL_M42),
2365 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2366 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2370 static void stac92xx_set_config_regs(struct hda_codec *codec,
2371 unsigned int *pincfgs)
2374 struct sigmatel_spec *spec = codec->spec;
2379 for (i = 0; i < spec->num_pins; i++)
2380 if (spec->pin_nids[i] && pincfgs[i])
2381 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2386 * Analog playback callbacks
2388 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2389 struct hda_codec *codec,
2390 struct snd_pcm_substream *substream)
2392 struct sigmatel_spec *spec = codec->spec;
2393 if (spec->stream_delay)
2394 msleep(spec->stream_delay);
2395 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2399 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2400 struct hda_codec *codec,
2401 unsigned int stream_tag,
2402 unsigned int format,
2403 struct snd_pcm_substream *substream)
2405 struct sigmatel_spec *spec = codec->spec;
2406 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2409 static int stac92xx_playback_pcm_cleanup(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_analog_cleanup(codec, &spec->multiout);
2418 * Digital playback callbacks
2420 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2421 struct hda_codec *codec,
2422 struct snd_pcm_substream *substream)
2424 struct sigmatel_spec *spec = codec->spec;
2425 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2428 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2429 struct hda_codec *codec,
2430 struct snd_pcm_substream *substream)
2432 struct sigmatel_spec *spec = codec->spec;
2433 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2436 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2437 struct hda_codec *codec,
2438 unsigned int stream_tag,
2439 unsigned int format,
2440 struct snd_pcm_substream *substream)
2442 struct sigmatel_spec *spec = codec->spec;
2443 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2444 stream_tag, format, substream);
2447 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2448 struct hda_codec *codec,
2449 struct snd_pcm_substream *substream)
2451 struct sigmatel_spec *spec = codec->spec;
2452 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2457 * Analog capture callbacks
2459 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2460 struct hda_codec *codec,
2461 unsigned int stream_tag,
2462 unsigned int format,
2463 struct snd_pcm_substream *substream)
2465 struct sigmatel_spec *spec = codec->spec;
2466 hda_nid_t nid = spec->adc_nids[substream->number];
2468 if (spec->powerdown_adcs) {
2470 snd_hda_codec_write(codec, nid, 0,
2471 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2473 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2477 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2478 struct hda_codec *codec,
2479 struct snd_pcm_substream *substream)
2481 struct sigmatel_spec *spec = codec->spec;
2482 hda_nid_t nid = spec->adc_nids[substream->number];
2484 snd_hda_codec_cleanup_stream(codec, nid);
2485 if (spec->powerdown_adcs)
2486 snd_hda_codec_write(codec, nid, 0,
2487 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2491 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2495 /* NID is set in stac92xx_build_pcms */
2497 .open = stac92xx_dig_playback_pcm_open,
2498 .close = stac92xx_dig_playback_pcm_close,
2499 .prepare = stac92xx_dig_playback_pcm_prepare,
2500 .cleanup = stac92xx_dig_playback_pcm_cleanup
2504 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2508 /* NID is set in stac92xx_build_pcms */
2511 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2515 .nid = 0x02, /* NID to query formats and rates */
2517 .open = stac92xx_playback_pcm_open,
2518 .prepare = stac92xx_playback_pcm_prepare,
2519 .cleanup = stac92xx_playback_pcm_cleanup
2523 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2527 .nid = 0x06, /* NID to query formats and rates */
2529 .open = stac92xx_playback_pcm_open,
2530 .prepare = stac92xx_playback_pcm_prepare,
2531 .cleanup = stac92xx_playback_pcm_cleanup
2535 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2538 /* NID + .substreams is set in stac92xx_build_pcms */
2540 .prepare = stac92xx_capture_pcm_prepare,
2541 .cleanup = stac92xx_capture_pcm_cleanup
2545 static int stac92xx_build_pcms(struct hda_codec *codec)
2547 struct sigmatel_spec *spec = codec->spec;
2548 struct hda_pcm *info = spec->pcm_rec;
2550 codec->num_pcms = 1;
2551 codec->pcm_info = info;
2553 info->name = "STAC92xx Analog";
2554 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2555 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2556 spec->multiout.dac_nids[0];
2557 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2558 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2559 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2561 if (spec->alt_switch) {
2564 info->name = "STAC92xx Analog Alt";
2565 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2568 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2571 info->name = "STAC92xx Digital";
2572 info->pcm_type = spec->autocfg.dig_out_type[0];
2573 if (spec->multiout.dig_out_nid) {
2574 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2575 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2577 if (spec->dig_in_nid) {
2578 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2579 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2586 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2589 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2590 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2591 if (pincap & AC_PINCAP_VREF_100)
2592 return AC_PINCTL_VREF_100;
2593 if (pincap & AC_PINCAP_VREF_80)
2594 return AC_PINCTL_VREF_80;
2595 if (pincap & AC_PINCAP_VREF_50)
2596 return AC_PINCTL_VREF_50;
2597 if (pincap & AC_PINCAP_VREF_GRD)
2598 return AC_PINCTL_VREF_GRD;
2602 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2605 snd_hda_codec_write_cache(codec, nid, 0,
2606 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2609 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2611 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2612 struct snd_ctl_elem_value *ucontrol)
2614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2615 struct sigmatel_spec *spec = codec->spec;
2617 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2621 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2623 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2624 struct snd_ctl_elem_value *ucontrol)
2626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2627 struct sigmatel_spec *spec = codec->spec;
2628 int nid = kcontrol->private_value;
2630 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2632 /* check to be sure that the ports are upto date with
2635 stac_issue_unsol_event(codec, nid);
2640 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2641 struct snd_ctl_elem_info *uinfo)
2644 static char *texts[] = {
2645 "Mic In", "Line In", "Line Out"
2648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2649 struct sigmatel_spec *spec = codec->spec;
2650 hda_nid_t nid = kcontrol->private_value;
2652 if (nid == spec->mic_switch || nid == spec->line_switch)
2657 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2658 uinfo->value.enumerated.items = i;
2660 if (uinfo->value.enumerated.item >= i)
2661 uinfo->value.enumerated.item = i-1;
2662 strcpy(uinfo->value.enumerated.name,
2663 texts[uinfo->value.enumerated.item]);
2668 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2669 struct snd_ctl_elem_value *ucontrol)
2671 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2672 hda_nid_t nid = kcontrol->private_value;
2673 unsigned int vref = stac92xx_vref_get(codec, nid);
2675 if (vref == stac92xx_get_default_vref(codec, nid))
2676 ucontrol->value.enumerated.item[0] = 0;
2677 else if (vref == AC_PINCTL_VREF_GRD)
2678 ucontrol->value.enumerated.item[0] = 1;
2679 else if (vref == AC_PINCTL_VREF_HIZ)
2680 ucontrol->value.enumerated.item[0] = 2;
2685 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2686 struct snd_ctl_elem_value *ucontrol)
2688 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2689 unsigned int new_vref = 0;
2691 hda_nid_t nid = kcontrol->private_value;
2693 if (ucontrol->value.enumerated.item[0] == 0)
2694 new_vref = stac92xx_get_default_vref(codec, nid);
2695 else if (ucontrol->value.enumerated.item[0] == 1)
2696 new_vref = AC_PINCTL_VREF_GRD;
2697 else if (ucontrol->value.enumerated.item[0] == 2)
2698 new_vref = AC_PINCTL_VREF_HIZ;
2702 if (new_vref != stac92xx_vref_get(codec, nid)) {
2703 error = stac92xx_vref_set(codec, nid, new_vref);
2710 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2711 struct snd_ctl_elem_info *uinfo)
2713 static char *texts[2];
2714 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2715 struct sigmatel_spec *spec = codec->spec;
2717 if (kcontrol->private_value == spec->line_switch)
2718 texts[0] = "Line In";
2720 texts[0] = "Mic In";
2721 texts[1] = "Line Out";
2722 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2723 uinfo->value.enumerated.items = 2;
2726 if (uinfo->value.enumerated.item >= 2)
2727 uinfo->value.enumerated.item = 1;
2728 strcpy(uinfo->value.enumerated.name,
2729 texts[uinfo->value.enumerated.item]);
2734 static int stac92xx_io_switch_get(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;
2741 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2745 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2748 struct sigmatel_spec *spec = codec->spec;
2749 hda_nid_t nid = kcontrol->private_value;
2750 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2751 unsigned short val = !!ucontrol->value.enumerated.item[0];
2753 spec->io_switch[io_idx] = val;
2756 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2758 unsigned int pinctl = AC_PINCTL_IN_EN;
2759 if (io_idx) /* set VREF for mic */
2760 pinctl |= stac92xx_get_default_vref(codec, nid);
2761 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2764 /* check the auto-mute again: we need to mute/unmute the speaker
2765 * appropriately according to the pin direction
2767 if (spec->hp_detect)
2768 stac_issue_unsol_event(codec, nid);
2773 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2775 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2776 struct snd_ctl_elem_value *ucontrol)
2778 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2779 struct sigmatel_spec *spec = codec->spec;
2781 ucontrol->value.integer.value[0] = spec->clfe_swap;
2785 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2786 struct snd_ctl_elem_value *ucontrol)
2788 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2789 struct sigmatel_spec *spec = codec->spec;
2790 hda_nid_t nid = kcontrol->private_value & 0xff;
2791 unsigned int val = !!ucontrol->value.integer.value[0];
2793 if (spec->clfe_swap == val)
2796 spec->clfe_swap = val;
2798 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2799 spec->clfe_swap ? 0x4 : 0x0);
2804 #define STAC_CODEC_HP_SWITCH(xname) \
2805 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2808 .info = stac92xx_hp_switch_info, \
2809 .get = stac92xx_hp_switch_get, \
2810 .put = stac92xx_hp_switch_put, \
2813 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2814 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2817 .info = stac92xx_io_switch_info, \
2818 .get = stac92xx_io_switch_get, \
2819 .put = stac92xx_io_switch_put, \
2820 .private_value = xpval, \
2823 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2824 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2827 .info = stac92xx_clfe_switch_info, \
2828 .get = stac92xx_clfe_switch_get, \
2829 .put = stac92xx_clfe_switch_put, \
2830 .private_value = xpval, \
2834 STAC_CTL_WIDGET_VOL,
2835 STAC_CTL_WIDGET_MUTE,
2836 STAC_CTL_WIDGET_MONO_MUX,
2837 STAC_CTL_WIDGET_AMP_MUX,
2838 STAC_CTL_WIDGET_AMP_VOL,
2839 STAC_CTL_WIDGET_HP_SWITCH,
2840 STAC_CTL_WIDGET_IO_SWITCH,
2841 STAC_CTL_WIDGET_CLFE_SWITCH,
2842 STAC_CTL_WIDGET_DC_BIAS
2845 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2846 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2847 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2850 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2851 STAC_CODEC_HP_SWITCH(NULL),
2852 STAC_CODEC_IO_SWITCH(NULL, 0),
2853 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2854 DC_BIAS(NULL, 0, 0),
2857 /* add dynamic controls */
2858 static struct snd_kcontrol_new *
2859 stac_control_new(struct sigmatel_spec *spec,
2860 struct snd_kcontrol_new *ktemp,
2863 struct snd_kcontrol_new *knew;
2865 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2866 knew = snd_array_new(&spec->kctls);
2870 knew->name = kstrdup(name, GFP_KERNEL);
2873 memset(knew, 0, sizeof(*knew));
2874 spec->kctls.alloced--;
2880 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2881 struct snd_kcontrol_new *ktemp,
2882 int idx, const char *name,
2885 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2889 knew->private_value = val;
2893 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2894 int type, int idx, const char *name,
2897 return stac92xx_add_control_temp(spec,
2898 &stac92xx_control_templates[type],
2903 /* add dynamic controls */
2904 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2905 const char *name, unsigned long val)
2907 return stac92xx_add_control_idx(spec, type, 0, name, val);
2910 static struct snd_kcontrol_new stac_input_src_temp = {
2911 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2912 .name = "Input Source",
2913 .info = stac92xx_mux_enum_info,
2914 .get = stac92xx_mux_enum_get,
2915 .put = stac92xx_mux_enum_put,
2918 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2919 hda_nid_t nid, int idx)
2921 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2923 struct sigmatel_spec *spec = codec->spec;
2926 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2927 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2928 && nid == spec->line_switch)
2929 control = STAC_CTL_WIDGET_IO_SWITCH;
2930 else if (snd_hda_query_pin_caps(codec, nid)
2931 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2932 control = STAC_CTL_WIDGET_DC_BIAS;
2933 else if (nid == spec->mic_switch)
2934 control = STAC_CTL_WIDGET_IO_SWITCH;
2938 strcpy(name, auto_pin_cfg_labels[idx]);
2939 return stac92xx_add_control(codec->spec, control,
2940 strcat(name, " Jack Mode"), nid);
2946 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2948 struct snd_kcontrol_new *knew;
2949 struct hda_input_mux *imux = &spec->private_imux;
2952 return 0; /* no need for input source */
2953 if (!spec->num_adcs || imux->num_items <= 1)
2954 return 0; /* no need for input source control */
2955 knew = stac_control_new(spec, &stac_input_src_temp,
2956 stac_input_src_temp.name);
2959 knew->count = spec->num_adcs;
2963 /* check whether the line-input can be used as line-out */
2964 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2966 struct sigmatel_spec *spec = codec->spec;
2967 struct auto_pin_cfg *cfg = &spec->autocfg;
2969 unsigned int pincap;
2971 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2973 nid = cfg->input_pins[AUTO_PIN_LINE];
2974 pincap = snd_hda_query_pin_caps(codec, nid);
2975 if (pincap & AC_PINCAP_OUT)
2980 /* check whether the mic-input can be used as line-out */
2981 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2983 struct sigmatel_spec *spec = codec->spec;
2984 struct auto_pin_cfg *cfg = &spec->autocfg;
2985 unsigned int def_conf, pincap;
2986 unsigned int mic_pin;
2988 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2990 mic_pin = AUTO_PIN_MIC;
2992 hda_nid_t nid = cfg->input_pins[mic_pin];
2993 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2994 /* some laptops have an internal analog microphone
2995 * which can't be used as a output */
2996 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2997 pincap = snd_hda_query_pin_caps(codec, nid);
2998 if (pincap & AC_PINCAP_OUT)
3001 if (mic_pin == AUTO_PIN_MIC)
3002 mic_pin = AUTO_PIN_FRONT_MIC;
3009 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3013 for (i = 0; i < spec->multiout.num_dacs; i++) {
3014 if (spec->multiout.dac_nids[i] == nid)
3021 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3024 if (is_in_dac_nids(spec, nid))
3026 for (i = 0; i < spec->autocfg.hp_outs; i++)
3027 if (spec->hp_dacs[i] == nid)
3029 for (i = 0; i < spec->autocfg.speaker_outs; i++)
3030 if (spec->speaker_dacs[i] == nid)
3035 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
3037 struct sigmatel_spec *spec = codec->spec;
3039 hda_nid_t conn[HDA_MAX_CONNECTIONS];
3040 unsigned int wcaps, wtype;
3042 conn_len = snd_hda_get_connections(codec, nid, conn,
3043 HDA_MAX_CONNECTIONS);
3044 for (j = 0; j < conn_len; j++) {
3045 wcaps = get_wcaps(codec, conn[j]);
3046 wtype = get_wcaps_type(wcaps);
3047 /* we check only analog outputs */
3048 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
3050 /* if this route has a free DAC, assign it */
3051 if (!check_all_dac_nids(spec, conn[j])) {
3053 /* select this DAC in the pin's input mux */
3054 snd_hda_codec_write_cache(codec, nid, 0,
3055 AC_VERB_SET_CONNECT_SEL, j);
3060 /* if all DACs are already assigned, connect to the primary DAC */
3062 for (j = 0; j < conn_len; j++) {
3063 if (conn[j] == spec->multiout.dac_nids[0]) {
3064 snd_hda_codec_write_cache(codec, nid, 0,
3065 AC_VERB_SET_CONNECT_SEL, j);
3073 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3074 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3077 * Fill in the dac_nids table from the parsed pin configuration
3078 * This function only works when every pin in line_out_pins[]
3079 * contains atleast one DAC in its connection list. Some 92xx
3080 * codecs are not connected directly to a DAC, such as the 9200
3081 * and 9202/925x. For those, dac_nids[] must be hard-coded.
3083 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
3085 struct sigmatel_spec *spec = codec->spec;
3086 struct auto_pin_cfg *cfg = &spec->autocfg;
3090 for (i = 0; i < cfg->line_outs; i++) {
3091 nid = cfg->line_out_pins[i];
3092 dac = get_unassigned_dac(codec, nid);
3094 if (spec->multiout.num_dacs > 0) {
3095 /* we have already working output pins,
3096 * so let's drop the broken ones again
3098 cfg->line_outs = spec->multiout.num_dacs;
3101 /* error out, no available DAC found */
3103 "%s: No available DAC for pin 0x%x\n",
3107 add_spec_dacs(spec, dac);
3110 for (i = 0; i < cfg->hp_outs; i++) {
3111 nid = cfg->hp_pins[i];
3112 dac = get_unassigned_dac(codec, nid);
3114 if (!spec->multiout.hp_nid)
3115 spec->multiout.hp_nid = dac;
3117 add_spec_extra_dacs(spec, dac);
3119 spec->hp_dacs[i] = dac;
3122 for (i = 0; i < cfg->speaker_outs; i++) {
3123 nid = cfg->speaker_pins[i];
3124 dac = get_unassigned_dac(codec, nid);
3126 add_spec_extra_dacs(spec, dac);
3127 spec->speaker_dacs[i] = dac;
3130 /* add line-in as output */
3131 nid = check_line_out_switch(codec);
3133 dac = get_unassigned_dac(codec, nid);
3135 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3136 nid, cfg->line_outs);
3137 cfg->line_out_pins[cfg->line_outs] = nid;
3139 spec->line_switch = nid;
3140 add_spec_dacs(spec, dac);
3143 /* add mic as output */
3144 nid = check_mic_out_switch(codec);
3146 dac = get_unassigned_dac(codec, nid);
3148 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3149 nid, cfg->line_outs);
3150 cfg->line_out_pins[cfg->line_outs] = nid;
3152 spec->mic_switch = nid;
3153 add_spec_dacs(spec, dac);
3157 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3158 spec->multiout.num_dacs,
3159 spec->multiout.dac_nids[0],
3160 spec->multiout.dac_nids[1],
3161 spec->multiout.dac_nids[2],
3162 spec->multiout.dac_nids[3],
3163 spec->multiout.dac_nids[4]);
3168 /* create volume control/switch for the given prefx type */
3169 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3170 int idx, hda_nid_t nid, int chs)
3172 struct sigmatel_spec *spec = codec->spec;
3176 if (!spec->check_volume_offset) {
3177 unsigned int caps, step, nums, db_scale;
3178 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3179 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3180 AC_AMPCAP_STEP_SIZE_SHIFT;
3181 step = (step + 1) * 25; /* in .01dB unit */
3182 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3183 AC_AMPCAP_NUM_STEPS_SHIFT;
3184 db_scale = nums * step;
3185 /* if dB scale is over -64dB, and finer enough,
3186 * let's reduce it to half
3188 if (db_scale > 6400 && nums >= 0x1f)
3189 spec->volume_offset = nums / 2;
3190 spec->check_volume_offset = 1;
3193 sprintf(name, "%s Playback Volume", pfx);
3194 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
3195 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3196 spec->volume_offset));
3199 sprintf(name, "%s Playback Switch", pfx);
3200 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
3201 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3207 #define create_controls(codec, pfx, nid, chs) \
3208 create_controls_idx(codec, pfx, 0, nid, chs)
3210 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3212 if (spec->multiout.num_dacs > 4) {
3213 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3216 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3217 spec->multiout.num_dacs++;
3222 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3225 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3226 if (!spec->multiout.extra_out_nid[i]) {
3227 spec->multiout.extra_out_nid[i] = nid;
3231 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3235 /* Create output controls
3236 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3238 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3239 const hda_nid_t *pins,
3240 const hda_nid_t *dac_nids,
3243 struct sigmatel_spec *spec = codec->spec;
3244 static const char *chname[4] = {
3245 "Front", "Surround", NULL /*CLFE*/, "Side"
3249 unsigned int wid_caps;
3251 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3252 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3253 wid_caps = get_wcaps(codec, pins[i]);
3254 if (wid_caps & AC_WCAP_UNSOL_CAP)
3255 spec->hp_detect = 1;
3260 if (type != AUTO_PIN_HP_OUT && i == 2) {
3262 err = create_controls(codec, "Center", nid, 1);
3265 err = create_controls(codec, "LFE", nid, 2);
3269 wid_caps = get_wcaps(codec, nid);
3271 if (wid_caps & AC_WCAP_LR_SWAP) {
3272 err = stac92xx_add_control(spec,
3273 STAC_CTL_WIDGET_CLFE_SWITCH,
3274 "Swap Center/LFE Playback Switch", nid);
3284 case AUTO_PIN_HP_OUT:
3288 case AUTO_PIN_SPEAKER_OUT:
3297 err = create_controls_idx(codec, name, idx, nid, 3);
3305 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3306 unsigned long sw, int idx)
3309 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3310 "Captuer Volume", vol);
3313 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3314 "Captuer Switch", sw);
3320 /* add playback controls from the parsed DAC table */
3321 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3322 const struct auto_pin_cfg *cfg)
3324 struct sigmatel_spec *spec = codec->spec;
3329 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3330 spec->multiout.dac_nids,
3331 cfg->line_out_type);
3335 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3336 err = stac92xx_add_control(spec,
3337 STAC_CTL_WIDGET_HP_SWITCH,
3338 "Headphone as Line Out Switch",
3339 cfg->hp_pins[cfg->hp_outs - 1]);
3344 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3345 nid = cfg->input_pins[idx];
3347 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3356 /* add playback controls for Speaker and HP outputs */
3357 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3358 struct auto_pin_cfg *cfg)
3360 struct sigmatel_spec *spec = codec->spec;
3363 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3364 spec->hp_dacs, AUTO_PIN_HP_OUT);
3368 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3369 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3376 /* labels for mono mux outputs */
3377 static const char *stac92xx_mono_labels[4] = {
3378 "DAC0", "DAC1", "Mixer", "DAC2"
3381 /* create mono mux for mono out on capable codecs */
3382 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3384 struct sigmatel_spec *spec = codec->spec;
3385 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3387 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3389 num_cons = snd_hda_get_connections(codec,
3392 HDA_MAX_NUM_INPUTS);
3393 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3396 for (i = 0; i < num_cons; i++) {
3397 mono_mux->items[mono_mux->num_items].label =
3398 stac92xx_mono_labels[i];
3399 mono_mux->items[mono_mux->num_items].index = i;
3400 mono_mux->num_items++;
3403 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3404 "Mono Mux", spec->mono_nid);
3407 /* labels for amp mux outputs */
3408 static const char *stac92xx_amp_labels[3] = {
3409 "Front Microphone", "Microphone", "Line In",
3412 /* create amp out controls mux on capable codecs */
3413 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3415 struct sigmatel_spec *spec = codec->spec;
3416 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3419 for (i = 0; i < spec->num_amps; i++) {
3420 amp_mux->items[amp_mux->num_items].label =
3421 stac92xx_amp_labels[i];
3422 amp_mux->items[amp_mux->num_items].index = i;
3423 amp_mux->num_items++;
3426 if (spec->num_amps > 1) {
3427 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3428 "Amp Selector Capture Switch", 0);
3432 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3433 "Amp Capture Volume",
3434 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3438 /* create PC beep volume controls */
3439 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3442 struct sigmatel_spec *spec = codec->spec;
3443 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3446 /* check for mute support for the the amp */
3447 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3448 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3449 "PC Beep Playback Switch",
3450 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3455 /* check to see if there is volume support for the amp */
3456 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3457 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3458 "PC Beep Playback Volume",
3459 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3466 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3467 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3469 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3470 struct snd_ctl_elem_value *ucontrol)
3472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3473 ucontrol->value.integer.value[0] = codec->beep->enabled;
3477 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3478 struct snd_ctl_elem_value *ucontrol)
3480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3481 int enabled = !!ucontrol->value.integer.value[0];
3482 if (codec->beep->enabled != enabled) {
3483 codec->beep->enabled = enabled;
3489 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3490 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3491 .info = stac92xx_dig_beep_switch_info,
3492 .get = stac92xx_dig_beep_switch_get,
3493 .put = stac92xx_dig_beep_switch_put,
3496 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3498 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3499 0, "PC Beep Playback Switch", 0);
3503 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3505 struct sigmatel_spec *spec = codec->spec;
3506 int wcaps, nid, i, err = 0;
3508 for (i = 0; i < spec->num_muxes; i++) {
3509 nid = spec->mux_nids[i];
3510 wcaps = get_wcaps(codec, nid);
3512 if (wcaps & AC_WCAP_OUT_AMP) {
3513 err = stac92xx_add_control_idx(spec,
3514 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3515 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3523 static const char *stac92xx_spdif_labels[3] = {
3524 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3527 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3529 struct sigmatel_spec *spec = codec->spec;
3530 struct hda_input_mux *spdif_mux = &spec->private_smux;
3531 const char **labels = spec->spdif_labels;
3533 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3535 num_cons = snd_hda_get_connections(codec,
3538 HDA_MAX_NUM_INPUTS);
3543 labels = stac92xx_spdif_labels;
3545 for (i = 0; i < num_cons; i++) {
3546 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3547 spdif_mux->items[spdif_mux->num_items].index = i;
3548 spdif_mux->num_items++;
3554 /* labels for dmic mux inputs */
3555 static const char *stac92xx_dmic_labels[5] = {
3556 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3557 "Digital Mic 3", "Digital Mic 4"
3560 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
3563 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3566 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3567 for (i = 0; i < nums; i++)
3573 /* create playback/capture controls for input pins on dmic capable codecs */
3574 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3575 const struct auto_pin_cfg *cfg)
3577 struct sigmatel_spec *spec = codec->spec;
3578 struct hda_input_mux *dimux = &spec->private_dimux;
3582 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3583 dimux->items[dimux->num_items].index = 0;
3586 for (i = 0; i < spec->num_dmics; i++) {
3590 unsigned int def_conf;
3592 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3593 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3596 nid = spec->dmic_nids[i];
3597 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3601 wcaps = get_wcaps(codec, nid) &
3602 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3605 sprintf(name, "%s Capture Volume",
3606 stac92xx_dmic_labels[dimux->num_items]);
3608 err = stac92xx_add_control(spec,
3609 STAC_CTL_WIDGET_VOL,
3611 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3612 (wcaps & AC_WCAP_OUT_AMP) ?
3613 HDA_OUTPUT : HDA_INPUT));
3618 dimux->items[dimux->num_items].label =
3619 stac92xx_dmic_labels[dimux->num_items];
3620 dimux->items[dimux->num_items].index = index;
3627 static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3628 hda_nid_t *fixed, hda_nid_t *ext)
3634 cfg = snd_hda_codec_get_pincfg(codec, nid);
3635 switch (get_defcfg_connect(cfg)) {
3636 case AC_JACK_PORT_FIXED:
3638 return 1; /* already occupied */
3641 case AC_JACK_PORT_COMPLEX:
3643 return 1; /* already occupied */
3650 static int set_mic_route(struct hda_codec *codec,
3651 struct sigmatel_mic_route *mic,
3654 struct sigmatel_spec *spec = codec->spec;
3655 struct auto_pin_cfg *cfg = &spec->autocfg;
3659 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3660 if (pin == cfg->input_pins[i])
3662 if (i <= AUTO_PIN_FRONT_MIC) {
3665 i = get_connection_index(codec, spec->mux_nids[0], pin);
3672 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3680 /* return non-zero if the device is for automatic mic switch */
3681 static int stac_check_auto_mic(struct hda_codec *codec)
3683 struct sigmatel_spec *spec = codec->spec;
3684 struct auto_pin_cfg *cfg = &spec->autocfg;
3685 hda_nid_t fixed, ext;
3688 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
3689 if (cfg->input_pins[i])
3690 return 0; /* must be exclusively mics */
3693 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3694 if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
3696 for (i = 0; i < spec->num_dmics; i++)
3697 if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
3701 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
3702 return 0; /* no unsol support */
3703 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3704 set_mic_route(codec, &spec->int_mic, fixed))
3705 return 0; /* something is wrong */
3709 /* create playback/capture controls for input pins */
3710 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3712 struct sigmatel_spec *spec = codec->spec;
3713 struct hda_input_mux *imux = &spec->private_imux;
3714 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3717 for (i = 0; i < AUTO_PIN_LAST; i++) {
3720 if (!cfg->input_pins[i])
3723 for (j = 0; j < spec->num_muxes; j++) {
3725 num_cons = snd_hda_get_connections(codec,
3728 HDA_MAX_NUM_INPUTS);
3729 for (k = 0; k < num_cons; k++)
3730 if (con_lst[k] == cfg->input_pins[i]) {
3737 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3738 imux->items[imux->num_items].index = index;
3742 if (imux->num_items) {
3744 * Set the current input for the muxes.
3745 * The STAC9221 has two input muxes with identical source
3746 * NID lists. Hopefully this won't get confused.
3748 for (i = 0; i < spec->num_muxes; i++) {
3749 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3750 AC_VERB_SET_CONNECT_SEL,
3751 imux->items[0].index);
3758 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3760 struct sigmatel_spec *spec = codec->spec;
3763 for (i = 0; i < spec->autocfg.line_outs; i++) {
3764 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3765 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3769 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3771 struct sigmatel_spec *spec = codec->spec;
3774 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3776 pin = spec->autocfg.hp_pins[i];
3777 if (pin) /* connect to front */
3778 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3780 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3782 pin = spec->autocfg.speaker_pins[i];
3783 if (pin) /* connect to front */
3784 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3788 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3790 struct sigmatel_spec *spec = codec->spec;
3794 if ((err = snd_hda_parse_pin_def_config(codec,
3796 spec->dmic_nids)) < 0)
3798 if (! spec->autocfg.line_outs)
3799 return 0; /* can't find valid pin config */
3801 /* If we have no real line-out pin and multiple hp-outs, HPs should
3802 * be set up as multi-channel outputs.
3804 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3805 spec->autocfg.hp_outs > 1) {
3806 /* Copy hp_outs to line_outs, backup line_outs in
3807 * speaker_outs so that the following routines can handle
3808 * HP pins as primary outputs.
3810 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3811 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3812 sizeof(spec->autocfg.line_out_pins));
3813 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3814 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3815 sizeof(spec->autocfg.hp_pins));
3816 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3817 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3818 spec->autocfg.hp_outs = 0;
3821 if (spec->autocfg.mono_out_pin) {
3822 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3823 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3824 u32 caps = query_amp_caps(codec,
3825 spec->autocfg.mono_out_pin, dir);
3826 hda_nid_t conn_list[1];
3828 /* get the mixer node and then the mono mux if it exists */
3829 if (snd_hda_get_connections(codec,
3830 spec->autocfg.mono_out_pin, conn_list, 1) &&
3831 snd_hda_get_connections(codec, conn_list[0],
3832 conn_list, 1) > 0) {
3834 int wcaps = get_wcaps(codec, conn_list[0]);
3835 int wid_type = get_wcaps_type(wcaps);
3836 /* LR swap check, some stac925x have a mux that
3837 * changes the DACs output path instead of the
3840 if (wid_type == AC_WID_AUD_SEL &&
3841 !(wcaps & AC_WCAP_LR_SWAP))
3842 spec->mono_nid = conn_list[0];
3845 hda_nid_t nid = spec->autocfg.mono_out_pin;
3847 /* most mono outs have a least a mute/unmute switch */
3848 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3849 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3850 "Mono Playback Switch",
3851 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3854 /* check for volume support for the amp */
3855 if ((caps & AC_AMPCAP_NUM_STEPS)
3856 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3857 err = stac92xx_add_control(spec,
3858 STAC_CTL_WIDGET_VOL,
3859 "Mono Playback Volume",
3860 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3866 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3870 if (!spec->multiout.num_dacs) {
3871 err = stac92xx_auto_fill_dac_nids(codec);
3874 err = stac92xx_auto_create_multi_out_ctls(codec,
3880 /* setup analog beep controls */
3881 if (spec->anabeep_nid > 0) {
3882 err = stac92xx_auto_create_beep_ctls(codec,
3888 /* setup digital beep controls and input device */
3889 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3890 if (spec->digbeep_nid > 0) {
3891 hda_nid_t nid = spec->digbeep_nid;
3894 err = stac92xx_auto_create_beep_ctls(codec, nid);
3897 err = snd_hda_attach_beep_device(codec, nid);
3900 /* IDT/STAC codecs have linear beep tone parameter */
3901 codec->beep->linear_tone = 1;
3902 /* if no beep switch is available, make its own one */
3903 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3905 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3906 err = stac92xx_beep_switch_ctl(codec);
3913 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3917 /* All output parsing done, now restore the swapped hp pins */
3919 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3920 sizeof(spec->autocfg.hp_pins));
3921 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3922 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3923 spec->autocfg.line_outs = 0;
3926 if (stac_check_auto_mic(codec)) {
3928 /* only one capture for auto-mic */
3931 spec->num_muxes = 1;
3934 for (i = 0; i < spec->num_caps; i++) {
3935 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3936 spec->capsws[i], i);
3941 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3945 if (spec->mono_nid > 0) {
3946 err = stac92xx_auto_create_mono_output_ctls(codec);
3950 if (spec->num_amps > 0) {
3951 err = stac92xx_auto_create_amp_output_ctls(codec);
3955 if (spec->num_dmics > 0 && !spec->dinput_mux)
3956 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3957 &spec->autocfg)) < 0)
3959 if (spec->num_muxes > 0) {
3960 err = stac92xx_auto_create_mux_input_ctls(codec);
3964 if (spec->num_smuxes > 0) {
3965 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3970 err = stac92xx_add_input_source(spec);
3974 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3975 if (spec->multiout.max_channels > 2)
3976 spec->surr_switch = 1;
3978 if (spec->autocfg.dig_outs)
3979 spec->multiout.dig_out_nid = dig_out;
3980 if (dig_in && spec->autocfg.dig_in_pin)
3981 spec->dig_in_nid = dig_in;
3983 if (spec->kctls.list)
3984 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3986 spec->input_mux = &spec->private_imux;
3987 if (!spec->dinput_mux)
3988 spec->dinput_mux = &spec->private_dimux;
3989 spec->sinput_mux = &spec->private_smux;
3990 spec->mono_mux = &spec->private_mono_mux;
3991 spec->amp_mux = &spec->private_amp_mux;
3995 /* add playback controls for HP output */
3996 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3997 struct auto_pin_cfg *cfg)
3999 struct sigmatel_spec *spec = codec->spec;
4000 hda_nid_t pin = cfg->hp_pins[0];
4001 unsigned int wid_caps;
4006 wid_caps = get_wcaps(codec, pin);
4007 if (wid_caps & AC_WCAP_UNSOL_CAP)
4008 spec->hp_detect = 1;
4013 /* add playback controls for LFE output */
4014 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
4015 struct auto_pin_cfg *cfg)
4017 struct sigmatel_spec *spec = codec->spec;
4019 hda_nid_t lfe_pin = 0x0;
4023 * search speaker outs and line outs for a mono speaker pin
4024 * with an amp. If one is found, add LFE controls
4027 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
4028 hda_nid_t pin = spec->autocfg.speaker_pins[i];
4029 unsigned int wcaps = get_wcaps(codec, pin);
4030 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4031 if (wcaps == AC_WCAP_OUT_AMP)
4032 /* found a mono speaker with an amp, must be lfe */
4036 /* if speaker_outs is 0, then speakers may be in line_outs */
4037 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
4038 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
4039 hda_nid_t pin = spec->autocfg.line_out_pins[i];
4040 unsigned int defcfg;
4041 defcfg = snd_hda_codec_get_pincfg(codec, pin);
4042 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
4043 unsigned int wcaps = get_wcaps(codec, pin);
4044 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4045 if (wcaps == AC_WCAP_OUT_AMP)
4046 /* found a mono speaker with an amp,
4054 err = create_controls(codec, "LFE", lfe_pin, 1);
4062 static int stac9200_parse_auto_config(struct hda_codec *codec)
4064 struct sigmatel_spec *spec = codec->spec;
4067 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
4070 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
4073 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4076 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4079 if (spec->num_muxes > 0) {
4080 err = stac92xx_auto_create_mux_input_ctls(codec);
4085 err = stac92xx_add_input_source(spec);
4089 if (spec->autocfg.dig_outs)
4090 spec->multiout.dig_out_nid = 0x05;
4091 if (spec->autocfg.dig_in_pin)
4092 spec->dig_in_nid = 0x04;
4094 if (spec->kctls.list)
4095 spec->mixers[spec->num_mixers++] = spec->kctls.list;
4097 spec->input_mux = &spec->private_imux;
4098 spec->dinput_mux = &spec->private_dimux;
4104 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4105 * funky external mute control using GPIO pins.
4108 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4109 unsigned int dir_mask, unsigned int data)
4111 unsigned int gpiostate, gpiomask, gpiodir;
4113 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4114 AC_VERB_GET_GPIO_DATA, 0);
4115 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
4117 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4118 AC_VERB_GET_GPIO_MASK, 0);
4121 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4122 AC_VERB_GET_GPIO_DIRECTION, 0);
4123 gpiodir |= dir_mask;
4125 /* Configure GPIOx as CMOS */
4126 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4128 snd_hda_codec_write(codec, codec->afg, 0,
4129 AC_VERB_SET_GPIO_MASK, gpiomask);
4130 snd_hda_codec_read(codec, codec->afg, 0,
4131 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
4135 snd_hda_codec_read(codec, codec->afg, 0,
4136 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
4139 #ifdef CONFIG_SND_HDA_INPUT_JACK
4140 static void stac92xx_free_jack_priv(struct snd_jack *jack)
4142 struct sigmatel_jack *jacks = jack->private_data;
4148 static int stac92xx_add_jack(struct hda_codec *codec,
4149 hda_nid_t nid, int type)
4151 #ifdef CONFIG_SND_HDA_INPUT_JACK
4152 struct sigmatel_spec *spec = codec->spec;
4153 struct sigmatel_jack *jack;
4154 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4155 int connectivity = get_defcfg_connect(def_conf);
4159 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4162 snd_array_init(&spec->jacks, sizeof(*jack), 32);
4163 jack = snd_array_new(&spec->jacks);
4169 snprintf(name, sizeof(name), "%s at %s %s Jack",
4170 snd_hda_get_jack_type(def_conf),
4171 snd_hda_get_jack_connectivity(def_conf),
4172 snd_hda_get_jack_location(def_conf));
4174 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4179 jack->jack->private_data = jack;
4180 jack->jack->private_free = stac92xx_free_jack_priv;
4185 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4186 unsigned char type, int data)
4188 struct sigmatel_event *event;
4190 snd_array_init(&spec->events, sizeof(*event), 32);
4191 event = snd_array_new(&spec->events);
4196 event->tag = spec->events.used;
4202 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4205 struct sigmatel_spec *spec = codec->spec;
4206 struct sigmatel_event *event = spec->events.list;
4209 for (i = 0; i < spec->events.used; i++, event++) {
4210 if (event->nid == nid)
4216 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4219 struct sigmatel_spec *spec = codec->spec;
4220 struct sigmatel_event *event = spec->events.list;
4223 for (i = 0; i < spec->events.used; i++, event++) {
4224 if (event->tag == tag)
4230 /* check if given nid is a valid pin and no other events are assigned
4231 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4232 * Otherwise, returns zero.
4234 static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4237 struct sigmatel_event *event;
4240 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4242 event = stac_get_event(codec, nid);
4244 if (event->type != type)
4248 tag = stac_add_event(codec->spec, nid, type, 0);
4252 snd_hda_codec_write_cache(codec, nid, 0,
4253 AC_VERB_SET_UNSOLICITED_ENABLE,
4258 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4261 for (i = 0; i < cfg->hp_outs; i++)
4262 if (cfg->hp_pins[i] == nid)
4263 return 1; /* nid is a HP-Out */
4265 return 0; /* nid is not a HP-Out */
4268 static void stac92xx_power_down(struct hda_codec *codec)
4270 struct sigmatel_spec *spec = codec->spec;
4272 /* power down inactive DACs */
4274 for (dac = spec->dac_list; *dac; dac++)
4275 if (!check_all_dac_nids(spec, *dac))
4276 snd_hda_codec_write(codec, *dac, 0,
4277 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4280 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4283 /* override some hints from the hwdep entry */
4284 static void stac_store_hints(struct hda_codec *codec)
4286 struct sigmatel_spec *spec = codec->spec;
4290 val = snd_hda_get_bool_hint(codec, "hp_detect");
4292 spec->hp_detect = val;
4293 p = snd_hda_get_hint(codec, "gpio_mask");
4295 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4296 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4299 p = snd_hda_get_hint(codec, "gpio_dir");
4301 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4302 p = snd_hda_get_hint(codec, "gpio_data");
4304 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4305 p = snd_hda_get_hint(codec, "eapd_mask");
4307 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4308 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4310 spec->eapd_switch = val;
4313 static int stac92xx_init(struct hda_codec *codec)
4315 struct sigmatel_spec *spec = codec->spec;
4316 struct auto_pin_cfg *cfg = &spec->autocfg;
4320 snd_hda_sequence_write(codec, spec->init);
4322 /* power down adcs initially */
4323 if (spec->powerdown_adcs)
4324 for (i = 0; i < spec->num_adcs; i++)
4325 snd_hda_codec_write(codec,
4326 spec->adc_nids[i], 0,
4327 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4329 /* override some hints */
4330 stac_store_hints(codec);
4333 gpio = spec->gpio_data;
4334 /* turn on EAPD statically when spec->eapd_switch isn't set.
4335 * otherwise, unsol event will turn it on/off dynamically
4337 if (!spec->eapd_switch)
4338 gpio |= spec->eapd_mask;
4339 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4342 if (spec->hp_detect) {
4343 /* Enable unsolicited responses on the HP widget */
4344 for (i = 0; i < cfg->hp_outs; i++) {
4345 hda_nid_t nid = cfg->hp_pins[i];
4346 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4348 /* force to enable the first line-out; the others are set up
4351 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4353 /* fake event to set up pins */
4354 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4356 stac92xx_auto_init_multi_out(codec);
4357 stac92xx_auto_init_hp_out(codec);
4358 for (i = 0; i < cfg->hp_outs; i++)
4359 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4361 if (spec->auto_mic) {
4362 /* initialize connection to analog input */
4363 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4364 AC_VERB_SET_CONNECT_SEL, 0);
4365 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4366 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4368 for (i = 0; i < AUTO_PIN_LAST; i++) {
4369 hda_nid_t nid = cfg->input_pins[i];
4371 unsigned int pinctl, conf;
4372 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4373 /* for mic pins, force to initialize */
4374 pinctl = stac92xx_get_default_vref(codec, nid);
4375 pinctl |= AC_PINCTL_IN_EN;
4376 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4378 pinctl = snd_hda_codec_read(codec, nid, 0,
4379 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4380 /* if PINCTL already set then skip */
4381 /* Also, if both INPUT and OUTPUT are set,
4382 * it must be a BIOS bug; need to override, too
4384 if (!(pinctl & AC_PINCTL_IN_EN) ||
4385 (pinctl & AC_PINCTL_OUT_EN)) {
4386 pinctl &= ~AC_PINCTL_OUT_EN;
4387 pinctl |= AC_PINCTL_IN_EN;
4388 stac92xx_auto_set_pinctl(codec, nid,
4392 conf = snd_hda_codec_get_pincfg(codec, nid);
4393 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4394 if (enable_pin_detect(codec, nid,
4396 stac_issue_unsol_event(codec, nid);
4400 for (i = 0; i < spec->num_dmics; i++)
4401 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4403 if (cfg->dig_out_pins[0])
4404 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4406 if (cfg->dig_in_pin)
4407 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4409 for (i = 0; i < spec->num_pwrs; i++) {
4410 hda_nid_t nid = spec->pwr_nids[i];
4411 int pinctl, def_conf;
4413 /* power on when no jack detection is available */
4414 if (!spec->hp_detect) {
4415 stac_toggle_power_map(codec, nid, 1);
4419 if (is_nid_hp_pin(cfg, nid))
4420 continue; /* already has an unsol event */
4422 pinctl = snd_hda_codec_read(codec, nid, 0,
4423 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4424 /* outputs are only ports capable of power management
4425 * any attempts on powering down a input port cause the
4426 * referenced VREF to act quirky.
4428 if (pinctl & AC_PINCTL_IN_EN) {
4429 stac_toggle_power_map(codec, nid, 1);
4432 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4433 def_conf = get_defcfg_connect(def_conf);
4434 /* skip any ports that don't have jacks since presence
4435 * detection is useless */
4436 if (def_conf != AC_JACK_PORT_COMPLEX) {
4437 if (def_conf != AC_JACK_PORT_NONE)
4438 stac_toggle_power_map(codec, nid, 1);
4441 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4442 stac_issue_unsol_event(codec, nid);
4445 stac92xx_power_down(codec);
4449 static void stac92xx_free_jacks(struct hda_codec *codec)
4451 #ifdef CONFIG_SND_HDA_INPUT_JACK
4452 /* free jack instances manually when clearing/reconfiguring */
4453 struct sigmatel_spec *spec = codec->spec;
4454 if (!codec->bus->shutdown && spec->jacks.list) {
4455 struct sigmatel_jack *jacks = spec->jacks.list;
4457 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4459 snd_device_free(codec->bus->card, jacks->jack);
4462 snd_array_free(&spec->jacks);
4466 static void stac92xx_free_kctls(struct hda_codec *codec)
4468 struct sigmatel_spec *spec = codec->spec;
4470 if (spec->kctls.list) {
4471 struct snd_kcontrol_new *kctl = spec->kctls.list;
4473 for (i = 0; i < spec->kctls.used; i++)
4474 kfree(kctl[i].name);
4476 snd_array_free(&spec->kctls);
4479 static void stac92xx_free(struct hda_codec *codec)
4481 struct sigmatel_spec *spec = codec->spec;
4486 stac92xx_free_jacks(codec);
4487 snd_array_free(&spec->events);
4490 snd_hda_detach_beep_device(codec);
4493 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4496 unsigned int old_ctl, pin_ctl;
4498 pin_ctl = snd_hda_codec_read(codec, nid,
4499 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4501 if (pin_ctl & AC_PINCTL_IN_EN) {
4503 * we need to check the current set-up direction of
4504 * shared input pins since they can be switched via
4505 * "xxx as Output" mixer switch
4507 struct sigmatel_spec *spec = codec->spec;
4508 if (nid == spec->line_switch || nid == spec->mic_switch)
4513 /* if setting pin direction bits, clear the current
4514 direction bits first */
4515 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4516 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4519 if (old_ctl != pin_ctl)
4520 snd_hda_codec_write_cache(codec, nid, 0,
4521 AC_VERB_SET_PIN_WIDGET_CONTROL,
4525 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4528 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4529 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4531 snd_hda_codec_write_cache(codec, nid, 0,
4532 AC_VERB_SET_PIN_WIDGET_CONTROL,
4536 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4540 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
4546 /* return non-zero if the hp-pin of the given array index isn't
4547 * a jack-detection target
4549 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4551 struct auto_pin_cfg *cfg = &spec->autocfg;
4553 /* ignore sensing of shared line and mic jacks */
4554 if (cfg->hp_pins[i] == spec->line_switch)
4556 if (cfg->hp_pins[i] == spec->mic_switch)
4558 /* ignore if the pin is set as line-out */
4559 if (cfg->hp_pins[i] == spec->hp_switch)
4564 static void stac92xx_hp_detect(struct hda_codec *codec)
4566 struct sigmatel_spec *spec = codec->spec;
4567 struct auto_pin_cfg *cfg = &spec->autocfg;
4571 if (spec->gpio_mute)
4572 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4573 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4575 for (i = 0; i < cfg->hp_outs; i++) {
4578 if (no_hp_sensing(spec, i))
4580 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4582 unsigned int pinctl;
4583 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4584 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4585 if (pinctl & AC_PINCTL_IN_EN)
4586 presence = 0; /* mic- or line-input */
4591 /* disable lineouts */
4592 if (spec->hp_switch)
4593 stac92xx_reset_pinctl(codec, spec->hp_switch,
4595 for (i = 0; i < cfg->line_outs; i++)
4596 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4598 for (i = 0; i < cfg->speaker_outs; i++)
4599 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4601 if (spec->eapd_mask && spec->eapd_switch)
4602 stac_gpio_set(codec, spec->gpio_mask,
4603 spec->gpio_dir, spec->gpio_data &
4606 /* enable lineouts */
4607 if (spec->hp_switch)
4608 stac92xx_set_pinctl(codec, spec->hp_switch,
4610 for (i = 0; i < cfg->line_outs; i++)
4611 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4613 for (i = 0; i < cfg->speaker_outs; i++)
4614 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4616 if (spec->eapd_mask && spec->eapd_switch)
4617 stac_gpio_set(codec, spec->gpio_mask,
4618 spec->gpio_dir, spec->gpio_data |
4621 /* toggle hp outs */
4622 for (i = 0; i < cfg->hp_outs; i++) {
4623 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4624 if (no_hp_sensing(spec, i))
4627 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4629 /* Resetting the pinctl like below may lead to (a sort of) regressions
4630 * on some devices since they use the HP pin actually for line/speaker
4631 * outs although the default pin config shows a different pin (that is
4632 * wrong and useless).
4634 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4635 * But, disabling the code below just works around it, and I'm too tired of
4636 * bug reports with such devices...
4639 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4644 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4647 struct sigmatel_spec *spec = codec->spec;
4648 unsigned int idx, val;
4650 for (idx = 0; idx < spec->num_pwrs; idx++) {
4651 if (spec->pwr_nids[idx] == nid)
4654 if (idx >= spec->num_pwrs)
4657 /* several codecs have two power down bits */
4658 if (spec->pwr_mapping)
4659 idx = spec->pwr_mapping[idx];
4663 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4669 /* power down unused output ports */
4670 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4673 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4675 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4678 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4680 struct sigmatel_spec *spec = codec->spec;
4681 struct sigmatel_jack *jacks = spec->jacks.list;
4685 for (i = 0; i < spec->jacks.used; i++) {
4686 if (jacks->nid == nid) {
4687 unsigned int pin_ctl =
4688 snd_hda_codec_read(codec, nid,
4689 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4691 int type = jacks->type;
4692 if (type == (SND_JACK_LINEOUT
4693 | SND_JACK_HEADPHONE))
4694 type = (pin_ctl & AC_PINCTL_HP_EN)
4695 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4696 snd_jack_report(jacks->jack,
4697 get_pin_presence(codec, nid)
4705 static void stac92xx_mic_detect(struct hda_codec *codec)
4707 struct sigmatel_spec *spec = codec->spec;
4708 struct sigmatel_mic_route *mic;
4710 if (get_pin_presence(codec, spec->ext_mic.pin))
4711 mic = &spec->ext_mic;
4713 mic = &spec->int_mic;
4715 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4716 AC_VERB_SET_CONNECT_SEL,
4719 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4720 AC_VERB_SET_CONNECT_SEL,
4724 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4726 struct sigmatel_event *event = stac_get_event(codec, nid);
4729 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4732 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4734 struct sigmatel_spec *spec = codec->spec;
4735 struct sigmatel_event *event;
4738 tag = (res >> 26) & 0x7f;
4739 event = stac_get_event_from_tag(codec, tag);
4743 switch (event->type) {
4745 stac92xx_hp_detect(codec);
4747 case STAC_MIC_EVENT:
4748 stac92xx_mic_detect(codec);
4752 switch (event->type) {
4754 case STAC_MIC_EVENT:
4755 case STAC_INSERT_EVENT:
4756 case STAC_PWR_EVENT:
4757 if (spec->num_pwrs > 0)
4758 stac92xx_pin_sense(codec, event->nid);
4759 stac92xx_report_jack(codec, event->nid);
4761 switch (codec->subsystem_id) {
4763 if (event->nid == 0xb) {
4764 int pin = AC_PINCTL_IN_EN;
4766 if (get_pin_presence(codec, 0xa)
4767 && get_pin_presence(codec, 0xb))
4768 pin |= AC_PINCTL_VREF_80;
4769 if (!get_pin_presence(codec, 0xb))
4770 pin |= AC_PINCTL_VREF_80;
4772 /* toggle VREF state based on mic + hp pin
4775 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4779 case STAC_VREF_EVENT:
4780 data = snd_hda_codec_read(codec, codec->afg, 0,
4781 AC_VERB_GET_GPIO_DATA, 0);
4782 /* toggle VREF state based on GPIOx status */
4783 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4784 !!(data & (1 << event->data)));
4789 #ifdef CONFIG_PROC_FS
4790 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4791 struct hda_codec *codec, hda_nid_t nid)
4793 if (nid == codec->afg)
4794 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4795 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4798 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4799 struct hda_codec *codec,
4802 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4803 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4806 /* stac92hd71bxx, stac92hd73xx */
4807 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4808 struct hda_codec *codec, hda_nid_t nid)
4810 stac92hd_proc_hook(buffer, codec, nid);
4811 if (nid == codec->afg)
4812 analog_loop_proc_hook(buffer, codec, 0xfa0);
4815 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4816 struct hda_codec *codec, hda_nid_t nid)
4818 if (nid == codec->afg)
4819 analog_loop_proc_hook(buffer, codec, 0xfe0);
4822 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4823 struct hda_codec *codec, hda_nid_t nid)
4825 if (nid == codec->afg)
4826 analog_loop_proc_hook(buffer, codec, 0xfeb);
4829 #define stac92hd_proc_hook NULL
4830 #define stac92hd7x_proc_hook NULL
4831 #define stac9205_proc_hook NULL
4832 #define stac927x_proc_hook NULL
4835 #ifdef SND_HDA_NEEDS_RESUME
4836 static int stac92xx_resume(struct hda_codec *codec)
4838 struct sigmatel_spec *spec = codec->spec;
4840 stac92xx_init(codec);
4841 snd_hda_codec_resume_amp(codec);
4842 snd_hda_codec_resume_cache(codec);
4843 /* fake event to set up pins again to override cached values */
4844 if (spec->hp_detect)
4845 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4850 * using power check for controlling mute led of HP notebooks
4851 * check for mute state only on Speakers (nid = 0x10)
4853 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4854 * the LED is NOT working properly !
4856 * Changed name to reflect that it now works for any designated
4857 * model, not just HP HDX.
4860 #ifdef CONFIG_SND_HDA_POWER_SAVE
4861 static int stac92xx_hp_check_power_status(struct hda_codec *codec,
4864 struct sigmatel_spec *spec = codec->spec;
4867 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4869 spec->gpio_data &= ~spec->gpio_led; /* orange */
4871 spec->gpio_data |= spec->gpio_led; /* white */
4873 stac_gpio_set(codec, spec->gpio_mask,
4882 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4884 struct sigmatel_spec *spec = codec->spec;
4888 /* reset each pin before powering down DAC/ADC to avoid click noise */
4889 nid = codec->start_nid;
4890 for (i = 0; i < codec->num_nodes; i++, nid++) {
4891 unsigned int wcaps = get_wcaps(codec, nid);
4892 unsigned int wid_type = get_wcaps_type(wcaps);
4893 if (wid_type == AC_WID_PIN)
4894 snd_hda_codec_read(codec, nid, 0,
4895 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4898 if (spec->eapd_mask)
4899 stac_gpio_set(codec, spec->gpio_mask,
4900 spec->gpio_dir, spec->gpio_data &
4906 static struct hda_codec_ops stac92xx_patch_ops = {
4907 .build_controls = stac92xx_build_controls,
4908 .build_pcms = stac92xx_build_pcms,
4909 .init = stac92xx_init,
4910 .free = stac92xx_free,
4911 .unsol_event = stac92xx_unsol_event,
4912 #ifdef SND_HDA_NEEDS_RESUME
4913 .suspend = stac92xx_suspend,
4914 .resume = stac92xx_resume,
4918 static int patch_stac9200(struct hda_codec *codec)
4920 struct sigmatel_spec *spec;
4923 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4928 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4929 spec->pin_nids = stac9200_pin_nids;
4930 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4933 if (spec->board_config < 0)
4934 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4937 stac92xx_set_config_regs(codec,
4938 stac9200_brd_tbl[spec->board_config]);
4940 spec->multiout.max_channels = 2;
4941 spec->multiout.num_dacs = 1;
4942 spec->multiout.dac_nids = stac9200_dac_nids;
4943 spec->adc_nids = stac9200_adc_nids;
4944 spec->mux_nids = stac9200_mux_nids;
4945 spec->num_muxes = 1;
4946 spec->num_dmics = 0;
4950 if (spec->board_config == STAC_9200_M4 ||
4951 spec->board_config == STAC_9200_M4_2 ||
4952 spec->board_config == STAC_9200_OQO)
4953 spec->init = stac9200_eapd_init;
4955 spec->init = stac9200_core_init;
4956 spec->mixer = stac9200_mixer;
4958 if (spec->board_config == STAC_9200_PANASONIC) {
4959 spec->gpio_mask = spec->gpio_dir = 0x09;
4960 spec->gpio_data = 0x00;
4963 err = stac9200_parse_auto_config(codec);
4965 stac92xx_free(codec);
4969 /* CF-74 has no headphone detection, and the driver should *NOT*
4970 * do detection and HP/speaker toggle because the hardware does it.
4972 if (spec->board_config == STAC_9200_PANASONIC)
4973 spec->hp_detect = 0;
4975 codec->patch_ops = stac92xx_patch_ops;
4980 static int patch_stac925x(struct hda_codec *codec)
4982 struct sigmatel_spec *spec;
4985 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4990 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4991 spec->pin_nids = stac925x_pin_nids;
4993 /* Check first for codec ID */
4994 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4997 stac925x_codec_id_cfg_tbl);
4999 /* Now checks for PCI ID, if codec ID is not found */
5000 if (spec->board_config < 0)
5001 spec->board_config = snd_hda_check_board_config(codec,
5006 if (spec->board_config < 0)
5007 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5010 stac92xx_set_config_regs(codec,
5011 stac925x_brd_tbl[spec->board_config]);
5013 spec->multiout.max_channels = 2;
5014 spec->multiout.num_dacs = 1;
5015 spec->multiout.dac_nids = stac925x_dac_nids;
5016 spec->adc_nids = stac925x_adc_nids;
5017 spec->mux_nids = stac925x_mux_nids;
5018 spec->num_muxes = 1;
5021 switch (codec->vendor_id) {
5022 case 0x83847632: /* STAC9202 */
5023 case 0x83847633: /* STAC9202D */
5024 case 0x83847636: /* STAC9251 */
5025 case 0x83847637: /* STAC9251D */
5026 spec->num_dmics = STAC925X_NUM_DMICS;
5027 spec->dmic_nids = stac925x_dmic_nids;
5028 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5029 spec->dmux_nids = stac925x_dmux_nids;
5032 spec->num_dmics = 0;
5036 spec->init = stac925x_core_init;
5037 spec->mixer = stac925x_mixer;
5039 spec->capvols = stac925x_capvols;
5040 spec->capsws = stac925x_capsws;
5042 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
5044 if (spec->board_config < 0) {
5045 printk(KERN_WARNING "hda_codec: No auto-config is "
5046 "available, default to model=ref\n");
5047 spec->board_config = STAC_925x_REF;
5053 stac92xx_free(codec);
5057 codec->patch_ops = stac92xx_patch_ops;
5062 static struct hda_input_mux stac92hd73xx_dmux = {
5065 { "Analog Inputs", 0x0b },
5066 { "Digital Mic 1", 0x09 },
5067 { "Digital Mic 2", 0x0a },
5072 static int patch_stac92hd73xx(struct hda_codec *codec)
5074 struct sigmatel_spec *spec;
5075 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5079 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5084 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
5085 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5086 spec->pin_nids = stac92hd73xx_pin_nids;
5087 spec->board_config = snd_hda_check_board_config(codec,
5088 STAC_92HD73XX_MODELS,
5089 stac92hd73xx_models,
5090 stac92hd73xx_cfg_tbl);
5092 if (spec->board_config < 0)
5093 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5096 stac92xx_set_config_regs(codec,
5097 stac92hd73xx_brd_tbl[spec->board_config]);
5099 num_dacs = snd_hda_get_connections(codec, 0x0a,
5100 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5102 if (num_dacs < 3 || num_dacs > 5) {
5103 printk(KERN_WARNING "hda_codec: Could not determine "
5104 "number of channels defaulting to DAC count\n");
5105 num_dacs = STAC92HD73_DAC_COUNT;
5108 case 0x3: /* 6 Channel */
5109 spec->mixer = stac92hd73xx_6ch_mixer;
5110 spec->init = stac92hd73xx_6ch_core_init;
5111 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
5113 case 0x4: /* 8 Channel */
5114 spec->mixer = stac92hd73xx_8ch_mixer;
5115 spec->init = stac92hd73xx_8ch_core_init;
5116 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
5118 case 0x5: /* 10 Channel */
5119 spec->mixer = stac92hd73xx_10ch_mixer;
5120 spec->init = stac92hd73xx_10ch_core_init;
5121 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5124 spec->multiout.dac_nids = spec->dac_nids;
5126 spec->aloopback_mask = 0x01;
5127 spec->aloopback_shift = 8;
5129 spec->digbeep_nid = 0x1c;
5130 spec->mux_nids = stac92hd73xx_mux_nids;
5131 spec->adc_nids = stac92hd73xx_adc_nids;
5132 spec->dmic_nids = stac92hd73xx_dmic_nids;
5133 spec->dmux_nids = stac92hd73xx_dmux_nids;
5134 spec->smux_nids = stac92hd73xx_smux_nids;
5135 spec->amp_nids = stac92hd73xx_amp_nids;
5136 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
5138 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5139 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
5140 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
5141 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
5142 sizeof(stac92hd73xx_dmux));
5144 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5145 spec->capvols = stac92hd73xx_capvols;
5146 spec->capsws = stac92hd73xx_capsws;
5148 switch (spec->board_config) {
5150 spec->init = dell_eq_core_init;
5152 case STAC_DELL_M6_AMIC:
5153 case STAC_DELL_M6_DMIC:
5154 case STAC_DELL_M6_BOTH:
5155 spec->num_smuxes = 0;
5156 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
5157 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
5158 spec->eapd_switch = 0;
5161 if (spec->board_config != STAC_DELL_EQ)
5162 spec->init = dell_m6_core_init;
5163 switch (spec->board_config) {
5164 case STAC_DELL_M6_AMIC: /* Analog Mics */
5165 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5166 spec->num_dmics = 0;
5167 spec->private_dimux.num_items = 1;
5169 case STAC_DELL_M6_DMIC: /* Digital Mics */
5170 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5171 spec->num_dmics = 1;
5172 spec->private_dimux.num_items = 2;
5174 case STAC_DELL_M6_BOTH: /* Both */
5175 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5176 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5177 spec->num_dmics = 1;
5178 spec->private_dimux.num_items = 2;
5183 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5184 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5185 spec->eapd_switch = 1;
5187 if (spec->board_config > STAC_92HD73XX_REF) {
5188 /* GPIO0 High = Enable EAPD */
5189 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5190 spec->gpio_data = 0x01;
5192 spec->dinput_mux = &spec->private_dimux;
5194 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5195 spec->pwr_nids = stac92hd73xx_pwr_nids;
5197 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
5200 if (spec->board_config < 0) {
5201 printk(KERN_WARNING "hda_codec: No auto-config is "
5202 "available, default to model=ref\n");
5203 spec->board_config = STAC_92HD73XX_REF;
5210 stac92xx_free(codec);
5214 if (spec->board_config == STAC_92HD73XX_NO_JD)
5215 spec->hp_detect = 0;
5217 codec->patch_ops = stac92xx_patch_ops;
5219 codec->proc_widget_hook = stac92hd7x_proc_hook;
5224 static struct hda_input_mux stac92hd83xxx_dmux = {
5227 { "Analog Inputs", 0x03 },
5228 { "Digital Mic 1", 0x04 },
5229 { "Digital Mic 2", 0x05 },
5233 static int patch_stac92hd83xxx(struct hda_codec *codec)
5235 struct sigmatel_spec *spec;
5236 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
5241 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5246 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5247 spec->mono_nid = 0x19;
5248 spec->digbeep_nid = 0x21;
5249 spec->dmic_nids = stac92hd83xxx_dmic_nids;
5250 spec->dmux_nids = stac92hd83xxx_dmux_nids;
5251 spec->adc_nids = stac92hd83xxx_adc_nids;
5252 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5253 spec->amp_nids = stac92hd83xxx_amp_nids;
5254 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5255 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5256 spec->multiout.dac_nids = spec->dac_nids;
5258 spec->init = stac92hd83xxx_core_init;
5259 spec->mixer = stac92hd83xxx_mixer;
5260 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5261 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
5262 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5263 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
5264 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
5265 spec->dinput_mux = &stac92hd83xxx_dmux;
5266 spec->pin_nids = stac92hd83xxx_pin_nids;
5267 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5268 spec->capvols = stac92hd83xxx_capvols;
5269 spec->capsws = stac92hd83xxx_capsws;
5271 spec->board_config = snd_hda_check_board_config(codec,
5272 STAC_92HD83XXX_MODELS,
5273 stac92hd83xxx_models,
5274 stac92hd83xxx_cfg_tbl);
5276 if (spec->board_config < 0)
5277 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5280 stac92xx_set_config_regs(codec,
5281 stac92hd83xxx_brd_tbl[spec->board_config]);
5283 switch (codec->vendor_id) {
5287 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5293 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5295 if (spec->board_config < 0) {
5296 printk(KERN_WARNING "hda_codec: No auto-config is "
5297 "available, default to model=ref\n");
5298 spec->board_config = STAC_92HD83XXX_REF;
5305 stac92xx_free(codec);
5309 switch (spec->board_config) {
5318 num_dacs = snd_hda_get_connections(codec, nid,
5319 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5321 num_dacs = STAC92HD83_DAC_COUNT;
5323 /* set port X to select the last DAC
5325 snd_hda_codec_write_cache(codec, nid, 0,
5326 AC_VERB_SET_CONNECT_SEL, num_dacs);
5328 codec->patch_ops = stac92xx_patch_ops;
5330 codec->proc_widget_hook = stac92hd_proc_hook;
5335 static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
5338 { "Analog Inputs", 0x00 },
5339 { "Digital Mic 1", 0x02 },
5340 { "Digital Mic 2", 0x03 },
5344 static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
5347 { "Analog Inputs", 0x00 },
5349 { "Digital Mic 1", 0x02 },
5350 { "Digital Mic 2", 0x03 },
5354 /* get the pin connection (fixed, none, etc) */
5355 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5357 struct sigmatel_spec *spec = codec->spec;
5360 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5361 return get_defcfg_connect(cfg);
5364 static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5365 hda_nid_t *nids, int num_nids)
5367 struct sigmatel_spec *spec = codec->spec;
5369 unsigned int def_conf;
5371 for (num = 0; num < num_nids; num++) {
5372 for (idx = 0; idx < spec->num_pins; idx++)
5373 if (spec->pin_nids[idx] == nids[num])
5375 if (idx >= spec->num_pins)
5377 def_conf = stac_get_defcfg_connect(codec, idx);
5378 if (def_conf == AC_JACK_PORT_NONE)
5384 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5387 struct sigmatel_spec *spec = codec->spec;
5390 for (idx = 0; idx < spec->num_pins; idx++)
5391 if (spec->pin_nids[idx] == dig0pin)
5393 if ((idx + 2) >= spec->num_pins)
5397 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5400 /* dig0pin + dig2pin case */
5401 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5403 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5409 static int patch_stac92hd71bxx(struct hda_codec *codec)
5411 struct sigmatel_spec *spec;
5412 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5414 unsigned int ndmic_nids = 0;
5416 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5421 codec->patch_ops = stac92xx_patch_ops;
5422 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5423 switch (codec->vendor_id) {
5426 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5430 /* On 92HD75Bx 0x27 isn't a pin nid */
5434 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5436 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5437 spec->board_config = snd_hda_check_board_config(codec,
5438 STAC_92HD71BXX_MODELS,
5439 stac92hd71bxx_models,
5440 stac92hd71bxx_cfg_tbl);
5442 if (spec->board_config < 0)
5443 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5446 stac92xx_set_config_regs(codec,
5447 stac92hd71bxx_brd_tbl[spec->board_config]);
5449 if (spec->board_config > STAC_92HD71BXX_REF) {
5451 spec->gpio_mask = 0x01;
5452 spec->gpio_dir = 0x01;
5453 spec->gpio_data = 0x01;
5456 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5457 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5459 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5460 spec->capvols = stac92hd71bxx_capvols;
5461 spec->capsws = stac92hd71bxx_capsws;
5463 switch (codec->vendor_id) {
5464 case 0x111d76b6: /* 4 Port without Analog Mixer */
5468 case 0x111d76b4: /* 6 Port without Analog Mixer */
5470 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
5471 sizeof(stac92hd71bxx_dmux_nomixer));
5472 spec->init = stac92hd71bxx_core_init;
5473 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5474 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5475 stac92hd71bxx_dmic_nids,
5476 STAC92HD71BXX_NUM_DMICS);
5477 if (spec->num_dmics) {
5478 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5479 spec->dinput_mux = &spec->private_dimux;
5480 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5483 case 0x111d7608: /* 5 Port with Analog Mixer */
5484 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5485 sizeof(stac92hd71bxx_dmux_amixer));
5486 spec->private_dimux.num_items--;
5487 switch (spec->board_config) {
5489 /* Enable VREF power saving on GPIO1 detect */
5490 err = stac_add_event(spec, codec->afg,
5491 STAC_VREF_EVENT, 0x02);
5494 snd_hda_codec_write_cache(codec, codec->afg, 0,
5495 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5496 snd_hda_codec_write_cache(codec, codec->afg, 0,
5497 AC_VERB_SET_UNSOLICITED_ENABLE,
5499 spec->gpio_mask |= 0x02;
5502 if ((codec->revision_id & 0xf) == 0 ||
5503 (codec->revision_id & 0xf) == 1)
5504 spec->stream_delay = 40; /* 40 milliseconds */
5506 /* no output amps */
5508 if (snd_hda_get_bool_hint(codec, "analog_mixer") == 1)
5509 spec->mixer = stac92hd71bxx_analog_mixer;
5512 spec->init = stac92hd71bxx_core_init;
5514 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5515 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5516 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5517 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5518 stac92hd71bxx_dmic_nids,
5519 STAC92HD71BXX_NUM_DMICS - 1);
5520 if (spec->num_dmics) {
5521 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5522 spec->dinput_mux = &spec->private_dimux;
5523 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
5526 case 0x111d7603: /* 6 Port with Analog Mixer */
5527 if ((codec->revision_id & 0xf) == 1)
5528 spec->stream_delay = 40; /* 40 milliseconds */
5530 /* no output amps */
5534 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5535 sizeof(stac92hd71bxx_dmux_amixer));
5536 if (snd_hda_get_bool_hint(codec, "analog_mixer") == 1)
5537 spec->mixer = stac92hd71bxx_analog_mixer;
5538 spec->init = stac92hd71bxx_core_init;
5539 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5540 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5541 stac92hd71bxx_dmic_nids,
5542 STAC92HD71BXX_NUM_DMICS);
5543 if (spec->num_dmics) {
5544 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5545 spec->dinput_mux = &spec->private_dimux;
5546 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5550 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5551 snd_hda_sequence_write_cache(codec, unmute_init);
5553 /* Some HP machines seem to have unstable codec communications
5554 * especially with ATI fglrx driver. For recovering from the
5555 * CORB/RIRB stall, allow the BUS reset and keep always sync
5557 if (spec->board_config == STAC_HP_DV5) {
5558 codec->bus->sync_write = 1;
5559 codec->bus->allow_bus_reset = 1;
5562 spec->aloopback_ctl = stac92hd71bxx_loopback;
5563 spec->aloopback_mask = 0x50;
5564 spec->aloopback_shift = 0;
5566 spec->powerdown_adcs = 1;
5567 spec->digbeep_nid = 0x26;
5568 spec->mux_nids = stac92hd71bxx_mux_nids;
5569 spec->adc_nids = stac92hd71bxx_adc_nids;
5570 spec->smux_nids = stac92hd71bxx_smux_nids;
5571 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5573 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5574 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5575 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5577 switch (spec->board_config) {
5579 /* enable internal microphone */
5580 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5581 stac92xx_auto_set_pinctl(codec, 0x0e,
5582 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5584 case STAC_DELL_M4_2:
5585 spec->num_dmics = 0;
5586 spec->num_smuxes = 0;
5587 spec->num_dmuxes = 0;
5589 case STAC_DELL_M4_1:
5590 case STAC_DELL_M4_3:
5591 spec->num_dmics = 1;
5592 spec->num_smuxes = 0;
5593 spec->num_dmuxes = 1;
5595 case STAC_HP_DV4_1222NR:
5596 spec->num_dmics = 1;
5597 /* I don't know if it needs 1 or 2 smuxes - will wait for
5598 * bug reports to fix if needed
5600 spec->num_smuxes = 1;
5601 spec->num_dmuxes = 1;
5602 spec->gpio_led = 0x01;
5605 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5606 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5609 spec->num_dmics = 1;
5610 spec->num_dmuxes = 1;
5611 spec->num_smuxes = 1;
5612 /* orange/white mute led on GPIO3, orange=0, white=1 */
5613 spec->gpio_led = 0x08;
5617 #ifdef CONFIG_SND_HDA_POWER_SAVE
5618 if (spec->gpio_led) {
5619 spec->gpio_mask |= spec->gpio_led;
5620 spec->gpio_dir |= spec->gpio_led;
5621 spec->gpio_data |= spec->gpio_led;
5622 /* register check_power_status callback. */
5623 codec->patch_ops.check_power_status =
5624 stac92xx_hp_check_power_status;
5628 spec->multiout.dac_nids = spec->dac_nids;
5629 if (spec->dinput_mux)
5630 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
5632 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5634 if (spec->board_config < 0) {
5635 printk(KERN_WARNING "hda_codec: No auto-config is "
5636 "available, default to model=ref\n");
5637 spec->board_config = STAC_92HD71BXX_REF;
5644 stac92xx_free(codec);
5648 codec->proc_widget_hook = stac92hd7x_proc_hook;
5653 static int patch_stac922x(struct hda_codec *codec)
5655 struct sigmatel_spec *spec;
5658 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5663 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5664 spec->pin_nids = stac922x_pin_nids;
5665 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5668 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5669 spec->gpio_mask = spec->gpio_dir = 0x03;
5670 spec->gpio_data = 0x03;
5671 /* Intel Macs have all same PCI SSID, so we need to check
5672 * codec SSID to distinguish the exact models
5674 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5675 switch (codec->subsystem_id) {
5678 spec->board_config = STAC_INTEL_MAC_V1;
5682 spec->board_config = STAC_INTEL_MAC_V2;
5690 spec->board_config = STAC_INTEL_MAC_V3;
5694 spec->board_config = STAC_INTEL_MAC_V4;
5698 spec->board_config = STAC_INTEL_MAC_V5;
5701 spec->board_config = STAC_INTEL_MAC_V3;
5707 if (spec->board_config < 0)
5708 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5711 stac92xx_set_config_regs(codec,
5712 stac922x_brd_tbl[spec->board_config]);
5714 spec->adc_nids = stac922x_adc_nids;
5715 spec->mux_nids = stac922x_mux_nids;
5716 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5717 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5718 spec->num_dmics = 0;
5721 spec->init = stac922x_core_init;
5723 spec->num_caps = STAC922X_NUM_CAPS;
5724 spec->capvols = stac922x_capvols;
5725 spec->capsws = stac922x_capsws;
5727 spec->multiout.dac_nids = spec->dac_nids;
5729 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5731 if (spec->board_config < 0) {
5732 printk(KERN_WARNING "hda_codec: No auto-config is "
5733 "available, default to model=ref\n");
5734 spec->board_config = STAC_D945_REF;
5740 stac92xx_free(codec);
5744 codec->patch_ops = stac92xx_patch_ops;
5746 /* Fix Mux capture level; max to 2 */
5747 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5748 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5749 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5750 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5751 (0 << AC_AMPCAP_MUTE_SHIFT));
5756 static int patch_stac927x(struct hda_codec *codec)
5758 struct sigmatel_spec *spec;
5761 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5766 codec->slave_dig_outs = stac927x_slave_dig_outs;
5767 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5768 spec->pin_nids = stac927x_pin_nids;
5769 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5773 if (spec->board_config < 0)
5774 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5777 stac92xx_set_config_regs(codec,
5778 stac927x_brd_tbl[spec->board_config]);
5780 spec->digbeep_nid = 0x23;
5781 spec->adc_nids = stac927x_adc_nids;
5782 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5783 spec->mux_nids = stac927x_mux_nids;
5784 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5785 spec->smux_nids = stac927x_smux_nids;
5786 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5787 spec->spdif_labels = stac927x_spdif_labels;
5788 spec->dac_list = stac927x_dac_nids;
5789 spec->multiout.dac_nids = spec->dac_nids;
5791 switch (spec->board_config) {
5794 /* GPIO0 High = Enable EAPD */
5795 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
5796 spec->gpio_data = 0x01;
5797 spec->num_dmics = 0;
5799 spec->init = d965_core_init;
5801 case STAC_DELL_BIOS:
5802 switch (codec->subsystem_id) {
5805 /* correct the device field to SPDIF out */
5806 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5809 /* configure the analog microphone on some laptops */
5810 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5811 /* correct the front output jack as a hp out */
5812 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5813 /* correct the front input jack as a mic */
5814 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5817 /* GPIO2 High = Enable EAPD */
5818 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
5819 spec->gpio_data = 0x04;
5820 spec->dmic_nids = stac927x_dmic_nids;
5821 spec->num_dmics = STAC927X_NUM_DMICS;
5823 spec->init = d965_core_init;
5824 spec->dmux_nids = stac927x_dmux_nids;
5825 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5828 if (spec->board_config > STAC_D965_REF) {
5829 /* GPIO0 High = Enable EAPD */
5830 spec->eapd_mask = spec->gpio_mask = 0x01;
5831 spec->gpio_dir = spec->gpio_data = 0x01;
5833 spec->num_dmics = 0;
5835 spec->init = stac927x_core_init;
5838 spec->num_caps = STAC927X_NUM_CAPS;
5839 spec->capvols = stac927x_capvols;
5840 spec->capsws = stac927x_capsws;
5843 spec->aloopback_ctl = stac927x_loopback;
5844 spec->aloopback_mask = 0x40;
5845 spec->aloopback_shift = 0;
5846 spec->eapd_switch = 1;
5848 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
5850 if (spec->board_config < 0) {
5851 printk(KERN_WARNING "hda_codec: No auto-config is "
5852 "available, default to model=ref\n");
5853 spec->board_config = STAC_D965_REF;
5859 stac92xx_free(codec);
5863 codec->patch_ops = stac92xx_patch_ops;
5865 codec->proc_widget_hook = stac927x_proc_hook;
5869 * The STAC927x seem to require fairly long delays for certain
5870 * command sequences. With too short delays (even if the answer
5871 * is set to RIRB properly), it results in the silence output
5872 * on some hardwares like Dell.
5874 * The below flag enables the longer delay (see get_response
5877 codec->bus->needs_damn_long_delay = 1;
5879 /* no jack detecion for ref-no-jd model */
5880 if (spec->board_config == STAC_D965_REF_NO_JD)
5881 spec->hp_detect = 0;
5886 static int patch_stac9205(struct hda_codec *codec)
5888 struct sigmatel_spec *spec;
5891 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5896 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
5897 spec->pin_nids = stac9205_pin_nids;
5898 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5902 if (spec->board_config < 0)
5903 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5906 stac92xx_set_config_regs(codec,
5907 stac9205_brd_tbl[spec->board_config]);
5909 spec->digbeep_nid = 0x23;
5910 spec->adc_nids = stac9205_adc_nids;
5911 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
5912 spec->mux_nids = stac9205_mux_nids;
5913 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
5914 spec->smux_nids = stac9205_smux_nids;
5915 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
5916 spec->dmic_nids = stac9205_dmic_nids;
5917 spec->num_dmics = STAC9205_NUM_DMICS;
5918 spec->dmux_nids = stac9205_dmux_nids;
5919 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
5922 spec->init = stac9205_core_init;
5923 spec->aloopback_ctl = stac9205_loopback;
5925 spec->num_caps = STAC9205_NUM_CAPS;
5926 spec->capvols = stac9205_capvols;
5927 spec->capsws = stac9205_capsws;
5929 spec->aloopback_mask = 0x40;
5930 spec->aloopback_shift = 0;
5931 /* Turn on/off EAPD per HP plugging */
5932 if (spec->board_config != STAC_9205_EAPD)
5933 spec->eapd_switch = 1;
5934 spec->multiout.dac_nids = spec->dac_nids;
5936 switch (spec->board_config){
5937 case STAC_9205_DELL_M43:
5938 /* Enable SPDIF in/out */
5939 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5940 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
5942 /* Enable unsol response for GPIO4/Dock HP connection */
5943 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5946 snd_hda_codec_write_cache(codec, codec->afg, 0,
5947 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5948 snd_hda_codec_write_cache(codec, codec->afg, 0,
5949 AC_VERB_SET_UNSOLICITED_ENABLE,
5952 spec->gpio_dir = 0x0b;
5953 spec->eapd_mask = 0x01;
5954 spec->gpio_mask = 0x1b;
5955 spec->gpio_mute = 0x10;
5956 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5959 spec->gpio_data = 0x01;
5962 /* SPDIF-In enabled */
5965 /* GPIO0 High = EAPD */
5966 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5967 spec->gpio_data = 0x01;
5971 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5973 if (spec->board_config < 0) {
5974 printk(KERN_WARNING "hda_codec: No auto-config is "
5975 "available, default to model=ref\n");
5976 spec->board_config = STAC_9205_REF;
5982 stac92xx_free(codec);
5986 codec->patch_ops = stac92xx_patch_ops;
5988 codec->proc_widget_hook = stac9205_proc_hook;
5997 static struct hda_verb stac9872_core_init[] = {
5998 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5999 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6003 static hda_nid_t stac9872_pin_nids[] = {
6004 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6008 static hda_nid_t stac9872_adc_nids[] = {
6012 static hda_nid_t stac9872_mux_nids[] = {
6016 static unsigned long stac9872_capvols[] = {
6017 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6019 #define stac9872_capsws stac9872_capvols
6021 static unsigned int stac9872_vaio_pin_configs[9] = {
6022 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6023 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6027 static const char *stac9872_models[STAC_9872_MODELS] = {
6028 [STAC_9872_AUTO] = "auto",
6029 [STAC_9872_VAIO] = "vaio",
6032 static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
6033 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6036 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
6037 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6038 "Sony VAIO F/S", STAC_9872_VAIO),
6042 static int patch_stac9872(struct hda_codec *codec)
6044 struct sigmatel_spec *spec;
6047 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6051 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6052 spec->pin_nids = stac9872_pin_nids;
6054 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6057 if (spec->board_config < 0)
6058 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6061 stac92xx_set_config_regs(codec,
6062 stac9872_brd_tbl[spec->board_config]);
6064 spec->multiout.dac_nids = spec->dac_nids;
6065 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6066 spec->adc_nids = stac9872_adc_nids;
6067 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6068 spec->mux_nids = stac9872_mux_nids;
6069 spec->init = stac9872_core_init;
6071 spec->capvols = stac9872_capvols;
6072 spec->capsws = stac9872_capsws;
6074 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
6076 stac92xx_free(codec);
6079 spec->input_mux = &spec->private_imux;
6080 codec->patch_ops = stac92xx_patch_ops;
6088 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
6089 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6090 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6091 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6092 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6093 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6094 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6095 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
6096 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6097 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6098 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6099 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6100 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6101 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
6102 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6103 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6104 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6105 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6106 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6107 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6108 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6109 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6110 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6111 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
6112 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6113 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6114 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6115 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6116 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6117 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
6118 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6119 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
6120 /* The following does not take into account .id=0x83847661 when subsys =
6121 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6122 * currently not fully supported.
6124 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6125 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6126 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
6127 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
6128 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6129 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6130 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6131 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6132 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6133 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6134 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6135 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
6136 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
6137 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
6138 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
6139 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
6140 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
6141 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6142 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
6143 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
6144 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6145 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6146 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6147 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6148 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6149 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6150 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6151 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6155 MODULE_ALIAS("snd-hda-codec-id:8384*");
6156 MODULE_ALIAS("snd-hda-codec-id:111d*");
6158 MODULE_LICENSE("GPL");
6159 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6161 static struct hda_codec_preset_list sigmatel_list = {
6162 .preset = snd_hda_preset_sigmatel,
6163 .owner = THIS_MODULE,
6166 static int __init patch_sigmatel_init(void)
6168 return snd_hda_add_codec_preset(&sigmatel_list);
6171 static void __exit patch_sigmatel_exit(void)
6173 snd_hda_delete_codec_preset(&sigmatel_list);
6176 module_init(patch_sigmatel_init)
6177 module_exit(patch_sigmatel_exit)