2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include <sound/asoundef.h>
33 #include <sound/jack.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
79 STAC_92HD73XX_NO_JD, /* no jack-detection */
91 STAC_92HD83XXX_PWR_REF,
106 STAC_92HD71BXX_MODELS
132 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
133 * is given, one of the above models will be
134 * chosen according to the subsystem id. */
135 /* for backward compatibility */
152 STAC_D965_REF_NO_JD, /* no jack-detection */
168 struct sigmatel_event {
175 struct sigmatel_jack {
178 struct snd_jack *jack;
181 struct sigmatel_mic_route {
183 unsigned char mux_idx;
184 unsigned char dmux_idx;
187 struct sigmatel_spec {
188 struct snd_kcontrol_new *mixers[4];
189 unsigned int num_mixers;
192 unsigned int eapd_switch: 1;
193 unsigned int surr_switch: 1;
194 unsigned int alt_switch: 1;
195 unsigned int hp_detect: 1;
196 unsigned int spdif_mute: 1;
197 unsigned int check_volume_offset:1;
198 unsigned int auto_mic:1;
201 unsigned int eapd_mask;
202 unsigned int gpio_mask;
203 unsigned int gpio_dir;
204 unsigned int gpio_data;
205 unsigned int gpio_mute;
206 unsigned int gpio_led;
209 unsigned int stream_delay;
211 /* analog loopback */
212 struct snd_kcontrol_new *aloopback_ctl;
213 unsigned char aloopback_mask;
214 unsigned char aloopback_shift;
216 /* power management */
217 unsigned int num_pwrs;
218 unsigned int *pwr_mapping;
223 struct snd_array jacks;
226 struct snd_array events;
229 struct hda_input_mux *mono_mux;
230 struct hda_input_mux *amp_mux;
231 unsigned int cur_mmux;
232 struct hda_multi_out multiout;
233 hda_nid_t dac_nids[5];
234 hda_nid_t hp_dacs[5];
235 hda_nid_t speaker_dacs[5];
241 unsigned int num_adcs;
243 unsigned int num_muxes;
244 hda_nid_t *dmic_nids;
245 unsigned int num_dmics;
246 hda_nid_t *dmux_nids;
247 unsigned int num_dmuxes;
248 hda_nid_t *smux_nids;
249 unsigned int num_smuxes;
250 unsigned int num_analog_muxes;
252 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
253 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
254 unsigned int num_caps; /* number of capture volume/switch elements */
256 struct sigmatel_mic_route ext_mic;
257 struct sigmatel_mic_route int_mic;
259 const char **spdif_labels;
261 hda_nid_t dig_in_nid;
263 hda_nid_t anabeep_nid;
264 hda_nid_t digbeep_nid;
268 unsigned int num_pins;
270 /* codec specific stuff */
271 struct hda_verb *init;
272 struct snd_kcontrol_new *mixer;
275 struct hda_input_mux *dinput_mux;
276 unsigned int cur_dmux[2];
277 struct hda_input_mux *input_mux;
278 unsigned int cur_mux[3];
279 struct hda_input_mux *sinput_mux;
280 unsigned int cur_smux[2];
281 unsigned int cur_amux;
283 unsigned int num_amps;
284 unsigned int powerdown_adcs;
287 unsigned int io_switch[2];
288 unsigned int clfe_swap;
289 hda_nid_t line_switch; /* shared line-in for input and output */
290 hda_nid_t mic_switch; /* shared mic-in for input and output */
291 hda_nid_t hp_switch; /* NID of HP as line-out */
292 unsigned int aloopback;
294 struct hda_pcm pcm_rec[2]; /* PCM information */
296 /* dynamic controls and input_mux */
297 struct auto_pin_cfg autocfg;
298 struct snd_array kctls;
299 struct hda_input_mux private_dimux;
300 struct hda_input_mux private_imux;
301 struct hda_input_mux private_smux;
302 struct hda_input_mux private_amp_mux;
303 struct hda_input_mux private_mono_mux;
306 static hda_nid_t stac9200_adc_nids[1] = {
310 static hda_nid_t stac9200_mux_nids[1] = {
314 static hda_nid_t stac9200_dac_nids[1] = {
318 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
319 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
323 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
327 static hda_nid_t stac92hd73xx_adc_nids[2] = {
331 #define DELL_M6_AMP 2
332 static hda_nid_t stac92hd73xx_amp_nids[3] = {
336 #define STAC92HD73XX_NUM_DMICS 2
337 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
341 #define STAC92HD73_DAC_COUNT 5
343 static hda_nid_t stac92hd73xx_mux_nids[4] = {
344 0x28, 0x29, 0x2a, 0x2b,
347 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
351 static hda_nid_t stac92hd73xx_smux_nids[2] = {
355 #define STAC92HD73XX_NUM_CAPS 2
356 static unsigned long stac92hd73xx_capvols[] = {
357 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
358 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
360 #define stac92hd73xx_capsws stac92hd73xx_capvols
362 #define STAC92HD83XXX_NUM_DMICS 2
363 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
367 #define STAC92HD83_DAC_COUNT 3
369 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
373 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
377 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
381 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
385 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
386 0x03, 0x0c, 0x20, 0x40,
389 static hda_nid_t stac92hd83xxx_amp_nids[1] = {
393 #define STAC92HD83XXX_NUM_CAPS 2
394 static unsigned long stac92hd83xxx_capvols[] = {
395 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
396 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
398 #define stac92hd83xxx_capsws stac92hd83xxx_capvols
400 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
404 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
408 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
412 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
416 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
420 #define STAC92HD71BXX_NUM_DMICS 2
421 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
425 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
429 #define STAC92HD71BXX_NUM_CAPS 2
430 static unsigned long stac92hd71bxx_capvols[] = {
431 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
432 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
434 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
436 static hda_nid_t stac925x_adc_nids[1] = {
440 static hda_nid_t stac925x_mux_nids[1] = {
444 static hda_nid_t stac925x_dac_nids[1] = {
448 #define STAC925X_NUM_DMICS 1
449 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
453 static hda_nid_t stac925x_dmux_nids[1] = {
457 static unsigned long stac925x_capvols[] = {
458 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
460 static unsigned long stac925x_capsws[] = {
461 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
464 static hda_nid_t stac922x_adc_nids[2] = {
468 static hda_nid_t stac922x_mux_nids[2] = {
472 #define STAC922X_NUM_CAPS 2
473 static unsigned long stac922x_capvols[] = {
474 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
475 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
477 #define stac922x_capsws stac922x_capvols
479 static hda_nid_t stac927x_slave_dig_outs[2] = {
483 static hda_nid_t stac927x_adc_nids[3] = {
487 static hda_nid_t stac927x_mux_nids[3] = {
491 static hda_nid_t stac927x_smux_nids[1] = {
495 static hda_nid_t stac927x_dac_nids[6] = {
496 0x02, 0x03, 0x04, 0x05, 0x06, 0
499 static hda_nid_t stac927x_dmux_nids[1] = {
503 #define STAC927X_NUM_DMICS 2
504 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
508 #define STAC927X_NUM_CAPS 3
509 static unsigned long stac927x_capvols[] = {
510 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
511 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
512 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
514 static unsigned long stac927x_capsws[] = {
515 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
516 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
517 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
520 static const char *stac927x_spdif_labels[5] = {
521 "Digital Playback", "ADAT", "Analog Mux 1",
522 "Analog Mux 2", "Analog Mux 3"
525 static hda_nid_t stac9205_adc_nids[2] = {
529 static hda_nid_t stac9205_mux_nids[2] = {
533 static hda_nid_t stac9205_dmux_nids[1] = {
537 static hda_nid_t stac9205_smux_nids[1] = {
541 #define STAC9205_NUM_DMICS 2
542 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
546 #define STAC9205_NUM_CAPS 2
547 static unsigned long stac9205_capvols[] = {
548 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
549 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
551 static unsigned long stac9205_capsws[] = {
552 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
553 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
556 static hda_nid_t stac9200_pin_nids[8] = {
557 0x08, 0x09, 0x0d, 0x0e,
558 0x0f, 0x10, 0x11, 0x12,
561 static hda_nid_t stac925x_pin_nids[8] = {
562 0x07, 0x08, 0x0a, 0x0b,
563 0x0c, 0x0d, 0x10, 0x11,
566 static hda_nid_t stac922x_pin_nids[10] = {
567 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
568 0x0f, 0x10, 0x11, 0x15, 0x1b,
571 static hda_nid_t stac92hd73xx_pin_nids[13] = {
572 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
573 0x0f, 0x10, 0x11, 0x12, 0x13,
577 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
578 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
579 0x0f, 0x10, 0x11, 0x1f, 0x20,
582 #define STAC92HD71BXX_NUM_PINS 13
583 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
584 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
585 0x00, 0x14, 0x18, 0x19, 0x1e,
588 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
589 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
590 0x0f, 0x14, 0x18, 0x19, 0x1e,
594 static hda_nid_t stac927x_pin_nids[14] = {
595 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
596 0x0f, 0x10, 0x11, 0x12, 0x13,
597 0x14, 0x21, 0x22, 0x23,
600 static hda_nid_t stac9205_pin_nids[12] = {
601 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
602 0x0f, 0x14, 0x16, 0x17, 0x18,
606 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
608 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
609 struct snd_ctl_elem_value *ucontrol)
611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
612 struct sigmatel_spec *spec = codec->spec;
613 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
615 kcontrol->private_value ^= get_amp_nid(kcontrol);
616 kcontrol->private_value |= nid;
618 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
621 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_value *ucontrol)
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct sigmatel_spec *spec = codec->spec;
626 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
628 kcontrol->private_value ^= get_amp_nid(kcontrol);
629 kcontrol->private_value |= nid;
631 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
634 static int stac92xx_dmux_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->dinput_mux, uinfo);
642 static int stac92xx_dmux_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 dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
649 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
653 static int stac92xx_dmux_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 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
660 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
661 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
664 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
665 struct snd_ctl_elem_info *uinfo)
667 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
668 struct sigmatel_spec *spec = codec->spec;
669 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
672 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_value *ucontrol)
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 struct sigmatel_spec *spec = codec->spec;
677 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
679 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
683 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
684 struct snd_ctl_elem_value *ucontrol)
686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
687 struct sigmatel_spec *spec = codec->spec;
688 struct hda_input_mux *smux = &spec->private_smux;
689 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
693 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
694 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
698 if (spec->spdif_mute) {
700 nid = spec->multiout.dig_out_nid;
702 nid = codec->slave_dig_outs[smux_idx - 1];
703 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
707 /* un/mute SPDIF out */
708 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
714 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
715 hda_nid_t nid, unsigned int new_vref)
719 pincfg = snd_hda_codec_read(codec, nid, 0,
720 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
723 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
726 if (new_vref == AC_PINCTL_VREF_HIZ)
727 pincfg |= AC_PINCTL_OUT_EN;
729 pincfg |= AC_PINCTL_IN_EN;
731 error = snd_hda_codec_write_cache(codec, nid, 0,
732 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
739 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
742 vref = snd_hda_codec_read(codec, nid, 0,
743 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
744 vref &= AC_PINCTL_VREFEN;
748 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
750 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
751 struct sigmatel_spec *spec = codec->spec;
752 return snd_hda_input_mux_info(spec->input_mux, uinfo);
755 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
758 struct sigmatel_spec *spec = codec->spec;
759 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
761 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
765 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
767 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
768 struct sigmatel_spec *spec = codec->spec;
769 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
770 const struct hda_input_mux *imux = spec->input_mux;
771 unsigned int idx, prev_idx;
773 idx = ucontrol->value.enumerated.item[0];
774 if (idx >= imux->num_items)
775 idx = imux->num_items - 1;
776 prev_idx = spec->cur_mux[adc_idx];
779 if (idx < spec->num_analog_muxes) {
780 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
781 AC_VERB_SET_CONNECT_SEL,
782 imux->items[idx].index);
783 if (prev_idx >= spec->num_analog_muxes) {
784 imux = spec->dinput_mux;
786 snd_hda_codec_write_cache(codec,
787 spec->dmux_nids[adc_idx], 0,
788 AC_VERB_SET_CONNECT_SEL,
789 imux->items[0].index);
792 imux = spec->dinput_mux;
793 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
794 AC_VERB_SET_CONNECT_SEL,
795 imux->items[idx - 1].index);
797 spec->cur_mux[adc_idx] = idx;
801 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
802 struct snd_ctl_elem_info *uinfo)
804 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
805 struct sigmatel_spec *spec = codec->spec;
806 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
809 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
810 struct snd_ctl_elem_value *ucontrol)
812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
813 struct sigmatel_spec *spec = codec->spec;
815 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
819 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
820 struct snd_ctl_elem_value *ucontrol)
822 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
823 struct sigmatel_spec *spec = codec->spec;
825 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
826 spec->mono_nid, &spec->cur_mmux);
829 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
830 struct snd_ctl_elem_info *uinfo)
832 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
833 struct sigmatel_spec *spec = codec->spec;
834 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
837 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
838 struct snd_ctl_elem_value *ucontrol)
840 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
841 struct sigmatel_spec *spec = codec->spec;
843 ucontrol->value.enumerated.item[0] = spec->cur_amux;
847 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
848 struct snd_ctl_elem_value *ucontrol)
850 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
851 struct sigmatel_spec *spec = codec->spec;
852 struct snd_kcontrol *ctl =
853 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
857 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
858 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
860 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
864 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
866 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
867 struct snd_ctl_elem_value *ucontrol)
869 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
870 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
871 struct sigmatel_spec *spec = codec->spec;
873 ucontrol->value.integer.value[0] = !!(spec->aloopback &
874 (spec->aloopback_mask << idx));
878 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
879 struct snd_ctl_elem_value *ucontrol)
881 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
882 struct sigmatel_spec *spec = codec->spec;
883 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
884 unsigned int dac_mode;
885 unsigned int val, idx_val;
887 idx_val = spec->aloopback_mask << idx;
888 if (ucontrol->value.integer.value[0])
889 val = spec->aloopback | idx_val;
891 val = spec->aloopback & ~idx_val;
892 if (spec->aloopback == val)
895 spec->aloopback = val;
897 /* Only return the bits defined by the shift value of the
898 * first two bytes of the mask
900 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
901 kcontrol->private_value & 0xFFFF, 0x0);
902 dac_mode >>= spec->aloopback_shift;
904 if (spec->aloopback & idx_val) {
905 snd_hda_power_up(codec);
908 snd_hda_power_down(codec);
909 dac_mode &= ~idx_val;
912 snd_hda_codec_write_cache(codec, codec->afg, 0,
913 kcontrol->private_value >> 16, dac_mode);
918 static struct hda_verb stac9200_core_init[] = {
919 /* set dac0mux for dac converter */
920 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
924 static struct hda_verb stac9200_eapd_init[] = {
925 /* set dac0mux for dac converter */
926 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
927 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
931 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
932 /* set master volume and direct control */
933 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
934 /* setup adcs to point to mixer */
935 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
936 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
937 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
938 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
939 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
940 /* setup import muxs */
941 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
942 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
943 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
944 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
948 static struct hda_verb dell_eq_core_init[] = {
949 /* set master volume to max value without distortion
950 * and direct control */
951 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
952 /* setup adcs to point to mixer */
953 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
954 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
955 /* setup import muxs */
956 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
957 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
958 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
959 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
963 static struct hda_verb dell_m6_core_init[] = {
964 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
965 /* setup adcs to point to mixer */
966 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
967 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
968 /* setup import muxs */
969 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
970 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
971 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
972 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
976 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
977 /* set master volume and direct control */
978 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
979 /* setup adcs to point to mixer */
980 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
981 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
982 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
983 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
984 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
985 /* setup import muxs */
986 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
987 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
988 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
989 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
993 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
994 /* set master volume and direct control */
995 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
996 /* dac3 is connected to import3 mux */
997 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
998 /* setup adcs to point to mixer */
999 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
1000 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
1001 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1002 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1003 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1004 /* setup import muxs */
1005 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
1006 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
1007 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
1008 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
1012 static struct hda_verb stac92hd83xxx_core_init[] = {
1013 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
1014 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
1015 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
1017 /* power state controls amps */
1018 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
1022 static struct hda_verb stac92hd71bxx_core_init[] = {
1023 /* set master volume and direct control */
1024 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1028 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
1029 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
1030 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1031 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1032 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1036 static struct hda_verb stac925x_core_init[] = {
1037 /* set dac0mux for dac converter */
1038 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
1039 /* mute the master volume */
1040 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1044 static struct hda_verb stac922x_core_init[] = {
1045 /* set master volume and direct control */
1046 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1050 static struct hda_verb d965_core_init[] = {
1051 /* set master volume and direct control */
1052 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1053 /* unmute node 0x1b */
1054 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1055 /* select node 0x03 as DAC */
1056 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
1060 static struct hda_verb stac927x_core_init[] = {
1061 /* set master volume and direct control */
1062 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1063 /* enable analog pc beep path */
1064 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
1068 static struct hda_verb stac9205_core_init[] = {
1069 /* set master volume and direct control */
1070 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1071 /* enable analog pc beep path */
1072 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
1076 #define STAC_MONO_MUX \
1078 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1079 .name = "Mono Mux", \
1081 .info = stac92xx_mono_mux_enum_info, \
1082 .get = stac92xx_mono_mux_enum_get, \
1083 .put = stac92xx_mono_mux_enum_put, \
1086 #define STAC_AMP_MUX \
1088 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1089 .name = "Amp Selector Capture Switch", \
1091 .info = stac92xx_amp_mux_enum_info, \
1092 .get = stac92xx_amp_mux_enum_get, \
1093 .put = stac92xx_amp_mux_enum_put, \
1096 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1098 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1101 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1102 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1103 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1104 .info = stac92xx_amp_volume_info, \
1105 .get = stac92xx_amp_volume_get, \
1106 .put = stac92xx_amp_volume_put, \
1107 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1108 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1111 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
1113 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1114 .name = "Analog Loopback", \
1116 .info = stac92xx_aloopback_info, \
1117 .get = stac92xx_aloopback_get, \
1118 .put = stac92xx_aloopback_put, \
1119 .private_value = verb_read | (verb_write << 16), \
1122 #define DC_BIAS(xname, idx, nid) \
1124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1127 .info = stac92xx_dc_bias_info, \
1128 .get = stac92xx_dc_bias_get, \
1129 .put = stac92xx_dc_bias_put, \
1130 .private_value = nid, \
1133 static struct snd_kcontrol_new stac9200_mixer[] = {
1134 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1135 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
1136 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1137 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1141 #define DELL_M6_MIXER 6
1142 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1143 /* start of config #1 */
1144 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1145 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1147 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1148 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1150 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1151 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1153 /* start of config #2 */
1154 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1155 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1157 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1158 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1163 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1164 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1168 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1169 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1173 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1174 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1178 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1179 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1180 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1182 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1183 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1185 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1186 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1188 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1189 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1191 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1192 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1196 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1197 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1198 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1200 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1201 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1203 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1204 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1206 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1207 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1209 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1210 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1215 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1216 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1217 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
1219 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1220 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
1222 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1223 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
1225 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1226 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
1229 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1230 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
1235 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1236 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1239 static struct snd_kcontrol_new stac925x_mixer[] = {
1240 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1241 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1245 static struct snd_kcontrol_new stac9205_loopback[] = {
1246 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1250 static struct snd_kcontrol_new stac927x_loopback[] = {
1251 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1255 static struct snd_kcontrol_new stac_dmux_mixer = {
1256 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1257 .name = "Digital Input Source",
1258 /* count set later */
1259 .info = stac92xx_dmux_enum_info,
1260 .get = stac92xx_dmux_enum_get,
1261 .put = stac92xx_dmux_enum_put,
1264 static struct snd_kcontrol_new stac_smux_mixer = {
1265 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1266 .name = "IEC958 Playback Source",
1267 /* count set later */
1268 .info = stac92xx_smux_enum_info,
1269 .get = stac92xx_smux_enum_get,
1270 .put = stac92xx_smux_enum_put,
1273 static const char *slave_vols[] = {
1274 "Front Playback Volume",
1275 "Surround Playback Volume",
1276 "Center Playback Volume",
1277 "LFE Playback Volume",
1278 "Side Playback Volume",
1279 "Headphone Playback Volume",
1280 "Speaker Playback Volume",
1284 static const char *slave_sws[] = {
1285 "Front Playback Switch",
1286 "Surround Playback Switch",
1287 "Center Playback Switch",
1288 "LFE Playback Switch",
1289 "Side Playback Switch",
1290 "Headphone Playback Switch",
1291 "Speaker Playback Switch",
1292 "IEC958 Playback Switch",
1296 static void stac92xx_free_kctls(struct hda_codec *codec);
1297 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1299 static int stac92xx_build_controls(struct hda_codec *codec)
1301 struct sigmatel_spec *spec = codec->spec;
1302 struct auto_pin_cfg *cfg = &spec->autocfg;
1308 err = snd_hda_add_new_ctls(codec, spec->mixer);
1313 for (i = 0; i < spec->num_mixers; i++) {
1314 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1318 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1319 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1320 stac_dmux_mixer.count = spec->num_dmuxes;
1321 err = snd_hda_ctl_add(codec,
1322 snd_ctl_new1(&stac_dmux_mixer, codec));
1326 if (spec->num_smuxes > 0) {
1327 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1328 struct hda_input_mux *smux = &spec->private_smux;
1329 /* check for mute support on SPDIF out */
1330 if (wcaps & AC_WCAP_OUT_AMP) {
1331 smux->items[smux->num_items].label = "Off";
1332 smux->items[smux->num_items].index = 0;
1334 spec->spdif_mute = 1;
1336 stac_smux_mixer.count = spec->num_smuxes;
1337 err = snd_hda_ctl_add(codec,
1338 snd_ctl_new1(&stac_smux_mixer, codec));
1343 if (spec->multiout.dig_out_nid) {
1344 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1347 err = snd_hda_create_spdif_share_sw(codec,
1351 spec->multiout.share_spdif = 1;
1353 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1354 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1359 /* if we have no master control, let's create it */
1360 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1361 unsigned int vmaster_tlv[4];
1362 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1363 HDA_OUTPUT, vmaster_tlv);
1364 /* correct volume offset */
1365 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1366 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1367 vmaster_tlv, slave_vols);
1371 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1372 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1378 if (spec->aloopback_ctl &&
1379 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1380 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1385 stac92xx_free_kctls(codec); /* no longer needed */
1387 /* create jack input elements */
1388 if (spec->hp_detect) {
1389 for (i = 0; i < cfg->hp_outs; i++) {
1390 int type = SND_JACK_HEADPHONE;
1391 nid = cfg->hp_pins[i];
1392 /* jack detection */
1393 if (cfg->hp_outs == i)
1394 type |= SND_JACK_LINEOUT;
1395 err = stac92xx_add_jack(codec, nid, type);
1400 for (i = 0; i < cfg->line_outs; i++) {
1401 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1406 for (i = 0; i < AUTO_PIN_LAST; i++) {
1407 nid = cfg->input_pins[i];
1409 err = stac92xx_add_jack(codec, nid,
1410 SND_JACK_MICROPHONE);
1419 static unsigned int ref9200_pin_configs[8] = {
1420 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1421 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1424 static unsigned int gateway9200_m4_pin_configs[8] = {
1425 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1426 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1428 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1429 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1430 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1434 STAC 9200 pin configs for
1439 static unsigned int dell9200_d21_pin_configs[8] = {
1440 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1441 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1445 STAC 9200 pin configs for
1449 static unsigned int dell9200_d22_pin_configs[8] = {
1450 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1451 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1455 STAC 9200 pin configs for
1456 102801C4 (Dell Dimension E310)
1463 static unsigned int dell9200_d23_pin_configs[8] = {
1464 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1465 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1470 STAC 9200-32 pin configs for
1471 102801B5 (Dell Inspiron 630m)
1472 102801D8 (Dell Inspiron 640m)
1474 static unsigned int dell9200_m21_pin_configs[8] = {
1475 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1476 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1480 STAC 9200-32 pin configs for
1481 102801C2 (Dell Latitude D620)
1483 102801CC (Dell Latitude D820)
1487 static unsigned int dell9200_m22_pin_configs[8] = {
1488 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1489 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1493 STAC 9200-32 pin configs for
1494 102801CE (Dell XPS M1710)
1495 102801CF (Dell Precision M90)
1497 static unsigned int dell9200_m23_pin_configs[8] = {
1498 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1499 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1503 STAC 9200-32 pin configs for
1506 102801CB (Dell Latitude 120L)
1509 static unsigned int dell9200_m24_pin_configs[8] = {
1510 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1511 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1515 STAC 9200-32 pin configs for
1516 102801BD (Dell Inspiron E1505n)
1520 static unsigned int dell9200_m25_pin_configs[8] = {
1521 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1522 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1526 STAC 9200-32 pin configs for
1527 102801F5 (Dell Inspiron 1501)
1530 static unsigned int dell9200_m26_pin_configs[8] = {
1531 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1532 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1537 102801CD (Dell Inspiron E1705/9400)
1539 static unsigned int dell9200_m27_pin_configs[8] = {
1540 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1541 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1544 static unsigned int oqo9200_pin_configs[8] = {
1545 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1546 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1550 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1551 [STAC_REF] = ref9200_pin_configs,
1552 [STAC_9200_OQO] = oqo9200_pin_configs,
1553 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1554 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1555 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1556 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1557 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1558 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1559 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1560 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1561 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1562 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1563 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1564 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1565 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1568 static const char *stac9200_models[STAC_9200_MODELS] = {
1569 [STAC_AUTO] = "auto",
1571 [STAC_9200_OQO] = "oqo",
1572 [STAC_9200_DELL_D21] = "dell-d21",
1573 [STAC_9200_DELL_D22] = "dell-d22",
1574 [STAC_9200_DELL_D23] = "dell-d23",
1575 [STAC_9200_DELL_M21] = "dell-m21",
1576 [STAC_9200_DELL_M22] = "dell-m22",
1577 [STAC_9200_DELL_M23] = "dell-m23",
1578 [STAC_9200_DELL_M24] = "dell-m24",
1579 [STAC_9200_DELL_M25] = "dell-m25",
1580 [STAC_9200_DELL_M26] = "dell-m26",
1581 [STAC_9200_DELL_M27] = "dell-m27",
1582 [STAC_9200_M4] = "gateway-m4",
1583 [STAC_9200_M4_2] = "gateway-m4-2",
1584 [STAC_9200_PANASONIC] = "panasonic",
1587 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1588 /* SigmaTel reference board */
1589 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1590 "DFI LanParty", STAC_REF),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1592 "DFI LanParty", STAC_REF),
1593 /* Dell laptops have BIOS problem */
1594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1595 "unknown Dell", STAC_9200_DELL_D21),
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1597 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1599 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1601 "unknown Dell", STAC_9200_DELL_D22),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1603 "unknown Dell", STAC_9200_DELL_D22),
1604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1605 "Dell Latitude D620", STAC_9200_DELL_M22),
1606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1607 "unknown Dell", STAC_9200_DELL_D23),
1608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1609 "unknown Dell", STAC_9200_DELL_D23),
1610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1611 "unknown Dell", STAC_9200_DELL_M22),
1612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1613 "unknown Dell", STAC_9200_DELL_M24),
1614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1615 "unknown Dell", STAC_9200_DELL_M24),
1616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1617 "Dell Latitude 120L", STAC_9200_DELL_M24),
1618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1619 "Dell Latitude D820", STAC_9200_DELL_M22),
1620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1621 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1623 "Dell XPS M1710", STAC_9200_DELL_M23),
1624 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1625 "Dell Precision M90", STAC_9200_DELL_M23),
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1627 "unknown Dell", STAC_9200_DELL_M22),
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1629 "unknown Dell", STAC_9200_DELL_M22),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1631 "unknown Dell", STAC_9200_DELL_M22),
1632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1633 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1634 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1635 "unknown Dell", STAC_9200_DELL_D23),
1636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1637 "unknown Dell", STAC_9200_DELL_D23),
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1639 "unknown Dell", STAC_9200_DELL_D21),
1640 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1641 "unknown Dell", STAC_9200_DELL_D23),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1643 "unknown Dell", STAC_9200_DELL_D21),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1645 "unknown Dell", STAC_9200_DELL_M25),
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1647 "unknown Dell", STAC_9200_DELL_M25),
1648 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1649 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1650 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1651 "unknown Dell", STAC_9200_DELL_M26),
1653 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1654 /* Gateway machines needs EAPD to be set on resume */
1655 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1656 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1657 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1659 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1663 static unsigned int ref925x_pin_configs[8] = {
1664 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1665 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1668 static unsigned int stac925xM1_pin_configs[8] = {
1669 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1670 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1673 static unsigned int stac925xM1_2_pin_configs[8] = {
1674 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1675 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1678 static unsigned int stac925xM2_pin_configs[8] = {
1679 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1680 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1683 static unsigned int stac925xM2_2_pin_configs[8] = {
1684 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1685 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1688 static unsigned int stac925xM3_pin_configs[8] = {
1689 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1690 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1693 static unsigned int stac925xM5_pin_configs[8] = {
1694 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1695 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1698 static unsigned int stac925xM6_pin_configs[8] = {
1699 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1700 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1703 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1704 [STAC_REF] = ref925x_pin_configs,
1705 [STAC_M1] = stac925xM1_pin_configs,
1706 [STAC_M1_2] = stac925xM1_2_pin_configs,
1707 [STAC_M2] = stac925xM2_pin_configs,
1708 [STAC_M2_2] = stac925xM2_2_pin_configs,
1709 [STAC_M3] = stac925xM3_pin_configs,
1710 [STAC_M5] = stac925xM5_pin_configs,
1711 [STAC_M6] = stac925xM6_pin_configs,
1714 static const char *stac925x_models[STAC_925x_MODELS] = {
1715 [STAC_925x_AUTO] = "auto",
1718 [STAC_M1_2] = "m1-2",
1720 [STAC_M2_2] = "m2-2",
1726 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1727 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1728 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1729 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1730 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1731 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1732 /* Not sure about the brand name for those */
1733 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1734 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1735 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1736 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1740 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1741 /* SigmaTel reference board */
1742 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1743 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1744 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1746 /* Default table for unknown ID */
1747 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1752 static unsigned int ref92hd73xx_pin_configs[13] = {
1753 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1754 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1755 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1759 static unsigned int dell_m6_pin_configs[13] = {
1760 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1761 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1762 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1766 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1767 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1768 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1769 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1770 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1771 [STAC_DELL_EQ] = dell_m6_pin_configs,
1774 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1775 [STAC_92HD73XX_AUTO] = "auto",
1776 [STAC_92HD73XX_NO_JD] = "no-jd",
1777 [STAC_92HD73XX_REF] = "ref",
1778 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1779 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1780 [STAC_DELL_M6_BOTH] = "dell-m6",
1781 [STAC_DELL_EQ] = "dell-eq",
1784 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1785 /* SigmaTel reference board */
1786 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1787 "DFI LanParty", STAC_92HD73XX_REF),
1788 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1789 "DFI LanParty", STAC_92HD73XX_REF),
1790 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1791 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1792 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1793 "unknown Dell", STAC_DELL_M6_DMIC),
1794 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1795 "unknown Dell", STAC_DELL_M6_BOTH),
1796 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1797 "unknown Dell", STAC_DELL_M6_BOTH),
1798 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1799 "unknown Dell", STAC_DELL_M6_AMIC),
1800 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1801 "unknown Dell", STAC_DELL_M6_AMIC),
1802 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1803 "unknown Dell", STAC_DELL_M6_DMIC),
1804 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1805 "unknown Dell", STAC_DELL_M6_DMIC),
1806 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1807 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1808 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1809 "Dell Studio 17", STAC_DELL_M6_DMIC),
1810 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1811 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1815 static unsigned int ref92hd83xxx_pin_configs[10] = {
1816 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1817 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1818 0x01451160, 0x98560170,
1821 static unsigned int dell_s14_pin_configs[10] = {
1822 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1823 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1824 0x40f000f0, 0x40f000f0,
1827 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1828 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1829 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1830 [STAC_DELL_S14] = dell_s14_pin_configs,
1833 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1834 [STAC_92HD83XXX_AUTO] = "auto",
1835 [STAC_92HD83XXX_REF] = "ref",
1836 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1837 [STAC_DELL_S14] = "dell-s14",
1840 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1841 /* SigmaTel reference board */
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1843 "DFI LanParty", STAC_92HD83XXX_REF),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1845 "DFI LanParty", STAC_92HD83XXX_REF),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1847 "unknown Dell", STAC_DELL_S14),
1851 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1852 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1853 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1854 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1858 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1859 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1860 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1861 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1865 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1866 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1867 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1868 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1872 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1873 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1874 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1875 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1879 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1880 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1881 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1882 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1883 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1884 [STAC_HP_M4] = NULL,
1885 [STAC_HP_DV5] = NULL,
1886 [STAC_HP_HDX] = NULL,
1887 [STAC_HP_DV4_1222NR] = NULL,
1890 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1891 [STAC_92HD71BXX_AUTO] = "auto",
1892 [STAC_92HD71BXX_REF] = "ref",
1893 [STAC_DELL_M4_1] = "dell-m4-1",
1894 [STAC_DELL_M4_2] = "dell-m4-2",
1895 [STAC_DELL_M4_3] = "dell-m4-3",
1896 [STAC_HP_M4] = "hp-m4",
1897 [STAC_HP_DV5] = "hp-dv5",
1898 [STAC_HP_HDX] = "hp-hdx",
1899 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1902 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1903 /* SigmaTel reference board */
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1905 "DFI LanParty", STAC_92HD71BXX_REF),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1907 "DFI LanParty", STAC_92HD71BXX_REF),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1909 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1910 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1912 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1913 "HP dv4-7", STAC_HP_DV5),
1914 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1915 "HP dv4-7", STAC_HP_DV5),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1917 "HP HDX", STAC_HP_HDX), /* HDX18 */
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1919 "HP mini 1000", STAC_HP_M4),
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1921 "HP HDX", STAC_HP_HDX), /* HDX16 */
1922 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1925 "unknown Dell", STAC_DELL_M4_1),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1927 "unknown Dell", STAC_DELL_M4_1),
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1929 "unknown Dell", STAC_DELL_M4_1),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1931 "unknown Dell", STAC_DELL_M4_1),
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1933 "unknown Dell", STAC_DELL_M4_1),
1934 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1935 "unknown Dell", STAC_DELL_M4_1),
1936 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1937 "unknown Dell", STAC_DELL_M4_1),
1938 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1939 "unknown Dell", STAC_DELL_M4_2),
1940 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1941 "unknown Dell", STAC_DELL_M4_2),
1942 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1943 "unknown Dell", STAC_DELL_M4_2),
1944 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1945 "unknown Dell", STAC_DELL_M4_2),
1946 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1947 "unknown Dell", STAC_DELL_M4_3),
1951 static unsigned int ref922x_pin_configs[10] = {
1952 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1953 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1954 0x40000100, 0x40000100,
1958 STAC 922X pin configs for
1965 static unsigned int dell_922x_d81_pin_configs[10] = {
1966 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1967 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1968 0x01813122, 0x400001f2,
1972 STAC 922X pin configs for
1976 static unsigned int dell_922x_d82_pin_configs[10] = {
1977 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1978 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1979 0x01813122, 0x400001f1,
1983 STAC 922X pin configs for
1986 static unsigned int dell_922x_m81_pin_configs[10] = {
1987 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1988 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1989 0x40C003f1, 0x405003f0,
1993 STAC 9221 A1 pin configs for
1994 102801D7 (Dell XPS M1210)
1996 static unsigned int dell_922x_m82_pin_configs[10] = {
1997 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1998 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1999 0x508003f3, 0x405003f4,
2002 static unsigned int d945gtp3_pin_configs[10] = {
2003 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
2004 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2005 0x02a19120, 0x40000100,
2008 static unsigned int d945gtp5_pin_configs[10] = {
2009 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
2010 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
2011 0x02a19320, 0x40000100,
2014 static unsigned int intel_mac_v1_pin_configs[10] = {
2015 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
2016 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
2017 0x400000fc, 0x400000fb,
2020 static unsigned int intel_mac_v2_pin_configs[10] = {
2021 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2022 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
2023 0x400000fc, 0x400000fb,
2026 static unsigned int intel_mac_v3_pin_configs[10] = {
2027 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2028 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
2029 0x400000fc, 0x400000fb,
2032 static unsigned int intel_mac_v4_pin_configs[10] = {
2033 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2034 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2035 0x400000fc, 0x400000fb,
2038 static unsigned int intel_mac_v5_pin_configs[10] = {
2039 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2040 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2041 0x400000fc, 0x400000fb,
2044 static unsigned int ecs202_pin_configs[10] = {
2045 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
2046 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
2047 0x9037012e, 0x40e000f2,
2050 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
2051 [STAC_D945_REF] = ref922x_pin_configs,
2052 [STAC_D945GTP3] = d945gtp3_pin_configs,
2053 [STAC_D945GTP5] = d945gtp5_pin_configs,
2054 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
2055 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
2056 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
2057 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
2058 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
2059 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
2060 /* for backward compatibility */
2061 [STAC_MACMINI] = intel_mac_v3_pin_configs,
2062 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
2063 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
2064 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
2065 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
2066 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
2067 [STAC_ECS_202] = ecs202_pin_configs,
2068 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
2069 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
2070 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
2071 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
2074 static const char *stac922x_models[STAC_922X_MODELS] = {
2075 [STAC_922X_AUTO] = "auto",
2076 [STAC_D945_REF] = "ref",
2077 [STAC_D945GTP5] = "5stack",
2078 [STAC_D945GTP3] = "3stack",
2079 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
2080 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
2081 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
2082 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
2083 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
2084 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
2085 /* for backward compatibility */
2086 [STAC_MACMINI] = "macmini",
2087 [STAC_MACBOOK] = "macbook",
2088 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2089 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
2090 [STAC_IMAC_INTEL] = "imac-intel",
2091 [STAC_IMAC_INTEL_20] = "imac-intel-20",
2092 [STAC_ECS_202] = "ecs202",
2093 [STAC_922X_DELL_D81] = "dell-d81",
2094 [STAC_922X_DELL_D82] = "dell-d82",
2095 [STAC_922X_DELL_M81] = "dell-m81",
2096 [STAC_922X_DELL_M82] = "dell-m82",
2099 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2100 /* SigmaTel reference board */
2101 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2102 "DFI LanParty", STAC_D945_REF),
2103 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2104 "DFI LanParty", STAC_D945_REF),
2105 /* Intel 945G based systems */
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2107 "Intel D945G", STAC_D945GTP3),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2109 "Intel D945G", STAC_D945GTP3),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2111 "Intel D945G", STAC_D945GTP3),
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2113 "Intel D945G", STAC_D945GTP3),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2115 "Intel D945G", STAC_D945GTP3),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2117 "Intel D945G", STAC_D945GTP3),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2119 "Intel D945G", STAC_D945GTP3),
2120 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2121 "Intel D945G", STAC_D945GTP3),
2122 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2123 "Intel D945G", STAC_D945GTP3),
2124 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2125 "Intel D945G", STAC_D945GTP3),
2126 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2127 "Intel D945G", STAC_D945GTP3),
2128 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2129 "Intel D945G", STAC_D945GTP3),
2130 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2131 "Intel D945G", STAC_D945GTP3),
2132 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2133 "Intel D945G", STAC_D945GTP3),
2134 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2135 "Intel D945G", STAC_D945GTP3),
2136 /* Intel D945G 5-stack systems */
2137 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2138 "Intel D945G", STAC_D945GTP5),
2139 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2140 "Intel D945G", STAC_D945GTP5),
2141 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2142 "Intel D945G", STAC_D945GTP5),
2143 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2144 "Intel D945G", STAC_D945GTP5),
2145 /* Intel 945P based systems */
2146 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2147 "Intel D945P", STAC_D945GTP3),
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2149 "Intel D945P", STAC_D945GTP3),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2151 "Intel D945P", STAC_D945GTP3),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2153 "Intel D945P", STAC_D945GTP3),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2155 "Intel D945P", STAC_D945GTP3),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2157 "Intel D945P", STAC_D945GTP5),
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2160 "Intel D945", STAC_D945_REF),
2162 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2163 SND_PCI_QUIRK(0x8384, 0x7680,
2164 "Mac", STAC_INTEL_MAC_AUTO),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2167 "unknown Dell", STAC_922X_DELL_D81),
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2169 "unknown Dell", STAC_922X_DELL_D81),
2170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2171 "unknown Dell", STAC_922X_DELL_D81),
2172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2173 "unknown Dell", STAC_922X_DELL_D82),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2175 "unknown Dell", STAC_922X_DELL_M81),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2177 "unknown Dell", STAC_922X_DELL_D82),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2179 "unknown Dell", STAC_922X_DELL_D81),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2181 "unknown Dell", STAC_922X_DELL_D81),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2183 "Dell XPS M1210", STAC_922X_DELL_M82),
2184 /* ECS/PC Chips boards */
2185 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2186 "ECS/PC chips", STAC_ECS_202),
2190 static unsigned int ref927x_pin_configs[14] = {
2191 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2192 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2193 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2194 0x01c42190, 0x40000100,
2197 static unsigned int d965_3st_pin_configs[14] = {
2198 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2199 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2200 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2201 0x40000100, 0x40000100
2204 static unsigned int d965_5st_pin_configs[14] = {
2205 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2206 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2207 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2208 0x40000100, 0x40000100
2211 static unsigned int d965_5st_no_fp_pin_configs[14] = {
2212 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2213 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2214 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2215 0x40000100, 0x40000100
2218 static unsigned int dell_3st_pin_configs[14] = {
2219 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2220 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2221 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2222 0x40c003fc, 0x40000100
2225 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2226 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2227 [STAC_D965_REF] = ref927x_pin_configs,
2228 [STAC_D965_3ST] = d965_3st_pin_configs,
2229 [STAC_D965_5ST] = d965_5st_pin_configs,
2230 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2231 [STAC_DELL_3ST] = dell_3st_pin_configs,
2232 [STAC_DELL_BIOS] = NULL,
2235 static const char *stac927x_models[STAC_927X_MODELS] = {
2236 [STAC_927X_AUTO] = "auto",
2237 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2238 [STAC_D965_REF] = "ref",
2239 [STAC_D965_3ST] = "3stack",
2240 [STAC_D965_5ST] = "5stack",
2241 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2242 [STAC_DELL_3ST] = "dell-3stack",
2243 [STAC_DELL_BIOS] = "dell-bios",
2246 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2247 /* SigmaTel reference board */
2248 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2249 "DFI LanParty", STAC_D965_REF),
2250 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2251 "DFI LanParty", STAC_D965_REF),
2252 /* Intel 946 based systems */
2253 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2254 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2255 /* 965 based 3 stack systems */
2256 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2257 "Intel D965", STAC_D965_3ST),
2258 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2259 "Intel D965", STAC_D965_3ST),
2260 /* Dell 3 stack systems */
2261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2262 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2263 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2264 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2265 /* Dell 3 stack systems with verb table in BIOS */
2266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2274 /* 965 based 5 stack systems */
2275 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2276 "Intel D965", STAC_D965_5ST),
2277 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2278 "Intel D965", STAC_D965_5ST),
2282 static unsigned int ref9205_pin_configs[12] = {
2283 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2284 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2285 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2289 STAC 9205 pin configs for
2296 10280228 (Dell Vostro 1500)
2298 static unsigned int dell_9205_m42_pin_configs[12] = {
2299 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2300 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2301 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2305 STAC 9205 pin configs for
2309 102801FF (Dell Precision M4300)
2314 static unsigned int dell_9205_m43_pin_configs[12] = {
2315 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2316 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2317 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2320 static unsigned int dell_9205_m44_pin_configs[12] = {
2321 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2322 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2323 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2326 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2327 [STAC_9205_REF] = ref9205_pin_configs,
2328 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2329 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2330 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2331 [STAC_9205_EAPD] = NULL,
2334 static const char *stac9205_models[STAC_9205_MODELS] = {
2335 [STAC_9205_AUTO] = "auto",
2336 [STAC_9205_REF] = "ref",
2337 [STAC_9205_DELL_M42] = "dell-m42",
2338 [STAC_9205_DELL_M43] = "dell-m43",
2339 [STAC_9205_DELL_M44] = "dell-m44",
2340 [STAC_9205_EAPD] = "eapd",
2343 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2344 /* SigmaTel reference board */
2345 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2346 "DFI LanParty", STAC_9205_REF),
2347 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2348 "SigmaTel", STAC_9205_REF),
2349 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2350 "DFI LanParty", STAC_9205_REF),
2352 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2353 "unknown Dell", STAC_9205_DELL_M42),
2354 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2355 "unknown Dell", STAC_9205_DELL_M42),
2356 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2357 "Dell Precision", STAC_9205_DELL_M43),
2358 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2359 "Dell Precision", STAC_9205_DELL_M43),
2360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2361 "Dell Precision", STAC_9205_DELL_M43),
2362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2363 "unknown Dell", STAC_9205_DELL_M42),
2364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2365 "unknown Dell", STAC_9205_DELL_M42),
2366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2367 "Dell Precision", STAC_9205_DELL_M43),
2368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2369 "Dell Precision M4300", STAC_9205_DELL_M43),
2370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2371 "unknown Dell", STAC_9205_DELL_M42),
2372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2373 "Dell Precision", STAC_9205_DELL_M43),
2374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2375 "Dell Precision", STAC_9205_DELL_M43),
2376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2377 "Dell Precision", STAC_9205_DELL_M43),
2378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2379 "Dell Inspiron", STAC_9205_DELL_M44),
2380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2381 "Dell Vostro 1500", STAC_9205_DELL_M42),
2383 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2384 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2388 static void stac92xx_set_config_regs(struct hda_codec *codec,
2389 unsigned int *pincfgs)
2392 struct sigmatel_spec *spec = codec->spec;
2397 for (i = 0; i < spec->num_pins; i++)
2398 if (spec->pin_nids[i] && pincfgs[i])
2399 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2404 * Analog playback callbacks
2406 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2407 struct hda_codec *codec,
2408 struct snd_pcm_substream *substream)
2410 struct sigmatel_spec *spec = codec->spec;
2411 if (spec->stream_delay)
2412 msleep(spec->stream_delay);
2413 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2417 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2418 struct hda_codec *codec,
2419 unsigned int stream_tag,
2420 unsigned int format,
2421 struct snd_pcm_substream *substream)
2423 struct sigmatel_spec *spec = codec->spec;
2424 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2427 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2428 struct hda_codec *codec,
2429 struct snd_pcm_substream *substream)
2431 struct sigmatel_spec *spec = codec->spec;
2432 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2436 * Digital playback callbacks
2438 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2439 struct hda_codec *codec,
2440 struct snd_pcm_substream *substream)
2442 struct sigmatel_spec *spec = codec->spec;
2443 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2446 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2447 struct hda_codec *codec,
2448 struct snd_pcm_substream *substream)
2450 struct sigmatel_spec *spec = codec->spec;
2451 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2454 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2455 struct hda_codec *codec,
2456 unsigned int stream_tag,
2457 unsigned int format,
2458 struct snd_pcm_substream *substream)
2460 struct sigmatel_spec *spec = codec->spec;
2461 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2462 stream_tag, format, substream);
2465 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2466 struct hda_codec *codec,
2467 struct snd_pcm_substream *substream)
2469 struct sigmatel_spec *spec = codec->spec;
2470 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2475 * Analog capture callbacks
2477 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2478 struct hda_codec *codec,
2479 unsigned int stream_tag,
2480 unsigned int format,
2481 struct snd_pcm_substream *substream)
2483 struct sigmatel_spec *spec = codec->spec;
2484 hda_nid_t nid = spec->adc_nids[substream->number];
2486 if (spec->powerdown_adcs) {
2488 snd_hda_codec_write(codec, nid, 0,
2489 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2491 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2495 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2496 struct hda_codec *codec,
2497 struct snd_pcm_substream *substream)
2499 struct sigmatel_spec *spec = codec->spec;
2500 hda_nid_t nid = spec->adc_nids[substream->number];
2502 snd_hda_codec_cleanup_stream(codec, nid);
2503 if (spec->powerdown_adcs)
2504 snd_hda_codec_write(codec, nid, 0,
2505 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2509 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2513 /* NID is set in stac92xx_build_pcms */
2515 .open = stac92xx_dig_playback_pcm_open,
2516 .close = stac92xx_dig_playback_pcm_close,
2517 .prepare = stac92xx_dig_playback_pcm_prepare,
2518 .cleanup = stac92xx_dig_playback_pcm_cleanup
2522 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2526 /* NID is set in stac92xx_build_pcms */
2529 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2533 .nid = 0x02, /* NID to query formats and rates */
2535 .open = stac92xx_playback_pcm_open,
2536 .prepare = stac92xx_playback_pcm_prepare,
2537 .cleanup = stac92xx_playback_pcm_cleanup
2541 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2545 .nid = 0x06, /* NID to query formats and rates */
2547 .open = stac92xx_playback_pcm_open,
2548 .prepare = stac92xx_playback_pcm_prepare,
2549 .cleanup = stac92xx_playback_pcm_cleanup
2553 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2556 /* NID + .substreams is set in stac92xx_build_pcms */
2558 .prepare = stac92xx_capture_pcm_prepare,
2559 .cleanup = stac92xx_capture_pcm_cleanup
2563 static int stac92xx_build_pcms(struct hda_codec *codec)
2565 struct sigmatel_spec *spec = codec->spec;
2566 struct hda_pcm *info = spec->pcm_rec;
2568 codec->num_pcms = 1;
2569 codec->pcm_info = info;
2571 info->name = "STAC92xx Analog";
2572 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2573 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2574 spec->multiout.dac_nids[0];
2575 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2576 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2577 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2579 if (spec->alt_switch) {
2582 info->name = "STAC92xx Analog Alt";
2583 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2586 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2589 info->name = "STAC92xx Digital";
2590 info->pcm_type = spec->autocfg.dig_out_type[0];
2591 if (spec->multiout.dig_out_nid) {
2592 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2593 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2595 if (spec->dig_in_nid) {
2596 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2597 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2604 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2607 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2608 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2609 if (pincap & AC_PINCAP_VREF_100)
2610 return AC_PINCTL_VREF_100;
2611 if (pincap & AC_PINCAP_VREF_80)
2612 return AC_PINCTL_VREF_80;
2613 if (pincap & AC_PINCAP_VREF_50)
2614 return AC_PINCTL_VREF_50;
2615 if (pincap & AC_PINCAP_VREF_GRD)
2616 return AC_PINCTL_VREF_GRD;
2620 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2623 snd_hda_codec_write_cache(codec, nid, 0,
2624 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2627 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2629 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2630 struct snd_ctl_elem_value *ucontrol)
2632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2633 struct sigmatel_spec *spec = codec->spec;
2635 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2639 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2641 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2642 struct snd_ctl_elem_value *ucontrol)
2644 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2645 struct sigmatel_spec *spec = codec->spec;
2646 int nid = kcontrol->private_value;
2648 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2650 /* check to be sure that the ports are upto date with
2653 stac_issue_unsol_event(codec, nid);
2658 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2659 struct snd_ctl_elem_info *uinfo)
2662 static char *texts[] = {
2663 "Mic In", "Line In", "Line Out"
2666 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2667 struct sigmatel_spec *spec = codec->spec;
2668 hda_nid_t nid = kcontrol->private_value;
2670 if (nid == spec->mic_switch || nid == spec->line_switch)
2675 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2676 uinfo->value.enumerated.items = i;
2678 if (uinfo->value.enumerated.item >= i)
2679 uinfo->value.enumerated.item = i-1;
2680 strcpy(uinfo->value.enumerated.name,
2681 texts[uinfo->value.enumerated.item]);
2686 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2687 struct snd_ctl_elem_value *ucontrol)
2689 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2690 hda_nid_t nid = kcontrol->private_value;
2691 unsigned int vref = stac92xx_vref_get(codec, nid);
2693 if (vref == stac92xx_get_default_vref(codec, nid))
2694 ucontrol->value.enumerated.item[0] = 0;
2695 else if (vref == AC_PINCTL_VREF_GRD)
2696 ucontrol->value.enumerated.item[0] = 1;
2697 else if (vref == AC_PINCTL_VREF_HIZ)
2698 ucontrol->value.enumerated.item[0] = 2;
2703 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2704 struct snd_ctl_elem_value *ucontrol)
2706 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2707 unsigned int new_vref = 0;
2709 hda_nid_t nid = kcontrol->private_value;
2711 if (ucontrol->value.enumerated.item[0] == 0)
2712 new_vref = stac92xx_get_default_vref(codec, nid);
2713 else if (ucontrol->value.enumerated.item[0] == 1)
2714 new_vref = AC_PINCTL_VREF_GRD;
2715 else if (ucontrol->value.enumerated.item[0] == 2)
2716 new_vref = AC_PINCTL_VREF_HIZ;
2720 if (new_vref != stac92xx_vref_get(codec, nid)) {
2721 error = stac92xx_vref_set(codec, nid, new_vref);
2728 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2729 struct snd_ctl_elem_info *uinfo)
2731 static char *texts[2];
2732 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2733 struct sigmatel_spec *spec = codec->spec;
2735 if (kcontrol->private_value == spec->line_switch)
2736 texts[0] = "Line In";
2738 texts[0] = "Mic In";
2739 texts[1] = "Line Out";
2740 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2741 uinfo->value.enumerated.items = 2;
2744 if (uinfo->value.enumerated.item >= 2)
2745 uinfo->value.enumerated.item = 1;
2746 strcpy(uinfo->value.enumerated.name,
2747 texts[uinfo->value.enumerated.item]);
2752 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2755 struct sigmatel_spec *spec = codec->spec;
2756 hda_nid_t nid = kcontrol->private_value;
2757 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2759 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2763 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2765 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2766 struct sigmatel_spec *spec = codec->spec;
2767 hda_nid_t nid = kcontrol->private_value;
2768 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2769 unsigned short val = !!ucontrol->value.enumerated.item[0];
2771 spec->io_switch[io_idx] = val;
2774 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2776 unsigned int pinctl = AC_PINCTL_IN_EN;
2777 if (io_idx) /* set VREF for mic */
2778 pinctl |= stac92xx_get_default_vref(codec, nid);
2779 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2782 /* check the auto-mute again: we need to mute/unmute the speaker
2783 * appropriately according to the pin direction
2785 if (spec->hp_detect)
2786 stac_issue_unsol_event(codec, nid);
2791 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2793 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2794 struct snd_ctl_elem_value *ucontrol)
2796 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2797 struct sigmatel_spec *spec = codec->spec;
2799 ucontrol->value.integer.value[0] = spec->clfe_swap;
2803 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2804 struct snd_ctl_elem_value *ucontrol)
2806 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2807 struct sigmatel_spec *spec = codec->spec;
2808 hda_nid_t nid = kcontrol->private_value & 0xff;
2809 unsigned int val = !!ucontrol->value.integer.value[0];
2811 if (spec->clfe_swap == val)
2814 spec->clfe_swap = val;
2816 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2817 spec->clfe_swap ? 0x4 : 0x0);
2822 #define STAC_CODEC_HP_SWITCH(xname) \
2823 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2826 .info = stac92xx_hp_switch_info, \
2827 .get = stac92xx_hp_switch_get, \
2828 .put = stac92xx_hp_switch_put, \
2831 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2832 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2835 .info = stac92xx_io_switch_info, \
2836 .get = stac92xx_io_switch_get, \
2837 .put = stac92xx_io_switch_put, \
2838 .private_value = xpval, \
2841 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2842 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2845 .info = stac92xx_clfe_switch_info, \
2846 .get = stac92xx_clfe_switch_get, \
2847 .put = stac92xx_clfe_switch_put, \
2848 .private_value = xpval, \
2852 STAC_CTL_WIDGET_VOL,
2853 STAC_CTL_WIDGET_MUTE,
2854 STAC_CTL_WIDGET_MONO_MUX,
2855 STAC_CTL_WIDGET_AMP_MUX,
2856 STAC_CTL_WIDGET_AMP_VOL,
2857 STAC_CTL_WIDGET_HP_SWITCH,
2858 STAC_CTL_WIDGET_IO_SWITCH,
2859 STAC_CTL_WIDGET_CLFE_SWITCH,
2860 STAC_CTL_WIDGET_DC_BIAS
2863 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2864 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2865 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2868 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2869 STAC_CODEC_HP_SWITCH(NULL),
2870 STAC_CODEC_IO_SWITCH(NULL, 0),
2871 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2872 DC_BIAS(NULL, 0, 0),
2875 /* add dynamic controls */
2876 static struct snd_kcontrol_new *
2877 stac_control_new(struct sigmatel_spec *spec,
2878 struct snd_kcontrol_new *ktemp,
2881 struct snd_kcontrol_new *knew;
2883 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2884 knew = snd_array_new(&spec->kctls);
2888 knew->name = kstrdup(name, GFP_KERNEL);
2891 memset(knew, 0, sizeof(*knew));
2892 spec->kctls.alloced--;
2898 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2899 struct snd_kcontrol_new *ktemp,
2900 int idx, const char *name,
2903 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2907 knew->private_value = val;
2911 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2912 int type, int idx, const char *name,
2915 return stac92xx_add_control_temp(spec,
2916 &stac92xx_control_templates[type],
2921 /* add dynamic controls */
2922 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2923 const char *name, unsigned long val)
2925 return stac92xx_add_control_idx(spec, type, 0, name, val);
2928 static struct snd_kcontrol_new stac_input_src_temp = {
2929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2930 .name = "Input Source",
2931 .info = stac92xx_mux_enum_info,
2932 .get = stac92xx_mux_enum_get,
2933 .put = stac92xx_mux_enum_put,
2936 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2937 hda_nid_t nid, int idx)
2939 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2941 struct sigmatel_spec *spec = codec->spec;
2944 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2945 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2946 && nid == spec->line_switch)
2947 control = STAC_CTL_WIDGET_IO_SWITCH;
2948 else if (snd_hda_query_pin_caps(codec, nid)
2949 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2950 control = STAC_CTL_WIDGET_DC_BIAS;
2951 else if (nid == spec->mic_switch)
2952 control = STAC_CTL_WIDGET_IO_SWITCH;
2956 strcpy(name, auto_pin_cfg_labels[idx]);
2957 return stac92xx_add_control(codec->spec, control,
2958 strcat(name, " Jack Mode"), nid);
2964 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2966 struct snd_kcontrol_new *knew;
2967 struct hda_input_mux *imux = &spec->private_imux;
2970 return 0; /* no need for input source */
2971 if (!spec->num_adcs || imux->num_items <= 1)
2972 return 0; /* no need for input source control */
2973 knew = stac_control_new(spec, &stac_input_src_temp,
2974 stac_input_src_temp.name);
2977 knew->count = spec->num_adcs;
2981 /* check whether the line-input can be used as line-out */
2982 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2984 struct sigmatel_spec *spec = codec->spec;
2985 struct auto_pin_cfg *cfg = &spec->autocfg;
2987 unsigned int pincap;
2989 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2991 nid = cfg->input_pins[AUTO_PIN_LINE];
2992 pincap = snd_hda_query_pin_caps(codec, nid);
2993 if (pincap & AC_PINCAP_OUT)
2998 /* check whether the mic-input can be used as line-out */
2999 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
3001 struct sigmatel_spec *spec = codec->spec;
3002 struct auto_pin_cfg *cfg = &spec->autocfg;
3003 unsigned int def_conf, pincap;
3004 unsigned int mic_pin;
3006 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
3008 mic_pin = AUTO_PIN_MIC;
3010 hda_nid_t nid = cfg->input_pins[mic_pin];
3011 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3012 /* some laptops have an internal analog microphone
3013 * which can't be used as a output */
3014 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
3015 pincap = snd_hda_query_pin_caps(codec, nid);
3016 if (pincap & AC_PINCAP_OUT)
3019 if (mic_pin == AUTO_PIN_MIC)
3020 mic_pin = AUTO_PIN_FRONT_MIC;
3027 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3031 for (i = 0; i < spec->multiout.num_dacs; i++) {
3032 if (spec->multiout.dac_nids[i] == nid)
3039 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3042 if (is_in_dac_nids(spec, nid))
3044 for (i = 0; i < spec->autocfg.hp_outs; i++)
3045 if (spec->hp_dacs[i] == nid)
3047 for (i = 0; i < spec->autocfg.speaker_outs; i++)
3048 if (spec->speaker_dacs[i] == nid)
3053 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
3055 struct sigmatel_spec *spec = codec->spec;
3057 hda_nid_t conn[HDA_MAX_CONNECTIONS];
3058 unsigned int wcaps, wtype;
3060 conn_len = snd_hda_get_connections(codec, nid, conn,
3061 HDA_MAX_CONNECTIONS);
3062 for (j = 0; j < conn_len; j++) {
3063 wcaps = get_wcaps(codec, conn[j]);
3064 wtype = get_wcaps_type(wcaps);
3065 /* we check only analog outputs */
3066 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
3068 /* if this route has a free DAC, assign it */
3069 if (!check_all_dac_nids(spec, conn[j])) {
3071 /* select this DAC in the pin's input mux */
3072 snd_hda_codec_write_cache(codec, nid, 0,
3073 AC_VERB_SET_CONNECT_SEL, j);
3078 /* if all DACs are already assigned, connect to the primary DAC */
3080 for (j = 0; j < conn_len; j++) {
3081 if (conn[j] == spec->multiout.dac_nids[0]) {
3082 snd_hda_codec_write_cache(codec, nid, 0,
3083 AC_VERB_SET_CONNECT_SEL, j);
3091 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3092 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3095 * Fill in the dac_nids table from the parsed pin configuration
3096 * This function only works when every pin in line_out_pins[]
3097 * contains atleast one DAC in its connection list. Some 92xx
3098 * codecs are not connected directly to a DAC, such as the 9200
3099 * and 9202/925x. For those, dac_nids[] must be hard-coded.
3101 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
3103 struct sigmatel_spec *spec = codec->spec;
3104 struct auto_pin_cfg *cfg = &spec->autocfg;
3108 for (i = 0; i < cfg->line_outs; i++) {
3109 nid = cfg->line_out_pins[i];
3110 dac = get_unassigned_dac(codec, nid);
3112 if (spec->multiout.num_dacs > 0) {
3113 /* we have already working output pins,
3114 * so let's drop the broken ones again
3116 cfg->line_outs = spec->multiout.num_dacs;
3119 /* error out, no available DAC found */
3121 "%s: No available DAC for pin 0x%x\n",
3125 add_spec_dacs(spec, dac);
3128 for (i = 0; i < cfg->hp_outs; i++) {
3129 nid = cfg->hp_pins[i];
3130 dac = get_unassigned_dac(codec, nid);
3132 if (!spec->multiout.hp_nid)
3133 spec->multiout.hp_nid = dac;
3135 add_spec_extra_dacs(spec, dac);
3137 spec->hp_dacs[i] = dac;
3140 for (i = 0; i < cfg->speaker_outs; i++) {
3141 nid = cfg->speaker_pins[i];
3142 dac = get_unassigned_dac(codec, nid);
3144 add_spec_extra_dacs(spec, dac);
3145 spec->speaker_dacs[i] = dac;
3148 /* add line-in as output */
3149 nid = check_line_out_switch(codec);
3151 dac = get_unassigned_dac(codec, nid);
3153 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3154 nid, cfg->line_outs);
3155 cfg->line_out_pins[cfg->line_outs] = nid;
3157 spec->line_switch = nid;
3158 add_spec_dacs(spec, dac);
3161 /* add mic as output */
3162 nid = check_mic_out_switch(codec);
3164 dac = get_unassigned_dac(codec, nid);
3166 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3167 nid, cfg->line_outs);
3168 cfg->line_out_pins[cfg->line_outs] = nid;
3170 spec->mic_switch = nid;
3171 add_spec_dacs(spec, dac);
3175 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3176 spec->multiout.num_dacs,
3177 spec->multiout.dac_nids[0],
3178 spec->multiout.dac_nids[1],
3179 spec->multiout.dac_nids[2],
3180 spec->multiout.dac_nids[3],
3181 spec->multiout.dac_nids[4]);
3186 /* create volume control/switch for the given prefx type */
3187 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3188 int idx, hda_nid_t nid, int chs)
3190 struct sigmatel_spec *spec = codec->spec;
3194 if (!spec->check_volume_offset) {
3195 unsigned int caps, step, nums, db_scale;
3196 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3197 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3198 AC_AMPCAP_STEP_SIZE_SHIFT;
3199 step = (step + 1) * 25; /* in .01dB unit */
3200 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3201 AC_AMPCAP_NUM_STEPS_SHIFT;
3202 db_scale = nums * step;
3203 /* if dB scale is over -64dB, and finer enough,
3204 * let's reduce it to half
3206 if (db_scale > 6400 && nums >= 0x1f)
3207 spec->volume_offset = nums / 2;
3208 spec->check_volume_offset = 1;
3211 sprintf(name, "%s Playback Volume", pfx);
3212 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
3213 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3214 spec->volume_offset));
3217 sprintf(name, "%s Playback Switch", pfx);
3218 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
3219 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3225 #define create_controls(codec, pfx, nid, chs) \
3226 create_controls_idx(codec, pfx, 0, nid, chs)
3228 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3230 if (spec->multiout.num_dacs > 4) {
3231 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3234 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3235 spec->multiout.num_dacs++;
3240 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3243 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3244 if (!spec->multiout.extra_out_nid[i]) {
3245 spec->multiout.extra_out_nid[i] = nid;
3249 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3253 /* Create output controls
3254 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3256 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3257 const hda_nid_t *pins,
3258 const hda_nid_t *dac_nids,
3261 struct sigmatel_spec *spec = codec->spec;
3262 static const char *chname[4] = {
3263 "Front", "Surround", NULL /*CLFE*/, "Side"
3267 unsigned int wid_caps;
3269 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3270 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3271 wid_caps = get_wcaps(codec, pins[i]);
3272 if (wid_caps & AC_WCAP_UNSOL_CAP)
3273 spec->hp_detect = 1;
3278 if (type != AUTO_PIN_HP_OUT && i == 2) {
3280 err = create_controls(codec, "Center", nid, 1);
3283 err = create_controls(codec, "LFE", nid, 2);
3287 wid_caps = get_wcaps(codec, nid);
3289 if (wid_caps & AC_WCAP_LR_SWAP) {
3290 err = stac92xx_add_control(spec,
3291 STAC_CTL_WIDGET_CLFE_SWITCH,
3292 "Swap Center/LFE Playback Switch", nid);
3302 case AUTO_PIN_HP_OUT:
3306 case AUTO_PIN_SPEAKER_OUT:
3315 err = create_controls_idx(codec, name, idx, nid, 3);
3323 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3324 unsigned long sw, int idx)
3327 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3328 "Capture Volume", vol);
3331 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3332 "Capture Switch", sw);
3338 /* add playback controls from the parsed DAC table */
3339 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3340 const struct auto_pin_cfg *cfg)
3342 struct sigmatel_spec *spec = codec->spec;
3347 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3348 spec->multiout.dac_nids,
3349 cfg->line_out_type);
3353 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3354 err = stac92xx_add_control(spec,
3355 STAC_CTL_WIDGET_HP_SWITCH,
3356 "Headphone as Line Out Switch",
3357 cfg->hp_pins[cfg->hp_outs - 1]);
3362 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3363 nid = cfg->input_pins[idx];
3365 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3374 /* add playback controls for Speaker and HP outputs */
3375 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3376 struct auto_pin_cfg *cfg)
3378 struct sigmatel_spec *spec = codec->spec;
3381 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3382 spec->hp_dacs, AUTO_PIN_HP_OUT);
3386 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3387 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3394 /* labels for mono mux outputs */
3395 static const char *stac92xx_mono_labels[4] = {
3396 "DAC0", "DAC1", "Mixer", "DAC2"
3399 /* create mono mux for mono out on capable codecs */
3400 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3402 struct sigmatel_spec *spec = codec->spec;
3403 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3405 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3407 num_cons = snd_hda_get_connections(codec,
3410 HDA_MAX_NUM_INPUTS);
3411 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3414 for (i = 0; i < num_cons; i++) {
3415 mono_mux->items[mono_mux->num_items].label =
3416 stac92xx_mono_labels[i];
3417 mono_mux->items[mono_mux->num_items].index = i;
3418 mono_mux->num_items++;
3421 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3422 "Mono Mux", spec->mono_nid);
3425 /* labels for amp mux outputs */
3426 static const char *stac92xx_amp_labels[3] = {
3427 "Front Microphone", "Microphone", "Line In",
3430 /* create amp out controls mux on capable codecs */
3431 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3433 struct sigmatel_spec *spec = codec->spec;
3434 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3437 for (i = 0; i < spec->num_amps; i++) {
3438 amp_mux->items[amp_mux->num_items].label =
3439 stac92xx_amp_labels[i];
3440 amp_mux->items[amp_mux->num_items].index = i;
3441 amp_mux->num_items++;
3444 if (spec->num_amps > 1) {
3445 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3446 "Amp Selector Capture Switch", 0);
3450 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3451 "Amp Capture Volume",
3452 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3456 /* create PC beep volume controls */
3457 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3460 struct sigmatel_spec *spec = codec->spec;
3461 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3464 /* check for mute support for the the amp */
3465 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3466 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3467 "PC Beep Playback Switch",
3468 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3473 /* check to see if there is volume support for the amp */
3474 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3475 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3476 "PC Beep Playback Volume",
3477 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3484 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3485 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3487 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3488 struct snd_ctl_elem_value *ucontrol)
3490 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3491 ucontrol->value.integer.value[0] = codec->beep->enabled;
3495 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3496 struct snd_ctl_elem_value *ucontrol)
3498 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3499 int enabled = !!ucontrol->value.integer.value[0];
3500 if (codec->beep->enabled != enabled) {
3501 codec->beep->enabled = enabled;
3507 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3508 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3509 .info = stac92xx_dig_beep_switch_info,
3510 .get = stac92xx_dig_beep_switch_get,
3511 .put = stac92xx_dig_beep_switch_put,
3514 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3516 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3517 0, "PC Beep Playback Switch", 0);
3521 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3523 struct sigmatel_spec *spec = codec->spec;
3524 int wcaps, nid, i, err = 0;
3526 for (i = 0; i < spec->num_muxes; i++) {
3527 nid = spec->mux_nids[i];
3528 wcaps = get_wcaps(codec, nid);
3530 if (wcaps & AC_WCAP_OUT_AMP) {
3531 err = stac92xx_add_control_idx(spec,
3532 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3533 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3541 static const char *stac92xx_spdif_labels[3] = {
3542 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3545 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3547 struct sigmatel_spec *spec = codec->spec;
3548 struct hda_input_mux *spdif_mux = &spec->private_smux;
3549 const char **labels = spec->spdif_labels;
3551 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3553 num_cons = snd_hda_get_connections(codec,
3556 HDA_MAX_NUM_INPUTS);
3561 labels = stac92xx_spdif_labels;
3563 for (i = 0; i < num_cons; i++) {
3564 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3565 spdif_mux->items[spdif_mux->num_items].index = i;
3566 spdif_mux->num_items++;
3572 /* labels for dmic mux inputs */
3573 static const char *stac92xx_dmic_labels[5] = {
3574 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3575 "Digital Mic 3", "Digital Mic 4"
3578 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
3581 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3584 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3585 for (i = 0; i < nums; i++)
3591 /* create playback/capture controls for input pins on dmic capable codecs */
3592 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3593 const struct auto_pin_cfg *cfg)
3595 struct sigmatel_spec *spec = codec->spec;
3596 struct hda_input_mux *imux = &spec->private_imux;
3597 struct hda_input_mux *dimux = &spec->private_dimux;
3598 int err, i, active_mics;
3599 unsigned int def_conf;
3602 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3603 dimux->items[dimux->num_items].index = 0;
3607 for (i = 0; i < spec->num_dmics; i++) {
3608 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3609 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
3613 for (i = 0; i < spec->num_dmics; i++) {
3619 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3620 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3623 nid = spec->dmic_nids[i];
3624 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3628 if (active_mics == 1)
3629 label = "Digital Mic";
3631 label = stac92xx_dmic_labels[dimux->num_items];
3633 wcaps = get_wcaps(codec, nid) &
3634 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3637 sprintf(name, "%s Capture Volume", label);
3639 err = stac92xx_add_control(spec,
3640 STAC_CTL_WIDGET_VOL,
3642 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3643 (wcaps & AC_WCAP_OUT_AMP) ?
3644 HDA_OUTPUT : HDA_INPUT));
3649 dimux->items[dimux->num_items].label = label;
3650 dimux->items[dimux->num_items].index = index;
3652 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) {
3653 imux->items[imux->num_items].label = label;
3654 imux->items[imux->num_items].index = index;
3662 static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3663 hda_nid_t *fixed, hda_nid_t *ext)
3669 cfg = snd_hda_codec_get_pincfg(codec, nid);
3670 switch (get_defcfg_connect(cfg)) {
3671 case AC_JACK_PORT_FIXED:
3673 return 1; /* already occupied */
3676 case AC_JACK_PORT_COMPLEX:
3678 return 1; /* already occupied */
3685 static int set_mic_route(struct hda_codec *codec,
3686 struct sigmatel_mic_route *mic,
3689 struct sigmatel_spec *spec = codec->spec;
3690 struct auto_pin_cfg *cfg = &spec->autocfg;
3694 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3695 if (pin == cfg->input_pins[i])
3697 if (i <= AUTO_PIN_FRONT_MIC) {
3700 i = get_connection_index(codec, spec->mux_nids[0], pin);
3704 } else if (spec->dmux_nids) {
3707 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3715 /* return non-zero if the device is for automatic mic switch */
3716 static int stac_check_auto_mic(struct hda_codec *codec)
3718 struct sigmatel_spec *spec = codec->spec;
3719 struct auto_pin_cfg *cfg = &spec->autocfg;
3720 hda_nid_t fixed, ext;
3723 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
3724 if (cfg->input_pins[i])
3725 return 0; /* must be exclusively mics */
3728 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3729 if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
3731 for (i = 0; i < spec->num_dmics; i++)
3732 if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
3736 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
3737 return 0; /* no unsol support */
3738 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3739 set_mic_route(codec, &spec->int_mic, fixed))
3740 return 0; /* something is wrong */
3744 /* create playback/capture controls for input pins */
3745 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3747 struct sigmatel_spec *spec = codec->spec;
3748 struct hda_input_mux *imux = &spec->private_imux;
3749 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3752 for (i = 0; i < AUTO_PIN_LAST; i++) {
3755 if (!cfg->input_pins[i])
3758 for (j = 0; j < spec->num_muxes; j++) {
3760 num_cons = snd_hda_get_connections(codec,
3763 HDA_MAX_NUM_INPUTS);
3764 for (k = 0; k < num_cons; k++)
3765 if (con_lst[k] == cfg->input_pins[i]) {
3772 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3773 imux->items[imux->num_items].index = index;
3776 spec->num_analog_muxes = imux->num_items;
3778 if (imux->num_items) {
3780 * Set the current input for the muxes.
3781 * The STAC9221 has two input muxes with identical source
3782 * NID lists. Hopefully this won't get confused.
3784 for (i = 0; i < spec->num_muxes; i++) {
3785 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3786 AC_VERB_SET_CONNECT_SEL,
3787 imux->items[0].index);
3794 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3796 struct sigmatel_spec *spec = codec->spec;
3799 for (i = 0; i < spec->autocfg.line_outs; i++) {
3800 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3801 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3805 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3807 struct sigmatel_spec *spec = codec->spec;
3810 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3812 pin = spec->autocfg.hp_pins[i];
3813 if (pin) /* connect to front */
3814 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3816 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3818 pin = spec->autocfg.speaker_pins[i];
3819 if (pin) /* connect to front */
3820 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3824 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3826 struct sigmatel_spec *spec = codec->spec;
3830 if ((err = snd_hda_parse_pin_def_config(codec,
3832 spec->dmic_nids)) < 0)
3834 if (! spec->autocfg.line_outs)
3835 return 0; /* can't find valid pin config */
3837 /* If we have no real line-out pin and multiple hp-outs, HPs should
3838 * be set up as multi-channel outputs.
3840 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3841 spec->autocfg.hp_outs > 1) {
3842 /* Copy hp_outs to line_outs, backup line_outs in
3843 * speaker_outs so that the following routines can handle
3844 * HP pins as primary outputs.
3846 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3847 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3848 sizeof(spec->autocfg.line_out_pins));
3849 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3850 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3851 sizeof(spec->autocfg.hp_pins));
3852 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3853 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3854 spec->autocfg.hp_outs = 0;
3857 if (spec->autocfg.mono_out_pin) {
3858 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3859 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3860 u32 caps = query_amp_caps(codec,
3861 spec->autocfg.mono_out_pin, dir);
3862 hda_nid_t conn_list[1];
3864 /* get the mixer node and then the mono mux if it exists */
3865 if (snd_hda_get_connections(codec,
3866 spec->autocfg.mono_out_pin, conn_list, 1) &&
3867 snd_hda_get_connections(codec, conn_list[0],
3868 conn_list, 1) > 0) {
3870 int wcaps = get_wcaps(codec, conn_list[0]);
3871 int wid_type = get_wcaps_type(wcaps);
3872 /* LR swap check, some stac925x have a mux that
3873 * changes the DACs output path instead of the
3876 if (wid_type == AC_WID_AUD_SEL &&
3877 !(wcaps & AC_WCAP_LR_SWAP))
3878 spec->mono_nid = conn_list[0];
3881 hda_nid_t nid = spec->autocfg.mono_out_pin;
3883 /* most mono outs have a least a mute/unmute switch */
3884 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3885 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3886 "Mono Playback Switch",
3887 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3890 /* check for volume support for the amp */
3891 if ((caps & AC_AMPCAP_NUM_STEPS)
3892 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3893 err = stac92xx_add_control(spec,
3894 STAC_CTL_WIDGET_VOL,
3895 "Mono Playback Volume",
3896 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3902 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3906 if (!spec->multiout.num_dacs) {
3907 err = stac92xx_auto_fill_dac_nids(codec);
3910 err = stac92xx_auto_create_multi_out_ctls(codec,
3916 /* setup analog beep controls */
3917 if (spec->anabeep_nid > 0) {
3918 err = stac92xx_auto_create_beep_ctls(codec,
3924 /* setup digital beep controls and input device */
3925 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3926 if (spec->digbeep_nid > 0) {
3927 hda_nid_t nid = spec->digbeep_nid;
3930 err = stac92xx_auto_create_beep_ctls(codec, nid);
3933 err = snd_hda_attach_beep_device(codec, nid);
3936 /* IDT/STAC codecs have linear beep tone parameter */
3937 codec->beep->linear_tone = 1;
3938 /* if no beep switch is available, make its own one */
3939 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3941 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3942 err = stac92xx_beep_switch_ctl(codec);
3949 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3953 /* All output parsing done, now restore the swapped hp pins */
3955 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3956 sizeof(spec->autocfg.hp_pins));
3957 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3958 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3959 spec->autocfg.line_outs = 0;
3962 if (stac_check_auto_mic(codec)) {
3964 /* only one capture for auto-mic */
3967 spec->num_muxes = 1;
3970 for (i = 0; i < spec->num_caps; i++) {
3971 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3972 spec->capsws[i], i);
3977 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3981 if (spec->mono_nid > 0) {
3982 err = stac92xx_auto_create_mono_output_ctls(codec);
3986 if (spec->num_amps > 0) {
3987 err = stac92xx_auto_create_amp_output_ctls(codec);
3991 if (spec->num_dmics > 0 && !spec->dinput_mux)
3992 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3993 &spec->autocfg)) < 0)
3995 if (spec->num_muxes > 0) {
3996 err = stac92xx_auto_create_mux_input_ctls(codec);
4000 if (spec->num_smuxes > 0) {
4001 err = stac92xx_auto_create_spdif_mux_ctls(codec);
4006 err = stac92xx_add_input_source(spec);
4010 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4011 if (spec->multiout.max_channels > 2)
4012 spec->surr_switch = 1;
4014 if (spec->autocfg.dig_outs)
4015 spec->multiout.dig_out_nid = dig_out;
4016 if (dig_in && spec->autocfg.dig_in_pin)
4017 spec->dig_in_nid = dig_in;
4019 if (spec->kctls.list)
4020 spec->mixers[spec->num_mixers++] = spec->kctls.list;
4022 spec->input_mux = &spec->private_imux;
4023 if (!spec->dinput_mux)
4024 spec->dinput_mux = &spec->private_dimux;
4025 spec->sinput_mux = &spec->private_smux;
4026 spec->mono_mux = &spec->private_mono_mux;
4027 spec->amp_mux = &spec->private_amp_mux;
4031 /* add playback controls for HP output */
4032 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
4033 struct auto_pin_cfg *cfg)
4035 struct sigmatel_spec *spec = codec->spec;
4036 hda_nid_t pin = cfg->hp_pins[0];
4037 unsigned int wid_caps;
4042 wid_caps = get_wcaps(codec, pin);
4043 if (wid_caps & AC_WCAP_UNSOL_CAP)
4044 spec->hp_detect = 1;
4049 /* add playback controls for LFE output */
4050 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
4051 struct auto_pin_cfg *cfg)
4053 struct sigmatel_spec *spec = codec->spec;
4055 hda_nid_t lfe_pin = 0x0;
4059 * search speaker outs and line outs for a mono speaker pin
4060 * with an amp. If one is found, add LFE controls
4063 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
4064 hda_nid_t pin = spec->autocfg.speaker_pins[i];
4065 unsigned int wcaps = get_wcaps(codec, pin);
4066 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4067 if (wcaps == AC_WCAP_OUT_AMP)
4068 /* found a mono speaker with an amp, must be lfe */
4072 /* if speaker_outs is 0, then speakers may be in line_outs */
4073 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
4074 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
4075 hda_nid_t pin = spec->autocfg.line_out_pins[i];
4076 unsigned int defcfg;
4077 defcfg = snd_hda_codec_get_pincfg(codec, pin);
4078 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
4079 unsigned int wcaps = get_wcaps(codec, pin);
4080 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4081 if (wcaps == AC_WCAP_OUT_AMP)
4082 /* found a mono speaker with an amp,
4090 err = create_controls(codec, "LFE", lfe_pin, 1);
4098 static int stac9200_parse_auto_config(struct hda_codec *codec)
4100 struct sigmatel_spec *spec = codec->spec;
4103 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
4106 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
4109 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4112 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4115 if (spec->num_muxes > 0) {
4116 err = stac92xx_auto_create_mux_input_ctls(codec);
4121 err = stac92xx_add_input_source(spec);
4125 if (spec->autocfg.dig_outs)
4126 spec->multiout.dig_out_nid = 0x05;
4127 if (spec->autocfg.dig_in_pin)
4128 spec->dig_in_nid = 0x04;
4130 if (spec->kctls.list)
4131 spec->mixers[spec->num_mixers++] = spec->kctls.list;
4133 spec->input_mux = &spec->private_imux;
4134 spec->dinput_mux = &spec->private_dimux;
4140 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4141 * funky external mute control using GPIO pins.
4144 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4145 unsigned int dir_mask, unsigned int data)
4147 unsigned int gpiostate, gpiomask, gpiodir;
4149 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4150 AC_VERB_GET_GPIO_DATA, 0);
4151 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
4153 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4154 AC_VERB_GET_GPIO_MASK, 0);
4157 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4158 AC_VERB_GET_GPIO_DIRECTION, 0);
4159 gpiodir |= dir_mask;
4161 /* Configure GPIOx as CMOS */
4162 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4164 snd_hda_codec_write(codec, codec->afg, 0,
4165 AC_VERB_SET_GPIO_MASK, gpiomask);
4166 snd_hda_codec_read(codec, codec->afg, 0,
4167 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
4171 snd_hda_codec_read(codec, codec->afg, 0,
4172 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
4175 #ifdef CONFIG_SND_HDA_INPUT_JACK
4176 static void stac92xx_free_jack_priv(struct snd_jack *jack)
4178 struct sigmatel_jack *jacks = jack->private_data;
4184 static int stac92xx_add_jack(struct hda_codec *codec,
4185 hda_nid_t nid, int type)
4187 #ifdef CONFIG_SND_HDA_INPUT_JACK
4188 struct sigmatel_spec *spec = codec->spec;
4189 struct sigmatel_jack *jack;
4190 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4191 int connectivity = get_defcfg_connect(def_conf);
4195 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4198 snd_array_init(&spec->jacks, sizeof(*jack), 32);
4199 jack = snd_array_new(&spec->jacks);
4205 snprintf(name, sizeof(name), "%s at %s %s Jack",
4206 snd_hda_get_jack_type(def_conf),
4207 snd_hda_get_jack_connectivity(def_conf),
4208 snd_hda_get_jack_location(def_conf));
4210 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4215 jack->jack->private_data = jack;
4216 jack->jack->private_free = stac92xx_free_jack_priv;
4221 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4222 unsigned char type, int data)
4224 struct sigmatel_event *event;
4226 snd_array_init(&spec->events, sizeof(*event), 32);
4227 event = snd_array_new(&spec->events);
4232 event->tag = spec->events.used;
4238 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4241 struct sigmatel_spec *spec = codec->spec;
4242 struct sigmatel_event *event = spec->events.list;
4245 for (i = 0; i < spec->events.used; i++, event++) {
4246 if (event->nid == nid)
4252 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4255 struct sigmatel_spec *spec = codec->spec;
4256 struct sigmatel_event *event = spec->events.list;
4259 for (i = 0; i < spec->events.used; i++, event++) {
4260 if (event->tag == tag)
4266 /* check if given nid is a valid pin and no other events are assigned
4267 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4268 * Otherwise, returns zero.
4270 static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4273 struct sigmatel_event *event;
4276 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4278 event = stac_get_event(codec, nid);
4280 if (event->type != type)
4284 tag = stac_add_event(codec->spec, nid, type, 0);
4288 snd_hda_codec_write_cache(codec, nid, 0,
4289 AC_VERB_SET_UNSOLICITED_ENABLE,
4294 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4297 for (i = 0; i < cfg->hp_outs; i++)
4298 if (cfg->hp_pins[i] == nid)
4299 return 1; /* nid is a HP-Out */
4301 return 0; /* nid is not a HP-Out */
4304 static void stac92xx_power_down(struct hda_codec *codec)
4306 struct sigmatel_spec *spec = codec->spec;
4308 /* power down inactive DACs */
4310 for (dac = spec->dac_list; *dac; dac++)
4311 if (!check_all_dac_nids(spec, *dac))
4312 snd_hda_codec_write(codec, *dac, 0,
4313 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4316 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4319 /* override some hints from the hwdep entry */
4320 static void stac_store_hints(struct hda_codec *codec)
4322 struct sigmatel_spec *spec = codec->spec;
4326 val = snd_hda_get_bool_hint(codec, "hp_detect");
4328 spec->hp_detect = val;
4329 p = snd_hda_get_hint(codec, "gpio_mask");
4331 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4332 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4335 p = snd_hda_get_hint(codec, "gpio_dir");
4337 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4338 p = snd_hda_get_hint(codec, "gpio_data");
4340 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4341 p = snd_hda_get_hint(codec, "eapd_mask");
4343 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4344 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4346 spec->eapd_switch = val;
4349 static int stac92xx_init(struct hda_codec *codec)
4351 struct sigmatel_spec *spec = codec->spec;
4352 struct auto_pin_cfg *cfg = &spec->autocfg;
4356 snd_hda_sequence_write(codec, spec->init);
4358 /* power down adcs initially */
4359 if (spec->powerdown_adcs)
4360 for (i = 0; i < spec->num_adcs; i++)
4361 snd_hda_codec_write(codec,
4362 spec->adc_nids[i], 0,
4363 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4365 /* override some hints */
4366 stac_store_hints(codec);
4369 gpio = spec->gpio_data;
4370 /* turn on EAPD statically when spec->eapd_switch isn't set.
4371 * otherwise, unsol event will turn it on/off dynamically
4373 if (!spec->eapd_switch)
4374 gpio |= spec->eapd_mask;
4375 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4378 if (spec->hp_detect) {
4379 /* Enable unsolicited responses on the HP widget */
4380 for (i = 0; i < cfg->hp_outs; i++) {
4381 hda_nid_t nid = cfg->hp_pins[i];
4382 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4384 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4385 cfg->speaker_outs > 0) {
4386 /* enable pin-detect for line-outs as well */
4387 for (i = 0; i < cfg->line_outs; i++) {
4388 hda_nid_t nid = cfg->line_out_pins[i];
4389 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4393 /* force to enable the first line-out; the others are set up
4396 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4398 /* fake event to set up pins */
4399 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4401 stac92xx_auto_init_multi_out(codec);
4402 stac92xx_auto_init_hp_out(codec);
4403 for (i = 0; i < cfg->hp_outs; i++)
4404 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4406 if (spec->auto_mic) {
4407 /* initialize connection to analog input */
4408 if (spec->dmux_nids)
4409 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4410 AC_VERB_SET_CONNECT_SEL, 0);
4411 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4412 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4414 for (i = 0; i < AUTO_PIN_LAST; i++) {
4415 hda_nid_t nid = cfg->input_pins[i];
4417 unsigned int pinctl, conf;
4418 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4419 /* for mic pins, force to initialize */
4420 pinctl = stac92xx_get_default_vref(codec, nid);
4421 pinctl |= AC_PINCTL_IN_EN;
4422 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4424 pinctl = snd_hda_codec_read(codec, nid, 0,
4425 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4426 /* if PINCTL already set then skip */
4427 /* Also, if both INPUT and OUTPUT are set,
4428 * it must be a BIOS bug; need to override, too
4430 if (!(pinctl & AC_PINCTL_IN_EN) ||
4431 (pinctl & AC_PINCTL_OUT_EN)) {
4432 pinctl &= ~AC_PINCTL_OUT_EN;
4433 pinctl |= AC_PINCTL_IN_EN;
4434 stac92xx_auto_set_pinctl(codec, nid,
4438 conf = snd_hda_codec_get_pincfg(codec, nid);
4439 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4440 if (enable_pin_detect(codec, nid,
4442 stac_issue_unsol_event(codec, nid);
4446 for (i = 0; i < spec->num_dmics; i++)
4447 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4449 if (cfg->dig_out_pins[0])
4450 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4452 if (cfg->dig_in_pin)
4453 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4455 for (i = 0; i < spec->num_pwrs; i++) {
4456 hda_nid_t nid = spec->pwr_nids[i];
4457 int pinctl, def_conf;
4459 /* power on when no jack detection is available */
4460 if (!spec->hp_detect) {
4461 stac_toggle_power_map(codec, nid, 1);
4465 if (is_nid_hp_pin(cfg, nid))
4466 continue; /* already has an unsol event */
4468 pinctl = snd_hda_codec_read(codec, nid, 0,
4469 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4470 /* outputs are only ports capable of power management
4471 * any attempts on powering down a input port cause the
4472 * referenced VREF to act quirky.
4474 if (pinctl & AC_PINCTL_IN_EN) {
4475 stac_toggle_power_map(codec, nid, 1);
4478 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4479 def_conf = get_defcfg_connect(def_conf);
4480 /* skip any ports that don't have jacks since presence
4481 * detection is useless */
4482 if (def_conf != AC_JACK_PORT_COMPLEX) {
4483 if (def_conf != AC_JACK_PORT_NONE)
4484 stac_toggle_power_map(codec, nid, 1);
4487 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4488 stac_issue_unsol_event(codec, nid);
4491 stac92xx_power_down(codec);
4495 static void stac92xx_free_jacks(struct hda_codec *codec)
4497 #ifdef CONFIG_SND_HDA_INPUT_JACK
4498 /* free jack instances manually when clearing/reconfiguring */
4499 struct sigmatel_spec *spec = codec->spec;
4500 if (!codec->bus->shutdown && spec->jacks.list) {
4501 struct sigmatel_jack *jacks = spec->jacks.list;
4503 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4505 snd_device_free(codec->bus->card, jacks->jack);
4508 snd_array_free(&spec->jacks);
4512 static void stac92xx_free_kctls(struct hda_codec *codec)
4514 struct sigmatel_spec *spec = codec->spec;
4516 if (spec->kctls.list) {
4517 struct snd_kcontrol_new *kctl = spec->kctls.list;
4519 for (i = 0; i < spec->kctls.used; i++)
4520 kfree(kctl[i].name);
4522 snd_array_free(&spec->kctls);
4525 static void stac92xx_free(struct hda_codec *codec)
4527 struct sigmatel_spec *spec = codec->spec;
4532 stac92xx_free_jacks(codec);
4533 snd_array_free(&spec->events);
4536 snd_hda_detach_beep_device(codec);
4539 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4542 unsigned int old_ctl, pin_ctl;
4544 pin_ctl = snd_hda_codec_read(codec, nid,
4545 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4547 if (pin_ctl & AC_PINCTL_IN_EN) {
4549 * we need to check the current set-up direction of
4550 * shared input pins since they can be switched via
4551 * "xxx as Output" mixer switch
4553 struct sigmatel_spec *spec = codec->spec;
4554 if (nid == spec->line_switch || nid == spec->mic_switch)
4559 /* if setting pin direction bits, clear the current
4560 direction bits first */
4561 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4562 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4565 if (old_ctl != pin_ctl)
4566 snd_hda_codec_write_cache(codec, nid, 0,
4567 AC_VERB_SET_PIN_WIDGET_CONTROL,
4571 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4574 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4575 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4577 snd_hda_codec_write_cache(codec, nid, 0,
4578 AC_VERB_SET_PIN_WIDGET_CONTROL,
4582 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4586 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
4592 static void stac92xx_line_out_detect(struct hda_codec *codec,
4595 struct sigmatel_spec *spec = codec->spec;
4596 struct auto_pin_cfg *cfg = &spec->autocfg;
4599 for (i = 0; i < cfg->line_outs; i++) {
4602 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4604 unsigned int pinctl;
4605 pinctl = snd_hda_codec_read(codec,
4606 cfg->line_out_pins[i], 0,
4607 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4608 if (pinctl & AC_PINCTL_IN_EN)
4609 presence = 0; /* mic- or line-input */
4614 /* disable speakers */
4615 for (i = 0; i < cfg->speaker_outs; i++)
4616 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4618 if (spec->eapd_mask && spec->eapd_switch)
4619 stac_gpio_set(codec, spec->gpio_mask,
4620 spec->gpio_dir, spec->gpio_data &
4623 /* enable speakers */
4624 for (i = 0; i < cfg->speaker_outs; i++)
4625 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4627 if (spec->eapd_mask && spec->eapd_switch)
4628 stac_gpio_set(codec, spec->gpio_mask,
4629 spec->gpio_dir, spec->gpio_data |
4634 /* return non-zero if the hp-pin of the given array index isn't
4635 * a jack-detection target
4637 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4639 struct auto_pin_cfg *cfg = &spec->autocfg;
4641 /* ignore sensing of shared line and mic jacks */
4642 if (cfg->hp_pins[i] == spec->line_switch)
4644 if (cfg->hp_pins[i] == spec->mic_switch)
4646 /* ignore if the pin is set as line-out */
4647 if (cfg->hp_pins[i] == spec->hp_switch)
4652 static void stac92xx_hp_detect(struct hda_codec *codec)
4654 struct sigmatel_spec *spec = codec->spec;
4655 struct auto_pin_cfg *cfg = &spec->autocfg;
4659 if (spec->gpio_mute)
4660 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4661 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4663 for (i = 0; i < cfg->hp_outs; i++) {
4666 if (no_hp_sensing(spec, i))
4668 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4670 unsigned int pinctl;
4671 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4672 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4673 if (pinctl & AC_PINCTL_IN_EN)
4674 presence = 0; /* mic- or line-input */
4679 /* disable lineouts */
4680 if (spec->hp_switch)
4681 stac92xx_reset_pinctl(codec, spec->hp_switch,
4683 for (i = 0; i < cfg->line_outs; i++)
4684 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4687 /* enable lineouts */
4688 if (spec->hp_switch)
4689 stac92xx_set_pinctl(codec, spec->hp_switch,
4691 for (i = 0; i < cfg->line_outs; i++)
4692 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4695 stac92xx_line_out_detect(codec, presence);
4696 /* toggle hp outs */
4697 for (i = 0; i < cfg->hp_outs; i++) {
4698 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4699 if (no_hp_sensing(spec, i))
4702 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4704 /* Resetting the pinctl like below may lead to (a sort of) regressions
4705 * on some devices since they use the HP pin actually for line/speaker
4706 * outs although the default pin config shows a different pin (that is
4707 * wrong and useless).
4709 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4710 * But, disabling the code below just works around it, and I'm too tired of
4711 * bug reports with such devices...
4714 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4719 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4722 struct sigmatel_spec *spec = codec->spec;
4723 unsigned int idx, val;
4725 for (idx = 0; idx < spec->num_pwrs; idx++) {
4726 if (spec->pwr_nids[idx] == nid)
4729 if (idx >= spec->num_pwrs)
4732 /* several codecs have two power down bits */
4733 if (spec->pwr_mapping)
4734 idx = spec->pwr_mapping[idx];
4738 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4744 /* power down unused output ports */
4745 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4748 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4750 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4753 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4755 struct sigmatel_spec *spec = codec->spec;
4756 struct sigmatel_jack *jacks = spec->jacks.list;
4760 for (i = 0; i < spec->jacks.used; i++) {
4761 if (jacks->nid == nid) {
4762 unsigned int pin_ctl =
4763 snd_hda_codec_read(codec, nid,
4764 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4766 int type = jacks->type;
4767 if (type == (SND_JACK_LINEOUT
4768 | SND_JACK_HEADPHONE))
4769 type = (pin_ctl & AC_PINCTL_HP_EN)
4770 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4771 snd_jack_report(jacks->jack,
4772 get_pin_presence(codec, nid)
4780 static void stac92xx_mic_detect(struct hda_codec *codec)
4782 struct sigmatel_spec *spec = codec->spec;
4783 struct sigmatel_mic_route *mic;
4785 if (get_pin_presence(codec, spec->ext_mic.pin))
4786 mic = &spec->ext_mic;
4788 mic = &spec->int_mic;
4790 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4791 AC_VERB_SET_CONNECT_SEL,
4794 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4795 AC_VERB_SET_CONNECT_SEL,
4799 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4801 struct sigmatel_event *event = stac_get_event(codec, nid);
4804 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4807 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4809 struct sigmatel_spec *spec = codec->spec;
4810 struct sigmatel_event *event;
4813 tag = (res >> 26) & 0x7f;
4814 event = stac_get_event_from_tag(codec, tag);
4818 switch (event->type) {
4821 stac92xx_hp_detect(codec);
4823 case STAC_MIC_EVENT:
4824 stac92xx_mic_detect(codec);
4828 switch (event->type) {
4831 case STAC_MIC_EVENT:
4832 case STAC_INSERT_EVENT:
4833 case STAC_PWR_EVENT:
4834 if (spec->num_pwrs > 0)
4835 stac92xx_pin_sense(codec, event->nid);
4836 stac92xx_report_jack(codec, event->nid);
4838 switch (codec->subsystem_id) {
4840 if (event->nid == 0xb) {
4841 int pin = AC_PINCTL_IN_EN;
4843 if (get_pin_presence(codec, 0xa)
4844 && get_pin_presence(codec, 0xb))
4845 pin |= AC_PINCTL_VREF_80;
4846 if (!get_pin_presence(codec, 0xb))
4847 pin |= AC_PINCTL_VREF_80;
4849 /* toggle VREF state based on mic + hp pin
4852 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4856 case STAC_VREF_EVENT:
4857 data = snd_hda_codec_read(codec, codec->afg, 0,
4858 AC_VERB_GET_GPIO_DATA, 0);
4859 /* toggle VREF state based on GPIOx status */
4860 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4861 !!(data & (1 << event->data)));
4866 #ifdef CONFIG_PROC_FS
4867 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4868 struct hda_codec *codec, hda_nid_t nid)
4870 if (nid == codec->afg)
4871 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4872 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4875 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4876 struct hda_codec *codec,
4879 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4880 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4883 /* stac92hd71bxx, stac92hd73xx */
4884 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4885 struct hda_codec *codec, hda_nid_t nid)
4887 stac92hd_proc_hook(buffer, codec, nid);
4888 if (nid == codec->afg)
4889 analog_loop_proc_hook(buffer, codec, 0xfa0);
4892 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4893 struct hda_codec *codec, hda_nid_t nid)
4895 if (nid == codec->afg)
4896 analog_loop_proc_hook(buffer, codec, 0xfe0);
4899 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4900 struct hda_codec *codec, hda_nid_t nid)
4902 if (nid == codec->afg)
4903 analog_loop_proc_hook(buffer, codec, 0xfeb);
4906 #define stac92hd_proc_hook NULL
4907 #define stac92hd7x_proc_hook NULL
4908 #define stac9205_proc_hook NULL
4909 #define stac927x_proc_hook NULL
4912 #ifdef SND_HDA_NEEDS_RESUME
4913 static int stac92xx_resume(struct hda_codec *codec)
4915 struct sigmatel_spec *spec = codec->spec;
4917 stac92xx_init(codec);
4918 snd_hda_codec_resume_amp(codec);
4919 snd_hda_codec_resume_cache(codec);
4920 /* fake event to set up pins again to override cached values */
4921 if (spec->hp_detect)
4922 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4927 * using power check for controlling mute led of HP notebooks
4928 * check for mute state only on Speakers (nid = 0x10)
4930 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4931 * the LED is NOT working properly !
4933 * Changed name to reflect that it now works for any designated
4934 * model, not just HP HDX.
4937 #ifdef CONFIG_SND_HDA_POWER_SAVE
4938 static int stac92xx_hp_check_power_status(struct hda_codec *codec,
4941 struct sigmatel_spec *spec = codec->spec;
4944 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4946 spec->gpio_data &= ~spec->gpio_led; /* orange */
4948 spec->gpio_data |= spec->gpio_led; /* white */
4950 stac_gpio_set(codec, spec->gpio_mask,
4959 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4961 struct sigmatel_spec *spec = codec->spec;
4965 /* reset each pin before powering down DAC/ADC to avoid click noise */
4966 nid = codec->start_nid;
4967 for (i = 0; i < codec->num_nodes; i++, nid++) {
4968 unsigned int wcaps = get_wcaps(codec, nid);
4969 unsigned int wid_type = get_wcaps_type(wcaps);
4970 if (wid_type == AC_WID_PIN)
4971 snd_hda_codec_read(codec, nid, 0,
4972 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4975 if (spec->eapd_mask)
4976 stac_gpio_set(codec, spec->gpio_mask,
4977 spec->gpio_dir, spec->gpio_data &
4983 static struct hda_codec_ops stac92xx_patch_ops = {
4984 .build_controls = stac92xx_build_controls,
4985 .build_pcms = stac92xx_build_pcms,
4986 .init = stac92xx_init,
4987 .free = stac92xx_free,
4988 .unsol_event = stac92xx_unsol_event,
4989 #ifdef SND_HDA_NEEDS_RESUME
4990 .suspend = stac92xx_suspend,
4991 .resume = stac92xx_resume,
4995 static int patch_stac9200(struct hda_codec *codec)
4997 struct sigmatel_spec *spec;
5000 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5005 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
5006 spec->pin_nids = stac9200_pin_nids;
5007 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5010 if (spec->board_config < 0)
5011 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5014 stac92xx_set_config_regs(codec,
5015 stac9200_brd_tbl[spec->board_config]);
5017 spec->multiout.max_channels = 2;
5018 spec->multiout.num_dacs = 1;
5019 spec->multiout.dac_nids = stac9200_dac_nids;
5020 spec->adc_nids = stac9200_adc_nids;
5021 spec->mux_nids = stac9200_mux_nids;
5022 spec->num_muxes = 1;
5023 spec->num_dmics = 0;
5027 if (spec->board_config == STAC_9200_M4 ||
5028 spec->board_config == STAC_9200_M4_2 ||
5029 spec->board_config == STAC_9200_OQO)
5030 spec->init = stac9200_eapd_init;
5032 spec->init = stac9200_core_init;
5033 spec->mixer = stac9200_mixer;
5035 if (spec->board_config == STAC_9200_PANASONIC) {
5036 spec->gpio_mask = spec->gpio_dir = 0x09;
5037 spec->gpio_data = 0x00;
5040 err = stac9200_parse_auto_config(codec);
5042 stac92xx_free(codec);
5046 /* CF-74 has no headphone detection, and the driver should *NOT*
5047 * do detection and HP/speaker toggle because the hardware does it.
5049 if (spec->board_config == STAC_9200_PANASONIC)
5050 spec->hp_detect = 0;
5052 codec->patch_ops = stac92xx_patch_ops;
5057 static int patch_stac925x(struct hda_codec *codec)
5059 struct sigmatel_spec *spec;
5062 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5067 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
5068 spec->pin_nids = stac925x_pin_nids;
5070 /* Check first for codec ID */
5071 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5074 stac925x_codec_id_cfg_tbl);
5076 /* Now checks for PCI ID, if codec ID is not found */
5077 if (spec->board_config < 0)
5078 spec->board_config = snd_hda_check_board_config(codec,
5083 if (spec->board_config < 0)
5084 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5087 stac92xx_set_config_regs(codec,
5088 stac925x_brd_tbl[spec->board_config]);
5090 spec->multiout.max_channels = 2;
5091 spec->multiout.num_dacs = 1;
5092 spec->multiout.dac_nids = stac925x_dac_nids;
5093 spec->adc_nids = stac925x_adc_nids;
5094 spec->mux_nids = stac925x_mux_nids;
5095 spec->num_muxes = 1;
5098 switch (codec->vendor_id) {
5099 case 0x83847632: /* STAC9202 */
5100 case 0x83847633: /* STAC9202D */
5101 case 0x83847636: /* STAC9251 */
5102 case 0x83847637: /* STAC9251D */
5103 spec->num_dmics = STAC925X_NUM_DMICS;
5104 spec->dmic_nids = stac925x_dmic_nids;
5105 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5106 spec->dmux_nids = stac925x_dmux_nids;
5109 spec->num_dmics = 0;
5113 spec->init = stac925x_core_init;
5114 spec->mixer = stac925x_mixer;
5116 spec->capvols = stac925x_capvols;
5117 spec->capsws = stac925x_capsws;
5119 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
5121 if (spec->board_config < 0) {
5122 printk(KERN_WARNING "hda_codec: No auto-config is "
5123 "available, default to model=ref\n");
5124 spec->board_config = STAC_925x_REF;
5130 stac92xx_free(codec);
5134 codec->patch_ops = stac92xx_patch_ops;
5139 static int patch_stac92hd73xx(struct hda_codec *codec)
5141 struct sigmatel_spec *spec;
5142 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5146 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5151 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
5152 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5153 spec->pin_nids = stac92hd73xx_pin_nids;
5154 spec->board_config = snd_hda_check_board_config(codec,
5155 STAC_92HD73XX_MODELS,
5156 stac92hd73xx_models,
5157 stac92hd73xx_cfg_tbl);
5159 if (spec->board_config < 0)
5160 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5163 stac92xx_set_config_regs(codec,
5164 stac92hd73xx_brd_tbl[spec->board_config]);
5166 num_dacs = snd_hda_get_connections(codec, 0x0a,
5167 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5169 if (num_dacs < 3 || num_dacs > 5) {
5170 printk(KERN_WARNING "hda_codec: Could not determine "
5171 "number of channels defaulting to DAC count\n");
5172 num_dacs = STAC92HD73_DAC_COUNT;
5175 case 0x3: /* 6 Channel */
5176 spec->mixer = stac92hd73xx_6ch_mixer;
5177 spec->init = stac92hd73xx_6ch_core_init;
5178 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
5180 case 0x4: /* 8 Channel */
5181 spec->mixer = stac92hd73xx_8ch_mixer;
5182 spec->init = stac92hd73xx_8ch_core_init;
5183 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
5185 case 0x5: /* 10 Channel */
5186 spec->mixer = stac92hd73xx_10ch_mixer;
5187 spec->init = stac92hd73xx_10ch_core_init;
5188 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5191 spec->multiout.dac_nids = spec->dac_nids;
5193 spec->aloopback_mask = 0x01;
5194 spec->aloopback_shift = 8;
5196 spec->digbeep_nid = 0x1c;
5197 spec->mux_nids = stac92hd73xx_mux_nids;
5198 spec->adc_nids = stac92hd73xx_adc_nids;
5199 spec->dmic_nids = stac92hd73xx_dmic_nids;
5200 spec->dmux_nids = stac92hd73xx_dmux_nids;
5201 spec->smux_nids = stac92hd73xx_smux_nids;
5202 spec->amp_nids = stac92hd73xx_amp_nids;
5203 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
5205 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5206 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
5207 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
5209 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5210 spec->capvols = stac92hd73xx_capvols;
5211 spec->capsws = stac92hd73xx_capsws;
5213 switch (spec->board_config) {
5215 spec->init = dell_eq_core_init;
5217 case STAC_DELL_M6_AMIC:
5218 case STAC_DELL_M6_DMIC:
5219 case STAC_DELL_M6_BOTH:
5220 spec->num_smuxes = 0;
5221 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
5222 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
5223 spec->eapd_switch = 0;
5226 if (spec->board_config != STAC_DELL_EQ)
5227 spec->init = dell_m6_core_init;
5228 switch (spec->board_config) {
5229 case STAC_DELL_M6_AMIC: /* Analog Mics */
5230 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5231 spec->num_dmics = 0;
5233 case STAC_DELL_M6_DMIC: /* Digital Mics */
5234 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5235 spec->num_dmics = 1;
5237 case STAC_DELL_M6_BOTH: /* Both */
5238 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5239 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5240 spec->num_dmics = 1;
5245 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5246 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5247 spec->eapd_switch = 1;
5250 if (spec->board_config > STAC_92HD73XX_REF) {
5251 /* GPIO0 High = Enable EAPD */
5252 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5253 spec->gpio_data = 0x01;
5256 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5257 spec->pwr_nids = stac92hd73xx_pwr_nids;
5259 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
5262 if (spec->board_config < 0) {
5263 printk(KERN_WARNING "hda_codec: No auto-config is "
5264 "available, default to model=ref\n");
5265 spec->board_config = STAC_92HD73XX_REF;
5272 stac92xx_free(codec);
5276 if (spec->board_config == STAC_92HD73XX_NO_JD)
5277 spec->hp_detect = 0;
5279 codec->patch_ops = stac92xx_patch_ops;
5281 codec->proc_widget_hook = stac92hd7x_proc_hook;
5286 static int patch_stac92hd83xxx(struct hda_codec *codec)
5288 struct sigmatel_spec *spec;
5289 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
5294 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5299 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5300 spec->mono_nid = 0x19;
5301 spec->digbeep_nid = 0x21;
5302 spec->dmic_nids = stac92hd83xxx_dmic_nids;
5303 spec->dmux_nids = stac92hd83xxx_dmux_nids;
5304 spec->adc_nids = stac92hd83xxx_adc_nids;
5305 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5306 spec->amp_nids = stac92hd83xxx_amp_nids;
5307 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5308 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5309 spec->multiout.dac_nids = spec->dac_nids;
5311 spec->init = stac92hd83xxx_core_init;
5312 spec->mixer = stac92hd83xxx_mixer;
5313 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5314 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
5315 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5316 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
5317 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
5318 spec->pin_nids = stac92hd83xxx_pin_nids;
5319 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5320 spec->capvols = stac92hd83xxx_capvols;
5321 spec->capsws = stac92hd83xxx_capsws;
5323 spec->board_config = snd_hda_check_board_config(codec,
5324 STAC_92HD83XXX_MODELS,
5325 stac92hd83xxx_models,
5326 stac92hd83xxx_cfg_tbl);
5328 if (spec->board_config < 0)
5329 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5332 stac92xx_set_config_regs(codec,
5333 stac92hd83xxx_brd_tbl[spec->board_config]);
5335 switch (codec->vendor_id) {
5339 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5345 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5347 if (spec->board_config < 0) {
5348 printk(KERN_WARNING "hda_codec: No auto-config is "
5349 "available, default to model=ref\n");
5350 spec->board_config = STAC_92HD83XXX_REF;
5357 stac92xx_free(codec);
5361 switch (spec->board_config) {
5370 num_dacs = snd_hda_get_connections(codec, nid,
5371 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5373 num_dacs = STAC92HD83_DAC_COUNT;
5375 /* set port X to select the last DAC
5377 snd_hda_codec_write_cache(codec, nid, 0,
5378 AC_VERB_SET_CONNECT_SEL, num_dacs);
5380 codec->patch_ops = stac92xx_patch_ops;
5382 codec->proc_widget_hook = stac92hd_proc_hook;
5387 /* get the pin connection (fixed, none, etc) */
5388 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5390 struct sigmatel_spec *spec = codec->spec;
5393 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5394 return get_defcfg_connect(cfg);
5397 static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5398 hda_nid_t *nids, int num_nids)
5400 struct sigmatel_spec *spec = codec->spec;
5402 unsigned int def_conf;
5404 for (num = 0; num < num_nids; num++) {
5405 for (idx = 0; idx < spec->num_pins; idx++)
5406 if (spec->pin_nids[idx] == nids[num])
5408 if (idx >= spec->num_pins)
5410 def_conf = stac_get_defcfg_connect(codec, idx);
5411 if (def_conf == AC_JACK_PORT_NONE)
5417 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5420 struct sigmatel_spec *spec = codec->spec;
5423 for (idx = 0; idx < spec->num_pins; idx++)
5424 if (spec->pin_nids[idx] == dig0pin)
5426 if ((idx + 2) >= spec->num_pins)
5430 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5433 /* dig0pin + dig2pin case */
5434 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5436 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5442 static int patch_stac92hd71bxx(struct hda_codec *codec)
5444 struct sigmatel_spec *spec;
5445 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5448 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5453 codec->patch_ops = stac92xx_patch_ops;
5454 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5455 switch (codec->vendor_id) {
5458 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5462 /* On 92HD75Bx 0x27 isn't a pin nid */
5466 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5468 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5469 spec->board_config = snd_hda_check_board_config(codec,
5470 STAC_92HD71BXX_MODELS,
5471 stac92hd71bxx_models,
5472 stac92hd71bxx_cfg_tbl);
5474 if (spec->board_config < 0)
5475 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5478 stac92xx_set_config_regs(codec,
5479 stac92hd71bxx_brd_tbl[spec->board_config]);
5481 if (spec->board_config > STAC_92HD71BXX_REF) {
5483 spec->gpio_mask = 0x01;
5484 spec->gpio_dir = 0x01;
5485 spec->gpio_data = 0x01;
5488 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5489 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5491 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5492 spec->capvols = stac92hd71bxx_capvols;
5493 spec->capsws = stac92hd71bxx_capsws;
5495 switch (codec->vendor_id) {
5496 case 0x111d76b6: /* 4 Port without Analog Mixer */
5500 case 0x111d76b4: /* 6 Port without Analog Mixer */
5502 spec->init = stac92hd71bxx_core_init;
5503 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5504 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5505 stac92hd71bxx_dmic_nids,
5506 STAC92HD71BXX_NUM_DMICS);
5508 case 0x111d7608: /* 5 Port with Analog Mixer */
5509 switch (spec->board_config) {
5511 /* Enable VREF power saving on GPIO1 detect */
5512 err = stac_add_event(spec, codec->afg,
5513 STAC_VREF_EVENT, 0x02);
5516 snd_hda_codec_write_cache(codec, codec->afg, 0,
5517 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5518 snd_hda_codec_write_cache(codec, codec->afg, 0,
5519 AC_VERB_SET_UNSOLICITED_ENABLE,
5521 spec->gpio_mask |= 0x02;
5524 if ((codec->revision_id & 0xf) == 0 ||
5525 (codec->revision_id & 0xf) == 1)
5526 spec->stream_delay = 40; /* 40 milliseconds */
5528 /* no output amps */
5531 spec->init = stac92hd71bxx_core_init;
5533 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5534 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5535 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5536 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5537 stac92hd71bxx_dmic_nids,
5538 STAC92HD71BXX_NUM_DMICS - 1);
5540 case 0x111d7603: /* 6 Port with Analog Mixer */
5541 if ((codec->revision_id & 0xf) == 1)
5542 spec->stream_delay = 40; /* 40 milliseconds */
5544 /* no output amps */
5548 spec->init = stac92hd71bxx_core_init;
5549 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5550 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5551 stac92hd71bxx_dmic_nids,
5552 STAC92HD71BXX_NUM_DMICS);
5556 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5557 snd_hda_sequence_write_cache(codec, unmute_init);
5559 /* Some HP machines seem to have unstable codec communications
5560 * especially with ATI fglrx driver. For recovering from the
5561 * CORB/RIRB stall, allow the BUS reset and keep always sync
5563 if (spec->board_config == STAC_HP_DV5) {
5564 codec->bus->sync_write = 1;
5565 codec->bus->allow_bus_reset = 1;
5568 spec->aloopback_ctl = stac92hd71bxx_loopback;
5569 spec->aloopback_mask = 0x50;
5570 spec->aloopback_shift = 0;
5572 spec->powerdown_adcs = 1;
5573 spec->digbeep_nid = 0x26;
5574 spec->mux_nids = stac92hd71bxx_mux_nids;
5575 spec->adc_nids = stac92hd71bxx_adc_nids;
5576 spec->smux_nids = stac92hd71bxx_smux_nids;
5577 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5579 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5580 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5581 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5582 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5584 switch (spec->board_config) {
5586 /* enable internal microphone */
5587 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5588 stac92xx_auto_set_pinctl(codec, 0x0e,
5589 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5591 case STAC_DELL_M4_2:
5592 spec->num_dmics = 0;
5593 spec->num_smuxes = 0;
5594 spec->num_dmuxes = 0;
5596 case STAC_DELL_M4_1:
5597 case STAC_DELL_M4_3:
5598 spec->num_dmics = 1;
5599 spec->num_smuxes = 0;
5600 spec->num_dmuxes = 1;
5602 case STAC_HP_DV4_1222NR:
5603 spec->num_dmics = 1;
5604 /* I don't know if it needs 1 or 2 smuxes - will wait for
5605 * bug reports to fix if needed
5607 spec->num_smuxes = 1;
5608 spec->num_dmuxes = 1;
5609 spec->gpio_led = 0x01;
5612 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5613 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5616 spec->num_dmics = 1;
5617 spec->num_dmuxes = 1;
5618 spec->num_smuxes = 1;
5619 /* orange/white mute led on GPIO3, orange=0, white=1 */
5620 spec->gpio_led = 0x08;
5624 #ifdef CONFIG_SND_HDA_POWER_SAVE
5625 if (spec->gpio_led) {
5626 spec->gpio_mask |= spec->gpio_led;
5627 spec->gpio_dir |= spec->gpio_led;
5628 spec->gpio_data |= spec->gpio_led;
5629 /* register check_power_status callback. */
5630 codec->patch_ops.check_power_status =
5631 stac92xx_hp_check_power_status;
5635 spec->multiout.dac_nids = spec->dac_nids;
5637 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5639 if (spec->board_config < 0) {
5640 printk(KERN_WARNING "hda_codec: No auto-config is "
5641 "available, default to model=ref\n");
5642 spec->board_config = STAC_92HD71BXX_REF;
5649 stac92xx_free(codec);
5653 codec->proc_widget_hook = stac92hd7x_proc_hook;
5658 static int patch_stac922x(struct hda_codec *codec)
5660 struct sigmatel_spec *spec;
5663 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5668 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5669 spec->pin_nids = stac922x_pin_nids;
5670 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5673 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5674 spec->gpio_mask = spec->gpio_dir = 0x03;
5675 spec->gpio_data = 0x03;
5676 /* Intel Macs have all same PCI SSID, so we need to check
5677 * codec SSID to distinguish the exact models
5679 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5680 switch (codec->subsystem_id) {
5683 spec->board_config = STAC_INTEL_MAC_V1;
5687 spec->board_config = STAC_INTEL_MAC_V2;
5695 spec->board_config = STAC_INTEL_MAC_V3;
5699 spec->board_config = STAC_INTEL_MAC_V4;
5703 spec->board_config = STAC_INTEL_MAC_V5;
5706 spec->board_config = STAC_INTEL_MAC_V3;
5712 if (spec->board_config < 0)
5713 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5716 stac92xx_set_config_regs(codec,
5717 stac922x_brd_tbl[spec->board_config]);
5719 spec->adc_nids = stac922x_adc_nids;
5720 spec->mux_nids = stac922x_mux_nids;
5721 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5722 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5723 spec->num_dmics = 0;
5726 spec->init = stac922x_core_init;
5728 spec->num_caps = STAC922X_NUM_CAPS;
5729 spec->capvols = stac922x_capvols;
5730 spec->capsws = stac922x_capsws;
5732 spec->multiout.dac_nids = spec->dac_nids;
5734 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5736 if (spec->board_config < 0) {
5737 printk(KERN_WARNING "hda_codec: No auto-config is "
5738 "available, default to model=ref\n");
5739 spec->board_config = STAC_D945_REF;
5745 stac92xx_free(codec);
5749 codec->patch_ops = stac92xx_patch_ops;
5751 /* Fix Mux capture level; max to 2 */
5752 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5753 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5754 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5755 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5756 (0 << AC_AMPCAP_MUTE_SHIFT));
5761 static int patch_stac927x(struct hda_codec *codec)
5763 struct sigmatel_spec *spec;
5766 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5771 codec->slave_dig_outs = stac927x_slave_dig_outs;
5772 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5773 spec->pin_nids = stac927x_pin_nids;
5774 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5778 if (spec->board_config < 0)
5779 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5782 stac92xx_set_config_regs(codec,
5783 stac927x_brd_tbl[spec->board_config]);
5785 spec->digbeep_nid = 0x23;
5786 spec->adc_nids = stac927x_adc_nids;
5787 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5788 spec->mux_nids = stac927x_mux_nids;
5789 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5790 spec->smux_nids = stac927x_smux_nids;
5791 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5792 spec->spdif_labels = stac927x_spdif_labels;
5793 spec->dac_list = stac927x_dac_nids;
5794 spec->multiout.dac_nids = spec->dac_nids;
5796 switch (spec->board_config) {
5799 /* GPIO0 High = Enable EAPD */
5800 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
5801 spec->gpio_data = 0x01;
5802 spec->num_dmics = 0;
5804 spec->init = d965_core_init;
5806 case STAC_DELL_BIOS:
5807 switch (codec->subsystem_id) {
5810 /* correct the device field to SPDIF out */
5811 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5814 /* configure the analog microphone on some laptops */
5815 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5816 /* correct the front output jack as a hp out */
5817 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5818 /* correct the front input jack as a mic */
5819 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5822 /* GPIO2 High = Enable EAPD */
5823 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
5824 spec->gpio_data = 0x04;
5825 switch (codec->subsystem_id) {
5827 /* correct EAPD to be GPIO0 */
5828 spec->eapd_mask = spec->gpio_mask = 0x01;
5829 spec->gpio_dir = spec->gpio_data = 0x01;
5832 spec->dmic_nids = stac927x_dmic_nids;
5833 spec->num_dmics = STAC927X_NUM_DMICS;
5835 spec->init = d965_core_init;
5836 spec->dmux_nids = stac927x_dmux_nids;
5837 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5840 if (spec->board_config > STAC_D965_REF) {
5841 /* GPIO0 High = Enable EAPD */
5842 spec->eapd_mask = spec->gpio_mask = 0x01;
5843 spec->gpio_dir = spec->gpio_data = 0x01;
5845 spec->num_dmics = 0;
5847 spec->init = stac927x_core_init;
5850 spec->num_caps = STAC927X_NUM_CAPS;
5851 spec->capvols = stac927x_capvols;
5852 spec->capsws = stac927x_capsws;
5855 spec->aloopback_ctl = stac927x_loopback;
5856 spec->aloopback_mask = 0x40;
5857 spec->aloopback_shift = 0;
5858 spec->eapd_switch = 1;
5860 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
5862 if (spec->board_config < 0) {
5863 printk(KERN_WARNING "hda_codec: No auto-config is "
5864 "available, default to model=ref\n");
5865 spec->board_config = STAC_D965_REF;
5871 stac92xx_free(codec);
5875 codec->patch_ops = stac92xx_patch_ops;
5877 codec->proc_widget_hook = stac927x_proc_hook;
5881 * The STAC927x seem to require fairly long delays for certain
5882 * command sequences. With too short delays (even if the answer
5883 * is set to RIRB properly), it results in the silence output
5884 * on some hardwares like Dell.
5886 * The below flag enables the longer delay (see get_response
5889 codec->bus->needs_damn_long_delay = 1;
5891 /* no jack detecion for ref-no-jd model */
5892 if (spec->board_config == STAC_D965_REF_NO_JD)
5893 spec->hp_detect = 0;
5898 static int patch_stac9205(struct hda_codec *codec)
5900 struct sigmatel_spec *spec;
5903 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5908 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
5909 spec->pin_nids = stac9205_pin_nids;
5910 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5914 if (spec->board_config < 0)
5915 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5918 stac92xx_set_config_regs(codec,
5919 stac9205_brd_tbl[spec->board_config]);
5921 spec->digbeep_nid = 0x23;
5922 spec->adc_nids = stac9205_adc_nids;
5923 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
5924 spec->mux_nids = stac9205_mux_nids;
5925 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
5926 spec->smux_nids = stac9205_smux_nids;
5927 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
5928 spec->dmic_nids = stac9205_dmic_nids;
5929 spec->num_dmics = STAC9205_NUM_DMICS;
5930 spec->dmux_nids = stac9205_dmux_nids;
5931 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
5934 spec->init = stac9205_core_init;
5935 spec->aloopback_ctl = stac9205_loopback;
5937 spec->num_caps = STAC9205_NUM_CAPS;
5938 spec->capvols = stac9205_capvols;
5939 spec->capsws = stac9205_capsws;
5941 spec->aloopback_mask = 0x40;
5942 spec->aloopback_shift = 0;
5943 /* Turn on/off EAPD per HP plugging */
5944 if (spec->board_config != STAC_9205_EAPD)
5945 spec->eapd_switch = 1;
5946 spec->multiout.dac_nids = spec->dac_nids;
5948 switch (spec->board_config){
5949 case STAC_9205_DELL_M43:
5950 /* Enable SPDIF in/out */
5951 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5952 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
5954 /* Enable unsol response for GPIO4/Dock HP connection */
5955 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5958 snd_hda_codec_write_cache(codec, codec->afg, 0,
5959 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5960 snd_hda_codec_write_cache(codec, codec->afg, 0,
5961 AC_VERB_SET_UNSOLICITED_ENABLE,
5964 spec->gpio_dir = 0x0b;
5965 spec->eapd_mask = 0x01;
5966 spec->gpio_mask = 0x1b;
5967 spec->gpio_mute = 0x10;
5968 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5971 spec->gpio_data = 0x01;
5974 /* SPDIF-In enabled */
5977 /* GPIO0 High = EAPD */
5978 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5979 spec->gpio_data = 0x01;
5983 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5985 if (spec->board_config < 0) {
5986 printk(KERN_WARNING "hda_codec: No auto-config is "
5987 "available, default to model=ref\n");
5988 spec->board_config = STAC_9205_REF;
5994 stac92xx_free(codec);
5998 codec->patch_ops = stac92xx_patch_ops;
6000 codec->proc_widget_hook = stac9205_proc_hook;
6009 static struct hda_verb stac9872_core_init[] = {
6010 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
6011 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6015 static hda_nid_t stac9872_pin_nids[] = {
6016 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6020 static hda_nid_t stac9872_adc_nids[] = {
6024 static hda_nid_t stac9872_mux_nids[] = {
6028 static unsigned long stac9872_capvols[] = {
6029 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6031 #define stac9872_capsws stac9872_capvols
6033 static unsigned int stac9872_vaio_pin_configs[9] = {
6034 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6035 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6039 static const char *stac9872_models[STAC_9872_MODELS] = {
6040 [STAC_9872_AUTO] = "auto",
6041 [STAC_9872_VAIO] = "vaio",
6044 static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
6045 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6048 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
6049 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6050 "Sony VAIO F/S", STAC_9872_VAIO),
6054 static int patch_stac9872(struct hda_codec *codec)
6056 struct sigmatel_spec *spec;
6059 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6063 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6064 spec->pin_nids = stac9872_pin_nids;
6066 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6069 if (spec->board_config < 0)
6070 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6073 stac92xx_set_config_regs(codec,
6074 stac9872_brd_tbl[spec->board_config]);
6076 spec->multiout.dac_nids = spec->dac_nids;
6077 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6078 spec->adc_nids = stac9872_adc_nids;
6079 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6080 spec->mux_nids = stac9872_mux_nids;
6081 spec->init = stac9872_core_init;
6083 spec->capvols = stac9872_capvols;
6084 spec->capsws = stac9872_capsws;
6086 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
6088 stac92xx_free(codec);
6091 spec->input_mux = &spec->private_imux;
6092 codec->patch_ops = stac92xx_patch_ops;
6100 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
6101 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6102 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6103 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6104 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6105 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6106 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6107 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
6108 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6109 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6110 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6111 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6112 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6113 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
6114 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6115 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6116 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6117 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6118 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6119 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6120 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6121 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6122 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6123 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
6124 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6125 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6126 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6127 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6128 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6129 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
6130 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6131 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
6132 /* The following does not take into account .id=0x83847661 when subsys =
6133 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6134 * currently not fully supported.
6136 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6137 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6138 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
6139 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
6140 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6141 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6142 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6143 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6144 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6145 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6146 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6147 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
6148 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
6149 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
6150 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
6151 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
6152 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
6153 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6154 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
6155 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
6156 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6157 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6158 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6159 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6160 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6161 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6162 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6163 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6167 MODULE_ALIAS("snd-hda-codec-id:8384*");
6168 MODULE_ALIAS("snd-hda-codec-id:111d*");
6170 MODULE_LICENSE("GPL");
6171 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6173 static struct hda_codec_preset_list sigmatel_list = {
6174 .preset = snd_hda_preset_sigmatel,
6175 .owner = THIS_MODULE,
6178 static int __init patch_sigmatel_init(void)
6180 return snd_hda_add_codec_preset(&sigmatel_list);
6183 static void __exit patch_sigmatel_exit(void)
6185 snd_hda_delete_codec_preset(&sigmatel_list);
6188 module_init(patch_sigmatel_init)
6189 module_exit(patch_sigmatel_exit)