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"
77 STAC_92HD73XX_NO_JD, /* no jack-detection */
89 STAC_92HD83XXX_PWR_REF,
104 STAC_92HD71BXX_MODELS
130 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
131 * is given, one of the above models will be
132 * chosen according to the subsystem id. */
133 /* for backward compatibility */
150 STAC_D965_REF_NO_JD, /* no jack-detection */
166 struct sigmatel_event {
173 struct sigmatel_jack {
176 struct snd_jack *jack;
179 struct sigmatel_spec {
180 struct snd_kcontrol_new *mixers[4];
181 unsigned int num_mixers;
184 unsigned int eapd_switch: 1;
185 unsigned int surr_switch: 1;
186 unsigned int alt_switch: 1;
187 unsigned int hp_detect: 1;
188 unsigned int spdif_mute: 1;
189 unsigned int check_volume_offset:1;
192 unsigned int eapd_mask;
193 unsigned int gpio_mask;
194 unsigned int gpio_dir;
195 unsigned int gpio_data;
196 unsigned int gpio_mute;
197 unsigned int gpio_led;
200 unsigned int stream_delay;
202 /* analog loopback */
203 struct snd_kcontrol_new *aloopback_ctl;
204 unsigned char aloopback_mask;
205 unsigned char aloopback_shift;
207 /* power management */
208 unsigned int num_pwrs;
209 unsigned int *pwr_mapping;
214 struct snd_array jacks;
217 struct snd_array events;
220 struct hda_input_mux *mono_mux;
221 struct hda_input_mux *amp_mux;
222 unsigned int cur_mmux;
223 struct hda_multi_out multiout;
224 hda_nid_t dac_nids[5];
225 hda_nid_t hp_dacs[5];
226 hda_nid_t speaker_dacs[5];
232 unsigned int num_adcs;
234 unsigned int num_muxes;
235 hda_nid_t *dmic_nids;
236 unsigned int num_dmics;
237 hda_nid_t *dmux_nids;
238 unsigned int num_dmuxes;
239 hda_nid_t *smux_nids;
240 unsigned int num_smuxes;
242 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
243 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
244 unsigned int num_caps; /* number of capture volume/switch elements */
246 const char **spdif_labels;
248 hda_nid_t dig_in_nid;
250 hda_nid_t anabeep_nid;
251 hda_nid_t digbeep_nid;
255 unsigned int num_pins;
257 /* codec specific stuff */
258 struct hda_verb *init;
259 struct snd_kcontrol_new *mixer;
262 struct hda_input_mux *dinput_mux;
263 unsigned int cur_dmux[2];
264 struct hda_input_mux *input_mux;
265 unsigned int cur_mux[3];
266 struct hda_input_mux *sinput_mux;
267 unsigned int cur_smux[2];
268 unsigned int cur_amux;
270 unsigned int num_amps;
271 unsigned int powerdown_adcs;
274 unsigned int io_switch[2];
275 unsigned int clfe_swap;
276 hda_nid_t line_switch; /* shared line-in for input and output */
277 hda_nid_t mic_switch; /* shared mic-in for input and output */
278 hda_nid_t hp_switch; /* NID of HP as line-out */
279 unsigned int aloopback;
281 struct hda_pcm pcm_rec[2]; /* PCM information */
283 /* dynamic controls and input_mux */
284 struct auto_pin_cfg autocfg;
285 struct snd_array kctls;
286 struct hda_input_mux private_dimux;
287 struct hda_input_mux private_imux;
288 struct hda_input_mux private_smux;
289 struct hda_input_mux private_amp_mux;
290 struct hda_input_mux private_mono_mux;
293 static hda_nid_t stac9200_adc_nids[1] = {
297 static hda_nid_t stac9200_mux_nids[1] = {
301 static hda_nid_t stac9200_dac_nids[1] = {
305 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
306 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
310 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
314 static hda_nid_t stac92hd73xx_adc_nids[2] = {
318 #define DELL_M6_AMP 2
319 static hda_nid_t stac92hd73xx_amp_nids[3] = {
323 #define STAC92HD73XX_NUM_DMICS 2
324 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
328 #define STAC92HD73_DAC_COUNT 5
330 static hda_nid_t stac92hd73xx_mux_nids[4] = {
331 0x28, 0x29, 0x2a, 0x2b,
334 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
338 static hda_nid_t stac92hd73xx_smux_nids[2] = {
342 #define STAC92HD73XX_NUM_CAPS 2
343 static unsigned long stac92hd73xx_capvols[] = {
344 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
345 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
347 #define stac92hd73xx_capsws stac92hd73xx_capvols
349 #define STAC92HD83XXX_NUM_DMICS 2
350 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
354 #define STAC92HD83_DAC_COUNT 3
356 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
360 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
364 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
368 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
372 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
373 0x03, 0x0c, 0x20, 0x40,
376 static hda_nid_t stac92hd83xxx_amp_nids[1] = {
380 #define STAC92HD83XXX_NUM_CAPS 2
381 static unsigned long stac92hd83xxx_capvols[] = {
382 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
383 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
385 #define stac92hd83xxx_capsws stac92hd83xxx_capvols
387 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
391 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
395 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
399 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
403 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
407 #define STAC92HD71BXX_NUM_DMICS 2
408 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
412 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
416 #define STAC92HD71BXX_NUM_CAPS 2
417 static unsigned long stac92hd71bxx_capvols[] = {
418 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
419 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
421 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
423 static hda_nid_t stac925x_adc_nids[1] = {
427 static hda_nid_t stac925x_mux_nids[1] = {
431 static hda_nid_t stac925x_dac_nids[1] = {
435 #define STAC925X_NUM_DMICS 1
436 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
440 static hda_nid_t stac925x_dmux_nids[1] = {
444 static unsigned long stac925x_capvols[] = {
445 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
447 static unsigned long stac925x_capsws[] = {
448 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
451 static hda_nid_t stac922x_adc_nids[2] = {
455 static hda_nid_t stac922x_mux_nids[2] = {
459 #define STAC922X_NUM_CAPS 2
460 static unsigned long stac922x_capvols[] = {
461 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
462 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
464 #define stac922x_capsws stac922x_capvols
466 static hda_nid_t stac927x_slave_dig_outs[2] = {
470 static hda_nid_t stac927x_adc_nids[3] = {
474 static hda_nid_t stac927x_mux_nids[3] = {
478 static hda_nid_t stac927x_smux_nids[1] = {
482 static hda_nid_t stac927x_dac_nids[6] = {
483 0x02, 0x03, 0x04, 0x05, 0x06, 0
486 static hda_nid_t stac927x_dmux_nids[1] = {
490 #define STAC927X_NUM_DMICS 2
491 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
495 #define STAC927X_NUM_CAPS 3
496 static unsigned long stac927x_capvols[] = {
497 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
498 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
499 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
501 static unsigned long stac927x_capsws[] = {
502 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
503 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
504 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
507 static const char *stac927x_spdif_labels[5] = {
508 "Digital Playback", "ADAT", "Analog Mux 1",
509 "Analog Mux 2", "Analog Mux 3"
512 static hda_nid_t stac9205_adc_nids[2] = {
516 static hda_nid_t stac9205_mux_nids[2] = {
520 static hda_nid_t stac9205_dmux_nids[1] = {
524 static hda_nid_t stac9205_smux_nids[1] = {
528 #define STAC9205_NUM_DMICS 2
529 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
533 #define STAC9205_NUM_CAPS 2
534 static unsigned long stac9205_capvols[] = {
535 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
536 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
538 static unsigned long stac9205_capsws[] = {
539 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
540 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
543 static hda_nid_t stac9200_pin_nids[8] = {
544 0x08, 0x09, 0x0d, 0x0e,
545 0x0f, 0x10, 0x11, 0x12,
548 static hda_nid_t stac925x_pin_nids[8] = {
549 0x07, 0x08, 0x0a, 0x0b,
550 0x0c, 0x0d, 0x10, 0x11,
553 static hda_nid_t stac922x_pin_nids[10] = {
554 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
555 0x0f, 0x10, 0x11, 0x15, 0x1b,
558 static hda_nid_t stac92hd73xx_pin_nids[13] = {
559 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
560 0x0f, 0x10, 0x11, 0x12, 0x13,
564 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
565 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
566 0x0f, 0x10, 0x11, 0x1f, 0x20,
569 #define STAC92HD71BXX_NUM_PINS 13
570 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
571 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
572 0x00, 0x14, 0x18, 0x19, 0x1e,
575 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
576 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
577 0x0f, 0x14, 0x18, 0x19, 0x1e,
581 static hda_nid_t stac927x_pin_nids[14] = {
582 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
583 0x0f, 0x10, 0x11, 0x12, 0x13,
584 0x14, 0x21, 0x22, 0x23,
587 static hda_nid_t stac9205_pin_nids[12] = {
588 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
589 0x0f, 0x14, 0x16, 0x17, 0x18,
593 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
595 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
596 struct snd_ctl_elem_value *ucontrol)
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 struct sigmatel_spec *spec = codec->spec;
600 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
602 kcontrol->private_value ^= get_amp_nid(kcontrol);
603 kcontrol->private_value |= nid;
605 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
608 static int stac92xx_amp_volume_put(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_put(kcontrol, ucontrol);
621 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_info *uinfo)
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct sigmatel_spec *spec = codec->spec;
626 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
629 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
630 struct snd_ctl_elem_value *ucontrol)
632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
633 struct sigmatel_spec *spec = codec->spec;
634 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
636 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
640 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 struct sigmatel_spec *spec = codec->spec;
645 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
647 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
648 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
651 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_info *uinfo)
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
656 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
659 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
660 struct snd_ctl_elem_value *ucontrol)
662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
663 struct sigmatel_spec *spec = codec->spec;
664 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
666 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
670 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
671 struct snd_ctl_elem_value *ucontrol)
673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
674 struct sigmatel_spec *spec = codec->spec;
675 struct hda_input_mux *smux = &spec->private_smux;
676 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
680 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
681 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
685 if (spec->spdif_mute) {
687 nid = spec->multiout.dig_out_nid;
689 nid = codec->slave_dig_outs[smux_idx - 1];
690 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
694 /* un/mute SPDIF out */
695 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
701 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
702 hda_nid_t nid, unsigned int new_vref)
706 pincfg = snd_hda_codec_read(codec, nid, 0,
707 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
710 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
713 if (new_vref == AC_PINCTL_VREF_HIZ)
714 pincfg |= AC_PINCTL_OUT_EN;
716 pincfg |= AC_PINCTL_IN_EN;
718 error = snd_hda_codec_write_cache(codec, nid, 0,
719 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
726 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
729 vref = snd_hda_codec_read(codec, nid, 0,
730 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
731 vref &= AC_PINCTL_VREFEN;
735 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
738 struct sigmatel_spec *spec = codec->spec;
739 return snd_hda_input_mux_info(spec->input_mux, uinfo);
742 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
744 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
745 struct sigmatel_spec *spec = codec->spec;
746 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
748 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
752 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
755 struct sigmatel_spec *spec = codec->spec;
756 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
758 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
759 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
762 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
763 struct snd_ctl_elem_info *uinfo)
765 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
766 struct sigmatel_spec *spec = codec->spec;
767 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
770 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
771 struct snd_ctl_elem_value *ucontrol)
773 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
774 struct sigmatel_spec *spec = codec->spec;
776 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
780 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
781 struct snd_ctl_elem_value *ucontrol)
783 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
784 struct sigmatel_spec *spec = codec->spec;
786 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
787 spec->mono_nid, &spec->cur_mmux);
790 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
791 struct snd_ctl_elem_info *uinfo)
793 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
794 struct sigmatel_spec *spec = codec->spec;
795 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
798 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
799 struct snd_ctl_elem_value *ucontrol)
801 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
802 struct sigmatel_spec *spec = codec->spec;
804 ucontrol->value.enumerated.item[0] = spec->cur_amux;
808 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
809 struct snd_ctl_elem_value *ucontrol)
811 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
812 struct sigmatel_spec *spec = codec->spec;
813 struct snd_kcontrol *ctl =
814 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
818 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
819 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
821 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
825 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
827 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
828 struct snd_ctl_elem_value *ucontrol)
830 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
831 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
832 struct sigmatel_spec *spec = codec->spec;
834 ucontrol->value.integer.value[0] = !!(spec->aloopback &
835 (spec->aloopback_mask << idx));
839 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
840 struct snd_ctl_elem_value *ucontrol)
842 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
843 struct sigmatel_spec *spec = codec->spec;
844 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
845 unsigned int dac_mode;
846 unsigned int val, idx_val;
848 idx_val = spec->aloopback_mask << idx;
849 if (ucontrol->value.integer.value[0])
850 val = spec->aloopback | idx_val;
852 val = spec->aloopback & ~idx_val;
853 if (spec->aloopback == val)
856 spec->aloopback = val;
858 /* Only return the bits defined by the shift value of the
859 * first two bytes of the mask
861 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
862 kcontrol->private_value & 0xFFFF, 0x0);
863 dac_mode >>= spec->aloopback_shift;
865 if (spec->aloopback & idx_val) {
866 snd_hda_power_up(codec);
869 snd_hda_power_down(codec);
870 dac_mode &= ~idx_val;
873 snd_hda_codec_write_cache(codec, codec->afg, 0,
874 kcontrol->private_value >> 16, dac_mode);
879 static struct hda_verb stac9200_core_init[] = {
880 /* set dac0mux for dac converter */
881 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
885 static struct hda_verb stac9200_eapd_init[] = {
886 /* set dac0mux for dac converter */
887 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
888 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
892 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
893 /* set master volume and direct control */
894 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
895 /* setup adcs to point to mixer */
896 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
897 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
898 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
899 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
900 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
901 /* setup import muxs */
902 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
903 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
904 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
905 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
909 static struct hda_verb dell_eq_core_init[] = {
910 /* set master volume to max value without distortion
911 * and direct control */
912 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
913 /* setup adcs to point to mixer */
914 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
915 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
916 /* setup import muxs */
917 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
918 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
919 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
920 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
924 static struct hda_verb dell_m6_core_init[] = {
925 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
926 /* setup adcs to point to mixer */
927 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
928 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
929 /* setup import muxs */
930 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
931 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
932 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
933 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
937 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
938 /* set master volume and direct control */
939 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
940 /* setup adcs to point to mixer */
941 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
942 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
943 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
944 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
945 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
946 /* setup import muxs */
947 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
948 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
949 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
950 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
954 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
955 /* set master volume and direct control */
956 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
957 /* dac3 is connected to import3 mux */
958 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
959 /* setup adcs to point to mixer */
960 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
961 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
962 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
963 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
964 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
965 /* setup import muxs */
966 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
967 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
968 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
969 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
973 static struct hda_verb stac92hd83xxx_core_init[] = {
974 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
975 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
976 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
978 /* power state controls amps */
979 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
983 static struct hda_verb stac92hd71bxx_core_init[] = {
984 /* set master volume and direct control */
985 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
989 #define HD_DISABLE_PORTF 1
990 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
991 /* start of config #1 */
993 /* connect port 0f to audio mixer */
994 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
995 /* start of config #2 */
997 /* set master volume and direct control */
998 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1002 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
1003 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
1004 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1005 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1006 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1010 static struct hda_verb stac925x_core_init[] = {
1011 /* set dac0mux for dac converter */
1012 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
1013 /* mute the master volume */
1014 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1018 static struct hda_verb stac922x_core_init[] = {
1019 /* set master volume and direct control */
1020 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1024 static struct hda_verb d965_core_init[] = {
1025 /* set master volume and direct control */
1026 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1027 /* unmute node 0x1b */
1028 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1029 /* select node 0x03 as DAC */
1030 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
1034 static struct hda_verb stac927x_core_init[] = {
1035 /* set master volume and direct control */
1036 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1037 /* enable analog pc beep path */
1038 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
1042 static struct hda_verb stac9205_core_init[] = {
1043 /* set master volume and direct control */
1044 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1045 /* enable analog pc beep path */
1046 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
1050 #define STAC_MONO_MUX \
1052 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1053 .name = "Mono Mux", \
1055 .info = stac92xx_mono_mux_enum_info, \
1056 .get = stac92xx_mono_mux_enum_get, \
1057 .put = stac92xx_mono_mux_enum_put, \
1060 #define STAC_AMP_MUX \
1062 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1063 .name = "Amp Selector Capture Switch", \
1065 .info = stac92xx_amp_mux_enum_info, \
1066 .get = stac92xx_amp_mux_enum_get, \
1067 .put = stac92xx_amp_mux_enum_put, \
1070 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1072 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1075 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1076 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1077 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1078 .info = stac92xx_amp_volume_info, \
1079 .get = stac92xx_amp_volume_get, \
1080 .put = stac92xx_amp_volume_put, \
1081 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1082 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1085 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
1087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1088 .name = "Analog Loopback", \
1090 .info = stac92xx_aloopback_info, \
1091 .get = stac92xx_aloopback_get, \
1092 .put = stac92xx_aloopback_put, \
1093 .private_value = verb_read | (verb_write << 16), \
1096 #define DC_BIAS(xname, idx, nid) \
1098 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1101 .info = stac92xx_dc_bias_info, \
1102 .get = stac92xx_dc_bias_get, \
1103 .put = stac92xx_dc_bias_put, \
1104 .private_value = nid, \
1107 static struct snd_kcontrol_new stac9200_mixer[] = {
1108 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1109 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
1110 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1111 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1115 #define DELL_M6_MIXER 6
1116 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1117 /* start of config #1 */
1118 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1119 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1121 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1122 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1124 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1125 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1127 /* start of config #2 */
1128 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1129 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1131 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1132 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1137 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1138 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1142 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1143 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1147 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1148 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1152 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1153 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1154 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1156 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1157 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1159 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1160 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1162 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1163 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1165 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1166 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1170 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1171 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1172 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1174 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1175 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1177 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1178 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1180 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1181 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1183 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1184 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1189 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1190 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1191 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
1193 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1194 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
1196 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1197 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
1199 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1200 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
1203 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1204 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
1209 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1210 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1211 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1213 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1214 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1216 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1217 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1219 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1220 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1224 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1225 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1228 static struct snd_kcontrol_new stac925x_mixer[] = {
1229 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1230 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1234 static struct snd_kcontrol_new stac9205_loopback[] = {
1235 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1239 static struct snd_kcontrol_new stac927x_loopback[] = {
1240 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1244 static struct snd_kcontrol_new stac_dmux_mixer = {
1245 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1246 .name = "Digital Input Source",
1247 /* count set later */
1248 .info = stac92xx_dmux_enum_info,
1249 .get = stac92xx_dmux_enum_get,
1250 .put = stac92xx_dmux_enum_put,
1253 static struct snd_kcontrol_new stac_smux_mixer = {
1254 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1255 .name = "IEC958 Playback Source",
1256 /* count set later */
1257 .info = stac92xx_smux_enum_info,
1258 .get = stac92xx_smux_enum_get,
1259 .put = stac92xx_smux_enum_put,
1262 static const char *slave_vols[] = {
1263 "Front Playback Volume",
1264 "Surround Playback Volume",
1265 "Center Playback Volume",
1266 "LFE Playback Volume",
1267 "Side Playback Volume",
1268 "Headphone Playback Volume",
1269 "Speaker Playback Volume",
1273 static const char *slave_sws[] = {
1274 "Front Playback Switch",
1275 "Surround Playback Switch",
1276 "Center Playback Switch",
1277 "LFE Playback Switch",
1278 "Side Playback Switch",
1279 "Headphone Playback Switch",
1280 "Speaker Playback Switch",
1281 "IEC958 Playback Switch",
1285 static void stac92xx_free_kctls(struct hda_codec *codec);
1286 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1288 static int stac92xx_build_controls(struct hda_codec *codec)
1290 struct sigmatel_spec *spec = codec->spec;
1291 struct auto_pin_cfg *cfg = &spec->autocfg;
1297 err = snd_hda_add_new_ctls(codec, spec->mixer);
1302 for (i = 0; i < spec->num_mixers; i++) {
1303 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1307 if (spec->num_dmuxes > 0) {
1308 stac_dmux_mixer.count = spec->num_dmuxes;
1309 err = snd_hda_ctl_add(codec,
1310 snd_ctl_new1(&stac_dmux_mixer, codec));
1314 if (spec->num_smuxes > 0) {
1315 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1316 struct hda_input_mux *smux = &spec->private_smux;
1317 /* check for mute support on SPDIF out */
1318 if (wcaps & AC_WCAP_OUT_AMP) {
1319 smux->items[smux->num_items].label = "Off";
1320 smux->items[smux->num_items].index = 0;
1322 spec->spdif_mute = 1;
1324 stac_smux_mixer.count = spec->num_smuxes;
1325 err = snd_hda_ctl_add(codec,
1326 snd_ctl_new1(&stac_smux_mixer, codec));
1331 if (spec->multiout.dig_out_nid) {
1332 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1335 err = snd_hda_create_spdif_share_sw(codec,
1339 spec->multiout.share_spdif = 1;
1341 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1342 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1347 /* if we have no master control, let's create it */
1348 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1349 unsigned int vmaster_tlv[4];
1350 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1351 HDA_OUTPUT, vmaster_tlv);
1352 /* correct volume offset */
1353 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1354 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1355 vmaster_tlv, slave_vols);
1359 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1360 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1366 if (spec->aloopback_ctl &&
1367 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1368 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1373 stac92xx_free_kctls(codec); /* no longer needed */
1375 /* create jack input elements */
1376 if (spec->hp_detect) {
1377 for (i = 0; i < cfg->hp_outs; i++) {
1378 int type = SND_JACK_HEADPHONE;
1379 nid = cfg->hp_pins[i];
1380 /* jack detection */
1381 if (cfg->hp_outs == i)
1382 type |= SND_JACK_LINEOUT;
1383 err = stac92xx_add_jack(codec, nid, type);
1388 for (i = 0; i < cfg->line_outs; i++) {
1389 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1394 for (i = 0; i < AUTO_PIN_LAST; i++) {
1395 nid = cfg->input_pins[i];
1397 err = stac92xx_add_jack(codec, nid,
1398 SND_JACK_MICROPHONE);
1407 static unsigned int ref9200_pin_configs[8] = {
1408 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1409 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1412 static unsigned int gateway9200_m4_pin_configs[8] = {
1413 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1414 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1416 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1417 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1418 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1422 STAC 9200 pin configs for
1427 static unsigned int dell9200_d21_pin_configs[8] = {
1428 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1429 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1433 STAC 9200 pin configs for
1437 static unsigned int dell9200_d22_pin_configs[8] = {
1438 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1439 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1443 STAC 9200 pin configs for
1444 102801C4 (Dell Dimension E310)
1451 static unsigned int dell9200_d23_pin_configs[8] = {
1452 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1453 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1458 STAC 9200-32 pin configs for
1459 102801B5 (Dell Inspiron 630m)
1460 102801D8 (Dell Inspiron 640m)
1462 static unsigned int dell9200_m21_pin_configs[8] = {
1463 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1464 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1468 STAC 9200-32 pin configs for
1469 102801C2 (Dell Latitude D620)
1471 102801CC (Dell Latitude D820)
1475 static unsigned int dell9200_m22_pin_configs[8] = {
1476 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1477 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1481 STAC 9200-32 pin configs for
1482 102801CE (Dell XPS M1710)
1483 102801CF (Dell Precision M90)
1485 static unsigned int dell9200_m23_pin_configs[8] = {
1486 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1487 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1491 STAC 9200-32 pin configs for
1494 102801CB (Dell Latitude 120L)
1497 static unsigned int dell9200_m24_pin_configs[8] = {
1498 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1499 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1503 STAC 9200-32 pin configs for
1504 102801BD (Dell Inspiron E1505n)
1508 static unsigned int dell9200_m25_pin_configs[8] = {
1509 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1510 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1514 STAC 9200-32 pin configs for
1515 102801F5 (Dell Inspiron 1501)
1518 static unsigned int dell9200_m26_pin_configs[8] = {
1519 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1520 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1525 102801CD (Dell Inspiron E1705/9400)
1527 static unsigned int dell9200_m27_pin_configs[8] = {
1528 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1529 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1532 static unsigned int oqo9200_pin_configs[8] = {
1533 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1534 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1538 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1539 [STAC_REF] = ref9200_pin_configs,
1540 [STAC_9200_OQO] = oqo9200_pin_configs,
1541 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1542 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1543 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1544 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1545 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1546 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1547 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1548 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1549 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1550 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1551 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1552 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1553 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1556 static const char *stac9200_models[STAC_9200_MODELS] = {
1557 [STAC_AUTO] = "auto",
1559 [STAC_9200_OQO] = "oqo",
1560 [STAC_9200_DELL_D21] = "dell-d21",
1561 [STAC_9200_DELL_D22] = "dell-d22",
1562 [STAC_9200_DELL_D23] = "dell-d23",
1563 [STAC_9200_DELL_M21] = "dell-m21",
1564 [STAC_9200_DELL_M22] = "dell-m22",
1565 [STAC_9200_DELL_M23] = "dell-m23",
1566 [STAC_9200_DELL_M24] = "dell-m24",
1567 [STAC_9200_DELL_M25] = "dell-m25",
1568 [STAC_9200_DELL_M26] = "dell-m26",
1569 [STAC_9200_DELL_M27] = "dell-m27",
1570 [STAC_9200_M4] = "gateway-m4",
1571 [STAC_9200_M4_2] = "gateway-m4-2",
1572 [STAC_9200_PANASONIC] = "panasonic",
1575 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1576 /* SigmaTel reference board */
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1578 "DFI LanParty", STAC_REF),
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1580 "DFI LanParty", STAC_REF),
1581 /* Dell laptops have BIOS problem */
1582 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1583 "unknown Dell", STAC_9200_DELL_D21),
1584 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1585 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1586 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1587 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1589 "unknown Dell", STAC_9200_DELL_D22),
1590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1591 "unknown Dell", STAC_9200_DELL_D22),
1592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1593 "Dell Latitude D620", STAC_9200_DELL_M22),
1594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1595 "unknown Dell", STAC_9200_DELL_D23),
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1597 "unknown Dell", STAC_9200_DELL_D23),
1598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1599 "unknown Dell", STAC_9200_DELL_M22),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1601 "unknown Dell", STAC_9200_DELL_M24),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1603 "unknown Dell", STAC_9200_DELL_M24),
1604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1605 "Dell Latitude 120L", STAC_9200_DELL_M24),
1606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1607 "Dell Latitude D820", STAC_9200_DELL_M22),
1608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1609 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1611 "Dell XPS M1710", STAC_9200_DELL_M23),
1612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1613 "Dell Precision M90", STAC_9200_DELL_M23),
1614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1615 "unknown Dell", STAC_9200_DELL_M22),
1616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1617 "unknown Dell", STAC_9200_DELL_M22),
1618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1619 "unknown Dell", STAC_9200_DELL_M22),
1620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1621 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1623 "unknown Dell", STAC_9200_DELL_D23),
1624 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1625 "unknown Dell", STAC_9200_DELL_D23),
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1627 "unknown Dell", STAC_9200_DELL_D21),
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1629 "unknown Dell", STAC_9200_DELL_D23),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1631 "unknown Dell", STAC_9200_DELL_D21),
1632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1633 "unknown Dell", STAC_9200_DELL_M25),
1634 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1635 "unknown Dell", STAC_9200_DELL_M25),
1636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1637 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1639 "unknown Dell", STAC_9200_DELL_M26),
1641 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1642 /* Gateway machines needs EAPD to be set on resume */
1643 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1644 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1645 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1647 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1651 static unsigned int ref925x_pin_configs[8] = {
1652 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1653 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1656 static unsigned int stac925xM1_pin_configs[8] = {
1657 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1658 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1661 static unsigned int stac925xM1_2_pin_configs[8] = {
1662 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1663 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1666 static unsigned int stac925xM2_pin_configs[8] = {
1667 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1668 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1671 static unsigned int stac925xM2_2_pin_configs[8] = {
1672 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1673 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1676 static unsigned int stac925xM3_pin_configs[8] = {
1677 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1678 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1681 static unsigned int stac925xM5_pin_configs[8] = {
1682 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1683 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1686 static unsigned int stac925xM6_pin_configs[8] = {
1687 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1688 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1691 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1692 [STAC_REF] = ref925x_pin_configs,
1693 [STAC_M1] = stac925xM1_pin_configs,
1694 [STAC_M1_2] = stac925xM1_2_pin_configs,
1695 [STAC_M2] = stac925xM2_pin_configs,
1696 [STAC_M2_2] = stac925xM2_2_pin_configs,
1697 [STAC_M3] = stac925xM3_pin_configs,
1698 [STAC_M5] = stac925xM5_pin_configs,
1699 [STAC_M6] = stac925xM6_pin_configs,
1702 static const char *stac925x_models[STAC_925x_MODELS] = {
1703 [STAC_925x_AUTO] = "auto",
1706 [STAC_M1_2] = "m1-2",
1708 [STAC_M2_2] = "m2-2",
1714 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1715 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1716 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1717 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1718 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1719 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1720 /* Not sure about the brand name for those */
1721 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1722 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1723 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1724 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1728 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1729 /* SigmaTel reference board */
1730 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1731 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1732 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1734 /* Default table for unknown ID */
1735 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1740 static unsigned int ref92hd73xx_pin_configs[13] = {
1741 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1742 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1743 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1747 static unsigned int dell_m6_pin_configs[13] = {
1748 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1749 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1750 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1754 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1755 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1756 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1757 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1758 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1759 [STAC_DELL_EQ] = dell_m6_pin_configs,
1762 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1763 [STAC_92HD73XX_AUTO] = "auto",
1764 [STAC_92HD73XX_NO_JD] = "no-jd",
1765 [STAC_92HD73XX_REF] = "ref",
1766 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1767 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1768 [STAC_DELL_M6_BOTH] = "dell-m6",
1769 [STAC_DELL_EQ] = "dell-eq",
1772 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1773 /* SigmaTel reference board */
1774 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1775 "DFI LanParty", STAC_92HD73XX_REF),
1776 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1777 "DFI LanParty", STAC_92HD73XX_REF),
1778 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1779 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1780 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1781 "unknown Dell", STAC_DELL_M6_DMIC),
1782 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1783 "unknown Dell", STAC_DELL_M6_BOTH),
1784 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1785 "unknown Dell", STAC_DELL_M6_BOTH),
1786 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1787 "unknown Dell", STAC_DELL_M6_AMIC),
1788 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1789 "unknown Dell", STAC_DELL_M6_AMIC),
1790 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1791 "unknown Dell", STAC_DELL_M6_DMIC),
1792 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1793 "unknown Dell", STAC_DELL_M6_DMIC),
1794 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1795 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1796 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1797 "Dell Studio 17", STAC_DELL_M6_DMIC),
1801 static unsigned int ref92hd83xxx_pin_configs[10] = {
1802 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1803 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1804 0x01451160, 0x98560170,
1807 static unsigned int dell_s14_pin_configs[10] = {
1808 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1809 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1810 0x40f000f0, 0x40f000f0,
1813 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1814 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1815 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1816 [STAC_DELL_S14] = dell_s14_pin_configs,
1819 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1820 [STAC_92HD83XXX_AUTO] = "auto",
1821 [STAC_92HD83XXX_REF] = "ref",
1822 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1823 [STAC_DELL_S14] = "dell-s14",
1826 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1827 /* SigmaTel reference board */
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1829 "DFI LanParty", STAC_92HD83XXX_REF),
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1831 "DFI LanParty", STAC_92HD83XXX_REF),
1832 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1833 "unknown Dell", STAC_DELL_S14),
1837 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1838 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1839 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1840 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1844 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1845 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1846 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1847 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1851 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1852 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1853 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1854 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1858 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1859 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1860 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1861 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1865 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1866 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1867 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1868 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1869 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1870 [STAC_HP_M4] = NULL,
1871 [STAC_HP_DV5] = NULL,
1872 [STAC_HP_HDX] = NULL,
1873 [STAC_HP_DV4_1222NR] = NULL,
1876 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1877 [STAC_92HD71BXX_AUTO] = "auto",
1878 [STAC_92HD71BXX_REF] = "ref",
1879 [STAC_DELL_M4_1] = "dell-m4-1",
1880 [STAC_DELL_M4_2] = "dell-m4-2",
1881 [STAC_DELL_M4_3] = "dell-m4-3",
1882 [STAC_HP_M4] = "hp-m4",
1883 [STAC_HP_DV5] = "hp-dv5",
1884 [STAC_HP_HDX] = "hp-hdx",
1885 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1888 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1889 /* SigmaTel reference board */
1890 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1891 "DFI LanParty", STAC_92HD71BXX_REF),
1892 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1893 "DFI LanParty", STAC_92HD71BXX_REF),
1894 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1895 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1896 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1898 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1899 "HP dv4-7", STAC_HP_DV5),
1900 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1901 "HP dv4-7", STAC_HP_DV5),
1902 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1903 "HP HDX", STAC_HP_HDX), /* HDX18 */
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1905 "HP mini 1000", STAC_HP_M4),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1907 "HP HDX", STAC_HP_HDX), /* HDX16 */
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1909 "unknown Dell", STAC_DELL_M4_1),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1911 "unknown Dell", STAC_DELL_M4_1),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1913 "unknown Dell", STAC_DELL_M4_1),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1915 "unknown Dell", STAC_DELL_M4_1),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1917 "unknown Dell", STAC_DELL_M4_1),
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1919 "unknown Dell", STAC_DELL_M4_1),
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1921 "unknown Dell", STAC_DELL_M4_1),
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1923 "unknown Dell", STAC_DELL_M4_2),
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1925 "unknown Dell", STAC_DELL_M4_2),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1927 "unknown Dell", STAC_DELL_M4_2),
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1929 "unknown Dell", STAC_DELL_M4_2),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1931 "unknown Dell", STAC_DELL_M4_3),
1935 static unsigned int ref922x_pin_configs[10] = {
1936 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1937 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1938 0x40000100, 0x40000100,
1942 STAC 922X pin configs for
1949 static unsigned int dell_922x_d81_pin_configs[10] = {
1950 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1951 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1952 0x01813122, 0x400001f2,
1956 STAC 922X pin configs for
1960 static unsigned int dell_922x_d82_pin_configs[10] = {
1961 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1962 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1963 0x01813122, 0x400001f1,
1967 STAC 922X pin configs for
1970 static unsigned int dell_922x_m81_pin_configs[10] = {
1971 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1972 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1973 0x40C003f1, 0x405003f0,
1977 STAC 9221 A1 pin configs for
1978 102801D7 (Dell XPS M1210)
1980 static unsigned int dell_922x_m82_pin_configs[10] = {
1981 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1982 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1983 0x508003f3, 0x405003f4,
1986 static unsigned int d945gtp3_pin_configs[10] = {
1987 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1988 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1989 0x02a19120, 0x40000100,
1992 static unsigned int d945gtp5_pin_configs[10] = {
1993 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1994 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1995 0x02a19320, 0x40000100,
1998 static unsigned int intel_mac_v1_pin_configs[10] = {
1999 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
2000 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
2001 0x400000fc, 0x400000fb,
2004 static unsigned int intel_mac_v2_pin_configs[10] = {
2005 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2006 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
2007 0x400000fc, 0x400000fb,
2010 static unsigned int intel_mac_v3_pin_configs[10] = {
2011 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2012 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
2013 0x400000fc, 0x400000fb,
2016 static unsigned int intel_mac_v4_pin_configs[10] = {
2017 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2018 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2019 0x400000fc, 0x400000fb,
2022 static unsigned int intel_mac_v5_pin_configs[10] = {
2023 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2024 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2025 0x400000fc, 0x400000fb,
2028 static unsigned int ecs202_pin_configs[10] = {
2029 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
2030 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
2031 0x9037012e, 0x40e000f2,
2034 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
2035 [STAC_D945_REF] = ref922x_pin_configs,
2036 [STAC_D945GTP3] = d945gtp3_pin_configs,
2037 [STAC_D945GTP5] = d945gtp5_pin_configs,
2038 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
2039 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
2040 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
2041 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
2042 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
2043 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
2044 /* for backward compatibility */
2045 [STAC_MACMINI] = intel_mac_v3_pin_configs,
2046 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
2047 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
2048 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
2049 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
2050 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
2051 [STAC_ECS_202] = ecs202_pin_configs,
2052 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
2053 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
2054 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
2055 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
2058 static const char *stac922x_models[STAC_922X_MODELS] = {
2059 [STAC_922X_AUTO] = "auto",
2060 [STAC_D945_REF] = "ref",
2061 [STAC_D945GTP5] = "5stack",
2062 [STAC_D945GTP3] = "3stack",
2063 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
2064 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
2065 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
2066 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
2067 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
2068 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
2069 /* for backward compatibility */
2070 [STAC_MACMINI] = "macmini",
2071 [STAC_MACBOOK] = "macbook",
2072 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2073 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
2074 [STAC_IMAC_INTEL] = "imac-intel",
2075 [STAC_IMAC_INTEL_20] = "imac-intel-20",
2076 [STAC_ECS_202] = "ecs202",
2077 [STAC_922X_DELL_D81] = "dell-d81",
2078 [STAC_922X_DELL_D82] = "dell-d82",
2079 [STAC_922X_DELL_M81] = "dell-m81",
2080 [STAC_922X_DELL_M82] = "dell-m82",
2083 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2084 /* SigmaTel reference board */
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2086 "DFI LanParty", STAC_D945_REF),
2087 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2088 "DFI LanParty", STAC_D945_REF),
2089 /* Intel 945G based systems */
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2091 "Intel D945G", STAC_D945GTP3),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2093 "Intel D945G", STAC_D945GTP3),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2095 "Intel D945G", STAC_D945GTP3),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2097 "Intel D945G", STAC_D945GTP3),
2098 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2099 "Intel D945G", STAC_D945GTP3),
2100 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2101 "Intel D945G", STAC_D945GTP3),
2102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2103 "Intel D945G", STAC_D945GTP3),
2104 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2105 "Intel D945G", STAC_D945GTP3),
2106 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2107 "Intel D945G", STAC_D945GTP3),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2109 "Intel D945G", STAC_D945GTP3),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2111 "Intel D945G", STAC_D945GTP3),
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2113 "Intel D945G", STAC_D945GTP3),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2115 "Intel D945G", STAC_D945GTP3),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2117 "Intel D945G", STAC_D945GTP3),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2119 "Intel D945G", STAC_D945GTP3),
2120 /* Intel D945G 5-stack systems */
2121 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2122 "Intel D945G", STAC_D945GTP5),
2123 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2124 "Intel D945G", STAC_D945GTP5),
2125 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2126 "Intel D945G", STAC_D945GTP5),
2127 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2128 "Intel D945G", STAC_D945GTP5),
2129 /* Intel 945P based systems */
2130 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2131 "Intel D945P", STAC_D945GTP3),
2132 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2133 "Intel D945P", STAC_D945GTP3),
2134 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2135 "Intel D945P", STAC_D945GTP3),
2136 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2137 "Intel D945P", STAC_D945GTP3),
2138 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2139 "Intel D945P", STAC_D945GTP3),
2140 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2141 "Intel D945P", STAC_D945GTP5),
2143 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2144 "Intel D945", STAC_D945_REF),
2146 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2147 SND_PCI_QUIRK(0x8384, 0x7680,
2148 "Mac", STAC_INTEL_MAC_AUTO),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2151 "unknown Dell", STAC_922X_DELL_D81),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2153 "unknown Dell", STAC_922X_DELL_D81),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2155 "unknown Dell", STAC_922X_DELL_D81),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2157 "unknown Dell", STAC_922X_DELL_D82),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2159 "unknown Dell", STAC_922X_DELL_M81),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2161 "unknown Dell", STAC_922X_DELL_D82),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2163 "unknown Dell", STAC_922X_DELL_D81),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2165 "unknown Dell", STAC_922X_DELL_D81),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2167 "Dell XPS M1210", STAC_922X_DELL_M82),
2168 /* ECS/PC Chips boards */
2169 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2170 "ECS/PC chips", STAC_ECS_202),
2174 static unsigned int ref927x_pin_configs[14] = {
2175 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2176 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2177 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2178 0x01c42190, 0x40000100,
2181 static unsigned int d965_3st_pin_configs[14] = {
2182 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2183 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2184 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2185 0x40000100, 0x40000100
2188 static unsigned int d965_5st_pin_configs[14] = {
2189 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2190 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2191 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2192 0x40000100, 0x40000100
2195 static unsigned int d965_5st_no_fp_pin_configs[14] = {
2196 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2197 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2198 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2199 0x40000100, 0x40000100
2202 static unsigned int dell_3st_pin_configs[14] = {
2203 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2204 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2205 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2206 0x40c003fc, 0x40000100
2209 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2210 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2211 [STAC_D965_REF] = ref927x_pin_configs,
2212 [STAC_D965_3ST] = d965_3st_pin_configs,
2213 [STAC_D965_5ST] = d965_5st_pin_configs,
2214 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2215 [STAC_DELL_3ST] = dell_3st_pin_configs,
2216 [STAC_DELL_BIOS] = NULL,
2219 static const char *stac927x_models[STAC_927X_MODELS] = {
2220 [STAC_927X_AUTO] = "auto",
2221 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2222 [STAC_D965_REF] = "ref",
2223 [STAC_D965_3ST] = "3stack",
2224 [STAC_D965_5ST] = "5stack",
2225 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2226 [STAC_DELL_3ST] = "dell-3stack",
2227 [STAC_DELL_BIOS] = "dell-bios",
2230 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2231 /* SigmaTel reference board */
2232 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2233 "DFI LanParty", STAC_D965_REF),
2234 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2235 "DFI LanParty", STAC_D965_REF),
2236 /* Intel 946 based systems */
2237 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2238 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2239 /* 965 based 3 stack systems */
2240 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2241 "Intel D965", STAC_D965_3ST),
2242 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2243 "Intel D965", STAC_D965_3ST),
2244 /* Dell 3 stack systems */
2245 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2246 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2247 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2248 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2249 /* Dell 3 stack systems with verb table in BIOS */
2250 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2251 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2252 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2253 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2254 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2255 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2256 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2257 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2258 /* 965 based 5 stack systems */
2259 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2260 "Intel D965", STAC_D965_5ST),
2261 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2262 "Intel D965", STAC_D965_5ST),
2266 static unsigned int ref9205_pin_configs[12] = {
2267 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2268 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2269 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2273 STAC 9205 pin configs for
2280 10280228 (Dell Vostro 1500)
2282 static unsigned int dell_9205_m42_pin_configs[12] = {
2283 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2284 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2285 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2289 STAC 9205 pin configs for
2293 102801FF (Dell Precision M4300)
2298 static unsigned int dell_9205_m43_pin_configs[12] = {
2299 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2300 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2301 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2304 static unsigned int dell_9205_m44_pin_configs[12] = {
2305 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2306 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2307 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2310 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2311 [STAC_9205_REF] = ref9205_pin_configs,
2312 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2313 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2314 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2315 [STAC_9205_EAPD] = NULL,
2318 static const char *stac9205_models[STAC_9205_MODELS] = {
2319 [STAC_9205_AUTO] = "auto",
2320 [STAC_9205_REF] = "ref",
2321 [STAC_9205_DELL_M42] = "dell-m42",
2322 [STAC_9205_DELL_M43] = "dell-m43",
2323 [STAC_9205_DELL_M44] = "dell-m44",
2324 [STAC_9205_EAPD] = "eapd",
2327 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2328 /* SigmaTel reference board */
2329 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2330 "DFI LanParty", STAC_9205_REF),
2331 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2332 "SigmaTel", STAC_9205_REF),
2333 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2334 "DFI LanParty", STAC_9205_REF),
2336 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2337 "unknown Dell", STAC_9205_DELL_M42),
2338 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2339 "unknown Dell", STAC_9205_DELL_M42),
2340 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2341 "Dell Precision", STAC_9205_DELL_M43),
2342 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2343 "Dell Precision", STAC_9205_DELL_M43),
2344 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2345 "Dell Precision", STAC_9205_DELL_M43),
2346 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2347 "unknown Dell", STAC_9205_DELL_M42),
2348 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2349 "unknown Dell", STAC_9205_DELL_M42),
2350 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2351 "Dell Precision", STAC_9205_DELL_M43),
2352 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2353 "Dell Precision M4300", STAC_9205_DELL_M43),
2354 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2355 "unknown Dell", STAC_9205_DELL_M42),
2356 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2357 "Dell Precision", STAC_9205_DELL_M43),
2358 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2359 "Dell Precision", STAC_9205_DELL_M43),
2360 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2361 "Dell Precision", STAC_9205_DELL_M43),
2362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2363 "Dell Inspiron", STAC_9205_DELL_M44),
2364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2365 "Dell Vostro 1500", STAC_9205_DELL_M42),
2367 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2368 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2372 static void stac92xx_set_config_regs(struct hda_codec *codec,
2373 unsigned int *pincfgs)
2376 struct sigmatel_spec *spec = codec->spec;
2381 for (i = 0; i < spec->num_pins; i++)
2382 if (spec->pin_nids[i] && pincfgs[i])
2383 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2388 * Analog playback callbacks
2390 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2391 struct hda_codec *codec,
2392 struct snd_pcm_substream *substream)
2394 struct sigmatel_spec *spec = codec->spec;
2395 if (spec->stream_delay)
2396 msleep(spec->stream_delay);
2397 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2401 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2402 struct hda_codec *codec,
2403 unsigned int stream_tag,
2404 unsigned int format,
2405 struct snd_pcm_substream *substream)
2407 struct sigmatel_spec *spec = codec->spec;
2408 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2411 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2412 struct hda_codec *codec,
2413 struct snd_pcm_substream *substream)
2415 struct sigmatel_spec *spec = codec->spec;
2416 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2420 * Digital playback callbacks
2422 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2423 struct hda_codec *codec,
2424 struct snd_pcm_substream *substream)
2426 struct sigmatel_spec *spec = codec->spec;
2427 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2430 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2431 struct hda_codec *codec,
2432 struct snd_pcm_substream *substream)
2434 struct sigmatel_spec *spec = codec->spec;
2435 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2438 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2439 struct hda_codec *codec,
2440 unsigned int stream_tag,
2441 unsigned int format,
2442 struct snd_pcm_substream *substream)
2444 struct sigmatel_spec *spec = codec->spec;
2445 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2446 stream_tag, format, substream);
2449 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2450 struct hda_codec *codec,
2451 struct snd_pcm_substream *substream)
2453 struct sigmatel_spec *spec = codec->spec;
2454 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2459 * Analog capture callbacks
2461 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2462 struct hda_codec *codec,
2463 unsigned int stream_tag,
2464 unsigned int format,
2465 struct snd_pcm_substream *substream)
2467 struct sigmatel_spec *spec = codec->spec;
2468 hda_nid_t nid = spec->adc_nids[substream->number];
2470 if (spec->powerdown_adcs) {
2472 snd_hda_codec_write(codec, nid, 0,
2473 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2475 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2479 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2480 struct hda_codec *codec,
2481 struct snd_pcm_substream *substream)
2483 struct sigmatel_spec *spec = codec->spec;
2484 hda_nid_t nid = spec->adc_nids[substream->number];
2486 snd_hda_codec_cleanup_stream(codec, nid);
2487 if (spec->powerdown_adcs)
2488 snd_hda_codec_write(codec, nid, 0,
2489 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2493 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2497 /* NID is set in stac92xx_build_pcms */
2499 .open = stac92xx_dig_playback_pcm_open,
2500 .close = stac92xx_dig_playback_pcm_close,
2501 .prepare = stac92xx_dig_playback_pcm_prepare,
2502 .cleanup = stac92xx_dig_playback_pcm_cleanup
2506 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2510 /* NID is set in stac92xx_build_pcms */
2513 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2517 .nid = 0x02, /* NID to query formats and rates */
2519 .open = stac92xx_playback_pcm_open,
2520 .prepare = stac92xx_playback_pcm_prepare,
2521 .cleanup = stac92xx_playback_pcm_cleanup
2525 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2529 .nid = 0x06, /* NID to query formats and rates */
2531 .open = stac92xx_playback_pcm_open,
2532 .prepare = stac92xx_playback_pcm_prepare,
2533 .cleanup = stac92xx_playback_pcm_cleanup
2537 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2540 /* NID + .substreams is set in stac92xx_build_pcms */
2542 .prepare = stac92xx_capture_pcm_prepare,
2543 .cleanup = stac92xx_capture_pcm_cleanup
2547 static int stac92xx_build_pcms(struct hda_codec *codec)
2549 struct sigmatel_spec *spec = codec->spec;
2550 struct hda_pcm *info = spec->pcm_rec;
2552 codec->num_pcms = 1;
2553 codec->pcm_info = info;
2555 info->name = "STAC92xx Analog";
2556 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2557 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2558 spec->multiout.dac_nids[0];
2559 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2560 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2561 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2563 if (spec->alt_switch) {
2566 info->name = "STAC92xx Analog Alt";
2567 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2570 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2573 info->name = "STAC92xx Digital";
2574 info->pcm_type = spec->autocfg.dig_out_type[0];
2575 if (spec->multiout.dig_out_nid) {
2576 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2577 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2579 if (spec->dig_in_nid) {
2580 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2581 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2588 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2591 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2592 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2593 if (pincap & AC_PINCAP_VREF_100)
2594 return AC_PINCTL_VREF_100;
2595 if (pincap & AC_PINCAP_VREF_80)
2596 return AC_PINCTL_VREF_80;
2597 if (pincap & AC_PINCAP_VREF_50)
2598 return AC_PINCTL_VREF_50;
2599 if (pincap & AC_PINCAP_VREF_GRD)
2600 return AC_PINCTL_VREF_GRD;
2604 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2607 snd_hda_codec_write_cache(codec, nid, 0,
2608 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2611 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2613 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2614 struct snd_ctl_elem_value *ucontrol)
2616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2617 struct sigmatel_spec *spec = codec->spec;
2619 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2623 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2624 unsigned char type);
2626 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2627 struct snd_ctl_elem_value *ucontrol)
2629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2630 struct sigmatel_spec *spec = codec->spec;
2631 int nid = kcontrol->private_value;
2633 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2635 /* check to be sure that the ports are upto date with
2638 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2643 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2644 struct snd_ctl_elem_info *uinfo)
2647 static char *texts[] = {
2648 "Mic In", "Line In", "Line Out"
2651 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2652 struct sigmatel_spec *spec = codec->spec;
2653 hda_nid_t nid = kcontrol->private_value;
2655 if (nid == spec->mic_switch || nid == spec->line_switch)
2660 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2661 uinfo->value.enumerated.items = i;
2663 if (uinfo->value.enumerated.item >= i)
2664 uinfo->value.enumerated.item = i-1;
2665 strcpy(uinfo->value.enumerated.name,
2666 texts[uinfo->value.enumerated.item]);
2671 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2672 struct snd_ctl_elem_value *ucontrol)
2674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2675 hda_nid_t nid = kcontrol->private_value;
2676 unsigned int vref = stac92xx_vref_get(codec, nid);
2678 if (vref == stac92xx_get_default_vref(codec, nid))
2679 ucontrol->value.enumerated.item[0] = 0;
2680 else if (vref == AC_PINCTL_VREF_GRD)
2681 ucontrol->value.enumerated.item[0] = 1;
2682 else if (vref == AC_PINCTL_VREF_HIZ)
2683 ucontrol->value.enumerated.item[0] = 2;
2688 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2689 struct snd_ctl_elem_value *ucontrol)
2691 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2692 unsigned int new_vref = 0;
2694 hda_nid_t nid = kcontrol->private_value;
2696 if (ucontrol->value.enumerated.item[0] == 0)
2697 new_vref = stac92xx_get_default_vref(codec, nid);
2698 else if (ucontrol->value.enumerated.item[0] == 1)
2699 new_vref = AC_PINCTL_VREF_GRD;
2700 else if (ucontrol->value.enumerated.item[0] == 2)
2701 new_vref = AC_PINCTL_VREF_HIZ;
2705 if (new_vref != stac92xx_vref_get(codec, nid)) {
2706 error = stac92xx_vref_set(codec, nid, new_vref);
2713 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2714 struct snd_ctl_elem_info *uinfo)
2716 static char *texts[2];
2717 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2718 struct sigmatel_spec *spec = codec->spec;
2720 if (kcontrol->private_value == spec->line_switch)
2721 texts[0] = "Line In";
2723 texts[0] = "Mic In";
2724 texts[1] = "Line Out";
2725 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2726 uinfo->value.enumerated.items = 2;
2729 if (uinfo->value.enumerated.item >= 2)
2730 uinfo->value.enumerated.item = 1;
2731 strcpy(uinfo->value.enumerated.name,
2732 texts[uinfo->value.enumerated.item]);
2737 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2739 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2740 struct sigmatel_spec *spec = codec->spec;
2741 hda_nid_t nid = kcontrol->private_value;
2742 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2744 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2748 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2750 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2751 struct sigmatel_spec *spec = codec->spec;
2752 hda_nid_t nid = kcontrol->private_value;
2753 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2754 unsigned short val = !!ucontrol->value.enumerated.item[0];
2756 spec->io_switch[io_idx] = val;
2759 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2761 unsigned int pinctl = AC_PINCTL_IN_EN;
2762 if (io_idx) /* set VREF for mic */
2763 pinctl |= stac92xx_get_default_vref(codec, nid);
2764 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2767 /* check the auto-mute again: we need to mute/unmute the speaker
2768 * appropriately according to the pin direction
2770 if (spec->hp_detect)
2771 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2776 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2778 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2779 struct snd_ctl_elem_value *ucontrol)
2781 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2782 struct sigmatel_spec *spec = codec->spec;
2784 ucontrol->value.integer.value[0] = spec->clfe_swap;
2788 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2789 struct snd_ctl_elem_value *ucontrol)
2791 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2792 struct sigmatel_spec *spec = codec->spec;
2793 hda_nid_t nid = kcontrol->private_value & 0xff;
2794 unsigned int val = !!ucontrol->value.integer.value[0];
2796 if (spec->clfe_swap == val)
2799 spec->clfe_swap = val;
2801 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2802 spec->clfe_swap ? 0x4 : 0x0);
2807 #define STAC_CODEC_HP_SWITCH(xname) \
2808 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2811 .info = stac92xx_hp_switch_info, \
2812 .get = stac92xx_hp_switch_get, \
2813 .put = stac92xx_hp_switch_put, \
2816 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2817 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2820 .info = stac92xx_io_switch_info, \
2821 .get = stac92xx_io_switch_get, \
2822 .put = stac92xx_io_switch_put, \
2823 .private_value = xpval, \
2826 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2827 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2830 .info = stac92xx_clfe_switch_info, \
2831 .get = stac92xx_clfe_switch_get, \
2832 .put = stac92xx_clfe_switch_put, \
2833 .private_value = xpval, \
2837 STAC_CTL_WIDGET_VOL,
2838 STAC_CTL_WIDGET_MUTE,
2839 STAC_CTL_WIDGET_MONO_MUX,
2840 STAC_CTL_WIDGET_AMP_MUX,
2841 STAC_CTL_WIDGET_AMP_VOL,
2842 STAC_CTL_WIDGET_HP_SWITCH,
2843 STAC_CTL_WIDGET_IO_SWITCH,
2844 STAC_CTL_WIDGET_CLFE_SWITCH,
2845 STAC_CTL_WIDGET_DC_BIAS
2848 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2849 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2850 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2853 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2854 STAC_CODEC_HP_SWITCH(NULL),
2855 STAC_CODEC_IO_SWITCH(NULL, 0),
2856 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2857 DC_BIAS(NULL, 0, 0),
2860 /* add dynamic controls */
2861 static struct snd_kcontrol_new *
2862 stac_control_new(struct sigmatel_spec *spec,
2863 struct snd_kcontrol_new *ktemp,
2866 struct snd_kcontrol_new *knew;
2868 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2869 knew = snd_array_new(&spec->kctls);
2873 knew->name = kstrdup(name, GFP_KERNEL);
2876 memset(knew, 0, sizeof(*knew));
2877 spec->kctls.alloced--;
2883 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2884 struct snd_kcontrol_new *ktemp,
2885 int idx, const char *name,
2888 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2892 knew->private_value = val;
2896 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2897 int type, int idx, const char *name,
2900 return stac92xx_add_control_temp(spec,
2901 &stac92xx_control_templates[type],
2906 /* add dynamic controls */
2907 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2908 const char *name, unsigned long val)
2910 return stac92xx_add_control_idx(spec, type, 0, name, val);
2913 static struct snd_kcontrol_new stac_input_src_temp = {
2914 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2915 .name = "Input Source",
2916 .info = stac92xx_mux_enum_info,
2917 .get = stac92xx_mux_enum_get,
2918 .put = stac92xx_mux_enum_put,
2921 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2922 hda_nid_t nid, int idx)
2924 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2926 struct sigmatel_spec *spec = codec->spec;
2929 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2930 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2931 && nid == spec->line_switch)
2932 control = STAC_CTL_WIDGET_IO_SWITCH;
2933 else if (snd_hda_query_pin_caps(codec, nid)
2934 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2935 control = STAC_CTL_WIDGET_DC_BIAS;
2936 else if (nid == spec->mic_switch)
2937 control = STAC_CTL_WIDGET_IO_SWITCH;
2941 strcpy(name, auto_pin_cfg_labels[idx]);
2942 return stac92xx_add_control(codec->spec, control,
2943 strcat(name, " Jack Mode"), nid);
2949 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2951 struct snd_kcontrol_new *knew;
2952 struct hda_input_mux *imux = &spec->private_imux;
2954 if (!spec->num_adcs || imux->num_items <= 1)
2955 return 0; /* no need for input source control */
2956 knew = stac_control_new(spec, &stac_input_src_temp,
2957 stac_input_src_temp.name);
2960 knew->count = spec->num_adcs;
2964 /* check whether the line-input can be used as line-out */
2965 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2967 struct sigmatel_spec *spec = codec->spec;
2968 struct auto_pin_cfg *cfg = &spec->autocfg;
2970 unsigned int pincap;
2972 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2974 nid = cfg->input_pins[AUTO_PIN_LINE];
2975 pincap = snd_hda_query_pin_caps(codec, nid);
2976 if (pincap & AC_PINCAP_OUT)
2981 /* check whether the mic-input can be used as line-out */
2982 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2984 struct sigmatel_spec *spec = codec->spec;
2985 struct auto_pin_cfg *cfg = &spec->autocfg;
2986 unsigned int def_conf, pincap;
2987 unsigned int mic_pin;
2989 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2991 mic_pin = AUTO_PIN_MIC;
2993 hda_nid_t nid = cfg->input_pins[mic_pin];
2994 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2995 /* some laptops have an internal analog microphone
2996 * which can't be used as a output */
2997 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2998 pincap = snd_hda_query_pin_caps(codec, nid);
2999 if (pincap & AC_PINCAP_OUT)
3002 if (mic_pin == AUTO_PIN_MIC)
3003 mic_pin = AUTO_PIN_FRONT_MIC;
3010 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3014 for (i = 0; i < spec->multiout.num_dacs; i++) {
3015 if (spec->multiout.dac_nids[i] == nid)
3022 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
3025 if (is_in_dac_nids(spec, nid))
3027 for (i = 0; i < spec->autocfg.hp_outs; i++)
3028 if (spec->hp_dacs[i] == nid)
3030 for (i = 0; i < spec->autocfg.speaker_outs; i++)
3031 if (spec->speaker_dacs[i] == nid)
3036 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
3038 struct sigmatel_spec *spec = codec->spec;
3040 hda_nid_t conn[HDA_MAX_CONNECTIONS];
3041 unsigned int wcaps, wtype;
3043 conn_len = snd_hda_get_connections(codec, nid, conn,
3044 HDA_MAX_CONNECTIONS);
3045 for (j = 0; j < conn_len; j++) {
3046 wcaps = get_wcaps(codec, conn[j]);
3047 wtype = get_wcaps_type(wcaps);
3048 /* we check only analog outputs */
3049 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
3051 /* if this route has a free DAC, assign it */
3052 if (!check_all_dac_nids(spec, conn[j])) {
3054 /* select this DAC in the pin's input mux */
3055 snd_hda_codec_write_cache(codec, nid, 0,
3056 AC_VERB_SET_CONNECT_SEL, j);
3061 /* if all DACs are already assigned, connect to the primary DAC */
3063 for (j = 0; j < conn_len; j++) {
3064 if (conn[j] == spec->multiout.dac_nids[0]) {
3065 snd_hda_codec_write_cache(codec, nid, 0,
3066 AC_VERB_SET_CONNECT_SEL, j);
3074 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3075 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3078 * Fill in the dac_nids table from the parsed pin configuration
3079 * This function only works when every pin in line_out_pins[]
3080 * contains atleast one DAC in its connection list. Some 92xx
3081 * codecs are not connected directly to a DAC, such as the 9200
3082 * and 9202/925x. For those, dac_nids[] must be hard-coded.
3084 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
3086 struct sigmatel_spec *spec = codec->spec;
3087 struct auto_pin_cfg *cfg = &spec->autocfg;
3091 for (i = 0; i < cfg->line_outs; i++) {
3092 nid = cfg->line_out_pins[i];
3093 dac = get_unassigned_dac(codec, nid);
3095 if (spec->multiout.num_dacs > 0) {
3096 /* we have already working output pins,
3097 * so let's drop the broken ones again
3099 cfg->line_outs = spec->multiout.num_dacs;
3102 /* error out, no available DAC found */
3104 "%s: No available DAC for pin 0x%x\n",
3108 add_spec_dacs(spec, dac);
3111 for (i = 0; i < cfg->hp_outs; i++) {
3112 nid = cfg->hp_pins[i];
3113 dac = get_unassigned_dac(codec, nid);
3115 if (!spec->multiout.hp_nid)
3116 spec->multiout.hp_nid = dac;
3118 add_spec_extra_dacs(spec, dac);
3120 spec->hp_dacs[i] = dac;
3123 for (i = 0; i < cfg->speaker_outs; i++) {
3124 nid = cfg->speaker_pins[i];
3125 dac = get_unassigned_dac(codec, nid);
3127 add_spec_extra_dacs(spec, dac);
3128 spec->speaker_dacs[i] = dac;
3131 /* add line-in as output */
3132 nid = check_line_out_switch(codec);
3134 dac = get_unassigned_dac(codec, nid);
3136 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3137 nid, cfg->line_outs);
3138 cfg->line_out_pins[cfg->line_outs] = nid;
3140 spec->line_switch = nid;
3141 add_spec_dacs(spec, dac);
3144 /* add mic as output */
3145 nid = check_mic_out_switch(codec);
3147 dac = get_unassigned_dac(codec, nid);
3149 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3150 nid, cfg->line_outs);
3151 cfg->line_out_pins[cfg->line_outs] = nid;
3153 spec->mic_switch = nid;
3154 add_spec_dacs(spec, dac);
3158 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3159 spec->multiout.num_dacs,
3160 spec->multiout.dac_nids[0],
3161 spec->multiout.dac_nids[1],
3162 spec->multiout.dac_nids[2],
3163 spec->multiout.dac_nids[3],
3164 spec->multiout.dac_nids[4]);
3169 /* create volume control/switch for the given prefx type */
3170 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3171 int idx, hda_nid_t nid, int chs)
3173 struct sigmatel_spec *spec = codec->spec;
3177 if (!spec->check_volume_offset) {
3178 unsigned int caps, step, nums, db_scale;
3179 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3180 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3181 AC_AMPCAP_STEP_SIZE_SHIFT;
3182 step = (step + 1) * 25; /* in .01dB unit */
3183 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3184 AC_AMPCAP_NUM_STEPS_SHIFT;
3185 db_scale = nums * step;
3186 /* if dB scale is over -64dB, and finer enough,
3187 * let's reduce it to half
3189 if (db_scale > 6400 && nums >= 0x1f)
3190 spec->volume_offset = nums / 2;
3191 spec->check_volume_offset = 1;
3194 sprintf(name, "%s Playback Volume", pfx);
3195 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
3196 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3197 spec->volume_offset));
3200 sprintf(name, "%s Playback Switch", pfx);
3201 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
3202 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3208 #define create_controls(codec, pfx, nid, chs) \
3209 create_controls_idx(codec, pfx, 0, nid, chs)
3211 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3213 if (spec->multiout.num_dacs > 4) {
3214 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3217 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3218 spec->multiout.num_dacs++;
3223 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3226 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3227 if (!spec->multiout.extra_out_nid[i]) {
3228 spec->multiout.extra_out_nid[i] = nid;
3232 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3236 /* Create output controls
3237 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3239 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3240 const hda_nid_t *pins,
3241 const hda_nid_t *dac_nids,
3244 struct sigmatel_spec *spec = codec->spec;
3245 static const char *chname[4] = {
3246 "Front", "Surround", NULL /*CLFE*/, "Side"
3250 unsigned int wid_caps;
3252 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3253 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3254 wid_caps = get_wcaps(codec, pins[i]);
3255 if (wid_caps & AC_WCAP_UNSOL_CAP)
3256 spec->hp_detect = 1;
3261 if (type != AUTO_PIN_HP_OUT && i == 2) {
3263 err = create_controls(codec, "Center", nid, 1);
3266 err = create_controls(codec, "LFE", nid, 2);
3270 wid_caps = get_wcaps(codec, nid);
3272 if (wid_caps & AC_WCAP_LR_SWAP) {
3273 err = stac92xx_add_control(spec,
3274 STAC_CTL_WIDGET_CLFE_SWITCH,
3275 "Swap Center/LFE Playback Switch", nid);
3285 case AUTO_PIN_HP_OUT:
3289 case AUTO_PIN_SPEAKER_OUT:
3298 err = create_controls_idx(codec, name, idx, nid, 3);
3306 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3307 unsigned long sw, int idx)
3310 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3311 "Captuer Volume", vol);
3314 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3315 "Captuer Switch", sw);
3321 /* add playback controls from the parsed DAC table */
3322 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3323 const struct auto_pin_cfg *cfg)
3325 struct sigmatel_spec *spec = codec->spec;
3330 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3331 spec->multiout.dac_nids,
3332 cfg->line_out_type);
3336 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3337 err = stac92xx_add_control(spec,
3338 STAC_CTL_WIDGET_HP_SWITCH,
3339 "Headphone as Line Out Switch",
3340 cfg->hp_pins[cfg->hp_outs - 1]);
3345 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3346 nid = cfg->input_pins[idx];
3348 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3357 /* add playback controls for Speaker and HP outputs */
3358 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3359 struct auto_pin_cfg *cfg)
3361 struct sigmatel_spec *spec = codec->spec;
3364 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3365 spec->hp_dacs, AUTO_PIN_HP_OUT);
3369 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3370 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3377 /* labels for mono mux outputs */
3378 static const char *stac92xx_mono_labels[4] = {
3379 "DAC0", "DAC1", "Mixer", "DAC2"
3382 /* create mono mux for mono out on capable codecs */
3383 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3385 struct sigmatel_spec *spec = codec->spec;
3386 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3388 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3390 num_cons = snd_hda_get_connections(codec,
3393 HDA_MAX_NUM_INPUTS);
3394 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3397 for (i = 0; i < num_cons; i++) {
3398 mono_mux->items[mono_mux->num_items].label =
3399 stac92xx_mono_labels[i];
3400 mono_mux->items[mono_mux->num_items].index = i;
3401 mono_mux->num_items++;
3404 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3405 "Mono Mux", spec->mono_nid);
3408 /* labels for amp mux outputs */
3409 static const char *stac92xx_amp_labels[3] = {
3410 "Front Microphone", "Microphone", "Line In",
3413 /* create amp out controls mux on capable codecs */
3414 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3416 struct sigmatel_spec *spec = codec->spec;
3417 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3420 for (i = 0; i < spec->num_amps; i++) {
3421 amp_mux->items[amp_mux->num_items].label =
3422 stac92xx_amp_labels[i];
3423 amp_mux->items[amp_mux->num_items].index = i;
3424 amp_mux->num_items++;
3427 if (spec->num_amps > 1) {
3428 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3429 "Amp Selector Capture Switch", 0);
3433 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3434 "Amp Capture Volume",
3435 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3439 /* create PC beep volume controls */
3440 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3443 struct sigmatel_spec *spec = codec->spec;
3444 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3447 /* check for mute support for the the amp */
3448 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3449 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3450 "PC Beep Playback Switch",
3451 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3456 /* check to see if there is volume support for the amp */
3457 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3458 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3459 "PC Beep Playback Volume",
3460 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3467 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3468 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3470 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3471 struct snd_ctl_elem_value *ucontrol)
3473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3474 ucontrol->value.integer.value[0] = codec->beep->enabled;
3478 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3479 struct snd_ctl_elem_value *ucontrol)
3481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3482 int enabled = !!ucontrol->value.integer.value[0];
3483 if (codec->beep->enabled != enabled) {
3484 codec->beep->enabled = enabled;
3490 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3491 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3492 .info = stac92xx_dig_beep_switch_info,
3493 .get = stac92xx_dig_beep_switch_get,
3494 .put = stac92xx_dig_beep_switch_put,
3497 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3499 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3500 0, "PC Beep Playback Switch", 0);
3504 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3506 struct sigmatel_spec *spec = codec->spec;
3507 int wcaps, nid, i, err = 0;
3509 for (i = 0; i < spec->num_muxes; i++) {
3510 nid = spec->mux_nids[i];
3511 wcaps = get_wcaps(codec, nid);
3513 if (wcaps & AC_WCAP_OUT_AMP) {
3514 err = stac92xx_add_control_idx(spec,
3515 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3516 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3524 static const char *stac92xx_spdif_labels[3] = {
3525 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3528 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3530 struct sigmatel_spec *spec = codec->spec;
3531 struct hda_input_mux *spdif_mux = &spec->private_smux;
3532 const char **labels = spec->spdif_labels;
3534 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3536 num_cons = snd_hda_get_connections(codec,
3539 HDA_MAX_NUM_INPUTS);
3544 labels = stac92xx_spdif_labels;
3546 for (i = 0; i < num_cons; i++) {
3547 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3548 spdif_mux->items[spdif_mux->num_items].index = i;
3549 spdif_mux->num_items++;
3555 /* labels for dmic mux inputs */
3556 static const char *stac92xx_dmic_labels[5] = {
3557 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3558 "Digital Mic 3", "Digital Mic 4"
3561 /* create playback/capture controls for input pins on dmic capable codecs */
3562 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3563 const struct auto_pin_cfg *cfg)
3565 struct sigmatel_spec *spec = codec->spec;
3566 struct hda_input_mux *dimux = &spec->private_dimux;
3567 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3571 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3572 dimux->items[dimux->num_items].index = 0;
3575 for (i = 0; i < spec->num_dmics; i++) {
3580 unsigned int def_conf;
3582 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3583 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3586 nid = spec->dmic_nids[i];
3587 num_cons = snd_hda_get_connections(codec,
3590 HDA_MAX_NUM_INPUTS);
3591 for (j = 0; j < num_cons; j++)
3592 if (con_lst[j] == nid) {
3598 wcaps = get_wcaps(codec, nid) &
3599 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3602 sprintf(name, "%s Capture Volume",
3603 stac92xx_dmic_labels[dimux->num_items]);
3605 err = stac92xx_add_control(spec,
3606 STAC_CTL_WIDGET_VOL,
3608 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3609 (wcaps & AC_WCAP_OUT_AMP) ?
3610 HDA_OUTPUT : HDA_INPUT));
3615 dimux->items[dimux->num_items].label =
3616 stac92xx_dmic_labels[dimux->num_items];
3617 dimux->items[dimux->num_items].index = index;
3624 /* create playback/capture controls for input pins */
3625 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3627 struct sigmatel_spec *spec = codec->spec;
3628 struct hda_input_mux *imux = &spec->private_imux;
3629 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3632 for (i = 0; i < AUTO_PIN_LAST; i++) {
3635 if (!cfg->input_pins[i])
3638 for (j = 0; j < spec->num_muxes; j++) {
3640 num_cons = snd_hda_get_connections(codec,
3643 HDA_MAX_NUM_INPUTS);
3644 for (k = 0; k < num_cons; k++)
3645 if (con_lst[k] == cfg->input_pins[i]) {
3652 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3653 imux->items[imux->num_items].index = index;
3657 if (imux->num_items) {
3659 * Set the current input for the muxes.
3660 * The STAC9221 has two input muxes with identical source
3661 * NID lists. Hopefully this won't get confused.
3663 for (i = 0; i < spec->num_muxes; i++) {
3664 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3665 AC_VERB_SET_CONNECT_SEL,
3666 imux->items[0].index);
3673 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3675 struct sigmatel_spec *spec = codec->spec;
3678 for (i = 0; i < spec->autocfg.line_outs; i++) {
3679 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3680 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3684 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3686 struct sigmatel_spec *spec = codec->spec;
3689 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3691 pin = spec->autocfg.hp_pins[i];
3692 if (pin) /* connect to front */
3693 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3695 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3697 pin = spec->autocfg.speaker_pins[i];
3698 if (pin) /* connect to front */
3699 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3703 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3705 struct sigmatel_spec *spec = codec->spec;
3709 if ((err = snd_hda_parse_pin_def_config(codec,
3711 spec->dmic_nids)) < 0)
3713 if (! spec->autocfg.line_outs)
3714 return 0; /* can't find valid pin config */
3716 /* If we have no real line-out pin and multiple hp-outs, HPs should
3717 * be set up as multi-channel outputs.
3719 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3720 spec->autocfg.hp_outs > 1) {
3721 /* Copy hp_outs to line_outs, backup line_outs in
3722 * speaker_outs so that the following routines can handle
3723 * HP pins as primary outputs.
3725 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3726 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3727 sizeof(spec->autocfg.line_out_pins));
3728 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3729 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3730 sizeof(spec->autocfg.hp_pins));
3731 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3732 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3733 spec->autocfg.hp_outs = 0;
3736 if (spec->autocfg.mono_out_pin) {
3737 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3738 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3739 u32 caps = query_amp_caps(codec,
3740 spec->autocfg.mono_out_pin, dir);
3741 hda_nid_t conn_list[1];
3743 /* get the mixer node and then the mono mux if it exists */
3744 if (snd_hda_get_connections(codec,
3745 spec->autocfg.mono_out_pin, conn_list, 1) &&
3746 snd_hda_get_connections(codec, conn_list[0],
3747 conn_list, 1) > 0) {
3749 int wcaps = get_wcaps(codec, conn_list[0]);
3750 int wid_type = get_wcaps_type(wcaps);
3751 /* LR swap check, some stac925x have a mux that
3752 * changes the DACs output path instead of the
3755 if (wid_type == AC_WID_AUD_SEL &&
3756 !(wcaps & AC_WCAP_LR_SWAP))
3757 spec->mono_nid = conn_list[0];
3760 hda_nid_t nid = spec->autocfg.mono_out_pin;
3762 /* most mono outs have a least a mute/unmute switch */
3763 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3764 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3765 "Mono Playback Switch",
3766 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3769 /* check for volume support for the amp */
3770 if ((caps & AC_AMPCAP_NUM_STEPS)
3771 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3772 err = stac92xx_add_control(spec,
3773 STAC_CTL_WIDGET_VOL,
3774 "Mono Playback Volume",
3775 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3781 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3785 if (!spec->multiout.num_dacs) {
3786 err = stac92xx_auto_fill_dac_nids(codec);
3789 err = stac92xx_auto_create_multi_out_ctls(codec,
3795 /* setup analog beep controls */
3796 if (spec->anabeep_nid > 0) {
3797 err = stac92xx_auto_create_beep_ctls(codec,
3803 /* setup digital beep controls and input device */
3804 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3805 if (spec->digbeep_nid > 0) {
3806 hda_nid_t nid = spec->digbeep_nid;
3809 err = stac92xx_auto_create_beep_ctls(codec, nid);
3812 err = snd_hda_attach_beep_device(codec, nid);
3815 /* IDT/STAC codecs have linear beep tone parameter */
3816 codec->beep->linear_tone = 1;
3817 /* if no beep switch is available, make its own one */
3818 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3820 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3821 err = stac92xx_beep_switch_ctl(codec);
3828 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3832 /* All output parsing done, now restore the swapped hp pins */
3834 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3835 sizeof(spec->autocfg.hp_pins));
3836 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3837 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3838 spec->autocfg.line_outs = 0;
3841 for (i = 0; i < spec->num_caps; i++) {
3842 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3843 spec->capsws[i], i);
3848 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3852 if (spec->mono_nid > 0) {
3853 err = stac92xx_auto_create_mono_output_ctls(codec);
3857 if (spec->num_amps > 0) {
3858 err = stac92xx_auto_create_amp_output_ctls(codec);
3862 if (spec->num_dmics > 0 && !spec->dinput_mux)
3863 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3864 &spec->autocfg)) < 0)
3866 if (spec->num_muxes > 0) {
3867 err = stac92xx_auto_create_mux_input_ctls(codec);
3871 if (spec->num_smuxes > 0) {
3872 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3877 err = stac92xx_add_input_source(spec);
3881 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3882 if (spec->multiout.max_channels > 2)
3883 spec->surr_switch = 1;
3885 if (spec->autocfg.dig_outs)
3886 spec->multiout.dig_out_nid = dig_out;
3887 if (dig_in && spec->autocfg.dig_in_pin)
3888 spec->dig_in_nid = dig_in;
3890 if (spec->kctls.list)
3891 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3893 spec->input_mux = &spec->private_imux;
3894 if (!spec->dinput_mux)
3895 spec->dinput_mux = &spec->private_dimux;
3896 spec->sinput_mux = &spec->private_smux;
3897 spec->mono_mux = &spec->private_mono_mux;
3898 spec->amp_mux = &spec->private_amp_mux;
3902 /* add playback controls for HP output */
3903 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3904 struct auto_pin_cfg *cfg)
3906 struct sigmatel_spec *spec = codec->spec;
3907 hda_nid_t pin = cfg->hp_pins[0];
3908 unsigned int wid_caps;
3913 wid_caps = get_wcaps(codec, pin);
3914 if (wid_caps & AC_WCAP_UNSOL_CAP)
3915 spec->hp_detect = 1;
3920 /* add playback controls for LFE output */
3921 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3922 struct auto_pin_cfg *cfg)
3924 struct sigmatel_spec *spec = codec->spec;
3926 hda_nid_t lfe_pin = 0x0;
3930 * search speaker outs and line outs for a mono speaker pin
3931 * with an amp. If one is found, add LFE controls
3934 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3935 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3936 unsigned int wcaps = get_wcaps(codec, pin);
3937 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3938 if (wcaps == AC_WCAP_OUT_AMP)
3939 /* found a mono speaker with an amp, must be lfe */
3943 /* if speaker_outs is 0, then speakers may be in line_outs */
3944 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3945 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3946 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3947 unsigned int defcfg;
3948 defcfg = snd_hda_codec_get_pincfg(codec, pin);
3949 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3950 unsigned int wcaps = get_wcaps(codec, pin);
3951 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3952 if (wcaps == AC_WCAP_OUT_AMP)
3953 /* found a mono speaker with an amp,
3961 err = create_controls(codec, "LFE", lfe_pin, 1);
3969 static int stac9200_parse_auto_config(struct hda_codec *codec)
3971 struct sigmatel_spec *spec = codec->spec;
3974 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3977 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3980 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3983 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3986 if (spec->num_muxes > 0) {
3987 err = stac92xx_auto_create_mux_input_ctls(codec);
3992 err = stac92xx_add_input_source(spec);
3996 if (spec->autocfg.dig_outs)
3997 spec->multiout.dig_out_nid = 0x05;
3998 if (spec->autocfg.dig_in_pin)
3999 spec->dig_in_nid = 0x04;
4001 if (spec->kctls.list)
4002 spec->mixers[spec->num_mixers++] = spec->kctls.list;
4004 spec->input_mux = &spec->private_imux;
4005 spec->dinput_mux = &spec->private_dimux;
4011 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4012 * funky external mute control using GPIO pins.
4015 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4016 unsigned int dir_mask, unsigned int data)
4018 unsigned int gpiostate, gpiomask, gpiodir;
4020 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4021 AC_VERB_GET_GPIO_DATA, 0);
4022 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
4024 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4025 AC_VERB_GET_GPIO_MASK, 0);
4028 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4029 AC_VERB_GET_GPIO_DIRECTION, 0);
4030 gpiodir |= dir_mask;
4032 /* Configure GPIOx as CMOS */
4033 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4035 snd_hda_codec_write(codec, codec->afg, 0,
4036 AC_VERB_SET_GPIO_MASK, gpiomask);
4037 snd_hda_codec_read(codec, codec->afg, 0,
4038 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
4042 snd_hda_codec_read(codec, codec->afg, 0,
4043 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
4046 #ifdef CONFIG_SND_HDA_INPUT_JACK
4047 static void stac92xx_free_jack_priv(struct snd_jack *jack)
4049 struct sigmatel_jack *jacks = jack->private_data;
4055 static int stac92xx_add_jack(struct hda_codec *codec,
4056 hda_nid_t nid, int type)
4058 #ifdef CONFIG_SND_HDA_INPUT_JACK
4059 struct sigmatel_spec *spec = codec->spec;
4060 struct sigmatel_jack *jack;
4061 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4062 int connectivity = get_defcfg_connect(def_conf);
4066 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4069 snd_array_init(&spec->jacks, sizeof(*jack), 32);
4070 jack = snd_array_new(&spec->jacks);
4076 snprintf(name, sizeof(name), "%s at %s %s Jack",
4077 snd_hda_get_jack_type(def_conf),
4078 snd_hda_get_jack_connectivity(def_conf),
4079 snd_hda_get_jack_location(def_conf));
4081 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4086 jack->jack->private_data = jack;
4087 jack->jack->private_free = stac92xx_free_jack_priv;
4092 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4093 unsigned char type, int data)
4095 struct sigmatel_event *event;
4097 snd_array_init(&spec->events, sizeof(*event), 32);
4098 event = snd_array_new(&spec->events);
4103 event->tag = spec->events.used;
4109 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4110 hda_nid_t nid, unsigned char type)
4112 struct sigmatel_spec *spec = codec->spec;
4113 struct sigmatel_event *event = spec->events.list;
4116 for (i = 0; i < spec->events.used; i++, event++) {
4117 if (event->nid == nid && event->type == type)
4123 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4126 struct sigmatel_spec *spec = codec->spec;
4127 struct sigmatel_event *event = spec->events.list;
4130 for (i = 0; i < spec->events.used; i++, event++) {
4131 if (event->tag == tag)
4137 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4140 struct sigmatel_event *event;
4143 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4145 event = stac_get_event(codec, nid, type);
4149 tag = stac_add_event(codec->spec, nid, type, 0);
4152 snd_hda_codec_write_cache(codec, nid, 0,
4153 AC_VERB_SET_UNSOLICITED_ENABLE,
4157 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4160 for (i = 0; i < cfg->hp_outs; i++)
4161 if (cfg->hp_pins[i] == nid)
4162 return 1; /* nid is a HP-Out */
4164 return 0; /* nid is not a HP-Out */
4167 static void stac92xx_power_down(struct hda_codec *codec)
4169 struct sigmatel_spec *spec = codec->spec;
4171 /* power down inactive DACs */
4173 for (dac = spec->dac_list; *dac; dac++)
4174 if (!check_all_dac_nids(spec, *dac))
4175 snd_hda_codec_write(codec, *dac, 0,
4176 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4179 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4182 /* override some hints from the hwdep entry */
4183 static void stac_store_hints(struct hda_codec *codec)
4185 struct sigmatel_spec *spec = codec->spec;
4189 val = snd_hda_get_bool_hint(codec, "hp_detect");
4191 spec->hp_detect = val;
4192 p = snd_hda_get_hint(codec, "gpio_mask");
4194 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4195 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4198 p = snd_hda_get_hint(codec, "gpio_dir");
4200 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4201 p = snd_hda_get_hint(codec, "gpio_data");
4203 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4204 p = snd_hda_get_hint(codec, "eapd_mask");
4206 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4207 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4209 spec->eapd_switch = val;
4212 static int stac92xx_init(struct hda_codec *codec)
4214 struct sigmatel_spec *spec = codec->spec;
4215 struct auto_pin_cfg *cfg = &spec->autocfg;
4219 snd_hda_sequence_write(codec, spec->init);
4221 /* power down adcs initially */
4222 if (spec->powerdown_adcs)
4223 for (i = 0; i < spec->num_adcs; i++)
4224 snd_hda_codec_write(codec,
4225 spec->adc_nids[i], 0,
4226 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4228 /* override some hints */
4229 stac_store_hints(codec);
4232 gpio = spec->gpio_data;
4233 /* turn on EAPD statically when spec->eapd_switch isn't set.
4234 * otherwise, unsol event will turn it on/off dynamically
4236 if (!spec->eapd_switch)
4237 gpio |= spec->eapd_mask;
4238 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4241 if (spec->hp_detect) {
4242 /* Enable unsolicited responses on the HP widget */
4243 for (i = 0; i < cfg->hp_outs; i++) {
4244 hda_nid_t nid = cfg->hp_pins[i];
4245 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4247 /* force to enable the first line-out; the others are set up
4250 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4252 /* fake event to set up pins */
4253 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4256 stac92xx_auto_init_multi_out(codec);
4257 stac92xx_auto_init_hp_out(codec);
4258 for (i = 0; i < cfg->hp_outs; i++)
4259 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4261 for (i = 0; i < AUTO_PIN_LAST; i++) {
4262 hda_nid_t nid = cfg->input_pins[i];
4264 unsigned int pinctl, conf;
4265 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4266 /* for mic pins, force to initialize */
4267 pinctl = stac92xx_get_default_vref(codec, nid);
4268 pinctl |= AC_PINCTL_IN_EN;
4269 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4271 pinctl = snd_hda_codec_read(codec, nid, 0,
4272 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4273 /* if PINCTL already set then skip */
4274 /* Also, if both INPUT and OUTPUT are set,
4275 * it must be a BIOS bug; need to override, too
4277 if (!(pinctl & AC_PINCTL_IN_EN) ||
4278 (pinctl & AC_PINCTL_OUT_EN)) {
4279 pinctl &= ~AC_PINCTL_OUT_EN;
4280 pinctl |= AC_PINCTL_IN_EN;
4281 stac92xx_auto_set_pinctl(codec, nid,
4285 conf = snd_hda_codec_get_pincfg(codec, nid);
4286 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4287 enable_pin_detect(codec, nid,
4289 stac_issue_unsol_event(codec, nid,
4294 for (i = 0; i < spec->num_dmics; i++)
4295 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4297 if (cfg->dig_out_pins[0])
4298 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4300 if (cfg->dig_in_pin)
4301 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4303 for (i = 0; i < spec->num_pwrs; i++) {
4304 hda_nid_t nid = spec->pwr_nids[i];
4305 int pinctl, def_conf;
4307 /* power on when no jack detection is available */
4308 if (!spec->hp_detect) {
4309 stac_toggle_power_map(codec, nid, 1);
4313 if (is_nid_hp_pin(cfg, nid))
4314 continue; /* already has an unsol event */
4316 pinctl = snd_hda_codec_read(codec, nid, 0,
4317 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4318 /* outputs are only ports capable of power management
4319 * any attempts on powering down a input port cause the
4320 * referenced VREF to act quirky.
4322 if (pinctl & AC_PINCTL_IN_EN) {
4323 stac_toggle_power_map(codec, nid, 1);
4326 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4327 def_conf = get_defcfg_connect(def_conf);
4328 /* skip any ports that don't have jacks since presence
4329 * detection is useless */
4330 if (def_conf != AC_JACK_PORT_COMPLEX) {
4331 if (def_conf != AC_JACK_PORT_NONE)
4332 stac_toggle_power_map(codec, nid, 1);
4335 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4336 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4337 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4341 stac92xx_power_down(codec);
4345 static void stac92xx_free_jacks(struct hda_codec *codec)
4347 #ifdef CONFIG_SND_HDA_INPUT_JACK
4348 /* free jack instances manually when clearing/reconfiguring */
4349 struct sigmatel_spec *spec = codec->spec;
4350 if (!codec->bus->shutdown && spec->jacks.list) {
4351 struct sigmatel_jack *jacks = spec->jacks.list;
4353 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4355 snd_device_free(codec->bus->card, jacks->jack);
4358 snd_array_free(&spec->jacks);
4362 static void stac92xx_free_kctls(struct hda_codec *codec)
4364 struct sigmatel_spec *spec = codec->spec;
4366 if (spec->kctls.list) {
4367 struct snd_kcontrol_new *kctl = spec->kctls.list;
4369 for (i = 0; i < spec->kctls.used; i++)
4370 kfree(kctl[i].name);
4372 snd_array_free(&spec->kctls);
4375 static void stac92xx_free(struct hda_codec *codec)
4377 struct sigmatel_spec *spec = codec->spec;
4382 stac92xx_free_jacks(codec);
4383 snd_array_free(&spec->events);
4386 snd_hda_detach_beep_device(codec);
4389 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4392 unsigned int old_ctl, pin_ctl;
4394 pin_ctl = snd_hda_codec_read(codec, nid,
4395 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4397 if (pin_ctl & AC_PINCTL_IN_EN) {
4399 * we need to check the current set-up direction of
4400 * shared input pins since they can be switched via
4401 * "xxx as Output" mixer switch
4403 struct sigmatel_spec *spec = codec->spec;
4404 if (nid == spec->line_switch || nid == spec->mic_switch)
4409 /* if setting pin direction bits, clear the current
4410 direction bits first */
4411 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4412 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4415 if (old_ctl != pin_ctl)
4416 snd_hda_codec_write_cache(codec, nid, 0,
4417 AC_VERB_SET_PIN_WIDGET_CONTROL,
4421 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4424 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4425 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4427 snd_hda_codec_write_cache(codec, nid, 0,
4428 AC_VERB_SET_PIN_WIDGET_CONTROL,
4432 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4436 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
4442 /* return non-zero if the hp-pin of the given array index isn't
4443 * a jack-detection target
4445 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4447 struct auto_pin_cfg *cfg = &spec->autocfg;
4449 /* ignore sensing of shared line and mic jacks */
4450 if (cfg->hp_pins[i] == spec->line_switch)
4452 if (cfg->hp_pins[i] == spec->mic_switch)
4454 /* ignore if the pin is set as line-out */
4455 if (cfg->hp_pins[i] == spec->hp_switch)
4460 static void stac92xx_hp_detect(struct hda_codec *codec)
4462 struct sigmatel_spec *spec = codec->spec;
4463 struct auto_pin_cfg *cfg = &spec->autocfg;
4467 if (spec->gpio_mute)
4468 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4469 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4471 for (i = 0; i < cfg->hp_outs; i++) {
4474 if (no_hp_sensing(spec, i))
4476 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4478 unsigned int pinctl;
4479 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4480 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4481 if (pinctl & AC_PINCTL_IN_EN)
4482 presence = 0; /* mic- or line-input */
4487 /* disable lineouts */
4488 if (spec->hp_switch)
4489 stac92xx_reset_pinctl(codec, spec->hp_switch,
4491 for (i = 0; i < cfg->line_outs; i++)
4492 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4494 for (i = 0; i < cfg->speaker_outs; i++)
4495 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4497 if (spec->eapd_mask && spec->eapd_switch)
4498 stac_gpio_set(codec, spec->gpio_mask,
4499 spec->gpio_dir, spec->gpio_data &
4502 /* enable lineouts */
4503 if (spec->hp_switch)
4504 stac92xx_set_pinctl(codec, spec->hp_switch,
4506 for (i = 0; i < cfg->line_outs; i++)
4507 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4509 for (i = 0; i < cfg->speaker_outs; i++)
4510 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4512 if (spec->eapd_mask && spec->eapd_switch)
4513 stac_gpio_set(codec, spec->gpio_mask,
4514 spec->gpio_dir, spec->gpio_data |
4517 /* toggle hp outs */
4518 for (i = 0; i < cfg->hp_outs; i++) {
4519 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4520 if (no_hp_sensing(spec, i))
4523 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4525 /* Resetting the pinctl like below may lead to (a sort of) regressions
4526 * on some devices since they use the HP pin actually for line/speaker
4527 * outs although the default pin config shows a different pin (that is
4528 * wrong and useless).
4530 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4531 * But, disabling the code below just works around it, and I'm too tired of
4532 * bug reports with such devices...
4535 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4540 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4543 struct sigmatel_spec *spec = codec->spec;
4544 unsigned int idx, val;
4546 for (idx = 0; idx < spec->num_pwrs; idx++) {
4547 if (spec->pwr_nids[idx] == nid)
4550 if (idx >= spec->num_pwrs)
4553 /* several codecs have two power down bits */
4554 if (spec->pwr_mapping)
4555 idx = spec->pwr_mapping[idx];
4559 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4565 /* power down unused output ports */
4566 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4569 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4571 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4574 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4576 struct sigmatel_spec *spec = codec->spec;
4577 struct sigmatel_jack *jacks = spec->jacks.list;
4581 for (i = 0; i < spec->jacks.used; i++) {
4582 if (jacks->nid == nid) {
4583 unsigned int pin_ctl =
4584 snd_hda_codec_read(codec, nid,
4585 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4587 int type = jacks->type;
4588 if (type == (SND_JACK_LINEOUT
4589 | SND_JACK_HEADPHONE))
4590 type = (pin_ctl & AC_PINCTL_HP_EN)
4591 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4592 snd_jack_report(jacks->jack,
4593 get_pin_presence(codec, nid)
4601 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4604 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4607 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4610 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4612 struct sigmatel_spec *spec = codec->spec;
4613 struct sigmatel_event *event;
4616 tag = (res >> 26) & 0x7f;
4617 event = stac_get_event_from_tag(codec, tag);
4621 switch (event->type) {
4623 stac92xx_hp_detect(codec);
4625 case STAC_INSERT_EVENT:
4626 case STAC_PWR_EVENT:
4627 if (spec->num_pwrs > 0)
4628 stac92xx_pin_sense(codec, event->nid);
4629 stac92xx_report_jack(codec, event->nid);
4631 switch (codec->subsystem_id) {
4633 if (event->nid == 0xb) {
4634 int pin = AC_PINCTL_IN_EN;
4636 if (get_pin_presence(codec, 0xa)
4637 && get_pin_presence(codec, 0xb))
4638 pin |= AC_PINCTL_VREF_80;
4639 if (!get_pin_presence(codec, 0xb))
4640 pin |= AC_PINCTL_VREF_80;
4642 /* toggle VREF state based on mic + hp pin
4645 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4649 case STAC_VREF_EVENT:
4650 data = snd_hda_codec_read(codec, codec->afg, 0,
4651 AC_VERB_GET_GPIO_DATA, 0);
4652 /* toggle VREF state based on GPIOx status */
4653 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4654 !!(data & (1 << event->data)));
4659 #ifdef CONFIG_PROC_FS
4660 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4661 struct hda_codec *codec, hda_nid_t nid)
4663 if (nid == codec->afg)
4664 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4665 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4668 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4669 struct hda_codec *codec,
4672 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4673 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4676 /* stac92hd71bxx, stac92hd73xx */
4677 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4678 struct hda_codec *codec, hda_nid_t nid)
4680 stac92hd_proc_hook(buffer, codec, nid);
4681 if (nid == codec->afg)
4682 analog_loop_proc_hook(buffer, codec, 0xfa0);
4685 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4686 struct hda_codec *codec, hda_nid_t nid)
4688 if (nid == codec->afg)
4689 analog_loop_proc_hook(buffer, codec, 0xfe0);
4692 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4693 struct hda_codec *codec, hda_nid_t nid)
4695 if (nid == codec->afg)
4696 analog_loop_proc_hook(buffer, codec, 0xfeb);
4699 #define stac92hd_proc_hook NULL
4700 #define stac92hd7x_proc_hook NULL
4701 #define stac9205_proc_hook NULL
4702 #define stac927x_proc_hook NULL
4705 #ifdef SND_HDA_NEEDS_RESUME
4706 static int stac92xx_resume(struct hda_codec *codec)
4708 struct sigmatel_spec *spec = codec->spec;
4710 stac92xx_init(codec);
4711 snd_hda_codec_resume_amp(codec);
4712 snd_hda_codec_resume_cache(codec);
4713 /* fake event to set up pins again to override cached values */
4714 if (spec->hp_detect)
4715 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4721 * using power check for controlling mute led of HP notebooks
4722 * check for mute state only on Speakers (nid = 0x10)
4724 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4725 * the LED is NOT working properly !
4727 * Changed name to reflect that it now works for any designated
4728 * model, not just HP HDX.
4731 #ifdef CONFIG_SND_HDA_POWER_SAVE
4732 static int stac92xx_hp_check_power_status(struct hda_codec *codec,
4735 struct sigmatel_spec *spec = codec->spec;
4738 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4740 spec->gpio_data &= ~spec->gpio_led; /* orange */
4742 spec->gpio_data |= spec->gpio_led; /* white */
4744 stac_gpio_set(codec, spec->gpio_mask,
4753 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4755 struct sigmatel_spec *spec = codec->spec;
4759 /* reset each pin before powering down DAC/ADC to avoid click noise */
4760 nid = codec->start_nid;
4761 for (i = 0; i < codec->num_nodes; i++, nid++) {
4762 unsigned int wcaps = get_wcaps(codec, nid);
4763 unsigned int wid_type = get_wcaps_type(wcaps);
4764 if (wid_type == AC_WID_PIN)
4765 snd_hda_codec_read(codec, nid, 0,
4766 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4769 if (spec->eapd_mask)
4770 stac_gpio_set(codec, spec->gpio_mask,
4771 spec->gpio_dir, spec->gpio_data &
4777 static struct hda_codec_ops stac92xx_patch_ops = {
4778 .build_controls = stac92xx_build_controls,
4779 .build_pcms = stac92xx_build_pcms,
4780 .init = stac92xx_init,
4781 .free = stac92xx_free,
4782 .unsol_event = stac92xx_unsol_event,
4783 #ifdef SND_HDA_NEEDS_RESUME
4784 .suspend = stac92xx_suspend,
4785 .resume = stac92xx_resume,
4789 static int patch_stac9200(struct hda_codec *codec)
4791 struct sigmatel_spec *spec;
4794 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4799 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4800 spec->pin_nids = stac9200_pin_nids;
4801 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4804 if (spec->board_config < 0)
4805 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4808 stac92xx_set_config_regs(codec,
4809 stac9200_brd_tbl[spec->board_config]);
4811 spec->multiout.max_channels = 2;
4812 spec->multiout.num_dacs = 1;
4813 spec->multiout.dac_nids = stac9200_dac_nids;
4814 spec->adc_nids = stac9200_adc_nids;
4815 spec->mux_nids = stac9200_mux_nids;
4816 spec->num_muxes = 1;
4817 spec->num_dmics = 0;
4821 if (spec->board_config == STAC_9200_M4 ||
4822 spec->board_config == STAC_9200_M4_2 ||
4823 spec->board_config == STAC_9200_OQO)
4824 spec->init = stac9200_eapd_init;
4826 spec->init = stac9200_core_init;
4827 spec->mixer = stac9200_mixer;
4829 if (spec->board_config == STAC_9200_PANASONIC) {
4830 spec->gpio_mask = spec->gpio_dir = 0x09;
4831 spec->gpio_data = 0x00;
4834 err = stac9200_parse_auto_config(codec);
4836 stac92xx_free(codec);
4840 /* CF-74 has no headphone detection, and the driver should *NOT*
4841 * do detection and HP/speaker toggle because the hardware does it.
4843 if (spec->board_config == STAC_9200_PANASONIC)
4844 spec->hp_detect = 0;
4846 codec->patch_ops = stac92xx_patch_ops;
4851 static int patch_stac925x(struct hda_codec *codec)
4853 struct sigmatel_spec *spec;
4856 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4861 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4862 spec->pin_nids = stac925x_pin_nids;
4864 /* Check first for codec ID */
4865 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4868 stac925x_codec_id_cfg_tbl);
4870 /* Now checks for PCI ID, if codec ID is not found */
4871 if (spec->board_config < 0)
4872 spec->board_config = snd_hda_check_board_config(codec,
4877 if (spec->board_config < 0)
4878 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4881 stac92xx_set_config_regs(codec,
4882 stac925x_brd_tbl[spec->board_config]);
4884 spec->multiout.max_channels = 2;
4885 spec->multiout.num_dacs = 1;
4886 spec->multiout.dac_nids = stac925x_dac_nids;
4887 spec->adc_nids = stac925x_adc_nids;
4888 spec->mux_nids = stac925x_mux_nids;
4889 spec->num_muxes = 1;
4892 switch (codec->vendor_id) {
4893 case 0x83847632: /* STAC9202 */
4894 case 0x83847633: /* STAC9202D */
4895 case 0x83847636: /* STAC9251 */
4896 case 0x83847637: /* STAC9251D */
4897 spec->num_dmics = STAC925X_NUM_DMICS;
4898 spec->dmic_nids = stac925x_dmic_nids;
4899 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4900 spec->dmux_nids = stac925x_dmux_nids;
4903 spec->num_dmics = 0;
4907 spec->init = stac925x_core_init;
4908 spec->mixer = stac925x_mixer;
4910 spec->capvols = stac925x_capvols;
4911 spec->capsws = stac925x_capsws;
4913 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4915 if (spec->board_config < 0) {
4916 printk(KERN_WARNING "hda_codec: No auto-config is "
4917 "available, default to model=ref\n");
4918 spec->board_config = STAC_925x_REF;
4924 stac92xx_free(codec);
4928 codec->patch_ops = stac92xx_patch_ops;
4933 static struct hda_input_mux stac92hd73xx_dmux = {
4936 { "Analog Inputs", 0x0b },
4937 { "Digital Mic 1", 0x09 },
4938 { "Digital Mic 2", 0x0a },
4943 static int patch_stac92hd73xx(struct hda_codec *codec)
4945 struct sigmatel_spec *spec;
4946 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4950 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4955 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4956 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4957 spec->pin_nids = stac92hd73xx_pin_nids;
4958 spec->board_config = snd_hda_check_board_config(codec,
4959 STAC_92HD73XX_MODELS,
4960 stac92hd73xx_models,
4961 stac92hd73xx_cfg_tbl);
4963 if (spec->board_config < 0)
4964 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4967 stac92xx_set_config_regs(codec,
4968 stac92hd73xx_brd_tbl[spec->board_config]);
4970 num_dacs = snd_hda_get_connections(codec, 0x0a,
4971 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4973 if (num_dacs < 3 || num_dacs > 5) {
4974 printk(KERN_WARNING "hda_codec: Could not determine "
4975 "number of channels defaulting to DAC count\n");
4976 num_dacs = STAC92HD73_DAC_COUNT;
4979 case 0x3: /* 6 Channel */
4980 spec->mixer = stac92hd73xx_6ch_mixer;
4981 spec->init = stac92hd73xx_6ch_core_init;
4982 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
4984 case 0x4: /* 8 Channel */
4985 spec->mixer = stac92hd73xx_8ch_mixer;
4986 spec->init = stac92hd73xx_8ch_core_init;
4987 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
4989 case 0x5: /* 10 Channel */
4990 spec->mixer = stac92hd73xx_10ch_mixer;
4991 spec->init = stac92hd73xx_10ch_core_init;
4992 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4995 spec->multiout.dac_nids = spec->dac_nids;
4997 spec->aloopback_mask = 0x01;
4998 spec->aloopback_shift = 8;
5000 spec->digbeep_nid = 0x1c;
5001 spec->mux_nids = stac92hd73xx_mux_nids;
5002 spec->adc_nids = stac92hd73xx_adc_nids;
5003 spec->dmic_nids = stac92hd73xx_dmic_nids;
5004 spec->dmux_nids = stac92hd73xx_dmux_nids;
5005 spec->smux_nids = stac92hd73xx_smux_nids;
5006 spec->amp_nids = stac92hd73xx_amp_nids;
5007 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
5009 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5010 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
5011 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
5012 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
5013 sizeof(stac92hd73xx_dmux));
5015 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5016 spec->capvols = stac92hd73xx_capvols;
5017 spec->capsws = stac92hd73xx_capsws;
5019 switch (spec->board_config) {
5021 spec->init = dell_eq_core_init;
5023 case STAC_DELL_M6_AMIC:
5024 case STAC_DELL_M6_DMIC:
5025 case STAC_DELL_M6_BOTH:
5026 spec->num_smuxes = 0;
5027 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
5028 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
5029 spec->eapd_switch = 0;
5032 if (spec->board_config != STAC_DELL_EQ)
5033 spec->init = dell_m6_core_init;
5034 switch (spec->board_config) {
5035 case STAC_DELL_M6_AMIC: /* Analog Mics */
5036 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5037 spec->num_dmics = 0;
5038 spec->private_dimux.num_items = 1;
5040 case STAC_DELL_M6_DMIC: /* Digital Mics */
5041 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5042 spec->num_dmics = 1;
5043 spec->private_dimux.num_items = 2;
5045 case STAC_DELL_M6_BOTH: /* Both */
5046 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5047 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5048 spec->num_dmics = 1;
5049 spec->private_dimux.num_items = 2;
5054 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5055 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5056 spec->eapd_switch = 1;
5058 if (spec->board_config > STAC_92HD73XX_REF) {
5059 /* GPIO0 High = Enable EAPD */
5060 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5061 spec->gpio_data = 0x01;
5063 spec->dinput_mux = &spec->private_dimux;
5065 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5066 spec->pwr_nids = stac92hd73xx_pwr_nids;
5068 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
5071 if (spec->board_config < 0) {
5072 printk(KERN_WARNING "hda_codec: No auto-config is "
5073 "available, default to model=ref\n");
5074 spec->board_config = STAC_92HD73XX_REF;
5081 stac92xx_free(codec);
5085 if (spec->board_config == STAC_92HD73XX_NO_JD)
5086 spec->hp_detect = 0;
5088 codec->patch_ops = stac92xx_patch_ops;
5090 codec->proc_widget_hook = stac92hd7x_proc_hook;
5095 static struct hda_input_mux stac92hd83xxx_dmux = {
5098 { "Analog Inputs", 0x03 },
5099 { "Digital Mic 1", 0x04 },
5100 { "Digital Mic 2", 0x05 },
5104 static int patch_stac92hd83xxx(struct hda_codec *codec)
5106 struct sigmatel_spec *spec;
5107 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
5112 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5117 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5118 spec->mono_nid = 0x19;
5119 spec->digbeep_nid = 0x21;
5120 spec->dmic_nids = stac92hd83xxx_dmic_nids;
5121 spec->dmux_nids = stac92hd83xxx_dmux_nids;
5122 spec->adc_nids = stac92hd83xxx_adc_nids;
5123 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5124 spec->amp_nids = stac92hd83xxx_amp_nids;
5125 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5126 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5127 spec->multiout.dac_nids = spec->dac_nids;
5129 spec->init = stac92hd83xxx_core_init;
5130 spec->mixer = stac92hd83xxx_mixer;
5131 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5132 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
5133 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5134 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
5135 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
5136 spec->dinput_mux = &stac92hd83xxx_dmux;
5137 spec->pin_nids = stac92hd83xxx_pin_nids;
5138 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5139 spec->capvols = stac92hd83xxx_capvols;
5140 spec->capsws = stac92hd83xxx_capsws;
5142 spec->board_config = snd_hda_check_board_config(codec,
5143 STAC_92HD83XXX_MODELS,
5144 stac92hd83xxx_models,
5145 stac92hd83xxx_cfg_tbl);
5147 if (spec->board_config < 0)
5148 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5151 stac92xx_set_config_regs(codec,
5152 stac92hd83xxx_brd_tbl[spec->board_config]);
5154 switch (codec->vendor_id) {
5158 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5164 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5166 if (spec->board_config < 0) {
5167 printk(KERN_WARNING "hda_codec: No auto-config is "
5168 "available, default to model=ref\n");
5169 spec->board_config = STAC_92HD83XXX_REF;
5176 stac92xx_free(codec);
5180 switch (spec->board_config) {
5189 num_dacs = snd_hda_get_connections(codec, nid,
5190 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5192 num_dacs = STAC92HD83_DAC_COUNT;
5194 /* set port X to select the last DAC
5196 snd_hda_codec_write_cache(codec, nid, 0,
5197 AC_VERB_SET_CONNECT_SEL, num_dacs);
5199 codec->patch_ops = stac92xx_patch_ops;
5201 codec->proc_widget_hook = stac92hd_proc_hook;
5206 static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
5209 { "Analog Inputs", 0x00 },
5210 { "Digital Mic 1", 0x02 },
5211 { "Digital Mic 2", 0x03 },
5215 static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
5218 { "Analog Inputs", 0x00 },
5220 { "Digital Mic 1", 0x02 },
5221 { "Digital Mic 2", 0x03 },
5225 /* get the pin connection (fixed, none, etc) */
5226 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5228 struct sigmatel_spec *spec = codec->spec;
5231 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5232 return get_defcfg_connect(cfg);
5235 static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5236 hda_nid_t *nids, int num_nids)
5238 struct sigmatel_spec *spec = codec->spec;
5240 unsigned int def_conf;
5242 for (num = 0; num < num_nids; num++) {
5243 for (idx = 0; idx < spec->num_pins; idx++)
5244 if (spec->pin_nids[idx] == nids[num])
5246 if (idx >= spec->num_pins)
5248 def_conf = stac_get_defcfg_connect(codec, idx);
5249 if (def_conf == AC_JACK_PORT_NONE)
5255 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5258 struct sigmatel_spec *spec = codec->spec;
5261 for (idx = 0; idx < spec->num_pins; idx++)
5262 if (spec->pin_nids[idx] == dig0pin)
5264 if ((idx + 2) >= spec->num_pins)
5268 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5271 /* dig0pin + dig2pin case */
5272 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5274 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5280 static int patch_stac92hd71bxx(struct hda_codec *codec)
5282 struct sigmatel_spec *spec;
5283 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5285 unsigned int ndmic_nids = 0;
5287 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5292 codec->patch_ops = stac92xx_patch_ops;
5293 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5294 switch (codec->vendor_id) {
5297 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5301 /* On 92HD75Bx 0x27 isn't a pin nid */
5305 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5307 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5308 spec->board_config = snd_hda_check_board_config(codec,
5309 STAC_92HD71BXX_MODELS,
5310 stac92hd71bxx_models,
5311 stac92hd71bxx_cfg_tbl);
5313 if (spec->board_config < 0)
5314 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5317 stac92xx_set_config_regs(codec,
5318 stac92hd71bxx_brd_tbl[spec->board_config]);
5320 if (spec->board_config > STAC_92HD71BXX_REF) {
5322 spec->gpio_mask = 0x01;
5323 spec->gpio_dir = 0x01;
5324 spec->gpio_data = 0x01;
5327 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5328 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5330 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5331 spec->capvols = stac92hd71bxx_capvols;
5332 spec->capsws = stac92hd71bxx_capsws;
5334 switch (codec->vendor_id) {
5335 case 0x111d76b6: /* 4 Port without Analog Mixer */
5339 case 0x111d76b4: /* 6 Port without Analog Mixer */
5341 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
5342 sizeof(stac92hd71bxx_dmux_nomixer));
5343 spec->init = stac92hd71bxx_core_init;
5344 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5345 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5346 stac92hd71bxx_dmic_nids,
5347 STAC92HD71BXX_NUM_DMICS);
5348 if (spec->num_dmics) {
5349 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5350 spec->dinput_mux = &spec->private_dimux;
5351 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5354 case 0x111d7608: /* 5 Port with Analog Mixer */
5355 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5356 sizeof(stac92hd71bxx_dmux_amixer));
5357 spec->private_dimux.num_items--;
5358 switch (spec->board_config) {
5360 /* Enable VREF power saving on GPIO1 detect */
5361 err = stac_add_event(spec, codec->afg,
5362 STAC_VREF_EVENT, 0x02);
5365 snd_hda_codec_write_cache(codec, codec->afg, 0,
5366 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5367 snd_hda_codec_write_cache(codec, codec->afg, 0,
5368 AC_VERB_SET_UNSOLICITED_ENABLE,
5370 spec->gpio_mask |= 0x02;
5373 if ((codec->revision_id & 0xf) == 0 ||
5374 (codec->revision_id & 0xf) == 1)
5375 spec->stream_delay = 40; /* 40 milliseconds */
5377 /* no output amps */
5379 spec->mixer = stac92hd71bxx_analog_mixer;
5382 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
5384 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5385 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5386 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5387 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5388 stac92hd71bxx_dmic_nids,
5389 STAC92HD71BXX_NUM_DMICS - 1);
5390 if (spec->num_dmics) {
5391 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5392 spec->dinput_mux = &spec->private_dimux;
5393 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
5396 case 0x111d7603: /* 6 Port with Analog Mixer */
5397 if ((codec->revision_id & 0xf) == 1)
5398 spec->stream_delay = 40; /* 40 milliseconds */
5400 /* no output amps */
5404 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5405 sizeof(stac92hd71bxx_dmux_amixer));
5406 spec->mixer = stac92hd71bxx_analog_mixer;
5407 spec->init = stac92hd71bxx_analog_core_init;
5408 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5409 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5410 stac92hd71bxx_dmic_nids,
5411 STAC92HD71BXX_NUM_DMICS);
5412 if (spec->num_dmics) {
5413 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5414 spec->dinput_mux = &spec->private_dimux;
5415 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5419 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5420 snd_hda_sequence_write_cache(codec, unmute_init);
5422 /* Some HP machines seem to have unstable codec communications
5423 * especially with ATI fglrx driver. For recovering from the
5424 * CORB/RIRB stall, allow the BUS reset and keep always sync
5426 if (spec->board_config == STAC_HP_DV5) {
5427 codec->bus->sync_write = 1;
5428 codec->bus->allow_bus_reset = 1;
5431 spec->aloopback_ctl = stac92hd71bxx_loopback;
5432 spec->aloopback_mask = 0x50;
5433 spec->aloopback_shift = 0;
5435 spec->powerdown_adcs = 1;
5436 spec->digbeep_nid = 0x26;
5437 spec->mux_nids = stac92hd71bxx_mux_nids;
5438 spec->adc_nids = stac92hd71bxx_adc_nids;
5439 spec->smux_nids = stac92hd71bxx_smux_nids;
5440 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5442 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5443 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5444 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5446 switch (spec->board_config) {
5448 /* enable internal microphone */
5449 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5450 stac92xx_auto_set_pinctl(codec, 0x0e,
5451 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5453 case STAC_DELL_M4_2:
5454 spec->num_dmics = 0;
5455 spec->num_smuxes = 0;
5456 spec->num_dmuxes = 0;
5458 case STAC_DELL_M4_1:
5459 case STAC_DELL_M4_3:
5460 spec->num_dmics = 1;
5461 spec->num_smuxes = 0;
5462 spec->num_dmuxes = 1;
5464 case STAC_HP_DV4_1222NR:
5465 spec->num_dmics = 1;
5466 /* I don't know if it needs 1 or 2 smuxes - will wait for
5467 * bug reports to fix if needed
5469 spec->num_smuxes = 1;
5470 spec->num_dmuxes = 1;
5471 spec->gpio_led = 0x01;
5474 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5475 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5478 spec->num_dmics = 1;
5479 spec->num_dmuxes = 1;
5480 spec->num_smuxes = 1;
5481 /* orange/white mute led on GPIO3, orange=0, white=1 */
5482 spec->gpio_led = 0x08;
5486 #ifdef CONFIG_SND_HDA_POWER_SAVE
5487 if (spec->gpio_led) {
5488 spec->gpio_mask |= spec->gpio_led;
5489 spec->gpio_dir |= spec->gpio_led;
5490 spec->gpio_data |= spec->gpio_led;
5491 /* register check_power_status callback. */
5492 codec->patch_ops.check_power_status =
5493 stac92xx_hp_check_power_status;
5497 spec->multiout.dac_nids = spec->dac_nids;
5498 if (spec->dinput_mux)
5499 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
5501 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5503 if (spec->board_config < 0) {
5504 printk(KERN_WARNING "hda_codec: No auto-config is "
5505 "available, default to model=ref\n");
5506 spec->board_config = STAC_92HD71BXX_REF;
5513 stac92xx_free(codec);
5517 codec->proc_widget_hook = stac92hd7x_proc_hook;
5522 static int patch_stac922x(struct hda_codec *codec)
5524 struct sigmatel_spec *spec;
5527 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5532 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5533 spec->pin_nids = stac922x_pin_nids;
5534 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5537 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5538 spec->gpio_mask = spec->gpio_dir = 0x03;
5539 spec->gpio_data = 0x03;
5540 /* Intel Macs have all same PCI SSID, so we need to check
5541 * codec SSID to distinguish the exact models
5543 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5544 switch (codec->subsystem_id) {
5547 spec->board_config = STAC_INTEL_MAC_V1;
5551 spec->board_config = STAC_INTEL_MAC_V2;
5559 spec->board_config = STAC_INTEL_MAC_V3;
5563 spec->board_config = STAC_INTEL_MAC_V4;
5567 spec->board_config = STAC_INTEL_MAC_V5;
5570 spec->board_config = STAC_INTEL_MAC_V3;
5576 if (spec->board_config < 0)
5577 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5580 stac92xx_set_config_regs(codec,
5581 stac922x_brd_tbl[spec->board_config]);
5583 spec->adc_nids = stac922x_adc_nids;
5584 spec->mux_nids = stac922x_mux_nids;
5585 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5586 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5587 spec->num_dmics = 0;
5590 spec->init = stac922x_core_init;
5592 spec->num_caps = STAC922X_NUM_CAPS;
5593 spec->capvols = stac922x_capvols;
5594 spec->capsws = stac922x_capsws;
5596 spec->multiout.dac_nids = spec->dac_nids;
5598 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5600 if (spec->board_config < 0) {
5601 printk(KERN_WARNING "hda_codec: No auto-config is "
5602 "available, default to model=ref\n");
5603 spec->board_config = STAC_D945_REF;
5609 stac92xx_free(codec);
5613 codec->patch_ops = stac92xx_patch_ops;
5615 /* Fix Mux capture level; max to 2 */
5616 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5617 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5618 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5619 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5620 (0 << AC_AMPCAP_MUTE_SHIFT));
5625 static int patch_stac927x(struct hda_codec *codec)
5627 struct sigmatel_spec *spec;
5630 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5635 codec->slave_dig_outs = stac927x_slave_dig_outs;
5636 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5637 spec->pin_nids = stac927x_pin_nids;
5638 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5642 if (spec->board_config < 0)
5643 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5646 stac92xx_set_config_regs(codec,
5647 stac927x_brd_tbl[spec->board_config]);
5649 spec->digbeep_nid = 0x23;
5650 spec->adc_nids = stac927x_adc_nids;
5651 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5652 spec->mux_nids = stac927x_mux_nids;
5653 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5654 spec->smux_nids = stac927x_smux_nids;
5655 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5656 spec->spdif_labels = stac927x_spdif_labels;
5657 spec->dac_list = stac927x_dac_nids;
5658 spec->multiout.dac_nids = spec->dac_nids;
5660 switch (spec->board_config) {
5663 /* GPIO0 High = Enable EAPD */
5664 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
5665 spec->gpio_data = 0x01;
5666 spec->num_dmics = 0;
5668 spec->init = d965_core_init;
5670 case STAC_DELL_BIOS:
5671 switch (codec->subsystem_id) {
5674 /* correct the device field to SPDIF out */
5675 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5678 /* configure the analog microphone on some laptops */
5679 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5680 /* correct the front output jack as a hp out */
5681 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5682 /* correct the front input jack as a mic */
5683 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5686 /* GPIO2 High = Enable EAPD */
5687 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
5688 spec->gpio_data = 0x04;
5689 spec->dmic_nids = stac927x_dmic_nids;
5690 spec->num_dmics = STAC927X_NUM_DMICS;
5692 spec->init = d965_core_init;
5693 spec->dmux_nids = stac927x_dmux_nids;
5694 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5697 if (spec->board_config > STAC_D965_REF) {
5698 /* GPIO0 High = Enable EAPD */
5699 spec->eapd_mask = spec->gpio_mask = 0x01;
5700 spec->gpio_dir = spec->gpio_data = 0x01;
5702 spec->num_dmics = 0;
5704 spec->init = stac927x_core_init;
5707 spec->num_caps = STAC927X_NUM_CAPS;
5708 spec->capvols = stac927x_capvols;
5709 spec->capsws = stac927x_capsws;
5712 spec->aloopback_ctl = stac927x_loopback;
5713 spec->aloopback_mask = 0x40;
5714 spec->aloopback_shift = 0;
5715 spec->eapd_switch = 1;
5717 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
5719 if (spec->board_config < 0) {
5720 printk(KERN_WARNING "hda_codec: No auto-config is "
5721 "available, default to model=ref\n");
5722 spec->board_config = STAC_D965_REF;
5728 stac92xx_free(codec);
5732 codec->patch_ops = stac92xx_patch_ops;
5734 codec->proc_widget_hook = stac927x_proc_hook;
5738 * The STAC927x seem to require fairly long delays for certain
5739 * command sequences. With too short delays (even if the answer
5740 * is set to RIRB properly), it results in the silence output
5741 * on some hardwares like Dell.
5743 * The below flag enables the longer delay (see get_response
5746 codec->bus->needs_damn_long_delay = 1;
5748 /* no jack detecion for ref-no-jd model */
5749 if (spec->board_config == STAC_D965_REF_NO_JD)
5750 spec->hp_detect = 0;
5755 static int patch_stac9205(struct hda_codec *codec)
5757 struct sigmatel_spec *spec;
5760 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5765 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
5766 spec->pin_nids = stac9205_pin_nids;
5767 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5771 if (spec->board_config < 0)
5772 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5775 stac92xx_set_config_regs(codec,
5776 stac9205_brd_tbl[spec->board_config]);
5778 spec->digbeep_nid = 0x23;
5779 spec->adc_nids = stac9205_adc_nids;
5780 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
5781 spec->mux_nids = stac9205_mux_nids;
5782 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
5783 spec->smux_nids = stac9205_smux_nids;
5784 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
5785 spec->dmic_nids = stac9205_dmic_nids;
5786 spec->num_dmics = STAC9205_NUM_DMICS;
5787 spec->dmux_nids = stac9205_dmux_nids;
5788 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
5791 spec->init = stac9205_core_init;
5792 spec->aloopback_ctl = stac9205_loopback;
5794 spec->num_caps = STAC9205_NUM_CAPS;
5795 spec->capvols = stac9205_capvols;
5796 spec->capsws = stac9205_capsws;
5798 spec->aloopback_mask = 0x40;
5799 spec->aloopback_shift = 0;
5800 /* Turn on/off EAPD per HP plugging */
5801 if (spec->board_config != STAC_9205_EAPD)
5802 spec->eapd_switch = 1;
5803 spec->multiout.dac_nids = spec->dac_nids;
5805 switch (spec->board_config){
5806 case STAC_9205_DELL_M43:
5807 /* Enable SPDIF in/out */
5808 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5809 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
5811 /* Enable unsol response for GPIO4/Dock HP connection */
5812 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5815 snd_hda_codec_write_cache(codec, codec->afg, 0,
5816 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5817 snd_hda_codec_write_cache(codec, codec->afg, 0,
5818 AC_VERB_SET_UNSOLICITED_ENABLE,
5821 spec->gpio_dir = 0x0b;
5822 spec->eapd_mask = 0x01;
5823 spec->gpio_mask = 0x1b;
5824 spec->gpio_mute = 0x10;
5825 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5828 spec->gpio_data = 0x01;
5831 /* SPDIF-In enabled */
5834 /* GPIO0 High = EAPD */
5835 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5836 spec->gpio_data = 0x01;
5840 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5842 if (spec->board_config < 0) {
5843 printk(KERN_WARNING "hda_codec: No auto-config is "
5844 "available, default to model=ref\n");
5845 spec->board_config = STAC_9205_REF;
5851 stac92xx_free(codec);
5855 codec->patch_ops = stac92xx_patch_ops;
5857 codec->proc_widget_hook = stac9205_proc_hook;
5866 static struct hda_verb stac9872_core_init[] = {
5867 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5868 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5872 static hda_nid_t stac9872_pin_nids[] = {
5873 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5877 static hda_nid_t stac9872_adc_nids[] = {
5881 static hda_nid_t stac9872_mux_nids[] = {
5885 static unsigned long stac9872_capvols[] = {
5886 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
5888 #define stac9872_capsws stac9872_capvols
5890 static unsigned int stac9872_vaio_pin_configs[9] = {
5891 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5892 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5896 static const char *stac9872_models[STAC_9872_MODELS] = {
5897 [STAC_9872_AUTO] = "auto",
5898 [STAC_9872_VAIO] = "vaio",
5901 static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5902 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5905 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5906 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
5907 "Sony VAIO F/S", STAC_9872_VAIO),
5911 static int patch_stac9872(struct hda_codec *codec)
5913 struct sigmatel_spec *spec;
5916 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5920 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5921 spec->pin_nids = stac9872_pin_nids;
5923 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5926 if (spec->board_config < 0)
5927 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5930 stac92xx_set_config_regs(codec,
5931 stac9872_brd_tbl[spec->board_config]);
5933 spec->multiout.dac_nids = spec->dac_nids;
5934 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5935 spec->adc_nids = stac9872_adc_nids;
5936 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5937 spec->mux_nids = stac9872_mux_nids;
5938 spec->init = stac9872_core_init;
5940 spec->capvols = stac9872_capvols;
5941 spec->capsws = stac9872_capsws;
5943 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5945 stac92xx_free(codec);
5948 spec->input_mux = &spec->private_imux;
5949 codec->patch_ops = stac92xx_patch_ops;
5957 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5958 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5959 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5960 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5961 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5962 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5963 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5964 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5965 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5966 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5967 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5968 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5969 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5970 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5971 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5972 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5973 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5974 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5975 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5976 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5977 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5978 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5979 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5980 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5981 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5982 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5983 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5984 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5985 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5986 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5987 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5988 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5989 /* The following does not take into account .id=0x83847661 when subsys =
5990 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5991 * currently not fully supported.
5993 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5994 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5995 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5996 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
5997 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5998 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5999 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6000 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6001 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6002 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6003 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6004 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
6005 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
6006 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
6007 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
6008 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
6009 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
6010 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6011 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
6012 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
6013 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6014 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6015 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6016 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6017 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6018 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6019 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6020 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6024 MODULE_ALIAS("snd-hda-codec-id:8384*");
6025 MODULE_ALIAS("snd-hda-codec-id:111d*");
6027 MODULE_LICENSE("GPL");
6028 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6030 static struct hda_codec_preset_list sigmatel_list = {
6031 .preset = snd_hda_preset_sigmatel,
6032 .owner = THIS_MODULE,
6035 static int __init patch_sigmatel_init(void)
6037 return snd_hda_add_codec_preset(&sigmatel_list);
6040 static void __exit patch_sigmatel_exit(void)
6042 snd_hda_delete_codec_preset(&sigmatel_list);
6045 module_init(patch_sigmatel_init)
6046 module_exit(patch_sigmatel_exit)