2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include <sound/asoundef.h>
33 #include <sound/jack.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
79 STAC_92HD73XX_NO_JD, /* no jack-detection */
92 STAC_92HD83XXX_PWR_REF,
107 STAC_92HD71BXX_MODELS
133 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
134 * is given, one of the above models will be
135 * chosen according to the subsystem id. */
136 /* for backward compatibility */
153 STAC_D965_REF_NO_JD, /* no jack-detection */
169 struct sigmatel_event {
176 struct sigmatel_jack {
179 struct snd_jack *jack;
182 struct sigmatel_mic_route {
184 unsigned char mux_idx;
185 unsigned char dmux_idx;
188 struct sigmatel_spec {
189 struct snd_kcontrol_new *mixers[4];
190 unsigned int num_mixers;
193 unsigned int eapd_switch: 1;
194 unsigned int surr_switch: 1;
195 unsigned int alt_switch: 1;
196 unsigned int hp_detect: 1;
197 unsigned int spdif_mute: 1;
198 unsigned int check_volume_offset:1;
199 unsigned int auto_mic:1;
202 unsigned int eapd_mask;
203 unsigned int gpio_mask;
204 unsigned int gpio_dir;
205 unsigned int gpio_data;
206 unsigned int gpio_mute;
207 unsigned int gpio_led;
210 unsigned int stream_delay;
212 /* analog loopback */
213 struct snd_kcontrol_new *aloopback_ctl;
214 unsigned char aloopback_mask;
215 unsigned char aloopback_shift;
217 /* power management */
218 unsigned int num_pwrs;
219 unsigned int *pwr_mapping;
224 struct snd_array jacks;
227 struct snd_array events;
230 struct hda_input_mux *mono_mux;
231 unsigned int cur_mmux;
232 struct hda_multi_out multiout;
233 hda_nid_t dac_nids[5];
234 hda_nid_t hp_dacs[5];
235 hda_nid_t speaker_dacs[5];
241 unsigned int num_adcs;
243 unsigned int num_muxes;
244 hda_nid_t *dmic_nids;
245 unsigned int num_dmics;
246 hda_nid_t *dmux_nids;
247 unsigned int num_dmuxes;
248 hda_nid_t *smux_nids;
249 unsigned int num_smuxes;
250 unsigned int num_analog_muxes;
252 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
253 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
254 unsigned int num_caps; /* number of capture volume/switch elements */
256 struct sigmatel_mic_route ext_mic;
257 struct sigmatel_mic_route int_mic;
259 const char **spdif_labels;
261 hda_nid_t dig_in_nid;
263 hda_nid_t anabeep_nid;
264 hda_nid_t digbeep_nid;
268 unsigned int num_pins;
270 /* codec specific stuff */
271 struct hda_verb *init;
272 struct snd_kcontrol_new *mixer;
275 struct hda_input_mux *dinput_mux;
276 unsigned int cur_dmux[2];
277 struct hda_input_mux *input_mux;
278 unsigned int cur_mux[3];
279 struct hda_input_mux *sinput_mux;
280 unsigned int cur_smux[2];
281 unsigned int cur_amux;
283 unsigned int powerdown_adcs;
286 unsigned int io_switch[2];
287 unsigned int clfe_swap;
288 hda_nid_t line_switch; /* shared line-in for input and output */
289 hda_nid_t mic_switch; /* shared mic-in for input and output */
290 hda_nid_t hp_switch; /* NID of HP as line-out */
291 unsigned int aloopback;
293 struct hda_pcm pcm_rec[2]; /* PCM information */
295 /* dynamic controls and input_mux */
296 struct auto_pin_cfg autocfg;
297 struct snd_array kctls;
298 struct hda_input_mux private_dimux;
299 struct hda_input_mux private_imux;
300 struct hda_input_mux private_smux;
301 struct hda_input_mux private_mono_mux;
304 static hda_nid_t stac9200_adc_nids[1] = {
308 static hda_nid_t stac9200_mux_nids[1] = {
312 static hda_nid_t stac9200_dac_nids[1] = {
316 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
317 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
321 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
325 static hda_nid_t stac92hd73xx_adc_nids[2] = {
329 #define STAC92HD73XX_NUM_DMICS 2
330 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
334 #define STAC92HD73_DAC_COUNT 5
336 static hda_nid_t stac92hd73xx_mux_nids[2] = {
340 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
344 static hda_nid_t stac92hd73xx_smux_nids[2] = {
348 #define STAC92HD73XX_NUM_CAPS 2
349 static unsigned long stac92hd73xx_capvols[] = {
350 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
351 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
353 #define stac92hd73xx_capsws stac92hd73xx_capvols
355 #define STAC92HD83_DAC_COUNT 3
357 static hda_nid_t stac92hd83xxx_mux_nids[2] = {
361 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
365 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
369 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
373 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
374 0x03, 0x0c, 0x20, 0x40,
377 #define STAC92HD83XXX_NUM_CAPS 2
378 static unsigned long stac92hd83xxx_capvols[] = {
379 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
380 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
382 #define stac92hd83xxx_capsws stac92hd83xxx_capvols
384 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
388 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
392 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
396 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
400 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
404 #define STAC92HD71BXX_NUM_DMICS 2
405 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
409 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
413 #define STAC92HD71BXX_NUM_CAPS 2
414 static unsigned long stac92hd71bxx_capvols[] = {
415 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
416 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
418 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
420 static hda_nid_t stac925x_adc_nids[1] = {
424 static hda_nid_t stac925x_mux_nids[1] = {
428 static hda_nid_t stac925x_dac_nids[1] = {
432 #define STAC925X_NUM_DMICS 1
433 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
437 static hda_nid_t stac925x_dmux_nids[1] = {
441 static unsigned long stac925x_capvols[] = {
442 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
444 static unsigned long stac925x_capsws[] = {
445 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
448 static hda_nid_t stac922x_adc_nids[2] = {
452 static hda_nid_t stac922x_mux_nids[2] = {
456 #define STAC922X_NUM_CAPS 2
457 static unsigned long stac922x_capvols[] = {
458 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
459 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
461 #define stac922x_capsws stac922x_capvols
463 static hda_nid_t stac927x_slave_dig_outs[2] = {
467 static hda_nid_t stac927x_adc_nids[3] = {
471 static hda_nid_t stac927x_mux_nids[3] = {
475 static hda_nid_t stac927x_smux_nids[1] = {
479 static hda_nid_t stac927x_dac_nids[6] = {
480 0x02, 0x03, 0x04, 0x05, 0x06, 0
483 static hda_nid_t stac927x_dmux_nids[1] = {
487 #define STAC927X_NUM_DMICS 2
488 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
492 #define STAC927X_NUM_CAPS 3
493 static unsigned long stac927x_capvols[] = {
494 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
495 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
496 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
498 static unsigned long stac927x_capsws[] = {
499 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
500 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
501 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
504 static const char *stac927x_spdif_labels[5] = {
505 "Digital Playback", "ADAT", "Analog Mux 1",
506 "Analog Mux 2", "Analog Mux 3"
509 static hda_nid_t stac9205_adc_nids[2] = {
513 static hda_nid_t stac9205_mux_nids[2] = {
517 static hda_nid_t stac9205_dmux_nids[1] = {
521 static hda_nid_t stac9205_smux_nids[1] = {
525 #define STAC9205_NUM_DMICS 2
526 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
530 #define STAC9205_NUM_CAPS 2
531 static unsigned long stac9205_capvols[] = {
532 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
533 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
535 static unsigned long stac9205_capsws[] = {
536 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
537 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
540 static hda_nid_t stac9200_pin_nids[8] = {
541 0x08, 0x09, 0x0d, 0x0e,
542 0x0f, 0x10, 0x11, 0x12,
545 static hda_nid_t stac925x_pin_nids[8] = {
546 0x07, 0x08, 0x0a, 0x0b,
547 0x0c, 0x0d, 0x10, 0x11,
550 static hda_nid_t stac922x_pin_nids[10] = {
551 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
552 0x0f, 0x10, 0x11, 0x15, 0x1b,
555 static hda_nid_t stac92hd73xx_pin_nids[13] = {
556 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
557 0x0f, 0x10, 0x11, 0x12, 0x13,
561 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
562 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
563 0x0f, 0x10, 0x11, 0x1f, 0x20,
566 #define STAC92HD71BXX_NUM_PINS 13
567 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
568 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
569 0x00, 0x14, 0x18, 0x19, 0x1e,
572 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
573 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
574 0x0f, 0x14, 0x18, 0x19, 0x1e,
578 static hda_nid_t stac927x_pin_nids[14] = {
579 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
580 0x0f, 0x10, 0x11, 0x12, 0x13,
581 0x14, 0x21, 0x22, 0x23,
584 static hda_nid_t stac9205_pin_nids[12] = {
585 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
586 0x0f, 0x14, 0x16, 0x17, 0x18,
590 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
591 struct snd_ctl_elem_info *uinfo)
593 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
594 struct sigmatel_spec *spec = codec->spec;
595 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
598 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
599 struct snd_ctl_elem_value *ucontrol)
601 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
602 struct sigmatel_spec *spec = codec->spec;
603 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
605 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
609 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
610 struct snd_ctl_elem_value *ucontrol)
612 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
613 struct sigmatel_spec *spec = codec->spec;
614 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
616 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
617 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
620 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
621 struct snd_ctl_elem_info *uinfo)
623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
624 struct sigmatel_spec *spec = codec->spec;
625 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
628 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
629 struct snd_ctl_elem_value *ucontrol)
631 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
632 struct sigmatel_spec *spec = codec->spec;
633 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
635 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
639 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
640 struct snd_ctl_elem_value *ucontrol)
642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
643 struct sigmatel_spec *spec = codec->spec;
644 struct hda_input_mux *smux = &spec->private_smux;
645 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
649 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
650 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
654 if (spec->spdif_mute) {
656 nid = spec->multiout.dig_out_nid;
658 nid = codec->slave_dig_outs[smux_idx - 1];
659 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
663 /* un/mute SPDIF out */
664 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
670 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
671 hda_nid_t nid, unsigned int new_vref)
675 pincfg = snd_hda_codec_read(codec, nid, 0,
676 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
679 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
682 if (new_vref == AC_PINCTL_VREF_HIZ)
683 pincfg |= AC_PINCTL_OUT_EN;
685 pincfg |= AC_PINCTL_IN_EN;
687 error = snd_hda_codec_write_cache(codec, nid, 0,
688 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
695 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
698 vref = snd_hda_codec_read(codec, nid, 0,
699 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
700 vref &= AC_PINCTL_VREFEN;
704 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
706 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
707 struct sigmatel_spec *spec = codec->spec;
708 return snd_hda_input_mux_info(spec->input_mux, uinfo);
711 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
714 struct sigmatel_spec *spec = codec->spec;
715 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
717 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
721 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
723 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
724 struct sigmatel_spec *spec = codec->spec;
725 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
726 const struct hda_input_mux *imux = spec->input_mux;
727 unsigned int idx, prev_idx;
729 idx = ucontrol->value.enumerated.item[0];
730 if (idx >= imux->num_items)
731 idx = imux->num_items - 1;
732 prev_idx = spec->cur_mux[adc_idx];
735 if (idx < spec->num_analog_muxes) {
736 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
737 AC_VERB_SET_CONNECT_SEL,
738 imux->items[idx].index);
739 if (prev_idx >= spec->num_analog_muxes) {
740 imux = spec->dinput_mux;
742 snd_hda_codec_write_cache(codec,
743 spec->dmux_nids[adc_idx], 0,
744 AC_VERB_SET_CONNECT_SEL,
745 imux->items[0].index);
748 imux = spec->dinput_mux;
749 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
750 AC_VERB_SET_CONNECT_SEL,
751 imux->items[idx - 1].index);
753 spec->cur_mux[adc_idx] = idx;
757 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
758 struct snd_ctl_elem_info *uinfo)
760 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
761 struct sigmatel_spec *spec = codec->spec;
762 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
765 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value *ucontrol)
768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
769 struct sigmatel_spec *spec = codec->spec;
771 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
775 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
776 struct snd_ctl_elem_value *ucontrol)
778 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
779 struct sigmatel_spec *spec = codec->spec;
781 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
782 spec->mono_nid, &spec->cur_mmux);
785 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
787 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
788 struct snd_ctl_elem_value *ucontrol)
790 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
791 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
792 struct sigmatel_spec *spec = codec->spec;
794 ucontrol->value.integer.value[0] = !!(spec->aloopback &
795 (spec->aloopback_mask << idx));
799 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
800 struct snd_ctl_elem_value *ucontrol)
802 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
803 struct sigmatel_spec *spec = codec->spec;
804 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
805 unsigned int dac_mode;
806 unsigned int val, idx_val;
808 idx_val = spec->aloopback_mask << idx;
809 if (ucontrol->value.integer.value[0])
810 val = spec->aloopback | idx_val;
812 val = spec->aloopback & ~idx_val;
813 if (spec->aloopback == val)
816 spec->aloopback = val;
818 /* Only return the bits defined by the shift value of the
819 * first two bytes of the mask
821 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
822 kcontrol->private_value & 0xFFFF, 0x0);
823 dac_mode >>= spec->aloopback_shift;
825 if (spec->aloopback & idx_val) {
826 snd_hda_power_up(codec);
829 snd_hda_power_down(codec);
830 dac_mode &= ~idx_val;
833 snd_hda_codec_write_cache(codec, codec->afg, 0,
834 kcontrol->private_value >> 16, dac_mode);
839 static struct hda_verb stac9200_core_init[] = {
840 /* set dac0mux for dac converter */
841 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
845 static struct hda_verb stac9200_eapd_init[] = {
846 /* set dac0mux for dac converter */
847 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
848 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
852 static struct hda_verb dell_eq_core_init[] = {
853 /* set master volume to max value without distortion
854 * and direct control */
855 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
859 static struct hda_verb stac92hd73xx_core_init[] = {
860 /* set master volume and direct control */
861 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
865 static struct hda_verb stac92hd83xxx_core_init[] = {
866 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
867 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
868 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
870 /* power state controls amps */
871 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
875 static struct hda_verb stac92hd71bxx_core_init[] = {
876 /* set master volume and direct control */
877 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
881 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
882 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
883 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
884 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
885 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
889 static struct hda_verb stac925x_core_init[] = {
890 /* set dac0mux for dac converter */
891 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
892 /* mute the master volume */
893 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
897 static struct hda_verb stac922x_core_init[] = {
898 /* set master volume and direct control */
899 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
903 static struct hda_verb d965_core_init[] = {
904 /* set master volume and direct control */
905 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
906 /* unmute node 0x1b */
907 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
908 /* select node 0x03 as DAC */
909 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
913 static struct hda_verb stac927x_core_init[] = {
914 /* set master volume and direct control */
915 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
916 /* enable analog pc beep path */
917 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
921 static struct hda_verb stac9205_core_init[] = {
922 /* set master volume and direct control */
923 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
924 /* enable analog pc beep path */
925 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
929 #define STAC_MONO_MUX \
931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
932 .name = "Mono Mux", \
934 .info = stac92xx_mono_mux_enum_info, \
935 .get = stac92xx_mono_mux_enum_get, \
936 .put = stac92xx_mono_mux_enum_put, \
939 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
941 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
942 .name = "Analog Loopback", \
944 .info = stac92xx_aloopback_info, \
945 .get = stac92xx_aloopback_get, \
946 .put = stac92xx_aloopback_put, \
947 .private_value = verb_read | (verb_write << 16), \
950 #define DC_BIAS(xname, idx, nid) \
952 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
955 .info = stac92xx_dc_bias_info, \
956 .get = stac92xx_dc_bias_get, \
957 .put = stac92xx_dc_bias_put, \
958 .private_value = nid, \
961 static struct snd_kcontrol_new stac9200_mixer[] = {
962 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
963 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
964 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
965 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
969 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
970 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
974 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
975 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
979 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
980 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
985 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
986 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
989 static struct snd_kcontrol_new stac925x_mixer[] = {
990 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
991 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
995 static struct snd_kcontrol_new stac9205_loopback[] = {
996 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1000 static struct snd_kcontrol_new stac927x_loopback[] = {
1001 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1005 static struct snd_kcontrol_new stac_dmux_mixer = {
1006 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1007 .name = "Digital Input Source",
1008 /* count set later */
1009 .info = stac92xx_dmux_enum_info,
1010 .get = stac92xx_dmux_enum_get,
1011 .put = stac92xx_dmux_enum_put,
1014 static struct snd_kcontrol_new stac_smux_mixer = {
1015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1016 .name = "IEC958 Playback Source",
1017 /* count set later */
1018 .info = stac92xx_smux_enum_info,
1019 .get = stac92xx_smux_enum_get,
1020 .put = stac92xx_smux_enum_put,
1023 static const char *slave_vols[] = {
1024 "Front Playback Volume",
1025 "Surround Playback Volume",
1026 "Center Playback Volume",
1027 "LFE Playback Volume",
1028 "Side Playback Volume",
1029 "Headphone Playback Volume",
1030 "Speaker Playback Volume",
1034 static const char *slave_sws[] = {
1035 "Front Playback Switch",
1036 "Surround Playback Switch",
1037 "Center Playback Switch",
1038 "LFE Playback Switch",
1039 "Side Playback Switch",
1040 "Headphone Playback Switch",
1041 "Speaker Playback Switch",
1042 "IEC958 Playback Switch",
1046 static void stac92xx_free_kctls(struct hda_codec *codec);
1047 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1049 static int stac92xx_build_controls(struct hda_codec *codec)
1051 struct sigmatel_spec *spec = codec->spec;
1052 struct auto_pin_cfg *cfg = &spec->autocfg;
1058 err = snd_hda_add_new_ctls(codec, spec->mixer);
1063 for (i = 0; i < spec->num_mixers; i++) {
1064 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1068 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1069 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1070 stac_dmux_mixer.count = spec->num_dmuxes;
1071 err = snd_hda_ctl_add(codec,
1072 snd_ctl_new1(&stac_dmux_mixer, codec));
1076 if (spec->num_smuxes > 0) {
1077 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1078 struct hda_input_mux *smux = &spec->private_smux;
1079 /* check for mute support on SPDIF out */
1080 if (wcaps & AC_WCAP_OUT_AMP) {
1081 smux->items[smux->num_items].label = "Off";
1082 smux->items[smux->num_items].index = 0;
1084 spec->spdif_mute = 1;
1086 stac_smux_mixer.count = spec->num_smuxes;
1087 err = snd_hda_ctl_add(codec,
1088 snd_ctl_new1(&stac_smux_mixer, codec));
1093 if (spec->multiout.dig_out_nid) {
1094 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1097 err = snd_hda_create_spdif_share_sw(codec,
1101 spec->multiout.share_spdif = 1;
1103 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1104 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1109 /* if we have no master control, let's create it */
1110 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1111 unsigned int vmaster_tlv[4];
1112 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1113 HDA_OUTPUT, vmaster_tlv);
1114 /* correct volume offset */
1115 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1116 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1117 vmaster_tlv, slave_vols);
1121 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1122 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1128 if (spec->aloopback_ctl &&
1129 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1130 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1135 stac92xx_free_kctls(codec); /* no longer needed */
1137 /* create jack input elements */
1138 if (spec->hp_detect) {
1139 for (i = 0; i < cfg->hp_outs; i++) {
1140 int type = SND_JACK_HEADPHONE;
1141 nid = cfg->hp_pins[i];
1142 /* jack detection */
1143 if (cfg->hp_outs == i)
1144 type |= SND_JACK_LINEOUT;
1145 err = stac92xx_add_jack(codec, nid, type);
1150 for (i = 0; i < cfg->line_outs; i++) {
1151 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1156 for (i = 0; i < AUTO_PIN_LAST; i++) {
1157 nid = cfg->input_pins[i];
1159 err = stac92xx_add_jack(codec, nid,
1160 SND_JACK_MICROPHONE);
1169 static unsigned int ref9200_pin_configs[8] = {
1170 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1171 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1174 static unsigned int gateway9200_m4_pin_configs[8] = {
1175 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1176 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1178 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1179 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1180 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1184 STAC 9200 pin configs for
1189 static unsigned int dell9200_d21_pin_configs[8] = {
1190 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1191 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1195 STAC 9200 pin configs for
1199 static unsigned int dell9200_d22_pin_configs[8] = {
1200 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1201 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1205 STAC 9200 pin configs for
1206 102801C4 (Dell Dimension E310)
1213 static unsigned int dell9200_d23_pin_configs[8] = {
1214 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1215 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1220 STAC 9200-32 pin configs for
1221 102801B5 (Dell Inspiron 630m)
1222 102801D8 (Dell Inspiron 640m)
1224 static unsigned int dell9200_m21_pin_configs[8] = {
1225 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1226 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1230 STAC 9200-32 pin configs for
1231 102801C2 (Dell Latitude D620)
1233 102801CC (Dell Latitude D820)
1237 static unsigned int dell9200_m22_pin_configs[8] = {
1238 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1239 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1243 STAC 9200-32 pin configs for
1244 102801CE (Dell XPS M1710)
1245 102801CF (Dell Precision M90)
1247 static unsigned int dell9200_m23_pin_configs[8] = {
1248 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1249 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1253 STAC 9200-32 pin configs for
1256 102801CB (Dell Latitude 120L)
1259 static unsigned int dell9200_m24_pin_configs[8] = {
1260 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1261 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1265 STAC 9200-32 pin configs for
1266 102801BD (Dell Inspiron E1505n)
1270 static unsigned int dell9200_m25_pin_configs[8] = {
1271 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1272 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1276 STAC 9200-32 pin configs for
1277 102801F5 (Dell Inspiron 1501)
1280 static unsigned int dell9200_m26_pin_configs[8] = {
1281 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1282 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1287 102801CD (Dell Inspiron E1705/9400)
1289 static unsigned int dell9200_m27_pin_configs[8] = {
1290 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1291 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1294 static unsigned int oqo9200_pin_configs[8] = {
1295 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1296 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1300 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1301 [STAC_REF] = ref9200_pin_configs,
1302 [STAC_9200_OQO] = oqo9200_pin_configs,
1303 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1304 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1305 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1306 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1307 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1308 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1309 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1310 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1311 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1312 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1313 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1314 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1315 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1318 static const char *stac9200_models[STAC_9200_MODELS] = {
1319 [STAC_AUTO] = "auto",
1321 [STAC_9200_OQO] = "oqo",
1322 [STAC_9200_DELL_D21] = "dell-d21",
1323 [STAC_9200_DELL_D22] = "dell-d22",
1324 [STAC_9200_DELL_D23] = "dell-d23",
1325 [STAC_9200_DELL_M21] = "dell-m21",
1326 [STAC_9200_DELL_M22] = "dell-m22",
1327 [STAC_9200_DELL_M23] = "dell-m23",
1328 [STAC_9200_DELL_M24] = "dell-m24",
1329 [STAC_9200_DELL_M25] = "dell-m25",
1330 [STAC_9200_DELL_M26] = "dell-m26",
1331 [STAC_9200_DELL_M27] = "dell-m27",
1332 [STAC_9200_M4] = "gateway-m4",
1333 [STAC_9200_M4_2] = "gateway-m4-2",
1334 [STAC_9200_PANASONIC] = "panasonic",
1337 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1338 /* SigmaTel reference board */
1339 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1340 "DFI LanParty", STAC_REF),
1341 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1342 "DFI LanParty", STAC_REF),
1343 /* Dell laptops have BIOS problem */
1344 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1345 "unknown Dell", STAC_9200_DELL_D21),
1346 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1347 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1348 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1349 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1350 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1351 "unknown Dell", STAC_9200_DELL_D22),
1352 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1353 "unknown Dell", STAC_9200_DELL_D22),
1354 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1355 "Dell Latitude D620", STAC_9200_DELL_M22),
1356 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1357 "unknown Dell", STAC_9200_DELL_D23),
1358 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1359 "unknown Dell", STAC_9200_DELL_D23),
1360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1361 "unknown Dell", STAC_9200_DELL_M22),
1362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1363 "unknown Dell", STAC_9200_DELL_M24),
1364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1365 "unknown Dell", STAC_9200_DELL_M24),
1366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1367 "Dell Latitude 120L", STAC_9200_DELL_M24),
1368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1369 "Dell Latitude D820", STAC_9200_DELL_M22),
1370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1371 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1373 "Dell XPS M1710", STAC_9200_DELL_M23),
1374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1375 "Dell Precision M90", STAC_9200_DELL_M23),
1376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1377 "unknown Dell", STAC_9200_DELL_M22),
1378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1379 "unknown Dell", STAC_9200_DELL_M22),
1380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1381 "unknown Dell", STAC_9200_DELL_M22),
1382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1383 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1384 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1385 "unknown Dell", STAC_9200_DELL_D23),
1386 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1387 "unknown Dell", STAC_9200_DELL_D23),
1388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1389 "unknown Dell", STAC_9200_DELL_D21),
1390 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1391 "unknown Dell", STAC_9200_DELL_D23),
1392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1393 "unknown Dell", STAC_9200_DELL_D21),
1394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1395 "unknown Dell", STAC_9200_DELL_M25),
1396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1397 "unknown Dell", STAC_9200_DELL_M25),
1398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1399 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1401 "unknown Dell", STAC_9200_DELL_M26),
1403 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1404 /* Gateway machines needs EAPD to be set on resume */
1405 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1406 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1407 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1409 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1413 static unsigned int ref925x_pin_configs[8] = {
1414 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1415 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1418 static unsigned int stac925xM1_pin_configs[8] = {
1419 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1420 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1423 static unsigned int stac925xM1_2_pin_configs[8] = {
1424 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1425 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1428 static unsigned int stac925xM2_pin_configs[8] = {
1429 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1430 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1433 static unsigned int stac925xM2_2_pin_configs[8] = {
1434 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1435 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1438 static unsigned int stac925xM3_pin_configs[8] = {
1439 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1440 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1443 static unsigned int stac925xM5_pin_configs[8] = {
1444 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1445 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1448 static unsigned int stac925xM6_pin_configs[8] = {
1449 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1450 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1453 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1454 [STAC_REF] = ref925x_pin_configs,
1455 [STAC_M1] = stac925xM1_pin_configs,
1456 [STAC_M1_2] = stac925xM1_2_pin_configs,
1457 [STAC_M2] = stac925xM2_pin_configs,
1458 [STAC_M2_2] = stac925xM2_2_pin_configs,
1459 [STAC_M3] = stac925xM3_pin_configs,
1460 [STAC_M5] = stac925xM5_pin_configs,
1461 [STAC_M6] = stac925xM6_pin_configs,
1464 static const char *stac925x_models[STAC_925x_MODELS] = {
1465 [STAC_925x_AUTO] = "auto",
1468 [STAC_M1_2] = "m1-2",
1470 [STAC_M2_2] = "m2-2",
1476 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1477 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1478 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1479 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1480 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1481 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1482 /* Not sure about the brand name for those */
1483 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1484 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1485 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1486 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1490 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1491 /* SigmaTel reference board */
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1493 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1494 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1496 /* Default table for unknown ID */
1497 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1502 static unsigned int ref92hd73xx_pin_configs[13] = {
1503 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1504 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1505 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1509 static unsigned int dell_m6_pin_configs[13] = {
1510 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1511 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1512 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1516 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1517 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1518 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1519 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1520 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1521 [STAC_DELL_EQ] = dell_m6_pin_configs,
1524 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1525 [STAC_92HD73XX_AUTO] = "auto",
1526 [STAC_92HD73XX_NO_JD] = "no-jd",
1527 [STAC_92HD73XX_REF] = "ref",
1528 [STAC_92HD73XX_INTEL] = "intel",
1529 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1530 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1531 [STAC_DELL_M6_BOTH] = "dell-m6",
1532 [STAC_DELL_EQ] = "dell-eq",
1535 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1536 /* SigmaTel reference board */
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1538 "DFI LanParty", STAC_92HD73XX_REF),
1539 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1540 "DFI LanParty", STAC_92HD73XX_REF),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1542 "Intel DG45ID", STAC_92HD73XX_INTEL),
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1544 "Intel DG45FC", STAC_92HD73XX_INTEL),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1546 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1548 "unknown Dell", STAC_DELL_M6_DMIC),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1550 "unknown Dell", STAC_DELL_M6_BOTH),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1552 "unknown Dell", STAC_DELL_M6_BOTH),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1554 "unknown Dell", STAC_DELL_M6_AMIC),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1556 "unknown Dell", STAC_DELL_M6_AMIC),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1558 "unknown Dell", STAC_DELL_M6_DMIC),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1560 "unknown Dell", STAC_DELL_M6_DMIC),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1562 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1564 "Dell Studio 17", STAC_DELL_M6_DMIC),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1566 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1570 static unsigned int ref92hd83xxx_pin_configs[10] = {
1571 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1572 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1573 0x01451160, 0x98560170,
1576 static unsigned int dell_s14_pin_configs[10] = {
1577 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1578 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1579 0x40f000f0, 0x40f000f0,
1582 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1583 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1584 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1585 [STAC_DELL_S14] = dell_s14_pin_configs,
1588 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1589 [STAC_92HD83XXX_AUTO] = "auto",
1590 [STAC_92HD83XXX_REF] = "ref",
1591 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1592 [STAC_DELL_S14] = "dell-s14",
1595 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1596 /* SigmaTel reference board */
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1598 "DFI LanParty", STAC_92HD83XXX_REF),
1599 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1600 "DFI LanParty", STAC_92HD83XXX_REF),
1601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1602 "unknown Dell", STAC_DELL_S14),
1606 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1607 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1608 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1609 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1613 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1614 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1615 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1616 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1620 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1621 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1622 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1623 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1627 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1628 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1629 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1630 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1634 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1635 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1636 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1637 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1638 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1639 [STAC_HP_M4] = NULL,
1640 [STAC_HP_DV5] = NULL,
1641 [STAC_HP_HDX] = NULL,
1642 [STAC_HP_DV4_1222NR] = NULL,
1645 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1646 [STAC_92HD71BXX_AUTO] = "auto",
1647 [STAC_92HD71BXX_REF] = "ref",
1648 [STAC_DELL_M4_1] = "dell-m4-1",
1649 [STAC_DELL_M4_2] = "dell-m4-2",
1650 [STAC_DELL_M4_3] = "dell-m4-3",
1651 [STAC_HP_M4] = "hp-m4",
1652 [STAC_HP_DV5] = "hp-dv5",
1653 [STAC_HP_HDX] = "hp-hdx",
1654 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1657 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1658 /* SigmaTel reference board */
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1660 "DFI LanParty", STAC_92HD71BXX_REF),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1662 "DFI LanParty", STAC_92HD71BXX_REF),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1664 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1665 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1667 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1668 "HP dv4-7", STAC_HP_DV5),
1669 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1670 "HP dv4-7", STAC_HP_DV5),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1672 "HP HDX", STAC_HP_HDX), /* HDX18 */
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1674 "HP mini 1000", STAC_HP_M4),
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1676 "HP HDX", STAC_HP_HDX), /* HDX16 */
1677 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1680 "unknown Dell", STAC_DELL_M4_1),
1681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1682 "unknown Dell", STAC_DELL_M4_1),
1683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1684 "unknown Dell", STAC_DELL_M4_1),
1685 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1686 "unknown Dell", STAC_DELL_M4_1),
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1688 "unknown Dell", STAC_DELL_M4_1),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1690 "unknown Dell", STAC_DELL_M4_1),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1692 "unknown Dell", STAC_DELL_M4_1),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1694 "unknown Dell", STAC_DELL_M4_2),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1696 "unknown Dell", STAC_DELL_M4_2),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1698 "unknown Dell", STAC_DELL_M4_2),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1700 "unknown Dell", STAC_DELL_M4_2),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1702 "unknown Dell", STAC_DELL_M4_3),
1706 static unsigned int ref922x_pin_configs[10] = {
1707 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1708 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1709 0x40000100, 0x40000100,
1713 STAC 922X pin configs for
1720 static unsigned int dell_922x_d81_pin_configs[10] = {
1721 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1722 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1723 0x01813122, 0x400001f2,
1727 STAC 922X pin configs for
1731 static unsigned int dell_922x_d82_pin_configs[10] = {
1732 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1733 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1734 0x01813122, 0x400001f1,
1738 STAC 922X pin configs for
1741 static unsigned int dell_922x_m81_pin_configs[10] = {
1742 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1743 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1744 0x40C003f1, 0x405003f0,
1748 STAC 9221 A1 pin configs for
1749 102801D7 (Dell XPS M1210)
1751 static unsigned int dell_922x_m82_pin_configs[10] = {
1752 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1753 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1754 0x508003f3, 0x405003f4,
1757 static unsigned int d945gtp3_pin_configs[10] = {
1758 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1759 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1760 0x02a19120, 0x40000100,
1763 static unsigned int d945gtp5_pin_configs[10] = {
1764 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1765 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1766 0x02a19320, 0x40000100,
1769 static unsigned int intel_mac_v1_pin_configs[10] = {
1770 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1771 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1772 0x400000fc, 0x400000fb,
1775 static unsigned int intel_mac_v2_pin_configs[10] = {
1776 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1777 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1778 0x400000fc, 0x400000fb,
1781 static unsigned int intel_mac_v3_pin_configs[10] = {
1782 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1783 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1784 0x400000fc, 0x400000fb,
1787 static unsigned int intel_mac_v4_pin_configs[10] = {
1788 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1789 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1790 0x400000fc, 0x400000fb,
1793 static unsigned int intel_mac_v5_pin_configs[10] = {
1794 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1795 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1796 0x400000fc, 0x400000fb,
1799 static unsigned int ecs202_pin_configs[10] = {
1800 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1801 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1802 0x9037012e, 0x40e000f2,
1805 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1806 [STAC_D945_REF] = ref922x_pin_configs,
1807 [STAC_D945GTP3] = d945gtp3_pin_configs,
1808 [STAC_D945GTP5] = d945gtp5_pin_configs,
1809 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1810 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1811 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1812 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1813 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1814 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1815 /* for backward compatibility */
1816 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1817 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1818 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1819 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1820 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1821 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1822 [STAC_ECS_202] = ecs202_pin_configs,
1823 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1824 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1825 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1826 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1829 static const char *stac922x_models[STAC_922X_MODELS] = {
1830 [STAC_922X_AUTO] = "auto",
1831 [STAC_D945_REF] = "ref",
1832 [STAC_D945GTP5] = "5stack",
1833 [STAC_D945GTP3] = "3stack",
1834 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1835 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1836 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1837 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1838 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1839 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1840 /* for backward compatibility */
1841 [STAC_MACMINI] = "macmini",
1842 [STAC_MACBOOK] = "macbook",
1843 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1844 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1845 [STAC_IMAC_INTEL] = "imac-intel",
1846 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1847 [STAC_ECS_202] = "ecs202",
1848 [STAC_922X_DELL_D81] = "dell-d81",
1849 [STAC_922X_DELL_D82] = "dell-d82",
1850 [STAC_922X_DELL_M81] = "dell-m81",
1851 [STAC_922X_DELL_M82] = "dell-m82",
1854 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1855 /* SigmaTel reference board */
1856 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1857 "DFI LanParty", STAC_D945_REF),
1858 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1859 "DFI LanParty", STAC_D945_REF),
1860 /* Intel 945G based systems */
1861 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1862 "Intel D945G", STAC_D945GTP3),
1863 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1864 "Intel D945G", STAC_D945GTP3),
1865 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1866 "Intel D945G", STAC_D945GTP3),
1867 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1868 "Intel D945G", STAC_D945GTP3),
1869 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1870 "Intel D945G", STAC_D945GTP3),
1871 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1872 "Intel D945G", STAC_D945GTP3),
1873 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1874 "Intel D945G", STAC_D945GTP3),
1875 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1876 "Intel D945G", STAC_D945GTP3),
1877 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1878 "Intel D945G", STAC_D945GTP3),
1879 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1880 "Intel D945G", STAC_D945GTP3),
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1882 "Intel D945G", STAC_D945GTP3),
1883 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1884 "Intel D945G", STAC_D945GTP3),
1885 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1886 "Intel D945G", STAC_D945GTP3),
1887 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1888 "Intel D945G", STAC_D945GTP3),
1889 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1890 "Intel D945G", STAC_D945GTP3),
1891 /* Intel D945G 5-stack systems */
1892 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1893 "Intel D945G", STAC_D945GTP5),
1894 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1895 "Intel D945G", STAC_D945GTP5),
1896 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1897 "Intel D945G", STAC_D945GTP5),
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1899 "Intel D945G", STAC_D945GTP5),
1900 /* Intel 945P based systems */
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1902 "Intel D945P", STAC_D945GTP3),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1904 "Intel D945P", STAC_D945GTP3),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1906 "Intel D945P", STAC_D945GTP3),
1907 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1908 "Intel D945P", STAC_D945GTP3),
1909 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1910 "Intel D945P", STAC_D945GTP3),
1911 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1912 "Intel D945P", STAC_D945GTP5),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
1915 "Intel D945", STAC_D945_REF),
1917 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1918 SND_PCI_QUIRK(0x8384, 0x7680,
1919 "Mac", STAC_INTEL_MAC_AUTO),
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1922 "unknown Dell", STAC_922X_DELL_D81),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1924 "unknown Dell", STAC_922X_DELL_D81),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1926 "unknown Dell", STAC_922X_DELL_D81),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1928 "unknown Dell", STAC_922X_DELL_D82),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1930 "unknown Dell", STAC_922X_DELL_M81),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1932 "unknown Dell", STAC_922X_DELL_D82),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1934 "unknown Dell", STAC_922X_DELL_D81),
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1936 "unknown Dell", STAC_922X_DELL_D81),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1938 "Dell XPS M1210", STAC_922X_DELL_M82),
1939 /* ECS/PC Chips boards */
1940 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
1941 "ECS/PC chips", STAC_ECS_202),
1945 static unsigned int ref927x_pin_configs[14] = {
1946 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1947 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1948 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1949 0x01c42190, 0x40000100,
1952 static unsigned int d965_3st_pin_configs[14] = {
1953 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1954 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1955 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1956 0x40000100, 0x40000100
1959 static unsigned int d965_5st_pin_configs[14] = {
1960 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1961 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1962 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1963 0x40000100, 0x40000100
1966 static unsigned int d965_5st_no_fp_pin_configs[14] = {
1967 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
1968 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1969 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1970 0x40000100, 0x40000100
1973 static unsigned int dell_3st_pin_configs[14] = {
1974 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1975 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1976 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1977 0x40c003fc, 0x40000100
1980 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1981 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
1982 [STAC_D965_REF] = ref927x_pin_configs,
1983 [STAC_D965_3ST] = d965_3st_pin_configs,
1984 [STAC_D965_5ST] = d965_5st_pin_configs,
1985 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
1986 [STAC_DELL_3ST] = dell_3st_pin_configs,
1987 [STAC_DELL_BIOS] = NULL,
1990 static const char *stac927x_models[STAC_927X_MODELS] = {
1991 [STAC_927X_AUTO] = "auto",
1992 [STAC_D965_REF_NO_JD] = "ref-no-jd",
1993 [STAC_D965_REF] = "ref",
1994 [STAC_D965_3ST] = "3stack",
1995 [STAC_D965_5ST] = "5stack",
1996 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
1997 [STAC_DELL_3ST] = "dell-3stack",
1998 [STAC_DELL_BIOS] = "dell-bios",
2001 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2002 /* SigmaTel reference board */
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2004 "DFI LanParty", STAC_D965_REF),
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2006 "DFI LanParty", STAC_D965_REF),
2007 /* Intel 946 based systems */
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2009 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2010 /* 965 based 3 stack systems */
2011 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2012 "Intel D965", STAC_D965_3ST),
2013 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2014 "Intel D965", STAC_D965_3ST),
2015 /* Dell 3 stack systems */
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2020 /* Dell 3 stack systems with verb table in BIOS */
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2029 /* 965 based 5 stack systems */
2030 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2031 "Intel D965", STAC_D965_5ST),
2032 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2033 "Intel D965", STAC_D965_5ST),
2037 static unsigned int ref9205_pin_configs[12] = {
2038 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2039 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2040 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2044 STAC 9205 pin configs for
2051 10280228 (Dell Vostro 1500)
2053 static unsigned int dell_9205_m42_pin_configs[12] = {
2054 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2055 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2056 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2060 STAC 9205 pin configs for
2064 102801FF (Dell Precision M4300)
2069 static unsigned int dell_9205_m43_pin_configs[12] = {
2070 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2071 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2072 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2075 static unsigned int dell_9205_m44_pin_configs[12] = {
2076 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2077 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2078 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2081 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2082 [STAC_9205_REF] = ref9205_pin_configs,
2083 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2084 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2085 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2086 [STAC_9205_EAPD] = NULL,
2089 static const char *stac9205_models[STAC_9205_MODELS] = {
2090 [STAC_9205_AUTO] = "auto",
2091 [STAC_9205_REF] = "ref",
2092 [STAC_9205_DELL_M42] = "dell-m42",
2093 [STAC_9205_DELL_M43] = "dell-m43",
2094 [STAC_9205_DELL_M44] = "dell-m44",
2095 [STAC_9205_EAPD] = "eapd",
2098 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2099 /* SigmaTel reference board */
2100 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2101 "DFI LanParty", STAC_9205_REF),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2103 "SigmaTel", STAC_9205_REF),
2104 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2105 "DFI LanParty", STAC_9205_REF),
2107 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2108 "unknown Dell", STAC_9205_DELL_M42),
2109 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2110 "unknown Dell", STAC_9205_DELL_M42),
2111 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2112 "Dell Precision", STAC_9205_DELL_M43),
2113 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2114 "Dell Precision", STAC_9205_DELL_M43),
2115 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2116 "Dell Precision", STAC_9205_DELL_M43),
2117 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2118 "unknown Dell", STAC_9205_DELL_M42),
2119 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2120 "unknown Dell", STAC_9205_DELL_M42),
2121 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2122 "Dell Precision", STAC_9205_DELL_M43),
2123 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2124 "Dell Precision M4300", STAC_9205_DELL_M43),
2125 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2126 "unknown Dell", STAC_9205_DELL_M42),
2127 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2128 "Dell Precision", STAC_9205_DELL_M43),
2129 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2130 "Dell Precision", STAC_9205_DELL_M43),
2131 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2132 "Dell Precision", STAC_9205_DELL_M43),
2133 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2134 "Dell Inspiron", STAC_9205_DELL_M44),
2135 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2136 "Dell Vostro 1500", STAC_9205_DELL_M42),
2138 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2139 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2143 static void stac92xx_set_config_regs(struct hda_codec *codec,
2144 unsigned int *pincfgs)
2147 struct sigmatel_spec *spec = codec->spec;
2152 for (i = 0; i < spec->num_pins; i++)
2153 if (spec->pin_nids[i] && pincfgs[i])
2154 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2159 * Analog playback callbacks
2161 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2162 struct hda_codec *codec,
2163 struct snd_pcm_substream *substream)
2165 struct sigmatel_spec *spec = codec->spec;
2166 if (spec->stream_delay)
2167 msleep(spec->stream_delay);
2168 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2172 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2173 struct hda_codec *codec,
2174 unsigned int stream_tag,
2175 unsigned int format,
2176 struct snd_pcm_substream *substream)
2178 struct sigmatel_spec *spec = codec->spec;
2179 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2182 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2183 struct hda_codec *codec,
2184 struct snd_pcm_substream *substream)
2186 struct sigmatel_spec *spec = codec->spec;
2187 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2191 * Digital playback callbacks
2193 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2194 struct hda_codec *codec,
2195 struct snd_pcm_substream *substream)
2197 struct sigmatel_spec *spec = codec->spec;
2198 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2201 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2202 struct hda_codec *codec,
2203 struct snd_pcm_substream *substream)
2205 struct sigmatel_spec *spec = codec->spec;
2206 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2209 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2210 struct hda_codec *codec,
2211 unsigned int stream_tag,
2212 unsigned int format,
2213 struct snd_pcm_substream *substream)
2215 struct sigmatel_spec *spec = codec->spec;
2216 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2217 stream_tag, format, substream);
2220 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2221 struct hda_codec *codec,
2222 struct snd_pcm_substream *substream)
2224 struct sigmatel_spec *spec = codec->spec;
2225 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2230 * Analog capture callbacks
2232 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2233 struct hda_codec *codec,
2234 unsigned int stream_tag,
2235 unsigned int format,
2236 struct snd_pcm_substream *substream)
2238 struct sigmatel_spec *spec = codec->spec;
2239 hda_nid_t nid = spec->adc_nids[substream->number];
2241 if (spec->powerdown_adcs) {
2243 snd_hda_codec_write(codec, nid, 0,
2244 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2246 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2250 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2251 struct hda_codec *codec,
2252 struct snd_pcm_substream *substream)
2254 struct sigmatel_spec *spec = codec->spec;
2255 hda_nid_t nid = spec->adc_nids[substream->number];
2257 snd_hda_codec_cleanup_stream(codec, nid);
2258 if (spec->powerdown_adcs)
2259 snd_hda_codec_write(codec, nid, 0,
2260 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2264 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2268 /* NID is set in stac92xx_build_pcms */
2270 .open = stac92xx_dig_playback_pcm_open,
2271 .close = stac92xx_dig_playback_pcm_close,
2272 .prepare = stac92xx_dig_playback_pcm_prepare,
2273 .cleanup = stac92xx_dig_playback_pcm_cleanup
2277 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2281 /* NID is set in stac92xx_build_pcms */
2284 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2288 .nid = 0x02, /* NID to query formats and rates */
2290 .open = stac92xx_playback_pcm_open,
2291 .prepare = stac92xx_playback_pcm_prepare,
2292 .cleanup = stac92xx_playback_pcm_cleanup
2296 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2300 .nid = 0x06, /* NID to query formats and rates */
2302 .open = stac92xx_playback_pcm_open,
2303 .prepare = stac92xx_playback_pcm_prepare,
2304 .cleanup = stac92xx_playback_pcm_cleanup
2308 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2311 /* NID + .substreams is set in stac92xx_build_pcms */
2313 .prepare = stac92xx_capture_pcm_prepare,
2314 .cleanup = stac92xx_capture_pcm_cleanup
2318 static int stac92xx_build_pcms(struct hda_codec *codec)
2320 struct sigmatel_spec *spec = codec->spec;
2321 struct hda_pcm *info = spec->pcm_rec;
2323 codec->num_pcms = 1;
2324 codec->pcm_info = info;
2326 info->name = "STAC92xx Analog";
2327 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2328 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2329 spec->multiout.dac_nids[0];
2330 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2331 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2332 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2334 if (spec->alt_switch) {
2337 info->name = "STAC92xx Analog Alt";
2338 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2341 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2344 info->name = "STAC92xx Digital";
2345 info->pcm_type = spec->autocfg.dig_out_type[0];
2346 if (spec->multiout.dig_out_nid) {
2347 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2348 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2350 if (spec->dig_in_nid) {
2351 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2352 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2359 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2362 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2363 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2364 if (pincap & AC_PINCAP_VREF_100)
2365 return AC_PINCTL_VREF_100;
2366 if (pincap & AC_PINCAP_VREF_80)
2367 return AC_PINCTL_VREF_80;
2368 if (pincap & AC_PINCAP_VREF_50)
2369 return AC_PINCTL_VREF_50;
2370 if (pincap & AC_PINCAP_VREF_GRD)
2371 return AC_PINCTL_VREF_GRD;
2375 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2378 snd_hda_codec_write_cache(codec, nid, 0,
2379 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2382 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2384 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2385 struct snd_ctl_elem_value *ucontrol)
2387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2388 struct sigmatel_spec *spec = codec->spec;
2390 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2394 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2396 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2397 struct snd_ctl_elem_value *ucontrol)
2399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2400 struct sigmatel_spec *spec = codec->spec;
2401 int nid = kcontrol->private_value;
2403 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2405 /* check to be sure that the ports are upto date with
2408 stac_issue_unsol_event(codec, nid);
2413 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2414 struct snd_ctl_elem_info *uinfo)
2417 static char *texts[] = {
2418 "Mic In", "Line In", "Line Out"
2421 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2422 struct sigmatel_spec *spec = codec->spec;
2423 hda_nid_t nid = kcontrol->private_value;
2425 if (nid == spec->mic_switch || nid == spec->line_switch)
2430 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2431 uinfo->value.enumerated.items = i;
2433 if (uinfo->value.enumerated.item >= i)
2434 uinfo->value.enumerated.item = i-1;
2435 strcpy(uinfo->value.enumerated.name,
2436 texts[uinfo->value.enumerated.item]);
2441 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2442 struct snd_ctl_elem_value *ucontrol)
2444 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2445 hda_nid_t nid = kcontrol->private_value;
2446 unsigned int vref = stac92xx_vref_get(codec, nid);
2448 if (vref == stac92xx_get_default_vref(codec, nid))
2449 ucontrol->value.enumerated.item[0] = 0;
2450 else if (vref == AC_PINCTL_VREF_GRD)
2451 ucontrol->value.enumerated.item[0] = 1;
2452 else if (vref == AC_PINCTL_VREF_HIZ)
2453 ucontrol->value.enumerated.item[0] = 2;
2458 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2459 struct snd_ctl_elem_value *ucontrol)
2461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2462 unsigned int new_vref = 0;
2464 hda_nid_t nid = kcontrol->private_value;
2466 if (ucontrol->value.enumerated.item[0] == 0)
2467 new_vref = stac92xx_get_default_vref(codec, nid);
2468 else if (ucontrol->value.enumerated.item[0] == 1)
2469 new_vref = AC_PINCTL_VREF_GRD;
2470 else if (ucontrol->value.enumerated.item[0] == 2)
2471 new_vref = AC_PINCTL_VREF_HIZ;
2475 if (new_vref != stac92xx_vref_get(codec, nid)) {
2476 error = stac92xx_vref_set(codec, nid, new_vref);
2483 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2484 struct snd_ctl_elem_info *uinfo)
2486 static char *texts[2];
2487 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2488 struct sigmatel_spec *spec = codec->spec;
2490 if (kcontrol->private_value == spec->line_switch)
2491 texts[0] = "Line In";
2493 texts[0] = "Mic In";
2494 texts[1] = "Line Out";
2495 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2496 uinfo->value.enumerated.items = 2;
2499 if (uinfo->value.enumerated.item >= 2)
2500 uinfo->value.enumerated.item = 1;
2501 strcpy(uinfo->value.enumerated.name,
2502 texts[uinfo->value.enumerated.item]);
2507 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2509 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2510 struct sigmatel_spec *spec = codec->spec;
2511 hda_nid_t nid = kcontrol->private_value;
2512 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2514 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2518 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2520 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2521 struct sigmatel_spec *spec = codec->spec;
2522 hda_nid_t nid = kcontrol->private_value;
2523 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2524 unsigned short val = !!ucontrol->value.enumerated.item[0];
2526 spec->io_switch[io_idx] = val;
2529 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2531 unsigned int pinctl = AC_PINCTL_IN_EN;
2532 if (io_idx) /* set VREF for mic */
2533 pinctl |= stac92xx_get_default_vref(codec, nid);
2534 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2537 /* check the auto-mute again: we need to mute/unmute the speaker
2538 * appropriately according to the pin direction
2540 if (spec->hp_detect)
2541 stac_issue_unsol_event(codec, nid);
2546 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2548 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2549 struct snd_ctl_elem_value *ucontrol)
2551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2552 struct sigmatel_spec *spec = codec->spec;
2554 ucontrol->value.integer.value[0] = spec->clfe_swap;
2558 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2559 struct snd_ctl_elem_value *ucontrol)
2561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2562 struct sigmatel_spec *spec = codec->spec;
2563 hda_nid_t nid = kcontrol->private_value & 0xff;
2564 unsigned int val = !!ucontrol->value.integer.value[0];
2566 if (spec->clfe_swap == val)
2569 spec->clfe_swap = val;
2571 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2572 spec->clfe_swap ? 0x4 : 0x0);
2577 #define STAC_CODEC_HP_SWITCH(xname) \
2578 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2581 .info = stac92xx_hp_switch_info, \
2582 .get = stac92xx_hp_switch_get, \
2583 .put = stac92xx_hp_switch_put, \
2586 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2587 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2590 .info = stac92xx_io_switch_info, \
2591 .get = stac92xx_io_switch_get, \
2592 .put = stac92xx_io_switch_put, \
2593 .private_value = xpval, \
2596 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2597 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2600 .info = stac92xx_clfe_switch_info, \
2601 .get = stac92xx_clfe_switch_get, \
2602 .put = stac92xx_clfe_switch_put, \
2603 .private_value = xpval, \
2607 STAC_CTL_WIDGET_VOL,
2608 STAC_CTL_WIDGET_MUTE,
2609 STAC_CTL_WIDGET_MONO_MUX,
2610 STAC_CTL_WIDGET_HP_SWITCH,
2611 STAC_CTL_WIDGET_IO_SWITCH,
2612 STAC_CTL_WIDGET_CLFE_SWITCH,
2613 STAC_CTL_WIDGET_DC_BIAS
2616 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2617 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2618 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2620 STAC_CODEC_HP_SWITCH(NULL),
2621 STAC_CODEC_IO_SWITCH(NULL, 0),
2622 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2623 DC_BIAS(NULL, 0, 0),
2626 /* add dynamic controls */
2627 static struct snd_kcontrol_new *
2628 stac_control_new(struct sigmatel_spec *spec,
2629 struct snd_kcontrol_new *ktemp,
2632 struct snd_kcontrol_new *knew;
2634 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2635 knew = snd_array_new(&spec->kctls);
2639 knew->name = kstrdup(name, GFP_KERNEL);
2642 memset(knew, 0, sizeof(*knew));
2643 spec->kctls.alloced--;
2649 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2650 struct snd_kcontrol_new *ktemp,
2651 int idx, const char *name,
2654 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2658 knew->private_value = val;
2662 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2663 int type, int idx, const char *name,
2666 return stac92xx_add_control_temp(spec,
2667 &stac92xx_control_templates[type],
2672 /* add dynamic controls */
2673 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2674 const char *name, unsigned long val)
2676 return stac92xx_add_control_idx(spec, type, 0, name, val);
2679 static struct snd_kcontrol_new stac_input_src_temp = {
2680 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2681 .name = "Input Source",
2682 .info = stac92xx_mux_enum_info,
2683 .get = stac92xx_mux_enum_get,
2684 .put = stac92xx_mux_enum_put,
2687 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2688 hda_nid_t nid, int idx)
2690 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2692 struct sigmatel_spec *spec = codec->spec;
2695 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2696 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2697 && nid == spec->line_switch)
2698 control = STAC_CTL_WIDGET_IO_SWITCH;
2699 else if (snd_hda_query_pin_caps(codec, nid)
2700 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2701 control = STAC_CTL_WIDGET_DC_BIAS;
2702 else if (nid == spec->mic_switch)
2703 control = STAC_CTL_WIDGET_IO_SWITCH;
2707 strcpy(name, auto_pin_cfg_labels[idx]);
2708 return stac92xx_add_control(codec->spec, control,
2709 strcat(name, " Jack Mode"), nid);
2715 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2717 struct snd_kcontrol_new *knew;
2718 struct hda_input_mux *imux = &spec->private_imux;
2721 return 0; /* no need for input source */
2722 if (!spec->num_adcs || imux->num_items <= 1)
2723 return 0; /* no need for input source control */
2724 knew = stac_control_new(spec, &stac_input_src_temp,
2725 stac_input_src_temp.name);
2728 knew->count = spec->num_adcs;
2732 /* check whether the line-input can be used as line-out */
2733 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2735 struct sigmatel_spec *spec = codec->spec;
2736 struct auto_pin_cfg *cfg = &spec->autocfg;
2738 unsigned int pincap;
2740 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2742 nid = cfg->input_pins[AUTO_PIN_LINE];
2743 pincap = snd_hda_query_pin_caps(codec, nid);
2744 if (pincap & AC_PINCAP_OUT)
2749 /* check whether the mic-input can be used as line-out */
2750 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2752 struct sigmatel_spec *spec = codec->spec;
2753 struct auto_pin_cfg *cfg = &spec->autocfg;
2754 unsigned int def_conf, pincap;
2755 unsigned int mic_pin;
2757 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2759 mic_pin = AUTO_PIN_MIC;
2761 hda_nid_t nid = cfg->input_pins[mic_pin];
2762 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2763 /* some laptops have an internal analog microphone
2764 * which can't be used as a output */
2765 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2766 pincap = snd_hda_query_pin_caps(codec, nid);
2767 if (pincap & AC_PINCAP_OUT)
2770 if (mic_pin == AUTO_PIN_MIC)
2771 mic_pin = AUTO_PIN_FRONT_MIC;
2778 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2782 for (i = 0; i < spec->multiout.num_dacs; i++) {
2783 if (spec->multiout.dac_nids[i] == nid)
2790 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2793 if (is_in_dac_nids(spec, nid))
2795 for (i = 0; i < spec->autocfg.hp_outs; i++)
2796 if (spec->hp_dacs[i] == nid)
2798 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2799 if (spec->speaker_dacs[i] == nid)
2804 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2806 struct sigmatel_spec *spec = codec->spec;
2808 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2809 unsigned int wcaps, wtype;
2811 conn_len = snd_hda_get_connections(codec, nid, conn,
2812 HDA_MAX_CONNECTIONS);
2813 for (j = 0; j < conn_len; j++) {
2814 wcaps = get_wcaps(codec, conn[j]);
2815 wtype = get_wcaps_type(wcaps);
2816 /* we check only analog outputs */
2817 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2819 /* if this route has a free DAC, assign it */
2820 if (!check_all_dac_nids(spec, conn[j])) {
2822 /* select this DAC in the pin's input mux */
2823 snd_hda_codec_write_cache(codec, nid, 0,
2824 AC_VERB_SET_CONNECT_SEL, j);
2829 /* if all DACs are already assigned, connect to the primary DAC */
2831 for (j = 0; j < conn_len; j++) {
2832 if (conn[j] == spec->multiout.dac_nids[0]) {
2833 snd_hda_codec_write_cache(codec, nid, 0,
2834 AC_VERB_SET_CONNECT_SEL, j);
2842 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2843 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2846 * Fill in the dac_nids table from the parsed pin configuration
2847 * This function only works when every pin in line_out_pins[]
2848 * contains atleast one DAC in its connection list. Some 92xx
2849 * codecs are not connected directly to a DAC, such as the 9200
2850 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2852 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2854 struct sigmatel_spec *spec = codec->spec;
2855 struct auto_pin_cfg *cfg = &spec->autocfg;
2859 for (i = 0; i < cfg->line_outs; i++) {
2860 nid = cfg->line_out_pins[i];
2861 dac = get_unassigned_dac(codec, nid);
2863 if (spec->multiout.num_dacs > 0) {
2864 /* we have already working output pins,
2865 * so let's drop the broken ones again
2867 cfg->line_outs = spec->multiout.num_dacs;
2870 /* error out, no available DAC found */
2872 "%s: No available DAC for pin 0x%x\n",
2876 add_spec_dacs(spec, dac);
2879 for (i = 0; i < cfg->hp_outs; i++) {
2880 nid = cfg->hp_pins[i];
2881 dac = get_unassigned_dac(codec, nid);
2883 if (!spec->multiout.hp_nid)
2884 spec->multiout.hp_nid = dac;
2886 add_spec_extra_dacs(spec, dac);
2888 spec->hp_dacs[i] = dac;
2891 for (i = 0; i < cfg->speaker_outs; i++) {
2892 nid = cfg->speaker_pins[i];
2893 dac = get_unassigned_dac(codec, nid);
2895 add_spec_extra_dacs(spec, dac);
2896 spec->speaker_dacs[i] = dac;
2899 /* add line-in as output */
2900 nid = check_line_out_switch(codec);
2902 dac = get_unassigned_dac(codec, nid);
2904 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2905 nid, cfg->line_outs);
2906 cfg->line_out_pins[cfg->line_outs] = nid;
2908 spec->line_switch = nid;
2909 add_spec_dacs(spec, dac);
2912 /* add mic as output */
2913 nid = check_mic_out_switch(codec);
2915 dac = get_unassigned_dac(codec, nid);
2917 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2918 nid, cfg->line_outs);
2919 cfg->line_out_pins[cfg->line_outs] = nid;
2921 spec->mic_switch = nid;
2922 add_spec_dacs(spec, dac);
2926 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2927 spec->multiout.num_dacs,
2928 spec->multiout.dac_nids[0],
2929 spec->multiout.dac_nids[1],
2930 spec->multiout.dac_nids[2],
2931 spec->multiout.dac_nids[3],
2932 spec->multiout.dac_nids[4]);
2937 /* create volume control/switch for the given prefx type */
2938 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
2939 int idx, hda_nid_t nid, int chs)
2941 struct sigmatel_spec *spec = codec->spec;
2945 if (!spec->check_volume_offset) {
2946 unsigned int caps, step, nums, db_scale;
2947 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2948 step = (caps & AC_AMPCAP_STEP_SIZE) >>
2949 AC_AMPCAP_STEP_SIZE_SHIFT;
2950 step = (step + 1) * 25; /* in .01dB unit */
2951 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
2952 AC_AMPCAP_NUM_STEPS_SHIFT;
2953 db_scale = nums * step;
2954 /* if dB scale is over -64dB, and finer enough,
2955 * let's reduce it to half
2957 if (db_scale > 6400 && nums >= 0x1f)
2958 spec->volume_offset = nums / 2;
2959 spec->check_volume_offset = 1;
2962 sprintf(name, "%s Playback Volume", pfx);
2963 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
2964 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
2965 spec->volume_offset));
2968 sprintf(name, "%s Playback Switch", pfx);
2969 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
2970 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2976 #define create_controls(codec, pfx, nid, chs) \
2977 create_controls_idx(codec, pfx, 0, nid, chs)
2979 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2981 if (spec->multiout.num_dacs > 4) {
2982 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2985 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2986 spec->multiout.num_dacs++;
2991 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2994 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
2995 if (!spec->multiout.extra_out_nid[i]) {
2996 spec->multiout.extra_out_nid[i] = nid;
3000 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3004 /* Create output controls
3005 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3007 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3008 const hda_nid_t *pins,
3009 const hda_nid_t *dac_nids,
3012 struct sigmatel_spec *spec = codec->spec;
3013 static const char *chname[4] = {
3014 "Front", "Surround", NULL /*CLFE*/, "Side"
3018 unsigned int wid_caps;
3020 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3021 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3022 wid_caps = get_wcaps(codec, pins[i]);
3023 if (wid_caps & AC_WCAP_UNSOL_CAP)
3024 spec->hp_detect = 1;
3029 if (type != AUTO_PIN_HP_OUT && i == 2) {
3031 err = create_controls(codec, "Center", nid, 1);
3034 err = create_controls(codec, "LFE", nid, 2);
3038 wid_caps = get_wcaps(codec, nid);
3040 if (wid_caps & AC_WCAP_LR_SWAP) {
3041 err = stac92xx_add_control(spec,
3042 STAC_CTL_WIDGET_CLFE_SWITCH,
3043 "Swap Center/LFE Playback Switch", nid);
3053 case AUTO_PIN_HP_OUT:
3057 case AUTO_PIN_SPEAKER_OUT:
3066 err = create_controls_idx(codec, name, idx, nid, 3);
3074 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3075 unsigned long sw, int idx)
3078 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3079 "Capture Volume", vol);
3082 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3083 "Capture Switch", sw);
3089 /* add playback controls from the parsed DAC table */
3090 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3091 const struct auto_pin_cfg *cfg)
3093 struct sigmatel_spec *spec = codec->spec;
3098 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3099 spec->multiout.dac_nids,
3100 cfg->line_out_type);
3104 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3105 err = stac92xx_add_control(spec,
3106 STAC_CTL_WIDGET_HP_SWITCH,
3107 "Headphone as Line Out Switch",
3108 cfg->hp_pins[cfg->hp_outs - 1]);
3113 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3114 nid = cfg->input_pins[idx];
3116 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3125 /* add playback controls for Speaker and HP outputs */
3126 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3127 struct auto_pin_cfg *cfg)
3129 struct sigmatel_spec *spec = codec->spec;
3132 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3133 spec->hp_dacs, AUTO_PIN_HP_OUT);
3137 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3138 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3145 /* labels for mono mux outputs */
3146 static const char *stac92xx_mono_labels[4] = {
3147 "DAC0", "DAC1", "Mixer", "DAC2"
3150 /* create mono mux for mono out on capable codecs */
3151 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3153 struct sigmatel_spec *spec = codec->spec;
3154 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3156 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3158 num_cons = snd_hda_get_connections(codec,
3161 HDA_MAX_NUM_INPUTS);
3162 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3165 for (i = 0; i < num_cons; i++) {
3166 mono_mux->items[mono_mux->num_items].label =
3167 stac92xx_mono_labels[i];
3168 mono_mux->items[mono_mux->num_items].index = i;
3169 mono_mux->num_items++;
3172 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3173 "Mono Mux", spec->mono_nid);
3176 /* create PC beep volume controls */
3177 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3180 struct sigmatel_spec *spec = codec->spec;
3181 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3184 /* check for mute support for the the amp */
3185 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3186 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3187 "PC Beep Playback Switch",
3188 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3193 /* check to see if there is volume support for the amp */
3194 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3195 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3196 "PC Beep Playback Volume",
3197 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3204 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3205 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3207 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3208 struct snd_ctl_elem_value *ucontrol)
3210 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3211 ucontrol->value.integer.value[0] = codec->beep->enabled;
3215 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3216 struct snd_ctl_elem_value *ucontrol)
3218 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3219 int enabled = !!ucontrol->value.integer.value[0];
3220 if (codec->beep->enabled != enabled) {
3221 codec->beep->enabled = enabled;
3227 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3228 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3229 .info = stac92xx_dig_beep_switch_info,
3230 .get = stac92xx_dig_beep_switch_get,
3231 .put = stac92xx_dig_beep_switch_put,
3234 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3236 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3237 0, "PC Beep Playback Switch", 0);
3241 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3243 struct sigmatel_spec *spec = codec->spec;
3246 for (i = 0; i < spec->num_muxes; i++) {
3251 nid = spec->mux_nids[i];
3252 wcaps = get_wcaps(codec, nid);
3253 if (!(wcaps & AC_WCAP_OUT_AMP))
3256 /* check whether already the same control was created as
3257 * normal Capture Volume.
3259 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3260 for (j = 0; j < spec->num_caps; j++) {
3261 if (spec->capvols[j] == val)
3264 if (j < spec->num_caps)
3267 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3268 "Mux Capture Volume", val);
3275 static const char *stac92xx_spdif_labels[3] = {
3276 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3279 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3281 struct sigmatel_spec *spec = codec->spec;
3282 struct hda_input_mux *spdif_mux = &spec->private_smux;
3283 const char **labels = spec->spdif_labels;
3285 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3287 num_cons = snd_hda_get_connections(codec,
3290 HDA_MAX_NUM_INPUTS);
3295 labels = stac92xx_spdif_labels;
3297 for (i = 0; i < num_cons; i++) {
3298 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3299 spdif_mux->items[spdif_mux->num_items].index = i;
3300 spdif_mux->num_items++;
3306 /* labels for dmic mux inputs */
3307 static const char *stac92xx_dmic_labels[5] = {
3308 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3309 "Digital Mic 3", "Digital Mic 4"
3312 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
3315 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3318 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3319 for (i = 0; i < nums; i++)
3325 /* create a volume assigned to the given pin (only if supported) */
3326 /* return 1 if the volume control is created */
3327 static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
3328 const char *label, int direction)
3330 unsigned int caps, nums;
3334 if (direction == HDA_OUTPUT)
3335 caps = AC_WCAP_OUT_AMP;
3337 caps = AC_WCAP_IN_AMP;
3338 if (!(get_wcaps(codec, nid) & caps))
3340 caps = query_amp_caps(codec, nid, direction);
3341 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3344 snprintf(name, sizeof(name), "%s Capture Volume", label);
3345 err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name,
3346 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3352 /* create playback/capture controls for input pins on dmic capable codecs */
3353 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3354 const struct auto_pin_cfg *cfg)
3356 struct sigmatel_spec *spec = codec->spec;
3357 struct hda_input_mux *imux = &spec->private_imux;
3358 struct hda_input_mux *dimux = &spec->private_dimux;
3359 int err, i, active_mics;
3360 unsigned int def_conf;
3362 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3363 dimux->items[dimux->num_items].index = 0;
3367 for (i = 0; i < spec->num_dmics; i++) {
3368 /* check the validity: sometimes it's a dead vendor-spec node */
3369 if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i]))
3372 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3373 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
3377 for (i = 0; i < spec->num_dmics; i++) {
3382 nid = spec->dmic_nids[i];
3383 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3385 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3386 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3389 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3393 if (active_mics == 1)
3394 label = "Digital Mic";
3396 label = stac92xx_dmic_labels[dimux->num_items];
3398 err = create_elem_capture_vol(codec, nid, label, HDA_INPUT);
3402 err = create_elem_capture_vol(codec, nid, label,
3408 dimux->items[dimux->num_items].label = label;
3409 dimux->items[dimux->num_items].index = index;
3411 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) {
3412 imux->items[imux->num_items].label = label;
3413 imux->items[imux->num_items].index = index;
3421 static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3422 hda_nid_t *fixed, hda_nid_t *ext)
3428 cfg = snd_hda_codec_get_pincfg(codec, nid);
3429 switch (get_defcfg_connect(cfg)) {
3430 case AC_JACK_PORT_FIXED:
3432 return 1; /* already occupied */
3435 case AC_JACK_PORT_COMPLEX:
3437 return 1; /* already occupied */
3444 static int set_mic_route(struct hda_codec *codec,
3445 struct sigmatel_mic_route *mic,
3448 struct sigmatel_spec *spec = codec->spec;
3449 struct auto_pin_cfg *cfg = &spec->autocfg;
3453 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3454 if (pin == cfg->input_pins[i])
3456 if (i <= AUTO_PIN_FRONT_MIC) {
3459 i = get_connection_index(codec, spec->mux_nids[0], pin);
3463 } else if (spec->dmux_nids) {
3466 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3474 /* return non-zero if the device is for automatic mic switch */
3475 static int stac_check_auto_mic(struct hda_codec *codec)
3477 struct sigmatel_spec *spec = codec->spec;
3478 struct auto_pin_cfg *cfg = &spec->autocfg;
3479 hda_nid_t fixed, ext;
3482 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
3483 if (cfg->input_pins[i])
3484 return 0; /* must be exclusively mics */
3487 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3488 if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
3490 for (i = 0; i < spec->num_dmics; i++)
3491 if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
3495 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
3496 return 0; /* no unsol support */
3497 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3498 set_mic_route(codec, &spec->int_mic, fixed))
3499 return 0; /* something is wrong */
3503 /* create playback/capture controls for input pins */
3504 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3506 struct sigmatel_spec *spec = codec->spec;
3507 struct hda_input_mux *imux = &spec->private_imux;
3510 for (i = 0; i < AUTO_PIN_LAST; i++) {
3511 hda_nid_t nid = cfg->input_pins[i];
3517 for (j = 0; j < spec->num_muxes; j++) {
3518 index = get_connection_index(codec, spec->mux_nids[j],
3526 err = create_elem_capture_vol(codec, nid,
3527 auto_pin_cfg_labels[i],
3532 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3533 imux->items[imux->num_items].index = index;
3536 spec->num_analog_muxes = imux->num_items;
3538 if (imux->num_items) {
3540 * Set the current input for the muxes.
3541 * The STAC9221 has two input muxes with identical source
3542 * NID lists. Hopefully this won't get confused.
3544 for (i = 0; i < spec->num_muxes; i++) {
3545 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3546 AC_VERB_SET_CONNECT_SEL,
3547 imux->items[0].index);
3554 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3556 struct sigmatel_spec *spec = codec->spec;
3559 for (i = 0; i < spec->autocfg.line_outs; i++) {
3560 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3561 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3565 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3567 struct sigmatel_spec *spec = codec->spec;
3570 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3572 pin = spec->autocfg.hp_pins[i];
3573 if (pin) /* connect to front */
3574 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3576 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3578 pin = spec->autocfg.speaker_pins[i];
3579 if (pin) /* connect to front */
3580 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3584 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3586 struct sigmatel_spec *spec = codec->spec;
3590 if ((err = snd_hda_parse_pin_def_config(codec,
3592 spec->dmic_nids)) < 0)
3594 if (! spec->autocfg.line_outs)
3595 return 0; /* can't find valid pin config */
3597 /* If we have no real line-out pin and multiple hp-outs, HPs should
3598 * be set up as multi-channel outputs.
3600 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3601 spec->autocfg.hp_outs > 1) {
3602 /* Copy hp_outs to line_outs, backup line_outs in
3603 * speaker_outs so that the following routines can handle
3604 * HP pins as primary outputs.
3606 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3607 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3608 sizeof(spec->autocfg.line_out_pins));
3609 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3610 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3611 sizeof(spec->autocfg.hp_pins));
3612 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3613 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3614 spec->autocfg.hp_outs = 0;
3617 if (spec->autocfg.mono_out_pin) {
3618 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3619 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3620 u32 caps = query_amp_caps(codec,
3621 spec->autocfg.mono_out_pin, dir);
3622 hda_nid_t conn_list[1];
3624 /* get the mixer node and then the mono mux if it exists */
3625 if (snd_hda_get_connections(codec,
3626 spec->autocfg.mono_out_pin, conn_list, 1) &&
3627 snd_hda_get_connections(codec, conn_list[0],
3628 conn_list, 1) > 0) {
3630 int wcaps = get_wcaps(codec, conn_list[0]);
3631 int wid_type = get_wcaps_type(wcaps);
3632 /* LR swap check, some stac925x have a mux that
3633 * changes the DACs output path instead of the
3636 if (wid_type == AC_WID_AUD_SEL &&
3637 !(wcaps & AC_WCAP_LR_SWAP))
3638 spec->mono_nid = conn_list[0];
3641 hda_nid_t nid = spec->autocfg.mono_out_pin;
3643 /* most mono outs have a least a mute/unmute switch */
3644 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3645 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3646 "Mono Playback Switch",
3647 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3650 /* check for volume support for the amp */
3651 if ((caps & AC_AMPCAP_NUM_STEPS)
3652 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3653 err = stac92xx_add_control(spec,
3654 STAC_CTL_WIDGET_VOL,
3655 "Mono Playback Volume",
3656 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3662 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3666 if (!spec->multiout.num_dacs) {
3667 err = stac92xx_auto_fill_dac_nids(codec);
3670 err = stac92xx_auto_create_multi_out_ctls(codec,
3676 /* setup analog beep controls */
3677 if (spec->anabeep_nid > 0) {
3678 err = stac92xx_auto_create_beep_ctls(codec,
3684 /* setup digital beep controls and input device */
3685 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3686 if (spec->digbeep_nid > 0) {
3687 hda_nid_t nid = spec->digbeep_nid;
3690 err = stac92xx_auto_create_beep_ctls(codec, nid);
3693 err = snd_hda_attach_beep_device(codec, nid);
3696 /* IDT/STAC codecs have linear beep tone parameter */
3697 codec->beep->linear_tone = 1;
3698 /* if no beep switch is available, make its own one */
3699 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3701 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3702 err = stac92xx_beep_switch_ctl(codec);
3709 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3713 /* All output parsing done, now restore the swapped hp pins */
3715 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3716 sizeof(spec->autocfg.hp_pins));
3717 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3718 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3719 spec->autocfg.line_outs = 0;
3722 if (stac_check_auto_mic(codec)) {
3724 /* only one capture for auto-mic */
3727 spec->num_muxes = 1;
3730 for (i = 0; i < spec->num_caps; i++) {
3731 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3732 spec->capsws[i], i);
3737 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3741 if (spec->mono_nid > 0) {
3742 err = stac92xx_auto_create_mono_output_ctls(codec);
3746 if (spec->num_dmics > 0 && !spec->dinput_mux)
3747 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3748 &spec->autocfg)) < 0)
3750 if (spec->num_muxes > 0) {
3751 err = stac92xx_auto_create_mux_input_ctls(codec);
3755 if (spec->num_smuxes > 0) {
3756 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3761 err = stac92xx_add_input_source(spec);
3765 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3766 if (spec->multiout.max_channels > 2)
3767 spec->surr_switch = 1;
3769 if (spec->autocfg.dig_outs)
3770 spec->multiout.dig_out_nid = dig_out;
3771 if (dig_in && spec->autocfg.dig_in_pin)
3772 spec->dig_in_nid = dig_in;
3774 if (spec->kctls.list)
3775 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3777 spec->input_mux = &spec->private_imux;
3778 if (!spec->dinput_mux)
3779 spec->dinput_mux = &spec->private_dimux;
3780 spec->sinput_mux = &spec->private_smux;
3781 spec->mono_mux = &spec->private_mono_mux;
3785 /* add playback controls for HP output */
3786 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3787 struct auto_pin_cfg *cfg)
3789 struct sigmatel_spec *spec = codec->spec;
3790 hda_nid_t pin = cfg->hp_pins[0];
3791 unsigned int wid_caps;
3796 wid_caps = get_wcaps(codec, pin);
3797 if (wid_caps & AC_WCAP_UNSOL_CAP)
3798 spec->hp_detect = 1;
3803 /* add playback controls for LFE output */
3804 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3805 struct auto_pin_cfg *cfg)
3807 struct sigmatel_spec *spec = codec->spec;
3809 hda_nid_t lfe_pin = 0x0;
3813 * search speaker outs and line outs for a mono speaker pin
3814 * with an amp. If one is found, add LFE controls
3817 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3818 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3819 unsigned int wcaps = get_wcaps(codec, pin);
3820 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3821 if (wcaps == AC_WCAP_OUT_AMP)
3822 /* found a mono speaker with an amp, must be lfe */
3826 /* if speaker_outs is 0, then speakers may be in line_outs */
3827 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3828 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3829 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3830 unsigned int defcfg;
3831 defcfg = snd_hda_codec_get_pincfg(codec, pin);
3832 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3833 unsigned int wcaps = get_wcaps(codec, pin);
3834 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3835 if (wcaps == AC_WCAP_OUT_AMP)
3836 /* found a mono speaker with an amp,
3844 err = create_controls(codec, "LFE", lfe_pin, 1);
3852 static int stac9200_parse_auto_config(struct hda_codec *codec)
3854 struct sigmatel_spec *spec = codec->spec;
3857 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3860 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3863 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3866 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3869 if (spec->num_muxes > 0) {
3870 err = stac92xx_auto_create_mux_input_ctls(codec);
3875 err = stac92xx_add_input_source(spec);
3879 if (spec->autocfg.dig_outs)
3880 spec->multiout.dig_out_nid = 0x05;
3881 if (spec->autocfg.dig_in_pin)
3882 spec->dig_in_nid = 0x04;
3884 if (spec->kctls.list)
3885 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3887 spec->input_mux = &spec->private_imux;
3888 spec->dinput_mux = &spec->private_dimux;
3894 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3895 * funky external mute control using GPIO pins.
3898 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3899 unsigned int dir_mask, unsigned int data)
3901 unsigned int gpiostate, gpiomask, gpiodir;
3903 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3904 AC_VERB_GET_GPIO_DATA, 0);
3905 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3907 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3908 AC_VERB_GET_GPIO_MASK, 0);
3911 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3912 AC_VERB_GET_GPIO_DIRECTION, 0);
3913 gpiodir |= dir_mask;
3915 /* Configure GPIOx as CMOS */
3916 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3918 snd_hda_codec_write(codec, codec->afg, 0,
3919 AC_VERB_SET_GPIO_MASK, gpiomask);
3920 snd_hda_codec_read(codec, codec->afg, 0,
3921 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3925 snd_hda_codec_read(codec, codec->afg, 0,
3926 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3929 #ifdef CONFIG_SND_HDA_INPUT_JACK
3930 static void stac92xx_free_jack_priv(struct snd_jack *jack)
3932 struct sigmatel_jack *jacks = jack->private_data;
3938 static int stac92xx_add_jack(struct hda_codec *codec,
3939 hda_nid_t nid, int type)
3941 #ifdef CONFIG_SND_HDA_INPUT_JACK
3942 struct sigmatel_spec *spec = codec->spec;
3943 struct sigmatel_jack *jack;
3944 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
3945 int connectivity = get_defcfg_connect(def_conf);
3949 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3952 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3953 jack = snd_array_new(&spec->jacks);
3959 snprintf(name, sizeof(name), "%s at %s %s Jack",
3960 snd_hda_get_jack_type(def_conf),
3961 snd_hda_get_jack_connectivity(def_conf),
3962 snd_hda_get_jack_location(def_conf));
3964 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
3969 jack->jack->private_data = jack;
3970 jack->jack->private_free = stac92xx_free_jack_priv;
3975 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
3976 unsigned char type, int data)
3978 struct sigmatel_event *event;
3980 snd_array_init(&spec->events, sizeof(*event), 32);
3981 event = snd_array_new(&spec->events);
3986 event->tag = spec->events.used;
3992 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
3995 struct sigmatel_spec *spec = codec->spec;
3996 struct sigmatel_event *event = spec->events.list;
3999 for (i = 0; i < spec->events.used; i++, event++) {
4000 if (event->nid == nid)
4006 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4009 struct sigmatel_spec *spec = codec->spec;
4010 struct sigmatel_event *event = spec->events.list;
4013 for (i = 0; i < spec->events.used; i++, event++) {
4014 if (event->tag == tag)
4020 /* check if given nid is a valid pin and no other events are assigned
4021 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4022 * Otherwise, returns zero.
4024 static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4027 struct sigmatel_event *event;
4030 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4032 event = stac_get_event(codec, nid);
4034 if (event->type != type)
4038 tag = stac_add_event(codec->spec, nid, type, 0);
4042 snd_hda_codec_write_cache(codec, nid, 0,
4043 AC_VERB_SET_UNSOLICITED_ENABLE,
4048 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4051 for (i = 0; i < cfg->hp_outs; i++)
4052 if (cfg->hp_pins[i] == nid)
4053 return 1; /* nid is a HP-Out */
4055 return 0; /* nid is not a HP-Out */
4058 static void stac92xx_power_down(struct hda_codec *codec)
4060 struct sigmatel_spec *spec = codec->spec;
4062 /* power down inactive DACs */
4064 for (dac = spec->dac_list; *dac; dac++)
4065 if (!check_all_dac_nids(spec, *dac))
4066 snd_hda_codec_write(codec, *dac, 0,
4067 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4070 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4073 /* override some hints from the hwdep entry */
4074 static void stac_store_hints(struct hda_codec *codec)
4076 struct sigmatel_spec *spec = codec->spec;
4080 val = snd_hda_get_bool_hint(codec, "hp_detect");
4082 spec->hp_detect = val;
4083 p = snd_hda_get_hint(codec, "gpio_mask");
4085 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4086 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4089 p = snd_hda_get_hint(codec, "gpio_dir");
4091 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4092 p = snd_hda_get_hint(codec, "gpio_data");
4094 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4095 p = snd_hda_get_hint(codec, "eapd_mask");
4097 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4098 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4100 spec->eapd_switch = val;
4103 static int stac92xx_init(struct hda_codec *codec)
4105 struct sigmatel_spec *spec = codec->spec;
4106 struct auto_pin_cfg *cfg = &spec->autocfg;
4110 snd_hda_sequence_write(codec, spec->init);
4112 /* power down adcs initially */
4113 if (spec->powerdown_adcs)
4114 for (i = 0; i < spec->num_adcs; i++)
4115 snd_hda_codec_write(codec,
4116 spec->adc_nids[i], 0,
4117 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4119 /* override some hints */
4120 stac_store_hints(codec);
4123 gpio = spec->gpio_data;
4124 /* turn on EAPD statically when spec->eapd_switch isn't set.
4125 * otherwise, unsol event will turn it on/off dynamically
4127 if (!spec->eapd_switch)
4128 gpio |= spec->eapd_mask;
4129 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4132 if (spec->hp_detect) {
4133 /* Enable unsolicited responses on the HP widget */
4134 for (i = 0; i < cfg->hp_outs; i++) {
4135 hda_nid_t nid = cfg->hp_pins[i];
4136 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4138 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4139 cfg->speaker_outs > 0) {
4140 /* enable pin-detect for line-outs as well */
4141 for (i = 0; i < cfg->line_outs; i++) {
4142 hda_nid_t nid = cfg->line_out_pins[i];
4143 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4147 /* force to enable the first line-out; the others are set up
4150 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4152 /* fake event to set up pins */
4153 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4155 stac92xx_auto_init_multi_out(codec);
4156 stac92xx_auto_init_hp_out(codec);
4157 for (i = 0; i < cfg->hp_outs; i++)
4158 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4160 if (spec->auto_mic) {
4161 /* initialize connection to analog input */
4162 if (spec->dmux_nids)
4163 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4164 AC_VERB_SET_CONNECT_SEL, 0);
4165 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4166 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4168 for (i = 0; i < AUTO_PIN_LAST; i++) {
4169 hda_nid_t nid = cfg->input_pins[i];
4171 unsigned int pinctl, conf;
4172 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4173 /* for mic pins, force to initialize */
4174 pinctl = stac92xx_get_default_vref(codec, nid);
4175 pinctl |= AC_PINCTL_IN_EN;
4176 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4178 pinctl = snd_hda_codec_read(codec, nid, 0,
4179 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4180 /* if PINCTL already set then skip */
4181 /* Also, if both INPUT and OUTPUT are set,
4182 * it must be a BIOS bug; need to override, too
4184 if (!(pinctl & AC_PINCTL_IN_EN) ||
4185 (pinctl & AC_PINCTL_OUT_EN)) {
4186 pinctl &= ~AC_PINCTL_OUT_EN;
4187 pinctl |= AC_PINCTL_IN_EN;
4188 stac92xx_auto_set_pinctl(codec, nid,
4192 conf = snd_hda_codec_get_pincfg(codec, nid);
4193 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4194 if (enable_pin_detect(codec, nid,
4196 stac_issue_unsol_event(codec, nid);
4200 for (i = 0; i < spec->num_dmics; i++)
4201 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4203 if (cfg->dig_out_pins[0])
4204 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4206 if (cfg->dig_in_pin)
4207 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4209 for (i = 0; i < spec->num_pwrs; i++) {
4210 hda_nid_t nid = spec->pwr_nids[i];
4211 int pinctl, def_conf;
4213 /* power on when no jack detection is available */
4214 if (!spec->hp_detect) {
4215 stac_toggle_power_map(codec, nid, 1);
4219 if (is_nid_hp_pin(cfg, nid))
4220 continue; /* already has an unsol event */
4222 pinctl = snd_hda_codec_read(codec, nid, 0,
4223 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4224 /* outputs are only ports capable of power management
4225 * any attempts on powering down a input port cause the
4226 * referenced VREF to act quirky.
4228 if (pinctl & AC_PINCTL_IN_EN) {
4229 stac_toggle_power_map(codec, nid, 1);
4232 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4233 def_conf = get_defcfg_connect(def_conf);
4234 /* skip any ports that don't have jacks since presence
4235 * detection is useless */
4236 if (def_conf != AC_JACK_PORT_COMPLEX) {
4237 if (def_conf != AC_JACK_PORT_NONE)
4238 stac_toggle_power_map(codec, nid, 1);
4241 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4242 stac_issue_unsol_event(codec, nid);
4245 stac92xx_power_down(codec);
4249 static void stac92xx_free_jacks(struct hda_codec *codec)
4251 #ifdef CONFIG_SND_HDA_INPUT_JACK
4252 /* free jack instances manually when clearing/reconfiguring */
4253 struct sigmatel_spec *spec = codec->spec;
4254 if (!codec->bus->shutdown && spec->jacks.list) {
4255 struct sigmatel_jack *jacks = spec->jacks.list;
4257 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4259 snd_device_free(codec->bus->card, jacks->jack);
4262 snd_array_free(&spec->jacks);
4266 static void stac92xx_free_kctls(struct hda_codec *codec)
4268 struct sigmatel_spec *spec = codec->spec;
4270 if (spec->kctls.list) {
4271 struct snd_kcontrol_new *kctl = spec->kctls.list;
4273 for (i = 0; i < spec->kctls.used; i++)
4274 kfree(kctl[i].name);
4276 snd_array_free(&spec->kctls);
4279 static void stac92xx_free(struct hda_codec *codec)
4281 struct sigmatel_spec *spec = codec->spec;
4286 stac92xx_free_jacks(codec);
4287 snd_array_free(&spec->events);
4290 snd_hda_detach_beep_device(codec);
4293 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4296 unsigned int old_ctl, pin_ctl;
4298 pin_ctl = snd_hda_codec_read(codec, nid,
4299 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4301 if (pin_ctl & AC_PINCTL_IN_EN) {
4303 * we need to check the current set-up direction of
4304 * shared input pins since they can be switched via
4305 * "xxx as Output" mixer switch
4307 struct sigmatel_spec *spec = codec->spec;
4308 if (nid == spec->line_switch || nid == spec->mic_switch)
4313 /* if setting pin direction bits, clear the current
4314 direction bits first */
4315 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4316 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4319 if (old_ctl != pin_ctl)
4320 snd_hda_codec_write_cache(codec, nid, 0,
4321 AC_VERB_SET_PIN_WIDGET_CONTROL,
4325 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4328 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4329 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4331 snd_hda_codec_write_cache(codec, nid, 0,
4332 AC_VERB_SET_PIN_WIDGET_CONTROL,
4336 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4340 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
4346 static void stac92xx_line_out_detect(struct hda_codec *codec,
4349 struct sigmatel_spec *spec = codec->spec;
4350 struct auto_pin_cfg *cfg = &spec->autocfg;
4353 for (i = 0; i < cfg->line_outs; i++) {
4356 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4358 unsigned int pinctl;
4359 pinctl = snd_hda_codec_read(codec,
4360 cfg->line_out_pins[i], 0,
4361 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4362 if (pinctl & AC_PINCTL_IN_EN)
4363 presence = 0; /* mic- or line-input */
4368 /* disable speakers */
4369 for (i = 0; i < cfg->speaker_outs; i++)
4370 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4372 if (spec->eapd_mask && spec->eapd_switch)
4373 stac_gpio_set(codec, spec->gpio_mask,
4374 spec->gpio_dir, spec->gpio_data &
4377 /* enable speakers */
4378 for (i = 0; i < cfg->speaker_outs; i++)
4379 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4381 if (spec->eapd_mask && spec->eapd_switch)
4382 stac_gpio_set(codec, spec->gpio_mask,
4383 spec->gpio_dir, spec->gpio_data |
4388 /* return non-zero if the hp-pin of the given array index isn't
4389 * a jack-detection target
4391 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4393 struct auto_pin_cfg *cfg = &spec->autocfg;
4395 /* ignore sensing of shared line and mic jacks */
4396 if (cfg->hp_pins[i] == spec->line_switch)
4398 if (cfg->hp_pins[i] == spec->mic_switch)
4400 /* ignore if the pin is set as line-out */
4401 if (cfg->hp_pins[i] == spec->hp_switch)
4406 static void stac92xx_hp_detect(struct hda_codec *codec)
4408 struct sigmatel_spec *spec = codec->spec;
4409 struct auto_pin_cfg *cfg = &spec->autocfg;
4413 if (spec->gpio_mute)
4414 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4415 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4417 for (i = 0; i < cfg->hp_outs; i++) {
4420 if (no_hp_sensing(spec, i))
4422 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4424 unsigned int pinctl;
4425 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4426 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4427 if (pinctl & AC_PINCTL_IN_EN)
4428 presence = 0; /* mic- or line-input */
4433 /* disable lineouts */
4434 if (spec->hp_switch)
4435 stac92xx_reset_pinctl(codec, spec->hp_switch,
4437 for (i = 0; i < cfg->line_outs; i++)
4438 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4441 /* enable lineouts */
4442 if (spec->hp_switch)
4443 stac92xx_set_pinctl(codec, spec->hp_switch,
4445 for (i = 0; i < cfg->line_outs; i++)
4446 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4449 stac92xx_line_out_detect(codec, presence);
4450 /* toggle hp outs */
4451 for (i = 0; i < cfg->hp_outs; i++) {
4452 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4453 if (no_hp_sensing(spec, i))
4456 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4458 /* Resetting the pinctl like below may lead to (a sort of) regressions
4459 * on some devices since they use the HP pin actually for line/speaker
4460 * outs although the default pin config shows a different pin (that is
4461 * wrong and useless).
4463 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4464 * But, disabling the code below just works around it, and I'm too tired of
4465 * bug reports with such devices...
4468 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4473 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4476 struct sigmatel_spec *spec = codec->spec;
4477 unsigned int idx, val;
4479 for (idx = 0; idx < spec->num_pwrs; idx++) {
4480 if (spec->pwr_nids[idx] == nid)
4483 if (idx >= spec->num_pwrs)
4486 /* several codecs have two power down bits */
4487 if (spec->pwr_mapping)
4488 idx = spec->pwr_mapping[idx];
4492 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4498 /* power down unused output ports */
4499 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4502 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4504 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4507 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4509 struct sigmatel_spec *spec = codec->spec;
4510 struct sigmatel_jack *jacks = spec->jacks.list;
4514 for (i = 0; i < spec->jacks.used; i++) {
4515 if (jacks->nid == nid) {
4516 unsigned int pin_ctl =
4517 snd_hda_codec_read(codec, nid,
4518 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4520 int type = jacks->type;
4521 if (type == (SND_JACK_LINEOUT
4522 | SND_JACK_HEADPHONE))
4523 type = (pin_ctl & AC_PINCTL_HP_EN)
4524 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4525 snd_jack_report(jacks->jack,
4526 get_pin_presence(codec, nid)
4534 static void stac92xx_mic_detect(struct hda_codec *codec)
4536 struct sigmatel_spec *spec = codec->spec;
4537 struct sigmatel_mic_route *mic;
4539 if (get_pin_presence(codec, spec->ext_mic.pin))
4540 mic = &spec->ext_mic;
4542 mic = &spec->int_mic;
4544 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4545 AC_VERB_SET_CONNECT_SEL,
4548 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4549 AC_VERB_SET_CONNECT_SEL,
4553 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4555 struct sigmatel_event *event = stac_get_event(codec, nid);
4558 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4561 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4563 struct sigmatel_spec *spec = codec->spec;
4564 struct sigmatel_event *event;
4567 tag = (res >> 26) & 0x7f;
4568 event = stac_get_event_from_tag(codec, tag);
4572 switch (event->type) {
4575 stac92xx_hp_detect(codec);
4577 case STAC_MIC_EVENT:
4578 stac92xx_mic_detect(codec);
4582 switch (event->type) {
4585 case STAC_MIC_EVENT:
4586 case STAC_INSERT_EVENT:
4587 case STAC_PWR_EVENT:
4588 if (spec->num_pwrs > 0)
4589 stac92xx_pin_sense(codec, event->nid);
4590 stac92xx_report_jack(codec, event->nid);
4592 switch (codec->subsystem_id) {
4594 if (event->nid == 0xb) {
4595 int pin = AC_PINCTL_IN_EN;
4597 if (get_pin_presence(codec, 0xa)
4598 && get_pin_presence(codec, 0xb))
4599 pin |= AC_PINCTL_VREF_80;
4600 if (!get_pin_presence(codec, 0xb))
4601 pin |= AC_PINCTL_VREF_80;
4603 /* toggle VREF state based on mic + hp pin
4606 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4610 case STAC_VREF_EVENT:
4611 data = snd_hda_codec_read(codec, codec->afg, 0,
4612 AC_VERB_GET_GPIO_DATA, 0);
4613 /* toggle VREF state based on GPIOx status */
4614 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4615 !!(data & (1 << event->data)));
4620 #ifdef CONFIG_PROC_FS
4621 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4622 struct hda_codec *codec, hda_nid_t nid)
4624 if (nid == codec->afg)
4625 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4626 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4629 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4630 struct hda_codec *codec,
4633 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4634 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4637 /* stac92hd71bxx, stac92hd73xx */
4638 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4639 struct hda_codec *codec, hda_nid_t nid)
4641 stac92hd_proc_hook(buffer, codec, nid);
4642 if (nid == codec->afg)
4643 analog_loop_proc_hook(buffer, codec, 0xfa0);
4646 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4647 struct hda_codec *codec, hda_nid_t nid)
4649 if (nid == codec->afg)
4650 analog_loop_proc_hook(buffer, codec, 0xfe0);
4653 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4654 struct hda_codec *codec, hda_nid_t nid)
4656 if (nid == codec->afg)
4657 analog_loop_proc_hook(buffer, codec, 0xfeb);
4660 #define stac92hd_proc_hook NULL
4661 #define stac92hd7x_proc_hook NULL
4662 #define stac9205_proc_hook NULL
4663 #define stac927x_proc_hook NULL
4666 #ifdef SND_HDA_NEEDS_RESUME
4667 static int stac92xx_resume(struct hda_codec *codec)
4669 struct sigmatel_spec *spec = codec->spec;
4671 stac92xx_init(codec);
4672 snd_hda_codec_resume_amp(codec);
4673 snd_hda_codec_resume_cache(codec);
4674 /* fake event to set up pins again to override cached values */
4675 if (spec->hp_detect)
4676 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4681 * using power check for controlling mute led of HP notebooks
4682 * check for mute state only on Speakers (nid = 0x10)
4684 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4685 * the LED is NOT working properly !
4687 * Changed name to reflect that it now works for any designated
4688 * model, not just HP HDX.
4691 #ifdef CONFIG_SND_HDA_POWER_SAVE
4692 static int stac92xx_hp_check_power_status(struct hda_codec *codec,
4695 struct sigmatel_spec *spec = codec->spec;
4698 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4700 spec->gpio_data &= ~spec->gpio_led; /* orange */
4702 spec->gpio_data |= spec->gpio_led; /* white */
4704 stac_gpio_set(codec, spec->gpio_mask,
4713 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4715 struct sigmatel_spec *spec = codec->spec;
4719 /* reset each pin before powering down DAC/ADC to avoid click noise */
4720 nid = codec->start_nid;
4721 for (i = 0; i < codec->num_nodes; i++, nid++) {
4722 unsigned int wcaps = get_wcaps(codec, nid);
4723 unsigned int wid_type = get_wcaps_type(wcaps);
4724 if (wid_type == AC_WID_PIN)
4725 snd_hda_codec_read(codec, nid, 0,
4726 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4729 if (spec->eapd_mask)
4730 stac_gpio_set(codec, spec->gpio_mask,
4731 spec->gpio_dir, spec->gpio_data &
4737 static struct hda_codec_ops stac92xx_patch_ops = {
4738 .build_controls = stac92xx_build_controls,
4739 .build_pcms = stac92xx_build_pcms,
4740 .init = stac92xx_init,
4741 .free = stac92xx_free,
4742 .unsol_event = stac92xx_unsol_event,
4743 #ifdef SND_HDA_NEEDS_RESUME
4744 .suspend = stac92xx_suspend,
4745 .resume = stac92xx_resume,
4749 static int patch_stac9200(struct hda_codec *codec)
4751 struct sigmatel_spec *spec;
4754 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4759 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4760 spec->pin_nids = stac9200_pin_nids;
4761 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4764 if (spec->board_config < 0)
4765 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4768 stac92xx_set_config_regs(codec,
4769 stac9200_brd_tbl[spec->board_config]);
4771 spec->multiout.max_channels = 2;
4772 spec->multiout.num_dacs = 1;
4773 spec->multiout.dac_nids = stac9200_dac_nids;
4774 spec->adc_nids = stac9200_adc_nids;
4775 spec->mux_nids = stac9200_mux_nids;
4776 spec->num_muxes = 1;
4777 spec->num_dmics = 0;
4781 if (spec->board_config == STAC_9200_M4 ||
4782 spec->board_config == STAC_9200_M4_2 ||
4783 spec->board_config == STAC_9200_OQO)
4784 spec->init = stac9200_eapd_init;
4786 spec->init = stac9200_core_init;
4787 spec->mixer = stac9200_mixer;
4789 if (spec->board_config == STAC_9200_PANASONIC) {
4790 spec->gpio_mask = spec->gpio_dir = 0x09;
4791 spec->gpio_data = 0x00;
4794 err = stac9200_parse_auto_config(codec);
4796 stac92xx_free(codec);
4800 /* CF-74 has no headphone detection, and the driver should *NOT*
4801 * do detection and HP/speaker toggle because the hardware does it.
4803 if (spec->board_config == STAC_9200_PANASONIC)
4804 spec->hp_detect = 0;
4806 codec->patch_ops = stac92xx_patch_ops;
4811 static int patch_stac925x(struct hda_codec *codec)
4813 struct sigmatel_spec *spec;
4816 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4821 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4822 spec->pin_nids = stac925x_pin_nids;
4824 /* Check first for codec ID */
4825 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4828 stac925x_codec_id_cfg_tbl);
4830 /* Now checks for PCI ID, if codec ID is not found */
4831 if (spec->board_config < 0)
4832 spec->board_config = snd_hda_check_board_config(codec,
4837 if (spec->board_config < 0)
4838 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4841 stac92xx_set_config_regs(codec,
4842 stac925x_brd_tbl[spec->board_config]);
4844 spec->multiout.max_channels = 2;
4845 spec->multiout.num_dacs = 1;
4846 spec->multiout.dac_nids = stac925x_dac_nids;
4847 spec->adc_nids = stac925x_adc_nids;
4848 spec->mux_nids = stac925x_mux_nids;
4849 spec->num_muxes = 1;
4852 switch (codec->vendor_id) {
4853 case 0x83847632: /* STAC9202 */
4854 case 0x83847633: /* STAC9202D */
4855 case 0x83847636: /* STAC9251 */
4856 case 0x83847637: /* STAC9251D */
4857 spec->num_dmics = STAC925X_NUM_DMICS;
4858 spec->dmic_nids = stac925x_dmic_nids;
4859 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4860 spec->dmux_nids = stac925x_dmux_nids;
4863 spec->num_dmics = 0;
4867 spec->init = stac925x_core_init;
4868 spec->mixer = stac925x_mixer;
4870 spec->capvols = stac925x_capvols;
4871 spec->capsws = stac925x_capsws;
4873 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4875 if (spec->board_config < 0) {
4876 printk(KERN_WARNING "hda_codec: No auto-config is "
4877 "available, default to model=ref\n");
4878 spec->board_config = STAC_925x_REF;
4884 stac92xx_free(codec);
4888 codec->patch_ops = stac92xx_patch_ops;
4893 static int patch_stac92hd73xx(struct hda_codec *codec)
4895 struct sigmatel_spec *spec;
4896 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4900 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4905 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4906 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4907 spec->pin_nids = stac92hd73xx_pin_nids;
4908 spec->board_config = snd_hda_check_board_config(codec,
4909 STAC_92HD73XX_MODELS,
4910 stac92hd73xx_models,
4911 stac92hd73xx_cfg_tbl);
4913 if (spec->board_config < 0)
4914 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4917 stac92xx_set_config_regs(codec,
4918 stac92hd73xx_brd_tbl[spec->board_config]);
4920 num_dacs = snd_hda_get_connections(codec, 0x0a,
4921 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4923 if (num_dacs < 3 || num_dacs > 5) {
4924 printk(KERN_WARNING "hda_codec: Could not determine "
4925 "number of channels defaulting to DAC count\n");
4926 num_dacs = STAC92HD73_DAC_COUNT;
4928 spec->init = stac92hd73xx_core_init;
4930 case 0x3: /* 6 Channel */
4931 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
4933 case 0x4: /* 8 Channel */
4934 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
4936 case 0x5: /* 10 Channel */
4937 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4940 spec->multiout.dac_nids = spec->dac_nids;
4942 spec->aloopback_mask = 0x01;
4943 spec->aloopback_shift = 8;
4945 spec->digbeep_nid = 0x1c;
4946 spec->mux_nids = stac92hd73xx_mux_nids;
4947 spec->adc_nids = stac92hd73xx_adc_nids;
4948 spec->dmic_nids = stac92hd73xx_dmic_nids;
4949 spec->dmux_nids = stac92hd73xx_dmux_nids;
4950 spec->smux_nids = stac92hd73xx_smux_nids;
4952 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4953 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4954 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4956 spec->num_caps = STAC92HD73XX_NUM_CAPS;
4957 spec->capvols = stac92hd73xx_capvols;
4958 spec->capsws = stac92hd73xx_capsws;
4960 switch (spec->board_config) {
4962 spec->init = dell_eq_core_init;
4964 case STAC_DELL_M6_AMIC:
4965 case STAC_DELL_M6_DMIC:
4966 case STAC_DELL_M6_BOTH:
4967 spec->num_smuxes = 0;
4968 spec->eapd_switch = 0;
4970 switch (spec->board_config) {
4971 case STAC_DELL_M6_AMIC: /* Analog Mics */
4972 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4973 spec->num_dmics = 0;
4975 case STAC_DELL_M6_DMIC: /* Digital Mics */
4976 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
4977 spec->num_dmics = 1;
4979 case STAC_DELL_M6_BOTH: /* Both */
4980 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4981 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
4982 spec->num_dmics = 1;
4987 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4988 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4989 spec->eapd_switch = 1;
4992 if (spec->board_config > STAC_92HD73XX_REF) {
4993 /* GPIO0 High = Enable EAPD */
4994 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4995 spec->gpio_data = 0x01;
4998 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4999 spec->pwr_nids = stac92hd73xx_pwr_nids;
5001 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
5004 if (spec->board_config < 0) {
5005 printk(KERN_WARNING "hda_codec: No auto-config is "
5006 "available, default to model=ref\n");
5007 spec->board_config = STAC_92HD73XX_REF;
5014 stac92xx_free(codec);
5018 if (spec->board_config == STAC_92HD73XX_NO_JD)
5019 spec->hp_detect = 0;
5021 codec->patch_ops = stac92xx_patch_ops;
5023 codec->proc_widget_hook = stac92hd7x_proc_hook;
5028 static int patch_stac92hd83xxx(struct hda_codec *codec)
5030 struct sigmatel_spec *spec;
5031 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
5036 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5041 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5042 spec->mono_nid = 0x19;
5043 spec->digbeep_nid = 0x21;
5044 spec->mux_nids = stac92hd83xxx_mux_nids;
5045 spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids);
5046 spec->adc_nids = stac92hd83xxx_adc_nids;
5047 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5048 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5049 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5050 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5051 spec->multiout.dac_nids = spec->dac_nids;
5053 spec->init = stac92hd83xxx_core_init;
5054 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5055 spec->pin_nids = stac92hd83xxx_pin_nids;
5056 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5057 spec->capvols = stac92hd83xxx_capvols;
5058 spec->capsws = stac92hd83xxx_capsws;
5060 spec->board_config = snd_hda_check_board_config(codec,
5061 STAC_92HD83XXX_MODELS,
5062 stac92hd83xxx_models,
5063 stac92hd83xxx_cfg_tbl);
5065 if (spec->board_config < 0)
5066 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5069 stac92xx_set_config_regs(codec,
5070 stac92hd83xxx_brd_tbl[spec->board_config]);
5072 switch (codec->vendor_id) {
5076 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5082 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5084 if (spec->board_config < 0) {
5085 printk(KERN_WARNING "hda_codec: No auto-config is "
5086 "available, default to model=ref\n");
5087 spec->board_config = STAC_92HD83XXX_REF;
5094 stac92xx_free(codec);
5098 switch (spec->board_config) {
5107 num_dacs = snd_hda_get_connections(codec, nid,
5108 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5110 num_dacs = STAC92HD83_DAC_COUNT;
5112 /* set port X to select the last DAC
5114 snd_hda_codec_write_cache(codec, nid, 0,
5115 AC_VERB_SET_CONNECT_SEL, num_dacs);
5117 codec->patch_ops = stac92xx_patch_ops;
5119 codec->proc_widget_hook = stac92hd_proc_hook;
5124 /* get the pin connection (fixed, none, etc) */
5125 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5127 struct sigmatel_spec *spec = codec->spec;
5130 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5131 return get_defcfg_connect(cfg);
5134 static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5135 hda_nid_t *nids, int num_nids)
5137 struct sigmatel_spec *spec = codec->spec;
5139 unsigned int def_conf;
5141 for (num = 0; num < num_nids; num++) {
5142 for (idx = 0; idx < spec->num_pins; idx++)
5143 if (spec->pin_nids[idx] == nids[num])
5145 if (idx >= spec->num_pins)
5147 def_conf = stac_get_defcfg_connect(codec, idx);
5148 if (def_conf == AC_JACK_PORT_NONE)
5154 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5157 struct sigmatel_spec *spec = codec->spec;
5160 for (idx = 0; idx < spec->num_pins; idx++)
5161 if (spec->pin_nids[idx] == dig0pin)
5163 if ((idx + 2) >= spec->num_pins)
5167 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5170 /* dig0pin + dig2pin case */
5171 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5173 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5179 static int patch_stac92hd71bxx(struct hda_codec *codec)
5181 struct sigmatel_spec *spec;
5182 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5185 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5190 codec->patch_ops = stac92xx_patch_ops;
5191 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5192 switch (codec->vendor_id) {
5195 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5199 /* On 92HD75Bx 0x27 isn't a pin nid */
5203 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5205 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5206 spec->board_config = snd_hda_check_board_config(codec,
5207 STAC_92HD71BXX_MODELS,
5208 stac92hd71bxx_models,
5209 stac92hd71bxx_cfg_tbl);
5211 if (spec->board_config < 0)
5212 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5215 stac92xx_set_config_regs(codec,
5216 stac92hd71bxx_brd_tbl[spec->board_config]);
5218 if (spec->board_config > STAC_92HD71BXX_REF) {
5220 spec->gpio_mask = 0x01;
5221 spec->gpio_dir = 0x01;
5222 spec->gpio_data = 0x01;
5225 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5226 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5228 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5229 spec->capvols = stac92hd71bxx_capvols;
5230 spec->capsws = stac92hd71bxx_capsws;
5232 switch (codec->vendor_id) {
5233 case 0x111d76b6: /* 4 Port without Analog Mixer */
5237 case 0x111d76b4: /* 6 Port without Analog Mixer */
5239 spec->init = stac92hd71bxx_core_init;
5240 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5241 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5242 stac92hd71bxx_dmic_nids,
5243 STAC92HD71BXX_NUM_DMICS);
5245 case 0x111d7608: /* 5 Port with Analog Mixer */
5246 switch (spec->board_config) {
5248 /* Enable VREF power saving on GPIO1 detect */
5249 err = stac_add_event(spec, codec->afg,
5250 STAC_VREF_EVENT, 0x02);
5253 snd_hda_codec_write_cache(codec, codec->afg, 0,
5254 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5255 snd_hda_codec_write_cache(codec, codec->afg, 0,
5256 AC_VERB_SET_UNSOLICITED_ENABLE,
5258 spec->gpio_mask |= 0x02;
5261 if ((codec->revision_id & 0xf) == 0 ||
5262 (codec->revision_id & 0xf) == 1)
5263 spec->stream_delay = 40; /* 40 milliseconds */
5265 /* no output amps */
5268 spec->init = stac92hd71bxx_core_init;
5270 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5271 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5272 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5273 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5274 stac92hd71bxx_dmic_nids,
5275 STAC92HD71BXX_NUM_DMICS - 1);
5277 case 0x111d7603: /* 6 Port with Analog Mixer */
5278 if ((codec->revision_id & 0xf) == 1)
5279 spec->stream_delay = 40; /* 40 milliseconds */
5281 /* no output amps */
5285 spec->init = stac92hd71bxx_core_init;
5286 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5287 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5288 stac92hd71bxx_dmic_nids,
5289 STAC92HD71BXX_NUM_DMICS);
5293 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5294 snd_hda_sequence_write_cache(codec, unmute_init);
5296 /* Some HP machines seem to have unstable codec communications
5297 * especially with ATI fglrx driver. For recovering from the
5298 * CORB/RIRB stall, allow the BUS reset and keep always sync
5300 if (spec->board_config == STAC_HP_DV5) {
5301 codec->bus->sync_write = 1;
5302 codec->bus->allow_bus_reset = 1;
5305 spec->aloopback_ctl = stac92hd71bxx_loopback;
5306 spec->aloopback_mask = 0x50;
5307 spec->aloopback_shift = 0;
5309 spec->powerdown_adcs = 1;
5310 spec->digbeep_nid = 0x26;
5311 spec->mux_nids = stac92hd71bxx_mux_nids;
5312 spec->adc_nids = stac92hd71bxx_adc_nids;
5313 spec->smux_nids = stac92hd71bxx_smux_nids;
5314 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5316 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5317 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5318 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5319 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5321 switch (spec->board_config) {
5323 /* enable internal microphone */
5324 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5325 stac92xx_auto_set_pinctl(codec, 0x0e,
5326 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5328 case STAC_DELL_M4_2:
5329 spec->num_dmics = 0;
5330 spec->num_smuxes = 0;
5331 spec->num_dmuxes = 0;
5333 case STAC_DELL_M4_1:
5334 case STAC_DELL_M4_3:
5335 spec->num_dmics = 1;
5336 spec->num_smuxes = 0;
5337 spec->num_dmuxes = 1;
5339 case STAC_HP_DV4_1222NR:
5340 spec->num_dmics = 1;
5341 /* I don't know if it needs 1 or 2 smuxes - will wait for
5342 * bug reports to fix if needed
5344 spec->num_smuxes = 1;
5345 spec->num_dmuxes = 1;
5346 spec->gpio_led = 0x01;
5349 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5350 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5353 spec->num_dmics = 1;
5354 spec->num_dmuxes = 1;
5355 spec->num_smuxes = 1;
5356 /* orange/white mute led on GPIO3, orange=0, white=1 */
5357 spec->gpio_led = 0x08;
5361 #ifdef CONFIG_SND_HDA_POWER_SAVE
5362 if (spec->gpio_led) {
5363 spec->gpio_mask |= spec->gpio_led;
5364 spec->gpio_dir |= spec->gpio_led;
5365 spec->gpio_data |= spec->gpio_led;
5366 /* register check_power_status callback. */
5367 codec->patch_ops.check_power_status =
5368 stac92xx_hp_check_power_status;
5372 spec->multiout.dac_nids = spec->dac_nids;
5374 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5376 if (spec->board_config < 0) {
5377 printk(KERN_WARNING "hda_codec: No auto-config is "
5378 "available, default to model=ref\n");
5379 spec->board_config = STAC_92HD71BXX_REF;
5386 stac92xx_free(codec);
5390 codec->proc_widget_hook = stac92hd7x_proc_hook;
5395 static int patch_stac922x(struct hda_codec *codec)
5397 struct sigmatel_spec *spec;
5400 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5405 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5406 spec->pin_nids = stac922x_pin_nids;
5407 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5410 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5411 spec->gpio_mask = spec->gpio_dir = 0x03;
5412 spec->gpio_data = 0x03;
5413 /* Intel Macs have all same PCI SSID, so we need to check
5414 * codec SSID to distinguish the exact models
5416 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5417 switch (codec->subsystem_id) {
5420 spec->board_config = STAC_INTEL_MAC_V1;
5424 spec->board_config = STAC_INTEL_MAC_V2;
5432 spec->board_config = STAC_INTEL_MAC_V3;
5436 spec->board_config = STAC_INTEL_MAC_V4;
5440 spec->board_config = STAC_INTEL_MAC_V5;
5443 spec->board_config = STAC_INTEL_MAC_V3;
5449 if (spec->board_config < 0)
5450 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5453 stac92xx_set_config_regs(codec,
5454 stac922x_brd_tbl[spec->board_config]);
5456 spec->adc_nids = stac922x_adc_nids;
5457 spec->mux_nids = stac922x_mux_nids;
5458 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5459 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5460 spec->num_dmics = 0;
5463 spec->init = stac922x_core_init;
5465 spec->num_caps = STAC922X_NUM_CAPS;
5466 spec->capvols = stac922x_capvols;
5467 spec->capsws = stac922x_capsws;
5469 spec->multiout.dac_nids = spec->dac_nids;
5471 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5473 if (spec->board_config < 0) {
5474 printk(KERN_WARNING "hda_codec: No auto-config is "
5475 "available, default to model=ref\n");
5476 spec->board_config = STAC_D945_REF;
5482 stac92xx_free(codec);
5486 codec->patch_ops = stac92xx_patch_ops;
5488 /* Fix Mux capture level; max to 2 */
5489 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5490 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5491 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5492 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5493 (0 << AC_AMPCAP_MUTE_SHIFT));
5498 static int patch_stac927x(struct hda_codec *codec)
5500 struct sigmatel_spec *spec;
5503 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5508 codec->slave_dig_outs = stac927x_slave_dig_outs;
5509 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5510 spec->pin_nids = stac927x_pin_nids;
5511 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5515 if (spec->board_config < 0)
5516 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5519 stac92xx_set_config_regs(codec,
5520 stac927x_brd_tbl[spec->board_config]);
5522 spec->digbeep_nid = 0x23;
5523 spec->adc_nids = stac927x_adc_nids;
5524 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5525 spec->mux_nids = stac927x_mux_nids;
5526 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5527 spec->smux_nids = stac927x_smux_nids;
5528 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5529 spec->spdif_labels = stac927x_spdif_labels;
5530 spec->dac_list = stac927x_dac_nids;
5531 spec->multiout.dac_nids = spec->dac_nids;
5533 switch (spec->board_config) {
5536 /* GPIO0 High = Enable EAPD */
5537 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
5538 spec->gpio_data = 0x01;
5539 spec->num_dmics = 0;
5541 spec->init = d965_core_init;
5543 case STAC_DELL_BIOS:
5544 switch (codec->subsystem_id) {
5547 /* correct the device field to SPDIF out */
5548 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5551 /* configure the analog microphone on some laptops */
5552 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5553 /* correct the front output jack as a hp out */
5554 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5555 /* correct the front input jack as a mic */
5556 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5559 /* GPIO2 High = Enable EAPD */
5560 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
5561 spec->gpio_data = 0x04;
5562 switch (codec->subsystem_id) {
5564 /* correct EAPD to be GPIO0 */
5565 spec->eapd_mask = spec->gpio_mask = 0x01;
5566 spec->gpio_dir = spec->gpio_data = 0x01;
5569 spec->dmic_nids = stac927x_dmic_nids;
5570 spec->num_dmics = STAC927X_NUM_DMICS;
5572 spec->init = d965_core_init;
5573 spec->dmux_nids = stac927x_dmux_nids;
5574 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5577 if (spec->board_config > STAC_D965_REF) {
5578 /* GPIO0 High = Enable EAPD */
5579 spec->eapd_mask = spec->gpio_mask = 0x01;
5580 spec->gpio_dir = spec->gpio_data = 0x01;
5582 spec->num_dmics = 0;
5584 spec->init = stac927x_core_init;
5587 spec->num_caps = STAC927X_NUM_CAPS;
5588 spec->capvols = stac927x_capvols;
5589 spec->capsws = stac927x_capsws;
5592 spec->aloopback_ctl = stac927x_loopback;
5593 spec->aloopback_mask = 0x40;
5594 spec->aloopback_shift = 0;
5595 spec->eapd_switch = 1;
5597 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
5599 if (spec->board_config < 0) {
5600 printk(KERN_WARNING "hda_codec: No auto-config is "
5601 "available, default to model=ref\n");
5602 spec->board_config = STAC_D965_REF;
5608 stac92xx_free(codec);
5612 codec->patch_ops = stac92xx_patch_ops;
5614 codec->proc_widget_hook = stac927x_proc_hook;
5618 * The STAC927x seem to require fairly long delays for certain
5619 * command sequences. With too short delays (even if the answer
5620 * is set to RIRB properly), it results in the silence output
5621 * on some hardwares like Dell.
5623 * The below flag enables the longer delay (see get_response
5626 codec->bus->needs_damn_long_delay = 1;
5628 /* no jack detecion for ref-no-jd model */
5629 if (spec->board_config == STAC_D965_REF_NO_JD)
5630 spec->hp_detect = 0;
5635 static int patch_stac9205(struct hda_codec *codec)
5637 struct sigmatel_spec *spec;
5640 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5645 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
5646 spec->pin_nids = stac9205_pin_nids;
5647 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5651 if (spec->board_config < 0)
5652 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5655 stac92xx_set_config_regs(codec,
5656 stac9205_brd_tbl[spec->board_config]);
5658 spec->digbeep_nid = 0x23;
5659 spec->adc_nids = stac9205_adc_nids;
5660 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
5661 spec->mux_nids = stac9205_mux_nids;
5662 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
5663 spec->smux_nids = stac9205_smux_nids;
5664 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
5665 spec->dmic_nids = stac9205_dmic_nids;
5666 spec->num_dmics = STAC9205_NUM_DMICS;
5667 spec->dmux_nids = stac9205_dmux_nids;
5668 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
5671 spec->init = stac9205_core_init;
5672 spec->aloopback_ctl = stac9205_loopback;
5674 spec->num_caps = STAC9205_NUM_CAPS;
5675 spec->capvols = stac9205_capvols;
5676 spec->capsws = stac9205_capsws;
5678 spec->aloopback_mask = 0x40;
5679 spec->aloopback_shift = 0;
5680 /* Turn on/off EAPD per HP plugging */
5681 if (spec->board_config != STAC_9205_EAPD)
5682 spec->eapd_switch = 1;
5683 spec->multiout.dac_nids = spec->dac_nids;
5685 switch (spec->board_config){
5686 case STAC_9205_DELL_M43:
5687 /* Enable SPDIF in/out */
5688 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5689 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
5691 /* Enable unsol response for GPIO4/Dock HP connection */
5692 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5695 snd_hda_codec_write_cache(codec, codec->afg, 0,
5696 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5697 snd_hda_codec_write_cache(codec, codec->afg, 0,
5698 AC_VERB_SET_UNSOLICITED_ENABLE,
5701 spec->gpio_dir = 0x0b;
5702 spec->eapd_mask = 0x01;
5703 spec->gpio_mask = 0x1b;
5704 spec->gpio_mute = 0x10;
5705 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5708 spec->gpio_data = 0x01;
5711 /* SPDIF-In enabled */
5714 /* GPIO0 High = EAPD */
5715 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5716 spec->gpio_data = 0x01;
5720 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5722 if (spec->board_config < 0) {
5723 printk(KERN_WARNING "hda_codec: No auto-config is "
5724 "available, default to model=ref\n");
5725 spec->board_config = STAC_9205_REF;
5731 stac92xx_free(codec);
5735 codec->patch_ops = stac92xx_patch_ops;
5737 codec->proc_widget_hook = stac9205_proc_hook;
5746 static struct hda_verb stac9872_core_init[] = {
5747 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5752 static hda_nid_t stac9872_pin_nids[] = {
5753 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5757 static hda_nid_t stac9872_adc_nids[] = {
5761 static hda_nid_t stac9872_mux_nids[] = {
5765 static unsigned long stac9872_capvols[] = {
5766 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
5768 #define stac9872_capsws stac9872_capvols
5770 static unsigned int stac9872_vaio_pin_configs[9] = {
5771 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5772 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5776 static const char *stac9872_models[STAC_9872_MODELS] = {
5777 [STAC_9872_AUTO] = "auto",
5778 [STAC_9872_VAIO] = "vaio",
5781 static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5782 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5785 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5786 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
5787 "Sony VAIO F/S", STAC_9872_VAIO),
5791 static int patch_stac9872(struct hda_codec *codec)
5793 struct sigmatel_spec *spec;
5796 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5800 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5801 spec->pin_nids = stac9872_pin_nids;
5803 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5806 if (spec->board_config < 0)
5807 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5810 stac92xx_set_config_regs(codec,
5811 stac9872_brd_tbl[spec->board_config]);
5813 spec->multiout.dac_nids = spec->dac_nids;
5814 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5815 spec->adc_nids = stac9872_adc_nids;
5816 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5817 spec->mux_nids = stac9872_mux_nids;
5818 spec->init = stac9872_core_init;
5820 spec->capvols = stac9872_capvols;
5821 spec->capsws = stac9872_capsws;
5823 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5825 stac92xx_free(codec);
5828 spec->input_mux = &spec->private_imux;
5829 codec->patch_ops = stac92xx_patch_ops;
5837 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5838 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5839 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5840 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5841 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5842 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5843 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5844 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5845 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5846 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5847 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5848 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5849 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5850 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5851 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5852 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5853 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5854 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5855 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5856 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5857 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5858 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5859 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5860 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5861 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5862 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5863 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5864 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5865 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5866 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5867 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5868 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5869 /* The following does not take into account .id=0x83847661 when subsys =
5870 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5871 * currently not fully supported.
5873 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5874 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5875 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5876 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
5877 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5878 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5879 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5880 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5881 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5882 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5883 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5884 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5885 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5886 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5887 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5888 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
5889 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5890 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5891 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5892 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5893 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5894 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5895 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5896 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5897 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5898 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5899 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5900 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5904 MODULE_ALIAS("snd-hda-codec-id:8384*");
5905 MODULE_ALIAS("snd-hda-codec-id:111d*");
5907 MODULE_LICENSE("GPL");
5908 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5910 static struct hda_codec_preset_list sigmatel_list = {
5911 .preset = snd_hda_preset_sigmatel,
5912 .owner = THIS_MODULE,
5915 static int __init patch_sigmatel_init(void)
5917 return snd_hda_add_codec_preset(&sigmatel_list);
5920 static void __exit patch_sigmatel_exit(void)
5922 snd_hda_delete_codec_preset(&sigmatel_list);
5925 module_init(patch_sigmatel_init)
5926 module_exit(patch_sigmatel_exit)