2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include <sound/asoundef.h>
33 #include <sound/jack.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
79 STAC_92HD73XX_NO_JD, /* no jack-detection */
93 STAC_92HD83XXX_PWR_REF,
108 STAC_92HD71BXX_MODELS
134 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
135 * is given, one of the above models will be
136 * chosen according to the subsystem id. */
137 /* for backward compatibility */
154 STAC_D965_REF_NO_JD, /* no jack-detection */
171 struct sigmatel_event {
178 struct sigmatel_jack {
181 struct snd_jack *jack;
184 struct sigmatel_mic_route {
187 signed char dmux_idx;
190 struct sigmatel_spec {
191 struct snd_kcontrol_new *mixers[4];
192 unsigned int num_mixers;
195 unsigned int eapd_switch: 1;
196 unsigned int surr_switch: 1;
197 unsigned int alt_switch: 1;
198 unsigned int hp_detect: 1;
199 unsigned int spdif_mute: 1;
200 unsigned int check_volume_offset:1;
201 unsigned int auto_mic:1;
204 unsigned int eapd_mask;
205 unsigned int gpio_mask;
206 unsigned int gpio_dir;
207 unsigned int gpio_data;
208 unsigned int gpio_mute;
209 unsigned int gpio_led;
212 unsigned int stream_delay;
214 /* analog loopback */
215 struct snd_kcontrol_new *aloopback_ctl;
216 unsigned char aloopback_mask;
217 unsigned char aloopback_shift;
219 /* power management */
220 unsigned int num_pwrs;
221 unsigned int *pwr_mapping;
226 struct snd_array jacks;
229 struct snd_array events;
232 struct hda_input_mux *mono_mux;
233 unsigned int cur_mmux;
234 struct hda_multi_out multiout;
235 hda_nid_t dac_nids[5];
236 hda_nid_t hp_dacs[5];
237 hda_nid_t speaker_dacs[5];
243 unsigned int num_adcs;
245 unsigned int num_muxes;
246 hda_nid_t *dmic_nids;
247 unsigned int num_dmics;
248 hda_nid_t *dmux_nids;
249 unsigned int num_dmuxes;
250 hda_nid_t *smux_nids;
251 unsigned int num_smuxes;
252 unsigned int num_analog_muxes;
254 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
255 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
256 unsigned int num_caps; /* number of capture volume/switch elements */
258 struct sigmatel_mic_route ext_mic;
259 struct sigmatel_mic_route int_mic;
261 const char **spdif_labels;
263 hda_nid_t dig_in_nid;
265 hda_nid_t anabeep_nid;
266 hda_nid_t digbeep_nid;
270 unsigned int num_pins;
272 /* codec specific stuff */
273 struct hda_verb *init;
274 struct snd_kcontrol_new *mixer;
277 struct hda_input_mux *dinput_mux;
278 unsigned int cur_dmux[2];
279 struct hda_input_mux *input_mux;
280 unsigned int cur_mux[3];
281 struct hda_input_mux *sinput_mux;
282 unsigned int cur_smux[2];
283 unsigned int cur_amux;
285 unsigned int powerdown_adcs;
288 unsigned int io_switch[2];
289 unsigned int clfe_swap;
290 hda_nid_t line_switch; /* shared line-in for input and output */
291 hda_nid_t mic_switch; /* shared mic-in for input and output */
292 hda_nid_t hp_switch; /* NID of HP as line-out */
293 unsigned int aloopback;
295 struct hda_pcm pcm_rec[2]; /* PCM information */
297 /* dynamic controls and input_mux */
298 struct auto_pin_cfg autocfg;
299 struct snd_array kctls;
300 struct hda_input_mux private_dimux;
301 struct hda_input_mux private_imux;
302 struct hda_input_mux private_smux;
303 struct hda_input_mux private_mono_mux;
306 static hda_nid_t stac9200_adc_nids[1] = {
310 static hda_nid_t stac9200_mux_nids[1] = {
314 static hda_nid_t stac9200_dac_nids[1] = {
318 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
319 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
323 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
327 static hda_nid_t stac92hd73xx_adc_nids[2] = {
331 #define STAC92HD73XX_NUM_DMICS 2
332 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
336 #define STAC92HD73_DAC_COUNT 5
338 static hda_nid_t stac92hd73xx_mux_nids[2] = {
342 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
346 static hda_nid_t stac92hd73xx_smux_nids[2] = {
350 #define STAC92HD73XX_NUM_CAPS 2
351 static unsigned long stac92hd73xx_capvols[] = {
352 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
353 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
355 #define stac92hd73xx_capsws stac92hd73xx_capvols
357 #define STAC92HD83_DAC_COUNT 3
359 static hda_nid_t stac92hd83xxx_mux_nids[2] = {
363 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
367 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
371 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
375 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
376 0x03, 0x0c, 0x20, 0x40,
379 #define STAC92HD83XXX_NUM_CAPS 2
380 static unsigned long stac92hd83xxx_capvols[] = {
381 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
382 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
384 #define stac92hd83xxx_capsws stac92hd83xxx_capvols
386 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
390 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
394 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
398 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
402 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
406 #define STAC92HD71BXX_NUM_DMICS 2
407 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
411 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
415 #define STAC92HD71BXX_NUM_CAPS 2
416 static unsigned long stac92hd71bxx_capvols[] = {
417 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
418 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
420 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
422 static hda_nid_t stac925x_adc_nids[1] = {
426 static hda_nid_t stac925x_mux_nids[1] = {
430 static hda_nid_t stac925x_dac_nids[1] = {
434 #define STAC925X_NUM_DMICS 1
435 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
439 static hda_nid_t stac925x_dmux_nids[1] = {
443 static unsigned long stac925x_capvols[] = {
444 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
446 static unsigned long stac925x_capsws[] = {
447 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
450 static hda_nid_t stac922x_adc_nids[2] = {
454 static hda_nid_t stac922x_mux_nids[2] = {
458 #define STAC922X_NUM_CAPS 2
459 static unsigned long stac922x_capvols[] = {
460 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
461 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
463 #define stac922x_capsws stac922x_capvols
465 static hda_nid_t stac927x_slave_dig_outs[2] = {
469 static hda_nid_t stac927x_adc_nids[3] = {
473 static hda_nid_t stac927x_mux_nids[3] = {
477 static hda_nid_t stac927x_smux_nids[1] = {
481 static hda_nid_t stac927x_dac_nids[6] = {
482 0x02, 0x03, 0x04, 0x05, 0x06, 0
485 static hda_nid_t stac927x_dmux_nids[1] = {
489 #define STAC927X_NUM_DMICS 2
490 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
494 #define STAC927X_NUM_CAPS 3
495 static unsigned long stac927x_capvols[] = {
496 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
497 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
498 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
500 static unsigned long stac927x_capsws[] = {
501 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
502 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
503 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
506 static const char *stac927x_spdif_labels[5] = {
507 "Digital Playback", "ADAT", "Analog Mux 1",
508 "Analog Mux 2", "Analog Mux 3"
511 static hda_nid_t stac9205_adc_nids[2] = {
515 static hda_nid_t stac9205_mux_nids[2] = {
519 static hda_nid_t stac9205_dmux_nids[1] = {
523 static hda_nid_t stac9205_smux_nids[1] = {
527 #define STAC9205_NUM_DMICS 2
528 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
532 #define STAC9205_NUM_CAPS 2
533 static unsigned long stac9205_capvols[] = {
534 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
535 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
537 static unsigned long stac9205_capsws[] = {
538 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
539 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
542 static hda_nid_t stac9200_pin_nids[8] = {
543 0x08, 0x09, 0x0d, 0x0e,
544 0x0f, 0x10, 0x11, 0x12,
547 static hda_nid_t stac925x_pin_nids[8] = {
548 0x07, 0x08, 0x0a, 0x0b,
549 0x0c, 0x0d, 0x10, 0x11,
552 static hda_nid_t stac922x_pin_nids[10] = {
553 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
554 0x0f, 0x10, 0x11, 0x15, 0x1b,
557 static hda_nid_t stac92hd73xx_pin_nids[13] = {
558 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
559 0x0f, 0x10, 0x11, 0x12, 0x13,
563 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
564 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
565 0x0f, 0x10, 0x11, 0x1f, 0x20,
568 #define STAC92HD71BXX_NUM_PINS 13
569 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
570 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
571 0x00, 0x14, 0x18, 0x19, 0x1e,
574 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
575 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
576 0x0f, 0x14, 0x18, 0x19, 0x1e,
580 static hda_nid_t stac927x_pin_nids[14] = {
581 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
582 0x0f, 0x10, 0x11, 0x12, 0x13,
583 0x14, 0x21, 0x22, 0x23,
586 static hda_nid_t stac9205_pin_nids[12] = {
587 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
588 0x0f, 0x14, 0x16, 0x17, 0x18,
592 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
593 struct snd_ctl_elem_info *uinfo)
595 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
596 struct sigmatel_spec *spec = codec->spec;
597 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
600 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
601 struct snd_ctl_elem_value *ucontrol)
603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
604 struct sigmatel_spec *spec = codec->spec;
605 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
607 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
611 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
612 struct snd_ctl_elem_value *ucontrol)
614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
615 struct sigmatel_spec *spec = codec->spec;
616 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
618 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
619 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
622 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
623 struct snd_ctl_elem_info *uinfo)
625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
626 struct sigmatel_spec *spec = codec->spec;
627 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
630 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
634 struct sigmatel_spec *spec = codec->spec;
635 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
637 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
641 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
642 struct snd_ctl_elem_value *ucontrol)
644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
645 struct sigmatel_spec *spec = codec->spec;
646 struct hda_input_mux *smux = &spec->private_smux;
647 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
651 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
652 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
656 if (spec->spdif_mute) {
658 nid = spec->multiout.dig_out_nid;
660 nid = codec->slave_dig_outs[smux_idx - 1];
661 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
665 /* un/mute SPDIF out */
666 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
672 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
673 hda_nid_t nid, unsigned int new_vref)
677 pincfg = snd_hda_codec_read(codec, nid, 0,
678 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
681 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
684 if (new_vref == AC_PINCTL_VREF_HIZ)
685 pincfg |= AC_PINCTL_OUT_EN;
687 pincfg |= AC_PINCTL_IN_EN;
689 error = snd_hda_codec_write_cache(codec, nid, 0,
690 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
697 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
700 vref = snd_hda_codec_read(codec, nid, 0,
701 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
702 vref &= AC_PINCTL_VREFEN;
706 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
708 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
709 struct sigmatel_spec *spec = codec->spec;
710 return snd_hda_input_mux_info(spec->input_mux, uinfo);
713 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
716 struct sigmatel_spec *spec = codec->spec;
717 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
719 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
723 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
725 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
726 struct sigmatel_spec *spec = codec->spec;
727 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
728 const struct hda_input_mux *imux = spec->input_mux;
729 unsigned int idx, prev_idx;
731 idx = ucontrol->value.enumerated.item[0];
732 if (idx >= imux->num_items)
733 idx = imux->num_items - 1;
734 prev_idx = spec->cur_mux[adc_idx];
737 if (idx < spec->num_analog_muxes) {
738 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
739 AC_VERB_SET_CONNECT_SEL,
740 imux->items[idx].index);
741 if (prev_idx >= spec->num_analog_muxes) {
742 imux = spec->dinput_mux;
744 snd_hda_codec_write_cache(codec,
745 spec->dmux_nids[adc_idx], 0,
746 AC_VERB_SET_CONNECT_SEL,
747 imux->items[0].index);
750 imux = spec->dinput_mux;
751 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
752 AC_VERB_SET_CONNECT_SEL,
753 imux->items[idx - 1].index);
755 spec->cur_mux[adc_idx] = idx;
759 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
760 struct snd_ctl_elem_info *uinfo)
762 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
763 struct sigmatel_spec *spec = codec->spec;
764 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
767 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
768 struct snd_ctl_elem_value *ucontrol)
770 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
771 struct sigmatel_spec *spec = codec->spec;
773 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
777 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
778 struct snd_ctl_elem_value *ucontrol)
780 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
781 struct sigmatel_spec *spec = codec->spec;
783 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
784 spec->mono_nid, &spec->cur_mmux);
787 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
789 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
790 struct snd_ctl_elem_value *ucontrol)
792 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
793 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
794 struct sigmatel_spec *spec = codec->spec;
796 ucontrol->value.integer.value[0] = !!(spec->aloopback &
797 (spec->aloopback_mask << idx));
801 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
802 struct snd_ctl_elem_value *ucontrol)
804 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
805 struct sigmatel_spec *spec = codec->spec;
806 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
807 unsigned int dac_mode;
808 unsigned int val, idx_val;
810 idx_val = spec->aloopback_mask << idx;
811 if (ucontrol->value.integer.value[0])
812 val = spec->aloopback | idx_val;
814 val = spec->aloopback & ~idx_val;
815 if (spec->aloopback == val)
818 spec->aloopback = val;
820 /* Only return the bits defined by the shift value of the
821 * first two bytes of the mask
823 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
824 kcontrol->private_value & 0xFFFF, 0x0);
825 dac_mode >>= spec->aloopback_shift;
827 if (spec->aloopback & idx_val) {
828 snd_hda_power_up(codec);
831 snd_hda_power_down(codec);
832 dac_mode &= ~idx_val;
835 snd_hda_codec_write_cache(codec, codec->afg, 0,
836 kcontrol->private_value >> 16, dac_mode);
841 static struct hda_verb stac9200_core_init[] = {
842 /* set dac0mux for dac converter */
843 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
847 static struct hda_verb stac9200_eapd_init[] = {
848 /* set dac0mux for dac converter */
849 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
850 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
854 static struct hda_verb dell_eq_core_init[] = {
855 /* set master volume to max value without distortion
856 * and direct control */
857 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
861 static struct hda_verb stac92hd73xx_core_init[] = {
862 /* set master volume and direct control */
863 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
867 static struct hda_verb stac92hd83xxx_core_init[] = {
868 /* power state controls amps */
869 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
873 static struct hda_verb stac92hd71bxx_core_init[] = {
874 /* set master volume and direct control */
875 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
879 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
880 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
881 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
882 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
883 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
887 static struct hda_verb stac925x_core_init[] = {
888 /* set dac0mux for dac converter */
889 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
890 /* mute the master volume */
891 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
895 static struct hda_verb stac922x_core_init[] = {
896 /* set master volume and direct control */
897 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
901 static struct hda_verb d965_core_init[] = {
902 /* set master volume and direct control */
903 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
904 /* unmute node 0x1b */
905 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
906 /* select node 0x03 as DAC */
907 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
911 static struct hda_verb stac927x_core_init[] = {
912 /* set master volume and direct control */
913 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
914 /* enable analog pc beep path */
915 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
919 static struct hda_verb stac927x_volknob_core_init[] = {
920 /* don't set delta bit */
921 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
922 /* enable analog pc beep path */
923 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
927 static struct hda_verb stac9205_core_init[] = {
928 /* set master volume and direct control */
929 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
930 /* enable analog pc beep path */
931 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
935 #define STAC_MONO_MUX \
937 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
938 .name = "Mono Mux", \
940 .info = stac92xx_mono_mux_enum_info, \
941 .get = stac92xx_mono_mux_enum_get, \
942 .put = stac92xx_mono_mux_enum_put, \
945 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
948 .name = "Analog Loopback", \
950 .info = stac92xx_aloopback_info, \
951 .get = stac92xx_aloopback_get, \
952 .put = stac92xx_aloopback_put, \
953 .private_value = verb_read | (verb_write << 16), \
956 #define DC_BIAS(xname, idx, nid) \
958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
961 .info = stac92xx_dc_bias_info, \
962 .get = stac92xx_dc_bias_get, \
963 .put = stac92xx_dc_bias_put, \
964 .private_value = nid, \
967 static struct snd_kcontrol_new stac9200_mixer[] = {
968 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
969 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
970 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
971 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
975 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
976 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
980 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
981 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
985 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
986 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
991 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
992 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
995 static struct snd_kcontrol_new stac925x_mixer[] = {
996 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
997 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1001 static struct snd_kcontrol_new stac9205_loopback[] = {
1002 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1006 static struct snd_kcontrol_new stac927x_loopback[] = {
1007 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1011 static struct snd_kcontrol_new stac_dmux_mixer = {
1012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1013 .name = "Digital Input Source",
1014 /* count set later */
1015 .info = stac92xx_dmux_enum_info,
1016 .get = stac92xx_dmux_enum_get,
1017 .put = stac92xx_dmux_enum_put,
1020 static struct snd_kcontrol_new stac_smux_mixer = {
1021 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1022 .name = "IEC958 Playback Source",
1023 /* count set later */
1024 .info = stac92xx_smux_enum_info,
1025 .get = stac92xx_smux_enum_get,
1026 .put = stac92xx_smux_enum_put,
1029 static const char *slave_vols[] = {
1030 "Front Playback Volume",
1031 "Surround Playback Volume",
1032 "Center Playback Volume",
1033 "LFE Playback Volume",
1034 "Side Playback Volume",
1035 "Headphone Playback Volume",
1036 "Speaker Playback Volume",
1040 static const char *slave_sws[] = {
1041 "Front Playback Switch",
1042 "Surround Playback Switch",
1043 "Center Playback Switch",
1044 "LFE Playback Switch",
1045 "Side Playback Switch",
1046 "Headphone Playback Switch",
1047 "Speaker Playback Switch",
1048 "IEC958 Playback Switch",
1052 static void stac92xx_free_kctls(struct hda_codec *codec);
1053 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1055 static int stac92xx_build_controls(struct hda_codec *codec)
1057 struct sigmatel_spec *spec = codec->spec;
1058 struct auto_pin_cfg *cfg = &spec->autocfg;
1064 err = snd_hda_add_new_ctls(codec, spec->mixer);
1069 for (i = 0; i < spec->num_mixers; i++) {
1070 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1074 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1075 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1076 stac_dmux_mixer.count = spec->num_dmuxes;
1077 err = snd_hda_ctl_add(codec,
1078 snd_ctl_new1(&stac_dmux_mixer, codec));
1082 if (spec->num_smuxes > 0) {
1083 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1084 struct hda_input_mux *smux = &spec->private_smux;
1085 /* check for mute support on SPDIF out */
1086 if (wcaps & AC_WCAP_OUT_AMP) {
1087 smux->items[smux->num_items].label = "Off";
1088 smux->items[smux->num_items].index = 0;
1090 spec->spdif_mute = 1;
1092 stac_smux_mixer.count = spec->num_smuxes;
1093 err = snd_hda_ctl_add(codec,
1094 snd_ctl_new1(&stac_smux_mixer, codec));
1099 if (spec->multiout.dig_out_nid) {
1100 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1103 err = snd_hda_create_spdif_share_sw(codec,
1107 spec->multiout.share_spdif = 1;
1109 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1110 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1115 /* if we have no master control, let's create it */
1116 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1117 unsigned int vmaster_tlv[4];
1118 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1119 HDA_OUTPUT, vmaster_tlv);
1120 /* correct volume offset */
1121 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1122 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1123 vmaster_tlv, slave_vols);
1127 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1128 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1134 if (spec->aloopback_ctl &&
1135 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1136 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1141 stac92xx_free_kctls(codec); /* no longer needed */
1143 /* create jack input elements */
1144 if (spec->hp_detect) {
1145 for (i = 0; i < cfg->hp_outs; i++) {
1146 int type = SND_JACK_HEADPHONE;
1147 nid = cfg->hp_pins[i];
1148 /* jack detection */
1149 if (cfg->hp_outs == i)
1150 type |= SND_JACK_LINEOUT;
1151 err = stac92xx_add_jack(codec, nid, type);
1156 for (i = 0; i < cfg->line_outs; i++) {
1157 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1162 for (i = 0; i < AUTO_PIN_LAST; i++) {
1163 nid = cfg->input_pins[i];
1165 err = stac92xx_add_jack(codec, nid,
1166 SND_JACK_MICROPHONE);
1175 static unsigned int ref9200_pin_configs[8] = {
1176 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1177 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1180 static unsigned int gateway9200_m4_pin_configs[8] = {
1181 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1182 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1184 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1185 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1186 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1190 STAC 9200 pin configs for
1195 static unsigned int dell9200_d21_pin_configs[8] = {
1196 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1197 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1201 STAC 9200 pin configs for
1205 static unsigned int dell9200_d22_pin_configs[8] = {
1206 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1207 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1211 STAC 9200 pin configs for
1212 102801C4 (Dell Dimension E310)
1219 static unsigned int dell9200_d23_pin_configs[8] = {
1220 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1221 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1226 STAC 9200-32 pin configs for
1227 102801B5 (Dell Inspiron 630m)
1228 102801D8 (Dell Inspiron 640m)
1230 static unsigned int dell9200_m21_pin_configs[8] = {
1231 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1232 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1236 STAC 9200-32 pin configs for
1237 102801C2 (Dell Latitude D620)
1239 102801CC (Dell Latitude D820)
1243 static unsigned int dell9200_m22_pin_configs[8] = {
1244 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1245 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1249 STAC 9200-32 pin configs for
1250 102801CE (Dell XPS M1710)
1251 102801CF (Dell Precision M90)
1253 static unsigned int dell9200_m23_pin_configs[8] = {
1254 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1255 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1259 STAC 9200-32 pin configs for
1262 102801CB (Dell Latitude 120L)
1265 static unsigned int dell9200_m24_pin_configs[8] = {
1266 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1267 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1271 STAC 9200-32 pin configs for
1272 102801BD (Dell Inspiron E1505n)
1276 static unsigned int dell9200_m25_pin_configs[8] = {
1277 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1278 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1282 STAC 9200-32 pin configs for
1283 102801F5 (Dell Inspiron 1501)
1286 static unsigned int dell9200_m26_pin_configs[8] = {
1287 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1288 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1293 102801CD (Dell Inspiron E1705/9400)
1295 static unsigned int dell9200_m27_pin_configs[8] = {
1296 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1297 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1300 static unsigned int oqo9200_pin_configs[8] = {
1301 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1302 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1306 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1307 [STAC_REF] = ref9200_pin_configs,
1308 [STAC_9200_OQO] = oqo9200_pin_configs,
1309 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1310 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1311 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1312 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1313 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1314 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1315 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1316 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1317 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1318 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1319 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1320 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1321 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1324 static const char *stac9200_models[STAC_9200_MODELS] = {
1325 [STAC_AUTO] = "auto",
1327 [STAC_9200_OQO] = "oqo",
1328 [STAC_9200_DELL_D21] = "dell-d21",
1329 [STAC_9200_DELL_D22] = "dell-d22",
1330 [STAC_9200_DELL_D23] = "dell-d23",
1331 [STAC_9200_DELL_M21] = "dell-m21",
1332 [STAC_9200_DELL_M22] = "dell-m22",
1333 [STAC_9200_DELL_M23] = "dell-m23",
1334 [STAC_9200_DELL_M24] = "dell-m24",
1335 [STAC_9200_DELL_M25] = "dell-m25",
1336 [STAC_9200_DELL_M26] = "dell-m26",
1337 [STAC_9200_DELL_M27] = "dell-m27",
1338 [STAC_9200_M4] = "gateway-m4",
1339 [STAC_9200_M4_2] = "gateway-m4-2",
1340 [STAC_9200_PANASONIC] = "panasonic",
1343 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1344 /* SigmaTel reference board */
1345 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1346 "DFI LanParty", STAC_REF),
1347 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1348 "DFI LanParty", STAC_REF),
1349 /* Dell laptops have BIOS problem */
1350 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1351 "unknown Dell", STAC_9200_DELL_D21),
1352 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1353 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1354 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1355 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1356 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1357 "unknown Dell", STAC_9200_DELL_D22),
1358 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1359 "unknown Dell", STAC_9200_DELL_D22),
1360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1361 "Dell Latitude D620", STAC_9200_DELL_M22),
1362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1363 "unknown Dell", STAC_9200_DELL_D23),
1364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1365 "unknown Dell", STAC_9200_DELL_D23),
1366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1367 "unknown Dell", STAC_9200_DELL_M22),
1368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1369 "unknown Dell", STAC_9200_DELL_M24),
1370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1371 "unknown Dell", STAC_9200_DELL_M24),
1372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1373 "Dell Latitude 120L", STAC_9200_DELL_M24),
1374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1375 "Dell Latitude D820", STAC_9200_DELL_M22),
1376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1377 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1379 "Dell XPS M1710", STAC_9200_DELL_M23),
1380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1381 "Dell Precision M90", STAC_9200_DELL_M23),
1382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1383 "unknown Dell", STAC_9200_DELL_M22),
1384 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1385 "unknown Dell", STAC_9200_DELL_M22),
1386 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1387 "unknown Dell", STAC_9200_DELL_M22),
1388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1389 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1390 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1391 "unknown Dell", STAC_9200_DELL_D23),
1392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1393 "unknown Dell", STAC_9200_DELL_D23),
1394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1395 "unknown Dell", STAC_9200_DELL_D21),
1396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1397 "unknown Dell", STAC_9200_DELL_D23),
1398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1399 "unknown Dell", STAC_9200_DELL_D21),
1400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1401 "unknown Dell", STAC_9200_DELL_M25),
1402 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1403 "unknown Dell", STAC_9200_DELL_M25),
1404 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1405 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1406 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1407 "unknown Dell", STAC_9200_DELL_M26),
1409 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1410 /* Gateway machines needs EAPD to be set on resume */
1411 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1412 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1413 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1415 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1419 static unsigned int ref925x_pin_configs[8] = {
1420 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1421 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1424 static unsigned int stac925xM1_pin_configs[8] = {
1425 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1426 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1429 static unsigned int stac925xM1_2_pin_configs[8] = {
1430 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1431 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1434 static unsigned int stac925xM2_pin_configs[8] = {
1435 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1436 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1439 static unsigned int stac925xM2_2_pin_configs[8] = {
1440 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1441 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1444 static unsigned int stac925xM3_pin_configs[8] = {
1445 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1446 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1449 static unsigned int stac925xM5_pin_configs[8] = {
1450 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1451 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1454 static unsigned int stac925xM6_pin_configs[8] = {
1455 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1456 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1459 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1460 [STAC_REF] = ref925x_pin_configs,
1461 [STAC_M1] = stac925xM1_pin_configs,
1462 [STAC_M1_2] = stac925xM1_2_pin_configs,
1463 [STAC_M2] = stac925xM2_pin_configs,
1464 [STAC_M2_2] = stac925xM2_2_pin_configs,
1465 [STAC_M3] = stac925xM3_pin_configs,
1466 [STAC_M5] = stac925xM5_pin_configs,
1467 [STAC_M6] = stac925xM6_pin_configs,
1470 static const char *stac925x_models[STAC_925x_MODELS] = {
1471 [STAC_925x_AUTO] = "auto",
1474 [STAC_M1_2] = "m1-2",
1476 [STAC_M2_2] = "m2-2",
1482 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1483 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1484 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1485 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1486 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1487 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1488 /* Not sure about the brand name for those */
1489 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1490 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1491 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1492 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1496 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1497 /* SigmaTel reference board */
1498 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1499 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1500 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1502 /* Default table for unknown ID */
1503 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1508 static unsigned int ref92hd73xx_pin_configs[13] = {
1509 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1510 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1511 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1515 static unsigned int dell_m6_pin_configs[13] = {
1516 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1517 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1518 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1522 static unsigned int alienware_m17x_pin_configs[13] = {
1523 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1524 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1525 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1529 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1530 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1531 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1532 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1533 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1534 [STAC_DELL_EQ] = dell_m6_pin_configs,
1535 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
1538 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1539 [STAC_92HD73XX_AUTO] = "auto",
1540 [STAC_92HD73XX_NO_JD] = "no-jd",
1541 [STAC_92HD73XX_REF] = "ref",
1542 [STAC_92HD73XX_INTEL] = "intel",
1543 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1544 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1545 [STAC_DELL_M6_BOTH] = "dell-m6",
1546 [STAC_DELL_EQ] = "dell-eq",
1547 [STAC_ALIENWARE_M17X] = "alienware",
1550 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1551 /* SigmaTel reference board */
1552 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1553 "DFI LanParty", STAC_92HD73XX_REF),
1554 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1555 "DFI LanParty", STAC_92HD73XX_REF),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1557 "Intel DG45ID", STAC_92HD73XX_INTEL),
1558 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1559 "Intel DG45FC", STAC_92HD73XX_INTEL),
1560 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1561 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1562 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1563 "unknown Dell", STAC_DELL_M6_DMIC),
1564 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1565 "unknown Dell", STAC_DELL_M6_BOTH),
1566 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1567 "unknown Dell", STAC_DELL_M6_BOTH),
1568 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1569 "unknown Dell", STAC_DELL_M6_AMIC),
1570 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1571 "unknown Dell", STAC_DELL_M6_AMIC),
1572 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1573 "unknown Dell", STAC_DELL_M6_DMIC),
1574 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1575 "unknown Dell", STAC_DELL_M6_DMIC),
1576 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1577 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1578 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1579 "Dell Studio 17", STAC_DELL_M6_DMIC),
1580 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1581 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1585 static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1586 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1587 "Alienware M17x", STAC_ALIENWARE_M17X),
1591 static unsigned int ref92hd83xxx_pin_configs[10] = {
1592 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1593 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1594 0x01451160, 0x98560170,
1597 static unsigned int dell_s14_pin_configs[10] = {
1598 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1599 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
1600 0x40f000f0, 0x40f000f0,
1603 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1604 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1605 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1606 [STAC_DELL_S14] = dell_s14_pin_configs,
1609 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1610 [STAC_92HD83XXX_AUTO] = "auto",
1611 [STAC_92HD83XXX_REF] = "ref",
1612 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1613 [STAC_DELL_S14] = "dell-s14",
1616 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1617 /* SigmaTel reference board */
1618 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1619 "DFI LanParty", STAC_92HD83XXX_REF),
1620 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1621 "DFI LanParty", STAC_92HD83XXX_REF),
1622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1623 "unknown Dell", STAC_DELL_S14),
1627 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1628 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1629 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1630 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1634 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1635 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1636 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1637 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1641 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1642 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1643 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1644 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1648 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1649 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1650 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1651 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1655 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1656 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1657 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1658 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1659 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1660 [STAC_HP_M4] = NULL,
1661 [STAC_HP_DV5] = NULL,
1662 [STAC_HP_HDX] = NULL,
1663 [STAC_HP_DV4_1222NR] = NULL,
1666 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1667 [STAC_92HD71BXX_AUTO] = "auto",
1668 [STAC_92HD71BXX_REF] = "ref",
1669 [STAC_DELL_M4_1] = "dell-m4-1",
1670 [STAC_DELL_M4_2] = "dell-m4-2",
1671 [STAC_DELL_M4_3] = "dell-m4-3",
1672 [STAC_HP_M4] = "hp-m4",
1673 [STAC_HP_DV5] = "hp-dv5",
1674 [STAC_HP_HDX] = "hp-hdx",
1675 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1678 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1679 /* SigmaTel reference board */
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1681 "DFI LanParty", STAC_92HD71BXX_REF),
1682 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1683 "DFI LanParty", STAC_92HD71BXX_REF),
1684 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1685 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1686 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1688 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1689 "HP dv4-7", STAC_HP_DV5),
1690 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1691 "HP dv4-7", STAC_HP_DV5),
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1693 "HP HDX", STAC_HP_HDX), /* HDX18 */
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1695 "HP mini 1000", STAC_HP_M4),
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1697 "HP HDX", STAC_HP_HDX), /* HDX16 */
1698 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1699 "HP dv6", STAC_HP_DV5),
1700 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1703 "unknown Dell", STAC_DELL_M4_1),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1705 "unknown Dell", STAC_DELL_M4_1),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1707 "unknown Dell", STAC_DELL_M4_1),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1709 "unknown Dell", STAC_DELL_M4_1),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1711 "unknown Dell", STAC_DELL_M4_1),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1713 "unknown Dell", STAC_DELL_M4_1),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1715 "unknown Dell", STAC_DELL_M4_1),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1717 "unknown Dell", STAC_DELL_M4_2),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1719 "unknown Dell", STAC_DELL_M4_2),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1721 "unknown Dell", STAC_DELL_M4_2),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1723 "unknown Dell", STAC_DELL_M4_2),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1725 "unknown Dell", STAC_DELL_M4_3),
1729 static unsigned int ref922x_pin_configs[10] = {
1730 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1731 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1732 0x40000100, 0x40000100,
1736 STAC 922X pin configs for
1743 static unsigned int dell_922x_d81_pin_configs[10] = {
1744 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1745 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1746 0x01813122, 0x400001f2,
1750 STAC 922X pin configs for
1754 static unsigned int dell_922x_d82_pin_configs[10] = {
1755 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1756 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1757 0x01813122, 0x400001f1,
1761 STAC 922X pin configs for
1764 static unsigned int dell_922x_m81_pin_configs[10] = {
1765 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1766 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1767 0x40C003f1, 0x405003f0,
1771 STAC 9221 A1 pin configs for
1772 102801D7 (Dell XPS M1210)
1774 static unsigned int dell_922x_m82_pin_configs[10] = {
1775 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1776 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1777 0x508003f3, 0x405003f4,
1780 static unsigned int d945gtp3_pin_configs[10] = {
1781 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1782 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1783 0x02a19120, 0x40000100,
1786 static unsigned int d945gtp5_pin_configs[10] = {
1787 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1788 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1789 0x02a19320, 0x40000100,
1792 static unsigned int intel_mac_v1_pin_configs[10] = {
1793 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1794 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1795 0x400000fc, 0x400000fb,
1798 static unsigned int intel_mac_v2_pin_configs[10] = {
1799 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1800 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1801 0x400000fc, 0x400000fb,
1804 static unsigned int intel_mac_v3_pin_configs[10] = {
1805 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1806 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1807 0x400000fc, 0x400000fb,
1810 static unsigned int intel_mac_v4_pin_configs[10] = {
1811 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1812 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1813 0x400000fc, 0x400000fb,
1816 static unsigned int intel_mac_v5_pin_configs[10] = {
1817 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1818 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1819 0x400000fc, 0x400000fb,
1822 static unsigned int ecs202_pin_configs[10] = {
1823 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1824 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1825 0x9037012e, 0x40e000f2,
1828 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1829 [STAC_D945_REF] = ref922x_pin_configs,
1830 [STAC_D945GTP3] = d945gtp3_pin_configs,
1831 [STAC_D945GTP5] = d945gtp5_pin_configs,
1832 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1833 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1834 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1835 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1836 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1837 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1838 /* for backward compatibility */
1839 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1840 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1841 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1842 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1843 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1844 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1845 [STAC_ECS_202] = ecs202_pin_configs,
1846 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1847 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1848 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1849 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1852 static const char *stac922x_models[STAC_922X_MODELS] = {
1853 [STAC_922X_AUTO] = "auto",
1854 [STAC_D945_REF] = "ref",
1855 [STAC_D945GTP5] = "5stack",
1856 [STAC_D945GTP3] = "3stack",
1857 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1858 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1859 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1860 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1861 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1862 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1863 /* for backward compatibility */
1864 [STAC_MACMINI] = "macmini",
1865 [STAC_MACBOOK] = "macbook",
1866 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1867 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1868 [STAC_IMAC_INTEL] = "imac-intel",
1869 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1870 [STAC_ECS_202] = "ecs202",
1871 [STAC_922X_DELL_D81] = "dell-d81",
1872 [STAC_922X_DELL_D82] = "dell-d82",
1873 [STAC_922X_DELL_M81] = "dell-m81",
1874 [STAC_922X_DELL_M82] = "dell-m82",
1877 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1878 /* SigmaTel reference board */
1879 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1880 "DFI LanParty", STAC_D945_REF),
1881 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1882 "DFI LanParty", STAC_D945_REF),
1883 /* Intel 945G based systems */
1884 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1885 "Intel D945G", STAC_D945GTP3),
1886 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1887 "Intel D945G", STAC_D945GTP3),
1888 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1889 "Intel D945G", STAC_D945GTP3),
1890 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1891 "Intel D945G", STAC_D945GTP3),
1892 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1893 "Intel D945G", STAC_D945GTP3),
1894 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1895 "Intel D945G", STAC_D945GTP3),
1896 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1897 "Intel D945G", STAC_D945GTP3),
1898 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1899 "Intel D945G", STAC_D945GTP3),
1900 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1901 "Intel D945G", STAC_D945GTP3),
1902 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1903 "Intel D945G", STAC_D945GTP3),
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1905 "Intel D945G", STAC_D945GTP3),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1907 "Intel D945G", STAC_D945GTP3),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1909 "Intel D945G", STAC_D945GTP3),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1911 "Intel D945G", STAC_D945GTP3),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1913 "Intel D945G", STAC_D945GTP3),
1914 /* Intel D945G 5-stack systems */
1915 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1916 "Intel D945G", STAC_D945GTP5),
1917 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1918 "Intel D945G", STAC_D945GTP5),
1919 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1920 "Intel D945G", STAC_D945GTP5),
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1922 "Intel D945G", STAC_D945GTP5),
1923 /* Intel 945P based systems */
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1925 "Intel D945P", STAC_D945GTP3),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1927 "Intel D945P", STAC_D945GTP3),
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1929 "Intel D945P", STAC_D945GTP3),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1931 "Intel D945P", STAC_D945GTP3),
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1933 "Intel D945P", STAC_D945GTP3),
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1935 "Intel D945P", STAC_D945GTP5),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
1938 "Intel D945", STAC_D945_REF),
1940 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1941 SND_PCI_QUIRK(0x8384, 0x7680,
1942 "Mac", STAC_INTEL_MAC_AUTO),
1944 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1945 "unknown Dell", STAC_922X_DELL_D81),
1946 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1947 "unknown Dell", STAC_922X_DELL_D81),
1948 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1949 "unknown Dell", STAC_922X_DELL_D81),
1950 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1951 "unknown Dell", STAC_922X_DELL_D82),
1952 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1953 "unknown Dell", STAC_922X_DELL_M81),
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1955 "unknown Dell", STAC_922X_DELL_D82),
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1957 "unknown Dell", STAC_922X_DELL_D81),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1959 "unknown Dell", STAC_922X_DELL_D81),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1961 "Dell XPS M1210", STAC_922X_DELL_M82),
1962 /* ECS/PC Chips boards */
1963 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
1964 "ECS/PC chips", STAC_ECS_202),
1968 static unsigned int ref927x_pin_configs[14] = {
1969 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1970 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1971 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1972 0x01c42190, 0x40000100,
1975 static unsigned int d965_3st_pin_configs[14] = {
1976 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1977 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1978 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1979 0x40000100, 0x40000100
1982 static unsigned int d965_5st_pin_configs[14] = {
1983 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1984 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1985 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1986 0x40000100, 0x40000100
1989 static unsigned int d965_5st_no_fp_pin_configs[14] = {
1990 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
1991 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1992 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1993 0x40000100, 0x40000100
1996 static unsigned int dell_3st_pin_configs[14] = {
1997 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1998 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1999 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2000 0x40c003fc, 0x40000100
2003 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2004 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2005 [STAC_D965_REF] = ref927x_pin_configs,
2006 [STAC_D965_3ST] = d965_3st_pin_configs,
2007 [STAC_D965_5ST] = d965_5st_pin_configs,
2008 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2009 [STAC_DELL_3ST] = dell_3st_pin_configs,
2010 [STAC_DELL_BIOS] = NULL,
2011 [STAC_927X_VOLKNOB] = NULL,
2014 static const char *stac927x_models[STAC_927X_MODELS] = {
2015 [STAC_927X_AUTO] = "auto",
2016 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2017 [STAC_D965_REF] = "ref",
2018 [STAC_D965_3ST] = "3stack",
2019 [STAC_D965_5ST] = "5stack",
2020 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2021 [STAC_DELL_3ST] = "dell-3stack",
2022 [STAC_DELL_BIOS] = "dell-bios",
2023 [STAC_927X_VOLKNOB] = "volknob",
2026 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2027 /* SigmaTel reference board */
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2029 "DFI LanParty", STAC_D965_REF),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2031 "DFI LanParty", STAC_D965_REF),
2032 /* Intel 946 based systems */
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2035 /* 965 based 3 stack systems */
2036 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2037 "Intel D965", STAC_D965_3ST),
2038 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2039 "Intel D965", STAC_D965_3ST),
2040 /* Dell 3 stack systems */
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2045 /* Dell 3 stack systems with verb table in BIOS */
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2054 /* 965 based 5 stack systems */
2055 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2056 "Intel D965", STAC_D965_5ST),
2057 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2058 "Intel D965", STAC_D965_5ST),
2059 /* volume-knob fixes */
2060 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
2064 static unsigned int ref9205_pin_configs[12] = {
2065 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2066 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2067 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2071 STAC 9205 pin configs for
2078 10280228 (Dell Vostro 1500)
2080 static unsigned int dell_9205_m42_pin_configs[12] = {
2081 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2082 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2083 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2087 STAC 9205 pin configs for
2091 102801FF (Dell Precision M4300)
2096 static unsigned int dell_9205_m43_pin_configs[12] = {
2097 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2098 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2099 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2102 static unsigned int dell_9205_m44_pin_configs[12] = {
2103 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2104 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2105 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2108 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2109 [STAC_9205_REF] = ref9205_pin_configs,
2110 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2111 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2112 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2113 [STAC_9205_EAPD] = NULL,
2116 static const char *stac9205_models[STAC_9205_MODELS] = {
2117 [STAC_9205_AUTO] = "auto",
2118 [STAC_9205_REF] = "ref",
2119 [STAC_9205_DELL_M42] = "dell-m42",
2120 [STAC_9205_DELL_M43] = "dell-m43",
2121 [STAC_9205_DELL_M44] = "dell-m44",
2122 [STAC_9205_EAPD] = "eapd",
2125 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2126 /* SigmaTel reference board */
2127 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2128 "DFI LanParty", STAC_9205_REF),
2129 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2130 "SigmaTel", STAC_9205_REF),
2131 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2132 "DFI LanParty", STAC_9205_REF),
2134 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2135 "unknown Dell", STAC_9205_DELL_M42),
2136 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2137 "unknown Dell", STAC_9205_DELL_M42),
2138 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2139 "Dell Precision", STAC_9205_DELL_M43),
2140 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2141 "Dell Precision", STAC_9205_DELL_M43),
2142 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2143 "Dell Precision", STAC_9205_DELL_M43),
2144 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2145 "unknown Dell", STAC_9205_DELL_M42),
2146 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2147 "unknown Dell", STAC_9205_DELL_M42),
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2149 "Dell Precision", STAC_9205_DELL_M43),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2151 "Dell Precision M4300", STAC_9205_DELL_M43),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2153 "unknown Dell", STAC_9205_DELL_M42),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2155 "Dell Precision", STAC_9205_DELL_M43),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2157 "Dell Precision", STAC_9205_DELL_M43),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2159 "Dell Precision", STAC_9205_DELL_M43),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2161 "Dell Inspiron", STAC_9205_DELL_M44),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2163 "Dell Vostro 1500", STAC_9205_DELL_M42),
2165 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2166 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2170 static void stac92xx_set_config_regs(struct hda_codec *codec,
2171 unsigned int *pincfgs)
2174 struct sigmatel_spec *spec = codec->spec;
2179 for (i = 0; i < spec->num_pins; i++)
2180 if (spec->pin_nids[i] && pincfgs[i])
2181 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2186 * Analog playback callbacks
2188 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2189 struct hda_codec *codec,
2190 struct snd_pcm_substream *substream)
2192 struct sigmatel_spec *spec = codec->spec;
2193 if (spec->stream_delay)
2194 msleep(spec->stream_delay);
2195 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2199 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2200 struct hda_codec *codec,
2201 unsigned int stream_tag,
2202 unsigned int format,
2203 struct snd_pcm_substream *substream)
2205 struct sigmatel_spec *spec = codec->spec;
2206 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2209 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2210 struct hda_codec *codec,
2211 struct snd_pcm_substream *substream)
2213 struct sigmatel_spec *spec = codec->spec;
2214 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2218 * Digital playback callbacks
2220 static int stac92xx_dig_playback_pcm_open(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_open(codec, &spec->multiout);
2228 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2229 struct hda_codec *codec,
2230 struct snd_pcm_substream *substream)
2232 struct sigmatel_spec *spec = codec->spec;
2233 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2236 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2237 struct hda_codec *codec,
2238 unsigned int stream_tag,
2239 unsigned int format,
2240 struct snd_pcm_substream *substream)
2242 struct sigmatel_spec *spec = codec->spec;
2243 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2244 stream_tag, format, substream);
2247 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2248 struct hda_codec *codec,
2249 struct snd_pcm_substream *substream)
2251 struct sigmatel_spec *spec = codec->spec;
2252 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2257 * Analog capture callbacks
2259 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2260 struct hda_codec *codec,
2261 unsigned int stream_tag,
2262 unsigned int format,
2263 struct snd_pcm_substream *substream)
2265 struct sigmatel_spec *spec = codec->spec;
2266 hda_nid_t nid = spec->adc_nids[substream->number];
2268 if (spec->powerdown_adcs) {
2270 snd_hda_codec_write(codec, nid, 0,
2271 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2273 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2277 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2278 struct hda_codec *codec,
2279 struct snd_pcm_substream *substream)
2281 struct sigmatel_spec *spec = codec->spec;
2282 hda_nid_t nid = spec->adc_nids[substream->number];
2284 snd_hda_codec_cleanup_stream(codec, nid);
2285 if (spec->powerdown_adcs)
2286 snd_hda_codec_write(codec, nid, 0,
2287 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2291 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2295 /* NID is set in stac92xx_build_pcms */
2297 .open = stac92xx_dig_playback_pcm_open,
2298 .close = stac92xx_dig_playback_pcm_close,
2299 .prepare = stac92xx_dig_playback_pcm_prepare,
2300 .cleanup = stac92xx_dig_playback_pcm_cleanup
2304 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2308 /* NID is set in stac92xx_build_pcms */
2311 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2315 .nid = 0x02, /* NID to query formats and rates */
2317 .open = stac92xx_playback_pcm_open,
2318 .prepare = stac92xx_playback_pcm_prepare,
2319 .cleanup = stac92xx_playback_pcm_cleanup
2323 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2327 .nid = 0x06, /* NID to query formats and rates */
2329 .open = stac92xx_playback_pcm_open,
2330 .prepare = stac92xx_playback_pcm_prepare,
2331 .cleanup = stac92xx_playback_pcm_cleanup
2335 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2338 /* NID + .substreams is set in stac92xx_build_pcms */
2340 .prepare = stac92xx_capture_pcm_prepare,
2341 .cleanup = stac92xx_capture_pcm_cleanup
2345 static int stac92xx_build_pcms(struct hda_codec *codec)
2347 struct sigmatel_spec *spec = codec->spec;
2348 struct hda_pcm *info = spec->pcm_rec;
2350 codec->num_pcms = 1;
2351 codec->pcm_info = info;
2353 info->name = "STAC92xx Analog";
2354 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2355 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2356 spec->multiout.dac_nids[0];
2357 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2358 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2359 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2361 if (spec->alt_switch) {
2364 info->name = "STAC92xx Analog Alt";
2365 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2368 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2371 info->name = "STAC92xx Digital";
2372 info->pcm_type = spec->autocfg.dig_out_type[0];
2373 if (spec->multiout.dig_out_nid) {
2374 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2375 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2377 if (spec->dig_in_nid) {
2378 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2379 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2386 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2389 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2390 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2391 if (pincap & AC_PINCAP_VREF_100)
2392 return AC_PINCTL_VREF_100;
2393 if (pincap & AC_PINCAP_VREF_80)
2394 return AC_PINCTL_VREF_80;
2395 if (pincap & AC_PINCAP_VREF_50)
2396 return AC_PINCTL_VREF_50;
2397 if (pincap & AC_PINCAP_VREF_GRD)
2398 return AC_PINCTL_VREF_GRD;
2402 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2405 snd_hda_codec_write_cache(codec, nid, 0,
2406 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2409 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2411 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2412 struct snd_ctl_elem_value *ucontrol)
2414 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2415 struct sigmatel_spec *spec = codec->spec;
2417 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2421 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2423 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2424 struct snd_ctl_elem_value *ucontrol)
2426 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2427 struct sigmatel_spec *spec = codec->spec;
2428 int nid = kcontrol->private_value;
2430 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2432 /* check to be sure that the ports are upto date with
2435 stac_issue_unsol_event(codec, nid);
2440 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2441 struct snd_ctl_elem_info *uinfo)
2444 static char *texts[] = {
2445 "Mic In", "Line In", "Line Out"
2448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2449 struct sigmatel_spec *spec = codec->spec;
2450 hda_nid_t nid = kcontrol->private_value;
2452 if (nid == spec->mic_switch || nid == spec->line_switch)
2457 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2458 uinfo->value.enumerated.items = i;
2460 if (uinfo->value.enumerated.item >= i)
2461 uinfo->value.enumerated.item = i-1;
2462 strcpy(uinfo->value.enumerated.name,
2463 texts[uinfo->value.enumerated.item]);
2468 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2469 struct snd_ctl_elem_value *ucontrol)
2471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2472 hda_nid_t nid = kcontrol->private_value;
2473 unsigned int vref = stac92xx_vref_get(codec, nid);
2475 if (vref == stac92xx_get_default_vref(codec, nid))
2476 ucontrol->value.enumerated.item[0] = 0;
2477 else if (vref == AC_PINCTL_VREF_GRD)
2478 ucontrol->value.enumerated.item[0] = 1;
2479 else if (vref == AC_PINCTL_VREF_HIZ)
2480 ucontrol->value.enumerated.item[0] = 2;
2485 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2486 struct snd_ctl_elem_value *ucontrol)
2488 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2489 unsigned int new_vref = 0;
2491 hda_nid_t nid = kcontrol->private_value;
2493 if (ucontrol->value.enumerated.item[0] == 0)
2494 new_vref = stac92xx_get_default_vref(codec, nid);
2495 else if (ucontrol->value.enumerated.item[0] == 1)
2496 new_vref = AC_PINCTL_VREF_GRD;
2497 else if (ucontrol->value.enumerated.item[0] == 2)
2498 new_vref = AC_PINCTL_VREF_HIZ;
2502 if (new_vref != stac92xx_vref_get(codec, nid)) {
2503 error = stac92xx_vref_set(codec, nid, new_vref);
2510 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2511 struct snd_ctl_elem_info *uinfo)
2513 static char *texts[2];
2514 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2515 struct sigmatel_spec *spec = codec->spec;
2517 if (kcontrol->private_value == spec->line_switch)
2518 texts[0] = "Line In";
2520 texts[0] = "Mic In";
2521 texts[1] = "Line Out";
2522 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2523 uinfo->value.enumerated.items = 2;
2526 if (uinfo->value.enumerated.item >= 2)
2527 uinfo->value.enumerated.item = 1;
2528 strcpy(uinfo->value.enumerated.name,
2529 texts[uinfo->value.enumerated.item]);
2534 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2537 struct sigmatel_spec *spec = codec->spec;
2538 hda_nid_t nid = kcontrol->private_value;
2539 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2541 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2545 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2547 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2548 struct sigmatel_spec *spec = codec->spec;
2549 hda_nid_t nid = kcontrol->private_value;
2550 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2551 unsigned short val = !!ucontrol->value.enumerated.item[0];
2553 spec->io_switch[io_idx] = val;
2556 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2558 unsigned int pinctl = AC_PINCTL_IN_EN;
2559 if (io_idx) /* set VREF for mic */
2560 pinctl |= stac92xx_get_default_vref(codec, nid);
2561 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2564 /* check the auto-mute again: we need to mute/unmute the speaker
2565 * appropriately according to the pin direction
2567 if (spec->hp_detect)
2568 stac_issue_unsol_event(codec, nid);
2573 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2575 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2576 struct snd_ctl_elem_value *ucontrol)
2578 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2579 struct sigmatel_spec *spec = codec->spec;
2581 ucontrol->value.integer.value[0] = spec->clfe_swap;
2585 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2586 struct snd_ctl_elem_value *ucontrol)
2588 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2589 struct sigmatel_spec *spec = codec->spec;
2590 hda_nid_t nid = kcontrol->private_value & 0xff;
2591 unsigned int val = !!ucontrol->value.integer.value[0];
2593 if (spec->clfe_swap == val)
2596 spec->clfe_swap = val;
2598 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2599 spec->clfe_swap ? 0x4 : 0x0);
2604 #define STAC_CODEC_HP_SWITCH(xname) \
2605 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2608 .info = stac92xx_hp_switch_info, \
2609 .get = stac92xx_hp_switch_get, \
2610 .put = stac92xx_hp_switch_put, \
2613 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2614 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2617 .info = stac92xx_io_switch_info, \
2618 .get = stac92xx_io_switch_get, \
2619 .put = stac92xx_io_switch_put, \
2620 .private_value = xpval, \
2623 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2624 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2627 .info = stac92xx_clfe_switch_info, \
2628 .get = stac92xx_clfe_switch_get, \
2629 .put = stac92xx_clfe_switch_put, \
2630 .private_value = xpval, \
2634 STAC_CTL_WIDGET_VOL,
2635 STAC_CTL_WIDGET_MUTE,
2636 STAC_CTL_WIDGET_MONO_MUX,
2637 STAC_CTL_WIDGET_HP_SWITCH,
2638 STAC_CTL_WIDGET_IO_SWITCH,
2639 STAC_CTL_WIDGET_CLFE_SWITCH,
2640 STAC_CTL_WIDGET_DC_BIAS
2643 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2644 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2645 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2647 STAC_CODEC_HP_SWITCH(NULL),
2648 STAC_CODEC_IO_SWITCH(NULL, 0),
2649 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2650 DC_BIAS(NULL, 0, 0),
2653 /* add dynamic controls */
2654 static struct snd_kcontrol_new *
2655 stac_control_new(struct sigmatel_spec *spec,
2656 struct snd_kcontrol_new *ktemp,
2659 struct snd_kcontrol_new *knew;
2661 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2662 knew = snd_array_new(&spec->kctls);
2666 knew->name = kstrdup(name, GFP_KERNEL);
2669 memset(knew, 0, sizeof(*knew));
2670 spec->kctls.alloced--;
2676 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2677 struct snd_kcontrol_new *ktemp,
2678 int idx, const char *name,
2681 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2685 knew->private_value = val;
2689 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2690 int type, int idx, const char *name,
2693 return stac92xx_add_control_temp(spec,
2694 &stac92xx_control_templates[type],
2699 /* add dynamic controls */
2700 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2701 const char *name, unsigned long val)
2703 return stac92xx_add_control_idx(spec, type, 0, name, val);
2706 static struct snd_kcontrol_new stac_input_src_temp = {
2707 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2708 .name = "Input Source",
2709 .info = stac92xx_mux_enum_info,
2710 .get = stac92xx_mux_enum_get,
2711 .put = stac92xx_mux_enum_put,
2714 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2715 hda_nid_t nid, int idx)
2717 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2719 struct sigmatel_spec *spec = codec->spec;
2722 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2723 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2724 && nid == spec->line_switch)
2725 control = STAC_CTL_WIDGET_IO_SWITCH;
2726 else if (snd_hda_query_pin_caps(codec, nid)
2727 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2728 control = STAC_CTL_WIDGET_DC_BIAS;
2729 else if (nid == spec->mic_switch)
2730 control = STAC_CTL_WIDGET_IO_SWITCH;
2734 strcpy(name, auto_pin_cfg_labels[idx]);
2735 return stac92xx_add_control(codec->spec, control,
2736 strcat(name, " Jack Mode"), nid);
2742 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2744 struct snd_kcontrol_new *knew;
2745 struct hda_input_mux *imux = &spec->private_imux;
2748 return 0; /* no need for input source */
2749 if (!spec->num_adcs || imux->num_items <= 1)
2750 return 0; /* no need for input source control */
2751 knew = stac_control_new(spec, &stac_input_src_temp,
2752 stac_input_src_temp.name);
2755 knew->count = spec->num_adcs;
2759 /* check whether the line-input can be used as line-out */
2760 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2762 struct sigmatel_spec *spec = codec->spec;
2763 struct auto_pin_cfg *cfg = &spec->autocfg;
2765 unsigned int pincap;
2767 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2769 nid = cfg->input_pins[AUTO_PIN_LINE];
2770 pincap = snd_hda_query_pin_caps(codec, nid);
2771 if (pincap & AC_PINCAP_OUT)
2776 /* check whether the mic-input can be used as line-out */
2777 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2779 struct sigmatel_spec *spec = codec->spec;
2780 struct auto_pin_cfg *cfg = &spec->autocfg;
2781 unsigned int def_conf, pincap;
2782 unsigned int mic_pin;
2784 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2786 mic_pin = AUTO_PIN_MIC;
2788 hda_nid_t nid = cfg->input_pins[mic_pin];
2789 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2790 /* some laptops have an internal analog microphone
2791 * which can't be used as a output */
2792 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2793 pincap = snd_hda_query_pin_caps(codec, nid);
2794 if (pincap & AC_PINCAP_OUT)
2797 if (mic_pin == AUTO_PIN_MIC)
2798 mic_pin = AUTO_PIN_FRONT_MIC;
2805 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2809 for (i = 0; i < spec->multiout.num_dacs; i++) {
2810 if (spec->multiout.dac_nids[i] == nid)
2817 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2820 if (is_in_dac_nids(spec, nid))
2822 for (i = 0; i < spec->autocfg.hp_outs; i++)
2823 if (spec->hp_dacs[i] == nid)
2825 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2826 if (spec->speaker_dacs[i] == nid)
2831 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2833 struct sigmatel_spec *spec = codec->spec;
2835 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2836 unsigned int wcaps, wtype;
2838 conn_len = snd_hda_get_connections(codec, nid, conn,
2839 HDA_MAX_CONNECTIONS);
2840 for (j = 0; j < conn_len; j++) {
2841 wcaps = get_wcaps(codec, conn[j]);
2842 wtype = get_wcaps_type(wcaps);
2843 /* we check only analog outputs */
2844 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2846 /* if this route has a free DAC, assign it */
2847 if (!check_all_dac_nids(spec, conn[j])) {
2849 /* select this DAC in the pin's input mux */
2850 snd_hda_codec_write_cache(codec, nid, 0,
2851 AC_VERB_SET_CONNECT_SEL, j);
2856 /* if all DACs are already assigned, connect to the primary DAC */
2858 for (j = 0; j < conn_len; j++) {
2859 if (conn[j] == spec->multiout.dac_nids[0]) {
2860 snd_hda_codec_write_cache(codec, nid, 0,
2861 AC_VERB_SET_CONNECT_SEL, j);
2869 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2870 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2873 * Fill in the dac_nids table from the parsed pin configuration
2874 * This function only works when every pin in line_out_pins[]
2875 * contains atleast one DAC in its connection list. Some 92xx
2876 * codecs are not connected directly to a DAC, such as the 9200
2877 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2879 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2881 struct sigmatel_spec *spec = codec->spec;
2882 struct auto_pin_cfg *cfg = &spec->autocfg;
2886 for (i = 0; i < cfg->line_outs; i++) {
2887 nid = cfg->line_out_pins[i];
2888 dac = get_unassigned_dac(codec, nid);
2890 if (spec->multiout.num_dacs > 0) {
2891 /* we have already working output pins,
2892 * so let's drop the broken ones again
2894 cfg->line_outs = spec->multiout.num_dacs;
2897 /* error out, no available DAC found */
2899 "%s: No available DAC for pin 0x%x\n",
2903 add_spec_dacs(spec, dac);
2906 for (i = 0; i < cfg->hp_outs; i++) {
2907 nid = cfg->hp_pins[i];
2908 dac = get_unassigned_dac(codec, nid);
2910 if (!spec->multiout.hp_nid)
2911 spec->multiout.hp_nid = dac;
2913 add_spec_extra_dacs(spec, dac);
2915 spec->hp_dacs[i] = dac;
2918 for (i = 0; i < cfg->speaker_outs; i++) {
2919 nid = cfg->speaker_pins[i];
2920 dac = get_unassigned_dac(codec, nid);
2922 add_spec_extra_dacs(spec, dac);
2923 spec->speaker_dacs[i] = dac;
2926 /* add line-in as output */
2927 nid = check_line_out_switch(codec);
2929 dac = get_unassigned_dac(codec, nid);
2931 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2932 nid, cfg->line_outs);
2933 cfg->line_out_pins[cfg->line_outs] = nid;
2935 spec->line_switch = nid;
2936 add_spec_dacs(spec, dac);
2939 /* add mic as output */
2940 nid = check_mic_out_switch(codec);
2942 dac = get_unassigned_dac(codec, nid);
2944 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
2945 nid, cfg->line_outs);
2946 cfg->line_out_pins[cfg->line_outs] = nid;
2948 spec->mic_switch = nid;
2949 add_spec_dacs(spec, dac);
2953 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2954 spec->multiout.num_dacs,
2955 spec->multiout.dac_nids[0],
2956 spec->multiout.dac_nids[1],
2957 spec->multiout.dac_nids[2],
2958 spec->multiout.dac_nids[3],
2959 spec->multiout.dac_nids[4]);
2964 /* create volume control/switch for the given prefx type */
2965 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
2966 int idx, hda_nid_t nid, int chs)
2968 struct sigmatel_spec *spec = codec->spec;
2972 if (!spec->check_volume_offset) {
2973 unsigned int caps, step, nums, db_scale;
2974 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2975 step = (caps & AC_AMPCAP_STEP_SIZE) >>
2976 AC_AMPCAP_STEP_SIZE_SHIFT;
2977 step = (step + 1) * 25; /* in .01dB unit */
2978 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
2979 AC_AMPCAP_NUM_STEPS_SHIFT;
2980 db_scale = nums * step;
2981 /* if dB scale is over -64dB, and finer enough,
2982 * let's reduce it to half
2984 if (db_scale > 6400 && nums >= 0x1f)
2985 spec->volume_offset = nums / 2;
2986 spec->check_volume_offset = 1;
2989 sprintf(name, "%s Playback Volume", pfx);
2990 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
2991 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
2992 spec->volume_offset));
2995 sprintf(name, "%s Playback Switch", pfx);
2996 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
2997 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3003 #define create_controls(codec, pfx, nid, chs) \
3004 create_controls_idx(codec, pfx, 0, nid, chs)
3006 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3008 if (spec->multiout.num_dacs > 4) {
3009 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3012 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3013 spec->multiout.num_dacs++;
3018 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3021 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3022 if (!spec->multiout.extra_out_nid[i]) {
3023 spec->multiout.extra_out_nid[i] = nid;
3027 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3031 /* Create output controls
3032 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3034 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3035 const hda_nid_t *pins,
3036 const hda_nid_t *dac_nids,
3039 struct sigmatel_spec *spec = codec->spec;
3040 static const char *chname[4] = {
3041 "Front", "Surround", NULL /*CLFE*/, "Side"
3045 unsigned int wid_caps;
3047 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3048 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3049 wid_caps = get_wcaps(codec, pins[i]);
3050 if (wid_caps & AC_WCAP_UNSOL_CAP)
3051 spec->hp_detect = 1;
3056 if (type != AUTO_PIN_HP_OUT && i == 2) {
3058 err = create_controls(codec, "Center", nid, 1);
3061 err = create_controls(codec, "LFE", nid, 2);
3065 wid_caps = get_wcaps(codec, nid);
3067 if (wid_caps & AC_WCAP_LR_SWAP) {
3068 err = stac92xx_add_control(spec,
3069 STAC_CTL_WIDGET_CLFE_SWITCH,
3070 "Swap Center/LFE Playback Switch", nid);
3080 case AUTO_PIN_HP_OUT:
3084 case AUTO_PIN_SPEAKER_OUT:
3093 err = create_controls_idx(codec, name, idx, nid, 3);
3101 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3102 unsigned long sw, int idx)
3105 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3106 "Capture Volume", vol);
3109 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3110 "Capture Switch", sw);
3116 /* add playback controls from the parsed DAC table */
3117 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3118 const struct auto_pin_cfg *cfg)
3120 struct sigmatel_spec *spec = codec->spec;
3125 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3126 spec->multiout.dac_nids,
3127 cfg->line_out_type);
3131 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3132 err = stac92xx_add_control(spec,
3133 STAC_CTL_WIDGET_HP_SWITCH,
3134 "Headphone as Line Out Switch",
3135 cfg->hp_pins[cfg->hp_outs - 1]);
3140 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3141 nid = cfg->input_pins[idx];
3143 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3152 /* add playback controls for Speaker and HP outputs */
3153 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3154 struct auto_pin_cfg *cfg)
3156 struct sigmatel_spec *spec = codec->spec;
3159 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3160 spec->hp_dacs, AUTO_PIN_HP_OUT);
3164 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3165 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3172 /* labels for mono mux outputs */
3173 static const char *stac92xx_mono_labels[4] = {
3174 "DAC0", "DAC1", "Mixer", "DAC2"
3177 /* create mono mux for mono out on capable codecs */
3178 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3180 struct sigmatel_spec *spec = codec->spec;
3181 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3183 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3185 num_cons = snd_hda_get_connections(codec,
3188 HDA_MAX_NUM_INPUTS);
3189 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3192 for (i = 0; i < num_cons; i++) {
3193 mono_mux->items[mono_mux->num_items].label =
3194 stac92xx_mono_labels[i];
3195 mono_mux->items[mono_mux->num_items].index = i;
3196 mono_mux->num_items++;
3199 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3200 "Mono Mux", spec->mono_nid);
3203 /* create PC beep volume controls */
3204 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3207 struct sigmatel_spec *spec = codec->spec;
3208 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3211 /* check for mute support for the the amp */
3212 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3213 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3214 "PC Beep Playback Switch",
3215 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3220 /* check to see if there is volume support for the amp */
3221 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3222 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3223 "PC Beep Playback Volume",
3224 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3231 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3232 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3234 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3235 struct snd_ctl_elem_value *ucontrol)
3237 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3238 ucontrol->value.integer.value[0] = codec->beep->enabled;
3242 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3243 struct snd_ctl_elem_value *ucontrol)
3245 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3246 int enabled = !!ucontrol->value.integer.value[0];
3247 if (codec->beep->enabled != enabled) {
3248 codec->beep->enabled = enabled;
3254 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3256 .info = stac92xx_dig_beep_switch_info,
3257 .get = stac92xx_dig_beep_switch_get,
3258 .put = stac92xx_dig_beep_switch_put,
3261 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3263 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3264 0, "PC Beep Playback Switch", 0);
3268 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3270 struct sigmatel_spec *spec = codec->spec;
3273 for (i = 0; i < spec->num_muxes; i++) {
3278 nid = spec->mux_nids[i];
3279 wcaps = get_wcaps(codec, nid);
3280 if (!(wcaps & AC_WCAP_OUT_AMP))
3283 /* check whether already the same control was created as
3284 * normal Capture Volume.
3286 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3287 for (j = 0; j < spec->num_caps; j++) {
3288 if (spec->capvols[j] == val)
3291 if (j < spec->num_caps)
3294 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3295 "Mux Capture Volume", val);
3302 static const char *stac92xx_spdif_labels[3] = {
3303 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3306 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3308 struct sigmatel_spec *spec = codec->spec;
3309 struct hda_input_mux *spdif_mux = &spec->private_smux;
3310 const char **labels = spec->spdif_labels;
3312 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3314 num_cons = snd_hda_get_connections(codec,
3317 HDA_MAX_NUM_INPUTS);
3322 labels = stac92xx_spdif_labels;
3324 for (i = 0; i < num_cons; i++) {
3325 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3326 spdif_mux->items[spdif_mux->num_items].index = i;
3327 spdif_mux->num_items++;
3333 /* labels for dmic mux inputs */
3334 static const char *stac92xx_dmic_labels[5] = {
3335 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3336 "Digital Mic 3", "Digital Mic 4"
3339 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
3342 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3345 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3346 for (i = 0; i < nums; i++)
3352 /* create a volume assigned to the given pin (only if supported) */
3353 /* return 1 if the volume control is created */
3354 static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
3355 const char *label, int direction)
3357 unsigned int caps, nums;
3361 if (direction == HDA_OUTPUT)
3362 caps = AC_WCAP_OUT_AMP;
3364 caps = AC_WCAP_IN_AMP;
3365 if (!(get_wcaps(codec, nid) & caps))
3367 caps = query_amp_caps(codec, nid, direction);
3368 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3371 snprintf(name, sizeof(name), "%s Capture Volume", label);
3372 err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name,
3373 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3379 /* create playback/capture controls for input pins on dmic capable codecs */
3380 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3381 const struct auto_pin_cfg *cfg)
3383 struct sigmatel_spec *spec = codec->spec;
3384 struct hda_input_mux *imux = &spec->private_imux;
3385 struct hda_input_mux *dimux = &spec->private_dimux;
3386 int err, i, active_mics;
3387 unsigned int def_conf;
3389 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3390 dimux->items[dimux->num_items].index = 0;
3394 for (i = 0; i < spec->num_dmics; i++) {
3395 /* check the validity: sometimes it's a dead vendor-spec node */
3396 if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i]))
3399 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3400 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
3404 for (i = 0; i < spec->num_dmics; i++) {
3409 nid = spec->dmic_nids[i];
3410 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3412 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3413 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3416 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3420 if (active_mics == 1)
3421 label = "Digital Mic";
3423 label = stac92xx_dmic_labels[dimux->num_items];
3425 err = create_elem_capture_vol(codec, nid, label, HDA_INPUT);
3429 err = create_elem_capture_vol(codec, nid, label,
3435 dimux->items[dimux->num_items].label = label;
3436 dimux->items[dimux->num_items].index = index;
3438 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) {
3439 imux->items[imux->num_items].label = label;
3440 imux->items[imux->num_items].index = index;
3448 static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3449 hda_nid_t *fixed, hda_nid_t *ext)
3455 cfg = snd_hda_codec_get_pincfg(codec, nid);
3456 switch (get_defcfg_connect(cfg)) {
3457 case AC_JACK_PORT_FIXED:
3459 return 1; /* already occupied */
3462 case AC_JACK_PORT_COMPLEX:
3464 return 1; /* already occupied */
3471 static int set_mic_route(struct hda_codec *codec,
3472 struct sigmatel_mic_route *mic,
3475 struct sigmatel_spec *spec = codec->spec;
3476 struct auto_pin_cfg *cfg = &spec->autocfg;
3480 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3481 if (pin == cfg->input_pins[i])
3483 if (i <= AUTO_PIN_FRONT_MIC) {
3485 i = get_connection_index(codec, spec->mux_nids[0], pin);
3490 if (spec->dmux_nids)
3491 mic->dmux_idx = get_connection_index(codec,
3494 } else if (spec->dmux_nids) {
3496 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3502 mic->mux_idx = get_connection_index(codec,
3504 spec->dmux_nids[0]);
3509 /* return non-zero if the device is for automatic mic switch */
3510 static int stac_check_auto_mic(struct hda_codec *codec)
3512 struct sigmatel_spec *spec = codec->spec;
3513 struct auto_pin_cfg *cfg = &spec->autocfg;
3514 hda_nid_t fixed, ext;
3517 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
3518 if (cfg->input_pins[i])
3519 return 0; /* must be exclusively mics */
3522 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3523 if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
3525 for (i = 0; i < spec->num_dmics; i++)
3526 if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
3530 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
3531 return 0; /* no unsol support */
3532 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3533 set_mic_route(codec, &spec->int_mic, fixed))
3534 return 0; /* something is wrong */
3538 /* create playback/capture controls for input pins */
3539 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3541 struct sigmatel_spec *spec = codec->spec;
3542 struct hda_input_mux *imux = &spec->private_imux;
3545 for (i = 0; i < AUTO_PIN_LAST; i++) {
3546 hda_nid_t nid = cfg->input_pins[i];
3552 for (j = 0; j < spec->num_muxes; j++) {
3553 index = get_connection_index(codec, spec->mux_nids[j],
3561 err = create_elem_capture_vol(codec, nid,
3562 auto_pin_cfg_labels[i],
3567 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3568 imux->items[imux->num_items].index = index;
3571 spec->num_analog_muxes = imux->num_items;
3573 if (imux->num_items) {
3575 * Set the current input for the muxes.
3576 * The STAC9221 has two input muxes with identical source
3577 * NID lists. Hopefully this won't get confused.
3579 for (i = 0; i < spec->num_muxes; i++) {
3580 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3581 AC_VERB_SET_CONNECT_SEL,
3582 imux->items[0].index);
3589 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3591 struct sigmatel_spec *spec = codec->spec;
3594 for (i = 0; i < spec->autocfg.line_outs; i++) {
3595 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3596 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3600 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3602 struct sigmatel_spec *spec = codec->spec;
3605 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3607 pin = spec->autocfg.hp_pins[i];
3608 if (pin) /* connect to front */
3609 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3611 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3613 pin = spec->autocfg.speaker_pins[i];
3614 if (pin) /* connect to front */
3615 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3619 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3621 struct sigmatel_spec *spec = codec->spec;
3625 if ((err = snd_hda_parse_pin_def_config(codec,
3627 spec->dmic_nids)) < 0)
3629 if (! spec->autocfg.line_outs)
3630 return 0; /* can't find valid pin config */
3632 /* If we have no real line-out pin and multiple hp-outs, HPs should
3633 * be set up as multi-channel outputs.
3635 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3636 spec->autocfg.hp_outs > 1) {
3637 /* Copy hp_outs to line_outs, backup line_outs in
3638 * speaker_outs so that the following routines can handle
3639 * HP pins as primary outputs.
3641 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3642 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3643 sizeof(spec->autocfg.line_out_pins));
3644 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3645 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3646 sizeof(spec->autocfg.hp_pins));
3647 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3648 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3649 spec->autocfg.hp_outs = 0;
3652 if (spec->autocfg.mono_out_pin) {
3653 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3654 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3655 u32 caps = query_amp_caps(codec,
3656 spec->autocfg.mono_out_pin, dir);
3657 hda_nid_t conn_list[1];
3659 /* get the mixer node and then the mono mux if it exists */
3660 if (snd_hda_get_connections(codec,
3661 spec->autocfg.mono_out_pin, conn_list, 1) &&
3662 snd_hda_get_connections(codec, conn_list[0],
3663 conn_list, 1) > 0) {
3665 int wcaps = get_wcaps(codec, conn_list[0]);
3666 int wid_type = get_wcaps_type(wcaps);
3667 /* LR swap check, some stac925x have a mux that
3668 * changes the DACs output path instead of the
3671 if (wid_type == AC_WID_AUD_SEL &&
3672 !(wcaps & AC_WCAP_LR_SWAP))
3673 spec->mono_nid = conn_list[0];
3676 hda_nid_t nid = spec->autocfg.mono_out_pin;
3678 /* most mono outs have a least a mute/unmute switch */
3679 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3680 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3681 "Mono Playback Switch",
3682 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3685 /* check for volume support for the amp */
3686 if ((caps & AC_AMPCAP_NUM_STEPS)
3687 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3688 err = stac92xx_add_control(spec,
3689 STAC_CTL_WIDGET_VOL,
3690 "Mono Playback Volume",
3691 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3697 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3701 if (!spec->multiout.num_dacs) {
3702 err = stac92xx_auto_fill_dac_nids(codec);
3705 err = stac92xx_auto_create_multi_out_ctls(codec,
3711 /* setup analog beep controls */
3712 if (spec->anabeep_nid > 0) {
3713 err = stac92xx_auto_create_beep_ctls(codec,
3719 /* setup digital beep controls and input device */
3720 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3721 if (spec->digbeep_nid > 0) {
3722 hda_nid_t nid = spec->digbeep_nid;
3725 err = stac92xx_auto_create_beep_ctls(codec, nid);
3728 err = snd_hda_attach_beep_device(codec, nid);
3731 /* IDT/STAC codecs have linear beep tone parameter */
3732 codec->beep->linear_tone = 1;
3733 /* if no beep switch is available, make its own one */
3734 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3736 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3737 err = stac92xx_beep_switch_ctl(codec);
3744 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3748 /* All output parsing done, now restore the swapped hp pins */
3750 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3751 sizeof(spec->autocfg.hp_pins));
3752 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3753 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3754 spec->autocfg.line_outs = 0;
3757 if (stac_check_auto_mic(codec)) {
3759 /* only one capture for auto-mic */
3762 spec->num_muxes = 1;
3765 for (i = 0; i < spec->num_caps; i++) {
3766 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3767 spec->capsws[i], i);
3772 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3776 if (spec->mono_nid > 0) {
3777 err = stac92xx_auto_create_mono_output_ctls(codec);
3781 if (spec->num_dmics > 0 && !spec->dinput_mux)
3782 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3783 &spec->autocfg)) < 0)
3785 if (spec->num_muxes > 0) {
3786 err = stac92xx_auto_create_mux_input_ctls(codec);
3790 if (spec->num_smuxes > 0) {
3791 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3796 err = stac92xx_add_input_source(spec);
3800 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3801 if (spec->multiout.max_channels > 2)
3802 spec->surr_switch = 1;
3804 if (spec->autocfg.dig_outs)
3805 spec->multiout.dig_out_nid = dig_out;
3806 if (dig_in && spec->autocfg.dig_in_pin)
3807 spec->dig_in_nid = dig_in;
3809 if (spec->kctls.list)
3810 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3812 spec->input_mux = &spec->private_imux;
3813 if (!spec->dinput_mux)
3814 spec->dinput_mux = &spec->private_dimux;
3815 spec->sinput_mux = &spec->private_smux;
3816 spec->mono_mux = &spec->private_mono_mux;
3820 /* add playback controls for HP output */
3821 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3822 struct auto_pin_cfg *cfg)
3824 struct sigmatel_spec *spec = codec->spec;
3825 hda_nid_t pin = cfg->hp_pins[0];
3826 unsigned int wid_caps;
3831 wid_caps = get_wcaps(codec, pin);
3832 if (wid_caps & AC_WCAP_UNSOL_CAP)
3833 spec->hp_detect = 1;
3838 /* add playback controls for LFE output */
3839 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3840 struct auto_pin_cfg *cfg)
3842 struct sigmatel_spec *spec = codec->spec;
3844 hda_nid_t lfe_pin = 0x0;
3848 * search speaker outs and line outs for a mono speaker pin
3849 * with an amp. If one is found, add LFE controls
3852 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3853 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3854 unsigned int wcaps = get_wcaps(codec, pin);
3855 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3856 if (wcaps == AC_WCAP_OUT_AMP)
3857 /* found a mono speaker with an amp, must be lfe */
3861 /* if speaker_outs is 0, then speakers may be in line_outs */
3862 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3863 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3864 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3865 unsigned int defcfg;
3866 defcfg = snd_hda_codec_get_pincfg(codec, pin);
3867 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3868 unsigned int wcaps = get_wcaps(codec, pin);
3869 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3870 if (wcaps == AC_WCAP_OUT_AMP)
3871 /* found a mono speaker with an amp,
3879 err = create_controls(codec, "LFE", lfe_pin, 1);
3887 static int stac9200_parse_auto_config(struct hda_codec *codec)
3889 struct sigmatel_spec *spec = codec->spec;
3892 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3895 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3898 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3901 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3904 if (spec->num_muxes > 0) {
3905 err = stac92xx_auto_create_mux_input_ctls(codec);
3910 err = stac92xx_add_input_source(spec);
3914 if (spec->autocfg.dig_outs)
3915 spec->multiout.dig_out_nid = 0x05;
3916 if (spec->autocfg.dig_in_pin)
3917 spec->dig_in_nid = 0x04;
3919 if (spec->kctls.list)
3920 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3922 spec->input_mux = &spec->private_imux;
3923 spec->dinput_mux = &spec->private_dimux;
3929 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3930 * funky external mute control using GPIO pins.
3933 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3934 unsigned int dir_mask, unsigned int data)
3936 unsigned int gpiostate, gpiomask, gpiodir;
3938 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3939 AC_VERB_GET_GPIO_DATA, 0);
3940 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3942 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3943 AC_VERB_GET_GPIO_MASK, 0);
3946 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3947 AC_VERB_GET_GPIO_DIRECTION, 0);
3948 gpiodir |= dir_mask;
3950 /* Configure GPIOx as CMOS */
3951 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3953 snd_hda_codec_write(codec, codec->afg, 0,
3954 AC_VERB_SET_GPIO_MASK, gpiomask);
3955 snd_hda_codec_read(codec, codec->afg, 0,
3956 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3960 snd_hda_codec_read(codec, codec->afg, 0,
3961 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3964 #ifdef CONFIG_SND_HDA_INPUT_JACK
3965 static void stac92xx_free_jack_priv(struct snd_jack *jack)
3967 struct sigmatel_jack *jacks = jack->private_data;
3973 static int stac92xx_add_jack(struct hda_codec *codec,
3974 hda_nid_t nid, int type)
3976 #ifdef CONFIG_SND_HDA_INPUT_JACK
3977 struct sigmatel_spec *spec = codec->spec;
3978 struct sigmatel_jack *jack;
3979 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
3980 int connectivity = get_defcfg_connect(def_conf);
3984 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3987 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3988 jack = snd_array_new(&spec->jacks);
3994 snprintf(name, sizeof(name), "%s at %s %s Jack",
3995 snd_hda_get_jack_type(def_conf),
3996 snd_hda_get_jack_connectivity(def_conf),
3997 snd_hda_get_jack_location(def_conf));
3999 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4004 jack->jack->private_data = jack;
4005 jack->jack->private_free = stac92xx_free_jack_priv;
4010 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4011 unsigned char type, int data)
4013 struct sigmatel_event *event;
4015 snd_array_init(&spec->events, sizeof(*event), 32);
4016 event = snd_array_new(&spec->events);
4021 event->tag = spec->events.used;
4027 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4030 struct sigmatel_spec *spec = codec->spec;
4031 struct sigmatel_event *event = spec->events.list;
4034 for (i = 0; i < spec->events.used; i++, event++) {
4035 if (event->nid == nid)
4041 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4044 struct sigmatel_spec *spec = codec->spec;
4045 struct sigmatel_event *event = spec->events.list;
4048 for (i = 0; i < spec->events.used; i++, event++) {
4049 if (event->tag == tag)
4055 /* check if given nid is a valid pin and no other events are assigned
4056 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4057 * Otherwise, returns zero.
4059 static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4062 struct sigmatel_event *event;
4065 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4067 event = stac_get_event(codec, nid);
4069 if (event->type != type)
4073 tag = stac_add_event(codec->spec, nid, type, 0);
4077 snd_hda_codec_write_cache(codec, nid, 0,
4078 AC_VERB_SET_UNSOLICITED_ENABLE,
4083 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4086 for (i = 0; i < cfg->hp_outs; i++)
4087 if (cfg->hp_pins[i] == nid)
4088 return 1; /* nid is a HP-Out */
4090 return 0; /* nid is not a HP-Out */
4093 static void stac92xx_power_down(struct hda_codec *codec)
4095 struct sigmatel_spec *spec = codec->spec;
4097 /* power down inactive DACs */
4099 for (dac = spec->dac_list; *dac; dac++)
4100 if (!check_all_dac_nids(spec, *dac))
4101 snd_hda_codec_write(codec, *dac, 0,
4102 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4105 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4108 /* override some hints from the hwdep entry */
4109 static void stac_store_hints(struct hda_codec *codec)
4111 struct sigmatel_spec *spec = codec->spec;
4115 val = snd_hda_get_bool_hint(codec, "hp_detect");
4117 spec->hp_detect = val;
4118 p = snd_hda_get_hint(codec, "gpio_mask");
4120 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4121 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4124 p = snd_hda_get_hint(codec, "gpio_dir");
4126 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4127 p = snd_hda_get_hint(codec, "gpio_data");
4129 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4130 p = snd_hda_get_hint(codec, "eapd_mask");
4132 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4133 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4135 spec->eapd_switch = val;
4138 static int stac92xx_init(struct hda_codec *codec)
4140 struct sigmatel_spec *spec = codec->spec;
4141 struct auto_pin_cfg *cfg = &spec->autocfg;
4145 snd_hda_sequence_write(codec, spec->init);
4147 /* power down adcs initially */
4148 if (spec->powerdown_adcs)
4149 for (i = 0; i < spec->num_adcs; i++)
4150 snd_hda_codec_write(codec,
4151 spec->adc_nids[i], 0,
4152 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4154 /* override some hints */
4155 stac_store_hints(codec);
4158 gpio = spec->gpio_data;
4159 /* turn on EAPD statically when spec->eapd_switch isn't set.
4160 * otherwise, unsol event will turn it on/off dynamically
4162 if (!spec->eapd_switch)
4163 gpio |= spec->eapd_mask;
4164 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4167 if (spec->hp_detect) {
4168 /* Enable unsolicited responses on the HP widget */
4169 for (i = 0; i < cfg->hp_outs; i++) {
4170 hda_nid_t nid = cfg->hp_pins[i];
4171 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4173 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4174 cfg->speaker_outs > 0) {
4175 /* enable pin-detect for line-outs as well */
4176 for (i = 0; i < cfg->line_outs; i++) {
4177 hda_nid_t nid = cfg->line_out_pins[i];
4178 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4182 /* force to enable the first line-out; the others are set up
4185 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4187 /* fake event to set up pins */
4188 if (cfg->hp_pins[0])
4189 stac_issue_unsol_event(codec, cfg->hp_pins[0]);
4190 else if (cfg->line_out_pins[0])
4191 stac_issue_unsol_event(codec, cfg->line_out_pins[0]);
4193 stac92xx_auto_init_multi_out(codec);
4194 stac92xx_auto_init_hp_out(codec);
4195 for (i = 0; i < cfg->hp_outs; i++)
4196 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4198 if (spec->auto_mic) {
4199 /* initialize connection to analog input */
4200 if (spec->dmux_nids)
4201 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4202 AC_VERB_SET_CONNECT_SEL, 0);
4203 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4204 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4206 for (i = 0; i < AUTO_PIN_LAST; i++) {
4207 hda_nid_t nid = cfg->input_pins[i];
4209 unsigned int pinctl, conf;
4210 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4211 /* for mic pins, force to initialize */
4212 pinctl = stac92xx_get_default_vref(codec, nid);
4213 pinctl |= AC_PINCTL_IN_EN;
4214 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4216 pinctl = snd_hda_codec_read(codec, nid, 0,
4217 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4218 /* if PINCTL already set then skip */
4219 /* Also, if both INPUT and OUTPUT are set,
4220 * it must be a BIOS bug; need to override, too
4222 if (!(pinctl & AC_PINCTL_IN_EN) ||
4223 (pinctl & AC_PINCTL_OUT_EN)) {
4224 pinctl &= ~AC_PINCTL_OUT_EN;
4225 pinctl |= AC_PINCTL_IN_EN;
4226 stac92xx_auto_set_pinctl(codec, nid,
4230 conf = snd_hda_codec_get_pincfg(codec, nid);
4231 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4232 if (enable_pin_detect(codec, nid,
4234 stac_issue_unsol_event(codec, nid);
4238 for (i = 0; i < spec->num_dmics; i++)
4239 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4241 if (cfg->dig_out_pins[0])
4242 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4244 if (cfg->dig_in_pin)
4245 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4247 for (i = 0; i < spec->num_pwrs; i++) {
4248 hda_nid_t nid = spec->pwr_nids[i];
4249 int pinctl, def_conf;
4251 /* power on when no jack detection is available */
4252 if (!spec->hp_detect) {
4253 stac_toggle_power_map(codec, nid, 1);
4257 if (is_nid_hp_pin(cfg, nid))
4258 continue; /* already has an unsol event */
4260 pinctl = snd_hda_codec_read(codec, nid, 0,
4261 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4262 /* outputs are only ports capable of power management
4263 * any attempts on powering down a input port cause the
4264 * referenced VREF to act quirky.
4266 if (pinctl & AC_PINCTL_IN_EN) {
4267 stac_toggle_power_map(codec, nid, 1);
4270 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4271 def_conf = get_defcfg_connect(def_conf);
4272 /* skip any ports that don't have jacks since presence
4273 * detection is useless */
4274 if (def_conf != AC_JACK_PORT_COMPLEX) {
4275 if (def_conf != AC_JACK_PORT_NONE)
4276 stac_toggle_power_map(codec, nid, 1);
4279 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4280 stac_issue_unsol_event(codec, nid);
4283 stac92xx_power_down(codec);
4287 static void stac92xx_free_jacks(struct hda_codec *codec)
4289 #ifdef CONFIG_SND_HDA_INPUT_JACK
4290 /* free jack instances manually when clearing/reconfiguring */
4291 struct sigmatel_spec *spec = codec->spec;
4292 if (!codec->bus->shutdown && spec->jacks.list) {
4293 struct sigmatel_jack *jacks = spec->jacks.list;
4295 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4297 snd_device_free(codec->bus->card, jacks->jack);
4300 snd_array_free(&spec->jacks);
4304 static void stac92xx_free_kctls(struct hda_codec *codec)
4306 struct sigmatel_spec *spec = codec->spec;
4308 if (spec->kctls.list) {
4309 struct snd_kcontrol_new *kctl = spec->kctls.list;
4311 for (i = 0; i < spec->kctls.used; i++)
4312 kfree(kctl[i].name);
4314 snd_array_free(&spec->kctls);
4317 static void stac92xx_free(struct hda_codec *codec)
4319 struct sigmatel_spec *spec = codec->spec;
4324 stac92xx_free_jacks(codec);
4325 snd_array_free(&spec->events);
4328 snd_hda_detach_beep_device(codec);
4331 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4334 unsigned int old_ctl, pin_ctl;
4336 pin_ctl = snd_hda_codec_read(codec, nid,
4337 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4339 if (pin_ctl & AC_PINCTL_IN_EN) {
4341 * we need to check the current set-up direction of
4342 * shared input pins since they can be switched via
4343 * "xxx as Output" mixer switch
4345 struct sigmatel_spec *spec = codec->spec;
4346 if (nid == spec->line_switch || nid == spec->mic_switch)
4351 /* if setting pin direction bits, clear the current
4352 direction bits first */
4353 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4354 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4357 if (old_ctl != pin_ctl)
4358 snd_hda_codec_write_cache(codec, nid, 0,
4359 AC_VERB_SET_PIN_WIDGET_CONTROL,
4363 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4366 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4367 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4369 snd_hda_codec_write_cache(codec, nid, 0,
4370 AC_VERB_SET_PIN_WIDGET_CONTROL,
4374 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4378 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
4384 static void stac92xx_line_out_detect(struct hda_codec *codec,
4387 struct sigmatel_spec *spec = codec->spec;
4388 struct auto_pin_cfg *cfg = &spec->autocfg;
4391 for (i = 0; i < cfg->line_outs; i++) {
4394 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4396 unsigned int pinctl;
4397 pinctl = snd_hda_codec_read(codec,
4398 cfg->line_out_pins[i], 0,
4399 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4400 if (pinctl & AC_PINCTL_IN_EN)
4401 presence = 0; /* mic- or line-input */
4406 /* disable speakers */
4407 for (i = 0; i < cfg->speaker_outs; i++)
4408 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4410 if (spec->eapd_mask && spec->eapd_switch)
4411 stac_gpio_set(codec, spec->gpio_mask,
4412 spec->gpio_dir, spec->gpio_data &
4415 /* enable speakers */
4416 for (i = 0; i < cfg->speaker_outs; i++)
4417 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4419 if (spec->eapd_mask && spec->eapd_switch)
4420 stac_gpio_set(codec, spec->gpio_mask,
4421 spec->gpio_dir, spec->gpio_data |
4426 /* return non-zero if the hp-pin of the given array index isn't
4427 * a jack-detection target
4429 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4431 struct auto_pin_cfg *cfg = &spec->autocfg;
4433 /* ignore sensing of shared line and mic jacks */
4434 if (cfg->hp_pins[i] == spec->line_switch)
4436 if (cfg->hp_pins[i] == spec->mic_switch)
4438 /* ignore if the pin is set as line-out */
4439 if (cfg->hp_pins[i] == spec->hp_switch)
4444 static void stac92xx_hp_detect(struct hda_codec *codec)
4446 struct sigmatel_spec *spec = codec->spec;
4447 struct auto_pin_cfg *cfg = &spec->autocfg;
4451 if (spec->gpio_mute)
4452 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4453 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4455 for (i = 0; i < cfg->hp_outs; i++) {
4458 if (no_hp_sensing(spec, i))
4460 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4462 unsigned int pinctl;
4463 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4464 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4465 if (pinctl & AC_PINCTL_IN_EN)
4466 presence = 0; /* mic- or line-input */
4471 /* disable lineouts */
4472 if (spec->hp_switch)
4473 stac92xx_reset_pinctl(codec, spec->hp_switch,
4475 for (i = 0; i < cfg->line_outs; i++)
4476 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4479 /* enable lineouts */
4480 if (spec->hp_switch)
4481 stac92xx_set_pinctl(codec, spec->hp_switch,
4483 for (i = 0; i < cfg->line_outs; i++)
4484 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4487 stac92xx_line_out_detect(codec, presence);
4488 /* toggle hp outs */
4489 for (i = 0; i < cfg->hp_outs; i++) {
4490 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4491 if (no_hp_sensing(spec, i))
4494 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4496 /* Resetting the pinctl like below may lead to (a sort of) regressions
4497 * on some devices since they use the HP pin actually for line/speaker
4498 * outs although the default pin config shows a different pin (that is
4499 * wrong and useless).
4501 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4502 * But, disabling the code below just works around it, and I'm too tired of
4503 * bug reports with such devices...
4506 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4511 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4514 struct sigmatel_spec *spec = codec->spec;
4515 unsigned int idx, val;
4517 for (idx = 0; idx < spec->num_pwrs; idx++) {
4518 if (spec->pwr_nids[idx] == nid)
4521 if (idx >= spec->num_pwrs)
4524 /* several codecs have two power down bits */
4525 if (spec->pwr_mapping)
4526 idx = spec->pwr_mapping[idx];
4530 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4536 /* power down unused output ports */
4537 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4540 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4542 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4545 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4547 struct sigmatel_spec *spec = codec->spec;
4548 struct sigmatel_jack *jacks = spec->jacks.list;
4552 for (i = 0; i < spec->jacks.used; i++) {
4553 if (jacks->nid == nid) {
4554 unsigned int pin_ctl =
4555 snd_hda_codec_read(codec, nid,
4556 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4558 int type = jacks->type;
4559 if (type == (SND_JACK_LINEOUT
4560 | SND_JACK_HEADPHONE))
4561 type = (pin_ctl & AC_PINCTL_HP_EN)
4562 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4563 snd_jack_report(jacks->jack,
4564 get_pin_presence(codec, nid)
4572 static void stac92xx_mic_detect(struct hda_codec *codec)
4574 struct sigmatel_spec *spec = codec->spec;
4575 struct sigmatel_mic_route *mic;
4577 if (get_pin_presence(codec, spec->ext_mic.pin))
4578 mic = &spec->ext_mic;
4580 mic = &spec->int_mic;
4581 if (mic->dmux_idx >= 0)
4582 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4583 AC_VERB_SET_CONNECT_SEL,
4585 if (mic->mux_idx >= 0)
4586 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4587 AC_VERB_SET_CONNECT_SEL,
4591 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4593 struct sigmatel_event *event = stac_get_event(codec, nid);
4596 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4599 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4601 struct sigmatel_spec *spec = codec->spec;
4602 struct sigmatel_event *event;
4605 tag = (res >> 26) & 0x7f;
4606 event = stac_get_event_from_tag(codec, tag);
4610 switch (event->type) {
4613 stac92xx_hp_detect(codec);
4615 case STAC_MIC_EVENT:
4616 stac92xx_mic_detect(codec);
4620 switch (event->type) {
4623 case STAC_MIC_EVENT:
4624 case STAC_INSERT_EVENT:
4625 case STAC_PWR_EVENT:
4626 if (spec->num_pwrs > 0)
4627 stac92xx_pin_sense(codec, event->nid);
4628 stac92xx_report_jack(codec, event->nid);
4630 switch (codec->subsystem_id) {
4632 if (event->nid == 0xb) {
4633 int pin = AC_PINCTL_IN_EN;
4635 if (get_pin_presence(codec, 0xa)
4636 && get_pin_presence(codec, 0xb))
4637 pin |= AC_PINCTL_VREF_80;
4638 if (!get_pin_presence(codec, 0xb))
4639 pin |= AC_PINCTL_VREF_80;
4641 /* toggle VREF state based on mic + hp pin
4644 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4648 case STAC_VREF_EVENT:
4649 data = snd_hda_codec_read(codec, codec->afg, 0,
4650 AC_VERB_GET_GPIO_DATA, 0);
4651 /* toggle VREF state based on GPIOx status */
4652 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4653 !!(data & (1 << event->data)));
4658 #ifdef CONFIG_PROC_FS
4659 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4660 struct hda_codec *codec, hda_nid_t nid)
4662 if (nid == codec->afg)
4663 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4664 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4667 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4668 struct hda_codec *codec,
4671 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4672 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4675 /* stac92hd71bxx, stac92hd73xx */
4676 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4677 struct hda_codec *codec, hda_nid_t nid)
4679 stac92hd_proc_hook(buffer, codec, nid);
4680 if (nid == codec->afg)
4681 analog_loop_proc_hook(buffer, codec, 0xfa0);
4684 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4685 struct hda_codec *codec, hda_nid_t nid)
4687 if (nid == codec->afg)
4688 analog_loop_proc_hook(buffer, codec, 0xfe0);
4691 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4692 struct hda_codec *codec, hda_nid_t nid)
4694 if (nid == codec->afg)
4695 analog_loop_proc_hook(buffer, codec, 0xfeb);
4698 #define stac92hd_proc_hook NULL
4699 #define stac92hd7x_proc_hook NULL
4700 #define stac9205_proc_hook NULL
4701 #define stac927x_proc_hook NULL
4704 #ifdef SND_HDA_NEEDS_RESUME
4705 static int stac92xx_resume(struct hda_codec *codec)
4707 struct sigmatel_spec *spec = codec->spec;
4709 stac92xx_init(codec);
4710 snd_hda_codec_resume_amp(codec);
4711 snd_hda_codec_resume_cache(codec);
4712 /* fake event to set up pins again to override cached values */
4713 if (spec->hp_detect) {
4714 if (spec->autocfg.hp_pins[0])
4715 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4716 else if (spec->autocfg.line_out_pins[0])
4717 stac_issue_unsol_event(codec,
4718 spec->autocfg.line_out_pins[0]);
4724 * using power check for controlling mute led of HP notebooks
4725 * check for mute state only on Speakers (nid = 0x10)
4727 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4728 * the LED is NOT working properly !
4730 * Changed name to reflect that it now works for any designated
4731 * model, not just HP HDX.
4734 #ifdef CONFIG_SND_HDA_POWER_SAVE
4735 static int stac92xx_hp_check_power_status(struct hda_codec *codec,
4738 struct sigmatel_spec *spec = codec->spec;
4741 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4743 spec->gpio_data &= ~spec->gpio_led; /* orange */
4745 spec->gpio_data |= spec->gpio_led; /* white */
4747 stac_gpio_set(codec, spec->gpio_mask,
4756 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4758 struct sigmatel_spec *spec = codec->spec;
4762 /* reset each pin before powering down DAC/ADC to avoid click noise */
4763 nid = codec->start_nid;
4764 for (i = 0; i < codec->num_nodes; i++, nid++) {
4765 unsigned int wcaps = get_wcaps(codec, nid);
4766 unsigned int wid_type = get_wcaps_type(wcaps);
4767 if (wid_type == AC_WID_PIN)
4768 snd_hda_codec_read(codec, nid, 0,
4769 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4772 if (spec->eapd_mask)
4773 stac_gpio_set(codec, spec->gpio_mask,
4774 spec->gpio_dir, spec->gpio_data &
4780 static struct hda_codec_ops stac92xx_patch_ops = {
4781 .build_controls = stac92xx_build_controls,
4782 .build_pcms = stac92xx_build_pcms,
4783 .init = stac92xx_init,
4784 .free = stac92xx_free,
4785 .unsol_event = stac92xx_unsol_event,
4786 #ifdef SND_HDA_NEEDS_RESUME
4787 .suspend = stac92xx_suspend,
4788 .resume = stac92xx_resume,
4792 static int patch_stac9200(struct hda_codec *codec)
4794 struct sigmatel_spec *spec;
4797 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4802 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4803 spec->pin_nids = stac9200_pin_nids;
4804 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4807 if (spec->board_config < 0)
4808 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4811 stac92xx_set_config_regs(codec,
4812 stac9200_brd_tbl[spec->board_config]);
4814 spec->multiout.max_channels = 2;
4815 spec->multiout.num_dacs = 1;
4816 spec->multiout.dac_nids = stac9200_dac_nids;
4817 spec->adc_nids = stac9200_adc_nids;
4818 spec->mux_nids = stac9200_mux_nids;
4819 spec->num_muxes = 1;
4820 spec->num_dmics = 0;
4824 if (spec->board_config == STAC_9200_M4 ||
4825 spec->board_config == STAC_9200_M4_2 ||
4826 spec->board_config == STAC_9200_OQO)
4827 spec->init = stac9200_eapd_init;
4829 spec->init = stac9200_core_init;
4830 spec->mixer = stac9200_mixer;
4832 if (spec->board_config == STAC_9200_PANASONIC) {
4833 spec->gpio_mask = spec->gpio_dir = 0x09;
4834 spec->gpio_data = 0x00;
4837 err = stac9200_parse_auto_config(codec);
4839 stac92xx_free(codec);
4843 /* CF-74 has no headphone detection, and the driver should *NOT*
4844 * do detection and HP/speaker toggle because the hardware does it.
4846 if (spec->board_config == STAC_9200_PANASONIC)
4847 spec->hp_detect = 0;
4849 codec->patch_ops = stac92xx_patch_ops;
4854 static int patch_stac925x(struct hda_codec *codec)
4856 struct sigmatel_spec *spec;
4859 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4864 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4865 spec->pin_nids = stac925x_pin_nids;
4867 /* Check first for codec ID */
4868 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4871 stac925x_codec_id_cfg_tbl);
4873 /* Now checks for PCI ID, if codec ID is not found */
4874 if (spec->board_config < 0)
4875 spec->board_config = snd_hda_check_board_config(codec,
4880 if (spec->board_config < 0)
4881 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4884 stac92xx_set_config_regs(codec,
4885 stac925x_brd_tbl[spec->board_config]);
4887 spec->multiout.max_channels = 2;
4888 spec->multiout.num_dacs = 1;
4889 spec->multiout.dac_nids = stac925x_dac_nids;
4890 spec->adc_nids = stac925x_adc_nids;
4891 spec->mux_nids = stac925x_mux_nids;
4892 spec->num_muxes = 1;
4895 switch (codec->vendor_id) {
4896 case 0x83847632: /* STAC9202 */
4897 case 0x83847633: /* STAC9202D */
4898 case 0x83847636: /* STAC9251 */
4899 case 0x83847637: /* STAC9251D */
4900 spec->num_dmics = STAC925X_NUM_DMICS;
4901 spec->dmic_nids = stac925x_dmic_nids;
4902 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4903 spec->dmux_nids = stac925x_dmux_nids;
4906 spec->num_dmics = 0;
4910 spec->init = stac925x_core_init;
4911 spec->mixer = stac925x_mixer;
4913 spec->capvols = stac925x_capvols;
4914 spec->capsws = stac925x_capsws;
4916 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4918 if (spec->board_config < 0) {
4919 printk(KERN_WARNING "hda_codec: No auto-config is "
4920 "available, default to model=ref\n");
4921 spec->board_config = STAC_925x_REF;
4927 stac92xx_free(codec);
4931 codec->patch_ops = stac92xx_patch_ops;
4936 static int patch_stac92hd73xx(struct hda_codec *codec)
4938 struct sigmatel_spec *spec;
4939 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4943 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4948 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4949 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4950 spec->pin_nids = stac92hd73xx_pin_nids;
4951 spec->board_config = snd_hda_check_board_config(codec,
4952 STAC_92HD73XX_MODELS,
4953 stac92hd73xx_models,
4954 stac92hd73xx_cfg_tbl);
4955 /* check codec subsystem id if not found */
4956 if (spec->board_config < 0)
4957 spec->board_config =
4958 snd_hda_check_board_codec_sid_config(codec,
4959 STAC_92HD73XX_MODELS, stac92hd73xx_models,
4960 stac92hd73xx_codec_id_cfg_tbl);
4962 if (spec->board_config < 0)
4963 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4966 stac92xx_set_config_regs(codec,
4967 stac92hd73xx_brd_tbl[spec->board_config]);
4969 num_dacs = snd_hda_get_connections(codec, 0x0a,
4970 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4972 if (num_dacs < 3 || num_dacs > 5) {
4973 printk(KERN_WARNING "hda_codec: Could not determine "
4974 "number of channels defaulting to DAC count\n");
4975 num_dacs = STAC92HD73_DAC_COUNT;
4977 spec->init = stac92hd73xx_core_init;
4979 case 0x3: /* 6 Channel */
4980 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
4982 case 0x4: /* 8 Channel */
4983 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
4985 case 0x5: /* 10 Channel */
4986 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4989 spec->multiout.dac_nids = spec->dac_nids;
4991 spec->aloopback_mask = 0x01;
4992 spec->aloopback_shift = 8;
4994 spec->digbeep_nid = 0x1c;
4995 spec->mux_nids = stac92hd73xx_mux_nids;
4996 spec->adc_nids = stac92hd73xx_adc_nids;
4997 spec->dmic_nids = stac92hd73xx_dmic_nids;
4998 spec->dmux_nids = stac92hd73xx_dmux_nids;
4999 spec->smux_nids = stac92hd73xx_smux_nids;
5001 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5002 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
5003 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
5005 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5006 spec->capvols = stac92hd73xx_capvols;
5007 spec->capsws = stac92hd73xx_capsws;
5009 switch (spec->board_config) {
5011 spec->init = dell_eq_core_init;
5013 case STAC_DELL_M6_AMIC:
5014 case STAC_DELL_M6_DMIC:
5015 case STAC_DELL_M6_BOTH:
5016 spec->num_smuxes = 0;
5017 spec->eapd_switch = 0;
5019 switch (spec->board_config) {
5020 case STAC_DELL_M6_AMIC: /* Analog Mics */
5021 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5022 spec->num_dmics = 0;
5024 case STAC_DELL_M6_DMIC: /* Digital Mics */
5025 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5026 spec->num_dmics = 1;
5028 case STAC_DELL_M6_BOTH: /* Both */
5029 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5030 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5031 spec->num_dmics = 1;
5035 case STAC_ALIENWARE_M17X:
5036 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5037 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5038 spec->eapd_switch = 0;
5041 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5042 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5043 spec->eapd_switch = 1;
5046 if (spec->board_config != STAC_92HD73XX_REF) {
5047 /* GPIO0 High = Enable EAPD */
5048 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5049 spec->gpio_data = 0x01;
5052 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5053 spec->pwr_nids = stac92hd73xx_pwr_nids;
5055 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
5058 if (spec->board_config < 0) {
5059 printk(KERN_WARNING "hda_codec: No auto-config is "
5060 "available, default to model=ref\n");
5061 spec->board_config = STAC_92HD73XX_REF;
5068 stac92xx_free(codec);
5072 if (spec->board_config == STAC_92HD73XX_NO_JD)
5073 spec->hp_detect = 0;
5075 codec->patch_ops = stac92xx_patch_ops;
5077 codec->proc_widget_hook = stac92hd7x_proc_hook;
5082 static int patch_stac92hd83xxx(struct hda_codec *codec)
5084 struct sigmatel_spec *spec;
5085 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
5090 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5095 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5096 spec->digbeep_nid = 0x21;
5097 spec->mux_nids = stac92hd83xxx_mux_nids;
5098 spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids);
5099 spec->adc_nids = stac92hd83xxx_adc_nids;
5100 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5101 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5102 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5103 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5104 spec->multiout.dac_nids = spec->dac_nids;
5106 spec->init = stac92hd83xxx_core_init;
5107 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5108 spec->pin_nids = stac92hd83xxx_pin_nids;
5109 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5110 spec->capvols = stac92hd83xxx_capvols;
5111 spec->capsws = stac92hd83xxx_capsws;
5113 spec->board_config = snd_hda_check_board_config(codec,
5114 STAC_92HD83XXX_MODELS,
5115 stac92hd83xxx_models,
5116 stac92hd83xxx_cfg_tbl);
5118 if (spec->board_config < 0)
5119 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5122 stac92xx_set_config_regs(codec,
5123 stac92hd83xxx_brd_tbl[spec->board_config]);
5125 switch (codec->vendor_id) {
5129 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5135 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5137 if (spec->board_config < 0) {
5138 printk(KERN_WARNING "hda_codec: No auto-config is "
5139 "available, default to model=ref\n");
5140 spec->board_config = STAC_92HD83XXX_REF;
5147 stac92xx_free(codec);
5151 switch (spec->board_config) {
5160 num_dacs = snd_hda_get_connections(codec, nid,
5161 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5163 num_dacs = STAC92HD83_DAC_COUNT;
5165 /* set port X to select the last DAC
5167 snd_hda_codec_write_cache(codec, nid, 0,
5168 AC_VERB_SET_CONNECT_SEL, num_dacs);
5170 codec->patch_ops = stac92xx_patch_ops;
5172 codec->proc_widget_hook = stac92hd_proc_hook;
5177 /* get the pin connection (fixed, none, etc) */
5178 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5180 struct sigmatel_spec *spec = codec->spec;
5183 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5184 return get_defcfg_connect(cfg);
5187 static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5188 hda_nid_t *nids, int num_nids)
5190 struct sigmatel_spec *spec = codec->spec;
5192 unsigned int def_conf;
5194 for (num = 0; num < num_nids; num++) {
5195 for (idx = 0; idx < spec->num_pins; idx++)
5196 if (spec->pin_nids[idx] == nids[num])
5198 if (idx >= spec->num_pins)
5200 def_conf = stac_get_defcfg_connect(codec, idx);
5201 if (def_conf == AC_JACK_PORT_NONE)
5207 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5210 struct sigmatel_spec *spec = codec->spec;
5213 for (idx = 0; idx < spec->num_pins; idx++)
5214 if (spec->pin_nids[idx] == dig0pin)
5216 if ((idx + 2) >= spec->num_pins)
5220 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5223 /* dig0pin + dig2pin case */
5224 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5226 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5232 static int patch_stac92hd71bxx(struct hda_codec *codec)
5234 struct sigmatel_spec *spec;
5235 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5238 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5243 codec->patch_ops = stac92xx_patch_ops;
5244 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5245 switch (codec->vendor_id) {
5248 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5252 /* On 92HD75Bx 0x27 isn't a pin nid */
5256 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5258 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5259 spec->board_config = snd_hda_check_board_config(codec,
5260 STAC_92HD71BXX_MODELS,
5261 stac92hd71bxx_models,
5262 stac92hd71bxx_cfg_tbl);
5264 if (spec->board_config < 0)
5265 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5268 stac92xx_set_config_regs(codec,
5269 stac92hd71bxx_brd_tbl[spec->board_config]);
5271 if (spec->board_config != STAC_92HD71BXX_REF) {
5273 spec->gpio_mask = 0x01;
5274 spec->gpio_dir = 0x01;
5275 spec->gpio_data = 0x01;
5278 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5279 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5281 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5282 spec->capvols = stac92hd71bxx_capvols;
5283 spec->capsws = stac92hd71bxx_capsws;
5285 switch (codec->vendor_id) {
5286 case 0x111d76b6: /* 4 Port without Analog Mixer */
5290 case 0x111d76b4: /* 6 Port without Analog Mixer */
5292 spec->init = stac92hd71bxx_core_init;
5293 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5294 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5295 stac92hd71bxx_dmic_nids,
5296 STAC92HD71BXX_NUM_DMICS);
5298 case 0x111d7608: /* 5 Port with Analog Mixer */
5299 switch (spec->board_config) {
5301 /* Enable VREF power saving on GPIO1 detect */
5302 err = stac_add_event(spec, codec->afg,
5303 STAC_VREF_EVENT, 0x02);
5306 snd_hda_codec_write_cache(codec, codec->afg, 0,
5307 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5308 snd_hda_codec_write_cache(codec, codec->afg, 0,
5309 AC_VERB_SET_UNSOLICITED_ENABLE,
5311 spec->gpio_mask |= 0x02;
5314 if ((codec->revision_id & 0xf) == 0 ||
5315 (codec->revision_id & 0xf) == 1)
5316 spec->stream_delay = 40; /* 40 milliseconds */
5318 /* no output amps */
5321 spec->init = stac92hd71bxx_core_init;
5323 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5324 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5325 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5326 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5327 stac92hd71bxx_dmic_nids,
5328 STAC92HD71BXX_NUM_DMICS - 1);
5330 case 0x111d7603: /* 6 Port with Analog Mixer */
5331 if ((codec->revision_id & 0xf) == 1)
5332 spec->stream_delay = 40; /* 40 milliseconds */
5334 /* no output amps */
5338 spec->init = stac92hd71bxx_core_init;
5339 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5340 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5341 stac92hd71bxx_dmic_nids,
5342 STAC92HD71BXX_NUM_DMICS);
5346 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5347 snd_hda_sequence_write_cache(codec, unmute_init);
5349 /* Some HP machines seem to have unstable codec communications
5350 * especially with ATI fglrx driver. For recovering from the
5351 * CORB/RIRB stall, allow the BUS reset and keep always sync
5353 if (spec->board_config == STAC_HP_DV5) {
5354 codec->bus->sync_write = 1;
5355 codec->bus->allow_bus_reset = 1;
5358 spec->aloopback_ctl = stac92hd71bxx_loopback;
5359 spec->aloopback_mask = 0x50;
5360 spec->aloopback_shift = 0;
5362 spec->powerdown_adcs = 1;
5363 spec->digbeep_nid = 0x26;
5364 spec->mux_nids = stac92hd71bxx_mux_nids;
5365 spec->adc_nids = stac92hd71bxx_adc_nids;
5366 spec->smux_nids = stac92hd71bxx_smux_nids;
5367 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5369 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5370 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5371 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5372 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5374 switch (spec->board_config) {
5376 /* enable internal microphone */
5377 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5378 stac92xx_auto_set_pinctl(codec, 0x0e,
5379 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5381 case STAC_DELL_M4_2:
5382 spec->num_dmics = 0;
5383 spec->num_smuxes = 0;
5384 spec->num_dmuxes = 0;
5386 case STAC_DELL_M4_1:
5387 case STAC_DELL_M4_3:
5388 spec->num_dmics = 1;
5389 spec->num_smuxes = 0;
5390 spec->num_dmuxes = 1;
5392 case STAC_HP_DV4_1222NR:
5393 spec->num_dmics = 1;
5394 /* I don't know if it needs 1 or 2 smuxes - will wait for
5395 * bug reports to fix if needed
5397 spec->num_smuxes = 1;
5398 spec->num_dmuxes = 1;
5399 spec->gpio_led = 0x01;
5402 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5403 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5404 /* HP dv6 gives the headphone pin as a line-out. Thus we
5405 * need to set hp_detect flag here to force to enable HP
5408 spec->hp_detect = 1;
5411 spec->num_dmics = 1;
5412 spec->num_dmuxes = 1;
5413 spec->num_smuxes = 1;
5414 /* orange/white mute led on GPIO3, orange=0, white=1 */
5415 spec->gpio_led = 0x08;
5419 #ifdef CONFIG_SND_HDA_POWER_SAVE
5420 if (spec->gpio_led) {
5421 spec->gpio_mask |= spec->gpio_led;
5422 spec->gpio_dir |= spec->gpio_led;
5423 spec->gpio_data |= spec->gpio_led;
5424 /* register check_power_status callback. */
5425 codec->patch_ops.check_power_status =
5426 stac92xx_hp_check_power_status;
5430 spec->multiout.dac_nids = spec->dac_nids;
5432 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5434 if (spec->board_config < 0) {
5435 printk(KERN_WARNING "hda_codec: No auto-config is "
5436 "available, default to model=ref\n");
5437 spec->board_config = STAC_92HD71BXX_REF;
5444 stac92xx_free(codec);
5448 codec->proc_widget_hook = stac92hd7x_proc_hook;
5453 static int patch_stac922x(struct hda_codec *codec)
5455 struct sigmatel_spec *spec;
5458 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5463 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5464 spec->pin_nids = stac922x_pin_nids;
5465 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5468 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5469 spec->gpio_mask = spec->gpio_dir = 0x03;
5470 spec->gpio_data = 0x03;
5471 /* Intel Macs have all same PCI SSID, so we need to check
5472 * codec SSID to distinguish the exact models
5474 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5475 switch (codec->subsystem_id) {
5478 spec->board_config = STAC_INTEL_MAC_V1;
5482 spec->board_config = STAC_INTEL_MAC_V2;
5490 spec->board_config = STAC_INTEL_MAC_V3;
5494 spec->board_config = STAC_INTEL_MAC_V4;
5498 spec->board_config = STAC_INTEL_MAC_V5;
5501 spec->board_config = STAC_INTEL_MAC_V3;
5507 if (spec->board_config < 0)
5508 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5511 stac92xx_set_config_regs(codec,
5512 stac922x_brd_tbl[spec->board_config]);
5514 spec->adc_nids = stac922x_adc_nids;
5515 spec->mux_nids = stac922x_mux_nids;
5516 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5517 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5518 spec->num_dmics = 0;
5521 spec->init = stac922x_core_init;
5523 spec->num_caps = STAC922X_NUM_CAPS;
5524 spec->capvols = stac922x_capvols;
5525 spec->capsws = stac922x_capsws;
5527 spec->multiout.dac_nids = spec->dac_nids;
5529 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5531 if (spec->board_config < 0) {
5532 printk(KERN_WARNING "hda_codec: No auto-config is "
5533 "available, default to model=ref\n");
5534 spec->board_config = STAC_D945_REF;
5540 stac92xx_free(codec);
5544 codec->patch_ops = stac92xx_patch_ops;
5546 /* Fix Mux capture level; max to 2 */
5547 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5548 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5549 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5550 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5551 (0 << AC_AMPCAP_MUTE_SHIFT));
5556 static int patch_stac927x(struct hda_codec *codec)
5558 struct sigmatel_spec *spec;
5561 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5566 codec->slave_dig_outs = stac927x_slave_dig_outs;
5567 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5568 spec->pin_nids = stac927x_pin_nids;
5569 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5573 if (spec->board_config < 0)
5574 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5577 stac92xx_set_config_regs(codec,
5578 stac927x_brd_tbl[spec->board_config]);
5580 spec->digbeep_nid = 0x23;
5581 spec->adc_nids = stac927x_adc_nids;
5582 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5583 spec->mux_nids = stac927x_mux_nids;
5584 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5585 spec->smux_nids = stac927x_smux_nids;
5586 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5587 spec->spdif_labels = stac927x_spdif_labels;
5588 spec->dac_list = stac927x_dac_nids;
5589 spec->multiout.dac_nids = spec->dac_nids;
5591 if (spec->board_config != STAC_D965_REF) {
5592 /* GPIO0 High = Enable EAPD */
5593 spec->eapd_mask = spec->gpio_mask = 0x01;
5594 spec->gpio_dir = spec->gpio_data = 0x01;
5597 switch (spec->board_config) {
5600 /* GPIO0 High = Enable EAPD */
5601 spec->num_dmics = 0;
5602 spec->init = d965_core_init;
5604 case STAC_DELL_BIOS:
5605 switch (codec->subsystem_id) {
5608 /* correct the device field to SPDIF out */
5609 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5612 /* configure the analog microphone on some laptops */
5613 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5614 /* correct the front output jack as a hp out */
5615 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5616 /* correct the front input jack as a mic */
5617 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5620 if (codec->subsystem_id != 0x1028022f) {
5621 /* GPIO2 High = Enable EAPD */
5622 spec->eapd_mask = spec->gpio_mask = 0x04;
5623 spec->gpio_dir = spec->gpio_data = 0x04;
5625 spec->dmic_nids = stac927x_dmic_nids;
5626 spec->num_dmics = STAC927X_NUM_DMICS;
5628 spec->init = d965_core_init;
5629 spec->dmux_nids = stac927x_dmux_nids;
5630 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5632 case STAC_927X_VOLKNOB:
5633 spec->num_dmics = 0;
5634 spec->init = stac927x_volknob_core_init;
5637 spec->num_dmics = 0;
5638 spec->init = stac927x_core_init;
5642 spec->num_caps = STAC927X_NUM_CAPS;
5643 spec->capvols = stac927x_capvols;
5644 spec->capsws = stac927x_capsws;
5647 spec->aloopback_ctl = stac927x_loopback;
5648 spec->aloopback_mask = 0x40;
5649 spec->aloopback_shift = 0;
5650 spec->eapd_switch = 1;
5652 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
5654 if (spec->board_config < 0) {
5655 printk(KERN_WARNING "hda_codec: No auto-config is "
5656 "available, default to model=ref\n");
5657 spec->board_config = STAC_D965_REF;
5663 stac92xx_free(codec);
5667 codec->patch_ops = stac92xx_patch_ops;
5669 codec->proc_widget_hook = stac927x_proc_hook;
5673 * The STAC927x seem to require fairly long delays for certain
5674 * command sequences. With too short delays (even if the answer
5675 * is set to RIRB properly), it results in the silence output
5676 * on some hardwares like Dell.
5678 * The below flag enables the longer delay (see get_response
5681 codec->bus->needs_damn_long_delay = 1;
5683 /* no jack detecion for ref-no-jd model */
5684 if (spec->board_config == STAC_D965_REF_NO_JD)
5685 spec->hp_detect = 0;
5690 static int patch_stac9205(struct hda_codec *codec)
5692 struct sigmatel_spec *spec;
5695 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5700 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
5701 spec->pin_nids = stac9205_pin_nids;
5702 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5706 if (spec->board_config < 0)
5707 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5710 stac92xx_set_config_regs(codec,
5711 stac9205_brd_tbl[spec->board_config]);
5713 spec->digbeep_nid = 0x23;
5714 spec->adc_nids = stac9205_adc_nids;
5715 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
5716 spec->mux_nids = stac9205_mux_nids;
5717 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
5718 spec->smux_nids = stac9205_smux_nids;
5719 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
5720 spec->dmic_nids = stac9205_dmic_nids;
5721 spec->num_dmics = STAC9205_NUM_DMICS;
5722 spec->dmux_nids = stac9205_dmux_nids;
5723 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
5726 spec->init = stac9205_core_init;
5727 spec->aloopback_ctl = stac9205_loopback;
5729 spec->num_caps = STAC9205_NUM_CAPS;
5730 spec->capvols = stac9205_capvols;
5731 spec->capsws = stac9205_capsws;
5733 spec->aloopback_mask = 0x40;
5734 spec->aloopback_shift = 0;
5735 /* Turn on/off EAPD per HP plugging */
5736 if (spec->board_config != STAC_9205_EAPD)
5737 spec->eapd_switch = 1;
5738 spec->multiout.dac_nids = spec->dac_nids;
5740 switch (spec->board_config){
5741 case STAC_9205_DELL_M43:
5742 /* Enable SPDIF in/out */
5743 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5744 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
5746 /* Enable unsol response for GPIO4/Dock HP connection */
5747 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5750 snd_hda_codec_write_cache(codec, codec->afg, 0,
5751 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5752 snd_hda_codec_write_cache(codec, codec->afg, 0,
5753 AC_VERB_SET_UNSOLICITED_ENABLE,
5756 spec->gpio_dir = 0x0b;
5757 spec->eapd_mask = 0x01;
5758 spec->gpio_mask = 0x1b;
5759 spec->gpio_mute = 0x10;
5760 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5763 spec->gpio_data = 0x01;
5766 /* SPDIF-In enabled */
5769 /* GPIO0 High = EAPD */
5770 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5771 spec->gpio_data = 0x01;
5775 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5777 if (spec->board_config < 0) {
5778 printk(KERN_WARNING "hda_codec: No auto-config is "
5779 "available, default to model=ref\n");
5780 spec->board_config = STAC_9205_REF;
5786 stac92xx_free(codec);
5790 codec->patch_ops = stac92xx_patch_ops;
5792 codec->proc_widget_hook = stac9205_proc_hook;
5801 static struct hda_verb stac9872_core_init[] = {
5802 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5803 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5807 static hda_nid_t stac9872_pin_nids[] = {
5808 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5812 static hda_nid_t stac9872_adc_nids[] = {
5816 static hda_nid_t stac9872_mux_nids[] = {
5820 static unsigned long stac9872_capvols[] = {
5821 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
5823 #define stac9872_capsws stac9872_capvols
5825 static unsigned int stac9872_vaio_pin_configs[9] = {
5826 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5827 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5831 static const char *stac9872_models[STAC_9872_MODELS] = {
5832 [STAC_9872_AUTO] = "auto",
5833 [STAC_9872_VAIO] = "vaio",
5836 static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5837 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5840 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5841 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
5842 "Sony VAIO F/S", STAC_9872_VAIO),
5846 static int patch_stac9872(struct hda_codec *codec)
5848 struct sigmatel_spec *spec;
5851 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5855 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5856 spec->pin_nids = stac9872_pin_nids;
5858 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5861 if (spec->board_config < 0)
5862 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5865 stac92xx_set_config_regs(codec,
5866 stac9872_brd_tbl[spec->board_config]);
5868 spec->multiout.dac_nids = spec->dac_nids;
5869 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5870 spec->adc_nids = stac9872_adc_nids;
5871 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5872 spec->mux_nids = stac9872_mux_nids;
5873 spec->init = stac9872_core_init;
5875 spec->capvols = stac9872_capvols;
5876 spec->capsws = stac9872_capsws;
5878 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5880 stac92xx_free(codec);
5883 spec->input_mux = &spec->private_imux;
5884 codec->patch_ops = stac92xx_patch_ops;
5892 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5893 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5894 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5895 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5896 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5897 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5898 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5899 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5900 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5901 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5902 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5903 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5904 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5905 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5906 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5907 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5908 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5909 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5910 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5911 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5912 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5913 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5914 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5915 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5916 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5917 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5918 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5919 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5920 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5921 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5922 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5923 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5924 /* The following does not take into account .id=0x83847661 when subsys =
5925 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5926 * currently not fully supported.
5928 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5929 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5930 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5931 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
5932 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5933 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5934 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5935 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5936 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5937 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5938 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5939 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5940 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5941 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5942 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5943 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
5944 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5945 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5946 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5947 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5948 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5949 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5950 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5951 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5952 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5953 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5954 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5955 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5959 MODULE_ALIAS("snd-hda-codec-id:8384*");
5960 MODULE_ALIAS("snd-hda-codec-id:111d*");
5962 MODULE_LICENSE("GPL");
5963 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5965 static struct hda_codec_preset_list sigmatel_list = {
5966 .preset = snd_hda_preset_sigmatel,
5967 .owner = THIS_MODULE,
5970 static int __init patch_sigmatel_init(void)
5972 return snd_hda_add_codec_preset(&sigmatel_list);
5975 static void __exit patch_sigmatel_exit(void)
5977 snd_hda_delete_codec_preset(&sigmatel_list);
5980 module_init(patch_sigmatel_init)
5981 module_exit(patch_sigmatel_exit)