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 <linux/dmi.h>
32 #include <sound/core.h>
33 #include <sound/asoundef.h>
34 #include <sound/jack.h>
35 #include "hda_codec.h"
36 #include "hda_local.h"
80 STAC_92HD73XX_NO_JD, /* no jack-detection */
94 STAC_92HD83XXX_PWR_REF,
113 STAC_92HD71BXX_MODELS
139 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
140 * is given, one of the above models will be
141 * chosen according to the subsystem id. */
142 /* for backward compatibility */
159 STAC_D965_REF_NO_JD, /* no jack-detection */
176 struct sigmatel_event {
183 struct sigmatel_jack {
186 struct snd_jack *jack;
189 struct sigmatel_mic_route {
192 signed char dmux_idx;
195 struct sigmatel_spec {
196 struct snd_kcontrol_new *mixers[4];
197 unsigned int num_mixers;
200 unsigned int eapd_switch: 1;
201 unsigned int surr_switch: 1;
202 unsigned int alt_switch: 1;
203 unsigned int hp_detect: 1;
204 unsigned int spdif_mute: 1;
205 unsigned int check_volume_offset:1;
206 unsigned int auto_mic:1;
207 unsigned int linear_tone_beep:1;
210 unsigned int eapd_mask;
211 unsigned int gpio_mask;
212 unsigned int gpio_dir;
213 unsigned int gpio_data;
214 unsigned int gpio_mute;
215 unsigned int gpio_led;
216 unsigned int gpio_led_polarity;
219 unsigned int stream_delay;
221 /* analog loopback */
222 struct snd_kcontrol_new *aloopback_ctl;
223 unsigned char aloopback_mask;
224 unsigned char aloopback_shift;
226 /* power management */
227 unsigned int num_pwrs;
228 unsigned int *pwr_mapping;
233 struct snd_array jacks;
236 struct snd_array events;
239 struct hda_input_mux *mono_mux;
240 unsigned int cur_mmux;
241 struct hda_multi_out multiout;
242 hda_nid_t dac_nids[5];
243 hda_nid_t hp_dacs[5];
244 hda_nid_t speaker_dacs[5];
250 unsigned int num_adcs;
252 unsigned int num_muxes;
253 hda_nid_t *dmic_nids;
254 unsigned int num_dmics;
255 hda_nid_t *dmux_nids;
256 unsigned int num_dmuxes;
257 hda_nid_t *smux_nids;
258 unsigned int num_smuxes;
259 unsigned int num_analog_muxes;
261 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
262 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
263 unsigned int num_caps; /* number of capture volume/switch elements */
265 struct sigmatel_mic_route ext_mic;
266 struct sigmatel_mic_route int_mic;
268 const char **spdif_labels;
270 hda_nid_t dig_in_nid;
272 hda_nid_t anabeep_nid;
273 hda_nid_t digbeep_nid;
277 unsigned int num_pins;
279 /* codec specific stuff */
280 struct hda_verb *init;
281 struct snd_kcontrol_new *mixer;
284 struct hda_input_mux *dinput_mux;
285 unsigned int cur_dmux[2];
286 struct hda_input_mux *input_mux;
287 unsigned int cur_mux[3];
288 struct hda_input_mux *sinput_mux;
289 unsigned int cur_smux[2];
290 unsigned int cur_amux;
292 unsigned int powerdown_adcs;
295 unsigned int io_switch[2];
296 unsigned int clfe_swap;
297 hda_nid_t line_switch; /* shared line-in for input and output */
298 hda_nid_t mic_switch; /* shared mic-in for input and output */
299 hda_nid_t hp_switch; /* NID of HP as line-out */
300 unsigned int aloopback;
302 struct hda_pcm pcm_rec[2]; /* PCM information */
304 /* dynamic controls and input_mux */
305 struct auto_pin_cfg autocfg;
306 struct snd_array kctls;
307 struct hda_input_mux private_dimux;
308 struct hda_input_mux private_imux;
309 struct hda_input_mux private_smux;
310 struct hda_input_mux private_mono_mux;
313 static hda_nid_t stac9200_adc_nids[1] = {
317 static hda_nid_t stac9200_mux_nids[1] = {
321 static hda_nid_t stac9200_dac_nids[1] = {
325 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
326 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
330 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
334 static hda_nid_t stac92hd73xx_adc_nids[2] = {
338 #define STAC92HD73XX_NUM_DMICS 2
339 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
343 #define STAC92HD73_DAC_COUNT 5
345 static hda_nid_t stac92hd73xx_mux_nids[2] = {
349 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
353 static hda_nid_t stac92hd73xx_smux_nids[2] = {
357 #define STAC92HD73XX_NUM_CAPS 2
358 static unsigned long stac92hd73xx_capvols[] = {
359 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
360 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
362 #define stac92hd73xx_capsws stac92hd73xx_capvols
364 #define STAC92HD83_DAC_COUNT 3
366 static hda_nid_t stac92hd83xxx_mux_nids[2] = {
370 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
374 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
378 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
382 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
383 0x03, 0x0c, 0x20, 0x40,
386 #define STAC92HD83XXX_NUM_CAPS 2
387 static unsigned long stac92hd83xxx_capvols[] = {
388 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
389 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
391 #define stac92hd83xxx_capsws stac92hd83xxx_capvols
393 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
397 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
401 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
405 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
409 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
413 #define STAC92HD71BXX_NUM_DMICS 2
414 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
418 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
422 #define STAC92HD71BXX_NUM_CAPS 2
423 static unsigned long stac92hd71bxx_capvols[] = {
424 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
425 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
427 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
429 static hda_nid_t stac925x_adc_nids[1] = {
433 static hda_nid_t stac925x_mux_nids[1] = {
437 static hda_nid_t stac925x_dac_nids[1] = {
441 #define STAC925X_NUM_DMICS 1
442 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
446 static hda_nid_t stac925x_dmux_nids[1] = {
450 static unsigned long stac925x_capvols[] = {
451 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
453 static unsigned long stac925x_capsws[] = {
454 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
457 static hda_nid_t stac922x_adc_nids[2] = {
461 static hda_nid_t stac922x_mux_nids[2] = {
465 #define STAC922X_NUM_CAPS 2
466 static unsigned long stac922x_capvols[] = {
467 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
468 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
470 #define stac922x_capsws stac922x_capvols
472 static hda_nid_t stac927x_slave_dig_outs[2] = {
476 static hda_nid_t stac927x_adc_nids[3] = {
480 static hda_nid_t stac927x_mux_nids[3] = {
484 static hda_nid_t stac927x_smux_nids[1] = {
488 static hda_nid_t stac927x_dac_nids[6] = {
489 0x02, 0x03, 0x04, 0x05, 0x06, 0
492 static hda_nid_t stac927x_dmux_nids[1] = {
496 #define STAC927X_NUM_DMICS 2
497 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
501 #define STAC927X_NUM_CAPS 3
502 static unsigned long stac927x_capvols[] = {
503 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
504 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
505 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
507 static unsigned long stac927x_capsws[] = {
508 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
509 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
510 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
513 static const char *stac927x_spdif_labels[5] = {
514 "Digital Playback", "ADAT", "Analog Mux 1",
515 "Analog Mux 2", "Analog Mux 3"
518 static hda_nid_t stac9205_adc_nids[2] = {
522 static hda_nid_t stac9205_mux_nids[2] = {
526 static hda_nid_t stac9205_dmux_nids[1] = {
530 static hda_nid_t stac9205_smux_nids[1] = {
534 #define STAC9205_NUM_DMICS 2
535 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
539 #define STAC9205_NUM_CAPS 2
540 static unsigned long stac9205_capvols[] = {
541 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
542 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
544 static unsigned long stac9205_capsws[] = {
545 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
546 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
549 static hda_nid_t stac9200_pin_nids[8] = {
550 0x08, 0x09, 0x0d, 0x0e,
551 0x0f, 0x10, 0x11, 0x12,
554 static hda_nid_t stac925x_pin_nids[8] = {
555 0x07, 0x08, 0x0a, 0x0b,
556 0x0c, 0x0d, 0x10, 0x11,
559 static hda_nid_t stac922x_pin_nids[10] = {
560 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
561 0x0f, 0x10, 0x11, 0x15, 0x1b,
564 static hda_nid_t stac92hd73xx_pin_nids[13] = {
565 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
566 0x0f, 0x10, 0x11, 0x12, 0x13,
570 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
571 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
572 0x0f, 0x10, 0x11, 0x1f, 0x20,
575 static hda_nid_t stac92hd88xxx_pin_nids[10] = {
576 0x0a, 0x0b, 0x0c, 0x0d,
577 0x0f, 0x11, 0x1f, 0x20,
580 #define STAC92HD71BXX_NUM_PINS 13
581 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
582 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
583 0x00, 0x14, 0x18, 0x19, 0x1e,
586 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
587 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
588 0x0f, 0x14, 0x18, 0x19, 0x1e,
592 static hda_nid_t stac927x_pin_nids[14] = {
593 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
594 0x0f, 0x10, 0x11, 0x12, 0x13,
595 0x14, 0x21, 0x22, 0x23,
598 static hda_nid_t stac9205_pin_nids[12] = {
599 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
600 0x0f, 0x14, 0x16, 0x17, 0x18,
604 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
605 struct snd_ctl_elem_info *uinfo)
607 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
608 struct sigmatel_spec *spec = codec->spec;
609 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
612 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
613 struct snd_ctl_elem_value *ucontrol)
615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
616 struct sigmatel_spec *spec = codec->spec;
617 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
619 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
623 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
624 struct snd_ctl_elem_value *ucontrol)
626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
627 struct sigmatel_spec *spec = codec->spec;
628 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
630 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
631 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
634 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
635 struct snd_ctl_elem_info *uinfo)
637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
638 struct sigmatel_spec *spec = codec->spec;
639 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
642 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 struct sigmatel_spec *spec = codec->spec;
647 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
649 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
653 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
654 struct snd_ctl_elem_value *ucontrol)
656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
657 struct sigmatel_spec *spec = codec->spec;
658 struct hda_input_mux *smux = &spec->private_smux;
659 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
663 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
664 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
668 if (spec->spdif_mute) {
670 nid = spec->multiout.dig_out_nid;
672 nid = codec->slave_dig_outs[smux_idx - 1];
673 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
677 /* un/mute SPDIF out */
678 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
684 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
685 hda_nid_t nid, unsigned int new_vref)
689 pincfg = snd_hda_codec_read(codec, nid, 0,
690 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
693 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
696 if (new_vref == AC_PINCTL_VREF_HIZ)
697 pincfg |= AC_PINCTL_OUT_EN;
699 pincfg |= AC_PINCTL_IN_EN;
701 error = snd_hda_codec_write_cache(codec, nid, 0,
702 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
709 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
712 vref = snd_hda_codec_read(codec, nid, 0,
713 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
714 vref &= AC_PINCTL_VREFEN;
718 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
720 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
721 struct sigmatel_spec *spec = codec->spec;
722 return snd_hda_input_mux_info(spec->input_mux, uinfo);
725 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
727 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
728 struct sigmatel_spec *spec = codec->spec;
729 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
731 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
735 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
738 struct sigmatel_spec *spec = codec->spec;
739 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
740 const struct hda_input_mux *imux = spec->input_mux;
741 unsigned int idx, prev_idx;
743 idx = ucontrol->value.enumerated.item[0];
744 if (idx >= imux->num_items)
745 idx = imux->num_items - 1;
746 prev_idx = spec->cur_mux[adc_idx];
749 if (idx < spec->num_analog_muxes) {
750 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
751 AC_VERB_SET_CONNECT_SEL,
752 imux->items[idx].index);
753 if (prev_idx >= spec->num_analog_muxes) {
754 imux = spec->dinput_mux;
756 snd_hda_codec_write_cache(codec,
757 spec->dmux_nids[adc_idx], 0,
758 AC_VERB_SET_CONNECT_SEL,
759 imux->items[0].index);
762 imux = spec->dinput_mux;
763 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
764 AC_VERB_SET_CONNECT_SEL,
765 imux->items[idx - 1].index);
767 spec->cur_mux[adc_idx] = idx;
771 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
772 struct snd_ctl_elem_info *uinfo)
774 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
775 struct sigmatel_spec *spec = codec->spec;
776 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
779 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
780 struct snd_ctl_elem_value *ucontrol)
782 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
783 struct sigmatel_spec *spec = codec->spec;
785 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
789 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
790 struct snd_ctl_elem_value *ucontrol)
792 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
793 struct sigmatel_spec *spec = codec->spec;
795 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
796 spec->mono_nid, &spec->cur_mmux);
799 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
801 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
802 struct snd_ctl_elem_value *ucontrol)
804 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
805 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
806 struct sigmatel_spec *spec = codec->spec;
808 ucontrol->value.integer.value[0] = !!(spec->aloopback &
809 (spec->aloopback_mask << idx));
813 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
814 struct snd_ctl_elem_value *ucontrol)
816 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
817 struct sigmatel_spec *spec = codec->spec;
818 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
819 unsigned int dac_mode;
820 unsigned int val, idx_val;
822 idx_val = spec->aloopback_mask << idx;
823 if (ucontrol->value.integer.value[0])
824 val = spec->aloopback | idx_val;
826 val = spec->aloopback & ~idx_val;
827 if (spec->aloopback == val)
830 spec->aloopback = val;
832 /* Only return the bits defined by the shift value of the
833 * first two bytes of the mask
835 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
836 kcontrol->private_value & 0xFFFF, 0x0);
837 dac_mode >>= spec->aloopback_shift;
839 if (spec->aloopback & idx_val) {
840 snd_hda_power_up(codec);
843 snd_hda_power_down(codec);
844 dac_mode &= ~idx_val;
847 snd_hda_codec_write_cache(codec, codec->afg, 0,
848 kcontrol->private_value >> 16, dac_mode);
853 static struct hda_verb stac9200_core_init[] = {
854 /* set dac0mux for dac converter */
855 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
859 static struct hda_verb stac9200_eapd_init[] = {
860 /* set dac0mux for dac converter */
861 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
862 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
866 static struct hda_verb dell_eq_core_init[] = {
867 /* set master volume to max value without distortion
868 * and direct control */
869 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
873 static struct hda_verb stac92hd73xx_core_init[] = {
874 /* set master volume and direct control */
875 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
879 static struct hda_verb stac92hd83xxx_core_init[] = {
880 /* power state controls amps */
881 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
885 static struct hda_verb stac92hd71bxx_core_init[] = {
886 /* set master volume and direct control */
887 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
891 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
892 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
893 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
894 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
895 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
899 static struct hda_verb stac925x_core_init[] = {
900 /* set dac0mux for dac converter */
901 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
902 /* mute the master volume */
903 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
907 static struct hda_verb stac922x_core_init[] = {
908 /* set master volume and direct control */
909 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
913 static struct hda_verb d965_core_init[] = {
914 /* set master volume and direct control */
915 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
916 /* unmute node 0x1b */
917 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
918 /* select node 0x03 as DAC */
919 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
923 static struct hda_verb dell_3st_core_init[] = {
924 /* don't set delta bit */
925 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
926 /* unmute node 0x1b */
927 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
928 /* select node 0x03 as DAC */
929 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
933 static struct hda_verb stac927x_core_init[] = {
934 /* set master volume and direct control */
935 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
936 /* enable analog pc beep path */
937 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
941 static struct hda_verb stac927x_volknob_core_init[] = {
942 /* don't set delta bit */
943 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
944 /* enable analog pc beep path */
945 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
949 static struct hda_verb stac9205_core_init[] = {
950 /* set master volume and direct control */
951 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
952 /* enable analog pc beep path */
953 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
957 #define STAC_MONO_MUX \
959 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
960 .name = "Mono Mux", \
962 .info = stac92xx_mono_mux_enum_info, \
963 .get = stac92xx_mono_mux_enum_get, \
964 .put = stac92xx_mono_mux_enum_put, \
967 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
970 .name = "Analog Loopback", \
972 .info = stac92xx_aloopback_info, \
973 .get = stac92xx_aloopback_get, \
974 .put = stac92xx_aloopback_put, \
975 .private_value = verb_read | (verb_write << 16), \
978 #define DC_BIAS(xname, idx, nid) \
980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
983 .info = stac92xx_dc_bias_info, \
984 .get = stac92xx_dc_bias_get, \
985 .put = stac92xx_dc_bias_put, \
986 .private_value = nid, \
989 static struct snd_kcontrol_new stac9200_mixer[] = {
990 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
991 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
992 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
993 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
997 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
998 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1002 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1003 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1007 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1008 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1013 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1014 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1017 static struct snd_kcontrol_new stac925x_mixer[] = {
1018 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1019 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1023 static struct snd_kcontrol_new stac9205_loopback[] = {
1024 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1028 static struct snd_kcontrol_new stac927x_loopback[] = {
1029 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1033 static struct snd_kcontrol_new stac_dmux_mixer = {
1034 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1035 .name = "Digital Input Source",
1036 /* count set later */
1037 .info = stac92xx_dmux_enum_info,
1038 .get = stac92xx_dmux_enum_get,
1039 .put = stac92xx_dmux_enum_put,
1042 static struct snd_kcontrol_new stac_smux_mixer = {
1043 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1044 .name = "IEC958 Playback Source",
1045 /* count set later */
1046 .info = stac92xx_smux_enum_info,
1047 .get = stac92xx_smux_enum_get,
1048 .put = stac92xx_smux_enum_put,
1051 static const char *slave_vols[] = {
1052 "Front Playback Volume",
1053 "Surround Playback Volume",
1054 "Center Playback Volume",
1055 "LFE Playback Volume",
1056 "Side Playback Volume",
1057 "Headphone Playback Volume",
1058 "Speaker Playback Volume",
1062 static const char *slave_sws[] = {
1063 "Front Playback Switch",
1064 "Surround Playback Switch",
1065 "Center Playback Switch",
1066 "LFE Playback Switch",
1067 "Side Playback Switch",
1068 "Headphone Playback Switch",
1069 "Speaker Playback Switch",
1070 "IEC958 Playback Switch",
1074 static void stac92xx_free_kctls(struct hda_codec *codec);
1075 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1077 static int stac92xx_build_controls(struct hda_codec *codec)
1079 struct sigmatel_spec *spec = codec->spec;
1080 struct auto_pin_cfg *cfg = &spec->autocfg;
1086 err = snd_hda_add_new_ctls(codec, spec->mixer);
1091 for (i = 0; i < spec->num_mixers; i++) {
1092 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1096 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1097 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1098 stac_dmux_mixer.count = spec->num_dmuxes;
1099 err = snd_hda_ctl_add(codec, 0,
1100 snd_ctl_new1(&stac_dmux_mixer, codec));
1104 if (spec->num_smuxes > 0) {
1105 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1106 struct hda_input_mux *smux = &spec->private_smux;
1107 /* check for mute support on SPDIF out */
1108 if (wcaps & AC_WCAP_OUT_AMP) {
1109 smux->items[smux->num_items].label = "Off";
1110 smux->items[smux->num_items].index = 0;
1112 spec->spdif_mute = 1;
1114 stac_smux_mixer.count = spec->num_smuxes;
1115 err = snd_hda_ctl_add(codec, 0,
1116 snd_ctl_new1(&stac_smux_mixer, codec));
1121 if (spec->multiout.dig_out_nid) {
1122 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1125 err = snd_hda_create_spdif_share_sw(codec,
1129 spec->multiout.share_spdif = 1;
1131 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1132 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1137 /* if we have no master control, let's create it */
1138 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1139 unsigned int vmaster_tlv[4];
1140 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1141 HDA_OUTPUT, vmaster_tlv);
1142 /* correct volume offset */
1143 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1144 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1145 vmaster_tlv, slave_vols);
1149 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1150 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1156 if (spec->aloopback_ctl &&
1157 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1158 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1163 stac92xx_free_kctls(codec); /* no longer needed */
1165 /* create jack input elements */
1166 if (spec->hp_detect) {
1167 for (i = 0; i < cfg->hp_outs; i++) {
1168 int type = SND_JACK_HEADPHONE;
1169 nid = cfg->hp_pins[i];
1170 /* jack detection */
1171 if (cfg->hp_outs == i)
1172 type |= SND_JACK_LINEOUT;
1173 err = stac92xx_add_jack(codec, nid, type);
1178 for (i = 0; i < cfg->line_outs; i++) {
1179 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1184 for (i = 0; i < AUTO_PIN_LAST; i++) {
1185 nid = cfg->input_pins[i];
1187 err = stac92xx_add_jack(codec, nid,
1188 SND_JACK_MICROPHONE);
1197 static unsigned int ref9200_pin_configs[8] = {
1198 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1199 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1202 static unsigned int gateway9200_m4_pin_configs[8] = {
1203 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1204 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1206 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1207 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1208 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1212 STAC 9200 pin configs for
1217 static unsigned int dell9200_d21_pin_configs[8] = {
1218 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1219 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1223 STAC 9200 pin configs for
1227 static unsigned int dell9200_d22_pin_configs[8] = {
1228 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1229 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1233 STAC 9200 pin configs for
1234 102801C4 (Dell Dimension E310)
1241 static unsigned int dell9200_d23_pin_configs[8] = {
1242 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1243 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1248 STAC 9200-32 pin configs for
1249 102801B5 (Dell Inspiron 630m)
1250 102801D8 (Dell Inspiron 640m)
1252 static unsigned int dell9200_m21_pin_configs[8] = {
1253 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1254 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1258 STAC 9200-32 pin configs for
1259 102801C2 (Dell Latitude D620)
1261 102801CC (Dell Latitude D820)
1265 static unsigned int dell9200_m22_pin_configs[8] = {
1266 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1267 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1271 STAC 9200-32 pin configs for
1272 102801CE (Dell XPS M1710)
1273 102801CF (Dell Precision M90)
1275 static unsigned int dell9200_m23_pin_configs[8] = {
1276 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1277 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1281 STAC 9200-32 pin configs for
1284 102801CB (Dell Latitude 120L)
1287 static unsigned int dell9200_m24_pin_configs[8] = {
1288 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1289 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1293 STAC 9200-32 pin configs for
1294 102801BD (Dell Inspiron E1505n)
1298 static unsigned int dell9200_m25_pin_configs[8] = {
1299 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1300 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1304 STAC 9200-32 pin configs for
1305 102801F5 (Dell Inspiron 1501)
1308 static unsigned int dell9200_m26_pin_configs[8] = {
1309 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1310 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1315 102801CD (Dell Inspiron E1705/9400)
1317 static unsigned int dell9200_m27_pin_configs[8] = {
1318 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1319 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1322 static unsigned int oqo9200_pin_configs[8] = {
1323 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1324 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1328 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1329 [STAC_REF] = ref9200_pin_configs,
1330 [STAC_9200_OQO] = oqo9200_pin_configs,
1331 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1332 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1333 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1334 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1335 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1336 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1337 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1338 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1339 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1340 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1341 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1342 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1343 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1346 static const char *stac9200_models[STAC_9200_MODELS] = {
1347 [STAC_AUTO] = "auto",
1349 [STAC_9200_OQO] = "oqo",
1350 [STAC_9200_DELL_D21] = "dell-d21",
1351 [STAC_9200_DELL_D22] = "dell-d22",
1352 [STAC_9200_DELL_D23] = "dell-d23",
1353 [STAC_9200_DELL_M21] = "dell-m21",
1354 [STAC_9200_DELL_M22] = "dell-m22",
1355 [STAC_9200_DELL_M23] = "dell-m23",
1356 [STAC_9200_DELL_M24] = "dell-m24",
1357 [STAC_9200_DELL_M25] = "dell-m25",
1358 [STAC_9200_DELL_M26] = "dell-m26",
1359 [STAC_9200_DELL_M27] = "dell-m27",
1360 [STAC_9200_M4] = "gateway-m4",
1361 [STAC_9200_M4_2] = "gateway-m4-2",
1362 [STAC_9200_PANASONIC] = "panasonic",
1365 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1366 /* SigmaTel reference board */
1367 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1368 "DFI LanParty", STAC_REF),
1369 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1370 "DFI LanParty", STAC_REF),
1371 /* Dell laptops have BIOS problem */
1372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1373 "unknown Dell", STAC_9200_DELL_D21),
1374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1375 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1377 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1379 "unknown Dell", STAC_9200_DELL_D22),
1380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1381 "unknown Dell", STAC_9200_DELL_D22),
1382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1383 "Dell Latitude D620", STAC_9200_DELL_M22),
1384 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1385 "unknown Dell", STAC_9200_DELL_D23),
1386 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1387 "unknown Dell", STAC_9200_DELL_D23),
1388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1389 "unknown Dell", STAC_9200_DELL_M22),
1390 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1391 "unknown Dell", STAC_9200_DELL_M24),
1392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1393 "unknown Dell", STAC_9200_DELL_M24),
1394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1395 "Dell Latitude 120L", STAC_9200_DELL_M24),
1396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1397 "Dell Latitude D820", STAC_9200_DELL_M22),
1398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1399 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1401 "Dell XPS M1710", STAC_9200_DELL_M23),
1402 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1403 "Dell Precision M90", STAC_9200_DELL_M23),
1404 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1405 "unknown Dell", STAC_9200_DELL_M22),
1406 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1407 "unknown Dell", STAC_9200_DELL_M22),
1408 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1409 "unknown Dell", STAC_9200_DELL_M22),
1410 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1411 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1412 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1413 "unknown Dell", STAC_9200_DELL_D23),
1414 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1415 "unknown Dell", STAC_9200_DELL_D23),
1416 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1417 "unknown Dell", STAC_9200_DELL_D21),
1418 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1419 "unknown Dell", STAC_9200_DELL_D23),
1420 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1421 "unknown Dell", STAC_9200_DELL_D21),
1422 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1423 "unknown Dell", STAC_9200_DELL_M25),
1424 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1425 "unknown Dell", STAC_9200_DELL_M25),
1426 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1427 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1428 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1429 "unknown Dell", STAC_9200_DELL_M26),
1431 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1432 /* Gateway machines needs EAPD to be set on resume */
1433 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1434 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1435 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1437 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1441 static unsigned int ref925x_pin_configs[8] = {
1442 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1443 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1446 static unsigned int stac925xM1_pin_configs[8] = {
1447 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1448 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1451 static unsigned int stac925xM1_2_pin_configs[8] = {
1452 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1453 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1456 static unsigned int stac925xM2_pin_configs[8] = {
1457 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1458 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1461 static unsigned int stac925xM2_2_pin_configs[8] = {
1462 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1463 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1466 static unsigned int stac925xM3_pin_configs[8] = {
1467 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1468 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1471 static unsigned int stac925xM5_pin_configs[8] = {
1472 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1473 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1476 static unsigned int stac925xM6_pin_configs[8] = {
1477 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1478 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1481 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1482 [STAC_REF] = ref925x_pin_configs,
1483 [STAC_M1] = stac925xM1_pin_configs,
1484 [STAC_M1_2] = stac925xM1_2_pin_configs,
1485 [STAC_M2] = stac925xM2_pin_configs,
1486 [STAC_M2_2] = stac925xM2_2_pin_configs,
1487 [STAC_M3] = stac925xM3_pin_configs,
1488 [STAC_M5] = stac925xM5_pin_configs,
1489 [STAC_M6] = stac925xM6_pin_configs,
1492 static const char *stac925x_models[STAC_925x_MODELS] = {
1493 [STAC_925x_AUTO] = "auto",
1496 [STAC_M1_2] = "m1-2",
1498 [STAC_M2_2] = "m2-2",
1504 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1505 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1506 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1507 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1508 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1509 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1510 /* Not sure about the brand name for those */
1511 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1512 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1513 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1514 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1518 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1519 /* SigmaTel reference board */
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1521 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1522 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1524 /* Default table for unknown ID */
1525 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1530 static unsigned int ref92hd73xx_pin_configs[13] = {
1531 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1532 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1533 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1537 static unsigned int dell_m6_pin_configs[13] = {
1538 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1539 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1540 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1544 static unsigned int alienware_m17x_pin_configs[13] = {
1545 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1546 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1547 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1551 static unsigned int intel_dg45id_pin_configs[13] = {
1552 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
1553 0x01A19250, 0x01011212, 0x01016211
1556 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1557 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1558 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1559 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1560 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1561 [STAC_DELL_EQ] = dell_m6_pin_configs,
1562 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
1563 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
1566 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1567 [STAC_92HD73XX_AUTO] = "auto",
1568 [STAC_92HD73XX_NO_JD] = "no-jd",
1569 [STAC_92HD73XX_REF] = "ref",
1570 [STAC_92HD73XX_INTEL] = "intel",
1571 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1572 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1573 [STAC_DELL_M6_BOTH] = "dell-m6",
1574 [STAC_DELL_EQ] = "dell-eq",
1575 [STAC_ALIENWARE_M17X] = "alienware",
1578 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1579 /* SigmaTel reference board */
1580 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1581 "DFI LanParty", STAC_92HD73XX_REF),
1582 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1583 "DFI LanParty", STAC_92HD73XX_REF),
1584 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1585 "Intel DG45ID", STAC_92HD73XX_INTEL),
1586 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1587 "Intel DG45FC", STAC_92HD73XX_INTEL),
1588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1589 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1591 "unknown Dell", STAC_DELL_M6_DMIC),
1592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1593 "unknown Dell", STAC_DELL_M6_BOTH),
1594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1595 "unknown Dell", STAC_DELL_M6_BOTH),
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1597 "unknown Dell", STAC_DELL_M6_AMIC),
1598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1599 "unknown Dell", STAC_DELL_M6_AMIC),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1601 "unknown Dell", STAC_DELL_M6_DMIC),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1603 "unknown Dell", STAC_DELL_M6_DMIC),
1604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1605 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1607 "Dell Studio 17", STAC_DELL_M6_DMIC),
1608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1609 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1611 "Dell Studio 1557", STAC_DELL_M6_DMIC),
1612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
1613 "Dell Studio XPS 1645", STAC_DELL_M6_BOTH),
1614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
1615 "Dell Studio 1558", STAC_DELL_M6_BOTH),
1619 static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1621 "Alienware M17x", STAC_ALIENWARE_M17X),
1622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1623 "Alienware M17x", STAC_ALIENWARE_M17X),
1627 static unsigned int ref92hd83xxx_pin_configs[10] = {
1628 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1629 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1630 0x01451160, 0x98560170,
1633 static unsigned int dell_s14_pin_configs[10] = {
1634 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1635 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
1636 0x40f000f0, 0x40f000f0,
1639 /* Deliberately turn off 0x0f (Dock Mic) to make it choose Int Mic instead */
1640 static unsigned int dell_e6410_pin_configs[10] = {
1641 0x04a11020, 0x0421101f, 0x400000f0, 0x90170110,
1642 0x23011050, 0x40f000f0, 0x400000f0, 0x90a60130,
1643 0x40f000f0, 0x40f000f0,
1646 static unsigned int hp_dv7_4000_pin_configs[10] = {
1647 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1648 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1649 0x40f000f0, 0x40f000f0,
1652 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1653 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1654 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1655 [STAC_DELL_S14] = dell_s14_pin_configs,
1656 [STAC_DELL_E6410] = dell_e6410_pin_configs,
1657 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
1660 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1661 [STAC_92HD83XXX_AUTO] = "auto",
1662 [STAC_92HD83XXX_REF] = "ref",
1663 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1664 [STAC_DELL_S14] = "dell-s14",
1665 [STAC_DELL_E6410] = "dell-e6410",
1666 [STAC_92HD83XXX_HP] = "hp",
1667 [STAC_HP_DV7_4000] = "hp-dv7-4000",
1670 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1671 /* SigmaTel reference board */
1672 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1673 "DFI LanParty", STAC_92HD83XXX_REF),
1674 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1675 "DFI LanParty", STAC_92HD83XXX_REF),
1676 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1677 "unknown Dell", STAC_DELL_S14),
1678 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x040a,
1679 "Dell E6410", STAC_DELL_E6410),
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x040b,
1681 "Dell E6510", STAC_DELL_E6410),
1682 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x3600,
1683 "HP", STAC_92HD83XXX_HP),
1687 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1688 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1689 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1690 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1694 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1695 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1696 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1697 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1701 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1702 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1703 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1704 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1708 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1709 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1710 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1711 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1715 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1716 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1717 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1718 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1719 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1720 [STAC_HP_M4] = NULL,
1721 [STAC_HP_DV4] = NULL,
1722 [STAC_HP_DV5] = NULL,
1723 [STAC_HP_HDX] = NULL,
1724 [STAC_HP_DV4_1222NR] = NULL,
1727 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1728 [STAC_92HD71BXX_AUTO] = "auto",
1729 [STAC_92HD71BXX_REF] = "ref",
1730 [STAC_DELL_M4_1] = "dell-m4-1",
1731 [STAC_DELL_M4_2] = "dell-m4-2",
1732 [STAC_DELL_M4_3] = "dell-m4-3",
1733 [STAC_HP_M4] = "hp-m4",
1734 [STAC_HP_DV4] = "hp-dv4",
1735 [STAC_HP_DV5] = "hp-dv5",
1736 [STAC_HP_HDX] = "hp-hdx",
1737 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1740 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1741 /* SigmaTel reference board */
1742 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1743 "DFI LanParty", STAC_92HD71BXX_REF),
1744 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1745 "DFI LanParty", STAC_92HD71BXX_REF),
1746 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1747 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1748 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1750 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1752 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1753 "HP dv4-7", STAC_HP_DV4),
1754 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1755 "HP dv4-7", STAC_HP_DV5),
1756 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1757 "HP HDX", STAC_HP_HDX), /* HDX18 */
1758 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1759 "HP mini 1000", STAC_HP_M4),
1760 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1761 "HP HDX", STAC_HP_HDX), /* HDX16 */
1762 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1763 "HP dv6", STAC_HP_DV5),
1764 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1765 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
1766 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
1767 "HP DV6", STAC_HP_DV5),
1768 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1770 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1771 "unknown Dell", STAC_DELL_M4_1),
1772 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1773 "unknown Dell", STAC_DELL_M4_1),
1774 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1775 "unknown Dell", STAC_DELL_M4_1),
1776 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1777 "unknown Dell", STAC_DELL_M4_1),
1778 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1779 "unknown Dell", STAC_DELL_M4_1),
1780 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1781 "unknown Dell", STAC_DELL_M4_1),
1782 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1783 "unknown Dell", STAC_DELL_M4_1),
1784 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1785 "unknown Dell", STAC_DELL_M4_2),
1786 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1787 "unknown Dell", STAC_DELL_M4_2),
1788 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1789 "unknown Dell", STAC_DELL_M4_2),
1790 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1791 "unknown Dell", STAC_DELL_M4_2),
1792 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1793 "unknown Dell", STAC_DELL_M4_3),
1797 static unsigned int ref922x_pin_configs[10] = {
1798 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1799 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1800 0x40000100, 0x40000100,
1804 STAC 922X pin configs for
1811 static unsigned int dell_922x_d81_pin_configs[10] = {
1812 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1813 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1814 0x01813122, 0x400001f2,
1818 STAC 922X pin configs for
1822 static unsigned int dell_922x_d82_pin_configs[10] = {
1823 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1824 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1825 0x01813122, 0x400001f1,
1829 STAC 922X pin configs for
1832 static unsigned int dell_922x_m81_pin_configs[10] = {
1833 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1834 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1835 0x40C003f1, 0x405003f0,
1839 STAC 9221 A1 pin configs for
1840 102801D7 (Dell XPS M1210)
1842 static unsigned int dell_922x_m82_pin_configs[10] = {
1843 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1844 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1845 0x508003f3, 0x405003f4,
1848 static unsigned int d945gtp3_pin_configs[10] = {
1849 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1850 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1851 0x02a19120, 0x40000100,
1854 static unsigned int d945gtp5_pin_configs[10] = {
1855 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1856 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1857 0x02a19320, 0x40000100,
1860 static unsigned int intel_mac_v1_pin_configs[10] = {
1861 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1862 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1863 0x400000fc, 0x400000fb,
1866 static unsigned int intel_mac_v2_pin_configs[10] = {
1867 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1868 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1869 0x400000fc, 0x400000fb,
1872 static unsigned int intel_mac_v3_pin_configs[10] = {
1873 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1874 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1875 0x400000fc, 0x400000fb,
1878 static unsigned int intel_mac_v4_pin_configs[10] = {
1879 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1880 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1881 0x400000fc, 0x400000fb,
1884 static unsigned int intel_mac_v5_pin_configs[10] = {
1885 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1886 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1887 0x400000fc, 0x400000fb,
1890 static unsigned int ecs202_pin_configs[10] = {
1891 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1892 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1893 0x9037012e, 0x40e000f2,
1896 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1897 [STAC_D945_REF] = ref922x_pin_configs,
1898 [STAC_D945GTP3] = d945gtp3_pin_configs,
1899 [STAC_D945GTP5] = d945gtp5_pin_configs,
1900 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1901 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1902 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1903 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1904 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1905 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1906 /* for backward compatibility */
1907 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1908 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1909 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1910 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1911 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1912 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1913 [STAC_ECS_202] = ecs202_pin_configs,
1914 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1915 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1916 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1917 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1920 static const char *stac922x_models[STAC_922X_MODELS] = {
1921 [STAC_922X_AUTO] = "auto",
1922 [STAC_D945_REF] = "ref",
1923 [STAC_D945GTP5] = "5stack",
1924 [STAC_D945GTP3] = "3stack",
1925 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1926 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1927 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1928 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1929 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1930 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1931 /* for backward compatibility */
1932 [STAC_MACMINI] = "macmini",
1933 [STAC_MACBOOK] = "macbook",
1934 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1935 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1936 [STAC_IMAC_INTEL] = "imac-intel",
1937 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1938 [STAC_ECS_202] = "ecs202",
1939 [STAC_922X_DELL_D81] = "dell-d81",
1940 [STAC_922X_DELL_D82] = "dell-d82",
1941 [STAC_922X_DELL_M81] = "dell-m81",
1942 [STAC_922X_DELL_M82] = "dell-m82",
1945 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1946 /* SigmaTel reference board */
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1948 "DFI LanParty", STAC_D945_REF),
1949 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1950 "DFI LanParty", STAC_D945_REF),
1951 /* Intel 945G based systems */
1952 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1953 "Intel D945G", STAC_D945GTP3),
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1955 "Intel D945G", STAC_D945GTP3),
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1957 "Intel D945G", STAC_D945GTP3),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1959 "Intel D945G", STAC_D945GTP3),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1961 "Intel D945G", STAC_D945GTP3),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1963 "Intel D945G", STAC_D945GTP3),
1964 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1965 "Intel D945G", STAC_D945GTP3),
1966 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1967 "Intel D945G", STAC_D945GTP3),
1968 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1969 "Intel D945G", STAC_D945GTP3),
1970 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1971 "Intel D945G", STAC_D945GTP3),
1972 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1973 "Intel D945G", STAC_D945GTP3),
1974 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1975 "Intel D945G", STAC_D945GTP3),
1976 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1977 "Intel D945G", STAC_D945GTP3),
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1979 "Intel D945G", STAC_D945GTP3),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1981 "Intel D945G", STAC_D945GTP3),
1982 /* Intel D945G 5-stack systems */
1983 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1984 "Intel D945G", STAC_D945GTP5),
1985 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1986 "Intel D945G", STAC_D945GTP5),
1987 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1988 "Intel D945G", STAC_D945GTP5),
1989 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1990 "Intel D945G", STAC_D945GTP5),
1991 /* Intel 945P based systems */
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1993 "Intel D945P", STAC_D945GTP3),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1995 "Intel D945P", STAC_D945GTP3),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1997 "Intel D945P", STAC_D945GTP3),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1999 "Intel D945P", STAC_D945GTP3),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2001 "Intel D945P", STAC_D945GTP3),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2003 "Intel D945P", STAC_D945GTP5),
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2006 "Intel D945", STAC_D945_REF),
2008 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2009 SND_PCI_QUIRK(0x8384, 0x7680,
2010 "Mac", STAC_INTEL_MAC_AUTO),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2013 "unknown Dell", STAC_922X_DELL_D81),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2015 "unknown Dell", STAC_922X_DELL_D81),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2017 "unknown Dell", STAC_922X_DELL_D81),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2019 "unknown Dell", STAC_922X_DELL_D82),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2021 "unknown Dell", STAC_922X_DELL_M81),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2023 "unknown Dell", STAC_922X_DELL_D82),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2025 "unknown Dell", STAC_922X_DELL_D81),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2027 "unknown Dell", STAC_922X_DELL_D81),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2029 "Dell XPS M1210", STAC_922X_DELL_M82),
2030 /* ECS/PC Chips boards */
2031 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2032 "ECS/PC chips", STAC_ECS_202),
2036 static unsigned int ref927x_pin_configs[14] = {
2037 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2038 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2039 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2040 0x01c42190, 0x40000100,
2043 static unsigned int d965_3st_pin_configs[14] = {
2044 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2045 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2046 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2047 0x40000100, 0x40000100
2050 static unsigned int d965_5st_pin_configs[14] = {
2051 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2052 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2053 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2054 0x40000100, 0x40000100
2057 static unsigned int d965_5st_no_fp_pin_configs[14] = {
2058 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2059 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2060 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2061 0x40000100, 0x40000100
2064 static unsigned int dell_3st_pin_configs[14] = {
2065 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2066 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2067 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2068 0x40c003fc, 0x40000100
2071 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2072 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2073 [STAC_D965_REF] = ref927x_pin_configs,
2074 [STAC_D965_3ST] = d965_3st_pin_configs,
2075 [STAC_D965_5ST] = d965_5st_pin_configs,
2076 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2077 [STAC_DELL_3ST] = dell_3st_pin_configs,
2078 [STAC_DELL_BIOS] = NULL,
2079 [STAC_927X_VOLKNOB] = NULL,
2082 static const char *stac927x_models[STAC_927X_MODELS] = {
2083 [STAC_927X_AUTO] = "auto",
2084 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2085 [STAC_D965_REF] = "ref",
2086 [STAC_D965_3ST] = "3stack",
2087 [STAC_D965_5ST] = "5stack",
2088 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2089 [STAC_DELL_3ST] = "dell-3stack",
2090 [STAC_DELL_BIOS] = "dell-bios",
2091 [STAC_927X_VOLKNOB] = "volknob",
2094 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2095 /* SigmaTel reference board */
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2097 "DFI LanParty", STAC_D965_REF),
2098 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2099 "DFI LanParty", STAC_D965_REF),
2100 /* Intel 946 based systems */
2101 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2103 /* 965 based 3 stack systems */
2104 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2105 "Intel D965", STAC_D965_3ST),
2106 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2107 "Intel D965", STAC_D965_3ST),
2108 /* Dell 3 stack systems */
2109 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2111 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2112 /* Dell 3 stack systems with verb table in BIOS */
2113 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
2115 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2117 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2119 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2120 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2121 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2122 /* 965 based 5 stack systems */
2123 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2124 "Intel D965", STAC_D965_5ST),
2125 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2126 "Intel D965", STAC_D965_5ST),
2127 /* volume-knob fixes */
2128 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
2132 static unsigned int ref9205_pin_configs[12] = {
2133 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2134 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2135 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2139 STAC 9205 pin configs for
2146 10280228 (Dell Vostro 1500)
2147 10280229 (Dell Vostro 1700)
2149 static unsigned int dell_9205_m42_pin_configs[12] = {
2150 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2151 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2152 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2156 STAC 9205 pin configs for
2160 102801FF (Dell Precision M4300)
2165 static unsigned int dell_9205_m43_pin_configs[12] = {
2166 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2167 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2168 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2171 static unsigned int dell_9205_m44_pin_configs[12] = {
2172 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2173 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2174 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2177 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2178 [STAC_9205_REF] = ref9205_pin_configs,
2179 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2180 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2181 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2182 [STAC_9205_EAPD] = NULL,
2185 static const char *stac9205_models[STAC_9205_MODELS] = {
2186 [STAC_9205_AUTO] = "auto",
2187 [STAC_9205_REF] = "ref",
2188 [STAC_9205_DELL_M42] = "dell-m42",
2189 [STAC_9205_DELL_M43] = "dell-m43",
2190 [STAC_9205_DELL_M44] = "dell-m44",
2191 [STAC_9205_EAPD] = "eapd",
2194 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2195 /* SigmaTel reference board */
2196 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2197 "DFI LanParty", STAC_9205_REF),
2198 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2199 "SigmaTel", STAC_9205_REF),
2200 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2201 "DFI LanParty", STAC_9205_REF),
2203 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2204 "unknown Dell", STAC_9205_DELL_M42),
2205 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2206 "unknown Dell", STAC_9205_DELL_M42),
2207 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2208 "Dell Precision", STAC_9205_DELL_M43),
2209 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2210 "Dell Precision", STAC_9205_DELL_M43),
2211 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2212 "Dell Precision", STAC_9205_DELL_M43),
2213 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2214 "unknown Dell", STAC_9205_DELL_M42),
2215 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2216 "unknown Dell", STAC_9205_DELL_M42),
2217 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2218 "Dell Precision", STAC_9205_DELL_M43),
2219 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2220 "Dell Precision M4300", STAC_9205_DELL_M43),
2221 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2222 "unknown Dell", STAC_9205_DELL_M42),
2223 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2224 "Dell Precision", STAC_9205_DELL_M43),
2225 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2226 "Dell Precision", STAC_9205_DELL_M43),
2227 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2228 "Dell Precision", STAC_9205_DELL_M43),
2229 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2230 "Dell Inspiron", STAC_9205_DELL_M44),
2231 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2232 "Dell Vostro 1500", STAC_9205_DELL_M42),
2233 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2234 "Dell Vostro 1700", STAC_9205_DELL_M42),
2236 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2237 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2241 static void stac92xx_set_config_regs(struct hda_codec *codec,
2242 unsigned int *pincfgs)
2245 struct sigmatel_spec *spec = codec->spec;
2250 for (i = 0; i < spec->num_pins; i++)
2251 if (spec->pin_nids[i] && pincfgs[i])
2252 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2257 * Analog playback callbacks
2259 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2260 struct hda_codec *codec,
2261 struct snd_pcm_substream *substream)
2263 struct sigmatel_spec *spec = codec->spec;
2264 if (spec->stream_delay)
2265 msleep(spec->stream_delay);
2266 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2270 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2271 struct hda_codec *codec,
2272 unsigned int stream_tag,
2273 unsigned int format,
2274 struct snd_pcm_substream *substream)
2276 struct sigmatel_spec *spec = codec->spec;
2277 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2280 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2281 struct hda_codec *codec,
2282 struct snd_pcm_substream *substream)
2284 struct sigmatel_spec *spec = codec->spec;
2285 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2289 * Digital playback callbacks
2291 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2292 struct hda_codec *codec,
2293 struct snd_pcm_substream *substream)
2295 struct sigmatel_spec *spec = codec->spec;
2296 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2299 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2300 struct hda_codec *codec,
2301 struct snd_pcm_substream *substream)
2303 struct sigmatel_spec *spec = codec->spec;
2304 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2307 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2308 struct hda_codec *codec,
2309 unsigned int stream_tag,
2310 unsigned int format,
2311 struct snd_pcm_substream *substream)
2313 struct sigmatel_spec *spec = codec->spec;
2314 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2315 stream_tag, format, substream);
2318 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2319 struct hda_codec *codec,
2320 struct snd_pcm_substream *substream)
2322 struct sigmatel_spec *spec = codec->spec;
2323 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2328 * Analog capture callbacks
2330 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2331 struct hda_codec *codec,
2332 unsigned int stream_tag,
2333 unsigned int format,
2334 struct snd_pcm_substream *substream)
2336 struct sigmatel_spec *spec = codec->spec;
2337 hda_nid_t nid = spec->adc_nids[substream->number];
2339 if (spec->powerdown_adcs) {
2341 snd_hda_codec_write(codec, nid, 0,
2342 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2344 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2348 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2349 struct hda_codec *codec,
2350 struct snd_pcm_substream *substream)
2352 struct sigmatel_spec *spec = codec->spec;
2353 hda_nid_t nid = spec->adc_nids[substream->number];
2355 snd_hda_codec_cleanup_stream(codec, nid);
2356 if (spec->powerdown_adcs)
2357 snd_hda_codec_write(codec, nid, 0,
2358 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2362 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2366 /* NID is set in stac92xx_build_pcms */
2368 .open = stac92xx_dig_playback_pcm_open,
2369 .close = stac92xx_dig_playback_pcm_close,
2370 .prepare = stac92xx_dig_playback_pcm_prepare,
2371 .cleanup = stac92xx_dig_playback_pcm_cleanup
2375 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2379 /* NID is set in stac92xx_build_pcms */
2382 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2386 .nid = 0x02, /* NID to query formats and rates */
2388 .open = stac92xx_playback_pcm_open,
2389 .prepare = stac92xx_playback_pcm_prepare,
2390 .cleanup = stac92xx_playback_pcm_cleanup
2394 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2398 .nid = 0x06, /* NID to query formats and rates */
2400 .open = stac92xx_playback_pcm_open,
2401 .prepare = stac92xx_playback_pcm_prepare,
2402 .cleanup = stac92xx_playback_pcm_cleanup
2406 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2409 /* NID + .substreams is set in stac92xx_build_pcms */
2411 .prepare = stac92xx_capture_pcm_prepare,
2412 .cleanup = stac92xx_capture_pcm_cleanup
2416 static int stac92xx_build_pcms(struct hda_codec *codec)
2418 struct sigmatel_spec *spec = codec->spec;
2419 struct hda_pcm *info = spec->pcm_rec;
2421 codec->num_pcms = 1;
2422 codec->pcm_info = info;
2424 info->name = "STAC92xx Analog";
2425 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2426 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2427 spec->multiout.dac_nids[0];
2428 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2429 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2430 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2432 if (spec->alt_switch) {
2435 info->name = "STAC92xx Analog Alt";
2436 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2439 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2442 info->name = "STAC92xx Digital";
2443 info->pcm_type = spec->autocfg.dig_out_type[0];
2444 if (spec->multiout.dig_out_nid) {
2445 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2446 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2448 if (spec->dig_in_nid) {
2449 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2450 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2457 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2460 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2461 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2462 if (pincap & AC_PINCAP_VREF_100)
2463 return AC_PINCTL_VREF_100;
2464 if (pincap & AC_PINCAP_VREF_80)
2465 return AC_PINCTL_VREF_80;
2466 if (pincap & AC_PINCAP_VREF_50)
2467 return AC_PINCTL_VREF_50;
2468 if (pincap & AC_PINCAP_VREF_GRD)
2469 return AC_PINCTL_VREF_GRD;
2473 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2476 snd_hda_codec_write_cache(codec, nid, 0,
2477 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2480 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2482 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2483 struct snd_ctl_elem_value *ucontrol)
2485 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2486 struct sigmatel_spec *spec = codec->spec;
2488 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2492 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2494 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2495 struct snd_ctl_elem_value *ucontrol)
2497 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2498 struct sigmatel_spec *spec = codec->spec;
2499 int nid = kcontrol->private_value;
2501 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2503 /* check to be sure that the ports are upto date with
2506 stac_issue_unsol_event(codec, nid);
2511 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2512 struct snd_ctl_elem_info *uinfo)
2515 static char *texts[] = {
2516 "Mic In", "Line In", "Line Out"
2519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2520 struct sigmatel_spec *spec = codec->spec;
2521 hda_nid_t nid = kcontrol->private_value;
2523 if (nid == spec->mic_switch || nid == spec->line_switch)
2528 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2529 uinfo->value.enumerated.items = i;
2531 if (uinfo->value.enumerated.item >= i)
2532 uinfo->value.enumerated.item = i-1;
2533 strcpy(uinfo->value.enumerated.name,
2534 texts[uinfo->value.enumerated.item]);
2539 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2540 struct snd_ctl_elem_value *ucontrol)
2542 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2543 hda_nid_t nid = kcontrol->private_value;
2544 unsigned int vref = stac92xx_vref_get(codec, nid);
2546 if (vref == stac92xx_get_default_vref(codec, nid))
2547 ucontrol->value.enumerated.item[0] = 0;
2548 else if (vref == AC_PINCTL_VREF_GRD)
2549 ucontrol->value.enumerated.item[0] = 1;
2550 else if (vref == AC_PINCTL_VREF_HIZ)
2551 ucontrol->value.enumerated.item[0] = 2;
2556 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2557 struct snd_ctl_elem_value *ucontrol)
2559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2560 unsigned int new_vref = 0;
2562 hda_nid_t nid = kcontrol->private_value;
2564 if (ucontrol->value.enumerated.item[0] == 0)
2565 new_vref = stac92xx_get_default_vref(codec, nid);
2566 else if (ucontrol->value.enumerated.item[0] == 1)
2567 new_vref = AC_PINCTL_VREF_GRD;
2568 else if (ucontrol->value.enumerated.item[0] == 2)
2569 new_vref = AC_PINCTL_VREF_HIZ;
2573 if (new_vref != stac92xx_vref_get(codec, nid)) {
2574 error = stac92xx_vref_set(codec, nid, new_vref);
2581 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2582 struct snd_ctl_elem_info *uinfo)
2584 static char *texts[2];
2585 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2586 struct sigmatel_spec *spec = codec->spec;
2588 if (kcontrol->private_value == spec->line_switch)
2589 texts[0] = "Line In";
2591 texts[0] = "Mic In";
2592 texts[1] = "Line Out";
2593 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2594 uinfo->value.enumerated.items = 2;
2597 if (uinfo->value.enumerated.item >= 2)
2598 uinfo->value.enumerated.item = 1;
2599 strcpy(uinfo->value.enumerated.name,
2600 texts[uinfo->value.enumerated.item]);
2605 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2607 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2608 struct sigmatel_spec *spec = codec->spec;
2609 hda_nid_t nid = kcontrol->private_value;
2610 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2612 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2616 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2619 struct sigmatel_spec *spec = codec->spec;
2620 hda_nid_t nid = kcontrol->private_value;
2621 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2622 unsigned short val = !!ucontrol->value.enumerated.item[0];
2624 spec->io_switch[io_idx] = val;
2627 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2629 unsigned int pinctl = AC_PINCTL_IN_EN;
2630 if (io_idx) /* set VREF for mic */
2631 pinctl |= stac92xx_get_default_vref(codec, nid);
2632 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2635 /* check the auto-mute again: we need to mute/unmute the speaker
2636 * appropriately according to the pin direction
2638 if (spec->hp_detect)
2639 stac_issue_unsol_event(codec, nid);
2644 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2646 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2647 struct snd_ctl_elem_value *ucontrol)
2649 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2650 struct sigmatel_spec *spec = codec->spec;
2652 ucontrol->value.integer.value[0] = spec->clfe_swap;
2656 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2657 struct snd_ctl_elem_value *ucontrol)
2659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2660 struct sigmatel_spec *spec = codec->spec;
2661 hda_nid_t nid = kcontrol->private_value & 0xff;
2662 unsigned int val = !!ucontrol->value.integer.value[0];
2664 if (spec->clfe_swap == val)
2667 spec->clfe_swap = val;
2669 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2670 spec->clfe_swap ? 0x4 : 0x0);
2675 #define STAC_CODEC_HP_SWITCH(xname) \
2676 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2679 .info = stac92xx_hp_switch_info, \
2680 .get = stac92xx_hp_switch_get, \
2681 .put = stac92xx_hp_switch_put, \
2684 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2685 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2688 .info = stac92xx_io_switch_info, \
2689 .get = stac92xx_io_switch_get, \
2690 .put = stac92xx_io_switch_put, \
2691 .private_value = xpval, \
2694 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2695 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2698 .info = stac92xx_clfe_switch_info, \
2699 .get = stac92xx_clfe_switch_get, \
2700 .put = stac92xx_clfe_switch_put, \
2701 .private_value = xpval, \
2705 STAC_CTL_WIDGET_VOL,
2706 STAC_CTL_WIDGET_MUTE,
2707 STAC_CTL_WIDGET_MUTE_BEEP,
2708 STAC_CTL_WIDGET_MONO_MUX,
2709 STAC_CTL_WIDGET_HP_SWITCH,
2710 STAC_CTL_WIDGET_IO_SWITCH,
2711 STAC_CTL_WIDGET_CLFE_SWITCH,
2712 STAC_CTL_WIDGET_DC_BIAS
2715 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2716 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2717 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2718 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
2720 STAC_CODEC_HP_SWITCH(NULL),
2721 STAC_CODEC_IO_SWITCH(NULL, 0),
2722 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2723 DC_BIAS(NULL, 0, 0),
2726 /* add dynamic controls */
2727 static struct snd_kcontrol_new *
2728 stac_control_new(struct sigmatel_spec *spec,
2729 struct snd_kcontrol_new *ktemp,
2731 unsigned int subdev)
2733 struct snd_kcontrol_new *knew;
2735 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2736 knew = snd_array_new(&spec->kctls);
2740 knew->name = kstrdup(name, GFP_KERNEL);
2743 memset(knew, 0, sizeof(*knew));
2744 spec->kctls.alloced--;
2747 knew->subdevice = subdev;
2751 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2752 struct snd_kcontrol_new *ktemp,
2753 int idx, const char *name,
2756 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
2757 HDA_SUBDEV_AMP_FLAG);
2761 knew->private_value = val;
2765 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2766 int type, int idx, const char *name,
2769 return stac92xx_add_control_temp(spec,
2770 &stac92xx_control_templates[type],
2775 /* add dynamic controls */
2776 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2777 const char *name, unsigned long val)
2779 return stac92xx_add_control_idx(spec, type, 0, name, val);
2782 static struct snd_kcontrol_new stac_input_src_temp = {
2783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2784 .name = "Input Source",
2785 .info = stac92xx_mux_enum_info,
2786 .get = stac92xx_mux_enum_get,
2787 .put = stac92xx_mux_enum_put,
2790 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2791 hda_nid_t nid, int idx)
2793 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2795 struct sigmatel_spec *spec = codec->spec;
2798 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2799 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2800 && nid == spec->line_switch)
2801 control = STAC_CTL_WIDGET_IO_SWITCH;
2802 else if (snd_hda_query_pin_caps(codec, nid)
2803 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2804 control = STAC_CTL_WIDGET_DC_BIAS;
2805 else if (nid == spec->mic_switch)
2806 control = STAC_CTL_WIDGET_IO_SWITCH;
2810 strcpy(name, auto_pin_cfg_labels[idx]);
2811 return stac92xx_add_control(codec->spec, control,
2812 strcat(name, " Jack Mode"), nid);
2818 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2820 struct snd_kcontrol_new *knew;
2821 struct hda_input_mux *imux = &spec->private_imux;
2824 return 0; /* no need for input source */
2825 if (!spec->num_adcs || imux->num_items <= 1)
2826 return 0; /* no need for input source control */
2827 knew = stac_control_new(spec, &stac_input_src_temp,
2828 stac_input_src_temp.name, 0);
2831 knew->count = spec->num_adcs;
2835 /* check whether the line-input can be used as line-out */
2836 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2838 struct sigmatel_spec *spec = codec->spec;
2839 struct auto_pin_cfg *cfg = &spec->autocfg;
2841 unsigned int pincap;
2843 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2845 nid = cfg->input_pins[AUTO_PIN_LINE];
2846 pincap = snd_hda_query_pin_caps(codec, nid);
2847 if (pincap & AC_PINCAP_OUT)
2852 /* check whether the mic-input can be used as line-out */
2853 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2855 struct sigmatel_spec *spec = codec->spec;
2856 struct auto_pin_cfg *cfg = &spec->autocfg;
2857 unsigned int def_conf, pincap;
2858 unsigned int mic_pin;
2860 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2862 mic_pin = AUTO_PIN_MIC;
2864 hda_nid_t nid = cfg->input_pins[mic_pin];
2865 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2866 /* some laptops have an internal analog microphone
2867 * which can't be used as a output */
2868 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2869 pincap = snd_hda_query_pin_caps(codec, nid);
2870 if (pincap & AC_PINCAP_OUT)
2873 if (mic_pin == AUTO_PIN_MIC)
2874 mic_pin = AUTO_PIN_FRONT_MIC;
2881 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2885 for (i = 0; i < spec->multiout.num_dacs; i++) {
2886 if (spec->multiout.dac_nids[i] == nid)
2893 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2896 if (is_in_dac_nids(spec, nid))
2898 for (i = 0; i < spec->autocfg.hp_outs; i++)
2899 if (spec->hp_dacs[i] == nid)
2901 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2902 if (spec->speaker_dacs[i] == nid)
2907 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2909 struct sigmatel_spec *spec = codec->spec;
2911 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2912 unsigned int wcaps, wtype;
2914 conn_len = snd_hda_get_connections(codec, nid, conn,
2915 HDA_MAX_CONNECTIONS);
2916 /* 92HD88: trace back up the link of nids to find the DAC */
2917 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2918 != AC_WID_AUD_OUT)) {
2920 conn_len = snd_hda_get_connections(codec, nid, conn,
2921 HDA_MAX_CONNECTIONS);
2923 for (j = 0; j < conn_len; j++) {
2924 wcaps = get_wcaps(codec, conn[j]);
2925 wtype = get_wcaps_type(wcaps);
2926 /* we check only analog outputs */
2927 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2929 /* if this route has a free DAC, assign it */
2930 if (!check_all_dac_nids(spec, conn[j])) {
2932 /* select this DAC in the pin's input mux */
2933 snd_hda_codec_write_cache(codec, nid, 0,
2934 AC_VERB_SET_CONNECT_SEL, j);
2939 /* if all DACs are already assigned, connect to the primary DAC */
2941 for (j = 0; j < conn_len; j++) {
2942 if (conn[j] == spec->multiout.dac_nids[0]) {
2943 snd_hda_codec_write_cache(codec, nid, 0,
2944 AC_VERB_SET_CONNECT_SEL, j);
2952 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2953 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2956 * Fill in the dac_nids table from the parsed pin configuration
2957 * This function only works when every pin in line_out_pins[]
2958 * contains atleast one DAC in its connection list. Some 92xx
2959 * codecs are not connected directly to a DAC, such as the 9200
2960 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2962 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2964 struct sigmatel_spec *spec = codec->spec;
2965 struct auto_pin_cfg *cfg = &spec->autocfg;
2969 for (i = 0; i < cfg->line_outs; i++) {
2970 nid = cfg->line_out_pins[i];
2971 dac = get_unassigned_dac(codec, nid);
2973 if (spec->multiout.num_dacs > 0) {
2974 /* we have already working output pins,
2975 * so let's drop the broken ones again
2977 cfg->line_outs = spec->multiout.num_dacs;
2980 /* error out, no available DAC found */
2982 "%s: No available DAC for pin 0x%x\n",
2986 add_spec_dacs(spec, dac);
2989 for (i = 0; i < cfg->hp_outs; i++) {
2990 nid = cfg->hp_pins[i];
2991 dac = get_unassigned_dac(codec, nid);
2993 if (!spec->multiout.hp_nid)
2994 spec->multiout.hp_nid = dac;
2996 add_spec_extra_dacs(spec, dac);
2998 spec->hp_dacs[i] = dac;
3001 for (i = 0; i < cfg->speaker_outs; i++) {
3002 nid = cfg->speaker_pins[i];
3003 dac = get_unassigned_dac(codec, nid);
3005 add_spec_extra_dacs(spec, dac);
3006 spec->speaker_dacs[i] = dac;
3009 /* add line-in as output */
3010 nid = check_line_out_switch(codec);
3012 dac = get_unassigned_dac(codec, nid);
3014 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3015 nid, cfg->line_outs);
3016 cfg->line_out_pins[cfg->line_outs] = nid;
3018 spec->line_switch = nid;
3019 add_spec_dacs(spec, dac);
3022 /* add mic as output */
3023 nid = check_mic_out_switch(codec);
3025 dac = get_unassigned_dac(codec, nid);
3027 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3028 nid, cfg->line_outs);
3029 cfg->line_out_pins[cfg->line_outs] = nid;
3031 spec->mic_switch = nid;
3032 add_spec_dacs(spec, dac);
3036 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3037 spec->multiout.num_dacs,
3038 spec->multiout.dac_nids[0],
3039 spec->multiout.dac_nids[1],
3040 spec->multiout.dac_nids[2],
3041 spec->multiout.dac_nids[3],
3042 spec->multiout.dac_nids[4]);
3047 /* create volume control/switch for the given prefx type */
3048 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3049 int idx, hda_nid_t nid, int chs)
3051 struct sigmatel_spec *spec = codec->spec;
3055 if (!spec->check_volume_offset) {
3056 unsigned int caps, step, nums, db_scale;
3057 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3058 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3059 AC_AMPCAP_STEP_SIZE_SHIFT;
3060 step = (step + 1) * 25; /* in .01dB unit */
3061 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3062 AC_AMPCAP_NUM_STEPS_SHIFT;
3063 db_scale = nums * step;
3064 /* if dB scale is over -64dB, and finer enough,
3065 * let's reduce it to half
3067 if (db_scale > 6400 && nums >= 0x1f)
3068 spec->volume_offset = nums / 2;
3069 spec->check_volume_offset = 1;
3072 sprintf(name, "%s Playback Volume", pfx);
3073 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
3074 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3075 spec->volume_offset));
3078 sprintf(name, "%s Playback Switch", pfx);
3079 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
3080 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3086 #define create_controls(codec, pfx, nid, chs) \
3087 create_controls_idx(codec, pfx, 0, nid, chs)
3089 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3091 if (spec->multiout.num_dacs > 4) {
3092 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3095 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3096 spec->multiout.num_dacs++;
3101 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3104 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3105 if (!spec->multiout.extra_out_nid[i]) {
3106 spec->multiout.extra_out_nid[i] = nid;
3110 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3114 /* Create output controls
3115 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3117 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3118 const hda_nid_t *pins,
3119 const hda_nid_t *dac_nids,
3122 struct sigmatel_spec *spec = codec->spec;
3123 static const char *chname[4] = {
3124 "Front", "Surround", NULL /*CLFE*/, "Side"
3128 unsigned int wid_caps;
3130 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3131 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3132 wid_caps = get_wcaps(codec, pins[i]);
3133 if (wid_caps & AC_WCAP_UNSOL_CAP)
3134 spec->hp_detect = 1;
3139 if (type != AUTO_PIN_HP_OUT && i == 2) {
3141 err = create_controls(codec, "Center", nid, 1);
3144 err = create_controls(codec, "LFE", nid, 2);
3148 wid_caps = get_wcaps(codec, nid);
3150 if (wid_caps & AC_WCAP_LR_SWAP) {
3151 err = stac92xx_add_control(spec,
3152 STAC_CTL_WIDGET_CLFE_SWITCH,
3153 "Swap Center/LFE Playback Switch", nid);
3163 case AUTO_PIN_HP_OUT:
3167 case AUTO_PIN_SPEAKER_OUT:
3176 err = create_controls_idx(codec, name, idx, nid, 3);
3184 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3185 unsigned long sw, int idx)
3188 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3189 "Capture Volume", vol);
3192 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3193 "Capture Switch", sw);
3199 /* add playback controls from the parsed DAC table */
3200 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3201 const struct auto_pin_cfg *cfg)
3203 struct sigmatel_spec *spec = codec->spec;
3208 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3209 spec->multiout.dac_nids,
3210 cfg->line_out_type);
3214 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3215 err = stac92xx_add_control(spec,
3216 STAC_CTL_WIDGET_HP_SWITCH,
3217 "Headphone as Line Out Switch",
3218 cfg->hp_pins[cfg->hp_outs - 1]);
3223 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3224 nid = cfg->input_pins[idx];
3226 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3235 /* add playback controls for Speaker and HP outputs */
3236 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3237 struct auto_pin_cfg *cfg)
3239 struct sigmatel_spec *spec = codec->spec;
3242 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3243 spec->hp_dacs, AUTO_PIN_HP_OUT);
3247 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3248 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3255 /* labels for mono mux outputs */
3256 static const char *stac92xx_mono_labels[4] = {
3257 "DAC0", "DAC1", "Mixer", "DAC2"
3260 /* create mono mux for mono out on capable codecs */
3261 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3263 struct sigmatel_spec *spec = codec->spec;
3264 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3266 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3268 num_cons = snd_hda_get_connections(codec,
3271 HDA_MAX_NUM_INPUTS);
3272 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3275 for (i = 0; i < num_cons; i++) {
3276 mono_mux->items[mono_mux->num_items].label =
3277 stac92xx_mono_labels[i];
3278 mono_mux->items[mono_mux->num_items].index = i;
3279 mono_mux->num_items++;
3282 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3283 "Mono Mux", spec->mono_nid);
3286 /* create PC beep volume controls */
3287 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3290 struct sigmatel_spec *spec = codec->spec;
3291 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3292 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3294 if (spec->anabeep_nid == nid)
3295 type = STAC_CTL_WIDGET_MUTE;
3297 /* check for mute support for the the amp */
3298 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3299 err = stac92xx_add_control(spec, type,
3300 "Beep Playback Switch",
3301 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3306 /* check to see if there is volume support for the amp */
3307 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3308 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3309 "Beep Playback Volume",
3310 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3317 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3318 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3320 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3321 struct snd_ctl_elem_value *ucontrol)
3323 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3324 ucontrol->value.integer.value[0] = codec->beep->enabled;
3328 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3329 struct snd_ctl_elem_value *ucontrol)
3331 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3332 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
3335 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3336 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3337 .info = stac92xx_dig_beep_switch_info,
3338 .get = stac92xx_dig_beep_switch_get,
3339 .put = stac92xx_dig_beep_switch_put,
3342 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3344 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3345 0, "Beep Playback Switch", 0);
3349 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3351 struct sigmatel_spec *spec = codec->spec;
3354 for (i = 0; i < spec->num_muxes; i++) {
3359 nid = spec->mux_nids[i];
3360 wcaps = get_wcaps(codec, nid);
3361 if (!(wcaps & AC_WCAP_OUT_AMP))
3364 /* check whether already the same control was created as
3365 * normal Capture Volume.
3367 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3368 for (j = 0; j < spec->num_caps; j++) {
3369 if (spec->capvols[j] == val)
3372 if (j < spec->num_caps)
3375 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3376 "Mux Capture Volume", val);
3383 static const char *stac92xx_spdif_labels[3] = {
3384 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3387 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3389 struct sigmatel_spec *spec = codec->spec;
3390 struct hda_input_mux *spdif_mux = &spec->private_smux;
3391 const char **labels = spec->spdif_labels;
3393 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3395 num_cons = snd_hda_get_connections(codec,
3398 HDA_MAX_NUM_INPUTS);
3403 labels = stac92xx_spdif_labels;
3405 for (i = 0; i < num_cons; i++) {
3406 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3407 spdif_mux->items[spdif_mux->num_items].index = i;
3408 spdif_mux->num_items++;
3414 /* labels for dmic mux inputs */
3415 static const char *stac92xx_dmic_labels[5] = {
3416 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3417 "Digital Mic 3", "Digital Mic 4"
3420 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
3423 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3426 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3427 for (i = 0; i < nums; i++)
3433 /* create a volume assigned to the given pin (only if supported) */
3434 /* return 1 if the volume control is created */
3435 static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
3436 const char *label, int direction)
3438 unsigned int caps, nums;
3442 if (direction == HDA_OUTPUT)
3443 caps = AC_WCAP_OUT_AMP;
3445 caps = AC_WCAP_IN_AMP;
3446 if (!(get_wcaps(codec, nid) & caps))
3448 caps = query_amp_caps(codec, nid, direction);
3449 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3452 snprintf(name, sizeof(name), "%s Capture Volume", label);
3453 err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name,
3454 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3460 /* create playback/capture controls for input pins on dmic capable codecs */
3461 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3462 const struct auto_pin_cfg *cfg)
3464 struct sigmatel_spec *spec = codec->spec;
3465 struct hda_input_mux *imux = &spec->private_imux;
3466 struct hda_input_mux *dimux = &spec->private_dimux;
3467 int err, i, active_mics;
3468 unsigned int def_conf;
3470 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3471 dimux->items[dimux->num_items].index = 0;
3475 for (i = 0; i < spec->num_dmics; i++) {
3476 /* check the validity: sometimes it's a dead vendor-spec node */
3477 if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i]))
3480 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3481 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
3485 for (i = 0; i < spec->num_dmics; i++) {
3490 nid = spec->dmic_nids[i];
3491 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3493 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3494 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3497 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3501 if (active_mics == 1)
3502 label = "Digital Mic";
3504 label = stac92xx_dmic_labels[dimux->num_items];
3506 err = create_elem_capture_vol(codec, nid, label, HDA_INPUT);
3510 err = create_elem_capture_vol(codec, nid, label,
3516 dimux->items[dimux->num_items].label = label;
3517 dimux->items[dimux->num_items].index = index;
3519 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) {
3520 imux->items[imux->num_items].label = label;
3521 imux->items[imux->num_items].index = index;
3529 static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3530 hda_nid_t *fixed, hda_nid_t *ext)
3536 cfg = snd_hda_codec_get_pincfg(codec, nid);
3537 switch (get_defcfg_connect(cfg)) {
3538 case AC_JACK_PORT_FIXED:
3540 return 1; /* already occupied */
3543 case AC_JACK_PORT_COMPLEX:
3545 return 1; /* already occupied */
3552 static int set_mic_route(struct hda_codec *codec,
3553 struct sigmatel_mic_route *mic,
3556 struct sigmatel_spec *spec = codec->spec;
3557 struct auto_pin_cfg *cfg = &spec->autocfg;
3561 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3562 if (pin == cfg->input_pins[i])
3564 if (i <= AUTO_PIN_FRONT_MIC) {
3566 i = get_connection_index(codec, spec->mux_nids[0], pin);
3571 if (spec->dmux_nids)
3572 mic->dmux_idx = get_connection_index(codec,
3575 } else if (spec->dmux_nids) {
3577 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3583 mic->mux_idx = get_connection_index(codec,
3585 spec->dmux_nids[0]);
3590 /* return non-zero if the device is for automatic mic switch */
3591 static int stac_check_auto_mic(struct hda_codec *codec)
3593 struct sigmatel_spec *spec = codec->spec;
3594 struct auto_pin_cfg *cfg = &spec->autocfg;
3595 hda_nid_t fixed, ext;
3598 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
3599 if (cfg->input_pins[i])
3600 return 0; /* must be exclusively mics */
3603 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3604 if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
3606 for (i = 0; i < spec->num_dmics; i++)
3607 if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
3611 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
3612 return 0; /* no unsol support */
3613 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3614 set_mic_route(codec, &spec->int_mic, fixed))
3615 return 0; /* something is wrong */
3619 /* create playback/capture controls for input pins */
3620 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3622 struct sigmatel_spec *spec = codec->spec;
3623 struct hda_input_mux *imux = &spec->private_imux;
3626 for (i = 0; i < AUTO_PIN_LAST; i++) {
3627 hda_nid_t nid = cfg->input_pins[i];
3633 for (j = 0; j < spec->num_muxes; j++) {
3634 index = get_connection_index(codec, spec->mux_nids[j],
3642 err = create_elem_capture_vol(codec, nid,
3643 auto_pin_cfg_labels[i],
3648 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3649 imux->items[imux->num_items].index = index;
3652 spec->num_analog_muxes = imux->num_items;
3654 if (imux->num_items) {
3656 * Set the current input for the muxes.
3657 * The STAC9221 has two input muxes with identical source
3658 * NID lists. Hopefully this won't get confused.
3660 for (i = 0; i < spec->num_muxes; i++) {
3661 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3662 AC_VERB_SET_CONNECT_SEL,
3663 imux->items[0].index);
3670 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3672 struct sigmatel_spec *spec = codec->spec;
3675 for (i = 0; i < spec->autocfg.line_outs; i++) {
3676 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3677 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3681 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3683 struct sigmatel_spec *spec = codec->spec;
3686 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3688 pin = spec->autocfg.hp_pins[i];
3689 if (pin) /* connect to front */
3690 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3692 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3694 pin = spec->autocfg.speaker_pins[i];
3695 if (pin) /* connect to front */
3696 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3700 static int is_dual_headphones(struct hda_codec *codec)
3702 struct sigmatel_spec *spec = codec->spec;
3705 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3706 spec->autocfg.hp_outs <= 1)
3709 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3710 hda_nid_t nid = spec->autocfg.hp_pins[i];
3711 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3712 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3716 return (valid_hps > 1);
3720 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3722 struct sigmatel_spec *spec = codec->spec;
3726 if ((err = snd_hda_parse_pin_def_config(codec,
3728 spec->dmic_nids)) < 0)
3730 if (! spec->autocfg.line_outs)
3731 return 0; /* can't find valid pin config */
3733 /* If we have no real line-out pin and multiple hp-outs, HPs should
3734 * be set up as multi-channel outputs.
3736 if (is_dual_headphones(codec)) {
3737 /* Copy hp_outs to line_outs, backup line_outs in
3738 * speaker_outs so that the following routines can handle
3739 * HP pins as primary outputs.
3741 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3742 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3743 sizeof(spec->autocfg.line_out_pins));
3744 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3745 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3746 sizeof(spec->autocfg.hp_pins));
3747 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3748 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3749 spec->autocfg.hp_outs = 0;
3752 if (spec->autocfg.mono_out_pin) {
3753 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3754 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3755 u32 caps = query_amp_caps(codec,
3756 spec->autocfg.mono_out_pin, dir);
3757 hda_nid_t conn_list[1];
3759 /* get the mixer node and then the mono mux if it exists */
3760 if (snd_hda_get_connections(codec,
3761 spec->autocfg.mono_out_pin, conn_list, 1) &&
3762 snd_hda_get_connections(codec, conn_list[0],
3763 conn_list, 1) > 0) {
3765 int wcaps = get_wcaps(codec, conn_list[0]);
3766 int wid_type = get_wcaps_type(wcaps);
3767 /* LR swap check, some stac925x have a mux that
3768 * changes the DACs output path instead of the
3771 if (wid_type == AC_WID_AUD_SEL &&
3772 !(wcaps & AC_WCAP_LR_SWAP))
3773 spec->mono_nid = conn_list[0];
3776 hda_nid_t nid = spec->autocfg.mono_out_pin;
3778 /* most mono outs have a least a mute/unmute switch */
3779 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3780 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3781 "Mono Playback Switch",
3782 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3785 /* check for volume support for the amp */
3786 if ((caps & AC_AMPCAP_NUM_STEPS)
3787 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3788 err = stac92xx_add_control(spec,
3789 STAC_CTL_WIDGET_VOL,
3790 "Mono Playback Volume",
3791 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3797 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3801 if (!spec->multiout.num_dacs) {
3802 err = stac92xx_auto_fill_dac_nids(codec);
3805 err = stac92xx_auto_create_multi_out_ctls(codec,
3811 /* setup analog beep controls */
3812 if (spec->anabeep_nid > 0) {
3813 err = stac92xx_auto_create_beep_ctls(codec,
3819 /* setup digital beep controls and input device */
3820 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3821 if (spec->digbeep_nid > 0) {
3822 hda_nid_t nid = spec->digbeep_nid;
3825 err = stac92xx_auto_create_beep_ctls(codec, nid);
3828 err = snd_hda_attach_beep_device(codec, nid);
3832 /* IDT/STAC codecs have linear beep tone parameter */
3833 codec->beep->linear_tone = spec->linear_tone_beep;
3834 /* if no beep switch is available, make its own one */
3835 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3836 if (!(caps & AC_AMPCAP_MUTE)) {
3837 err = stac92xx_beep_switch_ctl(codec);
3845 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3849 /* All output parsing done, now restore the swapped hp pins */
3851 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3852 sizeof(spec->autocfg.hp_pins));
3853 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3854 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3855 spec->autocfg.line_outs = 0;
3858 if (stac_check_auto_mic(codec)) {
3860 /* only one capture for auto-mic */
3863 spec->num_muxes = 1;
3866 for (i = 0; i < spec->num_caps; i++) {
3867 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3868 spec->capsws[i], i);
3873 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3877 if (spec->mono_nid > 0) {
3878 err = stac92xx_auto_create_mono_output_ctls(codec);
3882 if (spec->num_dmics > 0 && !spec->dinput_mux)
3883 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3884 &spec->autocfg)) < 0)
3886 if (spec->num_muxes > 0) {
3887 err = stac92xx_auto_create_mux_input_ctls(codec);
3891 if (spec->num_smuxes > 0) {
3892 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3897 err = stac92xx_add_input_source(spec);
3901 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3902 if (spec->multiout.max_channels > 2)
3903 spec->surr_switch = 1;
3905 if (spec->autocfg.dig_outs)
3906 spec->multiout.dig_out_nid = dig_out;
3907 if (dig_in && spec->autocfg.dig_in_pin)
3908 spec->dig_in_nid = dig_in;
3910 if (spec->kctls.list)
3911 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3913 spec->input_mux = &spec->private_imux;
3914 if (!spec->dinput_mux)
3915 spec->dinput_mux = &spec->private_dimux;
3916 spec->sinput_mux = &spec->private_smux;
3917 spec->mono_mux = &spec->private_mono_mux;
3921 /* add playback controls for HP output */
3922 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3923 struct auto_pin_cfg *cfg)
3925 struct sigmatel_spec *spec = codec->spec;
3926 hda_nid_t pin = cfg->hp_pins[0];
3927 unsigned int wid_caps;
3932 wid_caps = get_wcaps(codec, pin);
3933 if (wid_caps & AC_WCAP_UNSOL_CAP)
3934 spec->hp_detect = 1;
3939 /* add playback controls for LFE output */
3940 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3941 struct auto_pin_cfg *cfg)
3943 struct sigmatel_spec *spec = codec->spec;
3945 hda_nid_t lfe_pin = 0x0;
3949 * search speaker outs and line outs for a mono speaker pin
3950 * with an amp. If one is found, add LFE controls
3953 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3954 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3955 unsigned int wcaps = get_wcaps(codec, pin);
3956 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3957 if (wcaps == AC_WCAP_OUT_AMP)
3958 /* found a mono speaker with an amp, must be lfe */
3962 /* if speaker_outs is 0, then speakers may be in line_outs */
3963 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3964 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3965 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3966 unsigned int defcfg;
3967 defcfg = snd_hda_codec_get_pincfg(codec, pin);
3968 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3969 unsigned int wcaps = get_wcaps(codec, pin);
3970 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3971 if (wcaps == AC_WCAP_OUT_AMP)
3972 /* found a mono speaker with an amp,
3980 err = create_controls(codec, "LFE", lfe_pin, 1);
3988 static int stac9200_parse_auto_config(struct hda_codec *codec)
3990 struct sigmatel_spec *spec = codec->spec;
3993 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3996 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3999 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4002 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4005 if (spec->num_muxes > 0) {
4006 err = stac92xx_auto_create_mux_input_ctls(codec);
4011 err = stac92xx_add_input_source(spec);
4015 if (spec->autocfg.dig_outs)
4016 spec->multiout.dig_out_nid = 0x05;
4017 if (spec->autocfg.dig_in_pin)
4018 spec->dig_in_nid = 0x04;
4020 if (spec->kctls.list)
4021 spec->mixers[spec->num_mixers++] = spec->kctls.list;
4023 spec->input_mux = &spec->private_imux;
4024 spec->dinput_mux = &spec->private_dimux;
4030 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4031 * funky external mute control using GPIO pins.
4034 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4035 unsigned int dir_mask, unsigned int data)
4037 unsigned int gpiostate, gpiomask, gpiodir;
4039 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4040 AC_VERB_GET_GPIO_DATA, 0);
4041 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
4043 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4044 AC_VERB_GET_GPIO_MASK, 0);
4047 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4048 AC_VERB_GET_GPIO_DIRECTION, 0);
4049 gpiodir |= dir_mask;
4051 /* Configure GPIOx as CMOS */
4052 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4054 snd_hda_codec_write(codec, codec->afg, 0,
4055 AC_VERB_SET_GPIO_MASK, gpiomask);
4056 snd_hda_codec_read(codec, codec->afg, 0,
4057 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
4061 snd_hda_codec_read(codec, codec->afg, 0,
4062 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
4065 #ifdef CONFIG_SND_HDA_INPUT_JACK
4066 static void stac92xx_free_jack_priv(struct snd_jack *jack)
4068 struct sigmatel_jack *jacks = jack->private_data;
4074 static int stac92xx_add_jack(struct hda_codec *codec,
4075 hda_nid_t nid, int type)
4077 #ifdef CONFIG_SND_HDA_INPUT_JACK
4078 struct sigmatel_spec *spec = codec->spec;
4079 struct sigmatel_jack *jack;
4080 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4081 int connectivity = get_defcfg_connect(def_conf);
4085 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4088 snd_array_init(&spec->jacks, sizeof(*jack), 32);
4089 jack = snd_array_new(&spec->jacks);
4095 snprintf(name, sizeof(name), "%s at %s %s Jack",
4096 snd_hda_get_jack_type(def_conf),
4097 snd_hda_get_jack_connectivity(def_conf),
4098 snd_hda_get_jack_location(def_conf));
4100 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4105 jack->jack->private_data = jack;
4106 jack->jack->private_free = stac92xx_free_jack_priv;
4111 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4112 unsigned char type, int data)
4114 struct sigmatel_event *event;
4116 snd_array_init(&spec->events, sizeof(*event), 32);
4117 event = snd_array_new(&spec->events);
4122 event->tag = spec->events.used;
4128 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4131 struct sigmatel_spec *spec = codec->spec;
4132 struct sigmatel_event *event = spec->events.list;
4135 for (i = 0; i < spec->events.used; i++, event++) {
4136 if (event->nid == nid)
4142 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4145 struct sigmatel_spec *spec = codec->spec;
4146 struct sigmatel_event *event = spec->events.list;
4149 for (i = 0; i < spec->events.used; i++, event++) {
4150 if (event->tag == tag)
4156 /* check if given nid is a valid pin and no other events are assigned
4157 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4158 * Otherwise, returns zero.
4160 static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4163 struct sigmatel_event *event;
4166 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4168 event = stac_get_event(codec, nid);
4170 if (event->type != type)
4174 tag = stac_add_event(codec->spec, nid, type, 0);
4178 snd_hda_codec_write_cache(codec, nid, 0,
4179 AC_VERB_SET_UNSOLICITED_ENABLE,
4184 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4187 for (i = 0; i < cfg->hp_outs; i++)
4188 if (cfg->hp_pins[i] == nid)
4189 return 1; /* nid is a HP-Out */
4191 return 0; /* nid is not a HP-Out */
4194 static void stac92xx_power_down(struct hda_codec *codec)
4196 struct sigmatel_spec *spec = codec->spec;
4198 /* power down inactive DACs */
4200 for (dac = spec->dac_list; *dac; dac++)
4201 if (!check_all_dac_nids(spec, *dac))
4202 snd_hda_codec_write(codec, *dac, 0,
4203 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4206 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4209 static inline int get_int_hint(struct hda_codec *codec, const char *key,
4213 p = snd_hda_get_hint(codec, key);
4216 if (!strict_strtoul(p, 0, &val)) {
4224 /* override some hints from the hwdep entry */
4225 static void stac_store_hints(struct hda_codec *codec)
4227 struct sigmatel_spec *spec = codec->spec;
4230 val = snd_hda_get_bool_hint(codec, "hp_detect");
4232 spec->hp_detect = val;
4233 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
4234 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4237 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4238 spec->gpio_mask &= spec->gpio_mask;
4239 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4240 spec->gpio_dir &= spec->gpio_mask;
4241 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4242 spec->eapd_mask &= spec->gpio_mask;
4243 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4244 spec->gpio_mute &= spec->gpio_mask;
4245 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4247 spec->eapd_switch = val;
4248 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4249 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
4250 spec->gpio_mask |= spec->gpio_led;
4251 spec->gpio_dir |= spec->gpio_led;
4252 if (spec->gpio_led_polarity)
4253 spec->gpio_data |= spec->gpio_led;
4257 static int stac92xx_init(struct hda_codec *codec)
4259 struct sigmatel_spec *spec = codec->spec;
4260 struct auto_pin_cfg *cfg = &spec->autocfg;
4264 snd_hda_sequence_write(codec, spec->init);
4266 /* power down adcs initially */
4267 if (spec->powerdown_adcs)
4268 for (i = 0; i < spec->num_adcs; i++)
4269 snd_hda_codec_write(codec,
4270 spec->adc_nids[i], 0,
4271 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4273 /* override some hints */
4274 stac_store_hints(codec);
4277 gpio = spec->gpio_data;
4278 /* turn on EAPD statically when spec->eapd_switch isn't set.
4279 * otherwise, unsol event will turn it on/off dynamically
4281 if (!spec->eapd_switch)
4282 gpio |= spec->eapd_mask;
4283 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4286 if (spec->hp_detect) {
4287 /* Enable unsolicited responses on the HP widget */
4288 for (i = 0; i < cfg->hp_outs; i++) {
4289 hda_nid_t nid = cfg->hp_pins[i];
4290 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4292 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4293 cfg->speaker_outs > 0) {
4294 /* enable pin-detect for line-outs as well */
4295 for (i = 0; i < cfg->line_outs; i++) {
4296 hda_nid_t nid = cfg->line_out_pins[i];
4297 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4301 /* force to enable the first line-out; the others are set up
4304 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4306 /* fake event to set up pins */
4307 if (cfg->hp_pins[0])
4308 stac_issue_unsol_event(codec, cfg->hp_pins[0]);
4309 else if (cfg->line_out_pins[0])
4310 stac_issue_unsol_event(codec, cfg->line_out_pins[0]);
4312 stac92xx_auto_init_multi_out(codec);
4313 stac92xx_auto_init_hp_out(codec);
4314 for (i = 0; i < cfg->hp_outs; i++)
4315 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4317 if (spec->auto_mic) {
4318 /* initialize connection to analog input */
4319 if (spec->dmux_nids)
4320 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4321 AC_VERB_SET_CONNECT_SEL, 0);
4322 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4323 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4325 for (i = 0; i < AUTO_PIN_LAST; i++) {
4326 hda_nid_t nid = cfg->input_pins[i];
4328 unsigned int pinctl, conf;
4329 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4330 /* for mic pins, force to initialize */
4331 pinctl = stac92xx_get_default_vref(codec, nid);
4332 pinctl |= AC_PINCTL_IN_EN;
4333 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4335 pinctl = snd_hda_codec_read(codec, nid, 0,
4336 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4337 /* if PINCTL already set then skip */
4338 /* Also, if both INPUT and OUTPUT are set,
4339 * it must be a BIOS bug; need to override, too
4341 if (!(pinctl & AC_PINCTL_IN_EN) ||
4342 (pinctl & AC_PINCTL_OUT_EN)) {
4343 pinctl &= ~AC_PINCTL_OUT_EN;
4344 pinctl |= AC_PINCTL_IN_EN;
4345 stac92xx_auto_set_pinctl(codec, nid,
4349 conf = snd_hda_codec_get_pincfg(codec, nid);
4350 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4351 if (enable_pin_detect(codec, nid,
4353 stac_issue_unsol_event(codec, nid);
4357 for (i = 0; i < spec->num_dmics; i++)
4358 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4360 if (cfg->dig_out_pins[0])
4361 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4363 if (cfg->dig_in_pin)
4364 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4366 for (i = 0; i < spec->num_pwrs; i++) {
4367 hda_nid_t nid = spec->pwr_nids[i];
4368 int pinctl, def_conf;
4370 /* power on when no jack detection is available */
4371 if (!spec->hp_detect) {
4372 stac_toggle_power_map(codec, nid, 1);
4376 if (is_nid_hp_pin(cfg, nid))
4377 continue; /* already has an unsol event */
4379 pinctl = snd_hda_codec_read(codec, nid, 0,
4380 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4381 /* outputs are only ports capable of power management
4382 * any attempts on powering down a input port cause the
4383 * referenced VREF to act quirky.
4385 if (pinctl & AC_PINCTL_IN_EN) {
4386 stac_toggle_power_map(codec, nid, 1);
4389 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4390 def_conf = get_defcfg_connect(def_conf);
4391 /* skip any ports that don't have jacks since presence
4392 * detection is useless */
4393 if (def_conf != AC_JACK_PORT_COMPLEX) {
4394 if (def_conf != AC_JACK_PORT_NONE)
4395 stac_toggle_power_map(codec, nid, 1);
4398 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4399 stac_issue_unsol_event(codec, nid);
4402 #ifdef CONFIG_SND_HDA_POWER_SAVE
4404 if (spec->gpio_led && codec->patch_ops.check_power_status)
4405 codec->patch_ops.check_power_status(codec, 0x01);
4408 stac92xx_power_down(codec);
4412 static void stac92xx_free_jacks(struct hda_codec *codec)
4414 #ifdef CONFIG_SND_HDA_INPUT_JACK
4415 /* free jack instances manually when clearing/reconfiguring */
4416 struct sigmatel_spec *spec = codec->spec;
4417 if (!codec->bus->shutdown && spec->jacks.list) {
4418 struct sigmatel_jack *jacks = spec->jacks.list;
4420 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4422 snd_device_free(codec->bus->card, jacks->jack);
4425 snd_array_free(&spec->jacks);
4429 static void stac92xx_free_kctls(struct hda_codec *codec)
4431 struct sigmatel_spec *spec = codec->spec;
4433 if (spec->kctls.list) {
4434 struct snd_kcontrol_new *kctl = spec->kctls.list;
4436 for (i = 0; i < spec->kctls.used; i++)
4437 kfree(kctl[i].name);
4439 snd_array_free(&spec->kctls);
4442 static void stac92xx_shutup(struct hda_codec *codec)
4444 struct sigmatel_spec *spec = codec->spec;
4446 snd_hda_shutup_pins(codec);
4448 if (spec->eapd_mask)
4449 stac_gpio_set(codec, spec->gpio_mask,
4450 spec->gpio_dir, spec->gpio_data &
4454 static void stac92xx_free(struct hda_codec *codec)
4456 struct sigmatel_spec *spec = codec->spec;
4461 stac92xx_shutup(codec);
4462 stac92xx_free_jacks(codec);
4463 snd_array_free(&spec->events);
4466 snd_hda_detach_beep_device(codec);
4469 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4472 unsigned int old_ctl, pin_ctl;
4474 pin_ctl = snd_hda_codec_read(codec, nid,
4475 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4477 if (pin_ctl & AC_PINCTL_IN_EN) {
4479 * we need to check the current set-up direction of
4480 * shared input pins since they can be switched via
4481 * "xxx as Output" mixer switch
4483 struct sigmatel_spec *spec = codec->spec;
4484 if (nid == spec->line_switch || nid == spec->mic_switch)
4489 /* if setting pin direction bits, clear the current
4490 direction bits first */
4491 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4492 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4495 if (old_ctl != pin_ctl)
4496 snd_hda_codec_write_cache(codec, nid, 0,
4497 AC_VERB_SET_PIN_WIDGET_CONTROL,
4501 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4504 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4505 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4507 snd_hda_codec_write_cache(codec, nid, 0,
4508 AC_VERB_SET_PIN_WIDGET_CONTROL,
4512 static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4516 return snd_hda_jack_detect(codec, nid);
4519 static void stac92xx_line_out_detect(struct hda_codec *codec,
4522 struct sigmatel_spec *spec = codec->spec;
4523 struct auto_pin_cfg *cfg = &spec->autocfg;
4526 for (i = 0; i < cfg->line_outs; i++) {
4529 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4531 unsigned int pinctl;
4532 pinctl = snd_hda_codec_read(codec,
4533 cfg->line_out_pins[i], 0,
4534 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4535 if (pinctl & AC_PINCTL_IN_EN)
4536 presence = 0; /* mic- or line-input */
4541 /* disable speakers */
4542 for (i = 0; i < cfg->speaker_outs; i++)
4543 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4545 if (spec->eapd_mask && spec->eapd_switch)
4546 stac_gpio_set(codec, spec->gpio_mask,
4547 spec->gpio_dir, spec->gpio_data &
4550 /* enable speakers */
4551 for (i = 0; i < cfg->speaker_outs; i++)
4552 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4554 if (spec->eapd_mask && spec->eapd_switch)
4555 stac_gpio_set(codec, spec->gpio_mask,
4556 spec->gpio_dir, spec->gpio_data |
4561 /* return non-zero if the hp-pin of the given array index isn't
4562 * a jack-detection target
4564 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4566 struct auto_pin_cfg *cfg = &spec->autocfg;
4568 /* ignore sensing of shared line and mic jacks */
4569 if (cfg->hp_pins[i] == spec->line_switch)
4571 if (cfg->hp_pins[i] == spec->mic_switch)
4573 /* ignore if the pin is set as line-out */
4574 if (cfg->hp_pins[i] == spec->hp_switch)
4579 static void stac92xx_hp_detect(struct hda_codec *codec)
4581 struct sigmatel_spec *spec = codec->spec;
4582 struct auto_pin_cfg *cfg = &spec->autocfg;
4586 if (spec->gpio_mute)
4587 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4588 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4590 for (i = 0; i < cfg->hp_outs; i++) {
4593 if (no_hp_sensing(spec, i))
4595 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4597 unsigned int pinctl;
4598 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4599 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4600 if (pinctl & AC_PINCTL_IN_EN)
4601 presence = 0; /* mic- or line-input */
4606 /* disable lineouts */
4607 if (spec->hp_switch)
4608 stac92xx_reset_pinctl(codec, spec->hp_switch,
4610 for (i = 0; i < cfg->line_outs; i++)
4611 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4614 /* enable lineouts */
4615 if (spec->hp_switch)
4616 stac92xx_set_pinctl(codec, spec->hp_switch,
4618 for (i = 0; i < cfg->line_outs; i++)
4619 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4622 stac92xx_line_out_detect(codec, presence);
4623 /* toggle hp outs */
4624 for (i = 0; i < cfg->hp_outs; i++) {
4625 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4626 if (no_hp_sensing(spec, i))
4629 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4631 /* Resetting the pinctl like below may lead to (a sort of) regressions
4632 * on some devices since they use the HP pin actually for line/speaker
4633 * outs although the default pin config shows a different pin (that is
4634 * wrong and useless).
4636 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4637 * But, disabling the code below just works around it, and I'm too tired of
4638 * bug reports with such devices...
4641 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4646 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4649 struct sigmatel_spec *spec = codec->spec;
4650 unsigned int idx, val;
4652 for (idx = 0; idx < spec->num_pwrs; idx++) {
4653 if (spec->pwr_nids[idx] == nid)
4656 if (idx >= spec->num_pwrs)
4659 /* several codecs have two power down bits */
4660 if (spec->pwr_mapping)
4661 idx = spec->pwr_mapping[idx];
4665 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4671 /* power down unused output ports */
4672 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4675 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4677 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4680 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4682 struct sigmatel_spec *spec = codec->spec;
4683 struct sigmatel_jack *jacks = spec->jacks.list;
4687 for (i = 0; i < spec->jacks.used; i++) {
4688 if (jacks->nid == nid) {
4689 unsigned int pin_ctl =
4690 snd_hda_codec_read(codec, nid,
4691 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4693 int type = jacks->type;
4694 if (type == (SND_JACK_LINEOUT
4695 | SND_JACK_HEADPHONE))
4696 type = (pin_ctl & AC_PINCTL_HP_EN)
4697 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4698 snd_jack_report(jacks->jack,
4699 get_pin_presence(codec, nid)
4707 static void stac92xx_mic_detect(struct hda_codec *codec)
4709 struct sigmatel_spec *spec = codec->spec;
4710 struct sigmatel_mic_route *mic;
4712 if (get_pin_presence(codec, spec->ext_mic.pin))
4713 mic = &spec->ext_mic;
4715 mic = &spec->int_mic;
4716 if (mic->dmux_idx >= 0)
4717 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4718 AC_VERB_SET_CONNECT_SEL,
4720 if (mic->mux_idx >= 0)
4721 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4722 AC_VERB_SET_CONNECT_SEL,
4726 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4728 struct sigmatel_event *event = stac_get_event(codec, nid);
4731 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4734 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4736 struct sigmatel_spec *spec = codec->spec;
4737 struct sigmatel_event *event;
4740 tag = (res >> 26) & 0x7f;
4741 event = stac_get_event_from_tag(codec, tag);
4745 switch (event->type) {
4748 stac92xx_hp_detect(codec);
4750 case STAC_MIC_EVENT:
4751 stac92xx_mic_detect(codec);
4755 switch (event->type) {
4758 case STAC_MIC_EVENT:
4759 case STAC_INSERT_EVENT:
4760 case STAC_PWR_EVENT:
4761 if (spec->num_pwrs > 0)
4762 stac92xx_pin_sense(codec, event->nid);
4763 stac92xx_report_jack(codec, event->nid);
4765 switch (codec->subsystem_id) {
4767 if (event->nid == 0xb) {
4768 int pin = AC_PINCTL_IN_EN;
4770 if (get_pin_presence(codec, 0xa)
4771 && get_pin_presence(codec, 0xb))
4772 pin |= AC_PINCTL_VREF_80;
4773 if (!get_pin_presence(codec, 0xb))
4774 pin |= AC_PINCTL_VREF_80;
4776 /* toggle VREF state based on mic + hp pin
4779 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4783 case STAC_VREF_EVENT:
4784 data = snd_hda_codec_read(codec, codec->afg, 0,
4785 AC_VERB_GET_GPIO_DATA, 0);
4786 /* toggle VREF state based on GPIOx status */
4787 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4788 !!(data & (1 << event->data)));
4793 static int hp_blike_system(u32 subsystem_id);
4795 static void set_hp_led_gpio(struct hda_codec *codec)
4797 struct sigmatel_spec *spec = codec->spec;
4803 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4804 gpio &= AC_GPIO_IO_COUNT;
4806 spec->gpio_led = 0x08; /* GPIO 3 */
4808 spec->gpio_led = 0x01; /* GPIO 0 */
4812 * This method searches for the mute LED GPIO configuration
4813 * provided as OEM string in SMBIOS. The format of that string
4814 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4815 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4816 * that corresponds to the NOT muted state of the master volume
4817 * and G is the index of the GPIO to use as the mute LED control (0..9)
4818 * If _G portion is missing it is assigned based on the codec ID
4820 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4821 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
4824 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4825 * SMBIOS - at least the ones I have seen do not have them - which include
4826 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4827 * HP Pavilion dv9500t CTO.
4828 * Need more information on whether it is true across the entire series.
4831 static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
4833 struct sigmatel_spec *spec = codec->spec;
4834 const struct dmi_device *dev = NULL;
4836 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4837 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4839 if (sscanf(dev->name, "HP_Mute_LED_%d_%d",
4840 &spec->gpio_led_polarity,
4841 &spec->gpio_led) == 2) {
4842 spec->gpio_led = 1 << spec->gpio_led;
4845 if (sscanf(dev->name, "HP_Mute_LED_%d",
4846 &spec->gpio_led_polarity) == 1) {
4847 set_hp_led_gpio(codec);
4853 * Fallback case - if we don't find the DMI strings,
4854 * we statically set the GPIO - if not a B-series system.
4856 if (!hp_blike_system(codec->subsystem_id)) {
4857 set_hp_led_gpio(codec);
4858 spec->gpio_led_polarity = default_polarity;
4865 static int hp_blike_system(u32 subsystem_id)
4867 switch (subsystem_id) {
4894 #ifdef CONFIG_PROC_FS
4895 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4896 struct hda_codec *codec, hda_nid_t nid)
4898 if (nid == codec->afg)
4899 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4900 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4903 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4904 struct hda_codec *codec,
4907 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4908 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4911 /* stac92hd71bxx, stac92hd73xx */
4912 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4913 struct hda_codec *codec, hda_nid_t nid)
4915 stac92hd_proc_hook(buffer, codec, nid);
4916 if (nid == codec->afg)
4917 analog_loop_proc_hook(buffer, codec, 0xfa0);
4920 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4921 struct hda_codec *codec, hda_nid_t nid)
4923 if (nid == codec->afg)
4924 analog_loop_proc_hook(buffer, codec, 0xfe0);
4927 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4928 struct hda_codec *codec, hda_nid_t nid)
4930 if (nid == codec->afg)
4931 analog_loop_proc_hook(buffer, codec, 0xfeb);
4934 #define stac92hd_proc_hook NULL
4935 #define stac92hd7x_proc_hook NULL
4936 #define stac9205_proc_hook NULL
4937 #define stac927x_proc_hook NULL
4940 #ifdef SND_HDA_NEEDS_RESUME
4941 static int stac92xx_resume(struct hda_codec *codec)
4943 struct sigmatel_spec *spec = codec->spec;
4945 stac92xx_init(codec);
4946 snd_hda_codec_resume_amp(codec);
4947 snd_hda_codec_resume_cache(codec);
4948 /* fake event to set up pins again to override cached values */
4949 if (spec->hp_detect) {
4950 if (spec->autocfg.hp_pins[0])
4951 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4952 else if (spec->autocfg.line_out_pins[0])
4953 stac_issue_unsol_event(codec,
4954 spec->autocfg.line_out_pins[0]);
4956 #ifdef CONFIG_SND_HDA_POWER_SAVE
4958 if (spec->gpio_led && codec->patch_ops.check_power_status)
4959 codec->patch_ops.check_power_status(codec, 0x01);
4965 * using power check for controlling mute led of HP notebooks
4966 * check for mute state only on Speakers (nid = 0x10)
4968 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4969 * the LED is NOT working properly !
4971 * Changed name to reflect that it now works for any designated
4972 * model, not just HP HDX.
4975 #ifdef CONFIG_SND_HDA_POWER_SAVE
4976 static int stac92xx_hp_check_power_status(struct hda_codec *codec,
4979 struct sigmatel_spec *spec = codec->spec;
4982 for (i = 0; i < spec->multiout.num_dacs; i++) {
4983 nid = spec->multiout.dac_nids[i];
4984 if (!(snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4986 muted = 0; /* something heard */
4991 spec->gpio_data &= ~spec->gpio_led; /* orange */
4993 spec->gpio_data |= spec->gpio_led; /* white */
4995 if (!spec->gpio_led_polarity) {
4996 /* LED state is inverted on these systems */
4997 spec->gpio_data ^= spec->gpio_led;
5000 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5005 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
5007 stac92xx_shutup(codec);
5012 static struct hda_codec_ops stac92xx_patch_ops = {
5013 .build_controls = stac92xx_build_controls,
5014 .build_pcms = stac92xx_build_pcms,
5015 .init = stac92xx_init,
5016 .free = stac92xx_free,
5017 .unsol_event = stac92xx_unsol_event,
5018 #ifdef SND_HDA_NEEDS_RESUME
5019 .suspend = stac92xx_suspend,
5020 .resume = stac92xx_resume,
5022 .reboot_notify = stac92xx_shutup,
5025 static int patch_stac9200(struct hda_codec *codec)
5027 struct sigmatel_spec *spec;
5030 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5034 codec->no_trigger_sense = 1;
5036 spec->linear_tone_beep = 1;
5037 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
5038 spec->pin_nids = stac9200_pin_nids;
5039 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5042 if (spec->board_config < 0)
5043 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5046 stac92xx_set_config_regs(codec,
5047 stac9200_brd_tbl[spec->board_config]);
5049 spec->multiout.max_channels = 2;
5050 spec->multiout.num_dacs = 1;
5051 spec->multiout.dac_nids = stac9200_dac_nids;
5052 spec->adc_nids = stac9200_adc_nids;
5053 spec->mux_nids = stac9200_mux_nids;
5054 spec->num_muxes = 1;
5055 spec->num_dmics = 0;
5059 if (spec->board_config == STAC_9200_M4 ||
5060 spec->board_config == STAC_9200_M4_2 ||
5061 spec->board_config == STAC_9200_OQO)
5062 spec->init = stac9200_eapd_init;
5064 spec->init = stac9200_core_init;
5065 spec->mixer = stac9200_mixer;
5067 if (spec->board_config == STAC_9200_PANASONIC) {
5068 spec->gpio_mask = spec->gpio_dir = 0x09;
5069 spec->gpio_data = 0x00;
5072 err = stac9200_parse_auto_config(codec);
5074 stac92xx_free(codec);
5078 /* CF-74 has no headphone detection, and the driver should *NOT*
5079 * do detection and HP/speaker toggle because the hardware does it.
5081 if (spec->board_config == STAC_9200_PANASONIC)
5082 spec->hp_detect = 0;
5084 codec->patch_ops = stac92xx_patch_ops;
5089 static int patch_stac925x(struct hda_codec *codec)
5091 struct sigmatel_spec *spec;
5094 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5098 codec->no_trigger_sense = 1;
5100 spec->linear_tone_beep = 1;
5101 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
5102 spec->pin_nids = stac925x_pin_nids;
5104 /* Check first for codec ID */
5105 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5108 stac925x_codec_id_cfg_tbl);
5110 /* Now checks for PCI ID, if codec ID is not found */
5111 if (spec->board_config < 0)
5112 spec->board_config = snd_hda_check_board_config(codec,
5117 if (spec->board_config < 0)
5118 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5121 stac92xx_set_config_regs(codec,
5122 stac925x_brd_tbl[spec->board_config]);
5124 spec->multiout.max_channels = 2;
5125 spec->multiout.num_dacs = 1;
5126 spec->multiout.dac_nids = stac925x_dac_nids;
5127 spec->adc_nids = stac925x_adc_nids;
5128 spec->mux_nids = stac925x_mux_nids;
5129 spec->num_muxes = 1;
5132 switch (codec->vendor_id) {
5133 case 0x83847632: /* STAC9202 */
5134 case 0x83847633: /* STAC9202D */
5135 case 0x83847636: /* STAC9251 */
5136 case 0x83847637: /* STAC9251D */
5137 spec->num_dmics = STAC925X_NUM_DMICS;
5138 spec->dmic_nids = stac925x_dmic_nids;
5139 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5140 spec->dmux_nids = stac925x_dmux_nids;
5143 spec->num_dmics = 0;
5147 spec->init = stac925x_core_init;
5148 spec->mixer = stac925x_mixer;
5150 spec->capvols = stac925x_capvols;
5151 spec->capsws = stac925x_capsws;
5153 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
5155 if (spec->board_config < 0) {
5156 printk(KERN_WARNING "hda_codec: No auto-config is "
5157 "available, default to model=ref\n");
5158 spec->board_config = STAC_925x_REF;
5164 stac92xx_free(codec);
5168 codec->patch_ops = stac92xx_patch_ops;
5173 static int patch_stac92hd73xx(struct hda_codec *codec)
5175 struct sigmatel_spec *spec;
5176 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5180 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5184 codec->no_trigger_sense = 1;
5186 spec->linear_tone_beep = 0;
5187 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
5188 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5189 spec->pin_nids = stac92hd73xx_pin_nids;
5190 spec->board_config = snd_hda_check_board_config(codec,
5191 STAC_92HD73XX_MODELS,
5192 stac92hd73xx_models,
5193 stac92hd73xx_cfg_tbl);
5194 /* check codec subsystem id if not found */
5195 if (spec->board_config < 0)
5196 spec->board_config =
5197 snd_hda_check_board_codec_sid_config(codec,
5198 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5199 stac92hd73xx_codec_id_cfg_tbl);
5201 if (spec->board_config < 0)
5202 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5205 stac92xx_set_config_regs(codec,
5206 stac92hd73xx_brd_tbl[spec->board_config]);
5208 num_dacs = snd_hda_get_connections(codec, 0x0a,
5209 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5211 if (num_dacs < 3 || num_dacs > 5) {
5212 printk(KERN_WARNING "hda_codec: Could not determine "
5213 "number of channels defaulting to DAC count\n");
5214 num_dacs = STAC92HD73_DAC_COUNT;
5216 spec->init = stac92hd73xx_core_init;
5218 case 0x3: /* 6 Channel */
5219 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
5221 case 0x4: /* 8 Channel */
5222 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
5224 case 0x5: /* 10 Channel */
5225 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5228 spec->multiout.dac_nids = spec->dac_nids;
5230 spec->aloopback_mask = 0x01;
5231 spec->aloopback_shift = 8;
5233 spec->digbeep_nid = 0x1c;
5234 spec->mux_nids = stac92hd73xx_mux_nids;
5235 spec->adc_nids = stac92hd73xx_adc_nids;
5236 spec->dmic_nids = stac92hd73xx_dmic_nids;
5237 spec->dmux_nids = stac92hd73xx_dmux_nids;
5238 spec->smux_nids = stac92hd73xx_smux_nids;
5240 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5241 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
5242 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
5244 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5245 spec->capvols = stac92hd73xx_capvols;
5246 spec->capsws = stac92hd73xx_capsws;
5248 switch (spec->board_config) {
5250 spec->init = dell_eq_core_init;
5252 case STAC_DELL_M6_AMIC:
5253 case STAC_DELL_M6_DMIC:
5254 case STAC_DELL_M6_BOTH:
5255 spec->num_smuxes = 0;
5256 spec->eapd_switch = 0;
5258 switch (spec->board_config) {
5259 case STAC_DELL_M6_AMIC: /* Analog Mics */
5260 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5261 spec->num_dmics = 0;
5263 case STAC_DELL_M6_DMIC: /* Digital Mics */
5264 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5265 spec->num_dmics = 1;
5267 case STAC_DELL_M6_BOTH: /* Both */
5268 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5269 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5270 spec->num_dmics = 1;
5274 case STAC_ALIENWARE_M17X:
5275 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5276 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5277 spec->eapd_switch = 0;
5280 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5281 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5282 spec->eapd_switch = 1;
5285 if (spec->board_config != STAC_92HD73XX_REF) {
5286 /* GPIO0 High = Enable EAPD */
5287 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5288 spec->gpio_data = 0x01;
5291 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5292 spec->pwr_nids = stac92hd73xx_pwr_nids;
5294 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
5297 if (spec->board_config < 0) {
5298 printk(KERN_WARNING "hda_codec: No auto-config is "
5299 "available, default to model=ref\n");
5300 spec->board_config = STAC_92HD73XX_REF;
5307 stac92xx_free(codec);
5311 if (spec->board_config == STAC_92HD73XX_NO_JD)
5312 spec->hp_detect = 0;
5314 codec->patch_ops = stac92xx_patch_ops;
5316 codec->proc_widget_hook = stac92hd7x_proc_hook;
5321 static int patch_stac92hd83xxx(struct hda_codec *codec)
5323 struct sigmatel_spec *spec;
5324 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
5328 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5332 codec->no_trigger_sense = 1;
5334 spec->linear_tone_beep = 1;
5335 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5336 spec->digbeep_nid = 0x21;
5337 spec->mux_nids = stac92hd83xxx_mux_nids;
5338 spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids);
5339 spec->adc_nids = stac92hd83xxx_adc_nids;
5340 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5341 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5342 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5343 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5344 spec->multiout.dac_nids = spec->dac_nids;
5346 spec->init = stac92hd83xxx_core_init;
5347 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5348 spec->pin_nids = stac92hd83xxx_pin_nids;
5349 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5350 spec->capvols = stac92hd83xxx_capvols;
5351 spec->capsws = stac92hd83xxx_capsws;
5353 spec->board_config = snd_hda_check_board_config(codec,
5354 STAC_92HD83XXX_MODELS,
5355 stac92hd83xxx_models,
5356 stac92hd83xxx_cfg_tbl);
5358 if (spec->board_config < 0)
5359 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5362 stac92xx_set_config_regs(codec,
5363 stac92hd83xxx_brd_tbl[spec->board_config]);
5365 switch (codec->vendor_id) {
5372 spec->num_pins = ARRAY_SIZE(stac92hd88xxx_pin_nids);
5373 spec->pin_nids = stac92hd88xxx_pin_nids;
5375 spec->digbeep_nid = 0;
5382 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5388 codec->patch_ops = stac92xx_patch_ops;
5390 if (find_mute_led_gpio(codec, 0))
5391 snd_printd("mute LED gpio %d polarity %d\n",
5393 spec->gpio_led_polarity);
5395 #ifdef CONFIG_SND_HDA_POWER_SAVE
5396 if (spec->gpio_led) {
5397 spec->gpio_mask |= spec->gpio_led;
5398 spec->gpio_dir |= spec->gpio_led;
5399 spec->gpio_data |= spec->gpio_led;
5400 /* register check_power_status callback. */
5401 codec->patch_ops.check_power_status =
5402 stac92xx_hp_check_power_status;
5406 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5408 if (spec->board_config < 0) {
5409 printk(KERN_WARNING "hda_codec: No auto-config is "
5410 "available, default to model=ref\n");
5411 spec->board_config = STAC_92HD83XXX_REF;
5418 stac92xx_free(codec);
5422 /* docking output support */
5423 num_dacs = snd_hda_get_connections(codec, 0xF,
5424 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5425 /* skip non-DAC connections */
5426 while (num_dacs >= 0 &&
5427 (get_wcaps_type(get_wcaps(codec, conn[num_dacs]))
5430 /* set port E and F to select the last DAC */
5431 if (num_dacs >= 0) {
5432 snd_hda_codec_write_cache(codec, 0xE, 0,
5433 AC_VERB_SET_CONNECT_SEL, num_dacs);
5434 snd_hda_codec_write_cache(codec, 0xF, 0,
5435 AC_VERB_SET_CONNECT_SEL, num_dacs);
5438 codec->proc_widget_hook = stac92hd_proc_hook;
5443 /* get the pin connection (fixed, none, etc) */
5444 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5446 struct sigmatel_spec *spec = codec->spec;
5449 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5450 return get_defcfg_connect(cfg);
5453 static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5454 hda_nid_t *nids, int num_nids)
5456 struct sigmatel_spec *spec = codec->spec;
5458 unsigned int def_conf;
5460 for (num = 0; num < num_nids; num++) {
5461 for (idx = 0; idx < spec->num_pins; idx++)
5462 if (spec->pin_nids[idx] == nids[num])
5464 if (idx >= spec->num_pins)
5466 def_conf = stac_get_defcfg_connect(codec, idx);
5467 if (def_conf == AC_JACK_PORT_NONE)
5473 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5476 struct sigmatel_spec *spec = codec->spec;
5479 for (idx = 0; idx < spec->num_pins; idx++)
5480 if (spec->pin_nids[idx] == dig0pin)
5482 if ((idx + 2) >= spec->num_pins)
5486 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5489 /* dig0pin + dig2pin case */
5490 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5492 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5498 /* HP dv7 bass switch - GPIO5 */
5499 #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5500 static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5501 struct snd_ctl_elem_value *ucontrol)
5503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5504 struct sigmatel_spec *spec = codec->spec;
5505 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5509 static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
5510 struct snd_ctl_elem_value *ucontrol)
5512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5513 struct sigmatel_spec *spec = codec->spec;
5514 unsigned int gpio_data;
5516 gpio_data = (spec->gpio_data & ~0x20) |
5517 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5518 if (gpio_data == spec->gpio_data)
5520 spec->gpio_data = gpio_data;
5521 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5525 static struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
5526 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5527 .info = stac_hp_bass_gpio_info,
5528 .get = stac_hp_bass_gpio_get,
5529 .put = stac_hp_bass_gpio_put,
5532 static int stac_add_hp_bass_switch(struct hda_codec *codec)
5534 struct sigmatel_spec *spec = codec->spec;
5536 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5537 "Bass Speaker Playback Switch", 0))
5540 spec->gpio_mask |= 0x20;
5541 spec->gpio_dir |= 0x20;
5542 spec->gpio_data |= 0x20;
5546 static int patch_stac92hd71bxx(struct hda_codec *codec)
5548 struct sigmatel_spec *spec;
5549 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5550 unsigned int pin_cfg;
5553 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5557 codec->no_trigger_sense = 1;
5559 spec->linear_tone_beep = 0;
5560 codec->patch_ops = stac92xx_patch_ops;
5561 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5562 switch (codec->vendor_id) {
5565 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5569 /* On 92HD75Bx 0x27 isn't a pin nid */
5573 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5575 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5576 spec->board_config = snd_hda_check_board_config(codec,
5577 STAC_92HD71BXX_MODELS,
5578 stac92hd71bxx_models,
5579 stac92hd71bxx_cfg_tbl);
5581 if (spec->board_config < 0)
5582 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5585 stac92xx_set_config_regs(codec,
5586 stac92hd71bxx_brd_tbl[spec->board_config]);
5588 if (spec->board_config != STAC_92HD71BXX_REF) {
5590 spec->gpio_mask = 0x01;
5591 spec->gpio_dir = 0x01;
5592 spec->gpio_data = 0x01;
5595 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5596 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5598 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5599 spec->capvols = stac92hd71bxx_capvols;
5600 spec->capsws = stac92hd71bxx_capsws;
5602 switch (codec->vendor_id) {
5603 case 0x111d76b6: /* 4 Port without Analog Mixer */
5607 case 0x111d76b4: /* 6 Port without Analog Mixer */
5609 spec->init = stac92hd71bxx_core_init;
5610 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5611 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5612 stac92hd71bxx_dmic_nids,
5613 STAC92HD71BXX_NUM_DMICS);
5615 case 0x111d7608: /* 5 Port with Analog Mixer */
5616 switch (spec->board_config) {
5618 /* Enable VREF power saving on GPIO1 detect */
5619 err = stac_add_event(spec, codec->afg,
5620 STAC_VREF_EVENT, 0x02);
5623 snd_hda_codec_write_cache(codec, codec->afg, 0,
5624 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5625 snd_hda_codec_write_cache(codec, codec->afg, 0,
5626 AC_VERB_SET_UNSOLICITED_ENABLE,
5628 spec->gpio_mask |= 0x02;
5631 if ((codec->revision_id & 0xf) == 0 ||
5632 (codec->revision_id & 0xf) == 1)
5633 spec->stream_delay = 40; /* 40 milliseconds */
5635 /* no output amps */
5638 spec->init = stac92hd71bxx_core_init;
5640 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5641 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5642 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5643 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5644 stac92hd71bxx_dmic_nids,
5645 STAC92HD71BXX_NUM_DMICS - 1);
5647 case 0x111d7603: /* 6 Port with Analog Mixer */
5648 if ((codec->revision_id & 0xf) == 1)
5649 spec->stream_delay = 40; /* 40 milliseconds */
5651 /* no output amps */
5655 spec->init = stac92hd71bxx_core_init;
5656 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5657 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5658 stac92hd71bxx_dmic_nids,
5659 STAC92HD71BXX_NUM_DMICS);
5663 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5664 snd_hda_sequence_write_cache(codec, unmute_init);
5666 /* Some HP machines seem to have unstable codec communications
5667 * especially with ATI fglrx driver. For recovering from the
5668 * CORB/RIRB stall, allow the BUS reset and keep always sync
5670 if (spec->board_config == STAC_HP_DV5) {
5671 codec->bus->sync_write = 1;
5672 codec->bus->allow_bus_reset = 1;
5675 spec->aloopback_ctl = stac92hd71bxx_loopback;
5676 spec->aloopback_mask = 0x50;
5677 spec->aloopback_shift = 0;
5679 spec->powerdown_adcs = 1;
5680 spec->digbeep_nid = 0x26;
5681 spec->mux_nids = stac92hd71bxx_mux_nids;
5682 spec->adc_nids = stac92hd71bxx_adc_nids;
5683 spec->smux_nids = stac92hd71bxx_smux_nids;
5684 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5686 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5687 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5688 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5689 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5691 snd_printdd("Found board config: %d\n", spec->board_config);
5693 switch (spec->board_config) {
5695 /* enable internal microphone */
5696 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5697 stac92xx_auto_set_pinctl(codec, 0x0e,
5698 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5700 case STAC_DELL_M4_2:
5701 spec->num_dmics = 0;
5702 spec->num_smuxes = 0;
5703 spec->num_dmuxes = 0;
5705 case STAC_DELL_M4_1:
5706 case STAC_DELL_M4_3:
5707 spec->num_dmics = 1;
5708 spec->num_smuxes = 0;
5709 spec->num_dmuxes = 1;
5711 case STAC_HP_DV4_1222NR:
5712 spec->num_dmics = 1;
5713 /* I don't know if it needs 1 or 2 smuxes - will wait for
5714 * bug reports to fix if needed
5716 spec->num_smuxes = 1;
5717 spec->num_dmuxes = 1;
5720 spec->gpio_led = 0x01;
5723 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5724 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5725 /* HP dv6 gives the headphone pin as a line-out. Thus we
5726 * need to set hp_detect flag here to force to enable HP
5729 spec->hp_detect = 1;
5732 spec->num_dmics = 1;
5733 spec->num_dmuxes = 1;
5734 spec->num_smuxes = 1;
5735 spec->gpio_led = 0x08;
5739 if (hp_blike_system(codec->subsystem_id)) {
5740 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5741 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5742 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5743 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5744 /* It was changed in the BIOS to just satisfy MS DTM.
5745 * Lets turn it back into slaved HP
5747 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5748 | (AC_JACK_HP_OUT <<
5749 AC_DEFCFG_DEVICE_SHIFT);
5750 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5751 | AC_DEFCFG_SEQUENCE)))
5753 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5757 if (find_mute_led_gpio(codec, 1))
5758 snd_printd("mute LED gpio %d polarity %d\n",
5760 spec->gpio_led_polarity);
5762 #ifdef CONFIG_SND_HDA_POWER_SAVE
5763 if (spec->gpio_led) {
5764 spec->gpio_mask |= spec->gpio_led;
5765 spec->gpio_dir |= spec->gpio_led;
5766 spec->gpio_data |= spec->gpio_led;
5767 /* register check_power_status callback. */
5768 codec->patch_ops.check_power_status =
5769 stac92xx_hp_check_power_status;
5773 spec->multiout.dac_nids = spec->dac_nids;
5775 err = stac92xx_parse_auto_config(codec, 0x21, 0);
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_92HD71BXX_REF;
5787 stac92xx_free(codec);
5791 /* enable bass on HP dv7 */
5792 if (spec->board_config == STAC_HP_DV4 ||
5793 spec->board_config == STAC_HP_DV5) {
5795 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
5796 cap &= AC_GPIO_IO_COUNT;
5798 stac_add_hp_bass_switch(codec);
5801 codec->proc_widget_hook = stac92hd7x_proc_hook;
5806 static int patch_stac922x(struct hda_codec *codec)
5808 struct sigmatel_spec *spec;
5811 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5815 codec->no_trigger_sense = 1;
5817 spec->linear_tone_beep = 1;
5818 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5819 spec->pin_nids = stac922x_pin_nids;
5820 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5823 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5824 spec->gpio_mask = spec->gpio_dir = 0x03;
5825 spec->gpio_data = 0x03;
5826 /* Intel Macs have all same PCI SSID, so we need to check
5827 * codec SSID to distinguish the exact models
5829 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5830 switch (codec->subsystem_id) {
5833 spec->board_config = STAC_INTEL_MAC_V1;
5837 spec->board_config = STAC_INTEL_MAC_V2;
5845 spec->board_config = STAC_INTEL_MAC_V3;
5849 spec->board_config = STAC_INTEL_MAC_V4;
5853 spec->board_config = STAC_INTEL_MAC_V5;
5856 spec->board_config = STAC_INTEL_MAC_V3;
5862 if (spec->board_config < 0)
5863 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5866 stac92xx_set_config_regs(codec,
5867 stac922x_brd_tbl[spec->board_config]);
5869 spec->adc_nids = stac922x_adc_nids;
5870 spec->mux_nids = stac922x_mux_nids;
5871 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5872 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5873 spec->num_dmics = 0;
5876 spec->init = stac922x_core_init;
5878 spec->num_caps = STAC922X_NUM_CAPS;
5879 spec->capvols = stac922x_capvols;
5880 spec->capsws = stac922x_capsws;
5882 spec->multiout.dac_nids = spec->dac_nids;
5884 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5886 if (spec->board_config < 0) {
5887 printk(KERN_WARNING "hda_codec: No auto-config is "
5888 "available, default to model=ref\n");
5889 spec->board_config = STAC_D945_REF;
5895 stac92xx_free(codec);
5899 codec->patch_ops = stac92xx_patch_ops;
5901 /* Fix Mux capture level; max to 2 */
5902 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5903 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5904 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5905 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5906 (0 << AC_AMPCAP_MUTE_SHIFT));
5911 static int patch_stac927x(struct hda_codec *codec)
5913 struct sigmatel_spec *spec;
5916 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5920 codec->no_trigger_sense = 1;
5922 spec->linear_tone_beep = 1;
5923 codec->slave_dig_outs = stac927x_slave_dig_outs;
5924 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5925 spec->pin_nids = stac927x_pin_nids;
5926 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5930 if (spec->board_config < 0)
5931 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5934 stac92xx_set_config_regs(codec,
5935 stac927x_brd_tbl[spec->board_config]);
5937 spec->digbeep_nid = 0x23;
5938 spec->adc_nids = stac927x_adc_nids;
5939 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5940 spec->mux_nids = stac927x_mux_nids;
5941 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5942 spec->smux_nids = stac927x_smux_nids;
5943 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5944 spec->spdif_labels = stac927x_spdif_labels;
5945 spec->dac_list = stac927x_dac_nids;
5946 spec->multiout.dac_nids = spec->dac_nids;
5948 if (spec->board_config != STAC_D965_REF) {
5949 /* GPIO0 High = Enable EAPD */
5950 spec->eapd_mask = spec->gpio_mask = 0x01;
5951 spec->gpio_dir = spec->gpio_data = 0x01;
5954 switch (spec->board_config) {
5957 /* GPIO0 High = Enable EAPD */
5958 spec->num_dmics = 0;
5959 spec->init = d965_core_init;
5961 case STAC_DELL_BIOS:
5962 switch (codec->subsystem_id) {
5965 /* correct the device field to SPDIF out */
5966 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5969 /* configure the analog microphone on some laptops */
5970 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5971 /* correct the front output jack as a hp out */
5972 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5973 /* correct the front input jack as a mic */
5974 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5977 if (codec->subsystem_id != 0x1028022f) {
5978 /* GPIO2 High = Enable EAPD */
5979 spec->eapd_mask = spec->gpio_mask = 0x04;
5980 spec->gpio_dir = spec->gpio_data = 0x04;
5982 spec->dmic_nids = stac927x_dmic_nids;
5983 spec->num_dmics = STAC927X_NUM_DMICS;
5985 spec->init = dell_3st_core_init;
5986 spec->dmux_nids = stac927x_dmux_nids;
5987 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5989 case STAC_927X_VOLKNOB:
5990 spec->num_dmics = 0;
5991 spec->init = stac927x_volknob_core_init;
5994 spec->num_dmics = 0;
5995 spec->init = stac927x_core_init;
5999 spec->num_caps = STAC927X_NUM_CAPS;
6000 spec->capvols = stac927x_capvols;
6001 spec->capsws = stac927x_capsws;
6004 spec->aloopback_ctl = stac927x_loopback;
6005 spec->aloopback_mask = 0x40;
6006 spec->aloopback_shift = 0;
6007 spec->eapd_switch = 1;
6009 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
6011 if (spec->board_config < 0) {
6012 printk(KERN_WARNING "hda_codec: No auto-config is "
6013 "available, default to model=ref\n");
6014 spec->board_config = STAC_D965_REF;
6020 stac92xx_free(codec);
6024 codec->patch_ops = stac92xx_patch_ops;
6026 codec->proc_widget_hook = stac927x_proc_hook;
6030 * The STAC927x seem to require fairly long delays for certain
6031 * command sequences. With too short delays (even if the answer
6032 * is set to RIRB properly), it results in the silence output
6033 * on some hardwares like Dell.
6035 * The below flag enables the longer delay (see get_response
6038 codec->bus->needs_damn_long_delay = 1;
6040 /* no jack detecion for ref-no-jd model */
6041 if (spec->board_config == STAC_D965_REF_NO_JD)
6042 spec->hp_detect = 0;
6047 static int patch_stac9205(struct hda_codec *codec)
6049 struct sigmatel_spec *spec;
6052 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6056 codec->no_trigger_sense = 1;
6058 spec->linear_tone_beep = 1;
6059 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
6060 spec->pin_nids = stac9205_pin_nids;
6061 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6065 if (spec->board_config < 0)
6066 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6069 stac92xx_set_config_regs(codec,
6070 stac9205_brd_tbl[spec->board_config]);
6072 spec->digbeep_nid = 0x23;
6073 spec->adc_nids = stac9205_adc_nids;
6074 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
6075 spec->mux_nids = stac9205_mux_nids;
6076 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
6077 spec->smux_nids = stac9205_smux_nids;
6078 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
6079 spec->dmic_nids = stac9205_dmic_nids;
6080 spec->num_dmics = STAC9205_NUM_DMICS;
6081 spec->dmux_nids = stac9205_dmux_nids;
6082 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
6085 spec->init = stac9205_core_init;
6086 spec->aloopback_ctl = stac9205_loopback;
6088 spec->num_caps = STAC9205_NUM_CAPS;
6089 spec->capvols = stac9205_capvols;
6090 spec->capsws = stac9205_capsws;
6092 spec->aloopback_mask = 0x40;
6093 spec->aloopback_shift = 0;
6094 /* Turn on/off EAPD per HP plugging */
6095 if (spec->board_config != STAC_9205_EAPD)
6096 spec->eapd_switch = 1;
6097 spec->multiout.dac_nids = spec->dac_nids;
6099 switch (spec->board_config){
6100 case STAC_9205_DELL_M43:
6101 /* Enable SPDIF in/out */
6102 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6103 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
6105 /* Enable unsol response for GPIO4/Dock HP connection */
6106 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
6109 snd_hda_codec_write_cache(codec, codec->afg, 0,
6110 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
6111 snd_hda_codec_write_cache(codec, codec->afg, 0,
6112 AC_VERB_SET_UNSOLICITED_ENABLE,
6115 spec->gpio_dir = 0x0b;
6116 spec->eapd_mask = 0x01;
6117 spec->gpio_mask = 0x1b;
6118 spec->gpio_mute = 0x10;
6119 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
6122 spec->gpio_data = 0x01;
6125 /* SPDIF-In enabled */
6128 /* GPIO0 High = EAPD */
6129 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6130 spec->gpio_data = 0x01;
6134 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
6136 if (spec->board_config < 0) {
6137 printk(KERN_WARNING "hda_codec: No auto-config is "
6138 "available, default to model=ref\n");
6139 spec->board_config = STAC_9205_REF;
6145 stac92xx_free(codec);
6149 codec->patch_ops = stac92xx_patch_ops;
6151 codec->proc_widget_hook = stac9205_proc_hook;
6160 static struct hda_verb stac9872_core_init[] = {
6161 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
6162 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6166 static hda_nid_t stac9872_pin_nids[] = {
6167 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6171 static hda_nid_t stac9872_adc_nids[] = {
6175 static hda_nid_t stac9872_mux_nids[] = {
6179 static unsigned long stac9872_capvols[] = {
6180 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6182 #define stac9872_capsws stac9872_capvols
6184 static unsigned int stac9872_vaio_pin_configs[9] = {
6185 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6186 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6190 static const char *stac9872_models[STAC_9872_MODELS] = {
6191 [STAC_9872_AUTO] = "auto",
6192 [STAC_9872_VAIO] = "vaio",
6195 static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
6196 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6199 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
6200 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6201 "Sony VAIO F/S", STAC_9872_VAIO),
6205 static int patch_stac9872(struct hda_codec *codec)
6207 struct sigmatel_spec *spec;
6210 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6213 codec->no_trigger_sense = 1;
6215 spec->linear_tone_beep = 1;
6216 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6217 spec->pin_nids = stac9872_pin_nids;
6219 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6222 if (spec->board_config < 0)
6223 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6226 stac92xx_set_config_regs(codec,
6227 stac9872_brd_tbl[spec->board_config]);
6229 spec->multiout.dac_nids = spec->dac_nids;
6230 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6231 spec->adc_nids = stac9872_adc_nids;
6232 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6233 spec->mux_nids = stac9872_mux_nids;
6234 spec->init = stac9872_core_init;
6236 spec->capvols = stac9872_capvols;
6237 spec->capsws = stac9872_capsws;
6239 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
6241 stac92xx_free(codec);
6244 spec->input_mux = &spec->private_imux;
6245 codec->patch_ops = stac92xx_patch_ops;
6253 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
6254 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6255 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6256 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6257 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6258 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6259 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6260 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
6261 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6262 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6263 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6264 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6265 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6266 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
6267 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6268 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6269 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6270 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6271 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6272 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6273 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6274 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6275 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6276 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
6277 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6278 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6279 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6280 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6281 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6282 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
6283 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6284 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
6285 /* The following does not take into account .id=0x83847661 when subsys =
6286 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6287 * currently not fully supported.
6289 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6290 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6291 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
6292 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
6293 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6294 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6295 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6296 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6297 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6298 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6299 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6300 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
6301 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
6302 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
6303 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
6304 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
6305 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
6306 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
6307 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
6308 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6309 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6310 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6311 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
6312 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
6313 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6314 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
6315 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
6316 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6317 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6318 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6319 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6320 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6321 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6322 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6323 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6324 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
6325 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
6326 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
6327 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
6328 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
6329 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
6330 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
6331 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
6332 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
6333 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
6334 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
6335 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
6336 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
6337 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
6338 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
6342 MODULE_ALIAS("snd-hda-codec-id:8384*");
6343 MODULE_ALIAS("snd-hda-codec-id:111d*");
6345 MODULE_LICENSE("GPL");
6346 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6348 static struct hda_codec_preset_list sigmatel_list = {
6349 .preset = snd_hda_preset_sigmatel,
6350 .owner = THIS_MODULE,
6353 static int __init patch_sigmatel_init(void)
6355 return snd_hda_add_codec_preset(&sigmatel_list);
6358 static void __exit patch_sigmatel_exit(void)
6360 snd_hda_delete_codec_preset(&sigmatel_list);
6363 module_init(patch_sigmatel_init)
6364 module_exit(patch_sigmatel_exit)