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 */
165 struct sigmatel_event {
172 struct sigmatel_jack {
175 struct snd_jack *jack;
178 struct sigmatel_spec {
179 struct snd_kcontrol_new *mixers[4];
180 unsigned int num_mixers;
183 unsigned int eapd_switch: 1;
184 unsigned int surr_switch: 1;
185 unsigned int alt_switch: 1;
186 unsigned int hp_detect: 1;
187 unsigned int spdif_mute: 1;
188 unsigned int check_volume_offset:1;
191 unsigned int eapd_mask;
192 unsigned int gpio_mask;
193 unsigned int gpio_dir;
194 unsigned int gpio_data;
195 unsigned int gpio_mute;
196 unsigned int gpio_led;
199 unsigned int stream_delay;
201 /* analog loopback */
202 struct snd_kcontrol_new *aloopback_ctl;
203 unsigned char aloopback_mask;
204 unsigned char aloopback_shift;
206 /* power management */
207 unsigned int num_pwrs;
208 unsigned int *pwr_mapping;
213 struct snd_array jacks;
216 struct snd_array events;
219 struct hda_input_mux *mono_mux;
220 struct hda_input_mux *amp_mux;
221 unsigned int cur_mmux;
222 struct hda_multi_out multiout;
223 hda_nid_t dac_nids[5];
224 hda_nid_t hp_dacs[5];
225 hda_nid_t speaker_dacs[5];
231 unsigned int num_adcs;
233 unsigned int num_muxes;
234 hda_nid_t *dmic_nids;
235 unsigned int num_dmics;
236 hda_nid_t *dmux_nids;
237 unsigned int num_dmuxes;
238 hda_nid_t *smux_nids;
239 unsigned int num_smuxes;
240 const char **spdif_labels;
242 hda_nid_t dig_in_nid;
244 hda_nid_t anabeep_nid;
245 hda_nid_t digbeep_nid;
249 unsigned int num_pins;
251 /* codec specific stuff */
252 struct hda_verb *init;
253 struct snd_kcontrol_new *mixer;
256 struct hda_input_mux *dinput_mux;
257 unsigned int cur_dmux[2];
258 struct hda_input_mux *input_mux;
259 unsigned int cur_mux[3];
260 struct hda_input_mux *sinput_mux;
261 unsigned int cur_smux[2];
262 unsigned int cur_amux;
264 unsigned int num_amps;
265 unsigned int powerdown_adcs;
268 unsigned int io_switch[2];
269 unsigned int clfe_swap;
270 hda_nid_t line_switch; /* shared line-in for input and output */
271 hda_nid_t mic_switch; /* shared mic-in for input and output */
272 hda_nid_t hp_switch; /* NID of HP as line-out */
273 unsigned int aloopback;
275 struct hda_pcm pcm_rec[2]; /* PCM information */
277 /* dynamic controls and input_mux */
278 struct auto_pin_cfg autocfg;
279 struct snd_array kctls;
280 struct hda_input_mux private_dimux;
281 struct hda_input_mux private_imux;
282 struct hda_input_mux private_smux;
283 struct hda_input_mux private_amp_mux;
284 struct hda_input_mux private_mono_mux;
287 static hda_nid_t stac9200_adc_nids[1] = {
291 static hda_nid_t stac9200_mux_nids[1] = {
295 static hda_nid_t stac9200_dac_nids[1] = {
299 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
300 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
304 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
308 static hda_nid_t stac92hd73xx_adc_nids[2] = {
312 #define DELL_M6_AMP 2
313 static hda_nid_t stac92hd73xx_amp_nids[3] = {
317 #define STAC92HD73XX_NUM_DMICS 2
318 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
322 #define STAC92HD73_DAC_COUNT 5
324 static hda_nid_t stac92hd73xx_mux_nids[4] = {
325 0x28, 0x29, 0x2a, 0x2b,
328 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
332 static hda_nid_t stac92hd73xx_smux_nids[2] = {
336 #define STAC92HD83XXX_NUM_DMICS 2
337 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
341 #define STAC92HD83_DAC_COUNT 3
343 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
347 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
351 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
355 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
359 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
360 0x03, 0x0c, 0x20, 0x40,
363 static hda_nid_t stac92hd83xxx_amp_nids[1] = {
367 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
371 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
375 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
379 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
383 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
387 #define STAC92HD71BXX_NUM_DMICS 2
388 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
392 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
396 static hda_nid_t stac925x_adc_nids[1] = {
400 static hda_nid_t stac925x_mux_nids[1] = {
404 static hda_nid_t stac925x_dac_nids[1] = {
408 #define STAC925X_NUM_DMICS 1
409 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
413 static hda_nid_t stac925x_dmux_nids[1] = {
417 static hda_nid_t stac922x_adc_nids[2] = {
421 static hda_nid_t stac922x_mux_nids[2] = {
425 static hda_nid_t stac927x_slave_dig_outs[2] = {
429 static hda_nid_t stac927x_adc_nids[3] = {
433 static hda_nid_t stac927x_mux_nids[3] = {
437 static hda_nid_t stac927x_smux_nids[1] = {
441 static hda_nid_t stac927x_dac_nids[6] = {
442 0x02, 0x03, 0x04, 0x05, 0x06, 0
445 static hda_nid_t stac927x_dmux_nids[1] = {
449 #define STAC927X_NUM_DMICS 2
450 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
454 static const char *stac927x_spdif_labels[5] = {
455 "Digital Playback", "ADAT", "Analog Mux 1",
456 "Analog Mux 2", "Analog Mux 3"
459 static hda_nid_t stac9205_adc_nids[2] = {
463 static hda_nid_t stac9205_mux_nids[2] = {
467 static hda_nid_t stac9205_dmux_nids[1] = {
471 static hda_nid_t stac9205_smux_nids[1] = {
475 #define STAC9205_NUM_DMICS 2
476 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
480 static hda_nid_t stac9200_pin_nids[8] = {
481 0x08, 0x09, 0x0d, 0x0e,
482 0x0f, 0x10, 0x11, 0x12,
485 static hda_nid_t stac925x_pin_nids[8] = {
486 0x07, 0x08, 0x0a, 0x0b,
487 0x0c, 0x0d, 0x10, 0x11,
490 static hda_nid_t stac922x_pin_nids[10] = {
491 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
492 0x0f, 0x10, 0x11, 0x15, 0x1b,
495 static hda_nid_t stac92hd73xx_pin_nids[13] = {
496 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
497 0x0f, 0x10, 0x11, 0x12, 0x13,
501 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
502 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
503 0x0f, 0x10, 0x11, 0x1f, 0x20,
506 #define STAC92HD71BXX_NUM_PINS 13
507 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
508 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
509 0x00, 0x14, 0x18, 0x19, 0x1e,
512 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
513 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
514 0x0f, 0x14, 0x18, 0x19, 0x1e,
518 static hda_nid_t stac927x_pin_nids[14] = {
519 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
520 0x0f, 0x10, 0x11, 0x12, 0x13,
521 0x14, 0x21, 0x22, 0x23,
524 static hda_nid_t stac9205_pin_nids[12] = {
525 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
526 0x0f, 0x14, 0x16, 0x17, 0x18,
530 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
532 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
533 struct snd_ctl_elem_value *ucontrol)
535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
536 struct sigmatel_spec *spec = codec->spec;
537 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
539 kcontrol->private_value ^= get_amp_nid(kcontrol);
540 kcontrol->private_value |= nid;
542 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
545 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
546 struct snd_ctl_elem_value *ucontrol)
548 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
549 struct sigmatel_spec *spec = codec->spec;
550 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
552 kcontrol->private_value ^= get_amp_nid(kcontrol);
553 kcontrol->private_value |= nid;
555 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
558 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
559 struct snd_ctl_elem_info *uinfo)
561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
562 struct sigmatel_spec *spec = codec->spec;
563 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
566 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
567 struct snd_ctl_elem_value *ucontrol)
569 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
570 struct sigmatel_spec *spec = codec->spec;
571 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
573 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
577 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
578 struct snd_ctl_elem_value *ucontrol)
580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
581 struct sigmatel_spec *spec = codec->spec;
582 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
584 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
585 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
588 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
589 struct snd_ctl_elem_info *uinfo)
591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
592 struct sigmatel_spec *spec = codec->spec;
593 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
596 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
597 struct snd_ctl_elem_value *ucontrol)
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 struct sigmatel_spec *spec = codec->spec;
601 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
603 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
607 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
608 struct snd_ctl_elem_value *ucontrol)
610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
611 struct sigmatel_spec *spec = codec->spec;
612 struct hda_input_mux *smux = &spec->private_smux;
613 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
617 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
618 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
622 if (spec->spdif_mute) {
624 nid = spec->multiout.dig_out_nid;
626 nid = codec->slave_dig_outs[smux_idx - 1];
627 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
631 /* un/mute SPDIF out */
632 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
638 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
639 hda_nid_t nid, unsigned int new_vref)
643 pincfg = snd_hda_codec_read(codec, nid, 0,
644 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
647 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
650 if (new_vref == AC_PINCTL_VREF_HIZ)
651 pincfg |= AC_PINCTL_OUT_EN;
653 pincfg |= AC_PINCTL_IN_EN;
655 error = snd_hda_codec_write_cache(codec, nid, 0,
656 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
663 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
666 vref = snd_hda_codec_read(codec, nid, 0,
667 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
668 vref &= AC_PINCTL_VREFEN;
672 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_value *ucontrol)
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 unsigned int new_vref;
679 if (ucontrol->value.enumerated.item[0] == 0)
680 new_vref = AC_PINCTL_VREF_80;
681 else if (ucontrol->value.enumerated.item[0] == 1)
682 new_vref = AC_PINCTL_VREF_GRD;
684 new_vref = AC_PINCTL_VREF_HIZ;
686 if (new_vref != stac92xx_vref_get(codec, kcontrol->private_value)) {
687 error = stac92xx_vref_set(codec,
688 kcontrol->private_value, new_vref);
695 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
696 struct snd_ctl_elem_value *ucontrol)
698 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
699 unsigned int vref = stac92xx_vref_get(codec, kcontrol->private_value);
700 if (vref == AC_PINCTL_VREF_80)
701 ucontrol->value.enumerated.item[0] = 0;
702 else if (vref == AC_PINCTL_VREF_GRD)
703 ucontrol->value.enumerated.item[0] = 1;
704 else if (vref == AC_PINCTL_VREF_HIZ)
705 ucontrol->value.enumerated.item[0] = 2;
710 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
711 struct snd_ctl_elem_info *uinfo)
713 static char *texts[] = {
714 "Mic In", "Line In", "Line Out"
717 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
718 uinfo->value.enumerated.items = 3;
720 if (uinfo->value.enumerated.item >= 3)
721 uinfo->value.enumerated.item = 2;
722 strcpy(uinfo->value.enumerated.name,
723 texts[uinfo->value.enumerated.item]);
728 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
730 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
731 struct sigmatel_spec *spec = codec->spec;
732 return snd_hda_input_mux_info(spec->input_mux, uinfo);
735 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
738 struct sigmatel_spec *spec = codec->spec;
739 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
741 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
745 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
748 struct sigmatel_spec *spec = codec->spec;
749 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
751 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
752 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
755 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
756 struct snd_ctl_elem_info *uinfo)
758 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
759 struct sigmatel_spec *spec = codec->spec;
760 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
763 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
764 struct snd_ctl_elem_value *ucontrol)
766 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
767 struct sigmatel_spec *spec = codec->spec;
769 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
773 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
774 struct snd_ctl_elem_value *ucontrol)
776 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
777 struct sigmatel_spec *spec = codec->spec;
779 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
780 spec->mono_nid, &spec->cur_mmux);
783 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
784 struct snd_ctl_elem_info *uinfo)
786 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
787 struct sigmatel_spec *spec = codec->spec;
788 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
791 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
792 struct snd_ctl_elem_value *ucontrol)
794 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
795 struct sigmatel_spec *spec = codec->spec;
797 ucontrol->value.enumerated.item[0] = spec->cur_amux;
801 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
802 struct snd_ctl_elem_value *ucontrol)
804 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
805 struct sigmatel_spec *spec = codec->spec;
806 struct snd_kcontrol *ctl =
807 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
811 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
812 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
814 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
818 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
820 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
821 struct snd_ctl_elem_value *ucontrol)
823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
824 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
825 struct sigmatel_spec *spec = codec->spec;
827 ucontrol->value.integer.value[0] = !!(spec->aloopback &
828 (spec->aloopback_mask << idx));
832 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
833 struct snd_ctl_elem_value *ucontrol)
835 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
836 struct sigmatel_spec *spec = codec->spec;
837 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
838 unsigned int dac_mode;
839 unsigned int val, idx_val;
841 idx_val = spec->aloopback_mask << idx;
842 if (ucontrol->value.integer.value[0])
843 val = spec->aloopback | idx_val;
845 val = spec->aloopback & ~idx_val;
846 if (spec->aloopback == val)
849 spec->aloopback = val;
851 /* Only return the bits defined by the shift value of the
852 * first two bytes of the mask
854 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
855 kcontrol->private_value & 0xFFFF, 0x0);
856 dac_mode >>= spec->aloopback_shift;
858 if (spec->aloopback & idx_val) {
859 snd_hda_power_up(codec);
862 snd_hda_power_down(codec);
863 dac_mode &= ~idx_val;
866 snd_hda_codec_write_cache(codec, codec->afg, 0,
867 kcontrol->private_value >> 16, dac_mode);
872 static struct hda_verb stac9200_core_init[] = {
873 /* set dac0mux for dac converter */
874 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
878 static struct hda_verb stac9200_eapd_init[] = {
879 /* set dac0mux for dac converter */
880 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
881 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
885 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
886 /* set master volume and direct control */
887 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
888 /* setup adcs to point to mixer */
889 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
890 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
891 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
892 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
893 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
894 /* setup import muxs */
895 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
896 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
897 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
898 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
902 static struct hda_verb dell_eq_core_init[] = {
903 /* set master volume to max value without distortion
904 * and direct control */
905 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
906 /* setup adcs to point to mixer */
907 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
908 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
909 /* setup import muxs */
910 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
911 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
912 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
913 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
917 static struct hda_verb dell_m6_core_init[] = {
918 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
919 /* setup adcs to point to mixer */
920 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
921 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
922 /* setup import muxs */
923 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
924 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
925 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
926 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
930 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
931 /* set master volume and direct control */
932 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
933 /* setup adcs to point to mixer */
934 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
935 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
936 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
937 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
938 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
939 /* setup import muxs */
940 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
941 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
942 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
943 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
947 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
948 /* set master volume and direct control */
949 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
950 /* dac3 is connected to import3 mux */
951 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
952 /* setup adcs to point to mixer */
953 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
954 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
955 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
956 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
957 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
958 /* setup import muxs */
959 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
960 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
961 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
962 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
966 static struct hda_verb stac92hd83xxx_core_init[] = {
967 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
968 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
969 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
971 /* power state controls amps */
972 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
976 static struct hda_verb stac92hd71bxx_core_init[] = {
977 /* set master volume and direct control */
978 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
982 #define HD_DISABLE_PORTF 1
983 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
984 /* start of config #1 */
986 /* connect port 0f to audio mixer */
987 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
988 /* start of config #2 */
990 /* set master volume and direct control */
991 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
995 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
996 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
997 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
998 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
999 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1003 static struct hda_verb stac925x_core_init[] = {
1004 /* set dac0mux for dac converter */
1005 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
1006 /* mute the master volume */
1007 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1011 static struct hda_verb stac922x_core_init[] = {
1012 /* set master volume and direct control */
1013 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1017 static struct hda_verb d965_core_init[] = {
1018 /* set master volume and direct control */
1019 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1020 /* unmute node 0x1b */
1021 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1022 /* select node 0x03 as DAC */
1023 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
1027 static struct hda_verb stac927x_core_init[] = {
1028 /* set master volume and direct control */
1029 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1030 /* enable analog pc beep path */
1031 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
1035 static struct hda_verb stac9205_core_init[] = {
1036 /* set master volume and direct control */
1037 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
1038 /* enable analog pc beep path */
1039 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
1043 #define STAC_MONO_MUX \
1045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1046 .name = "Mono Mux", \
1048 .info = stac92xx_mono_mux_enum_info, \
1049 .get = stac92xx_mono_mux_enum_get, \
1050 .put = stac92xx_mono_mux_enum_put, \
1053 #define STAC_AMP_MUX \
1055 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1056 .name = "Amp Selector Capture Switch", \
1058 .info = stac92xx_amp_mux_enum_info, \
1059 .get = stac92xx_amp_mux_enum_get, \
1060 .put = stac92xx_amp_mux_enum_put, \
1063 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1065 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1068 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1069 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1070 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1071 .info = stac92xx_amp_volume_info, \
1072 .get = stac92xx_amp_volume_get, \
1073 .put = stac92xx_amp_volume_put, \
1074 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1075 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1078 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
1080 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1081 .name = "Analog Loopback", \
1083 .info = stac92xx_aloopback_info, \
1084 .get = stac92xx_aloopback_get, \
1085 .put = stac92xx_aloopback_put, \
1086 .private_value = verb_read | (verb_write << 16), \
1089 #define DC_BIAS(xname, idx, nid) \
1091 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1094 .info = stac92xx_dc_bias_info, \
1095 .get = stac92xx_dc_bias_get, \
1096 .put = stac92xx_dc_bias_put, \
1097 .private_value = nid, \
1100 static struct snd_kcontrol_new stac9200_mixer[] = {
1101 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1102 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
1103 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1104 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1108 #define DELL_M6_MIXER 6
1109 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1110 /* start of config #1 */
1111 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1112 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1114 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1115 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1117 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1118 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1120 /* start of config #2 */
1121 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1122 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1124 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1125 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1127 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1128 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1131 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1136 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1137 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1141 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1142 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1146 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1147 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1151 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1152 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1153 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1155 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1156 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1158 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1159 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1161 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1162 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1164 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1165 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1167 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1168 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1170 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1171 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1175 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1176 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1177 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1179 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1180 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1182 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1183 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1185 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1186 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1188 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1189 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1191 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1192 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1194 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1195 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1200 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1201 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1202 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1204 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1205 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1207 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1208 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
1210 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1211 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
1213 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1214 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
1216 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1217 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
1220 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1221 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
1226 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1227 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1228 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1230 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1231 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1232 /* analog pc-beep replaced with digital beep support */
1234 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1235 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1238 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1239 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1241 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1242 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1244 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1245 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1247 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1248 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1252 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1253 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1256 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1257 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1258 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1260 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1261 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1265 static struct snd_kcontrol_new stac925x_mixer[] = {
1266 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1267 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1268 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1269 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1273 static struct snd_kcontrol_new stac9205_mixer[] = {
1274 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1275 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1277 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1278 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1282 static struct snd_kcontrol_new stac9205_loopback[] = {
1283 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1287 /* This needs to be generated dynamically based on sequence */
1288 static struct snd_kcontrol_new stac922x_mixer[] = {
1289 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1290 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1292 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1293 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1298 static struct snd_kcontrol_new stac927x_mixer[] = {
1299 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1300 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1302 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1303 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1305 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1306 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1310 static struct snd_kcontrol_new stac927x_loopback[] = {
1311 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1315 static struct snd_kcontrol_new stac_dmux_mixer = {
1316 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1317 .name = "Digital Input Source",
1318 /* count set later */
1319 .info = stac92xx_dmux_enum_info,
1320 .get = stac92xx_dmux_enum_get,
1321 .put = stac92xx_dmux_enum_put,
1324 static struct snd_kcontrol_new stac_smux_mixer = {
1325 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1326 .name = "IEC958 Playback Source",
1327 /* count set later */
1328 .info = stac92xx_smux_enum_info,
1329 .get = stac92xx_smux_enum_get,
1330 .put = stac92xx_smux_enum_put,
1333 static const char *slave_vols[] = {
1334 "Front Playback Volume",
1335 "Surround Playback Volume",
1336 "Center Playback Volume",
1337 "LFE Playback Volume",
1338 "Side Playback Volume",
1339 "Headphone Playback Volume",
1340 "Speaker Playback Volume",
1344 static const char *slave_sws[] = {
1345 "Front Playback Switch",
1346 "Surround Playback Switch",
1347 "Center Playback Switch",
1348 "LFE Playback Switch",
1349 "Side Playback Switch",
1350 "Headphone Playback Switch",
1351 "Speaker Playback Switch",
1352 "IEC958 Playback Switch",
1356 static void stac92xx_free_kctls(struct hda_codec *codec);
1357 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1359 static int stac92xx_build_controls(struct hda_codec *codec)
1361 struct sigmatel_spec *spec = codec->spec;
1362 struct auto_pin_cfg *cfg = &spec->autocfg;
1367 err = snd_hda_add_new_ctls(codec, spec->mixer);
1371 for (i = 0; i < spec->num_mixers; i++) {
1372 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1376 if (spec->num_dmuxes > 0) {
1377 stac_dmux_mixer.count = spec->num_dmuxes;
1378 err = snd_hda_ctl_add(codec,
1379 snd_ctl_new1(&stac_dmux_mixer, codec));
1383 if (spec->num_smuxes > 0) {
1384 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1385 struct hda_input_mux *smux = &spec->private_smux;
1386 /* check for mute support on SPDIF out */
1387 if (wcaps & AC_WCAP_OUT_AMP) {
1388 smux->items[smux->num_items].label = "Off";
1389 smux->items[smux->num_items].index = 0;
1391 spec->spdif_mute = 1;
1393 stac_smux_mixer.count = spec->num_smuxes;
1394 err = snd_hda_ctl_add(codec,
1395 snd_ctl_new1(&stac_smux_mixer, codec));
1400 if (spec->multiout.dig_out_nid) {
1401 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1404 err = snd_hda_create_spdif_share_sw(codec,
1408 spec->multiout.share_spdif = 1;
1410 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1411 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1416 /* if we have no master control, let's create it */
1417 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1418 unsigned int vmaster_tlv[4];
1419 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1420 HDA_OUTPUT, vmaster_tlv);
1421 /* correct volume offset */
1422 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1423 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1424 vmaster_tlv, slave_vols);
1428 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1429 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1435 if (spec->aloopback_ctl &&
1436 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1437 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1442 stac92xx_free_kctls(codec); /* no longer needed */
1444 /* create jack input elements */
1445 if (spec->hp_detect) {
1446 for (i = 0; i < cfg->hp_outs; i++) {
1447 int type = SND_JACK_HEADPHONE;
1448 nid = cfg->hp_pins[i];
1449 /* jack detection */
1450 if (cfg->hp_outs == i)
1451 type |= SND_JACK_LINEOUT;
1452 err = stac92xx_add_jack(codec, nid, type);
1457 for (i = 0; i < cfg->line_outs; i++) {
1458 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1463 for (i = 0; i < AUTO_PIN_LAST; i++) {
1464 nid = cfg->input_pins[i];
1466 err = stac92xx_add_jack(codec, nid,
1467 SND_JACK_MICROPHONE);
1476 static unsigned int ref9200_pin_configs[8] = {
1477 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1478 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1481 static unsigned int gateway9200_m4_pin_configs[8] = {
1482 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1483 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1485 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1486 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1487 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1491 STAC 9200 pin configs for
1496 static unsigned int dell9200_d21_pin_configs[8] = {
1497 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1498 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1502 STAC 9200 pin configs for
1506 static unsigned int dell9200_d22_pin_configs[8] = {
1507 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1508 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1512 STAC 9200 pin configs for
1513 102801C4 (Dell Dimension E310)
1520 static unsigned int dell9200_d23_pin_configs[8] = {
1521 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1522 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1527 STAC 9200-32 pin configs for
1528 102801B5 (Dell Inspiron 630m)
1529 102801D8 (Dell Inspiron 640m)
1531 static unsigned int dell9200_m21_pin_configs[8] = {
1532 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1533 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1537 STAC 9200-32 pin configs for
1538 102801C2 (Dell Latitude D620)
1540 102801CC (Dell Latitude D820)
1544 static unsigned int dell9200_m22_pin_configs[8] = {
1545 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1546 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1550 STAC 9200-32 pin configs for
1551 102801CE (Dell XPS M1710)
1552 102801CF (Dell Precision M90)
1554 static unsigned int dell9200_m23_pin_configs[8] = {
1555 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1556 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1560 STAC 9200-32 pin configs for
1563 102801CB (Dell Latitude 120L)
1566 static unsigned int dell9200_m24_pin_configs[8] = {
1567 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1568 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1572 STAC 9200-32 pin configs for
1573 102801BD (Dell Inspiron E1505n)
1577 static unsigned int dell9200_m25_pin_configs[8] = {
1578 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1579 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1583 STAC 9200-32 pin configs for
1584 102801F5 (Dell Inspiron 1501)
1587 static unsigned int dell9200_m26_pin_configs[8] = {
1588 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1589 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1594 102801CD (Dell Inspiron E1705/9400)
1596 static unsigned int dell9200_m27_pin_configs[8] = {
1597 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1598 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1601 static unsigned int oqo9200_pin_configs[8] = {
1602 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1603 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1607 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1608 [STAC_REF] = ref9200_pin_configs,
1609 [STAC_9200_OQO] = oqo9200_pin_configs,
1610 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1611 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1612 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1613 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1614 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1615 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1616 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1617 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1618 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1619 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1620 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1621 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1622 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1625 static const char *stac9200_models[STAC_9200_MODELS] = {
1626 [STAC_AUTO] = "auto",
1628 [STAC_9200_OQO] = "oqo",
1629 [STAC_9200_DELL_D21] = "dell-d21",
1630 [STAC_9200_DELL_D22] = "dell-d22",
1631 [STAC_9200_DELL_D23] = "dell-d23",
1632 [STAC_9200_DELL_M21] = "dell-m21",
1633 [STAC_9200_DELL_M22] = "dell-m22",
1634 [STAC_9200_DELL_M23] = "dell-m23",
1635 [STAC_9200_DELL_M24] = "dell-m24",
1636 [STAC_9200_DELL_M25] = "dell-m25",
1637 [STAC_9200_DELL_M26] = "dell-m26",
1638 [STAC_9200_DELL_M27] = "dell-m27",
1639 [STAC_9200_M4] = "gateway-m4",
1640 [STAC_9200_M4_2] = "gateway-m4-2",
1641 [STAC_9200_PANASONIC] = "panasonic",
1644 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1645 /* SigmaTel reference board */
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1647 "DFI LanParty", STAC_REF),
1648 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1649 "DFI LanParty", STAC_REF),
1650 /* Dell laptops have BIOS problem */
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1652 "unknown Dell", STAC_9200_DELL_D21),
1653 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1654 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1656 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1657 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1658 "unknown Dell", STAC_9200_DELL_D22),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1660 "unknown Dell", STAC_9200_DELL_D22),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1662 "Dell Latitude D620", STAC_9200_DELL_M22),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1664 "unknown Dell", STAC_9200_DELL_D23),
1665 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1666 "unknown Dell", STAC_9200_DELL_D23),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1668 "unknown Dell", STAC_9200_DELL_M22),
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1670 "unknown Dell", STAC_9200_DELL_M24),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1672 "unknown Dell", STAC_9200_DELL_M24),
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1674 "Dell Latitude 120L", STAC_9200_DELL_M24),
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1676 "Dell Latitude D820", STAC_9200_DELL_M22),
1677 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1678 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1680 "Dell XPS M1710", STAC_9200_DELL_M23),
1681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1682 "Dell Precision M90", STAC_9200_DELL_M23),
1683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1684 "unknown Dell", STAC_9200_DELL_M22),
1685 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1686 "unknown Dell", STAC_9200_DELL_M22),
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1688 "unknown Dell", STAC_9200_DELL_M22),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1690 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1692 "unknown Dell", STAC_9200_DELL_D23),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1694 "unknown Dell", STAC_9200_DELL_D23),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1696 "unknown Dell", STAC_9200_DELL_D21),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1698 "unknown Dell", STAC_9200_DELL_D23),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1700 "unknown Dell", STAC_9200_DELL_D21),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1702 "unknown Dell", STAC_9200_DELL_M25),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1704 "unknown Dell", STAC_9200_DELL_M25),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1706 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1708 "unknown Dell", STAC_9200_DELL_M26),
1710 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1711 /* Gateway machines needs EAPD to be set on resume */
1712 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1713 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1714 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1716 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1720 static unsigned int ref925x_pin_configs[8] = {
1721 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1722 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1725 static unsigned int stac925xM1_pin_configs[8] = {
1726 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1727 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1730 static unsigned int stac925xM1_2_pin_configs[8] = {
1731 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1732 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1735 static unsigned int stac925xM2_pin_configs[8] = {
1736 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1737 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1740 static unsigned int stac925xM2_2_pin_configs[8] = {
1741 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1742 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1745 static unsigned int stac925xM3_pin_configs[8] = {
1746 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1747 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1750 static unsigned int stac925xM5_pin_configs[8] = {
1751 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1752 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1755 static unsigned int stac925xM6_pin_configs[8] = {
1756 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1757 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1760 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1761 [STAC_REF] = ref925x_pin_configs,
1762 [STAC_M1] = stac925xM1_pin_configs,
1763 [STAC_M1_2] = stac925xM1_2_pin_configs,
1764 [STAC_M2] = stac925xM2_pin_configs,
1765 [STAC_M2_2] = stac925xM2_2_pin_configs,
1766 [STAC_M3] = stac925xM3_pin_configs,
1767 [STAC_M5] = stac925xM5_pin_configs,
1768 [STAC_M6] = stac925xM6_pin_configs,
1771 static const char *stac925x_models[STAC_925x_MODELS] = {
1772 [STAC_925x_AUTO] = "auto",
1775 [STAC_M1_2] = "m1-2",
1777 [STAC_M2_2] = "m2-2",
1783 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1784 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1785 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1786 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1787 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1788 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1789 /* Not sure about the brand name for those */
1790 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1791 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1792 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1793 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1797 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1798 /* SigmaTel reference board */
1799 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1800 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1801 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1803 /* Default table for unknown ID */
1804 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1809 static unsigned int ref92hd73xx_pin_configs[13] = {
1810 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1811 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1812 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1816 static unsigned int dell_m6_pin_configs[13] = {
1817 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1818 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1819 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1823 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1824 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1825 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1826 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1827 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1828 [STAC_DELL_EQ] = dell_m6_pin_configs,
1831 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1832 [STAC_92HD73XX_AUTO] = "auto",
1833 [STAC_92HD73XX_NO_JD] = "no-jd",
1834 [STAC_92HD73XX_REF] = "ref",
1835 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1836 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1837 [STAC_DELL_M6_BOTH] = "dell-m6",
1838 [STAC_DELL_EQ] = "dell-eq",
1841 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1842 /* SigmaTel reference board */
1843 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1844 "DFI LanParty", STAC_92HD73XX_REF),
1845 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1846 "DFI LanParty", STAC_92HD73XX_REF),
1847 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1848 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1849 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1850 "unknown Dell", STAC_DELL_M6_DMIC),
1851 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1852 "unknown Dell", STAC_DELL_M6_BOTH),
1853 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1854 "unknown Dell", STAC_DELL_M6_BOTH),
1855 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1856 "unknown Dell", STAC_DELL_M6_AMIC),
1857 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1858 "unknown Dell", STAC_DELL_M6_AMIC),
1859 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1860 "unknown Dell", STAC_DELL_M6_DMIC),
1861 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1862 "unknown Dell", STAC_DELL_M6_DMIC),
1863 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1864 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1865 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1866 "Dell Studio 17", STAC_DELL_M6_DMIC),
1870 static unsigned int ref92hd83xxx_pin_configs[10] = {
1871 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1872 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1873 0x01451160, 0x98560170,
1876 static unsigned int dell_s14_pin_configs[10] = {
1877 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1878 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1879 0x40f000f0, 0x40f000f0,
1882 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1883 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1884 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1885 [STAC_DELL_S14] = dell_s14_pin_configs,
1888 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1889 [STAC_92HD83XXX_AUTO] = "auto",
1890 [STAC_92HD83XXX_REF] = "ref",
1891 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1892 [STAC_DELL_S14] = "dell-s14",
1895 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1896 /* SigmaTel reference board */
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1898 "DFI LanParty", STAC_92HD83XXX_REF),
1899 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1900 "DFI LanParty", STAC_92HD83XXX_REF),
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1902 "unknown Dell", STAC_DELL_S14),
1906 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1907 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1908 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1909 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1913 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1914 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1915 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1916 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1920 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1921 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1922 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1923 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1927 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1928 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1929 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1930 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1934 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1935 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1936 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1937 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1938 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1939 [STAC_HP_M4] = NULL,
1940 [STAC_HP_DV5] = NULL,
1941 [STAC_HP_HDX] = NULL,
1942 [STAC_HP_DV4_1222NR] = NULL,
1945 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1946 [STAC_92HD71BXX_AUTO] = "auto",
1947 [STAC_92HD71BXX_REF] = "ref",
1948 [STAC_DELL_M4_1] = "dell-m4-1",
1949 [STAC_DELL_M4_2] = "dell-m4-2",
1950 [STAC_DELL_M4_3] = "dell-m4-3",
1951 [STAC_HP_M4] = "hp-m4",
1952 [STAC_HP_DV5] = "hp-dv5",
1953 [STAC_HP_HDX] = "hp-hdx",
1954 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1957 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1958 /* SigmaTel reference board */
1959 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1960 "DFI LanParty", STAC_92HD71BXX_REF),
1961 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1962 "DFI LanParty", STAC_92HD71BXX_REF),
1963 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1964 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1965 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1967 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1968 "HP dv4-7", STAC_HP_DV5),
1969 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1970 "HP dv4-7", STAC_HP_DV5),
1971 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1972 "HP HDX", STAC_HP_HDX), /* HDX18 */
1973 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1974 "HP mini 1000", STAC_HP_M4),
1975 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1976 "HP HDX", STAC_HP_HDX), /* HDX16 */
1977 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1978 "unknown Dell", STAC_DELL_M4_1),
1979 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1980 "unknown Dell", STAC_DELL_M4_1),
1981 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1982 "unknown Dell", STAC_DELL_M4_1),
1983 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1984 "unknown Dell", STAC_DELL_M4_1),
1985 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1986 "unknown Dell", STAC_DELL_M4_1),
1987 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1988 "unknown Dell", STAC_DELL_M4_1),
1989 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1990 "unknown Dell", STAC_DELL_M4_1),
1991 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1992 "unknown Dell", STAC_DELL_M4_2),
1993 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1994 "unknown Dell", STAC_DELL_M4_2),
1995 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1996 "unknown Dell", STAC_DELL_M4_2),
1997 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1998 "unknown Dell", STAC_DELL_M4_2),
1999 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
2000 "unknown Dell", STAC_DELL_M4_3),
2004 static unsigned int ref922x_pin_configs[10] = {
2005 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
2006 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
2007 0x40000100, 0x40000100,
2011 STAC 922X pin configs for
2018 static unsigned int dell_922x_d81_pin_configs[10] = {
2019 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
2020 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
2021 0x01813122, 0x400001f2,
2025 STAC 922X pin configs for
2029 static unsigned int dell_922x_d82_pin_configs[10] = {
2030 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
2031 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
2032 0x01813122, 0x400001f1,
2036 STAC 922X pin configs for
2039 static unsigned int dell_922x_m81_pin_configs[10] = {
2040 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
2041 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
2042 0x40C003f1, 0x405003f0,
2046 STAC 9221 A1 pin configs for
2047 102801D7 (Dell XPS M1210)
2049 static unsigned int dell_922x_m82_pin_configs[10] = {
2050 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
2051 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
2052 0x508003f3, 0x405003f4,
2055 static unsigned int d945gtp3_pin_configs[10] = {
2056 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
2057 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2058 0x02a19120, 0x40000100,
2061 static unsigned int d945gtp5_pin_configs[10] = {
2062 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
2063 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
2064 0x02a19320, 0x40000100,
2067 static unsigned int intel_mac_v1_pin_configs[10] = {
2068 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
2069 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
2070 0x400000fc, 0x400000fb,
2073 static unsigned int intel_mac_v2_pin_configs[10] = {
2074 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2075 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
2076 0x400000fc, 0x400000fb,
2079 static unsigned int intel_mac_v3_pin_configs[10] = {
2080 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
2081 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
2082 0x400000fc, 0x400000fb,
2085 static unsigned int intel_mac_v4_pin_configs[10] = {
2086 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2087 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2088 0x400000fc, 0x400000fb,
2091 static unsigned int intel_mac_v5_pin_configs[10] = {
2092 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
2093 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
2094 0x400000fc, 0x400000fb,
2097 static unsigned int ecs202_pin_configs[10] = {
2098 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
2099 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
2100 0x9037012e, 0x40e000f2,
2103 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
2104 [STAC_D945_REF] = ref922x_pin_configs,
2105 [STAC_D945GTP3] = d945gtp3_pin_configs,
2106 [STAC_D945GTP5] = d945gtp5_pin_configs,
2107 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
2108 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
2109 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
2110 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
2111 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
2112 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
2113 /* for backward compatibility */
2114 [STAC_MACMINI] = intel_mac_v3_pin_configs,
2115 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
2116 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
2117 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
2118 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
2119 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
2120 [STAC_ECS_202] = ecs202_pin_configs,
2121 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
2122 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
2123 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
2124 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
2127 static const char *stac922x_models[STAC_922X_MODELS] = {
2128 [STAC_922X_AUTO] = "auto",
2129 [STAC_D945_REF] = "ref",
2130 [STAC_D945GTP5] = "5stack",
2131 [STAC_D945GTP3] = "3stack",
2132 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
2133 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
2134 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
2135 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
2136 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
2137 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
2138 /* for backward compatibility */
2139 [STAC_MACMINI] = "macmini",
2140 [STAC_MACBOOK] = "macbook",
2141 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2142 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
2143 [STAC_IMAC_INTEL] = "imac-intel",
2144 [STAC_IMAC_INTEL_20] = "imac-intel-20",
2145 [STAC_ECS_202] = "ecs202",
2146 [STAC_922X_DELL_D81] = "dell-d81",
2147 [STAC_922X_DELL_D82] = "dell-d82",
2148 [STAC_922X_DELL_M81] = "dell-m81",
2149 [STAC_922X_DELL_M82] = "dell-m82",
2152 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2153 /* SigmaTel reference board */
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2155 "DFI LanParty", STAC_D945_REF),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2157 "DFI LanParty", STAC_D945_REF),
2158 /* Intel 945G based systems */
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2160 "Intel D945G", STAC_D945GTP3),
2161 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2162 "Intel D945G", STAC_D945GTP3),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2164 "Intel D945G", STAC_D945GTP3),
2165 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2166 "Intel D945G", STAC_D945GTP3),
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2168 "Intel D945G", STAC_D945GTP3),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2170 "Intel D945G", STAC_D945GTP3),
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2172 "Intel D945G", STAC_D945GTP3),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2174 "Intel D945G", STAC_D945GTP3),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2176 "Intel D945G", STAC_D945GTP3),
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2178 "Intel D945G", STAC_D945GTP3),
2179 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2180 "Intel D945G", STAC_D945GTP3),
2181 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2182 "Intel D945G", STAC_D945GTP3),
2183 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2184 "Intel D945G", STAC_D945GTP3),
2185 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2186 "Intel D945G", STAC_D945GTP3),
2187 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2188 "Intel D945G", STAC_D945GTP3),
2189 /* Intel D945G 5-stack systems */
2190 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2191 "Intel D945G", STAC_D945GTP5),
2192 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2193 "Intel D945G", STAC_D945GTP5),
2194 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2195 "Intel D945G", STAC_D945GTP5),
2196 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2197 "Intel D945G", STAC_D945GTP5),
2198 /* Intel 945P based systems */
2199 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2200 "Intel D945P", STAC_D945GTP3),
2201 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2202 "Intel D945P", STAC_D945GTP3),
2203 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2204 "Intel D945P", STAC_D945GTP3),
2205 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2206 "Intel D945P", STAC_D945GTP3),
2207 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2208 "Intel D945P", STAC_D945GTP3),
2209 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2210 "Intel D945P", STAC_D945GTP5),
2212 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2213 "Intel D945", STAC_D945_REF),
2215 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2216 SND_PCI_QUIRK(0x8384, 0x7680,
2217 "Mac", STAC_INTEL_MAC_AUTO),
2219 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2220 "unknown Dell", STAC_922X_DELL_D81),
2221 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2222 "unknown Dell", STAC_922X_DELL_D81),
2223 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2224 "unknown Dell", STAC_922X_DELL_D81),
2225 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2226 "unknown Dell", STAC_922X_DELL_D82),
2227 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2228 "unknown Dell", STAC_922X_DELL_M81),
2229 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2230 "unknown Dell", STAC_922X_DELL_D82),
2231 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2232 "unknown Dell", STAC_922X_DELL_D81),
2233 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2234 "unknown Dell", STAC_922X_DELL_D81),
2235 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2236 "Dell XPS M1210", STAC_922X_DELL_M82),
2237 /* ECS/PC Chips boards */
2238 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2239 "ECS/PC chips", STAC_ECS_202),
2243 static unsigned int ref927x_pin_configs[14] = {
2244 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2245 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2246 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2247 0x01c42190, 0x40000100,
2250 static unsigned int d965_3st_pin_configs[14] = {
2251 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2252 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2253 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2254 0x40000100, 0x40000100
2257 static unsigned int d965_5st_pin_configs[14] = {
2258 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2259 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2260 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2261 0x40000100, 0x40000100
2264 static unsigned int dell_3st_pin_configs[14] = {
2265 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2266 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2267 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2268 0x40c003fc, 0x40000100
2271 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2272 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2273 [STAC_D965_REF] = ref927x_pin_configs,
2274 [STAC_D965_3ST] = d965_3st_pin_configs,
2275 [STAC_D965_5ST] = d965_5st_pin_configs,
2276 [STAC_DELL_3ST] = dell_3st_pin_configs,
2277 [STAC_DELL_BIOS] = NULL,
2280 static const char *stac927x_models[STAC_927X_MODELS] = {
2281 [STAC_927X_AUTO] = "auto",
2282 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2283 [STAC_D965_REF] = "ref",
2284 [STAC_D965_3ST] = "3stack",
2285 [STAC_D965_5ST] = "5stack",
2286 [STAC_DELL_3ST] = "dell-3stack",
2287 [STAC_DELL_BIOS] = "dell-bios",
2290 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2291 /* SigmaTel reference board */
2292 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2293 "DFI LanParty", STAC_D965_REF),
2294 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2295 "DFI LanParty", STAC_D965_REF),
2296 /* Intel 946 based systems */
2297 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2298 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2299 /* 965 based 3 stack systems */
2300 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2301 "Intel D965", STAC_D965_3ST),
2302 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2303 "Intel D965", STAC_D965_3ST),
2304 /* Dell 3 stack systems */
2305 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2306 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2307 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2308 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2309 /* Dell 3 stack systems with verb table in BIOS */
2310 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2311 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2312 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2313 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2314 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2315 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2316 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2317 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2318 /* 965 based 5 stack systems */
2319 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2320 "Intel D965", STAC_D965_5ST),
2321 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2322 "Intel D965", STAC_D965_5ST),
2326 static unsigned int ref9205_pin_configs[12] = {
2327 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2328 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2329 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2333 STAC 9205 pin configs for
2340 10280228 (Dell Vostro 1500)
2342 static unsigned int dell_9205_m42_pin_configs[12] = {
2343 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2344 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2345 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2349 STAC 9205 pin configs for
2353 102801FF (Dell Precision M4300)
2358 static unsigned int dell_9205_m43_pin_configs[12] = {
2359 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2360 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2361 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2364 static unsigned int dell_9205_m44_pin_configs[12] = {
2365 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2366 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2367 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2370 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2371 [STAC_9205_REF] = ref9205_pin_configs,
2372 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2373 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2374 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2375 [STAC_9205_EAPD] = NULL,
2378 static const char *stac9205_models[STAC_9205_MODELS] = {
2379 [STAC_9205_AUTO] = "auto",
2380 [STAC_9205_REF] = "ref",
2381 [STAC_9205_DELL_M42] = "dell-m42",
2382 [STAC_9205_DELL_M43] = "dell-m43",
2383 [STAC_9205_DELL_M44] = "dell-m44",
2384 [STAC_9205_EAPD] = "eapd",
2387 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2388 /* SigmaTel reference board */
2389 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2390 "DFI LanParty", STAC_9205_REF),
2391 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2392 "DFI LanParty", STAC_9205_REF),
2394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2395 "unknown Dell", STAC_9205_DELL_M42),
2396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2397 "unknown Dell", STAC_9205_DELL_M42),
2398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2399 "Dell Precision", STAC_9205_DELL_M43),
2400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2401 "Dell Precision", STAC_9205_DELL_M43),
2402 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2403 "Dell Precision", STAC_9205_DELL_M43),
2404 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2405 "unknown Dell", STAC_9205_DELL_M42),
2406 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2407 "unknown Dell", STAC_9205_DELL_M42),
2408 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2409 "Dell Precision", STAC_9205_DELL_M43),
2410 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2411 "Dell Precision M4300", STAC_9205_DELL_M43),
2412 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2413 "unknown Dell", STAC_9205_DELL_M42),
2414 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2415 "Dell Precision", STAC_9205_DELL_M43),
2416 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2417 "Dell Precision", STAC_9205_DELL_M43),
2418 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2419 "Dell Precision", STAC_9205_DELL_M43),
2420 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2421 "Dell Inspiron", STAC_9205_DELL_M44),
2422 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2423 "Dell Vostro 1500", STAC_9205_DELL_M42),
2425 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2429 static void stac92xx_set_config_regs(struct hda_codec *codec,
2430 unsigned int *pincfgs)
2433 struct sigmatel_spec *spec = codec->spec;
2438 for (i = 0; i < spec->num_pins; i++)
2439 if (spec->pin_nids[i] && pincfgs[i])
2440 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2445 * Analog playback callbacks
2447 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2448 struct hda_codec *codec,
2449 struct snd_pcm_substream *substream)
2451 struct sigmatel_spec *spec = codec->spec;
2452 if (spec->stream_delay)
2453 msleep(spec->stream_delay);
2454 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2458 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2459 struct hda_codec *codec,
2460 unsigned int stream_tag,
2461 unsigned int format,
2462 struct snd_pcm_substream *substream)
2464 struct sigmatel_spec *spec = codec->spec;
2465 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2468 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2469 struct hda_codec *codec,
2470 struct snd_pcm_substream *substream)
2472 struct sigmatel_spec *spec = codec->spec;
2473 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2477 * Digital playback callbacks
2479 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2480 struct hda_codec *codec,
2481 struct snd_pcm_substream *substream)
2483 struct sigmatel_spec *spec = codec->spec;
2484 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2487 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2488 struct hda_codec *codec,
2489 struct snd_pcm_substream *substream)
2491 struct sigmatel_spec *spec = codec->spec;
2492 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2495 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2496 struct hda_codec *codec,
2497 unsigned int stream_tag,
2498 unsigned int format,
2499 struct snd_pcm_substream *substream)
2501 struct sigmatel_spec *spec = codec->spec;
2502 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2503 stream_tag, format, substream);
2506 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2507 struct hda_codec *codec,
2508 struct snd_pcm_substream *substream)
2510 struct sigmatel_spec *spec = codec->spec;
2511 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2516 * Analog capture callbacks
2518 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2519 struct hda_codec *codec,
2520 unsigned int stream_tag,
2521 unsigned int format,
2522 struct snd_pcm_substream *substream)
2524 struct sigmatel_spec *spec = codec->spec;
2525 hda_nid_t nid = spec->adc_nids[substream->number];
2527 if (spec->powerdown_adcs) {
2529 snd_hda_codec_write(codec, nid, 0,
2530 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2532 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2536 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2537 struct hda_codec *codec,
2538 struct snd_pcm_substream *substream)
2540 struct sigmatel_spec *spec = codec->spec;
2541 hda_nid_t nid = spec->adc_nids[substream->number];
2543 snd_hda_codec_cleanup_stream(codec, nid);
2544 if (spec->powerdown_adcs)
2545 snd_hda_codec_write(codec, nid, 0,
2546 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2550 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2554 /* NID is set in stac92xx_build_pcms */
2556 .open = stac92xx_dig_playback_pcm_open,
2557 .close = stac92xx_dig_playback_pcm_close,
2558 .prepare = stac92xx_dig_playback_pcm_prepare,
2559 .cleanup = stac92xx_dig_playback_pcm_cleanup
2563 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2567 /* NID is set in stac92xx_build_pcms */
2570 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2574 .nid = 0x02, /* NID to query formats and rates */
2576 .open = stac92xx_playback_pcm_open,
2577 .prepare = stac92xx_playback_pcm_prepare,
2578 .cleanup = stac92xx_playback_pcm_cleanup
2582 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2586 .nid = 0x06, /* NID to query formats and rates */
2588 .open = stac92xx_playback_pcm_open,
2589 .prepare = stac92xx_playback_pcm_prepare,
2590 .cleanup = stac92xx_playback_pcm_cleanup
2594 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2597 /* NID + .substreams is set in stac92xx_build_pcms */
2599 .prepare = stac92xx_capture_pcm_prepare,
2600 .cleanup = stac92xx_capture_pcm_cleanup
2604 static int stac92xx_build_pcms(struct hda_codec *codec)
2606 struct sigmatel_spec *spec = codec->spec;
2607 struct hda_pcm *info = spec->pcm_rec;
2609 codec->num_pcms = 1;
2610 codec->pcm_info = info;
2612 info->name = "STAC92xx Analog";
2613 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2614 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2615 spec->multiout.dac_nids[0];
2616 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2617 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2618 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2620 if (spec->alt_switch) {
2623 info->name = "STAC92xx Analog Alt";
2624 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2627 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2630 info->name = "STAC92xx Digital";
2631 info->pcm_type = spec->autocfg.dig_out_type[0];
2632 if (spec->multiout.dig_out_nid) {
2633 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2634 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2636 if (spec->dig_in_nid) {
2637 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2638 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2645 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2647 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2648 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2649 if (pincap & AC_PINCAP_VREF_100)
2650 return AC_PINCTL_VREF_100;
2651 if (pincap & AC_PINCAP_VREF_80)
2652 return AC_PINCTL_VREF_80;
2653 if (pincap & AC_PINCAP_VREF_50)
2654 return AC_PINCTL_VREF_50;
2655 if (pincap & AC_PINCAP_VREF_GRD)
2656 return AC_PINCTL_VREF_GRD;
2660 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2663 snd_hda_codec_write_cache(codec, nid, 0,
2664 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2667 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2669 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2670 struct snd_ctl_elem_value *ucontrol)
2672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2673 struct sigmatel_spec *spec = codec->spec;
2675 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2679 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
2680 unsigned char type);
2682 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2683 struct snd_ctl_elem_value *ucontrol)
2685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2686 struct sigmatel_spec *spec = codec->spec;
2687 int nid = kcontrol->private_value;
2689 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2691 /* check to be sure that the ports are upto date with
2694 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2699 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2701 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2704 struct sigmatel_spec *spec = codec->spec;
2705 int io_idx = kcontrol-> private_value & 0xff;
2707 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2711 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2714 struct sigmatel_spec *spec = codec->spec;
2715 hda_nid_t nid = kcontrol->private_value >> 8;
2716 int io_idx = kcontrol-> private_value & 0xff;
2717 unsigned short val = !!ucontrol->value.integer.value[0];
2719 spec->io_switch[io_idx] = val;
2722 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2724 unsigned int pinctl = AC_PINCTL_IN_EN;
2725 if (io_idx) /* set VREF for mic */
2726 pinctl |= stac92xx_get_vref(codec, nid);
2727 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2730 /* check the auto-mute again: we need to mute/unmute the speaker
2731 * appropriately according to the pin direction
2733 if (spec->hp_detect)
2734 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT);
2739 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2741 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2742 struct snd_ctl_elem_value *ucontrol)
2744 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2745 struct sigmatel_spec *spec = codec->spec;
2747 ucontrol->value.integer.value[0] = spec->clfe_swap;
2751 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2752 struct snd_ctl_elem_value *ucontrol)
2754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2755 struct sigmatel_spec *spec = codec->spec;
2756 hda_nid_t nid = kcontrol->private_value & 0xff;
2757 unsigned int val = !!ucontrol->value.integer.value[0];
2759 if (spec->clfe_swap == val)
2762 spec->clfe_swap = val;
2764 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2765 spec->clfe_swap ? 0x4 : 0x0);
2770 #define STAC_CODEC_HP_SWITCH(xname) \
2771 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2774 .info = stac92xx_hp_switch_info, \
2775 .get = stac92xx_hp_switch_get, \
2776 .put = stac92xx_hp_switch_put, \
2779 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2780 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2783 .info = stac92xx_io_switch_info, \
2784 .get = stac92xx_io_switch_get, \
2785 .put = stac92xx_io_switch_put, \
2786 .private_value = xpval, \
2789 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2790 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2793 .info = stac92xx_clfe_switch_info, \
2794 .get = stac92xx_clfe_switch_get, \
2795 .put = stac92xx_clfe_switch_put, \
2796 .private_value = xpval, \
2800 STAC_CTL_WIDGET_VOL,
2801 STAC_CTL_WIDGET_MUTE,
2802 STAC_CTL_WIDGET_MONO_MUX,
2803 STAC_CTL_WIDGET_AMP_MUX,
2804 STAC_CTL_WIDGET_AMP_VOL,
2805 STAC_CTL_WIDGET_HP_SWITCH,
2806 STAC_CTL_WIDGET_IO_SWITCH,
2807 STAC_CTL_WIDGET_CLFE_SWITCH,
2808 STAC_CTL_WIDGET_DC_BIAS
2811 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2812 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2813 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2816 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2817 STAC_CODEC_HP_SWITCH(NULL),
2818 STAC_CODEC_IO_SWITCH(NULL, 0),
2819 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2820 DC_BIAS(NULL, 0, 0),
2823 /* add dynamic controls */
2824 static struct snd_kcontrol_new *
2825 stac_control_new(struct sigmatel_spec *spec,
2826 struct snd_kcontrol_new *ktemp,
2829 struct snd_kcontrol_new *knew;
2831 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2832 knew = snd_array_new(&spec->kctls);
2836 knew->name = kstrdup(name, GFP_KERNEL);
2839 memset(knew, 0, sizeof(*knew));
2840 spec->kctls.alloced--;
2846 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2847 struct snd_kcontrol_new *ktemp,
2848 int idx, const char *name,
2851 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2855 knew->private_value = val;
2859 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2860 int type, int idx, const char *name,
2863 return stac92xx_add_control_temp(spec,
2864 &stac92xx_control_templates[type],
2869 /* add dynamic controls */
2870 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2871 const char *name, unsigned long val)
2873 return stac92xx_add_control_idx(spec, type, 0, name, val);
2876 static struct snd_kcontrol_new stac_input_src_temp = {
2877 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2878 .name = "Input Source",
2879 .info = stac92xx_mux_enum_info,
2880 .get = stac92xx_mux_enum_get,
2881 .put = stac92xx_mux_enum_put,
2884 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2886 struct snd_kcontrol_new *knew;
2887 struct hda_input_mux *imux = &spec->private_imux;
2889 if (!spec->num_adcs || imux->num_items <= 1)
2890 return 0; /* no need for input source control */
2891 knew = stac_control_new(spec, &stac_input_src_temp,
2892 stac_input_src_temp.name);
2895 knew->count = spec->num_adcs;
2899 /* check whether the line-input can be used as line-out */
2900 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2902 struct sigmatel_spec *spec = codec->spec;
2903 struct auto_pin_cfg *cfg = &spec->autocfg;
2905 unsigned int pincap;
2907 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2909 nid = cfg->input_pins[AUTO_PIN_LINE];
2910 pincap = snd_hda_query_pin_caps(codec, nid);
2911 if (pincap & AC_PINCAP_OUT)
2916 /* check whether the mic-input can be used as line-out */
2917 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2919 struct sigmatel_spec *spec = codec->spec;
2920 struct auto_pin_cfg *cfg = &spec->autocfg;
2921 unsigned int def_conf, pincap;
2922 unsigned int mic_pin;
2924 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2926 mic_pin = AUTO_PIN_MIC;
2928 hda_nid_t nid = cfg->input_pins[mic_pin];
2929 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2930 /* some laptops have an internal analog microphone
2931 * which can't be used as a output */
2932 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2933 pincap = snd_hda_query_pin_caps(codec, nid);
2934 if (pincap & AC_PINCAP_OUT)
2937 if (mic_pin == AUTO_PIN_MIC)
2938 mic_pin = AUTO_PIN_FRONT_MIC;
2945 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2949 for (i = 0; i < spec->multiout.num_dacs; i++) {
2950 if (spec->multiout.dac_nids[i] == nid)
2957 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2960 if (is_in_dac_nids(spec, nid))
2962 for (i = 0; i < spec->autocfg.hp_outs; i++)
2963 if (spec->hp_dacs[i] == nid)
2965 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2966 if (spec->speaker_dacs[i] == nid)
2971 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2973 struct sigmatel_spec *spec = codec->spec;
2975 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2976 unsigned int wcaps, wtype;
2978 conn_len = snd_hda_get_connections(codec, nid, conn,
2979 HDA_MAX_CONNECTIONS);
2980 for (j = 0; j < conn_len; j++) {
2981 wcaps = get_wcaps(codec, conn[j]);
2982 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2983 /* we check only analog outputs */
2984 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2986 /* if this route has a free DAC, assign it */
2987 if (!check_all_dac_nids(spec, conn[j])) {
2989 /* select this DAC in the pin's input mux */
2990 snd_hda_codec_write_cache(codec, nid, 0,
2991 AC_VERB_SET_CONNECT_SEL, j);
2996 /* if all DACs are already assigned, connect to the primary DAC */
2998 for (j = 0; j < conn_len; j++) {
2999 if (conn[j] == spec->multiout.dac_nids[0]) {
3000 snd_hda_codec_write_cache(codec, nid, 0,
3001 AC_VERB_SET_CONNECT_SEL, j);
3009 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3010 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3013 * Fill in the dac_nids table from the parsed pin configuration
3014 * This function only works when every pin in line_out_pins[]
3015 * contains atleast one DAC in its connection list. Some 92xx
3016 * codecs are not connected directly to a DAC, such as the 9200
3017 * and 9202/925x. For those, dac_nids[] must be hard-coded.
3019 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
3021 struct sigmatel_spec *spec = codec->spec;
3022 struct auto_pin_cfg *cfg = &spec->autocfg;
3026 for (i = 0; i < cfg->line_outs; i++) {
3027 nid = cfg->line_out_pins[i];
3028 dac = get_unassigned_dac(codec, nid);
3030 if (spec->multiout.num_dacs > 0) {
3031 /* we have already working output pins,
3032 * so let's drop the broken ones again
3034 cfg->line_outs = spec->multiout.num_dacs;
3037 /* error out, no available DAC found */
3039 "%s: No available DAC for pin 0x%x\n",
3043 add_spec_dacs(spec, dac);
3046 for (i = 0; i < cfg->hp_outs; i++) {
3047 nid = cfg->hp_pins[i];
3048 dac = get_unassigned_dac(codec, nid);
3050 if (!spec->multiout.hp_nid)
3051 spec->multiout.hp_nid = dac;
3053 add_spec_extra_dacs(spec, dac);
3055 spec->hp_dacs[i] = dac;
3058 for (i = 0; i < cfg->speaker_outs; i++) {
3059 nid = cfg->speaker_pins[i];
3060 dac = get_unassigned_dac(codec, nid);
3062 add_spec_extra_dacs(spec, dac);
3063 spec->speaker_dacs[i] = dac;
3066 /* add line-in as output */
3067 nid = check_line_out_switch(codec);
3069 dac = get_unassigned_dac(codec, nid);
3071 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3072 nid, cfg->line_outs);
3073 cfg->line_out_pins[cfg->line_outs] = nid;
3075 spec->line_switch = nid;
3076 add_spec_dacs(spec, dac);
3079 /* add mic as output */
3080 nid = check_mic_out_switch(codec);
3082 dac = get_unassigned_dac(codec, nid);
3084 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3085 nid, cfg->line_outs);
3086 cfg->line_out_pins[cfg->line_outs] = nid;
3088 spec->mic_switch = nid;
3089 add_spec_dacs(spec, dac);
3093 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3094 spec->multiout.num_dacs,
3095 spec->multiout.dac_nids[0],
3096 spec->multiout.dac_nids[1],
3097 spec->multiout.dac_nids[2],
3098 spec->multiout.dac_nids[3],
3099 spec->multiout.dac_nids[4]);
3104 /* create volume control/switch for the given prefx type */
3105 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3106 int idx, hda_nid_t nid, int chs)
3108 struct sigmatel_spec *spec = codec->spec;
3112 if (!spec->check_volume_offset) {
3113 unsigned int caps, step, nums, db_scale;
3114 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3115 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3116 AC_AMPCAP_STEP_SIZE_SHIFT;
3117 step = (step + 1) * 25; /* in .01dB unit */
3118 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3119 AC_AMPCAP_NUM_STEPS_SHIFT;
3120 db_scale = nums * step;
3121 /* if dB scale is over -64dB, and finer enough,
3122 * let's reduce it to half
3124 if (db_scale > 6400 && nums >= 0x1f)
3125 spec->volume_offset = nums / 2;
3126 spec->check_volume_offset = 1;
3129 sprintf(name, "%s Playback Volume", pfx);
3130 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
3131 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3132 spec->volume_offset));
3135 sprintf(name, "%s Playback Switch", pfx);
3136 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
3137 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3143 #define create_controls(codec, pfx, nid, chs) \
3144 create_controls_idx(codec, pfx, 0, nid, chs)
3146 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3148 if (spec->multiout.num_dacs > 4) {
3149 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3152 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3153 spec->multiout.num_dacs++;
3158 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3161 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3162 if (!spec->multiout.extra_out_nid[i]) {
3163 spec->multiout.extra_out_nid[i] = nid;
3167 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3171 /* Create output controls
3172 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3174 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3175 const hda_nid_t *pins,
3176 const hda_nid_t *dac_nids,
3179 struct sigmatel_spec *spec = codec->spec;
3180 static const char *chname[4] = {
3181 "Front", "Surround", NULL /*CLFE*/, "Side"
3185 unsigned int wid_caps;
3187 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3188 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3189 wid_caps = get_wcaps(codec, pins[i]);
3190 if (wid_caps & AC_WCAP_UNSOL_CAP)
3191 spec->hp_detect = 1;
3196 if (type != AUTO_PIN_HP_OUT && i == 2) {
3198 err = create_controls(codec, "Center", nid, 1);
3201 err = create_controls(codec, "LFE", nid, 2);
3205 wid_caps = get_wcaps(codec, nid);
3207 if (wid_caps & AC_WCAP_LR_SWAP) {
3208 err = stac92xx_add_control(spec,
3209 STAC_CTL_WIDGET_CLFE_SWITCH,
3210 "Swap Center/LFE Playback Switch", nid);
3220 case AUTO_PIN_HP_OUT:
3224 case AUTO_PIN_SPEAKER_OUT:
3233 err = create_controls_idx(codec, name, idx, nid, 3);
3241 /* add playback controls from the parsed DAC table */
3242 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3243 const struct auto_pin_cfg *cfg)
3245 struct sigmatel_spec *spec = codec->spec;
3248 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3249 spec->multiout.dac_nids,
3250 cfg->line_out_type);
3254 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3255 err = stac92xx_add_control(spec,
3256 STAC_CTL_WIDGET_HP_SWITCH,
3257 "Headphone as Line Out Switch",
3258 cfg->hp_pins[cfg->hp_outs - 1]);
3263 if (spec->line_switch) {
3264 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
3265 "Line In as Output Switch",
3266 spec->line_switch << 8);
3271 if (spec->mic_switch) {
3272 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_DC_BIAS,
3282 /* add playback controls for Speaker and HP outputs */
3283 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3284 struct auto_pin_cfg *cfg)
3286 struct sigmatel_spec *spec = codec->spec;
3289 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3290 spec->hp_dacs, AUTO_PIN_HP_OUT);
3294 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3295 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3302 /* labels for mono mux outputs */
3303 static const char *stac92xx_mono_labels[4] = {
3304 "DAC0", "DAC1", "Mixer", "DAC2"
3307 /* create mono mux for mono out on capable codecs */
3308 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3310 struct sigmatel_spec *spec = codec->spec;
3311 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3313 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3315 num_cons = snd_hda_get_connections(codec,
3318 HDA_MAX_NUM_INPUTS);
3319 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3322 for (i = 0; i < num_cons; i++) {
3323 mono_mux->items[mono_mux->num_items].label =
3324 stac92xx_mono_labels[i];
3325 mono_mux->items[mono_mux->num_items].index = i;
3326 mono_mux->num_items++;
3329 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3330 "Mono Mux", spec->mono_nid);
3333 /* labels for amp mux outputs */
3334 static const char *stac92xx_amp_labels[3] = {
3335 "Front Microphone", "Microphone", "Line In",
3338 /* create amp out controls mux on capable codecs */
3339 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3341 struct sigmatel_spec *spec = codec->spec;
3342 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3345 for (i = 0; i < spec->num_amps; i++) {
3346 amp_mux->items[amp_mux->num_items].label =
3347 stac92xx_amp_labels[i];
3348 amp_mux->items[amp_mux->num_items].index = i;
3349 amp_mux->num_items++;
3352 if (spec->num_amps > 1) {
3353 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3354 "Amp Selector Capture Switch", 0);
3358 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3359 "Amp Capture Volume",
3360 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3364 /* create PC beep volume controls */
3365 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3368 struct sigmatel_spec *spec = codec->spec;
3369 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3372 /* check for mute support for the the amp */
3373 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3374 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3375 "PC Beep Playback Switch",
3376 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3381 /* check to see if there is volume support for the amp */
3382 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3383 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3384 "PC Beep Playback Volume",
3385 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3392 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3393 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3395 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3396 struct snd_ctl_elem_value *ucontrol)
3398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3399 ucontrol->value.integer.value[0] = codec->beep->enabled;
3403 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3404 struct snd_ctl_elem_value *ucontrol)
3406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3407 int enabled = !!ucontrol->value.integer.value[0];
3408 if (codec->beep->enabled != enabled) {
3409 codec->beep->enabled = enabled;
3415 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3417 .info = stac92xx_dig_beep_switch_info,
3418 .get = stac92xx_dig_beep_switch_get,
3419 .put = stac92xx_dig_beep_switch_put,
3422 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3424 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3425 0, "PC Beep Playback Switch", 0);
3429 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3431 struct sigmatel_spec *spec = codec->spec;
3432 int wcaps, nid, i, err = 0;
3434 for (i = 0; i < spec->num_muxes; i++) {
3435 nid = spec->mux_nids[i];
3436 wcaps = get_wcaps(codec, nid);
3438 if (wcaps & AC_WCAP_OUT_AMP) {
3439 err = stac92xx_add_control_idx(spec,
3440 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3441 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3449 static const char *stac92xx_spdif_labels[3] = {
3450 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3453 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3455 struct sigmatel_spec *spec = codec->spec;
3456 struct hda_input_mux *spdif_mux = &spec->private_smux;
3457 const char **labels = spec->spdif_labels;
3459 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3461 num_cons = snd_hda_get_connections(codec,
3464 HDA_MAX_NUM_INPUTS);
3469 labels = stac92xx_spdif_labels;
3471 for (i = 0; i < num_cons; i++) {
3472 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3473 spdif_mux->items[spdif_mux->num_items].index = i;
3474 spdif_mux->num_items++;
3480 /* labels for dmic mux inputs */
3481 static const char *stac92xx_dmic_labels[5] = {
3482 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3483 "Digital Mic 3", "Digital Mic 4"
3486 /* create playback/capture controls for input pins on dmic capable codecs */
3487 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3488 const struct auto_pin_cfg *cfg)
3490 struct sigmatel_spec *spec = codec->spec;
3491 struct hda_input_mux *dimux = &spec->private_dimux;
3492 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3496 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3497 dimux->items[dimux->num_items].index = 0;
3500 for (i = 0; i < spec->num_dmics; i++) {
3505 unsigned int def_conf;
3507 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3508 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3511 nid = spec->dmic_nids[i];
3512 num_cons = snd_hda_get_connections(codec,
3515 HDA_MAX_NUM_INPUTS);
3516 for (j = 0; j < num_cons; j++)
3517 if (con_lst[j] == nid) {
3523 wcaps = get_wcaps(codec, nid) &
3524 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3527 sprintf(name, "%s Capture Volume",
3528 stac92xx_dmic_labels[dimux->num_items]);
3530 err = stac92xx_add_control(spec,
3531 STAC_CTL_WIDGET_VOL,
3533 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3534 (wcaps & AC_WCAP_OUT_AMP) ?
3535 HDA_OUTPUT : HDA_INPUT));
3540 dimux->items[dimux->num_items].label =
3541 stac92xx_dmic_labels[dimux->num_items];
3542 dimux->items[dimux->num_items].index = index;
3549 /* create playback/capture controls for input pins */
3550 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3552 struct sigmatel_spec *spec = codec->spec;
3553 struct hda_input_mux *imux = &spec->private_imux;
3554 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3557 for (i = 0; i < AUTO_PIN_LAST; i++) {
3560 if (!cfg->input_pins[i])
3563 for (j = 0; j < spec->num_muxes; j++) {
3565 num_cons = snd_hda_get_connections(codec,
3568 HDA_MAX_NUM_INPUTS);
3569 for (k = 0; k < num_cons; k++)
3570 if (con_lst[k] == cfg->input_pins[i]) {
3577 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3578 imux->items[imux->num_items].index = index;
3582 if (imux->num_items) {
3584 * Set the current input for the muxes.
3585 * The STAC9221 has two input muxes with identical source
3586 * NID lists. Hopefully this won't get confused.
3588 for (i = 0; i < spec->num_muxes; i++) {
3589 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3590 AC_VERB_SET_CONNECT_SEL,
3591 imux->items[0].index);
3598 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3600 struct sigmatel_spec *spec = codec->spec;
3603 for (i = 0; i < spec->autocfg.line_outs; i++) {
3604 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3605 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3609 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3611 struct sigmatel_spec *spec = codec->spec;
3614 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3616 pin = spec->autocfg.hp_pins[i];
3617 if (pin) /* connect to front */
3618 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3620 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3622 pin = spec->autocfg.speaker_pins[i];
3623 if (pin) /* connect to front */
3624 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3628 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3630 struct sigmatel_spec *spec = codec->spec;
3634 if ((err = snd_hda_parse_pin_def_config(codec,
3636 spec->dmic_nids)) < 0)
3638 if (! spec->autocfg.line_outs)
3639 return 0; /* can't find valid pin config */
3641 /* If we have no real line-out pin and multiple hp-outs, HPs should
3642 * be set up as multi-channel outputs.
3644 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3645 spec->autocfg.hp_outs > 1) {
3646 /* Copy hp_outs to line_outs, backup line_outs in
3647 * speaker_outs so that the following routines can handle
3648 * HP pins as primary outputs.
3650 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3651 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3652 sizeof(spec->autocfg.line_out_pins));
3653 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3654 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3655 sizeof(spec->autocfg.hp_pins));
3656 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3657 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3658 spec->autocfg.hp_outs = 0;
3661 if (spec->autocfg.mono_out_pin) {
3662 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3663 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3664 u32 caps = query_amp_caps(codec,
3665 spec->autocfg.mono_out_pin, dir);
3666 hda_nid_t conn_list[1];
3668 /* get the mixer node and then the mono mux if it exists */
3669 if (snd_hda_get_connections(codec,
3670 spec->autocfg.mono_out_pin, conn_list, 1) &&
3671 snd_hda_get_connections(codec, conn_list[0],
3674 int wcaps = get_wcaps(codec, conn_list[0]);
3675 int wid_type = (wcaps & AC_WCAP_TYPE)
3676 >> AC_WCAP_TYPE_SHIFT;
3677 /* LR swap check, some stac925x have a mux that
3678 * changes the DACs output path instead of the
3681 if (wid_type == AC_WID_AUD_SEL &&
3682 !(wcaps & AC_WCAP_LR_SWAP))
3683 spec->mono_nid = conn_list[0];
3686 hda_nid_t nid = spec->autocfg.mono_out_pin;
3688 /* most mono outs have a least a mute/unmute switch */
3689 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3690 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3691 "Mono Playback Switch",
3692 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3695 /* check for volume support for the amp */
3696 if ((caps & AC_AMPCAP_NUM_STEPS)
3697 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3698 err = stac92xx_add_control(spec,
3699 STAC_CTL_WIDGET_VOL,
3700 "Mono Playback Volume",
3701 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3707 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3711 if (!spec->multiout.num_dacs) {
3712 err = stac92xx_auto_fill_dac_nids(codec);
3715 err = stac92xx_auto_create_multi_out_ctls(codec,
3721 /* setup analog beep controls */
3722 if (spec->anabeep_nid > 0) {
3723 err = stac92xx_auto_create_beep_ctls(codec,
3729 /* setup digital beep controls and input device */
3730 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3731 if (spec->digbeep_nid > 0) {
3732 hda_nid_t nid = spec->digbeep_nid;
3735 err = stac92xx_auto_create_beep_ctls(codec, nid);
3738 err = snd_hda_attach_beep_device(codec, nid);
3741 /* IDT/STAC codecs have linear beep tone parameter */
3742 codec->beep->linear_tone = 1;
3743 /* if no beep switch is available, make its own one */
3744 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3746 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3747 err = stac92xx_beep_switch_ctl(codec);
3754 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3758 /* All output parsing done, now restore the swapped hp pins */
3760 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3761 sizeof(spec->autocfg.hp_pins));
3762 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3763 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3764 spec->autocfg.line_outs = 0;
3767 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3771 if (spec->mono_nid > 0) {
3772 err = stac92xx_auto_create_mono_output_ctls(codec);
3776 if (spec->num_amps > 0) {
3777 err = stac92xx_auto_create_amp_output_ctls(codec);
3781 if (spec->num_dmics > 0 && !spec->dinput_mux)
3782 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3783 &spec->autocfg)) < 0)
3785 if (spec->num_muxes > 0) {
3786 err = stac92xx_auto_create_mux_input_ctls(codec);
3790 if (spec->num_smuxes > 0) {
3791 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3796 err = stac92xx_add_input_source(spec);
3800 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3801 if (spec->multiout.max_channels > 2)
3802 spec->surr_switch = 1;
3804 if (spec->autocfg.dig_outs)
3805 spec->multiout.dig_out_nid = dig_out;
3806 if (dig_in && spec->autocfg.dig_in_pin)
3807 spec->dig_in_nid = dig_in;
3809 if (spec->kctls.list)
3810 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3812 spec->input_mux = &spec->private_imux;
3813 if (!spec->dinput_mux)
3814 spec->dinput_mux = &spec->private_dimux;
3815 spec->sinput_mux = &spec->private_smux;
3816 spec->mono_mux = &spec->private_mono_mux;
3817 spec->amp_mux = &spec->private_amp_mux;
3821 /* add playback controls for HP output */
3822 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3823 struct auto_pin_cfg *cfg)
3825 struct sigmatel_spec *spec = codec->spec;
3826 hda_nid_t pin = cfg->hp_pins[0];
3827 unsigned int wid_caps;
3832 wid_caps = get_wcaps(codec, pin);
3833 if (wid_caps & AC_WCAP_UNSOL_CAP)
3834 spec->hp_detect = 1;
3839 /* add playback controls for LFE output */
3840 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3841 struct auto_pin_cfg *cfg)
3843 struct sigmatel_spec *spec = codec->spec;
3845 hda_nid_t lfe_pin = 0x0;
3849 * search speaker outs and line outs for a mono speaker pin
3850 * with an amp. If one is found, add LFE controls
3853 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3854 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3855 unsigned int wcaps = get_wcaps(codec, pin);
3856 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3857 if (wcaps == AC_WCAP_OUT_AMP)
3858 /* found a mono speaker with an amp, must be lfe */
3862 /* if speaker_outs is 0, then speakers may be in line_outs */
3863 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3864 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3865 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3866 unsigned int defcfg;
3867 defcfg = snd_hda_codec_get_pincfg(codec, pin);
3868 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3869 unsigned int wcaps = get_wcaps(codec, pin);
3870 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3871 if (wcaps == AC_WCAP_OUT_AMP)
3872 /* found a mono speaker with an amp,
3880 err = create_controls(codec, "LFE", lfe_pin, 1);
3888 static int stac9200_parse_auto_config(struct hda_codec *codec)
3890 struct sigmatel_spec *spec = codec->spec;
3893 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3896 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3899 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3902 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3905 if (spec->num_muxes > 0) {
3906 err = stac92xx_auto_create_mux_input_ctls(codec);
3911 err = stac92xx_add_input_source(spec);
3915 if (spec->autocfg.dig_outs)
3916 spec->multiout.dig_out_nid = 0x05;
3917 if (spec->autocfg.dig_in_pin)
3918 spec->dig_in_nid = 0x04;
3920 if (spec->kctls.list)
3921 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3923 spec->input_mux = &spec->private_imux;
3924 spec->dinput_mux = &spec->private_dimux;
3930 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3931 * funky external mute control using GPIO pins.
3934 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3935 unsigned int dir_mask, unsigned int data)
3937 unsigned int gpiostate, gpiomask, gpiodir;
3939 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3940 AC_VERB_GET_GPIO_DATA, 0);
3941 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3943 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3944 AC_VERB_GET_GPIO_MASK, 0);
3947 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3948 AC_VERB_GET_GPIO_DIRECTION, 0);
3949 gpiodir |= dir_mask;
3951 /* Configure GPIOx as CMOS */
3952 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3954 snd_hda_codec_write(codec, codec->afg, 0,
3955 AC_VERB_SET_GPIO_MASK, gpiomask);
3956 snd_hda_codec_read(codec, codec->afg, 0,
3957 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3961 snd_hda_codec_read(codec, codec->afg, 0,
3962 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3965 #ifdef CONFIG_SND_JACK
3966 static void stac92xx_free_jack_priv(struct snd_jack *jack)
3968 struct sigmatel_jack *jacks = jack->private_data;
3974 static int stac92xx_add_jack(struct hda_codec *codec,
3975 hda_nid_t nid, int type)
3977 #ifdef CONFIG_SND_JACK
3978 struct sigmatel_spec *spec = codec->spec;
3979 struct sigmatel_jack *jack;
3980 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
3981 int connectivity = get_defcfg_connect(def_conf);
3985 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
3988 snd_array_init(&spec->jacks, sizeof(*jack), 32);
3989 jack = snd_array_new(&spec->jacks);
3995 sprintf(name, "%s at %s %s Jack",
3996 snd_hda_get_jack_type(def_conf),
3997 snd_hda_get_jack_connectivity(def_conf),
3998 snd_hda_get_jack_location(def_conf));
4000 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4005 jack->jack->private_data = jack;
4006 jack->jack->private_free = stac92xx_free_jack_priv;
4011 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4012 unsigned char type, int data)
4014 struct sigmatel_event *event;
4016 snd_array_init(&spec->events, sizeof(*event), 32);
4017 event = snd_array_new(&spec->events);
4022 event->tag = spec->events.used;
4028 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4029 hda_nid_t nid, unsigned char type)
4031 struct sigmatel_spec *spec = codec->spec;
4032 struct sigmatel_event *event = spec->events.list;
4035 for (i = 0; i < spec->events.used; i++, event++) {
4036 if (event->nid == nid && event->type == type)
4042 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4045 struct sigmatel_spec *spec = codec->spec;
4046 struct sigmatel_event *event = spec->events.list;
4049 for (i = 0; i < spec->events.used; i++, event++) {
4050 if (event->tag == tag)
4056 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4059 struct sigmatel_event *event;
4062 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4064 event = stac_get_event(codec, nid, type);
4068 tag = stac_add_event(codec->spec, nid, type, 0);
4071 snd_hda_codec_write_cache(codec, nid, 0,
4072 AC_VERB_SET_UNSOLICITED_ENABLE,
4076 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4079 for (i = 0; i < cfg->hp_outs; i++)
4080 if (cfg->hp_pins[i] == nid)
4081 return 1; /* nid is a HP-Out */
4083 return 0; /* nid is not a HP-Out */
4086 static void stac92xx_power_down(struct hda_codec *codec)
4088 struct sigmatel_spec *spec = codec->spec;
4090 /* power down inactive DACs */
4092 for (dac = spec->dac_list; *dac; dac++)
4093 if (!check_all_dac_nids(spec, *dac))
4094 snd_hda_codec_write(codec, *dac, 0,
4095 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4098 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4101 /* override some hints from the hwdep entry */
4102 static void stac_store_hints(struct hda_codec *codec)
4104 struct sigmatel_spec *spec = codec->spec;
4108 val = snd_hda_get_bool_hint(codec, "hp_detect");
4110 spec->hp_detect = val;
4111 p = snd_hda_get_hint(codec, "gpio_mask");
4113 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4114 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4117 p = snd_hda_get_hint(codec, "gpio_dir");
4119 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4120 p = snd_hda_get_hint(codec, "gpio_data");
4122 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4123 p = snd_hda_get_hint(codec, "eapd_mask");
4125 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4126 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4128 spec->eapd_switch = val;
4131 static int stac92xx_init(struct hda_codec *codec)
4133 struct sigmatel_spec *spec = codec->spec;
4134 struct auto_pin_cfg *cfg = &spec->autocfg;
4138 snd_hda_sequence_write(codec, spec->init);
4140 /* power down adcs initially */
4141 if (spec->powerdown_adcs)
4142 for (i = 0; i < spec->num_adcs; i++)
4143 snd_hda_codec_write(codec,
4144 spec->adc_nids[i], 0,
4145 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4147 /* override some hints */
4148 stac_store_hints(codec);
4151 gpio = spec->gpio_data;
4152 /* turn on EAPD statically when spec->eapd_switch isn't set.
4153 * otherwise, unsol event will turn it on/off dynamically
4155 if (!spec->eapd_switch)
4156 gpio |= spec->eapd_mask;
4157 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4160 if (spec->hp_detect) {
4161 /* Enable unsolicited responses on the HP widget */
4162 for (i = 0; i < cfg->hp_outs; i++) {
4163 hda_nid_t nid = cfg->hp_pins[i];
4164 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4166 /* force to enable the first line-out; the others are set up
4169 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4171 /* fake event to set up pins */
4172 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4175 stac92xx_auto_init_multi_out(codec);
4176 stac92xx_auto_init_hp_out(codec);
4177 for (i = 0; i < cfg->hp_outs; i++)
4178 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4180 for (i = 0; i < AUTO_PIN_LAST; i++) {
4181 hda_nid_t nid = cfg->input_pins[i];
4183 unsigned int pinctl, conf;
4184 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4185 /* for mic pins, force to initialize */
4186 pinctl = stac92xx_get_vref(codec, nid);
4187 pinctl |= AC_PINCTL_IN_EN;
4188 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4190 pinctl = snd_hda_codec_read(codec, nid, 0,
4191 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4192 /* if PINCTL already set then skip */
4193 /* Also, if both INPUT and OUTPUT are set,
4194 * it must be a BIOS bug; need to override, too
4196 if (!(pinctl & AC_PINCTL_IN_EN) ||
4197 (pinctl & AC_PINCTL_OUT_EN)) {
4198 pinctl &= ~AC_PINCTL_OUT_EN;
4199 pinctl |= AC_PINCTL_IN_EN;
4200 stac92xx_auto_set_pinctl(codec, nid,
4204 conf = snd_hda_codec_get_pincfg(codec, nid);
4205 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4206 enable_pin_detect(codec, nid,
4208 stac_issue_unsol_event(codec, nid,
4213 for (i = 0; i < spec->num_dmics; i++)
4214 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4216 if (cfg->dig_out_pins[0])
4217 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4219 if (cfg->dig_in_pin)
4220 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4222 for (i = 0; i < spec->num_pwrs; i++) {
4223 hda_nid_t nid = spec->pwr_nids[i];
4224 int pinctl, def_conf;
4226 /* power on when no jack detection is available */
4227 if (!spec->hp_detect) {
4228 stac_toggle_power_map(codec, nid, 1);
4232 if (is_nid_hp_pin(cfg, nid))
4233 continue; /* already has an unsol event */
4235 pinctl = snd_hda_codec_read(codec, nid, 0,
4236 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4237 /* outputs are only ports capable of power management
4238 * any attempts on powering down a input port cause the
4239 * referenced VREF to act quirky.
4241 if (pinctl & AC_PINCTL_IN_EN) {
4242 stac_toggle_power_map(codec, nid, 1);
4245 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4246 def_conf = get_defcfg_connect(def_conf);
4247 /* skip any ports that don't have jacks since presence
4248 * detection is useless */
4249 if (def_conf != AC_JACK_PORT_COMPLEX) {
4250 if (def_conf != AC_JACK_PORT_NONE)
4251 stac_toggle_power_map(codec, nid, 1);
4254 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) {
4255 enable_pin_detect(codec, nid, STAC_PWR_EVENT);
4256 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4260 stac92xx_power_down(codec);
4264 static void stac92xx_free_jacks(struct hda_codec *codec)
4266 #ifdef CONFIG_SND_JACK
4267 /* free jack instances manually when clearing/reconfiguring */
4268 struct sigmatel_spec *spec = codec->spec;
4269 if (!codec->bus->shutdown && spec->jacks.list) {
4270 struct sigmatel_jack *jacks = spec->jacks.list;
4272 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4274 snd_device_free(codec->bus->card, jacks->jack);
4277 snd_array_free(&spec->jacks);
4281 static void stac92xx_free_kctls(struct hda_codec *codec)
4283 struct sigmatel_spec *spec = codec->spec;
4285 if (spec->kctls.list) {
4286 struct snd_kcontrol_new *kctl = spec->kctls.list;
4288 for (i = 0; i < spec->kctls.used; i++)
4289 kfree(kctl[i].name);
4291 snd_array_free(&spec->kctls);
4294 static void stac92xx_free(struct hda_codec *codec)
4296 struct sigmatel_spec *spec = codec->spec;
4301 stac92xx_free_jacks(codec);
4302 snd_array_free(&spec->events);
4305 snd_hda_detach_beep_device(codec);
4308 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4311 unsigned int old_ctl, pin_ctl;
4313 pin_ctl = snd_hda_codec_read(codec, nid,
4314 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4316 if (pin_ctl & AC_PINCTL_IN_EN) {
4318 * we need to check the current set-up direction of
4319 * shared input pins since they can be switched via
4320 * "xxx as Output" mixer switch
4322 struct sigmatel_spec *spec = codec->spec;
4323 if (nid == spec->line_switch || nid == spec->mic_switch)
4328 /* if setting pin direction bits, clear the current
4329 direction bits first */
4330 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4331 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4334 if (old_ctl != pin_ctl)
4335 snd_hda_codec_write_cache(codec, nid, 0,
4336 AC_VERB_SET_PIN_WIDGET_CONTROL,
4340 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4343 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4344 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4346 snd_hda_codec_write_cache(codec, nid, 0,
4347 AC_VERB_SET_PIN_WIDGET_CONTROL,
4351 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4355 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
4361 /* return non-zero if the hp-pin of the given array index isn't
4362 * a jack-detection target
4364 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4366 struct auto_pin_cfg *cfg = &spec->autocfg;
4368 /* ignore sensing of shared line and mic jacks */
4369 if (cfg->hp_pins[i] == spec->line_switch)
4371 if (cfg->hp_pins[i] == spec->mic_switch)
4373 /* ignore if the pin is set as line-out */
4374 if (cfg->hp_pins[i] == spec->hp_switch)
4379 static void stac92xx_hp_detect(struct hda_codec *codec)
4381 struct sigmatel_spec *spec = codec->spec;
4382 struct auto_pin_cfg *cfg = &spec->autocfg;
4386 if (spec->gpio_mute)
4387 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4388 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4390 for (i = 0; i < cfg->hp_outs; i++) {
4393 if (no_hp_sensing(spec, i))
4395 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4397 unsigned int pinctl;
4398 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4399 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4400 if (pinctl & AC_PINCTL_IN_EN)
4401 presence = 0; /* mic- or line-input */
4406 /* disable lineouts */
4407 if (spec->hp_switch)
4408 stac92xx_reset_pinctl(codec, spec->hp_switch,
4410 for (i = 0; i < cfg->line_outs; i++)
4411 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4413 for (i = 0; i < cfg->speaker_outs; i++)
4414 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4416 if (spec->eapd_mask && spec->eapd_switch)
4417 stac_gpio_set(codec, spec->gpio_mask,
4418 spec->gpio_dir, spec->gpio_data &
4421 /* enable lineouts */
4422 if (spec->hp_switch)
4423 stac92xx_set_pinctl(codec, spec->hp_switch,
4425 for (i = 0; i < cfg->line_outs; i++)
4426 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4428 for (i = 0; i < cfg->speaker_outs; i++)
4429 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4431 if (spec->eapd_mask && spec->eapd_switch)
4432 stac_gpio_set(codec, spec->gpio_mask,
4433 spec->gpio_dir, spec->gpio_data |
4436 /* toggle hp outs */
4437 for (i = 0; i < cfg->hp_outs; i++) {
4438 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4439 if (no_hp_sensing(spec, i))
4442 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4444 /* Resetting the pinctl like below may lead to (a sort of) regressions
4445 * on some devices since they use the HP pin actually for line/speaker
4446 * outs although the default pin config shows a different pin (that is
4447 * wrong and useless).
4449 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4450 * But, disabling the code below just works around it, and I'm too tired of
4451 * bug reports with such devices...
4454 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4459 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4462 struct sigmatel_spec *spec = codec->spec;
4463 unsigned int idx, val;
4465 for (idx = 0; idx < spec->num_pwrs; idx++) {
4466 if (spec->pwr_nids[idx] == nid)
4469 if (idx >= spec->num_pwrs)
4472 /* several codecs have two power down bits */
4473 if (spec->pwr_mapping)
4474 idx = spec->pwr_mapping[idx];
4478 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4484 /* power down unused output ports */
4485 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4488 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4490 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4493 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4495 struct sigmatel_spec *spec = codec->spec;
4496 struct sigmatel_jack *jacks = spec->jacks.list;
4500 for (i = 0; i < spec->jacks.used; i++) {
4501 if (jacks->nid == nid) {
4502 unsigned int pin_ctl =
4503 snd_hda_codec_read(codec, nid,
4504 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4506 int type = jacks->type;
4507 if (type == (SND_JACK_LINEOUT
4508 | SND_JACK_HEADPHONE))
4509 type = (pin_ctl & AC_PINCTL_HP_EN)
4510 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4511 snd_jack_report(jacks->jack,
4512 get_pin_presence(codec, nid)
4520 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid,
4523 struct sigmatel_event *event = stac_get_event(codec, nid, type);
4526 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4529 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4531 struct sigmatel_spec *spec = codec->spec;
4532 struct sigmatel_event *event;
4535 tag = (res >> 26) & 0x7f;
4536 event = stac_get_event_from_tag(codec, tag);
4540 switch (event->type) {
4542 stac92xx_hp_detect(codec);
4544 case STAC_INSERT_EVENT:
4545 case STAC_PWR_EVENT:
4546 if (spec->num_pwrs > 0)
4547 stac92xx_pin_sense(codec, event->nid);
4548 stac92xx_report_jack(codec, event->nid);
4550 switch (codec->subsystem_id) {
4552 if (event->nid == 0xb) {
4553 int pin = AC_PINCTL_IN_EN;
4555 if (get_pin_presence(codec, 0xa)
4556 && get_pin_presence(codec, 0xb))
4557 pin |= AC_PINCTL_VREF_80;
4558 if (!get_pin_presence(codec, 0xb))
4559 pin |= AC_PINCTL_VREF_80;
4561 /* toggle VREF state based on mic + hp pin
4564 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4568 case STAC_VREF_EVENT:
4569 data = snd_hda_codec_read(codec, codec->afg, 0,
4570 AC_VERB_GET_GPIO_DATA, 0);
4571 /* toggle VREF state based on GPIOx status */
4572 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4573 !!(data & (1 << event->data)));
4578 #ifdef CONFIG_PROC_FS
4579 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4580 struct hda_codec *codec, hda_nid_t nid)
4582 if (nid == codec->afg)
4583 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4584 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4587 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4588 struct hda_codec *codec,
4591 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4592 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4595 /* stac92hd71bxx, stac92hd73xx */
4596 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4597 struct hda_codec *codec, hda_nid_t nid)
4599 stac92hd_proc_hook(buffer, codec, nid);
4600 if (nid == codec->afg)
4601 analog_loop_proc_hook(buffer, codec, 0xfa0);
4604 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4605 struct hda_codec *codec, hda_nid_t nid)
4607 if (nid == codec->afg)
4608 analog_loop_proc_hook(buffer, codec, 0xfe0);
4611 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4612 struct hda_codec *codec, hda_nid_t nid)
4614 if (nid == codec->afg)
4615 analog_loop_proc_hook(buffer, codec, 0xfeb);
4618 #define stac92hd_proc_hook NULL
4619 #define stac92hd7x_proc_hook NULL
4620 #define stac9205_proc_hook NULL
4621 #define stac927x_proc_hook NULL
4624 #ifdef SND_HDA_NEEDS_RESUME
4625 static int stac92xx_resume(struct hda_codec *codec)
4627 struct sigmatel_spec *spec = codec->spec;
4629 stac92xx_init(codec);
4630 snd_hda_codec_resume_amp(codec);
4631 snd_hda_codec_resume_cache(codec);
4632 /* fake event to set up pins again to override cached values */
4633 if (spec->hp_detect)
4634 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0],
4640 * using power check for controlling mute led of HP notebooks
4641 * check for mute state only on Speakers (nid = 0x10)
4643 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4644 * the LED is NOT working properly !
4646 * Changed name to reflect that it now works for any designated
4647 * model, not just HP HDX.
4650 #ifdef CONFIG_SND_HDA_POWER_SAVE
4651 static int stac92xx_hp_check_power_status(struct hda_codec *codec,
4654 struct sigmatel_spec *spec = codec->spec;
4657 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4659 spec->gpio_data |= spec->gpio_led; /* white */
4661 spec->gpio_data &= ~spec->gpio_led; /* orange */
4663 stac_gpio_set(codec, spec->gpio_mask,
4672 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4674 struct sigmatel_spec *spec = codec->spec;
4675 if (spec->eapd_mask)
4676 stac_gpio_set(codec, spec->gpio_mask,
4677 spec->gpio_dir, spec->gpio_data &
4683 static struct hda_codec_ops stac92xx_patch_ops = {
4684 .build_controls = stac92xx_build_controls,
4685 .build_pcms = stac92xx_build_pcms,
4686 .init = stac92xx_init,
4687 .free = stac92xx_free,
4688 .unsol_event = stac92xx_unsol_event,
4689 #ifdef SND_HDA_NEEDS_RESUME
4690 .suspend = stac92xx_suspend,
4691 .resume = stac92xx_resume,
4695 static int patch_stac9200(struct hda_codec *codec)
4697 struct sigmatel_spec *spec;
4700 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4705 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4706 spec->pin_nids = stac9200_pin_nids;
4707 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4710 if (spec->board_config < 0)
4711 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4713 stac92xx_set_config_regs(codec,
4714 stac9200_brd_tbl[spec->board_config]);
4716 spec->multiout.max_channels = 2;
4717 spec->multiout.num_dacs = 1;
4718 spec->multiout.dac_nids = stac9200_dac_nids;
4719 spec->adc_nids = stac9200_adc_nids;
4720 spec->mux_nids = stac9200_mux_nids;
4721 spec->num_muxes = 1;
4722 spec->num_dmics = 0;
4726 if (spec->board_config == STAC_9200_M4 ||
4727 spec->board_config == STAC_9200_M4_2 ||
4728 spec->board_config == STAC_9200_OQO)
4729 spec->init = stac9200_eapd_init;
4731 spec->init = stac9200_core_init;
4732 spec->mixer = stac9200_mixer;
4734 if (spec->board_config == STAC_9200_PANASONIC) {
4735 spec->gpio_mask = spec->gpio_dir = 0x09;
4736 spec->gpio_data = 0x00;
4739 err = stac9200_parse_auto_config(codec);
4741 stac92xx_free(codec);
4745 /* CF-74 has no headphone detection, and the driver should *NOT*
4746 * do detection and HP/speaker toggle because the hardware does it.
4748 if (spec->board_config == STAC_9200_PANASONIC)
4749 spec->hp_detect = 0;
4751 codec->patch_ops = stac92xx_patch_ops;
4756 static int patch_stac925x(struct hda_codec *codec)
4758 struct sigmatel_spec *spec;
4761 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4766 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4767 spec->pin_nids = stac925x_pin_nids;
4769 /* Check first for codec ID */
4770 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4773 stac925x_codec_id_cfg_tbl);
4775 /* Now checks for PCI ID, if codec ID is not found */
4776 if (spec->board_config < 0)
4777 spec->board_config = snd_hda_check_board_config(codec,
4782 if (spec->board_config < 0)
4783 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4784 "using BIOS defaults\n");
4786 stac92xx_set_config_regs(codec,
4787 stac925x_brd_tbl[spec->board_config]);
4789 spec->multiout.max_channels = 2;
4790 spec->multiout.num_dacs = 1;
4791 spec->multiout.dac_nids = stac925x_dac_nids;
4792 spec->adc_nids = stac925x_adc_nids;
4793 spec->mux_nids = stac925x_mux_nids;
4794 spec->num_muxes = 1;
4797 switch (codec->vendor_id) {
4798 case 0x83847632: /* STAC9202 */
4799 case 0x83847633: /* STAC9202D */
4800 case 0x83847636: /* STAC9251 */
4801 case 0x83847637: /* STAC9251D */
4802 spec->num_dmics = STAC925X_NUM_DMICS;
4803 spec->dmic_nids = stac925x_dmic_nids;
4804 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4805 spec->dmux_nids = stac925x_dmux_nids;
4808 spec->num_dmics = 0;
4812 spec->init = stac925x_core_init;
4813 spec->mixer = stac925x_mixer;
4815 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4817 if (spec->board_config < 0) {
4818 printk(KERN_WARNING "hda_codec: No auto-config is "
4819 "available, default to model=ref\n");
4820 spec->board_config = STAC_925x_REF;
4826 stac92xx_free(codec);
4830 codec->patch_ops = stac92xx_patch_ops;
4835 static struct hda_input_mux stac92hd73xx_dmux = {
4838 { "Analog Inputs", 0x0b },
4839 { "Digital Mic 1", 0x09 },
4840 { "Digital Mic 2", 0x0a },
4845 static int patch_stac92hd73xx(struct hda_codec *codec)
4847 struct sigmatel_spec *spec;
4848 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4852 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4857 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4858 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4859 spec->pin_nids = stac92hd73xx_pin_nids;
4860 spec->board_config = snd_hda_check_board_config(codec,
4861 STAC_92HD73XX_MODELS,
4862 stac92hd73xx_models,
4863 stac92hd73xx_cfg_tbl);
4865 if (spec->board_config < 0)
4866 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4867 " STAC92HD73XX, using BIOS defaults\n");
4869 stac92xx_set_config_regs(codec,
4870 stac92hd73xx_brd_tbl[spec->board_config]);
4872 num_dacs = snd_hda_get_connections(codec, 0x0a,
4873 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4875 if (num_dacs < 3 || num_dacs > 5) {
4876 printk(KERN_WARNING "hda_codec: Could not determine "
4877 "number of channels defaulting to DAC count\n");
4878 num_dacs = STAC92HD73_DAC_COUNT;
4881 case 0x3: /* 6 Channel */
4882 spec->mixer = stac92hd73xx_6ch_mixer;
4883 spec->init = stac92hd73xx_6ch_core_init;
4884 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
4886 case 0x4: /* 8 Channel */
4887 spec->mixer = stac92hd73xx_8ch_mixer;
4888 spec->init = stac92hd73xx_8ch_core_init;
4889 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
4891 case 0x5: /* 10 Channel */
4892 spec->mixer = stac92hd73xx_10ch_mixer;
4893 spec->init = stac92hd73xx_10ch_core_init;
4894 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4897 spec->multiout.dac_nids = spec->dac_nids;
4899 spec->aloopback_mask = 0x01;
4900 spec->aloopback_shift = 8;
4902 spec->digbeep_nid = 0x1c;
4903 spec->mux_nids = stac92hd73xx_mux_nids;
4904 spec->adc_nids = stac92hd73xx_adc_nids;
4905 spec->dmic_nids = stac92hd73xx_dmic_nids;
4906 spec->dmux_nids = stac92hd73xx_dmux_nids;
4907 spec->smux_nids = stac92hd73xx_smux_nids;
4908 spec->amp_nids = stac92hd73xx_amp_nids;
4909 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4911 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4912 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4913 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4914 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4915 sizeof(stac92hd73xx_dmux));
4917 switch (spec->board_config) {
4919 spec->init = dell_eq_core_init;
4921 case STAC_DELL_M6_AMIC:
4922 case STAC_DELL_M6_DMIC:
4923 case STAC_DELL_M6_BOTH:
4924 spec->num_smuxes = 0;
4925 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4926 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4927 spec->eapd_switch = 0;
4930 if (spec->board_config != STAC_DELL_EQ)
4931 spec->init = dell_m6_core_init;
4932 switch (spec->board_config) {
4933 case STAC_DELL_M6_AMIC: /* Analog Mics */
4934 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4935 spec->num_dmics = 0;
4936 spec->private_dimux.num_items = 1;
4938 case STAC_DELL_M6_DMIC: /* Digital Mics */
4939 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
4940 spec->num_dmics = 1;
4941 spec->private_dimux.num_items = 2;
4943 case STAC_DELL_M6_BOTH: /* Both */
4944 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4945 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
4946 spec->num_dmics = 1;
4947 spec->private_dimux.num_items = 2;
4952 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4953 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4954 spec->eapd_switch = 1;
4956 if (spec->board_config > STAC_92HD73XX_REF) {
4957 /* GPIO0 High = Enable EAPD */
4958 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4959 spec->gpio_data = 0x01;
4961 spec->dinput_mux = &spec->private_dimux;
4963 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4964 spec->pwr_nids = stac92hd73xx_pwr_nids;
4966 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
4969 if (spec->board_config < 0) {
4970 printk(KERN_WARNING "hda_codec: No auto-config is "
4971 "available, default to model=ref\n");
4972 spec->board_config = STAC_92HD73XX_REF;
4979 stac92xx_free(codec);
4983 if (spec->board_config == STAC_92HD73XX_NO_JD)
4984 spec->hp_detect = 0;
4986 codec->patch_ops = stac92xx_patch_ops;
4988 codec->proc_widget_hook = stac92hd7x_proc_hook;
4993 static struct hda_input_mux stac92hd83xxx_dmux = {
4996 { "Analog Inputs", 0x03 },
4997 { "Digital Mic 1", 0x04 },
4998 { "Digital Mic 2", 0x05 },
5002 static int patch_stac92hd83xxx(struct hda_codec *codec)
5004 struct sigmatel_spec *spec;
5005 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
5010 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5015 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5016 spec->mono_nid = 0x19;
5017 spec->digbeep_nid = 0x21;
5018 spec->dmic_nids = stac92hd83xxx_dmic_nids;
5019 spec->dmux_nids = stac92hd83xxx_dmux_nids;
5020 spec->adc_nids = stac92hd83xxx_adc_nids;
5021 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5022 spec->amp_nids = stac92hd83xxx_amp_nids;
5023 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5024 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5025 spec->multiout.dac_nids = spec->dac_nids;
5027 spec->init = stac92hd83xxx_core_init;
5028 spec->mixer = stac92hd83xxx_mixer;
5029 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5030 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
5031 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5032 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
5033 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
5034 spec->dinput_mux = &stac92hd83xxx_dmux;
5035 spec->pin_nids = stac92hd83xxx_pin_nids;
5036 spec->board_config = snd_hda_check_board_config(codec,
5037 STAC_92HD83XXX_MODELS,
5038 stac92hd83xxx_models,
5039 stac92hd83xxx_cfg_tbl);
5041 if (spec->board_config < 0)
5042 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5043 " STAC92HD83XXX, using BIOS defaults\n");
5045 stac92xx_set_config_regs(codec,
5046 stac92hd83xxx_brd_tbl[spec->board_config]);
5048 switch (codec->vendor_id) {
5052 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5058 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5060 if (spec->board_config < 0) {
5061 printk(KERN_WARNING "hda_codec: No auto-config is "
5062 "available, default to model=ref\n");
5063 spec->board_config = STAC_92HD83XXX_REF;
5070 stac92xx_free(codec);
5074 switch (spec->board_config) {
5083 num_dacs = snd_hda_get_connections(codec, nid,
5084 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5086 /* set port X to select the last DAC
5088 snd_hda_codec_write_cache(codec, nid, 0,
5089 AC_VERB_SET_CONNECT_SEL, num_dacs);
5091 codec->patch_ops = stac92xx_patch_ops;
5093 codec->proc_widget_hook = stac92hd_proc_hook;
5098 static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
5101 { "Analog Inputs", 0x00 },
5102 { "Digital Mic 1", 0x02 },
5103 { "Digital Mic 2", 0x03 },
5107 static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
5110 { "Analog Inputs", 0x00 },
5112 { "Digital Mic 1", 0x02 },
5113 { "Digital Mic 2", 0x03 },
5117 /* get the pin connection (fixed, none, etc) */
5118 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5120 struct sigmatel_spec *spec = codec->spec;
5123 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5124 return get_defcfg_connect(cfg);
5127 static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5128 hda_nid_t *nids, int num_nids)
5130 struct sigmatel_spec *spec = codec->spec;
5132 unsigned int def_conf;
5134 for (num = 0; num < num_nids; num++) {
5135 for (idx = 0; idx < spec->num_pins; idx++)
5136 if (spec->pin_nids[idx] == nids[num])
5138 if (idx >= spec->num_pins)
5140 def_conf = stac_get_defcfg_connect(codec, idx);
5141 if (def_conf == AC_JACK_PORT_NONE)
5147 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5150 struct sigmatel_spec *spec = codec->spec;
5153 for (idx = 0; idx < spec->num_pins; idx++)
5154 if (spec->pin_nids[idx] == dig0pin)
5156 if ((idx + 2) >= spec->num_pins)
5160 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5163 /* dig0pin + dig2pin case */
5164 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5166 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5172 static int patch_stac92hd71bxx(struct hda_codec *codec)
5174 struct sigmatel_spec *spec;
5175 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5177 unsigned int ndmic_nids = 0;
5179 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5184 codec->patch_ops = stac92xx_patch_ops;
5185 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5186 switch (codec->vendor_id) {
5189 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5193 /* On 92HD75Bx 0x27 isn't a pin nid */
5197 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5199 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5200 spec->board_config = snd_hda_check_board_config(codec,
5201 STAC_92HD71BXX_MODELS,
5202 stac92hd71bxx_models,
5203 stac92hd71bxx_cfg_tbl);
5205 if (spec->board_config < 0)
5206 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5207 " STAC92HD71BXX, using BIOS defaults\n");
5209 stac92xx_set_config_regs(codec,
5210 stac92hd71bxx_brd_tbl[spec->board_config]);
5212 if (spec->board_config > STAC_92HD71BXX_REF) {
5214 spec->gpio_mask = 0x01;
5215 spec->gpio_dir = 0x01;
5216 spec->gpio_data = 0x01;
5219 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5220 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5222 switch (codec->vendor_id) {
5223 case 0x111d76b6: /* 4 Port without Analog Mixer */
5227 case 0x111d76b4: /* 6 Port without Analog Mixer */
5229 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
5230 sizeof(stac92hd71bxx_dmux_nomixer));
5231 spec->mixer = stac92hd71bxx_mixer;
5232 spec->init = stac92hd71bxx_core_init;
5233 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5234 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5235 stac92hd71bxx_dmic_nids,
5236 STAC92HD71BXX_NUM_DMICS);
5237 if (spec->num_dmics) {
5238 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5239 spec->dinput_mux = &spec->private_dimux;
5240 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5243 case 0x111d7608: /* 5 Port with Analog Mixer */
5244 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5245 sizeof(stac92hd71bxx_dmux_amixer));
5246 spec->private_dimux.num_items--;
5247 switch (spec->board_config) {
5249 /* Enable VREF power saving on GPIO1 detect */
5250 err = stac_add_event(spec, codec->afg,
5251 STAC_VREF_EVENT, 0x02);
5254 snd_hda_codec_write_cache(codec, codec->afg, 0,
5255 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5256 snd_hda_codec_write_cache(codec, codec->afg, 0,
5257 AC_VERB_SET_UNSOLICITED_ENABLE,
5259 spec->gpio_mask |= 0x02;
5262 if ((codec->revision_id & 0xf) == 0 ||
5263 (codec->revision_id & 0xf) == 1)
5264 spec->stream_delay = 40; /* 40 milliseconds */
5266 /* no output amps */
5268 spec->mixer = stac92hd71bxx_analog_mixer;
5269 spec->dinput_mux = &spec->private_dimux;
5272 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
5274 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5275 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5276 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5277 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5278 stac92hd71bxx_dmic_nids,
5279 STAC92HD71BXX_NUM_DMICS - 1);
5280 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5281 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
5283 case 0x111d7603: /* 6 Port with Analog Mixer */
5284 if ((codec->revision_id & 0xf) == 1)
5285 spec->stream_delay = 40; /* 40 milliseconds */
5287 /* no output amps */
5291 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5292 sizeof(stac92hd71bxx_dmux_amixer));
5293 spec->dinput_mux = &spec->private_dimux;
5294 spec->mixer = stac92hd71bxx_analog_mixer;
5295 spec->init = stac92hd71bxx_analog_core_init;
5296 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5297 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5298 stac92hd71bxx_dmic_nids,
5299 STAC92HD71BXX_NUM_DMICS);
5300 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5301 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5304 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5305 snd_hda_sequence_write_cache(codec, unmute_init);
5307 spec->aloopback_ctl = stac92hd71bxx_loopback;
5308 spec->aloopback_mask = 0x50;
5309 spec->aloopback_shift = 0;
5311 spec->powerdown_adcs = 1;
5312 spec->digbeep_nid = 0x26;
5313 spec->mux_nids = stac92hd71bxx_mux_nids;
5314 spec->adc_nids = stac92hd71bxx_adc_nids;
5315 spec->smux_nids = stac92hd71bxx_smux_nids;
5316 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5318 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5319 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5320 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5322 switch (spec->board_config) {
5324 /* enable internal microphone */
5325 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5326 stac92xx_auto_set_pinctl(codec, 0x0e,
5327 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5329 case STAC_DELL_M4_2:
5330 spec->num_dmics = 0;
5331 spec->num_smuxes = 0;
5332 spec->num_dmuxes = 0;
5334 case STAC_DELL_M4_1:
5335 case STAC_DELL_M4_3:
5336 spec->num_dmics = 1;
5337 spec->num_smuxes = 0;
5338 spec->num_dmuxes = 1;
5340 case STAC_HP_DV4_1222NR:
5341 spec->num_dmics = 1;
5342 /* I don't know if it needs 1 or 2 smuxes - will wait for
5343 * bug reports to fix if needed
5345 spec->num_smuxes = 1;
5346 spec->num_dmuxes = 1;
5347 spec->gpio_led = 0x01;
5350 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5351 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5354 spec->num_dmics = 1;
5355 spec->num_dmuxes = 1;
5356 spec->num_smuxes = 1;
5357 /* orange/white mute led on GPIO3, orange=0, white=1 */
5358 spec->gpio_led = 0x08;
5362 #ifdef CONFIG_SND_HDA_POWER_SAVE
5363 if (spec->gpio_led) {
5364 spec->gpio_mask |= spec->gpio_led;
5365 spec->gpio_dir |= spec->gpio_led;
5366 spec->gpio_data |= spec->gpio_led;
5367 /* register check_power_status callback. */
5368 codec->patch_ops.check_power_status =
5369 stac92xx_hp_check_power_status;
5373 spec->multiout.dac_nids = spec->dac_nids;
5374 if (spec->dinput_mux)
5375 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
5377 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5379 if (spec->board_config < 0) {
5380 printk(KERN_WARNING "hda_codec: No auto-config is "
5381 "available, default to model=ref\n");
5382 spec->board_config = STAC_92HD71BXX_REF;
5389 stac92xx_free(codec);
5393 codec->proc_widget_hook = stac92hd7x_proc_hook;
5398 static int patch_stac922x(struct hda_codec *codec)
5400 struct sigmatel_spec *spec;
5403 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5408 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5409 spec->pin_nids = stac922x_pin_nids;
5410 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5413 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5414 spec->gpio_mask = spec->gpio_dir = 0x03;
5415 spec->gpio_data = 0x03;
5416 /* Intel Macs have all same PCI SSID, so we need to check
5417 * codec SSID to distinguish the exact models
5419 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5420 switch (codec->subsystem_id) {
5423 spec->board_config = STAC_INTEL_MAC_V1;
5427 spec->board_config = STAC_INTEL_MAC_V2;
5435 spec->board_config = STAC_INTEL_MAC_V3;
5439 spec->board_config = STAC_INTEL_MAC_V4;
5443 spec->board_config = STAC_INTEL_MAC_V5;
5446 spec->board_config = STAC_INTEL_MAC_V3;
5452 if (spec->board_config < 0)
5453 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5454 "using BIOS defaults\n");
5456 stac92xx_set_config_regs(codec,
5457 stac922x_brd_tbl[spec->board_config]);
5459 spec->adc_nids = stac922x_adc_nids;
5460 spec->mux_nids = stac922x_mux_nids;
5461 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5462 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5463 spec->num_dmics = 0;
5466 spec->init = stac922x_core_init;
5467 spec->mixer = stac922x_mixer;
5469 spec->multiout.dac_nids = spec->dac_nids;
5471 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5473 if (spec->board_config < 0) {
5474 printk(KERN_WARNING "hda_codec: No auto-config is "
5475 "available, default to model=ref\n");
5476 spec->board_config = STAC_D945_REF;
5482 stac92xx_free(codec);
5486 codec->patch_ops = stac92xx_patch_ops;
5488 /* Fix Mux capture level; max to 2 */
5489 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5490 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5491 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5492 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5493 (0 << AC_AMPCAP_MUTE_SHIFT));
5498 static int patch_stac927x(struct hda_codec *codec)
5500 struct sigmatel_spec *spec;
5503 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5508 codec->slave_dig_outs = stac927x_slave_dig_outs;
5509 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5510 spec->pin_nids = stac927x_pin_nids;
5511 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5515 if (spec->board_config < 0)
5516 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5517 "STAC927x, using BIOS defaults\n");
5519 stac92xx_set_config_regs(codec,
5520 stac927x_brd_tbl[spec->board_config]);
5522 spec->digbeep_nid = 0x23;
5523 spec->adc_nids = stac927x_adc_nids;
5524 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5525 spec->mux_nids = stac927x_mux_nids;
5526 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5527 spec->smux_nids = stac927x_smux_nids;
5528 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5529 spec->spdif_labels = stac927x_spdif_labels;
5530 spec->dac_list = stac927x_dac_nids;
5531 spec->multiout.dac_nids = spec->dac_nids;
5533 switch (spec->board_config) {
5536 /* GPIO0 High = Enable EAPD */
5537 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
5538 spec->gpio_data = 0x01;
5539 spec->num_dmics = 0;
5541 spec->init = d965_core_init;
5542 spec->mixer = stac927x_mixer;
5544 case STAC_DELL_BIOS:
5545 switch (codec->subsystem_id) {
5548 /* correct the device field to SPDIF out */
5549 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5552 /* configure the analog microphone on some laptops */
5553 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5554 /* correct the front output jack as a hp out */
5555 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5556 /* correct the front input jack as a mic */
5557 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5560 /* GPIO2 High = Enable EAPD */
5561 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
5562 spec->gpio_data = 0x04;
5563 spec->dmic_nids = stac927x_dmic_nids;
5564 spec->num_dmics = STAC927X_NUM_DMICS;
5566 spec->init = d965_core_init;
5567 spec->mixer = stac927x_mixer;
5568 spec->dmux_nids = stac927x_dmux_nids;
5569 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5572 if (spec->board_config > STAC_D965_REF) {
5573 /* GPIO0 High = Enable EAPD */
5574 spec->eapd_mask = spec->gpio_mask = 0x01;
5575 spec->gpio_dir = spec->gpio_data = 0x01;
5577 spec->num_dmics = 0;
5579 spec->init = stac927x_core_init;
5580 spec->mixer = stac927x_mixer;
5584 spec->aloopback_ctl = stac927x_loopback;
5585 spec->aloopback_mask = 0x40;
5586 spec->aloopback_shift = 0;
5587 spec->eapd_switch = 1;
5589 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
5591 if (spec->board_config < 0) {
5592 printk(KERN_WARNING "hda_codec: No auto-config is "
5593 "available, default to model=ref\n");
5594 spec->board_config = STAC_D965_REF;
5600 stac92xx_free(codec);
5604 codec->patch_ops = stac92xx_patch_ops;
5606 codec->proc_widget_hook = stac927x_proc_hook;
5610 * The STAC927x seem to require fairly long delays for certain
5611 * command sequences. With too short delays (even if the answer
5612 * is set to RIRB properly), it results in the silence output
5613 * on some hardwares like Dell.
5615 * The below flag enables the longer delay (see get_response
5618 codec->bus->needs_damn_long_delay = 1;
5620 /* no jack detecion for ref-no-jd model */
5621 if (spec->board_config == STAC_D965_REF_NO_JD)
5622 spec->hp_detect = 0;
5627 static int patch_stac9205(struct hda_codec *codec)
5629 struct sigmatel_spec *spec;
5632 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5637 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
5638 spec->pin_nids = stac9205_pin_nids;
5639 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5643 if (spec->board_config < 0)
5644 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5646 stac92xx_set_config_regs(codec,
5647 stac9205_brd_tbl[spec->board_config]);
5649 spec->digbeep_nid = 0x23;
5650 spec->adc_nids = stac9205_adc_nids;
5651 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
5652 spec->mux_nids = stac9205_mux_nids;
5653 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
5654 spec->smux_nids = stac9205_smux_nids;
5655 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
5656 spec->dmic_nids = stac9205_dmic_nids;
5657 spec->num_dmics = STAC9205_NUM_DMICS;
5658 spec->dmux_nids = stac9205_dmux_nids;
5659 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
5662 spec->init = stac9205_core_init;
5663 spec->mixer = stac9205_mixer;
5664 spec->aloopback_ctl = stac9205_loopback;
5666 spec->aloopback_mask = 0x40;
5667 spec->aloopback_shift = 0;
5668 /* Turn on/off EAPD per HP plugging */
5669 if (spec->board_config != STAC_9205_EAPD)
5670 spec->eapd_switch = 1;
5671 spec->multiout.dac_nids = spec->dac_nids;
5673 switch (spec->board_config){
5674 case STAC_9205_DELL_M43:
5675 /* Enable SPDIF in/out */
5676 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5677 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
5679 /* Enable unsol response for GPIO4/Dock HP connection */
5680 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5683 snd_hda_codec_write_cache(codec, codec->afg, 0,
5684 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5685 snd_hda_codec_write_cache(codec, codec->afg, 0,
5686 AC_VERB_SET_UNSOLICITED_ENABLE,
5689 spec->gpio_dir = 0x0b;
5690 spec->eapd_mask = 0x01;
5691 spec->gpio_mask = 0x1b;
5692 spec->gpio_mute = 0x10;
5693 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5696 spec->gpio_data = 0x01;
5699 /* SPDIF-In enabled */
5702 /* GPIO0 High = EAPD */
5703 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5704 spec->gpio_data = 0x01;
5708 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5710 if (spec->board_config < 0) {
5711 printk(KERN_WARNING "hda_codec: No auto-config is "
5712 "available, default to model=ref\n");
5713 spec->board_config = STAC_9205_REF;
5719 stac92xx_free(codec);
5723 codec->patch_ops = stac92xx_patch_ops;
5725 codec->proc_widget_hook = stac9205_proc_hook;
5734 static struct hda_verb stac9872_core_init[] = {
5735 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5736 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5740 static struct snd_kcontrol_new stac9872_mixer[] = {
5741 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5742 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5746 static hda_nid_t stac9872_pin_nids[] = {
5747 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5751 static hda_nid_t stac9872_adc_nids[] = {
5755 static hda_nid_t stac9872_mux_nids[] = {
5759 static unsigned int stac9872_vaio_pin_configs[9] = {
5760 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5761 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5765 static const char *stac9872_models[STAC_9872_MODELS] = {
5766 [STAC_9872_AUTO] = "auto",
5767 [STAC_9872_VAIO] = "vaio",
5770 static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5771 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5774 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5778 static int patch_stac9872(struct hda_codec *codec)
5780 struct sigmatel_spec *spec;
5783 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5788 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5791 if (spec->board_config < 0)
5792 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, "
5793 "using BIOS defaults\n");
5795 stac92xx_set_config_regs(codec,
5796 stac9872_brd_tbl[spec->board_config]);
5798 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5799 spec->pin_nids = stac9872_pin_nids;
5800 spec->multiout.dac_nids = spec->dac_nids;
5801 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5802 spec->adc_nids = stac9872_adc_nids;
5803 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5804 spec->mux_nids = stac9872_mux_nids;
5805 spec->mixer = stac9872_mixer;
5806 spec->init = stac9872_core_init;
5808 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5810 stac92xx_free(codec);
5813 spec->input_mux = &spec->private_imux;
5814 codec->patch_ops = stac92xx_patch_ops;
5822 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5823 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5824 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5825 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5826 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5827 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5828 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5829 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5830 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5831 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5832 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5833 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5834 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5835 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5836 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5837 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5838 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5839 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5840 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5841 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5842 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5843 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5844 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5845 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5846 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5847 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5848 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5849 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5850 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5851 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5852 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5853 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5854 /* The following does not take into account .id=0x83847661 when subsys =
5855 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5856 * currently not fully supported.
5858 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5859 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5860 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5861 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5862 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5863 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5864 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5865 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5866 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5867 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5868 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5869 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5870 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5871 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5872 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
5873 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5874 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5875 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5876 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5877 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5878 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5879 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5880 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5881 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5882 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5883 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5884 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5888 MODULE_ALIAS("snd-hda-codec-id:8384*");
5889 MODULE_ALIAS("snd-hda-codec-id:111d*");
5891 MODULE_LICENSE("GPL");
5892 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5894 static struct hda_codec_preset_list sigmatel_list = {
5895 .preset = snd_hda_preset_sigmatel,
5896 .owner = THIS_MODULE,
5899 static int __init patch_sigmatel_init(void)
5901 return snd_hda_add_codec_preset(&sigmatel_list);
5904 static void __exit patch_sigmatel_exit(void)
5906 snd_hda_delete_codec_preset(&sigmatel_list);
5909 module_init(patch_sigmatel_init)
5910 module_exit(patch_sigmatel_exit)